Harryxun/stf_run huggingface dataset:
S = input()
K = int(input())

s = [v for v in S]

block = []
count = 1

for i in range(len(s)-1):
    if s[i] == s[i+1]:
        count += 1
        if i+2 == len(s):
            block.append(s[i]*count)
    else:
        block.append(s[i]*count)
        count = 1

z = len(block)
t = 0
d = 0

if not z == 1:
    for j in range(len(block)):
        x = len(block[j])
        if x == 1:
            continue
        else:
            if x%2 == 0:
                t += x//2
            elif x%2 == 1:
                t += x - (x+1)//2
    
    if block[0][0] == block[-1][-1]:
        joint = block[0] + block[-1]
        y = len(joint)
        if y%2 == 1:
            d = 0
        else:
            d = 1
else:
    p = len(block[0])
    if p%2 == 0:
        t = p//2
    else:
        t = (p-1)//2
        if K%2 == 1:
            ans = t + p*(K-1)//2                       
            print(ans)
            exit()
        else:
            ans = p + p*(K-2)//2
            print(ans)
            exit()

ans = t*K + d*(K-1)
print(ans)

### FIXED CODE ###

S = input()
K = int(input())

s = [v for v in S]

block = []
count = 1

if len(s) == 1:
    if K == 1:
        print(0)
        exit()
    else:
        if K%2 == 1:
            print((K-1)//2)
            exit()
        else:
            print(K//2)
            exit()

for i in range(len(s)-1):
    if s[i] == s[i+1]:
        count += 1
        if i+2 == len(s):
            block.append(s[i]*count)
    else:
        block.append(s[i]*count)
        count = 1

z = len(block)
t = 0
d = 0

if not z == 1:
    for j in range(len(block)):
        x = len(block[j])
        if x == 1:
            continue
        else:
            if x%2 == 0:
                t += x//2
            elif x%2 == 1:
                t += x - (x+1)//2
    
    if block[0][0] == block[-1][-1]:
        joint = block[0] + block[-1]
        y = len(joint)
        if y%2 == 1:
            d = 0
        else:
            d = 1
else:
    p = len(block[0])
    if p%2 == 0:
        t = p//2
    else:
        t = (p-1)//2
        if K%2 == 1:
            ans = t + p*(K-1)//2                       
            print(ans)
            exit()
        else:
            ans = p + p*(K-2)//2
            print(ans)
            exit()

ans = t*K + d*(K-1)
print(ans)
S=input()
if S= AAA or BBB
print(No)
 else print(YES)

### FIXED CODE ###

S=input()
if S == 'AAA' or S == 'BBB':
	print('No')
else:
	print('Yes')
A,B,C,D=list(map(int,input()))
ab=A*B
cd=C*D
if ab>cd:print(ab)
elif cd>ab:print(cd)
else:print(ab)

### FIXED CODE ###

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

ab = a*b
cd = c*d
if ab>cd:print(ab)
elif cd>ab:print(cd)
else:print(ab)
def main():
    n = int(input())
    c = []
    mod = 10 ** 9 + 7
    state = [0 for i in range(n+1)]
    dp = [0 for i in range(n+1)]
    dp[0] = 1
    for i in range(n):
        c_i = int(input())

        if state[c_i] >= 1 and state[c_i] != i:
            dp[i+1] = (dp[state[c_i]] + dp[i]) % mod

        else:
            dp[i+1] = dp[i] % mod

        state[c_i] = i + 1

    print(dp[-1] % mod)

main()


### FIXED CODE ###

def main():
    n = int(input())
    c = []
    mod = 10 ** 9 + 7
    state = [0 for i in range(n+200000)]
    dp = [0 for i in range(n+1)]
    dp[0] = 1
    for i in range(n):
        c_i = int(input())

        if state[c_i] >= 1 and state[c_i] != i:
            dp[i+1] = (dp[state[c_i]] + dp[i]) % mod
        else:
            dp[i+1] = dp[i] % mod

        state[c_i] = i + 1
    print(dp[-1] % mod)

main()
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

# MOD combination
def cmb(n, r, mod=10**9+7):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

N = 2*10**5+10
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ans=0
for i in range(n):
    ans+=i*(n-i)*m*m*cmb(n*m-2,k-2)
    ans%=mod

n,m=m,n
for i in range(n):
    ans+=i*(n-i)*m*m*cmb(n*m-2,k-2)
    ans%=mod

print(ans)

### FIXED CODE ###

import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
# from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

# MOD combination
def cmb(n, r, mod=10**9+7):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

N = 2*10**5+10
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ans=0
for i in range(n):
    ans+=i*(n-i)*m*m*cmb(n*m-2,k-2)
    ans%=mod

n,m=m,n
for i in range(n):
    ans+=i*(n-i)*m*m*cmb(n*m-2,k-2)
    ans%=mod

print(ans)
w=input()
s=set(list(w))

if len(s) = 2 and w.count(s[0]) = 2:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

w=input()
s=list(set(list(w)))

if len(s) == 2 and w.count(s[0]) == 2:
  print("Yes")
else:
  print("No")
import sys
sys.setrecursionlimit(100000)
readline = sys.stdin.readline

N , Q = map(int,readline().rstrip().split())
G = [[] for _ in range(N)]
for n in range(N-1):
    a , b = map(int,readline().rstrip().split())
    G[a-1].append(b-1)
query = []
[query.append( list(map(int,readline().rstrip().split()))) for _ in range(Q) ]
counter = [0] * N 
# visit = []

def dfs(root , x , visit):
    if visit[root] == 0:
        visit[root] = 1
        counter[root] += x
    else:
        return 0
    
    for g in G[root]:
        dfs( g, x , visit)
    
    return 0

def solve():
    for q in query:
        visit = [0] * N
        dfs(q[0]-1,q[1] , visit)
    [print(c , end="" ) for c in counter]
    print("")

if __name__ == "__main__":
    solve()

### FIXED CODE ###

import sys
sys.setrecursionlimit(10000000)
readline = sys.stdin.readline

N , Q = map(int,readline().rstrip().split())
G = [[] for _ in range(N)]
for n in range(N-1):
    a , b = map(int,readline().rstrip().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
query = [0] * N
for q in range(Q):
    p , x = map(int,readline().rstrip().split())
    query[p-1] += x
counter = [0] * N 
visit = [0] * N

def dfs(root , x ):
    if visit[root] == 0:
        visit[root] = 1
        x += query[root]
        counter[root] += x
    else:
        return 0
    
    for g in G[root]:
        dfs( g, x )

    return 0

def solve():
    dfs(0 , 0)
    [print(c , end = " " ) for c in counter]
    print("")

if __name__ == "__main__":
    solve()
# -*- coding: utf-8 -*-
from collections import defaultdict
from sys import setrecursionlimit
setrecursionlimit(100000)
def inpl(): return list(map(int, input().split()))
N = int(input())
A = inpl()

def calc(i):
    if i == N-2:
        return (A[i], A[i+1]), (-A[i], -A[i+1])
    else:
        X, Y = calc(i+1)
        return ([A[i], max(X[0] + X[1], Y[0] + Y[1])],
                [-A[i], max(-X[0] + X[1], -Y[0] + Y[1])])

print(max(map(sum, calc(0))))

### FIXED CODE ###

# -*- coding: utf-8 -*-
from collections import defaultdict
from sys import setrecursionlimit
setrecursionlimit(10**9)
def inpl(): return list(map(int, input().split()))
N = int(input())
A = inpl()

def calc(i):
    if i == N-2:
        return (A[i], A[i+1]), (-A[i], -A[i+1])
    else:
        X, Y = calc(i+1)
        return ([A[i], max(X[0] + X[1], Y[0] + Y[1])],
                [-A[i], max(-X[0] + X[1], -Y[0] + Y[1])])

print(max(map(sum, calc(0))))
import math

n, m = map(int, input().split(" "))
aL = sorted(list(map(int, input().split(" "))))
bcL = sorted([list(map(int,
                       input().split(" "))) for _ in range(m)],
             key=lambda x: x[1],
             reverse=True)

csl = 0
for cnt, point in bcL:
    for i in range(cnt):
        if aL[csl] >= point:
            print(sum(aL))
            exit()
        aL[csl] = point
        csl += 1

print(sum(aL))
exit()

### FIXED CODE ###

import math

n, m = map(int, input().split(" "))
aL = sorted(list(map(int, input().split(" "))))
bcL = sorted([list(map(int,
                       input().split(" "))) for _ in range(m)],
             key=lambda x: x[1],
             reverse=True)

csl = 0
for cnt, point in bcL:
    for i in range(cnt):
        if csl == n or aL[csl] >= point:
            print(sum(aL))
            exit()
        aL[csl] = point
        csl += 1

print(sum(aL))
exit()
a,n=map(int,input().split())

amari=n%500

if amari<a:
    print('Yes')

else:
    print('No')

### FIXED CODE ###

n=int(input())
a=int(input())

amari=int(n%500)

if amari<=a:
    print('Yes')

else:
    print('No')
n,m = map(int,input().split())
graph = {i+1:[] for i in range(n)}
for _ in range(m):
  a,b = map(int,input(),split())
  graph[a].append(b)
  graph[b].append(a)

count = 0
def func(path,p):
  if len(path) == n:
    count += 1
    return
  for i in graph[p]:
    if i in path:
      continue
    func(path+[i],i)
print(count)

### FIXED CODE ###

n,m = map(int,input().split())
graph = {i+1:[] for i in range(n)}
for _ in range(m):
  a,b = map(int,input().split())
  graph[a].append(b)
  graph[b].append(a)

def func(path,p,count):
  if len(path) == n:
    return count + 1
  for i in graph[p]:
    if i in path:
      continue
    count = func(path+[i],i,count)
  return count
print(func([1],1,0))
n = int(input())
b = list(map(int, input().split()))
s=0
if n==1:
  print(b[0]*2)
else:
  s = min(b[0],b[1])*2+b[-1]
  for i in range(1,n-1):
  	s+=min(b[i],b[i+1])
    
  print(s)
  
  

### FIXED CODE ###

n = int(input())
b = list(map(int, input().split()))
s=0
if n==2:
  print(b[0]*2)
else:
  if(b[0]<b[1]):
  	s = b[0]*2+b[-1]
  else:
  	s = b[0]+b[1]+b[-1]
  for i in range(1,n-2):
  	s+=min(b[i],b[i+1])
    
  print(s)
YAKINIKUFESTIVAL

### FIXED CODE ###

print raw_input()[:-8]
a = list(map(int, input().split()))
sum = a[0] + a[1]
if sum%2 == 0:
  return sum/2
else:
  return (sum + 1)/2

### FIXED CODE ###

a = list(map(int, input().split()))
sum = a[0] + a[1]
if sum%2 == 0:
  print(int(sum/2))
else:
  print(int((sum + 1)/2))
s=list(input())
u=[int(s[0]+s[1]),int(s[2]+s[3])]
if(u[0]<=12):
    m1=1
    if(u[1]<=12):
        m2=1
    else:
        m2=0
else:
    m1=0
    if(u[1]<=12):                                                                                                                           m2=1                                                                                                                            else:
        m2=0
if(m1==1 and m2==0):
    print('MMYY')                                                                                                                   elif(m1==1 and m2==1):
    print('AMBIGUOUS')
elif(m1==0 and m2==0):
    print('NA')
else:
    print('YYMM')

### FIXED CODE ###

s=list(input())
u=[int(s[0]+s[1]),int(s[2]+s[3])]
if(0<u[0]<=12):
    m1=1
    if(0<u[1]<=12):                                                                                                                                                                                                    m2=1
    else:
        m2=0
else:
    m1=0
    if(0<u[1]<=12):
        m2=1
    else:
        m2=0
if(m1==1 and m2==0):
    print('MMYY')
elif(m1==1 and m2==1):
    print('AMBIGUOUS')
elif(m1==0 and m2==0):
    print('NA')
else:
    print('YYMM')
import math
a,b = map(int,input().split())

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))


### FIXED CODE ###

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

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

print(int(lcm(a, b)))
import itertools
import sys


c = list(itertools.product(range(10), repeat=4))

if __name__ == '__main__':
    for line in sys.stdin.readlines():
        print sum([l for l in c if int(n) == sum(l)])

### FIXED CODE ###

import sys


for n in sys.stdin:
    ret = 0
    for a in xrange(10):
        for b in xrange(10):
            for c in xrange(10):
                for d in xrange(10):
                    if a+b+c+d == int(n):
                        ret += 1
    print ret
n = int(input())
li = list(map(int, input().split()))
tmpMinIndex = li.index(1)
count = 0

while True:
    count += 1
    tmpMinIndex = li[0:tmpMinIndex]
    if tmpMinIndex == 0:
        break

print(count)


### FIXED CODE ###

n = int(input())
li = list(map(int, input().split()))
tmpMin = li[0]
count = 0

for i in range(n):
    if li[i] <= tmpMin:
        tmpMin = li[i]
        count += 1

print(count)
k = int(input())

if k%2 == 0:
    print(-1)
    exit()
elif k == 1:
    print(1)
    exit()
elif k == 11:
    print(2)
    exit()
elif k == 101:
    print(4)
    exit()
elif 1001%k == 0:
    print(6)
    exit()
elif 10001%k == 0:
    print(8)
    exit()
elif 100001%k == 0:
    print(10)
    exit()
elif 1000001%k == 0:
    print(12)
    exit()
elif 10000001%k == 0:
    print(14)
    exit()
elif 100000001%k == 0:
    print(16)
    exit()
elif 1000000001%k == 0:
    print(18)
    exit()
elif 10000000001%k == 0:
    print(20)
    exit()
k = int(input())

if k%2 == 0:
    print(-1)
    exit()
elif k == 1:
    print(1)
    exit()
elif k == 11:
    print(2)
    exit()
elif k == 101:
    print(4)
    exit()
elif 1001%k == 0:
    print(6)
    exit()
elif 10001%k == 0:
    print(8)
    exit()
elif 100001%k == 0:
    print(10)
    exit()
elif 1000001%k == 0:
    print(12)
    exit()
elif 10000001%k == 0:
    print(14)
    exit()
elif 100000001%k == 0:
    print(16)
    exit()
elif 1000000001%k == 0:
    print(18)
    exit()
elif 10000000001%k == 0:
    print(20)
    exit()
elif 100000000001%k == 0:
    print(22)
    exit()
elif 1000000000001%k == 0:
    print(24)
    exit()
elif 10000000000001%k == 0:
    print(26)
    exit()
else:
    print(k-1)

### FIXED CODE ###

k = int(input())

def solve():
    if 7%k == 0:
        return 1
    val = 7
    for i in range(2, k + 1):
        val = val*10 + 7
        val = val%k
        if val == 0:
            return i

    return -1

print(solve())
import sys
import numpy as np

read = sys.stdin.buffer.read

H,W,M = list(map(int, input().split()))

hw = np.zeros((H+1,W+1),dtype=np.int64)
w = np.zeros(3*10**5,dtype=np.int64)
h = np.zeros(3*10**5,dtype=np.int64)
 
for i in range(M):
    h_i, w_j = map(int, input().split())
    hw[h_i-1, w_j-1] = 1
    h[h_i-1] += 1
    w[w_j-1] += 1

a = 0
d = 0
for i in np.where(h==h.max())[0]:
    for j in np.where(w==w.max())[0]:
        mxh_v = h[i]
        mxw_v = w[j]
        d = hw[i, j]
        # print(i,j,a, mxh_v , mxw_v , d)
        a = max(a, mxh_v + mxw_v - d)
    if d == 0:
        break
print(a)

### FIXED CODE ###

H,W,M = list(map(int, input().split()))

hw = set()
w = [0] * 3*10**5
h = [0] * 3*10**5

for i in range(M):
    h_i, w_j = map(int, input().split())
    hw.add((h_i-1) + (w_j-1)*3*10**6)
    h[h_i-1] += 1
    w[w_j-1] += 1

a = 0
d = 1
mxh_v = max(h)
mxw_v = max(w)

x = [i for i,j in enumerate(h) if j == mxh_v]
y = [i for i,j in enumerate(w) if j == mxw_v]

for i in x:
    for j in y:
        if not(i + j*3*10**6 in hw):
            print(mxh_v+mxw_v)
            exit()
print(mxh_v+mxw_v-d)
N=int(input())
A=list(map(int, input().split()))
master=False
if max(A)>=3200:
  master=True
  
def judge(n):
  return n//400

rate=[0]*8
for a in A:
  rate[judge(a)]+=1
  
count=0
for r in rate:
  if r!=0:
    count+=1
if master:
  MAX=min(count+1, 8)
else:
  MAX=count

print(count,MAX)

### FIXED CODE ###

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

  
def judge(n):
  return n//400

rate=[0]*8
masters=0
for a in A:
  if judge(a)<8:
    rate[judge(a)]+=1
  else:
    masters+=1
  
count=0
for r in rate:
  if r!=0:
    count+=1
MAX=count+masters


print(max(1,count),MAX)
S=str(input())

if ('hi' in S):
    print('Yes')
elif ('hii' in S)
    print('No')
else:
    print('No')

### FIXED CODE ###

S = input()

while len(S) >= 2:
    if S[0:2]== 'hi':
        S=S[2:]
    else:
        break
if len(S)==0:
    print('Yes')
else:
    print('No')
A,B,C,D=list(map(int,input().split()))
if A+B>C+D:
    print("Left")
elif A+B<C+D:
    print("Right)
else:
    print("Balanced")

### FIXED CODE ###

A,B,C,D=list(map(int,input().split()))
if A+B>C+D:
    print("Left")
elif A+B<C+D:
    print("Right")
else:
    print("Balanced")
n,m = map(int,input().split())
lis = [list(map(int,input().split())) for i in range(n)]
lis.sort()
cnt = 0
mon = 0
i = 0
if n >= 2:
    while cnt <= m:
        if lis[i][1] + cnt <= m:
            cnt += lis[i][1]
            mon += lis[i][0]*lis[i][1]
            i += 1
        else:
            break
    print(mon + (m-cnt) * lis[i][0])
else:
    print(m*lis[0][0])


### FIXED CODE ###

n,m = map(int,input().split())
lis = [list(map(int,input().split())) for i in range(n)]
lis.sort()
cnt = 0
mon = 0
i = 0
if n >= 2:
    while cnt < m:
        if lis[i][1] + cnt < m:
            cnt += lis[i][1]
            mon += lis[i][0]*lis[i][1]
            i += 1
        else:
            break
    print(mon + (m-cnt) * lis[i][0])
else:
    print(m*lis[0][0])
import sys
S = sys.stdin.readline().rstrip()
L = ['Sunny', 'Cloudy', 'Rainy']
if S ==L[0]:
    print(L[1])
elif S ==L[1]:
    print(L[2])
elif S ==L[2]:
    printf(L[0])


### FIXED CODE ###

#import sys
S = input()
#L = ["Sunny", "Cloudy", "Rainy"]

if S == "Sunny":
    print("Cloudy")
elif S =="Cloudy":
    print("Rainy")
elif S == "Rainy":
    print("Sunny")
import numpy as np
N, K = map(int, input().split())
A = np.array(list(map(int, input().split())))
new_l= np.array([A[0]])
for i in range(K):
    r = i%N
    if A[new_l[r]-1] in new_l:
        target = A[new_l[r]-1]
        break
    new_l=np.append(new_l,A[new_l[r]-1])
    i+=1

index = np.where(new_l == target)
index=list(index)[0][0]
right = new_l[:index]
left  = new_l[index:]
pattern = K-len(right)
n = pattern % len(left)
print(left[n-1])

### FIXED CODE ###

n,k = map(int,input().split())
A = [0]+list(map(int,input().split()))
visited = [False for _ in range(n+1)]
pos = 1
x = []
flg = False
for i in range(k):
    if visited[pos] == False:
        x.append(pos)
        visited[pos] = True
        pos = A[pos]
    else:
        flg = True
        pre = x.index(pos)
        loop = x[pre:]
        break
if not flg:
    print(pos)
else:
    print(loop[(k-pre)%len(loop)])
n=int(input())
a=[]
for i in range(n):
    m=int(input())
    if m in a:
        a.append(m)
    else:
        a.remove(a)
print(len(a))

### FIXED CODE ###

from collections import defaultdict
n=int(input())
a=[]
d=defaultdict(int)
D=[]
for i in range(n):
    a.append(input())

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

for k,v in d.items():
    if v%2==1:
        D.append(k)
print(len(D))
r=int(input())
print(r**2)


### FIXED CODE ###

from math import pi
r = float(input())
a = pi*r*r
b = 2*pi*r
print(a,b)
import math

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


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


for i in range(1, k + 1):
    if k - 1 == i - 1:
        tmp1 = 1
    else:
        tmp1 = combinations_count(k - 1, i - 1) % 1000000007
    if n - k + 1 == i:
        tmp2 = 1
    else:
        tmp2 = combinations_count(n - k + 1, i) % 1000000007
    print((tmp1 * tmp2) % 1000000007)


### FIXED CODE ###

import math

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


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


for i in range(1, k + 1):
    if n - k + 1 >= i:
        tmp1 = combinations_count(k - 1, i - 1) % 1000000007
        tmp2 = combinations_count(n - k + 1, i) % 1000000007
        ans = (tmp1 * tmp2) % 1000000007
        print(ans)
    else:
        print(0)
from collections import defaultdict, deque
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate
import sys


def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


def main():
    n = I()
    num = LI()
    for i in range(n):
        for j in range(n):
            tmp[i], tmp[j] = tmp[j], tmp[i]
            if tmp == sorted(num):
                return 'YES'
    return 'NO'


print(main())

### FIXED CODE ###

from collections import defaultdict, deque
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate
import sys


def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


def main():
    n = I()
    num = LI()
    for i in range(n):
        for j in range(n):
            tmp = num.copy()
            tmp[i], tmp[j] = tmp[j], tmp[i]
            if tmp == sorted(num):
                return 'YES'
    return 'NO'


print(main())
n = int(input())
n = int(input())
s = input()
if s[:n//2] == s[n//2:]:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n = int(input())
s = input()
if s[:n//2] == s[n//2:]:
    print("Yes")
else:
    print("No")
import sys
input = sys.stdin.readlines()
n,q = map(int,input().split())
s = input()
l = []
r = []
cnt = []
for i in range(q):
    _l,_r = [int(i) for i in input().split()]
    l.append(_l)
    r.append(_r)
for i in range(q):
    cnt.append(s[l[i]-1:r[i]].count('AC'))
for i in range(len(cnt)):
    print(cnt[i])


### FIXED CODE ###

import sys
input = sys.stdin.readline
n,q = map(int,input().split())
s = input()
t = [0] * (n+1)
for i in range(n):
    t[i+1] = t[i] + (1 if s[i:i+2]=='AC' else 0)
for i in range(q):
    l,r = map(int,input().split())
    print(t[r-1] - t[l-1])
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 18 13:12:09 2019

@author: reimu
"""

a = map(int, input().split())
if a.count(5) == 2 and a.count(7) == 1:
    print('YES')
else:
    print('NO')

### FIXED CODE ###

a = list(map(int, input().split()))
if a.count(5) == 2 and a.count(7) == 1:
    print('YES')
else:
    print('NO')
n = raw_input().split()
x = map(int, raw_input().split())
 
if n = 0 : break
x.reverse()
print(x)


### FIXED CODE ###

input()
a = map(int, raw_input().split())
 
a.reverse()
print(" ".join(map(str, a)))
k=int(input())
if n%2==0:
    print(int(n*n/4))
else:
    print(int((n-1)*(n+1)/4))

### FIXED CODE ###

n=int(input())
if n%2==0:
    print(int((n*n)/4))
else:
    print(int(((n-1)*(n+1))/4))