peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n = int(input())
alp = 'abcdefghijklmnopqrstuvwxyz'
S1 = input()
from collections import Counter
SC1 = Counter(S1)

for a in alp:
    SC1.setdefault(a, 0)

for _ in range(n-1):
    S = input()
    SC = Counter(S)
    for a in alp:
        SC.setdefault(a, 0)
        SC1[a] = min(SC1[a], SC[a])

ans = ''
for a in alp:
    ans += a*SC1[a]
print(ans)
# Judge status: Accepted
N,M=map(int, input().split())
ansY = [0]*N
ansWA = [0]*N
for i in range(M):
  id,ans = input().split()
  idr = int(id)-1
  if ans=='AC':
    ansY[idr]=1
  elif ans=='WA' and ansY[idr]==0:
    ansWA[idr]+=1
WA = sum([x * y for (x, y) in zip(ansY, ansWA)])
print(sum(ansY),WA)
# Judge status: Accepted
def main():
    N, *X = map(int, open(0).read().split())
    l, r = sorted(X)[N // 2 - 1:N // 2 + 1]
    print("\n".join(map(str, [r if x <= l else l for x in X])))
    return


main()
# Judge status: Accepted
n = int(input())
l = list(map(int,input().split()))
l.sort()
ans = 0
def ok(a,b,c):
    return c < a+b
for i in range(n):
    for j in range(i+1,n):
        bot = j
        top = n
        while top-bot > 1:
            mid = (top+bot)//2
            if ok(l[i],l[j],l[mid]):bot = mid
            else:top = mid
        ans += bot - j
print(ans)
# Judge status: Accepted
# https://atcoder.jp/contests/arc068/tasks/arc068_a

x = int(input())

# 6の面が上向きになるように置き、次は5にする。そしてまた6に戻す。
# この2回の操作で11点獲得できる。これが2回の操作で得られる最高点である。

n = x // 11
ans = n * 2
x -= n * 11

if x == 0:
    pass
elif x <= 6:
    ans += 1
else:
    ans += 2
print(ans)
# Judge status: Accepted
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n = ii()
V = sorted(iil())

ans = V[0]

for i in V:
    ans = (ans+i)/2

print(ans)
# Judge status: Accepted
n=int(input())
l=list(map(int,input().split()))
p=1
flag=1
zero=0 
for i in l:
    if i==0 :
        zero=1 
        break 
if zero==0:
    for i in l:
        p*=i
        if p>1000000000000000000:
            flag=0
            break
    if flag==0:
        print('-1')
    else:
        print(p)
else : 
    print("0")
# Judge status: Wrong Answer
n, x, t = map(int, input().split())
print((n + 1) // x * t)
# Judge status: Accepted
n = int(input())
d = [int(x) for x in input().split()]
mod = 998244353
m = [0]*n

for x in d:
    m[x] += 1
ans = 1

if d[0] != 0 or m[0] > 1:
    print(0)
else:
    for i in range(1, n):
        ans *= pow(m[i-1], m[i], mod)
        ans %= mod
    print(ans)
# Judge status: Wrong Answer
a,b,c=map(int, input().split())
k = int(input())

for i in range(k):
    if a > b:
        b = b*2
    elif b > c:
        c = c*2
if a < b and b < c:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N = int(input())
txy = [list(map(int, input().split())) for _ in range(N)]

now_x, now_y = 0, 0
pre_t = 0

for t, x, y in txy:
    walk = abs(now_x - x) + abs(now_y - y)
    if t - pre_t < walk:
        print('No')
        exit()
    if (t-pre_t) % 2 != walk % 2:
        print('No')
        exit()
    now_x = x
    now_y = y
    pre_t = t

print('Yes')
# Judge status: Accepted
import math

a,b = map(int, input().split())


if a % b == 0:
    ans = math.floor(a / b)
else:
    ans = math.floor(a / b) + 1

print(ans)
# Judge status: Accepted
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

x, y = map(int, input().split())

i = 0
while True:
  if x * 2 ** i > y:
    break

# 12
  i += 1
  
print(i)
# Judge status: Accepted
X= int(input())

print("Yes" if X>=30 else "No")
# Judge status: Wrong Answer
n,a,b,c,d = map(int,input().split())
s = ["s"] + list(input())

for i in range(a,max(c,d)-1):
        if s[i] == s[i+1] == "#":
            print("No")
            exit()
if c < d:
    print("Yes")
else:
    for i in range(b+1,d+1):
        if s[i-2] == s[i-1] == s[i] == ".":
            print("Yes")
            exit()
    print("No")
# Judge status: Wrong Answer
N = int(input())

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

arr.sort()
cnt = 0
num = 1

a = arr[0]

for i in range(1,N):
  if arr[i] == a:
    num += 1
  else:
    if num % 2 == 1:
      cnt += 1
    num = 1
    a = arr[i]
print(int(cnt))
# Judge status: Accepted
from functools import reduce
def f(n):
    res = 0
    while(n%2 == 0):
        res += 1
        n //= 2
    return res

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

def lcm(a, b):
    return a // gcd(a, b) * b

n, m = map(int, input().split())
A = list(map(lambda x: int(x) // 2, input().split()))

l = reduce(lcm, A, 1)
for a in A:
    if((l // a) % 2 == 0):
        print(0)
        break

else:
    ans = (m // l +1) // 2
    print(ans)
# Judge status: Accepted
# E - Rotation Matching

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

l, r = 1, n
for i in range(m):
    if 2 * (r - l) == n or 2 * (r - l + 1) == n:
        l += 1
    print(l, r)
    l, r = l + 1, r - 1
# Judge status: Accepted
s=input()
k=int(input())
ans,bns=0,0
for i in range(len(s)):
    if s[i]!="1":
        ans=s[i]
        break
    else:
        bns+=1 #0の連続
if k<=bns: #k=何番目
    print(1)
else:
    print(ans)
# Judge status: Accepted
N = int(input())
ans = 0
for a in range(1, N+1):
    ans += (N-1) // a
print(ans)
# Judge status: Wrong Answer
N, M = map(int, input().split())
if N >= M:
    print(0)
    exit()
X = list(map(int, input().split()))
X.sort()
leng = []
for i in range(1, M):
    leng.append(X[i] - X[i-1])
leng.sort()
N 
print(sum(leng[:-N+1]))
# Judge status: Accepted
n=int(input())
d,m=divmod(n-6,11)
if m<1: print(d*2+1)
elif m<6: print(d*2+2)
else: print(d*2+3)
# Judge status: Accepted
k, a, b = map(int, input().split())
if k <= a or b - a <= 2:
    ans = 1 + k
elif b - a > 2:
    ans = ((k - a + 1) // 2) * (b - a) + a + (k - a + 1) % 2
print(ans)
# Judge status: Accepted
import math
n=int(input())
print(math.factorial(n)%(pow(10,9)+7))
# Judge status: Accepted
import math
n = int(input())

ans = math.ceil(n / 1000) * 1000 - n

print(ans)
# Judge status: Accepted
d = int(input())

if d == 25:
    print('Christmas')
elif d == 24:
    print('Christmas Eve')
elif d == 23:
    print('Christmas Eve Eve')
elif d == 22:
    print('Christmas Eve Eve Eve')
# Judge status: Accepted
n, a, b = list(map(int, input().split()))
print(max(0, (b - a) * (n - 2) + 1))
# Judge status: Accepted
N,M = map(int,input().split()) 
Pref_info = [[] for _ in range(N)] 
for i in range(M):
    P,Y = map(int,input().split())
    Pref_info[P - 1].append([Y,i])
ans = [""]* M 
for i in range(N): 
    Pref_info[i].sort()
    for index, p in enumerate(Pref_info[i]):
        ans[p[1]] = "{0}{1}".format(str(i+1).zfill(6),str(index+1).zfill(6))
for i in ans:
    print(i)
# Judge status: Wrong Answer
import time
k = int(input())
n = 7
c = 1
t1 = time.time() 
t2 = time.time()
while (t2-t1) <= 1.8:
  if n%k == 0:
    print(c)
    break
  else:
    n = int(str(n)+"7")
    c+=1
    t2 = time.time()

if (t2-t1) > 1.8:
  print(-1)
# Judge status: Wrong Answer
N = int(input())
a = list(map(int, input().split()))

ans = []
over = 0
for i in range(N):
  n = a[i] // 400
  if n < 8:
    if n not in ans:
      ans.append(n)
  else:
    over += 1
    
cnt = len(ans) + over
if cnt < 8:
  print(len(ans), cnt)
else:
  print(len(ans), 8)
# Judge status: Accepted
x = int(input())


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


def lcm(a, b):
    return a*(b//gcd(a, b))


print(lcm(360, x)//x)
# Judge status: Accepted
# coding: utf-8
# Your code here!
ary = list(map(int,input().split(" ")))
area = ary[0]*ary[1]/2
f = 0
if ary[0] / 2 - ary[2] == 0 and ary[1] / 2 - ary[3] == 0:
    f = 1
print(area,f)
# Judge status: Accepted
n = int(input())
s = list(map(int,input().split()))
s.sort()
ans = 10**9
for i in range(101):
  sum = 0
  for j in s:
    sum += (i-j)**2
  if sum < ans: ans = sum
  else: break  

print(ans)
# Judge status: Accepted
from collections import deque

S = input()
Q = int(input())
L = 1
S = deque(S)

for i in range(Q):
    A = list(input().split())
    if int(A[0]) == 1:
        L = -L
    if int(A[0]) == 2:
        A[1] = 2*int(A[1]) - 3
        if L*A[1] == -1:
            S.appendleft(A[2])
        else:
            S.append(A[2])

if L == 1:
    print(''.join(S))
else:
    print(''.join(list(reversed(S))))
# Judge status: Accepted
N, Y = map(int, input().split())

ans = [-1, -1, -1]
ok = False
for x in range(N+1):
    for y in range((N+1)-x):
        if 10000 * x + 5000 * y > Y:break
        z = N - x- y
        if 10000 * x + 5000 * y + 1000 * z == Y:
            print(x, y, z)
            exit()
if not ok: print(-1, -1, -1)
# Judge status: Accepted
# https://atcoder.jp/contests/abc112/tasks/abc112_d

n, m = map(int, input().split())
if n == 1:
    ans = m
else:
    ans = 1
    i = 1
    limit = m / n
    while i <= limit:
        if m % i == 0 and m // i >= n:
            ans = max(ans, i)
        i += 1
print(ans)
# Judge status: Wrong Answer
N,A,B = map(int, input().split())
x = sum(i for i in range(1, N+1) if A <= i//10+i%10 <= B)
print(x)
# Judge status: Wrong Answer
def main():
    n, k, s = map(int, input().split())
    if k == n:
        print(*([s]*n))
    else:
        if s == 10**9:
            ans = ([s]*k)+([1]*(n-k))
        else:
            if k % 2 == 1:
                ans = [s-1, 1]*((k+1)//2)+[10**9]*(n-k-1)
            else:
                ans = [s-1, 1]*(k//2)+[s-1]+[10**9]*(n-k-1)
        print(*ans)


main()
# Judge status: Accepted
N = int(input())
S = []
for i in range(N):
  S.append(str(input()))
           

print('AC x %d' % S.count('AC'))
print('WA x %d' % S.count('WA'))
print('TLE x %d' % S.count('TLE'))
print('RE x %d' % S.count('RE'))
# Judge status: Wrong Answer
#!/usr/bin/env python3
import sys
n = int(input())
a = list(map(int,input().split()))
ans = 0
mod = (10**9 +7)
for j in range(61):# 2**j 桁に対して1なものの数を求める
    num_one = 0
    for i in range(len(a)):
        if a[i] & 1 << i: 
            num_one += 1
    # num_one = sum(1 for j in a if 1 << i & j == 1)
    #print(j,num_one)
    ans += (2**j % mod) * (n-num_one)*(num_one) % mod
    #print(ans)
print(ans%mod)
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline
n = int(input())
C = [list(map(int,input().split())) for i in range(n)]

a = 10**9+5
b = 0
c = 10**9+5
d = 0

for i in range(n):
    a = min(a, C[i][0]+C[i][1])
    b = max(b, C[i][0]+C[i][1])
    c = min(c, C[i][0]-C[i][1])
    d = max(d, C[i][0]-C[i][1])

print(max(b-a,d-c))
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))

S = 0
for a in A:
    S ^= a

B = [0]*N

for i in range(N):
    B[i] = S^A[i]
print(*B)
# Judge status: Accepted
import sys
input = sys.stdin.readline

s = input().split()[0]

print('x'*len(s))
# Judge status: Accepted
# -*- coding: utf-8 -*-
K, N = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
D = []
D.append(A[N-1]-A[0])
for i in range(1, N):
  D.append(A[i-1]+K-A[i])

print(min(D))
# Judge status: Accepted
l,r,d = map(int,input().split())

print(r//d - (l-1)//d)
# Judge status: Wrong Answer
S = sorted(list(input()))
T = sorted(list(input()))

for s, t in zip(S, T):
    if s != t:
        print("No")
        exit()
print("Yes")
# Judge status: Accepted
import sys

input = sys.stdin.readline

def main():
    ans = 0
    n = int(input())
    s = input().rstrip('\n')
    t = input().rstrip('\n')
    for i in range(n):
        if s[i:] == t[:n-i]:
            print(n+i)
            break
    else:
        print(n*2)
        
if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
import scipy.misc

N=int(input())
X=list(map(int,input().split()))
SX=sorted(X)
M=SX.pop()
MV=10**9
ANS=0
for x in SX:
  z = M - x
  if MV > z:
    MV = z
    ANS = x
print("{} {}".format(M,ANS))
# Judge status: Accepted
if __name__=="__main__":
    # Problem A
    A, B = map(int, input().split(' '))
    print(int(A*B))
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))

a.sort()

for i in range(n-1):  
  if a[i] == a[i+1]:
    print("NO")
    exit()

print("YES")
# Judge status: Wrong Answer
from decimal import Decimal
a, b, c = map(Decimal, input().split())

ans = (c - a - b)**2 > 4 * a * b

print("Yes" if ans else "No")
# Judge status: Accepted
from copy import copy
n=int(input())
a=[0]+[int(input()) for _ in range(n)]
ans=0
for i in range(n):
  ans+=(a[i+1]+a[i])//2
  if a[i+1]:a[i+1]=(a[i+1]+a[i])%2
print(ans)
# Judge status: Wrong Answer
K,X=map(int,input().split())
A=list(range(X-K+1,X+K-1))
print(A)
# Judge status: Accepted
h1,m1,h2,m2,k = map(int,input().split())
if h2 < h1:
    h2 += 24
if m2 < m1:
    m2 += 60
    h2 -= 1
print((h2-h1)*60+m2-m1-k)
# Judge status: Wrong Answer
n, k, s = map(int, input().split())

arr = [s] * k + [s + 1, s - 1] * ((n - k) // 2) + [s + 1] * ((n - k) % 2)

print(arr)
# Judge status: Wrong Answer
a, b = map(int,input().split())
count = 1
if b < 2*a:
  print(1)
else:
  while True:
    if 2*a<=b:
      count+=1
      a *= 2
    else:
      break
print(count)
# Judge status: Accepted
n, (T, A),  *D,  = [list(map(int, s.split())) for s in open(0)]
n = n[0]
D = D[0]
di = {}
for i in range(len(D)):
    di[i] = abs(A  - T + D[i] * 0.006)
   
di = sorted(di.items(), key = lambda x:x[1])
print(di[0][0] + 1)
# Judge status: Wrong Answer
s = input()
if s.islower == True:
  print("a")
else:
  print("A")
# Judge status: Accepted
N=int(input())
d=list(map(int,input().split()))
d.sort()
print(max(0,d[N//2]-d[N//2-1]))
# Judge status: Accepted
K,X=[int(i) for i in input().split()]
print("Yes" if X<=K*500 else "No")
# Judge status: Accepted
import sys
f=lambda:map(int,sys.stdin.readline().split())
_,m=f()
d,t,c={},0,0
for p,y,i in sorted(list(f())+[i] for i in range(m)):
  if p>t: t,c=p,1
  else: c+=1
  d[i]=str(p).zfill(6)+str(c).zfill(6)
for _,v in sorted(d.items()): print(v)
# Judge status: Accepted
k,x=map(int,input().split())
if 500*k>=x:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
n, k = map(int, input().split())
missing = 0
snuke = []
for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    snuke.append(d)

snuke = list(set(snuke))
print(n - len(snuke))
# Judge status: Accepted
n=int(input())
l=list(map(int,input().split()))
c=0
for i in range(0,n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if l[i]!=l[j] and l[k]!=l[j] and l[i]!=l[k] and abs(l[i]-l[j])< l[k] <l[i]+l[j]:
                c+=1
print(c)
# Judge status: Accepted
n = int(input())
ll = []
for i in range(n):
  x, l = map(int, input().split())
  ll.append([x-l, x+l])
ll = sorted(ll, key=lambda x: x[1])

ans = 0
tmp = -10**9

for s, t in ll:
  if s >= tmp:
    ans += 1
    tmp = t

print(ans)
# Judge status: Accepted
l = list(map(int, input().split()))
count = count2 = 0
for i in range(3):
  if(l[i] == 5):
    count+=1
  elif(l[i] == 7):
    count2 += 1
    
if(count == 2 and count2 == 1):
    print("YES")
else:
	print("NO")
# Judge status: Wrong Answer
#S,T = map(int,input().split())
S,T = input().split()
#S = input()
print(S+T)
# Judge status: Accepted
s = input()[::-1]
s += "0"
n = len(s)
dp = [[10**7 for _ in range(2)] for _ in range(n+1)]
dp[0][0] = 0
for i in range(n):
	for j in range(2):
		x = int(s[i]) + j
		for a in range(10):
			kurisagaru = False
			if a >= x:
				b = 0
			else:
				b = 10 + a - x
				kurisagaru = True
			dp[i+1][kurisagaru] = min(dp[i+1][kurisagaru], dp[i][j]+a+b)
print(dp[n][0])
# Judge status: Accepted
import sys
import heapq 
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    A = list(map(lambda x : int(x) * -1, input().split()))
    heapq.heapify(A)

    for _ in range(M):
        a = heapq.heappop(A) * -1
        a = a // 2
        heapq.heappush(A, a * -1)

    print(sum(A) * -1)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
A, B, C, D = map(int, input().split())
print("Yes") if A > C else print("No")
# Judge status: Wrong Answer
W, a, b = map(int, input().split())

ans = min(abs(b - (a+W)), abs(a - (b+W)))
print(ans)
# Judge status: Accepted
N,C,K = list(map(int,input().split()))
T = [int(input()) for _ in range(N)]

T.sort()

cnt = 0
passengers = 0
due = 0
for t in T:
  if passengers == 0:
    cnt +=1
    passengers += 1
    due = t + K
  elif passengers > 0 and passengers < C and t <= due:
    passengers +=1
  elif t > due or passengers == C:
    passengers = 1
    due = t + K
    cnt +=1
  #print(t, passengers, due, cnt)

print(cnt)
# Judge status: Accepted
import sys
import math
import itertools as it
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    x, y = I2()
    cnt = 0
    while x <= y:
        x *= 2
        cnt += 1
    print(cnt)
# Judge status: Accepted
a, b = map(int, input().split())
def make_divisors(N):
	divisors = []
	for i in range(1, int(N**0.5)+1):
		if N % i == 0:
			divisors.append(i)
			if i != N // i:
				divisors.append(N//i)

	return divisors
import math
def is_prime(n):
	if n == 1:
		return False
	
	for k in range(2, int(math.sqrt(n)) + 1):
		if n%k == 0:
			return False
	return True
yakua = make_divisors(a)
yakub = make_divisors(b)
s = set(yakua) & set(yakub)
ans = []
for i in list(s):
	if is_prime(i):
		ans.append(i)
print (len(ans)+1)
# Judge status: Wrong Answer
D,N = map(int, input().split())

print(N * 100**D)
# Judge status: Accepted
import sys

input = sys.stdin.readline


def main():
    N, K = map(int, input().split())
    # A = list(map(int, input().split()))

    q, r, = divmod(N - 1, K - 1)
    ans = q + int(r > 0)

    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
x,y = map(int, input().split())
ans = 0
if x*y<0:
    ans = abs(x+y) +1
else:
    ans = abs(x-y)
    
    if 0 <= y and y < x:
        ans +=2
    elif x==0 and y < 0:
        ans +=1
    elif y < x and x < 0:
        ans +=2
print(ans)
# Judge status: Accepted
s = input()
n = int(input())
head = ''
tail = s
for _ in range(n):
    q = input()
    if q[0] == '1':
        head, tail = tail, head
    else:
        _, f, c = q.split()
        if f == '1':
            head += c
        else:
            tail += c
print(head[::-1] + tail)
# Judge status: Wrong Answer
from collections import *
n=int(input())
l=list(map(int,input().split()))
d=defaultdict(int)
for i in l:
    d[i]+=1
c=0
for i in d:
    if(i!=d[i]):
        c+=min(abs(i-d[i]),d[i])
print(c)
# Judge status: Accepted
h_1,m_1,h_2,m_2,k=map(int,input().split())
print(60*(h_2-h_1)+m_2-m_1-k)
# Judge status: Accepted
#!/usr/bin/env python3

from functools import reduce


def main():
    N, M = [int(x) for x in input().split()]
    A = [[int(x) for x in input().split()[1:]] for _ in range(N)]
    print(len(reduce(lambda a, b: a & b, map(lambda a: set(a), A))))


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
h = int(input())
def ans(x):
    return 2**(x)-1
count = 0
while(h>1):
    h/=2
    count+=1
print(ans(count))
# Judge status: Accepted
n = int(input())
a=1
m = n - 1
count = 0
while a < n:
  count = count + (m // a)
  a = a + 1
print(count)
# Judge status: Accepted
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

X, Y = inm()
INF = 1 << 50


def solve():
    ans = INF
    for x, y, c in [(X, Y, 0), (-X, Y, 1), (X, -Y, 1), (-X, -Y, 2)]:
        if y < x:
            continue
        ans = min(ans, c + y - x)
    return ans


print(solve())
# Judge status: Accepted
def main():
    S = list(str(input()))
    if S[0] != S[1] and S[1] != S[2] and S[0] != S[2]:
        print('Yes')
    else:
        print('No')
main()
# Judge status: Accepted
n = int(input())
print('{:.8f}'.format((n//2 + (n%2))/n))
# Judge status: Accepted
list_s = list(input())
for i in range(0, len(list_s)):
    if list_s[i] == 'U' or list_s[i] == 'D': continue
    elif (i % 2 == 0 and list_s[i] == 'R') or (i % 2 != 0 and list_s[i] == 'L'): continue
    else: print("No")
    exit()
print("Yes")
# Judge status: Accepted
n,a,c = raw_input(),map(int, raw_input().split(' ')), 0
for i in range(len(a)):
  if a[i] != i+1: c+=1
print 'YES' if c <=2 else 'NO'
# Judge status: Accepted
c = [[int(i) for i in input().split()] for _ in range(3)]
x = 0
for i in range(2):
    if c[0][i] - c[0][i + 1] == c[1][i] - c[1][i + 1] == c[2][i] - c[2][i + 1]:
        x += 1
for i in range(2):
    if c[i][0] - c[i + 1][0] == c[i][1] - c[i + 1][1] == c[i][2] - c[i + 1][2]:
        x += 1
if x == 4:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
S= list(input())
T= list(input())

N=len(S)

flag=0
for i in range(N):
  if S[0]!=T[0]:
    T.append(T[0])
    del T[0]
  elif S[0]==T[0]:
    #print(i,T)
    flag=1
    for j in range(1,N):
      if S[j]!=T[j]:
        flag=0
    break
        
print('Yes' if flag==1 else 'No')
# Judge status: Accepted
a,b=(int(i) for i in input().strip().split(" "))
n=b-a
k=(n*(n+1))//2
print(k-b)
# Judge status: Accepted
a,b=map(int,input().split())
g=1
while 1:
  if a==b:
    g=a
    break
  if a<b:
    k=a
    a=b
    b=k
  a-=b
ans=1
i=2
while i*i<=g:
  if g%i==0:
    ans+=1
    while g%i==0:
      g//=i
  i+=1
if g!=1:
  ans+=1
print(ans)
# Judge status: Accepted
n=int(input())
s=list(input())

import collections
c=collections.Counter(s)
c=c.most_common()

ans=1
for i in range(len(c)):
    ans *= (c[i][1]+1)
print((ans-1)%(10**9+7))
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
m=10**9+7
bo=[0]*61
bz=[0]*61
for i in a:
  t=format(i,'061b')
  for j in range(61):
    if t[j]=='0':
      bz[j]+=1
    else:
      bo[j]+=1
bo=bo[::-1]
bz=bz[::-1]
x=0
for i in range(61):
  x+=bo[i]*bz[i]*(2**i)
print(x)
# Judge status: Accepted
S=input()
T=input()
#条件は、SとTで、同じ文字が同じ場所に同数存在していること
d={}
#used=set()
for (s,t) in zip(S,T):
    try:
        if d[s]!=t:
            print("No")
            exit()
    except KeyError:
        #sとtの対応関係を記録
        d[s]=t

v=d.values() 
if len(v)!=len(set(v)):
    print("No")
else:
    print("Yes")
# Judge status: Wrong Answer
import sys
s=list(input())
odd=["R","U","D"]
even=["L","U","D"]
for i in range(len(s)):
  if i%2==0:
    if s[i] not in even:
      print("No")
      sys.exit()
  else:
    if s[i] not in odd:
      print("No")
      sys.exit()
print("Yes")
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
record = []
for i, a in enumerate(A):
    record += [(i, a)]
print(' '.join([str(s[0] + 1) for s in sorted(record, key=lambda x:x[1])]))
# Judge status: Wrong Answer
import math
A, B, X = [int(s) for s in input().split()]

def main():
    a = math.ceil(A / X)
    b = math.floor(B / X)
    print(b - a + 1)

if __name__ == '__main__':
    main()
# Judge status: Accepted
from collections import Counter
n = int(input())
d = Counter(list(input()))
val = d.values()
ans = 1
for i in val:
    ans *= (i + 1)
    ans %= 10**9 + 7
print(ans - 1)
# Judge status: Wrong Answer
from collections import Counter
N = int(input())
a = []
for i in range(N):
    inputs = int(input())
    a.append(inputs)
    
ans = dict(Counter(a))
ans = [kv[0] for kv in ans.items() if kv[1]==1]

print(len(ans))
# Judge status: Wrong Answer
n = int(input())
ab =[list(map(int,input().split())) for _ in range(n)]

a = []
b =[]
for x in ab:
  a.append(x[0])
  b.append(x[1])

a.sort()
b.sort()
ca,cb =0,0
if n % 2 == 0:
  ca = (a[n//2-1] + a[n//2])//2
  cb = (b[n//2-1] + b[n//2])//2
  ans = (cb-ca) / 0.5 +1
else:
  ca = a[(n+1)//2-1]
  cb = b[(n+1)//2-1]
  ans = (cb-ca) +1

print(int(ans))