Harryxun/stf_run huggingface dataset:
N=int(input())
if N%2==1:
  print(No)
  #偶数なら不適
else:
  s=input()
  b=N//2
  s=0
  for i in range (0,b):
    if s[i]==s[i+b]:
      s=s
    else:
      s=s+1
  if s==0:
    print(Yes)
  else:
    print(No)

### FIXED CODE ###

N=int(input())
if N%2==1:
  print("No")
  #偶数なら不適
else:
  s=input()
  b=N//2
  t=0
  for i in range (0,b):
    if s[i]==s[i+b]:
      t=t
    else:
      t=t+1
  if t==0:
    print("Yes")
  else:
    print("No")
n = int(input())
sum = 0
tmp = n

while n > 0:
    sum += sum % 10
    n //= 10

if tmp % sum == 0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

def digitsum(n):
    ans = 0
    while n > 0:
        ans += n % 10
        n = n // 10
    return ans

N = int(input())
SumN = digitsum(N)
if N % SumN == 0:
    print("Yes")
else:
    print("No")
n = int(input())
sft = 753
list = []
while n > 0:
    list.append(i%10)
    i //= 10 # 必須
list.reverse()
ans = 1000
for i in range(len(list)-2):
    tmp = 100*list[i] + 10*list[i+1] + list[i+2]
    sft - tmp if sft - tmp < ans else ans
print(ans)


### FIXED CODE ###

s = input()
print(min(abs(int(s[i:i+3]) - 753) for i in range(len(s) - 2)))
ans = []
n, m, k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

i = 0
j = 0
while True:
    
    if a[i] < b[j]:
        ans += [a[i]]
        i += 1
    else:
        ans += [b[j]]
        j += 1

    if sum(ans) > k:
        print(len(ans) - 1)
        break
    

### FIXED CODE ###

#(0)環境
from itertools import accumulate
import bisect
n, m, k = map(int,input().split())
#[0]足すことで上から０冊読んだという要素として加えると実装が楽に(一冊も読めんかった)
#accumulate:累積和などが求められる
a = [0] + list(accumulate(map(int,input().split())))
b = [0] + list(accumulate(map(int,input().split())))
ans =[0]

for i in range(n + 1):
    c = bisect.bisect_right(b, k - a[i]) - 1
    #k-s<0のときはインデックスがー１なので除外しなあかん
    if c != -1:
        ans.append(c + i)
print(max(ans))
import numpy as np
from sys import stdin
s_in = lambda: stdin.readline()[:-1]  # s = s_in()
d_in = lambda: int(stdin.readline())  # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()
N, M = ds_in()
info_list = []
for _ in range(M):
    info_list.append(ds_in())
info_list = np.array(info_list)
ordered = np.argsort(info_list[:, 1])
pref_count = np.zeros(N)
ans_list = ['' for _ in range(M)]
for i in ordered:
    pref = info_list[i, 0]
    pref_count[pref - 1] += 1
    ans_list[i] = '%06d%06d' % (pref, pref_count[pref - 1])
for a in ans_list:
    print(a)

### FIXED CODE ###

from sys import stdin
import numpy as np

s_in = lambda: stdin.readline()[:-1]  # s = s_in()
d_in = lambda: int(stdin.readline())  # N = d_in()
ds_in = lambda: list(map(int, stdin.readline().split()))  # List = ds_in()
N, M = ds_in()
info_list = []
for _ in range(M):
    info_list.append(ds_in())
info_list = np.array(info_list)
ordered = np.argsort(info_list[:, 1])
pref_count = np.zeros(N)
ans_list = ['' for _ in range(M)]
for i in ordered:
    pref = info_list[i, 0]
    pref_count[pref - 1] += 1
    ans_list[i] = '%06d%06d' % (pref, pref_count[pref - 1])
for a in ans_list:
    print(a)
from math import pow
N, P = map(int, input().split())
S = list(map(int, list(input())))

l = len(S)
if P == 2:
    ans = 0
    for i in range(l):
        if S[i]%2 == 0:
            ans += i+1
elif P == 5:
    ans = 0
    for i in range(l):
        if S[i]%5 == 0:
            ans += i+1
else:
    data = [0]*P
    temp = 0
    ans = 0
    for i in range(l-1, -1, -1):
        temp += S[i]*pow(10, l-i-1, P)
        temp %= P
        ans += data[temp]
        data[temp] += 1
    ans += data[0]

print(ans)

### FIXED CODE ###

N, P = map(int, input().split())
S = list(map(int, list(input())))

l = len(S)
if P == 2:
    ans = 0
    for i in range(l):
        if S[i]%2 == 0:
            ans += i+1
elif P == 5:
    ans = 0
    for i in range(l):
        if S[i]%5 == 0:
            ans += i+1
else:
    data = [0]*P
    temp = 0
    ans = 0
    for i in range(l-1, -1, -1):
        temp += S[i]*pow(10, l-i-1, P)
        temp %= P
        ans += data[temp]
        data[temp] += 1
    ans += data[0]

print(ans)
import sys
sys.setrecursionlimit(10**10)
N, M, K = map(int,input().split())
class UnionFind:
    def __init__(self, N):
        self.par = [-1 for i in range(N+1)]
        self.rank = [1]*(N+1)
    
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
        
    def same_check(self, x, y):
        return self.find(x) == self.find(y)
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if self.rank[x] > self.rank[y]:
            self.par[x] += self.par[y]
            self.par[y] = x
        else:
            self.par[y] += self.par[x]
            self.par[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

UF = UnionFind(N)
friendlist = [[] for _ in range(N+1)]
for n in range(M):
    A, B = map(int,input().split())
    friendlist[A].append(B)
    friendlist[B].append(A)
    if not UF.same_check(A,B):
        UF.union(A, B)
blocklist = [[] for _ in range(N+1)]
for n in range(K):
    C, D = map(int, input().split())
    blocklist[C].append(D)
    blocklist[D].append(C)

for person in range(1,N+1):
    root = UF.find(person)
    ans = -UF.par[root]-1
    ans -= len(friendlist[person])
    for l in blocklist[person]:
        if UF.same_check(person,l):
            ans -= 1
    print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5+10)
N, M, K = map(int,input().split())
class UnionFind:
    def __init__(self, N):
        self.par = [-1 for i in range(N+1)]
        self.rank = [1]*(N+1)
    
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
        
    def same_check(self, x, y):
        return self.find(x) == self.find(y)
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if self.rank[x] > self.rank[y]:
            self.par[x] += self.par[y]
            self.par[y] = x
        else:
            self.par[y] += self.par[x]
            self.par[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

UF = UnionFind(N)
friendlist = [[] for _ in range(N+1)]
for n in range(M):
    A, B = map(int,input().split())
    friendlist[A].append(B)
    friendlist[B].append(A)
    if not UF.same_check(A,B):
        UF.union(A, B)
blocklist = [[] for _ in range(N+1)]
for n in range(K):
    C, D = map(int, input().split())
    blocklist[C].append(D)
    blocklist[D].append(C)

for person in range(1,N+1):
    root = UF.find(person)
    ans = -UF.par[root]-1
    ans -= len(friendlist[person])
    for l in blocklist[person]:
        if UF.same_check(person,l):
            ans -= 1
    print(ans)
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa == x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))

n,k = m()

s = [[] for i in range(n)]

sss = [[Max,Max,Max] for i in range(n)]

for i in range(k):
    u,v = m()
    u -= 1
    v -= 1
    if v not in s[u]:
        s[u].append(v)

st,g = m()
g -= 1
co = Max
def dfs(x,nn,now,coun):
    global sss,g,co
    if min(sss[now][nn],coun) == coun:
        if now == g and nn == 0:
            co = min(co,coun)
        else:
            sss[now][nn] = coun
            for i in x[now]:
                if nn == 2:
                    nn = 0
                    coun += 1
                else:
                    nn += 1
                dfs(x,nn,i,coun)
    else:
        if now == g and nn == 0:
            co = min(co,coun)
dfs(s,st-1,0,0)
if co == Max:
    print(-1)
else:
    print(co)



### FIXED CODE ###

import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa == x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))

n,k = m()

s = [[] for i in range(n)]

sss = [[Max,Max,Max] for i in range(n)]

for i in range(k):
    u,v = m()
    u -= 1
    v -= 1
    if v not in s[u]:
        s[u].append(v)

st,g = m()
st -= 1
g -= 1
co = Max

eee = [[s,0,st,0]]
eee = cl.deque(eee)
def bfs(x,nn,now,coun):
    global eee,sss,g,co
    if sss[now][nn] == Max:
        if nn == 0 and g == now:
            co = min(co,coun)
        else:
            sss[now][nn] = coun
            if nn == 2:
                nn = 0
                coun += 1
            else:
                nn += 1
            for i in x[now]:
                eee.append([x,nn,i,coun])
    else:
        if now == g and nn == 0:
            co = min(co,coun)

while eee:
    op = eee.popleft()
    bfs(op[0],op[1],op[2],op[3])

#dfs(s,0,g,0)
if co == Max:
    print(-1)
else:
    print(co)
from collections import defaultdict

N, Q = map(int, input().split())
e = [[] for _ in range(N + 1)]
for i in range(N - 1):
    a, b = map(int, input().split())
    e[a].append(b)

q = defaultdict(int)
for i in range(Q):
    p, x = map(int, input().split())
    q[p] += x

seen = [False] * (N + 1)
subtree = [[] for _ in range(N + 1)]


def dfs(e, v):
    seen[v] = True
    for next_v in e[v]:
        if seen[next_v]:
            continue
        else:
            dfs(e, next_v)
            subtree[v].extend(subtree[next_v])

    subtree[v].append(v)


dfs(e, 1)
ans = [0] * (N + 1)


for i in q:
    for j in subtree[i]:
        ans[j] += q[i]

print(*ans[1:])


### FIXED CODE ###

from collections import defaultdict
import sys
input = sys.stdin.readline

sys.setrecursionlimit(10**6)

N, Q = map(int, input().split())
e = [[] for _ in range(N + 1)]
for i in range(N - 1):
    a, b = map(int, input().split())
    e[a].append(b)

q = defaultdict(int)
for i in range(Q):
    p, x = map(int, input().split())
    q[p] += x

seen = [False] * (N + 1)
ans = [0] * (N + 1)


def dfs(e, v, x):
    seen[v] = True
    ans[v] += x
    for next_v in e[v]:
        if seen[next_v]:
            continue
        else:
            dfs(e, next_v, x + q[next_v])


dfs(e, 1, q[1])
print(*ans[1:])
N,A,B = map(int, input().split())
total = 0
for num in range(1,N):
    cnt = 0
    num_str = str(num)
    for i in num_str:
        cnt += int(i)
        if A <= cnt <= B:
            total += num_str

print(total) 
    


### FIXED CODE ###

n, a, b = map(int, input().split())
 
sum = 0
for i in range(n+1) :
    count = 0
    for num in str(i) :
        count += int(num)
 
    if (count >= a) and (count <= b) :
        sum += i
            
print(sum)
N = int(input())
S = list(input())
K = int(input())

for i in range(N):
	if S[i] != S[K-1]:
		S[i] = "*"
S_changed = "".join(S)
print(S_changed)

### FIXED CODE ###

a,b,c = map(int,input().split())
if a > b:
	A = a
	a = b
	b = A

yoru = 1    
if a < c and b > c:
	yoru = 1
else:
	yoru = 0
if yoru == 1:
	print("Yes")
else:
	print("No")
from collections import deque
N,M = map(int,input().split())
E = {i: [] for i in range(N)}
for m in range(M):
  A,B = map(int,input().split())
  E[A].append(B)
  E[B].append(A)
  
q = deque([0])
checked = [False]*N
ans = 0
while q and not(all(checked)):
  n = q.popleft()
  if checked[n]: continue
  checked[n] = True
  for i in E[n]:
    if not checked[i]: q.append(i)
  if all(checked): break
  elif not q:
    ans += 1
    for i in range(N):
      if not checked[i]:
        q.append(i)
        break
  
print(ans)

### FIXED CODE ###

def f(x):
  while p[x]>0: x = p[x]
  return x
N,M = map(int,input().split())
p = [-1]*N
for _ in range(M):
  A,B = map(lambda x:f(int(x)-1),input().split())
  if A==B: continue
  elif A<B: A,B=B,A
  p[A] += p[B]
  p[B] = A
print(sum(i<0 for i in p)-1)
N, X = map(int, input().split())
2
3 a, p = [1], [1]
4 for i in range(N):
5 a.append(a[i] * 2 + 3)
6 p.append(p[i] * 2 + 1)
7
8 def f(N, X): # X <= 0 や X > a_N を許容し解説本文から簡略化
9 if N == 0:
10 return 0 if X <= 0 else 1
11 elif X <= 1 + a[N-1]:
12 return f(N-1, X-1)
13 else:
14 return p[N-1] + 1 + f(N-1, X-2-a[N-1])
15
16 print(f(N, X))


### FIXED CODE ###

N, X = map(int, input().split())
p = 1
t = 1
pdic = {}
tdic = {}
for i in range(N):
  pdic[i] = p
  tdic[i] = t
  p = 2*p+1
  t = 2*t+3
pdic[N] = p
tdic[N] = t
ans = 0
nokori = X
state = N
count = N
while True:
  while tdic[count]+state-count>nokori:
    count -= 1
    if count<0:
      break
  if count<0:
    break
  nokori -= (tdic[count]+state-count)
  state = count
  ans += pdic[count]
  if nokori==0:
    break
  nokori -= 1
  ans += 1
  if nokori==0:
    break
print(ans)
import numpy as np

N = int(input())  

A = np.zeros(N) 
B = np.zeros(N) 

for i in range(N):
    A[i], B[i] = map(int, input().split())

a = 0
for i in range(1000000):
    C = np.random.permutation(np.arange(N))
    k = 0
    a = 0
    b = 0
    for j in range(N):
        k += A[C[i]]
        if  k > B[i]:
            a = 1
            
    if a == 0:
        b = 1
        print('Yes')
        break
    
if b == 0:
    print('No')
    

### FIXED CODE ###

import numpy as np

N = int(input())  

A = np.zeros(N) 
B = np.zeros(N) 

for i in range(N):
    A[i], B[i] = map(int, input().split())
    
B1 = np.argsort(B)

ans = "Yes"
 
k = 0
for i in range(N):
    k += A[B1[i]]
    if k > B[B1[i]]:
        ans = "No"
 
print(ans)
hoge = input().split(" ")
for i in range(int(hoge[1])):
  a += hoge[0]
for i in range(int(hoge[0])):
  b += hoge[1]
txt = [a,b]
txt.sort
print(a[0])

### FIXED CODE ###

hoge = input().split(" ")
a=""
b=""
for i in range(int(hoge[1])):
  a += hoge[0]
for i in range(int(hoge[0])):
  b += hoge[1]
txt = [a,b]
txt.sort()
print(txt[0])
n = input()
if n % 2 == 0:
  print(n/2)
else:
  print(n//2 + 1)

### FIXED CODE ###

n = int(input())
if n % 2 == 0:
    print(int(n/2))
else:
    print(n//2 + 1)
N,K = map(int, input().split())
A =[0]
B=list(map(int, input().split()))
for m in range(N):
    A.append(B[m])
place=set([])
i=1
count=0
while i not in place:
    place.add(i)
    i=A[i]
    count+=1
if count>=K:
    print(place[K+1])
else:
    loop=[i]
    start=i
    j=A[i]
    count+=1
    while j!=start:
        loop.append(j)
        j=A[j]
        count+=1
    if count>=K:
        print(loop[K-len(place)])
    else:
        num=(K-count)%len(loop)
        print(loop[num])

### FIXED CODE ###

N,K = map(int, input().split())
A =[0]
B=list(map(int, input().split()))
for m in range(N):
    A.append(B[m])
place=set([])
p=[]
i=1
count=0
while i not in place:
    place.add(i)
    p.append(i)
    i=A[i]
    count+=1
if count>K:
    print(p[K])
else:
    loop=[i]
    start=i
    j=A[i]
    count+=1
    while j!=start:
        loop.append(j)
        j=A[j]
        count+=1
    if count>K:
        print(loop[K-len(p)])
    else:
        num=(K-count)%len(loop)
        print(loop[num])
def main():
  x, t = map(int, input().split())
  if t > x:
    print(0)
  else:
    print(x-t)

if __name__ == '__main__':
  main()

### FIXED CODE ###

def main():
  n = int(input())
  a = tuple(map(int ,input().split()))

  ans = [0]*(10**6)
  for x in a:
    ans[x-1] += 1
    ans[x] += 1
    ans[x+1] += 1
  print(max(ans))
if __name__ == '__main__':
  main()
import numpy as np
N,K=map(int,input().split())
A=list(map(int,input().split()))
def B(i):
  if i==0:
    return 1
  return A[B(i-1)-1]
C=[1]
for i in range(1,N+1):
  if C.count(B(i))==0:
    C.append(B(i))
  else:
    l=C.index(B(i))+1
    break
if K+1<=l:
  print(C[K])
else:
  print(C[l-1])
print(C)

### FIXED CODE ###

import numpy as np
N,K=map(int,input().split())
A=list(map(int,input().split()))
C=[1]
s=set([1])
for i in range(N):
  if A[C[i]-1] in s:
    l=C.index(A[C[i]-1])+1
    break
  else:
    C.append(A[C[i]-1])
    s.add(A[C[i]-1])
if K+1<=l:
  print(C[K])
else:
  print(C[l-1+(K+1-l)%(len(C)-l+1)])
N=int(input())
A=list(map(int,input().split()))
heikin=sum(A)/N
kouho = []

if heikin in A:
    print(A.index(heikin))
else:
    for i in A:
        kouho.append(abs(heikin-i))
    ans = kouho.copy()
    ans.sort()
print(kouho.index(ans[0]))

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
heikin=sum(A)/N
kouho = []

if heikin in A:
    print(A.index(heikin))
else:
    for i in A:
        kouho.append(abs(heikin-i))
    ans = kouho.copy()
    ans.sort()
    print(kouho.index(ans[0]))
def main():
  input_number=list(map(int, input().split()))
  for i in input:
    if i==0:
      print(i)
      break

if __name__=='__main__':
  main()

### FIXED CODE ###

def main():
  input_number = list(map(int, input().split()))
  for i in range(5):
    if input_number[i]==0:
      print(i+1)
      exit()

if __name__=='__main__':
  main()
a, b = int(input())
x = (a+b)/2
print(int(x))

### FIXED CODE ###

import math
a, b = map(int,input().split())
x = (a + b)/2
print(math.ceil(x))
from operator import itemgetter

class UnionFind():
	def __init__(self, size):
		self.table = [-1 for _ in range(size)]

	def find(self, x):
		while self.table[x] >= 0:
			x = self.table[x]
		return x

	def union(self, x, y):
		s1 = self.find(x)
		s2 = self.find(y)
		if s1 != s2:
			if self.table[s1] > self.table[s2]:
				self.table[s2] = s1
			elif self.table[s1] < self.table[s2]:
				self.table[s1] = s2
			else:
				self.table[s1] = s2
				self.table[s2] -= 1
		return

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
xy_x = {i: xy[i][0] for i in range(n)}
xy_y = {i: xy[i][1] for i in range(n)}

v_x = sorted(xy_x.items(), key=itemgetter(1))
v_y = sorted(xy_y.items(), key=itemgetter(1))

edges = dict()

for i in range(n - 1):
	edges[(v_x[i][0], v_x[i+1][0])] = v_x[i+1][1] - v_x[i][1]
	edges[(v_y[i][0], v_y[i+1][0])] = v_y[i+1][1] - v_y[i][1]

uf = UnionFind(n)

edges = sorted(edges.items(), key=itemgetter(1))

ans = 0

while edges != list():
	e = edges.pop(0)
	if uf.find(e[0][0]) != uf.find(e[0][1]):
		uf.union(e[0][0], e[0][1])
		ans += e[1]

print(ans)

### FIXED CODE ###

MOD = 10 ** 9 + 7
n, m = map(int, input().split())

if abs(n - m) >= 2:
	print(0)

else:
	n, m = (max(n, m), min(n, m))
	ans = 1
	for i in range(1, m + 1):
		ans = (ans * i) % MOD

	if n == m:
		print((ans ** 2 * 2) % MOD)
	else:
		print((ans ** 2 * n) % MOD)
# coding: utf-8
# Your code here!
W, H, x, y, r = map(int, raw_input().split())
if r <= x and r <= y and x+r <= W y+r <= H:
    print "Yes"
else:
    print "No"


### FIXED CODE ###

W, H, x, y, r = map(int, input().split())
if x-r < -1 or y-r < -1 or x+r > W or y+r > H:
    print("No")
else:
    print("Yes")
n = int(input())
d =list(map(int,input().split()))

sum = 0

for i in range(n):
  	for j in range(i+1,n):
      	s += d[i] * d[j]
print(s)

### FIXED CODE ###

n = int(input())
d =list(map(int,input().split()))
s = 0
for i in range(n):
    for j in range(i+1,n):
       s += d[i] * d[j]
print(s)
N, M = map(int, input().split())
S = [0]*M
C = [0]*M
SC = {1: set([]), 2: set([]), 3: set([])}
for m in range(M):
    S[m], C[m] = map(int, input().split())
    SC[S[m]].add(C[m])

ANS = [0]*N
out = 0
for i in range(1, 4):
    if len(SC[i]) >= 2:
        out = 1
if out == 1:
    print(-1)

else:
    if N == 1:
        if list(SC[1])[0] == 0:
            out = 1
        elif len(SC[1]) == 0:
            ANS[0] = 0
        else:
            ANS[0] = list(SC[1])[0]

    else:
        for i in range(N):
            if i == 0:
                if list(SC[i+1])[0] == 0:
                    out = 1
                elif len(SC[i+1]) == 0:
                    ANS[0] == 1
                else:
                    ANS[0] = list(SC[i+1])[0]
            else:
                if len(SC[i+1]) == 0:
                    ANS[i] = 0
                else:
                    ANS[i] = list(SC[i+1])[0]
    if out == 1:
        print(-1)
    else:
        ans = 0
        for i in range(N):
            ans += ANS[i]*10**(N-i-1)
        print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
S = [0]*M
C = [0]*M
SC = {}
SC = {1: set([]), 2: set([]), 3: set([])}
for m in range(M):
    S[m], C[m] = map(int, input().split())
    SC[S[m]].add(C[m])

ANS = [0]*N
out = 0
for i in range(1, 4):
    if len(SC[i]) >= 2:
        out = 1
if out == 1:
    print(-1)

else:
    out = 0
    if N == 1:
        if len(SC[1]) == 0:
            ANS[0] = 0
        else:
            ANS[0] = list(SC[1])[0]

    else:
        for i in range(N):
            if i == 0:
                if len(SC[i+1]) == 0:
                    ANS[0] = 1
                elif list(SC[i+1])[0] == 0:
                    out = 1
                else:
                    ANS[0] = list(SC[i+1])[0]
            else:
                if len(SC[i+1]) == 0:
                    ANS[i] = 0
                else:
                    ANS[i] = list(SC[i+1])[0]
    if out == 1:
        print(-1)
    else:
        ans = 0
        for i in range(N):
            ans += ANS[i]*10**(N-i-1)
        print(ans)
N, M = map(int, input().split())
H = list(map(int, input().split()))
adj_max = [0]*N
ans = 0
for _ in range(M):
  tmp1, tmp2 = map(int, input().split())
  adj_max[tmp1] = max(adj_max[tmp1], H[tmp2])
  adj_max[tmp2] = max(adj_max[tmp2], H[tmp1])
for num in range(N):
  if H[num] > adj_max[num]:
    ans += 1
print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
H = list(map(int, input().split()))
adj_max = [0]*N
ans = 0
for _ in range(M):
  tmp1, tmp2 = map(int, input().split())
  adj_max[tmp1-1] = max(adj_max[tmp1-1], H[tmp2-1])
  adj_max[tmp2-1] = max(adj_max[tmp2-1], H[tmp1-1])
for num in range(N):
  if H[num] > adj_max[num]:
    ans += 1
print(ans)
n = int(input())
if n[0]==n[1]==n[2] or n[1]==n[2]==n[3]:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n = input()
if n[0]==n[1]==n[2] or n[1]==n[2]==n[3]:
    print("Yes")
else:
    print("No")
i = 1
while i > 0:
    x = input()
    print("Case",i,end="")
    print(":",x)
    if x == 0:
        break

### FIXED CODE ###

i = 1
while True:
    x = input()
    if x == "0":
        break
    print("Case",i,end="")
    print(":",x)
    i +=1
second=input()
first=split(second)
P=string(first[0])
S=string(first[1])
count=0
for t in range(0,len(P)-1):
  if P[t]=S[t]:count=count+1
    else count=count
print(int(count))

### FIXED CODE ###

a=[input() for i in range(2)]
P=a[0]
S=a[1]
count=0
for t in range(len(P)):
  if P[t] != S[t]:
    count=count+1
print(count)
N=int(input())
A=list(map(int,input().split()))

num=A[0]
data=[[A[0],0]]

for i in range(1,N):
    if A[i]>num:
        data.append([A[i],i])
        num=A[i]
        
B=sorted(A,reverse=True)

ans=[0]*N

kkk=0
for i in range(len(data)-1,0,-1):
    
    zzz=data[i][0]
    while kkk<N and B[kkk]>=zzz:
        kkk+=1
        
    ans[data[i][1]]=(zzz-data[i-1][0])*kkk
    cnt+=1
ans[0]=sum(A)-sum(ans)

for u in ans:
    print(u)

### FIXED CODE ###

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

num=A[0]
data=[[A[0],0]]

for i in range(1,N):
    if A[i]>num:
        data.append([A[i],i])
        num=A[i]
        
B=sorted(A,reverse=True)
C=[0]*N
C[0]=B[0]
for i in range(1,N):
    C[i]=C[i-1]+B[i]
    
    
ans=[0]*N
cnt=0
kkk=0
for i in range(len(data)-1,0,-1):
    
    zzz=data[i-1][0]
    while kkk<N and B[kkk]>zzz:
        kkk+=1
    num=C[kkk-1]-kkk*zzz
    num-=cnt
    ans[data[i][1]]=num
    cnt+=num

ans[0]=sum(A)-sum(ans)

for u in ans:
    print(u)