Harryxun/stf_run huggingface dataset:
from collections import defaultdict
N, M = map(int, input().split())  # ちょうどN桁, M個のクエリ
correspondence = defaultdict(set)
for _ in range(M):
    s, c = map(int, input().split())
    correspondence[s].add(c)
# print(correspondence)
for k, v in correspondence.items():  # 要素が複数あったら-1を出力
    if len(v) > 1:
        print(-1)
        exit()

# correspondence = dict(sorted(correspondence.items(), key=lambda x: x[0]))
# print(correspondence)
ans = ""
for i in range(1, N+1):
    if i in correspondence.keys():
        ans += str(list(correspondence[i])[0])
    else:
        ans += "0"
if ans[0] == "0":
    ans = list(ans)
    ans[0] = "1"
    ans = "".join(ans)

if list(correspondence[1])[0] == 0:
    print(-1)
else:
    print(ans)


### FIXED CODE ###

from collections import defaultdict
N, M = map(int, input().split())  # ちょうどN桁, M個のクエリ
correspondence = defaultdict(set)
for _ in range(M):
    s, c = map(int, input().split())
    correspondence[s].add(c)
# print(correspondence)
if M == 0:
    if N == 1:
        print(0)
        exit()
    print("1"+"0"*(N-1))
    exit()
for k, v in correspondence.items():  # 要素が複数あったら-1を出力
    if len(v) > 1:
        print(-1)
        exit()
ans = ""
for i in range(1, N+1):
    if i in correspondence.keys():  # 指定があるならばそれにする
        ans += str(list(correspondence[i])[0])
    else:
        ans += "0"  # ないならば0にする
if ans[0] == "0":
    ans = list(ans)
    ans[0] = "1"
    ans = "".join(ans)

if N == 1 and 1 in correspondence.keys():
    print(list(correspondence[1])[0])
    exit()

if 1 in correspondence.keys() and list(correspondence[1])[0] == 0:  # 1桁目が0に指定されているなら終わり
    print(-1)
else:
    print(ans)
n = int(input())
a = list(map(int,input().split()))
b = list(a[i]-i-1 for i in range(n))
b.sort()

def sadness(x,y):
  s = 0
  for i in range(len(y)):
    s += abs(y[i]-x)
  return s

if n%2 == 0:
  print(sadness(a[n/2],b))
else:
  print(sadness(a[(n-1)/2],b))


  
  
  

### FIXED CODE ###

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

def sadness(x,y):
  s = 0
  for i in range(len(y)):
    s += abs(y[i]-x)
  return s

if n%2 == 0:
  print(sadness(b[int(n/2)],b))
else:
  print(sadness(b[int((n-1)/2)],b))
S = input()

MOD = 10 ** 9 + 7
N = len(S)
dp = [[0] * 4 for _ in range(N + 1)]
dp[-1][-1] = 1

for i in reversed(range(N)):
    m = 3 if S[i] == '?' else 1
    for j in reversed(range(3)):
        dp[i][j] = m * dp[i + 1][j]
        if S[i] == '?' or S[i] == 'ABC'[j]:
            dp[i][j] += m2 * dp[i + 1][j + 1]
        dp[i][j] %= MOD
    
    # j == 3
    dp[i][3] = m * dp[i + 1][3] % MOD
            
print(dp[0][0] % MOD)



### FIXED CODE ###

S = input()

MOD = 10 ** 9 + 7
N = len(S)
dp = [[0] * 4 for _ in range(N + 1)]
dp[-1][-1] = 1

for i in reversed(range(N)):
    m = 3 if S[i] == '?' else 1
    for j in reversed(range(3)):
        dp[i][j] = m * dp[i + 1][j]
        if S[i] == '?' or S[i] == 'ABC'[j]:
            dp[i][j] += dp[i + 1][j + 1]
        dp[i][j] %= MOD
    
    # j == 3
    dp[i][3] = m * dp[i + 1][3] % MOD
            
print(dp[0][0] % MOD)
l = input().split()
l = list(map(int, l))

if l[2]-l[4] >=0 and l[3]-l[4] >=0 and l[2]+l[4] <=l[0] and l[3]+l[4] <=l[1]:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

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

if l[2]-l[4] >=0 and l[3]-l[4] >=0 and l[2]+l[4] <=l[0] and l[3]+l[4] <=l[1]:
    print("Yes")
else:
    print("No")
#!/usr/bin/env python3
import sys


def solve(N: int, a: "List[int]"):
    dpmin = [[None] * (N + 1) for _ in range(N + 1)]
    dpmax = [[None] * (N + 1) for _ in range(N + 1)]
    for i in range(N):
        dpmin[i][i] = dpmax[i][i] = 0
        dpmin[i][i + 1] = -a[i]
        dpmax[i][i + 1] = a[i]
    dpmin[N][N] = dpmax[N][N] = 0

    def minimize(a, begin, end):
        x = dpmin[begin][end]
        if x is not None:
            return x
        pt1 = -a[begin] + maximize(a, begin + 1, end)
        pt2 = -a[end - 1] + maximize(a, begin, end - 1)
        r = min(pt1, pt2)
        dpmin[begin][end] = r
        return r

    def maximize(a, begin, end):
        x = dpmax[begin][end]
        if x is not None:
            return x
        pt1 = a[begin] + minimize(a, begin + 1, end)
        pt2 = a[end - 1] + minimize(a, begin, end - 1)
        r = max(pt1, pt2)
        dpmax[begin][end] = r
        return r

    return maximize(a, 0, N)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    print(solve(N, a))


if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys

sys.setrecursionlimit(10 ** 8)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def solve(N: int, a: "List[int]"):
    N1 = N + 1
    dpmin = [-1] * N1 ** 2
    dpmax = [-1] * N1 ** 2
    for i in range(N1):
        dpmin[0 * N1 + i] = dpmax[0 * N1 + i] = 0
    for i in range(N):
        dpmin[1 * N1 + i] = -a[i]
        dpmax[1 * N1 + i] = a[i]
    for k in range(2, N1):
        for i in range(N - k + 1):
            dpmin[k * N1 + i] = min(
                -a[i] + dpmax[(k - 1) * N1 + i + 1],
                -a[i + k - 1] + dpmax[(k - 1) * N1 + i],
            )
            r = -1
            dpmax[k * N1 + i] = max(
                a[i] + dpmin[(k - 1) * N1 + i + 1],
                a[i + k - 1] + dpmin[(k - 1) * N1 + i],
            )
    return dpmax[N * N1]


def main():
    N = int(readline())  # type: int
    a = [int(x) for x in readline().split()]  # type: "List[int]"
    print(solve(N, a))


if __name__ == "__main__":
    main()
import math
x1, y1, x2, y2 = map(int, input().split())

diffx = x1 - x2
diffy = y1 - y2

len_of_v = int((diffx ** 2 + diffy ** 2) ** 0.5)

if diffx == 0:
    x3 = x2 + diffy
    x4 = x1 + diffy
    y3 = y2
    y4 = y1
else:
    grad = diffy / diffx
    counter_grad = -1 / grad

    x3 = x2 + diffy
    y3 = y2 + diffy * counter_grad

    x4 = x1 + diffy
    y4 = y1 + diffy * counter_grad

print(int(x3), round(y3), int(x4), int(y4))



### FIXED CODE ###

import math
x1, y1, x2, y2 = map(int, input().split())

diffx = x1 - x2
diffy = y1 - y2

len_of_v = int((diffx ** 2 + diffy ** 2) ** 0.5)

if diffx == 0:
    x3 = x2 + diffy
    x4 = x1 + diffy
    y3 = y2
    y4 = y1
elif diffy == 0:
    x3 = x2
    x4 = x1
    y3 = y2 - diffx
    y4 = y1 - diffx
else:
    grad = diffy / diffx
    counter_grad = -1 / grad

    x3 = x2 + diffy
    y3 = y2 + diffy * counter_grad

    x4 = x1 + diffy
    y4 = y1 + diffy * counter_grad

print(round(x3), round(y3), round(x4), round(y4))
s = input()
K = int(input())

sub = set()
for i in range(1, len(s) + 1):
    for k in range(int(len(s) / i) + 1):
        sub.add(s[k:i + k])

print(sorted([i for i in sub])[1:][K])


### FIXED CODE ###

s = input()
K = int(input())

sub = set()
for i in range(1, K + 1):
    for k in range(len(s) - i + 1):
        sub.add(s[k:i + k])

print(sorted([i for i in sub])[K - 1])
a, b, c, d = list(map(int,input().split(" ")))

ac_r = a % c
ad_r = a % d
acd_r = a % (c*d)

if (ac_r == 0 and n % c == 1) or ((ac_r == 0 and n % c == 2) or (ac_r == 2 and n % c == 2)) :
    n_c = (b - a + 1) // c + 1
else:
    n_c = (b - a + 1) // c
    
if (ad_r == 0 and n % d == 1) or ((ad_r == 0 and n % d == 2) or (ad_r == 2 and n % d == 2)):
    n_d = (b - a + 1) // d + 1
else:
    n_d = (b - a + 1) // d
    
if (acd_r == 0 and n % (c*d) == 1) or ((acd_r == 0 and n % (c*d) == 2) or (acd_r == 2 and n % (c*d) == 2)):
    n_cd = (b - a + 1) // (c*d) + 1
else:
    n_cd = (b - a + 1) // (c*d)
    
print((b - a + 1) - (n_c + n_d - n_cd))    

### FIXED CODE ###

def gcd(a, b):
    return a if b == 0 else gcd(b, a%b)
 
def lcm(a, b):
    return a // gcd(a, b) * b

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

n = b - a + 1
n_c = b//c - (a-1)//c
n_d = b//d - (a-1)//d
n_cd = b//lcm(c,d) - (a-1)//lcm(c,d)

print(n - n_c - n_d + n_cd)
n = int(input())
x = list(input())
for i in range(n,1,-1):
  if x[i]==x[i-1]:
    x.pop(i)
print(len(x))

### FIXED CODE ###

n = int(input())
x = list(input())
count = n
for i in range(n-1):
  if x[i]==x[i+1]:
    count-=1
print(count)
X, Y, Z, K = map(int, input().split())
A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))
C_list = list(map(int, input().split()))

A_list.sort(reverse=True)
B_list.sort(reverse=True)
C_list.sort(reverse=True)

F_list = []
for i in range(1, X+1):
  if i > K:
    break
  for j in range(1, Y+1):
    if i*j > K:
      break
    for k in range(1, Z+1):
      if i*j*k > K:
        break
      F_list.append(A_list[i]+B_list[j]+C_list[k])

F_list.sort(reverse=True)

for i in range(K):
  print(F_list[i])

### FIXED CODE ###

X, Y, Z, K = map(int, input().split())
A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))
C_list = list(map(int, input().split()))

A_list.sort(reverse=True)
B_list.sort(reverse=True)
C_list.sort(reverse=True)

F_list = []
for i in range(1, X+1):
  if i > K:
    break
  for j in range(1, Y+1):
    if i*j > K:
      break
    for k in range(1, Z+1):
      if i*j*k > K:
        break
      F_list.append(A_list[i-1]+B_list[j-1]+C_list[k-1])

F_list.sort(reverse=True)

for i in range(K):
  print(F_list[i])
arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(arr[k+1])

### FIXED CODE ###

arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(arr[k-1])
import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, K, S = map(int, read().split())

S_half = [S // 2, S - S // 2]

ans = []
for _ in range(N // 2 + 1):
    ans += S_half
ans = np.array(ans[:N])
i = 0
cnt = 0
for i in range(N):
    if cnt == K:
        ans[i:N] = S - 1
        idx = i
        break
    if sum(ans[i:i + 2]) == S:
        cnt += 1
        continue

if ans[idx - 1:idx + 1].sum() != S:
    for s_ in S_half:
        if ans[idx - 1] + s_ == S:
            ans[idx] = s_

print(*ans)


### FIXED CODE ###

import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

N, K, S = map(int, read().split())

if S != 1:
    ans = [S - 1] * N
else:
    ans = [S + 1] * N
for i in range(K):
    ans[i] = S

print(*ans)
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

_,p = [list(map(int, s.split())) for s in open(0)]
lcm = reduce(lcm_base, p)
x = 1e9 + 7
ans = 0
for q in p:
    ans += int((lcm/q)%x)
print(int(ans%x))

### FIXED CODE ###

from fractions import gcd
from functools import reduce

#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

def lcm_mod(a, mod=-1):
    x = a[0]
    if mod == -1:
        for i in range(1, len(a)):
            x = (x * a[i]) // gcd(x, a[i])
    else:
        for i in range(1, len(a)):
            x *= (a[i] * mod_inv(gcd(x, a[i]), P)) % P
    return x

_,a = [list(map(int, s.split())) for s in open(0)]

P = 10**9 + 7
N = max(a)

lcm_ = lcm_mod(a, P)

ans = 0
for x in a:
    ans += int((lcm_*mod_inv(x,P))%P)
print(int(ans%P))
# # C - Lower
N = int(input())
H = list(map(int, input().split()))
count = []

for i in range(N):
    count_i = 0
    for j in range(i,N-1):
        if H[j] - H[j+1] >= 0:
            count_i += 1
            if j+1 == N-1:
                count.append(count_i)
            else:
                pass
        else:
            count.append(count_i)
            break

print(max(count))

### FIXED CODE ###

# C - Lower
N = int(input())
H = list(map(int, input().split()))
max = 0
count_i = 0
for i in range(N-1):
    if H[i] >= H[i+1]:
        count_i += 1
    else:
        if max > count_i:
            count_i = 0
        else:
            max = count_i
            count_i = 0

    if max > count_i:
        pass
    else:
        max = count_i
print(max)
h,w=map(int,input().split())
a={}
for i in range(26):
  a[chr(i+97)]=0
for i in range(h):
  s=input()
  for j in s:
    a[j]+=1
if h==1 and w==1:print("Yes")
elif h==1 or w==1:
  cnt=0
  for i in a.values():
    if i%2==1:cnt+=1
  if cnt!=1:print("No")
  else:print("Yes")
elif h%2==0 and w%2==0:
  for i in a.values():
    if i%4!=0:print("No");exit()
  print("Yes")
elif h%2==1 and w%2==0:
  cnt=0
  for i in a.values():
    if i%4==1 or i%4==3:
      print("No");exit()
    if i%4==2:cnt+=1
  if cnt>w//2:
    print("No")
  else:print("Yes")
elif h%2==0 and w%2==1:
  cnt=0
  for i in a.values():
    if i%4==1 or i%4==3:
      print("No");exit()
    if i%4==2:cnt+=1
  if cnt>h//2:
    print("No")
  else:print("Yes")
else:
  cnt3=0;cnt2=0;cnt1=0
  for i in a.values():
    if i%4==1:cnt1+=1
    elif i%4==2:cnt2+=1
    elif i%4==3:cnt3+=1
  rem=1-cnt1
  elif cnt1+cnt3!=1:print("No")
  elif cnt2+cnt3>h+w-2:print("No")
  else:
    print("Yes")


### FIXED CODE ###

h,w=map(int,input().split())
a={}
for i in range(26):
  a[chr(i+97)]=0
for i in range(h):
  s=input()
  for j in s:
    a[j]+=1
if h==1 and w==1:print("Yes")
elif h%2==0 and w%2==0:
  for i in a.values():
    if i%4!=0:print("No");exit()
  print("Yes")
elif h%2==1 and w%2==0:
  cnt=0
  for i in a.values():
    if i%4==1 or i%4==3:
      print("No");exit()
    if i%4==2:cnt+=1
  if cnt>w//2:
    print("No")
  else:print("Yes")
elif h%2==0 and w%2==1:
  cnt=0
  for i in a.values():
    if i%4==1 or i%4==3:
      print("No");exit()
    if i%4==2:cnt+=1
  if cnt>h//2:
    print("No")
  else:print("Yes")
else:
  cnt3=0;cnt2=0;cnt1=0
  for i in a.values():
    if i%4==1:cnt1+=1
    elif i%4==2:cnt2+=1
    elif i%4==3:cnt3+=1
  if cnt1+cnt3!=1:print("No")
  elif cnt2+cnt3>(h-1)//2+(w-1)//2:print("No")
  else:
    print("Yes")
a = [[j for j in map(int,input().split())] for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]

for i in range(3):
    for j in range(3):
        for k in range(n):
            if a[i][j] == b[k]:
                a[i][j] = 0

if sum(a[0,:]) == 0 or sum(a[1,:]) == 0 or sum(a[2,:]) == 0:
    print('Yes')
elif sum(a[:,0]) == 0 or sum(a[:,1]) == 0 or sum(a[:,2]) == 0:
    print('Yes')
elif (a[0][0] + a[1][1] + a[2][2]) == 0 or (a[0][2] + a[1][1] + a[2][0]) == 0:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

import numpy as np
a = [[j for j in map(int,input().split())] for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]

for i in range(3):
    for j in range(3):
        for k in range(n):
            if a[i][j] == b[k]:
                a[i][j] = 0
a = np.array(a)
if sum(a[0,:]) == 0 or sum(a[1,:]) == 0 or sum(a[2,:]) == 0:
    print('Yes')
elif sum(a[:,0]) == 0 or sum(a[:,1]) == 0 or sum(a[:,2]) == 0:
    print('Yes')
elif (a[0][0] + a[1][1] + a[2][2]) == 0 or (a[0][2] + a[1][1] + a[2][0]) == 0:
    print('Yes')
else:
    print('No')
N=int(input())
H=list(map(int,input().split()))
ans=0
for i in range(len(H)):
    if i==1:
        ans+=1
    elif max(H[1:i-1])<=H[i]:
        ans+=1
print(ans)

### FIXED CODE ###

N=int(input())
H=list(map(int,input().split()))
ans=0
for i in range(len(H)):
    if i==0:
        ans+=1
    elif max(H[0:i])<=H[i]:
        ans+=1
print(ans)
N, M = map(int, input().split())
a = [0]*N
for i in range(M):
    s, c = map(int, input().split())
    d = a[s-1]
    if s == 1 and c == 0:
        print("-1")
        break
    if d != 0:
        a[s-1] = min(c, d)
    else:
        a[s-1] = c
if M == 0:
    if N == 1:
        print(0)
    elif N == 2:
        print(10)
    else:
        print(100)
else:
    if a[0] == 0:
        a[1] = 1
        print(*a, sep="") 
    else:
        print(*a, sep="") 

### FIXED CODE ###

N, M = map(int, input().split())
A=[]
for j in range(M):
    s, c = map(int, input().split())
    A.append([s-1, str(c)])
if N == 1:
    b = 0
elif N == 2:
    b= 10
else:
    b = 100
ans=[]
for i in range(b, 1000):
    a = 0
    for j in range(M):
        x=str(i)
        if len(x) < N:
            break 
        if A[j][1] == x[A[j][0]]:
            a += 1
    if a == M:
        ans.append(i)
if ans == []:
    print(-1)
else:
    print(min(ans))
import sys
 
n = sys.stdin.readline()
 
last = int(n[-1])
 
result = ''
if last in [0,1,6,8]:
    result = 'pon'
elif last == 3:
    result = 'bon'
else:
    result = 'hon'
 
print(result)

### FIXED CODE ###

n = input()
 
last = int(n[-1])
 
result = ''
if last in [0,1,6,8]:
    result = 'pon'
elif last == 3:
    result = 'bon'
else:
    result = 'hon'
 
print(result)
n = int(input())
h = list(map(int, input().split()))
a = []
ans = []
for i in range(n-1):
  if h[i] < h[i+1]:
    a.append(i+1)

ans.append(a[0]-1)
for i in range(len(a)-1):
  ans.append((a[i+1] - a[i])-1)
ans.append((len(h) - a[len(a)-1])-1)
print(max(ans))

### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))
a = []
ans = []
b = set(h)
if n == 0:
  print(0)
elif len(b) == 1:
  print(len(h)-1)
else:


  for i in range(n-1):
    if h[i] < h[i+1]:
      a.append(i+1)

  
  if a == []:
    print(len(h)-1)
  else:
    ans.append(a[0])
    ans[0] -= 1
    for i in range(len(a)-1):
      ans.append((a[i+1] - a[i])-1)
    ans.append((len(h) - a[len(a)-1])-1)
    if ans == []:
      print(0)
    else:
      print(max(ans))
n = int(input())
a = list(map(int,input().strip().split())
count = 0
for i in range(n):
    for j in range(n-1,i,-1):
        if a[j] < a[j-1]:
            count += 1
            a[j],a[j-1] = a[j-1],a[j]

print(' '.join(map(str,a)))
print(count)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().strip().split()))
count = 0
for i in range(n):
    for j in range(n-1,i,-1):
        if a[j] < a[j-1]:
            a[j],a[j-1] = a[j-1],a[j]
            count += 1
print(' '.join(map(str,a)))
print(count)
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

n, m = getList()
nums = getList()
sn = sum(nums)
if sn > n:
  print(-1)
else:
  print(n - sn)
  

### FIXED CODE ###


getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]
 
n, m = getList()
nums = getList()
sn = sum(nums)
if sn > n:
  print(-1)
else:
  print(n - sn)
import fractions:
A, B = map(int, input().split())
C = fractions.gcd(A, B)
print(A * B // C)

### FIXED CODE ###

import fractions
A, B = map(int, input().split())
print(A * B // fractions.gcd(A, B))
def longest_subsequence(sequence):
  return 5

def true_longest_subsequence(sequence):
  table = [(1, sequence[0])]
  for x in sequence[1:]:
    maxlen = 0
    for (L, z) in table:
      if z < x: # strict increasing
        maxlen = max(maxlen, L)
    table.append((maxlen+1, x))
  return max(L for (L, _) in table)
def dfs(vertex):
  visited[vertex] = True
  node_sequence.append(a[vertex])
  ans[vertex] = longest_subsequence(node_sequence)
  for node in adjacent[vertex]:
    if not visited[node]:
      dfs(node)
  node_sequence.pop()
  return
n = int(input())
a = list(map(int, input().split()))
adjacent = {i: [] for i in range(n)}
for _ in range(n-1):
  node1, node2 = map(int, input().split())
  node1 -= 1
  node2 -= 1
  adjacent[node1].append(node2)
  adjacent[node2].append(node1)
node_sequence = list()
visited = [False]*n
ans = [0]*n
dfs(0)
[print(value) for value in ans]

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)
from bisect import bisect, bisect_left
def longest_subsequence(sequence):
  subsequence = [float("inf") for _ in range(len(sequence)+1)]
  subsequence[0] = float("-inf")
  for value in sequence:
    j = bisect(subsequence, value)
    if subsequence[j-1] != value: # strict increasing
      subsequence[j] = value
  return bisect_left(dp, float("inf"))-1
# print(longest_subsequence([9, 13, 2, 10, 4, 13, 11, 13]))
# sys.exit()
def dfs(vertex):
  visited[vertex] = True
  value = a[vertex]
  j = bisect(subsequence, value)
  previous = subsequence[j]
  if subsequence[j-1] != value: # strict increasing
    subsequence[j] = value
  ans[vertex] = bisect_left(subsequence, float("inf"))-1
  for node in adjacent[vertex]:
    if not visited[node]:
      dfs(node)
  subsequence[j] = previous
  return
n = int(input())
a = list(map(int, input().split()))
adjacent = {i: [] for i in range(n)}
for _ in range(n-1):
  node1, node2 = map(int, input().split())
  node1 -= 1
  node2 -= 1
  adjacent[node1].append(node2)
  adjacent[node2].append(node1)
visited = [False]*n
ans = [0]*n
subsequence = [float("inf") for _ in range(n+1)]
subsequence[0] = float("-inf")
dfs(0)
[print(value) for value in ans]
s=input()
clist=['A','C','G','T']
count=0
a=[]
for i in s:
  if i in clist:
    count+=1
  else:
    a.append(count)
    count=0

print(max(a))

### FIXED CODE ###

s=input()
clist=['A','C','G','T']
count=0
a=[]
for i in s:
  if i in clist:
    count+=1
  else:
    a.append(count)
    count=0
a.append(count)
print(max(a))
N = int(input())
a = list(map(int, input().split()))
count = 0
if 1 not in a:
    print(-1)
else:
    count += a.index(1)
    prev_index = a.index(1)
    for i in range(prev_index):
        a[i] = 0
for i in range(2,N+2):
    if i not in a:
        count += N - prev_index - 1
        break
    else:
        count += a.index(i) - prev_index -1
        prev_index = a.index(i)
        for j in range(prev_index):
            a[j] = 0
print(count)

### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
count = 1
brick = 0
for i in range(N):
    if a[i] != count:
        brick += 1
    else:
        count += 1
if brick == N:
    print(-1)
else:
    print(brick)
c=input()
if c== 'a'|'i'|'u'|'e'|'o':
  print('vowel')
else:
  print('consonant')

### FIXED CODE ###

c=input()
if c in ['a','i','u','e','o']:
  print('vowel')
else:
  print('consonant')
import sys

def main():
    args = sys.argv
    if args[1] == args[2] and args[2] == args[3]:
        print("Yes")
	else:
        print("No")

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

def main():
	A,B,C = input().split()

	if A == B and B == C:
  		print("Yes")
	else:
  		print("No")

if __name__ == '__main__':
	main()
limit = int(input())
string = input()

if limit <= len(string):
    print(string[:7] + '...')
else:
    print(stirng)

### FIXED CODE ###

limit = int(input())
string = input()

if limit < len(string):
    string = string[:limit] + '...'

print(string)