Harryxun/stf_run huggingface dataset:
n = map(int,input().split())

nana = 0
go = 0

for i in n:
    if i == 5:
        go +=1
    elif i ==7:
        nana +=1

if nana ==1 and go ==2:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

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

nana = 0
go = 0

for i in n:
    if i == 5:
        go +=1
    elif i ==7:
        nana +=1

if nana ==1 and go ==2:
    print("YES")
else:
    print("NO")
import sys,queue,math,copy,itertools
from fractions import gcd
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())

ans = 10**5+1
for i in range(len(S)-1):
    if S[i] != S[i+1]:
        ans = min(ans,max(i+1,len(S)-i-1))
if ans == 0: ans = len(S)

print (ans)



### FIXED CODE ###

import sys,queue,math,copy,itertools
from fractions import gcd
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())

S = input()
ans = len(S)
for i in range(len(S)-1):
    if S[i] != S[i+1]:
        ans = min(ans,max(i+1,len(S)-i-1))

print (ans)
from bisect import bisect, bisect_left
import sys

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

def search_1(start):
	return bisect(x, x[start] + l) - 1

route = [[] for _ in range(n)]

i = 0 # 親の位置
for i in range(n - 1):
	if route[i] == []:
		j = search_1(i) # カーソルの位置
		num = 1 # 何日目の場所か
		route[i].append(j)
		if route[j] == []:
			route[j] = (i, num)
		else: # 既に他の親が通っている
			route[i] += route[route[j][0]][route[j][1]:]
			continue
		while j < n - 1:
			j = search_1(j)
			num += 1
			route[i].append(j)
			if route[j] == []:
				route[j] = (i, num)
			else: # 既に他の親が通っている
				route[i] += route[route[j][0]][route[j][1]:]
				break
	else:
		continue

# print(route)

def search_2(start, goal):
	if type(route[start]) == type([]):
		return bisect_left(route[start], goal) + 1
	else:
		return bisect_left(route[route[start][0]][route[start][1]:], goal) + 1



q = int(input())
for _ in range(q):
	a, b = map(int, sys.stdin.redline().strip().split())
	if a > b:
		a, b = b, a
	print(search_2(a - 1, b - 1))

### FIXED CODE ###

from bisect import bisect

n = int(input())
x = list(map(int, input().split()))
l = int(input())
q = int(input())

#r[i][j]: jから(2**i)日で行ける右端
r = [[i for i in range(n)] for _ in range(18)]
for j in range(n):
	r[0][j] = bisect(x, x[j]+l) - 1
for i in range(1, 18):
	for j in range(n):
		r[i][j] = r[i-1][r[i-1][j]]

def search(x, y):
	res = 0
	cur = x
	while True:
		for i in range(18):
			if r[i][cur] >= y:
				if i == 0:
					return res+1
				cur = r[i-1][cur]
				res += 1 << (i-1) 
				break

for _ in range(q):
	a, b = map(int, input().split())
	print(search(min(a, b)-1, max(a, b)-1))
N = int(input())
X = list(map(int, input().split()))

MaxX = max(X)
MinX = min(X)

ListP = []

for i in range(MinX, MaxX):
    P = 0
    for j in range(N):
        P += (X[j]-i)**2
    
    ListP.append(P)

print(min(ListP))

### FIXED CODE ###

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

a = min(X)
b = max(X)

ans = []

for i in range(a,b+1):
  S = 0
  for j in range(N):
    S += (X[j]-i)**2

  ans.append(S)
  
print(min(ans))
import math

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

count = 0

for i in range(n):
  x, y = map(int, input().split())
  if math.sprt((abs(x)**2) + (abs(y)**2)) <= d:
    count += 1

### FIXED CODE ###

import math

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

count = 0

for i in range(n):
  x, y = map(int, input().split())
  if math.sqrt((x)**2 + (y)**2) <= d:
    count += 1

print(count)
n, k = map(int, raw_input().split())
sum = 0
array = []
for i in range(n):
    a, b = map(int, raw_input().split())
    sum += b
    if k <= sum:
        break
    for j in range(b):
        array.append(a)

array.sort()
print array[k]


### FIXED CODE ###

n, k = map(int, raw_input().split())
counter = {}
for i in range(n):
    a, b = map(int, raw_input().split())
    if counter.has_key(a):
        counter[a] += b
    else:
        counter[a] = b

num = 0
for ele in sorted(counter.items()):
    num += ele[1]
    if k <= num:
        print ele[0]
        break
N = int(input())
print('Yes' if 9 in N else 'No')

### FIXED CODE ###

print("Yes" if input() in input()*2 else "No")
n,m,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))

print(["War","No War"][X<min(y) and max(x)<Y and max(x)<min(y)])



### FIXED CODE ###

abc = list(map(int,input().split()))
abc.sort()
print(abc[0]+int(str(abc[2])+str(abc[1])))
a,b,c = map(int,input().split())

print(a+b+c)


### FIXED CODE ###

D = input()

A="1"
B="11"
C="101"
F="111"

if F == D:
    print(3)
    
elif B in D:
    print(2)

elif C == D:
    print(2)

elif A in D:
    print(1)

else:
    print(0)
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))

import bisect

color = []
color.append(a.pop(0))
color_count =0 
for i, ai in enumerate(a): 
    index = bisect.bisect_left(color, ai)
    print(index-1, ai, color)
    if index > 0:
        color[index -1] = ai
    else:
        color.insert(0, ai)
print(len(color), color)

### FIXED CODE ###

n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
from collections import deque
import bisect

color = deque([a.pop(0)])
color_count =0 
for ai in a: 
    index = bisect.bisect_left(color, ai)
    if index > 0:
        color[index -1] = ai
    else:
        color.appendleft(ai)
print(len(color))
s = input()
t = input()
S = ''.join(list(s).sort)
T = ''.join(list(t).reverse)
print("Yes" if S < T else "No")


### FIXED CODE ###

s = input()
t = input()
S = ''.join(list(sorted(s)))
T = ''.join(list(sorted(t,reverse = True)))
print("Yes" if S < T else "No")
A,B,C = map(int,input.split())
if A == B:
	print(C)
elif B == C:
	print(A)
else:
	print(B)

### FIXED CODE ###

A,B,C = map(int,input().split())
if A == B:
	print(C)
elif B == C:
	print(A)
else:
	print(B)
s = str(int(input()))

if 1 <= int(s[0:2]) and int(s[0:2]) <= 12:
    if 1 <= int(s[2:4]) and int(s[2:4]) <= 12:
        print('AMBIGUOUS')
    else:
        if int(s[2:4]) != 0:
            print('MMYY')
        else:
            print('NA')
elif int(s[0:2]) == 0:
    print('NA')
else:
    if 1 <= int(s[2:4]) and int(s[2:4]) <= 12:
        if int(s[2:4]) != 0:
            print('YYMM')
        else:
            print('NA')
    else:
        print('NA')


### FIXED CODE ###

s = input()
i = int(s[:2])
j = int(s[2:])
if 1 <= i and i <= 12:
    if 1 <= j and j <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:    
    if 1 <= j and j <= 12:
        print('YYMM')
    else:
        print('NA')
n, l = (int(x) for x in input().split())
while range(n + 1):
    s = list(x for x in input.split())

s.sort()
ans = 0
while range(n + 1):
    ans += s[n]

### FIXED CODE ###

n, l = (int(x) for x in input().split())
s = [input() for a in range(n)]
print("".join(sorted(s)))
N = int(input())
A = list(map(int,input().split())
ans = -100
for i in range(N):
  for j in range(i, N):
    s = abs(A[i] - A[j])
    ans = max(ans, s)
print(ans)

### FIXED CODE ###

N = input()
A=sorted(map(int,input().split()),reverse = True)
s = A[0]-A[-1]
print(s)
S = input()
if(S == ABC):
  print("ARC")
else:
  print("ABC")

### FIXED CODE ###

S = input()
if(S == "ABC"):
  print("ARC")
else:
  print("ABC")
#import numpy as np
#import collections
#import math

#f = open('./input_E.txt')
#
#N,K = map(int, f.readline().split())
#A = list(map(int, f.readline().split()))

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

if K == 0:
    ans = max(A)
else:
    A.sort(reverse=True)
    
    All_length = sum(A)
    KK = K+N-1
    lm = All_length/(KK+1)
    
    k_list = [int(Ai//lm) for Ai in A]
    X_list = [Ai%lm for Ai in A]
    Xmax = max(X_list)

    zero_k = 0
    for i in range(1,N+1):
        if k_list[-i] == 0:
            zero_k +=1
        else:
            break
    
    sum_k = sum(k_list)-(N-zero_k)
    res_cut = K-sum_k
    
    
    if res_cut > 0:
#        think = min(7*(N//res_cut)+1,res_cut)
        ans_kouho = []
#        for i in range(-zero_k,0):
#            ans_kouho.append(A[i])
#        ans_kouho.extend(X_list)
        for i in range(res_cut):
#        for i in range(think):
            if Xmax >= i*lm:
                for j in range(N-zero_k):
#                    ans_kouho.append((X_list[j]-i*lm)/k_list[j]+1)
                    ans_kouho.append(A[j]/(k_list[j]+i))
        
        ans_kouho.sort(reverse=True)
        ans = ans_kouho[res_cut]
        ans = int(ans+1)
    else:
        ans = int(lm+1)
print(ans)

### FIXED CODE ###

#import numpy as np
#import collections
#import math

#f = open('./input_E.txt')
#
#N,K = map(int, f.readline().split())
#A = list(map(int, f.readline().split()))

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

A.sort(reverse=True)

def nibu(small,big,KK,AA):
    mid = (small+big)//2
    k_list = [(x-1)//mid for x in AA]
    sum_k = sum(k_list)
    if sum_k <= KK: #達成可能 -> 答えはもっと小さい
        return small,mid # 不可能,可能
    else:
        return mid,big # 不可能,可能


if K==0:
    ans = A[0]
else:    
    lmin = 0
    lmax = A[0]
    
    while lmax - lmin >= 2:
        lmin, lmax = nibu(lmin,lmax,K,A)
    
    ans = lmax
    
print(ans)
import sys
sys.setrecursionlimit(20000)

class UnionFind:
    def __init__(self,N):
        self.par = [i for i in range(N)]

    def root(self,x):
        if self.par[x] == x:
            return x
        self.par[x] = self.root(self.par[x])
        return self.par[x]

    def unite(self,x,y):
        self.rx = self.root(x)
        self.ry = self.root(y)
        if self.rx == self.ry:
            return
        self.par[self.rx] = self.ry

    def same(self,x,y):
        self.rx = self.root(x)
        self.ry = self.root(y)
        return self.rx == self.ry

N,M = [int(i) for i in input().split()]
uf = UnionFind(N)

for _ in range(M):
    x,y,_ = [int(i)-1 for i in input().split()]
    uf.unite(x,y)

ans = set()
for i in range(N):
    ans.add(uf.root(i))
print(len(ans))


### FIXED CODE ###

import sys
sys.setrecursionlimit(200000)

class UnionFind:
    def __init__(self,N):
        self.par = [i for i in range(N)]

    def root(self,x):
        if self.par[x] == x:
            return x
        self.par[x] = self.root(self.par[x])
        return self.par[x]

    def unite(self,x,y):
        self.rx = self.root(x)
        self.ry = self.root(y)
        if self.rx == self.ry:
            return
        self.par[self.rx] = self.ry

    def same(self,x,y):
        self.rx = self.root(x)
        self.ry = self.root(y)
        return self.rx == self.ry

N,M = [int(i) for i in input().split()]
uf = UnionFind(N)

for _ in range(M):
    x,y,_ = [int(i)-1 for i in input().split()]
    uf.unite(x,y)

ans = set()
for i in range(N):
    ans.add(uf.root(i))
print(len(ans))
A,B = [int(x) for x in input().spit()]

if (A>=10)&&(B>=10):
  print("-1")
else:
  print(A*B)


### FIXED CODE ###

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

if (A>=10)or(B>=10):
  print("-1")
else:
  print(A*B)
N,K=map(int,input().split())
A=list(map(int,input().split()))
now=1
count=0
a=0
l=[1]
b=0
c=0
q=[True]*N
while a==0and count<K:
    now=A[now-1]
    count+=1
    if q[now-1]:
        a=1
    else:
        l.append(now)
        q[now-1]=False
        
b=l.index(now)
c=count-b
if count==K:
    print(now)
else:
    n= ((K-b)%c)
    print(l[b+n])



### FIXED CODE ###

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

s = [True] * n #訪れているかを判定するlist
c = [1] #訪ずれた順番を記録するlist
now = 0 #現在地
while s[now]:
    s[now] = False #訪ずれた地点を記録
    now = a[now] - 1
    c.append(now+1)

start_cycle = c.index(c[-1]) #ループに入る点
loop = c[start_cycle:-1] #ループのlist
cycle = len(loop)

if k < start_cycle: #ループまで到達できないK
    print(c[k])
else:
    k -= start_cycle
    k %= cycle
    print(loop[k])
def main():
    N=input()
    A=list(map(int, input().split()))

    mod_value = 10**9 + 7
    sum_ = 0
    b_sum = 0
    for i in range(len(A)-1):
        b_sum = b_sum + A[len(A)-i-1]
        sum_ = sum_ + (A[len(A)- i - 2]*b_sum) % mod_value
    print(sum_%mod_value)
main()

### FIXED CODE ###

def main():
    D, T, S = map(int, input().split())
    if float(T) < float(D) /float(S) :
        print("No")
    else:
        print("Yes")
    #N = int(input())
    #A = [int(s) for s in input().split()]
    #

main()
# coding: UTF-8
x = imput()
print x **= 3


### FIXED CODE ###

x = input()
print (x ** 3)
import math
&#160;
r = 50000
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
&#160;&#160;&#160;&#160;if p[i]:
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for j in range(2*i+1,r,i+1):
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;p[j] = 0
&#160;
while True:
&#160;&#160;&#160;&#160;try:
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;n = int(raw_input())
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for i in range(n,50000):
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;    if p[i] == 1:
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;        lp = i
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;        break
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for i in range(n-1,3,-1):
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;    if p[i] == 1:
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;        sp = i
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;        break
&#160;&#160;&#160;&#160;&#160;&#160;&#160; print lp, sp
&#160;&#160;&#160;&#160;except:
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;break

### FIXED CODE ###

import math

n = []
while True:
    try:
        n.append(int(raw_input()))
    except:
        break
    
r = max(n)+100
sqrt = int(math.sqrt(r))
p = [1]*r
p[0] = 0
for i in range(1,sqrt):
    if p[i]:
        for j in range(2*i+1,r,i+1):
            p[j] = 0

for a in n:
    for i in range(a,r):
       if p[i] == 1:
            lp = i+1
            break
    for i in range(a-2,0,-1):
        if p[i] == 1:
            sp = i+1
            break
    print sp, lp
import math

a, b = map(str, input().split())
c = a + b
d = math.sqrt(int(c))
if isinstance(i, int):
  print("Yes")
else:
  print("No")


### FIXED CODE ###

import math

a, b = map(str, input().split())
c = a + b
d = math.sqrt(int(c))
if d % 1 == 0:
  print("Yes")
else:
  print("No")
a = int(input())
4000
s = input()
yes
if a >= 3200:
    print(s)
else:
    print("red")
    

### FIXED CODE ###

a = int(input())

s = input()

if a >= 3200:
    print(s)
else:
    print("red")
c = 0
for i in range(1, N+1):
  if i % 2 == 0:
    c+=1

print(c/N)




### FIXED CODE ###

N = int(input())
c = 0
for i in range(1, N+1):
  if i % 2 == 1:
    c+=1

print(c/N)
# coding: utf-8

# In[1]:

import sys
#input = sys.stdin.readline
N, K = map(int, input().split())
S = input()


# In[2]:

#print(N, K)
#print(len(S), S)


# In[4]:

tmp = S[0]
sums = [0]*(N+1)
counter = 1
gc = N
nb = 0
for i in range(1, N):
    if S[i] != tmp:
        sums[nb+1] = i
        nb += 1
        counter = 0
        tmp = S[i]
    else:
        gc -= 1
    counter += 1
    if i == N-1:
        sums[nb+1] = i+1

#print(N, gc)
sums = sums[:gc+1]
pl = [0]*gc
if gc < K*2:
    print(N)
else:
    if S[0] == "0":
        for i in range(-1, gc-K*2+1, 2):
            j = 0 if i < 0 else i
            pl[i] = sums[i+1+K*2]-sums[j]
    else:
        for i in range(0, gc-K*2+1, 2):
            j = i
            pl[i] = sums[i+1+K*2]-sums[j]
    print(max(pl))


# In[ ]:





### FIXED CODE ###


# coding: utf-8

# In[5]:

import sys
#input = sys.stdin.readline
N, K = map(int, input().split())
S = input()


# In[6]:

#print(N, K)
#print(len(S), S)


# In[21]:

tmp = S[0]
sums = [0]*(N+2)
counter = 1
gc = N
nb = 0
for i in range(1, N):
    if S[i] != tmp:
        sums[nb+1] = i
        nb += 1
        counter = 0
        tmp = S[i]
    else:
        gc -= 1
    counter += 1
    if i == N-1:
        sums[nb+1] = i+1

#print(N, gc)
sums = sums[:gc+2]
#print(S)
#print(sums)
#print(gc)
#print(gc-K*2)
pl = [0]*(gc+2)
if gc < K*2:
    print(N)
else:
    if S[0] == "0":
        if S[-1] == "0":
            for i in range(-1, gc-K*2+1, 2):
                #print(i, i+1+K*2, gc)
                j = 0 if i < 0 else i
                l = gc if i+1+K*2>gc else i+1+K*2
                #print(j, l)
                pl[i] = sums[l]-sums[j]
        else:
            for i in range(-1, gc-K*2, 2):
                j = 0 if i < 0 else i
                pl[i] = sums[i+1+K*2]-sums[j]
    else:
        if S[-1] == "0":
            for i in range(0, gc-K*2+1, 2):
                #print(i, i+1+K*2, gc)
                j=i
                l = gc if i+1+K*2>gc else i+1+K*2
                #print(j, l)
                pl[i] = sums[l]-sums[j]
        else:
            for i in range(0, gc-K*2, 2):
                j = i
                pl[i] = sums[i+1+K*2]-sums[j]
    #print(pl)
    print(max(pl))


# In[ ]:
def gcd(x,y):
  if y == 0:
    return x
  else:
    return gcd(y,x%y)

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]


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

GCD = gcd(a,b)
count = 0
for prime in primes(GCD):
    if GCD % prime == 0:
        count += 1
print(count+1)

### FIXED CODE ###

def gcd(x,y):
  if y == 0:
    return x
  else:
    return gcd(y,x%y)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr



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

GCD = gcd(a,b)

fac = factorization(GCD)

if fac[0][0] == 1:
    print(1)
else:
    print(len(factorization(GCD))+1)
from math import gcd



a,b,n=map(int,input().split())
t=a*b//gcd(a,b)
if a==1:
    print(0)
    exit()

ans=[]

n%=t
for i in range(1,n+1):
    y=int(a*i/b)-a*int(i/b)
    ans.append(y)


print(max(ans))


### FIXED CODE ###


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

def f(x):
    return a*x//b-a*(x//b)

print(f(min(n,b-1)))
#!/usr/bin/env python
#coding: UTF-8
import sys
import math

line = []
for l in sys.stdin:
    for i in l.split(' '):
    	line.append(float(i))
print math.sqrt((line[0]-line[2])**2+(line[1]-line[3])**2)

### FIXED CODE ###

import math

x1,y1,x2,y2 = map(float,raw_input().split())
a = math.sqrt((x1-x2)**2+(y1-y2)**2)
print '%f'%a
def calc0toN(a):
  bina = int(bin(a)[2:]) 
  if a % 2 == 0:
    if a % 4 == 0:
      return bina
    else:
      return 1 | bina
  else:
    if (a + 1) % 4 == 0:
      return 0
    else:
      return 1
A, B = map(int, input().split())
print(int("0b" + str(calc0toN(A - 1) | calc0toN(B)), 2))

### FIXED CODE ###

def calc0toN(a):
  if a % 2 == 0:
    if a % 4 == 0:
      return a
    else:
      return 1 ^ a
  else:
    if (a + 1) % 4 == 0:
      return 0
    else:
      return 1
A, B = map(int, input().split())
print(calc0toN(A - 1) ^ calc0toN(B))
import sys
h,w = map(int,input().split())
matrix = [[0]*(h+2) for _ in range(w+2)]
for hi in range(h):
    all_inp = input()
    for i,a in enumerate(all_inp):
        matrix[hi+1][i+1]= 0 if a == '.' else 1
print(matrix)
for ri,row in enumerate(matrix):
    for ci,column in enumerate(row):
        if column == 1:
            if row[ci-1] == 0 and row[ci+1] == 0 and matrix[ri-1][ci] == 0 and matrix[ri+1][ci] == 0:
                print('No')
                sys.exit()
print('Yes')

### FIXED CODE ###

import sys
h,w = map(int,input().split())
matrix = [[0]*(w+2) for _ in range(h+2)]
for hi in range(h):
    all_inp = input()
    for i,a in enumerate(all_inp):
        matrix[hi+1][i+1]= 1 if a == '#' else 0
#print(matrix)
for ri,row in enumerate(matrix):
    for ci,column in enumerate(row):
        if column == 1:
            if row[ci-1] == 0 and row[ci+1] == 0 and matrix[ri-1][ci] == 0 and matrix[ri+1][ci] == 0:
                print('No')
                sys.exit()
print('Yes')
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
from itertools import permutations,groupby
import sys
import bisect
import string
alp=string.ascii_lowercase
sys.setrecursionlimit(10**6)
def SI():
    return input().split()
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
mo=10**9+7
#mo=998244353
#input=sys.stdin.readline

n,k=MI()
a=LI()
c=[0]*(n+1)
t=[0]*(2000+10)
for i in range(n):
    c[a[i]]+=1
    tmp=0
    for j in range(i):
        tmp+=1 if a[j]>a[i] else 0
    t[i]=tmp

A=[0]
for i in c:
    A+=[i+A[-1]]
q=0
for i in range(n):
    q+=A[a[i]]
#q=sum(A[:-1])
q%=mo
q*=k*(k-1)//2
q%=mo

ans=k*sum(t)%mo
ans+=q
print(ans%mo)
#print(c,A,t,ans%mo)

### FIXED CODE ###

from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
from itertools import permutations,groupby
import sys
import bisect
import string
alp=string.ascii_lowercase
sys.setrecursionlimit(10**6)
def SI():
    return input().split()
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
mo=10**9+7
#mo=998244353
#input=sys.stdin.readline

n,k=MI()
a=LI()
c=[0]*(2000+10)
t=[0]*(2000+10)
for i in range(n):
    c[a[i]]+=1
    tmp=0
    for j in range(i):
        tmp+=1 if a[j]>a[i] else 0
    t[i]=tmp

A=[0]
for i in c:
    A+=[i+A[-1]]
q=0
for i in range(n):
    q+=A[a[i]]
#q=sum(A[:-1])
q%=mo
q*=k*(k-1)//2
q%=mo

ans=k*sum(t)%mo
ans+=q
print(ans%mo)
#print(c,A,t,ans%mo)
d, n = map(int, input().split())

if d = 0:
  if n <= 99:
    print(n)
  else:
    print(101)
elif d = 1:
  if n <= 99:
    print(100*n)
  else:
    print(10100)
else:
  if n <= 99:
    print(10000*n)
  else:
    print(1010000)
  

### FIXED CODE ###

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

if d == 0:
    if n <= 99:
        print(n)
    else:
        print(101)
elif d == 1:
    if n <= 99:
        print(n*100)
    else:
        print(10100)
elif d == 2:
    if n <= 99:
        print(n*10000)
    else:
        print(1010000)
import sys

if sum(for n in map(int, next(sys.stdin).split()) if n % 2 == 1) % 2 == 0:
    print('YES')
else:
    print('NO')


### FIXED CODE ###

import sys

next(sys.stdin)
ns = list(map(int, next(sys.stdin).split()))

if len(ns) == 1:
    print('YES')
    exit()

if sum(1 for n in ns if n % 2 == 1) % 2 == 0:
    print('YES')
else:
    print('NO')
from sys import stdin
A = stdin.readline().rstrip()

weather = ["Sunny", "Cloudy", "Rainy", "Sunny"]

for i in round(len(weather) - 1):
    if A == weather[i]:
        t = i
        break
    else:
        i += 1


print(weather[t+1])




### FIXED CODE ###

from sys import stdin
A = stdin.readline().rstrip()

weather = ["Sunny", "Cloudy", "Rainy", "Sunny"]

for i in range(len(weather)):
    if A == weather[i]:
        t = i
        break
    else:
        i += 1


print(weather[t+1])
n=input().split()
n=[int(i) for i in n]
h=[0]*n[0]
for i in range(n[0]):
    #h.append(int(input()))
    h[i]=int(input())
h.sort()

q=-1
for i in range(len(h)):
    a=h[i+n[1]-1]-h[i]
    if q==-1 or q>a:
        q=a
    if q==0:
        break
print(q)

### FIXED CODE ###

n=input().split()
n=[int(i) for i in n]
h=[0]*n[0]
for i in range(n[0]):
    h[i]=int(input())
h.sort()
q=-1
for i in range(0,len(h)-n[1]+1):
    a=h[i+n[1]-1]-h[i]
    if q==-1 or q>a:
        q=a
print(q)
a = int(input())
b = int(input())

if b-a == 0:
    print("Even")
else:
    print("Odd")

### FIXED CODE ###

a,b = map(int,input().split())
if (a% 2 ==0)or(b% 2 ==0):
    print("Even")
else:
    print("Odd")