Harryxun/stf_run huggingface dataset:
import sys
input=sys.stdin.readline
a = input()
while (int(a) != 0):
    remain = [0for i in range(2019)]
    remain[int(a[0])] = remain[int(a[0])] + 1  ##V0
    n = len(a)
    cnt = 0
    for i in range(1,n):
        copy = remain[:]
        remain = [0for i in range(2019)]
        a_i = int(a[i])
        if (a_i != 0):
            for k in range(2019):
                rem = (k*10 + a_i)%2019
                remain[rem] += copy[k]
            remain[a_i] += 1
        elif (a_i == 0):
            for k in range(2019):
                rem = (k*10 + a_i)%2019
                remain[rem] += copy[k]
        cnt += remain[0]
    print(cnt)
    exit(0)


### FIXED CODE ###


"""
：余りの等しい物をカウントし、その累積和
：Aの余りとBの余り(mod 2019)が等しい場合
　A-Bは2019の倍数である
：計算量を抑えるため各項と１０の指数乗は分けて計算する
：
"""

import sys
input=sys.stdin.readline
s = input()[:-1][::-1] # 入力文字列を逆順でsに格納

counts = [0] * 2019
counts[0] = 1

num, d = 0, 1

for char in s:
    num += int(char) * d
    num %= 2019
    d *= 10
    d%= 2019
    counts[num] += 1

ans = 0

for cnt in counts:
    ans += cnt * (cnt - 1) // 2

print(ans) # 答えの出力
N = int(input())
h_ls = list(map(int,input().split(" ")))

h_ls = np.array(h_ls)
n = 0
h_len = len(h_ls)
while max(h_ls)!=0:
    max_ind = h_ls.argmax()
    d = 0
    while max_ind+d < h_len -1 and h_ls[max_ind+d+1]==h_ls[max_ind]:
        d+=1
    h_ls[max_ind:max_ind+d+1] =h_ls[max_ind:max_ind+d+1]-1
    n+=1

print(n)


### FIXED CODE ###

import numpy as np

N = int(input())
h_ls = list(map(int,input().split(" ")))

h_ls = np.array(h_ls)
n = 0
h_len = len(h_ls)
while max(h_ls)!=0:
    max_ind = h_ls.argmax()
    d = 0
    while max_ind+d < h_len -1 and h_ls[max_ind+d+1]==h_ls[max_ind]:
        d+=1
    h_ls[max_ind:max_ind+d+1] =h_ls[max_ind:max_ind+d+1]-1
    n+=1

print(n)
n, k = map(int, input().split())
h = list()
ans = list()

for i in range(n):
    h.append(int(input()))
h.sort()

for i in range(n-k+1):
    ans.append(h[i+k-1] - h[i])

print(min(ans))

### FIXED CODE ###

print('Christmas' + ' Eve' * (25 - int(input())))
a,b,c = int(input()).split()

if a <=c and b >= c:
  	print("Yes")
else:
  	print("No")

### FIXED CODE ###

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

if a <=c and b >= c:
  	print("Yes")
else:
  	print("No")
a, b, c = map(int, input().split())
if a + b >=  c:
  print(b + c)
else:
  print(c + b - 1)
a, b, c = map(int, input().split())
if a + b >=  c:
  print(b + c)
else:
  print(b + 2 * c + 1)

### FIXED CODE ###

a, b, c = map(int, input().split())
if a + b >=  c:
  print(b + c)
else:
  print(a + b * 2 + 1)
weather1 = input().split()
weather2 = input().split()
match = 0
for i in range(0,2):
    if weather1[i] == weather2[i]:
        match += 1
print(match)

### FIXED CODE ###

weather1 = input()
weather2 = input()
match = 0
for i in range(0,3):
    if weather1[i] == weather2[i]:
        match += 1
print(match)
import collections



def XORC(a,b,p):
    for i in range(len(a)):
        if (int(a[i])+int(b[i]))%2 == int(p[i]):
            continue
        else:
            return False
        
    return True
            
def Solve():
    N=int(input())
    AL=[("0"*34+bin(int(x))[2:])[-33:] for x in input().split()]

    ALC=collections.Counter(AL)

    keys=list(ALC.keys())
    vals=list(ALC.values())

    if len(keys)>3:
        stop
        return 'No'
    if len(keys)==1:
        stop
        if "1" in keys[0]:
            return 'No'
        return 'Yes'
    
    if len(keys)==2:
        if "1" in keys[0] and "1" in keys[1]:
            return 'No'
        
        if vals[0]==vals[1]*2 and "1" not in keys[0]:
            return 'Yes'
        
        if vals[0]*2==vals[1] and "1" not in keys[1]:
            return 'Yes'
        
        return 'No'
    if len(keys)==3:
        stop
        if vals[0]==vals[1]==vals[2]:
            if XORC(keys[0],keys[1],keys[2]) and XORC(keys[0],keys[2],keys[1]) and XORC(keys[1],keys[2],keys[0]):
                return 'Yes'
        
        return 'No'
print(Solve())


### FIXED CODE ###

import collections



def XORC(a,b,p):
    for i in range(len(a)):
        if (int(a[i])+int(b[i]))%2 == int(p[i]):
            continue
        else:
            return False
        
    return True
            
def Solve():
    N=int(input())
    AL=[("0"*34+bin(int(x))[2:])[-33:] for x in input().split()]

    ALC=collections.Counter(AL)

    keys=list(ALC.keys())
    vals=list(ALC.values())

    if len(keys)>3:
        return 'No'
    if len(keys)==1:
        if "1" in keys[0]:
            return 'No'
        return 'Yes'
    
    if len(keys)==2:
        if "1" in keys[0] and "1" in keys[1]:
            return 'No'

        if vals[0]*2==vals[1] and ("1" not in keys[0]):
            return 'Yes'
        
        if vals[0]==vals[1]*2 and ("1" not in keys[1]):
            return 'Yes'
        
        return 'No'
    if len(keys)==3:
        if vals[0]==vals[1]==vals[2]:
            if XORC(keys[0],keys[1],keys[2]) and XORC(keys[0],keys[2],keys[1]) and XORC(keys[1],keys[2],keys[0]):
                return 'Yes'
        
        return 'No'
print(Solve())
n = int(input().split())
list = map(int, input().split())

sum = 0
for i in range(n)
    sum += list[i]

print(min(list), max(list), sum)


### FIXED CODE ###

#
# 4d
#


def main():
    n = int(input())
    a = list(map(int, input().split()))
    print(f"{min(a)} {max(a)} {sum(a)}")


if __name__ == '__main__':
    main()
N, K = list(map(int,input().split()))
h = [None for _ in range(N)]
MIN = float('inf')
for i in range(N):
  h[i] = int(input())
H = sorted(h)
for i in range(N-2):
  if MIN >= H[i+(K-1)] - H[i]:
    MIN = H[i+(K-1)] - H[i]
print(MIN)

### FIXED CODE ###

N, K = list(map(int,input().split()))
h = [None for _ in range(N)]
MIN = float('inf')
for i in range(N):
  h[i] = int(input())
H = sorted(h)
for i in range(N-(K-1)):
  if MIN >= H[i+(K-1)] - H[i]:
    MIN = H[i+(K-1)] - H[i]
print(MIN)
import math

def gcd(a,b):
    """Compute the greatest common divisor of a and b"""
    while b > 0:
        a, b = b, a % b
    return a

def lcm(a, b):
    """Compute the lowest common multiple of a and b"""
    return a * b / gcd(a, b)


def best_alignment(lst, small):

	ans = 0

	p = []

	if(small):
		p.append(lst[-1])
		p.append(lst[-1])
		del lst[-1:]
	else:
		m = min(lst)
		p.append(lst[0])
		p.append(lst[0])
		lst.pop(0)


	while(len(lst)>0):

		print(small)
		print(lst)
		print(p)
		print(ans)
		print("")

		if(small):
			ans = ans + abs(max(p)-lst[0])
			if(len(lst)==1):
				break

			ans = ans + abs(min(p)-lst[1])

			p = []
			p.append(lst.pop(0))
			p.append(lst.pop(0))
			small = False
			continue
		else:
			ans = ans + abs(min(p)-lst[-1])
			if(len(lst)==1):
				break

			ans = ans + abs(max(p)-lst[-2])

			p = []
			p.append(lst[-1])
			p.append(lst[-2])
			del lst[-2:]
			small = True
			continue

	return ans	




N = int(input().strip())
A = []
for i in range(N):
	A.append(int(input().strip()))

A.sort()
A_=A.copy()

print(max(best_alignment(A, True), best_alignment(A_, False)))

### FIXED CODE ###

import math

def gcd(a,b):
    """Compute the greatest common divisor of a and b"""
    while b > 0:
        a, b = b, a % b
    return a

def lcm(a, b):
    """Compute the lowest common multiple of a and b"""
    return a * b / gcd(a, b)


def best_alignment(lst, small):

	ans = 0

	p = []

	if(small):
		p.append(lst[-1])
		p.append(lst[-1])
		del lst[-1:]
	else:
		m = min(lst)
		p.append(lst[0])
		p.append(lst[0])
		lst.pop(0)


	while(len(lst)>0):

		if(small):
			ans = ans + abs(max(p)-lst[0])
			if(len(lst)==1):
				break

			ans = ans + abs(min(p)-lst[1])

			p = []
			p.append(lst.pop(0))
			p.append(lst.pop(0))
			small = False
			continue
		else:
			ans = ans + abs(min(p)-lst[-1])
			if(len(lst)==1):
				break

			ans = ans + abs(max(p)-lst[-2])

			p = []
			p.append(lst[-1])
			p.append(lst[-2])
			del lst[-2:]
			small = True
			continue

	return ans	




N = int(input().strip())
A = []
for i in range(N):
	A.append(int(input().strip()))

A.sort()
A_=A.copy()

print(max(best_alignment(A, True), best_alignment(A_, False)))
n = map(int, input().split())
count = 0
for i in range(n[0]):
  a, b = map(int, input().split())
  r = (a **2 + b ** 2) ** 0.5
  if r <= n[1]:
    count += 1
print(count)

### FIXED CODE ###

N, D = map(int, input().split())
count = 0
for i in range(N):
  a, b = map(int, input().split())
  r = (a **2 + b ** 2) ** 0.5
  if r <= D:
    count += 1
print(count)
from collections import deque


def remove(adj, a):
    for nxt in adj[a]:
        adj[nxt].remove(a)


def main():
    N, M = map(int, input().split())
    adj = [set() for _ in range(N+1)]
    for _ in range(M):
        a, b = map(int, input().split())
        adj[a].add(b)
        adj[b].add(a)
    ans = deque([a, b])
    remove(adj, a)
    remove(adj, b)
    first = a
    while len(adj[first]):
        nxt = list(adj[first])[0]
        ans.appendleft(nxt)
        remove(adj, nxt)
        first = nxt
    remove(adj, first)
    last = b
    for a in ans:
        if a in adj[last]:
            adj[last].remove(a)
    while len(adj[last]):
        nxt = list(adj[last])[0]
        ans.append(nxt)
        remove(adj, nxt)
        last = nxt
    print(len(ans))
    print(*ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import deque


def remove(adj, a):
    for nxt in adj[a]:
        adj[nxt].remove(a)


def main():
    N, M = map(int, input().split())
    adj = [set() for _ in range(N+1)]
    for _ in range(M):
        a, b = map(int, input().split())
        adj[a].add(b)
        adj[b].add(a)
    ans = deque([a, b])
    remove(adj, b)
    remove(adj, a)
    first = a
    last = b
    while len(adj[first]):
        nxt = list(adj[first])[0]
        ans.appendleft(nxt)
        remove(adj, nxt)
        first = nxt
    remove(adj, first)
    for a in ans:
        if a in adj[last]:
            adj[last].remove(a)
    while len(adj[last]):
        nxt = list(adj[last])[0]
        ans.append(nxt)
        remove(adj, nxt)
        last = nxt
    print(len(ans))
    print(*ans)


if __name__ == "__main__":
    main()
n = int(input())
a = list(map(int, input().split()))
 
count = 0
while True:
    for i in range(n):
        if a[i] % 2 == 0:
            a[i] /= 2
        else:
            print(count)
            exit()
    count += 1
print(count)

### FIXED CODE ###

s = input()
a = [int(c) for c in s]
b = 0
for i in a:
  if i == 1:
    b += 1
 
print(b)
d,n = map(int,input().split())

a=[]
k = 1
while len(a) == n:
  if (k % d < 100):
    a.append(k)
    
    
print(a[-1])


### FIXED CODE ###

d, n = map(int, input().split())
if n != 100:
    print(n*100**d)
else:
    print((n+1)*100**d)
a, b, c = map(int, input())
if a + b + c >= 22:
  print('bust')
else:
  print('win')

### FIXED CODE ###

a, b, c = map(int, input().split())
if a + b + c >= 22:
  print('bust')
else:
  print('win')
letters = list(S)
a = letters[0]
if letters.count(a) == 2:
  if letters[1] == a:
    if letters[2] == letters[3]:
      return "Yes"
    else return "No"
  else:
    b = letters[1]
    if letters.count(b) == 2:
      return "Yes"
    else:
      return "No"
else:
  return "No"

    

### FIXED CODE ###

letters = list(input())
x = 1
for letter in letters:
        if letters.count(letter) == 2:
            x *= 1
        else:
            x *= 0
print(["No","Yes"][x])
s = input()

while s:
  if s[0:7] == 'dreamer':
    s = s[7:]
    if s != [] and s[0] == 'a':
      s = 'er' + s
    continue
  elif s[0:6] == 'eraser':
    s = s[6:]
    continue
  elif s[0:5] in ('dream', 'erase'):
    s = s[5:]
    continue
  else:
    print('NO')
    exit(0)
print('YES')

### FIXED CODE ###

s = input()
dp = [0 for i in range(len(s)+1)]
dp[0] = 1
words = ['eraser', 'erase', 'dreamer', 'dream']

for i in range(len(s)):
  i += 1
  for sent in words:
    before = i - len(sent)
    if before < 0:
      continue
    if dp[before] == 1 and s[before:i] == sent:
      dp[i] = 1
print('YES' if dp[-1] else 'NO')
from math import factorial as fact
n,m=map(int,input().split())
i,k=0,0
if n<2 and m<2:
  print(0)
else:
  if n!=0:
  	i=fact(n)/fact(2)/fact(n-2)
  if m!=0:
    k=fact(m)/fact(2)/fact(m-2)
  print(int(i+k))

### FIXED CODE ###

from math import factorial as fact
n,m=map(int,input().split())
i,k=0,0
if n<2 and m<2:
  print(0)
else:
  if n==0:i=0
  elif n==2:
  	i=1
  elif n!=1:
    i=fact(n)/fact(2)/fact(n-2)
  if m==0:k=0
  elif m==2:
  	k=1
  elif m!=1:
    k=fact(m)/fact(2)/fact(m-2)
  print(int(i+k))
import sys
sys.setrecursionlimit(10 ** 6)

n = int(input())
x = input()
z = '1' * n
o = '0' * n
X = int(x, 2)

if (z == x):
  u = n - 1
  d = n - 1
elif (o == x):
  u = 1
  d = 1
else:
  tmp = len(list(filter(lambda x: x == '1', x)))
  u = tmp + 1
  d = tmp - 1


def popcount(i):
  return i % len(list(filter(lambda x: x == '1', format(i, 'b'))))


def solve(i, count):
  if (i <= 2 * 10**5 and ans[i] != 0):
    return count + ans[i]
  elif (i == 0):
    return count
  else:
    return solve(popcount(i), count + 1)


def solve2(i, div):
  if (i <= 2 * 10**5):
    return ans[i]
  else:
    return ans[i % div] + 1


ans = [0] * (2 * 10 ** 5 + 1)
_u = (2 * 10 ** 5) // u
U = X % u + (u * _u) + u
_d = (2 * 10 ** 5) // d
D = X % d + (d * _d) * 2 + d * 2
Us = [0] * (2 * 10 ** 5)
Ds = [0] * (2 * 10 ** 5)
for i in range(1, 2 * 10 ** 5 + 1):
  ans[i] = solve(i, 0)
  
Us[0] = 1 % u
Ds[0] = 1 % d
for i in range(1, 2 * 10 ** 5):
  Us[i] = (Us[i-1] * 2) % u
  Ds[i] = (Ds[i-1] * 2) % d

for i in range(n):
  if(X <= 2 * 10 ** 5 + 1):
    if(x[i] == '0'):
      print(solve2(X + 2 ** (n - i - 1), u))
    else:
      print(solve2(X - 2 ** (n - i - 1), d))
  else:
    if(x[i] == '0'):
      print(solve2(U + Us[n-i-1], u))
    else:
      print(solve2(D - Ds[n-i-1], d))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)

n = int(input())
x = input()
z = '1' * n
o = '0' * n
X = int(x, 2)

if (n == 1 and x == '1'):
  print(0)
  exit()

if (z == x):
  u = n - 1
  d = n - 1
elif (o == x):
  u = 1
  d = 1
else:
  tmp = len(list(filter(lambda x: x == '1', x)))
  u = tmp + 1
  d = tmp - 1


def popcount(i):
  return i % len(list(filter(lambda x: x == '1', format(i, 'b'))))


def solve(i, count):
  if (i <= 2 * 10**5 and ans[i] != 0):
    return count + ans[i]
  elif (i == 0):
    return count
  else:
    return solve(popcount(i), count + 1)


def solve2(i, div):
  if (i <= 2 * 10**5):
    return ans[i]
  else:
    return ans[i % div] + 1


ans = [0] * (2 * 10 ** 5 + 4)
_u = (2 * 10 ** 5) // u
U = X % u + (u * _u) + u
if(d != 0):
  _d = (2 * 10 ** 5) // d
  D = X % d + (d * _d) * 2 + d * 2
Us = [0] * (2 * 10 ** 5)
Ds = [0] * (2 * 10 ** 5)
for i in range(1, 2 * 10 ** 5 + 4):
  ans[i] = solve(i, 0)
Us[0] = 1 % u
if(d != 0):
  Ds[0] = 1 % d
for i in range(1, 2 * 10 ** 5):
  Us[i] = (Us[i - 1] * 2) % u
  if(d != 0):
    Ds[i] = (Ds[i-1] * 2) % d

for i in range(n):
  if(x[i] == '0'):
    print(solve2(U + Us[n-i-1], u))
  else:
    if (d == 0):
      print(0)
    else:
      print(solve2(D - Ds[n-i-1], d))
import math

i = []
for l in range(5):
    i.append(int(input()))
m = -1
l = 0
for x in range(5):
    if m < (10 - i[x] % 10) and 10 - i[x] % 10 != 10:
        if x != 0:
            l += math.ceil(i[mx] / 10) * 10
        m = 10 - i[x] % 10
        mx = x
    else:
        l += math.ceil(i[x] / 10) * 10
l += i[mx]
print(l)


### FIXED CODE ###

import math

i = []
for l in range(5):
    i.append(int(input()))
m = 0
l = 0
mx = -1
for x in range(5):
    if m < (10 - i[x] % 10) and 10 - i[x] % 10 != 10:
        if x != 0:
            l += math.ceil(i[mx] / 10) * 10
        m = 10 - i[x] % 10
        mx = x
    else:
        l += math.ceil(i[x] / 10) * 10
if mx != -1:
    l += i[mx]
print(l)
n, k = map(int, input().split())
import math
def kai(x):
  if x == 0:
    return 1
  elif x < 0:
    return 1
  else:
    return math.factorial(x)
  
for i in range(1, k+1):
  if n - k  + 1 >= i:
    print(int(((kai(k-1)*kai(n-k+1)/(kai(i-1)*kai(k-i)*kai(i)*kai(n-k+1-i))) % (10**9 +7))//1))
  else:
    print(0)




### FIXED CODE ###

n, k = map(int, input().split())
import math
mod = (10**9) +7
def kai(x):
  if x == 0:
    return 1
  elif x < 0:
    return 1
  else:
    return math.factorial(x)
  
for i in range(1, k+1):
  if n - k  + 1 >= i:
    result = (kai(k-1)*kai(n-k+1))//(kai(i-1)*kai(k-i)*kai(i)*kai(n-k+1-i))
    result2 = result % mod
    print(result2)
  else:
    print(0)
n = int(input())
s = list(str(input()))
for i in range(int(n/2)+1):
  if s[i] != s[int(n/2+i)] or n==1 or n%2:
    print('No')
    exit()
print('Yes')

### FIXED CODE ###

n = int(input())
s = list(str(input()))
if n == 1:
  print('No')
  exit()
for i in range(int(n/2)):
  if s[i] != s[int(n/2+i)] or n%2:
    print('No')
    exit()
print('Yes')
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

def find(x):
    if node[x] < 0:
        return x
    else:
        node[x] = find(node[x])
        return node[x]

def unite(x, y):
    x = find(x)
    y = find(y)
    ret = False
    if x != y:
        ret = True
        if rank[x] > rank[y]:
            node[x] += node[y]
            node[y] = x
        else:
            node[y] += node[x]
            node[x] = y
            if rank[x] == rank[y]:
                rank[y] += 1
    return ret

def is_same(x, y):
    return find(x) == find(y)

def size(x):
    return -node[find(x)]

n, m = map(int,input().split())
node = [-1 for i in range(n + 1)]
rank = [0 for i in range(n + 1)]
e = [[int(i) for i in input().split()] for i in range(m)]
ans = deque()
num = int((n * (n - 1)) // 2)
s = 0
for i in e[::-1]:
    s1 = size(i[0])
    s2 = size(i[1])
    ans.appendleft(num)
    if unite(i[0], i[1]):
        num -= s1 * s2
for i in ans:
    print(i)


### FIXED CODE ###

# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

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

cnt = 0
for i in range(c):
    if b >= a:
        cnt += 1
        b -= a
    else:
        break
print(cnt)
s = input()

ans = 0
if s == 'RRR':
    print(3)
    exit()
elif s[0] == 'R' and s[1] == 'R':
    print(2)
    exit()
elif s[1] == 'R' and s[2] == 'R':
    print(2)
    eixt()
elif 'R' in s:
    print(1)
    exit()
else:
    print(0)

### FIXED CODE ###

s = input()

if s == 'RRR':
    print(3)
    exit()
elif s == 'SSS':
    print(0)
    exit()
elif s[:2] == 'RR' or s[1:] == 'RR':
    print(2)
    exit()
elif 'R' in s:
    print(1)
    exit()
else:
    print(0)
    exit()
s=input()
if len(s)<4:print("No")
elif s[:3]=print("Yes")
else:print("No")

### FIXED CODE ###

s=input()
if len(s)<4:print("No")
elif s[:4]=="YAKI":print("Yes")
else:print("No")
a = list(input())
b = [int(i) for i in a]
c=sorted(b,reverse=True)
d =10*c[0]+c[1]+c[2]
print(int(d))

### FIXED CODE ###

a = input().split()
b = [int(i) for i in a]
c=sorted(b,reverse=True)
d =10*c[0]+c[1]+c[2]
print(d)
N = int(input())
str(n)
listN = sorted(N)
if listN.count(7) >= 1:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

N = int(input())
listN = sorted(str(N))
if listN.count("7") >= 1:
    print("Yes")
else:
    print("No")
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
ans = 0
aa=sum(a)
for i in range(n):
    aa-=a[i]
        ans += a[i]*a[j]
ans %= mod
print(ans)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
ans = 0
aa=sum(a)
for i in range(n):
    aa-=a[i]
    ans += a[i]*aa
ans %= mod
print(ans)
import numpy as np
a,b,x=map(int,input().split())

V=a**2*b
if x<=V/2:
    alpha=np.arctan(2*x/a/b**2)
    angle=90-alpha/np.pi*180
    print('{:.10f}'.format(angle))
else:
    angle=90-np.arctan(a**3/2/(a**2*b-x))/np.pi*180
    print('{:.10f}'.format(angle))

### FIXED CODE ###

import numpy as np
a,b,x=map(int,input().split())

V=a**2*b
if x==V:
    print('{:.10f}'.format(0))
elif x<=V/2:
    alpha=np.arctan(2*x/a/b**2)
    angle=90-alpha/np.pi*180
    print('{:.10f}'.format(angle))
else:
    angle=90-np.arctan(a**3/2/(a**2*b-x))/np.pi*180
    print('{:.10f}'.format(angle))
N, K = map(int, input().split())
A_list = list(map(int, input().split()))
same = 0
diff = 0

for i in range(N):
  for j in range(N):
    if N[i] > N[j]:
      if i < j:
        same += 1
        diff += 1
      elif i>j:
        diff += 1

ans = (same*K) + (diff*((K * (K-1))//2))
print(ans%(10**9 + 7))
        

### FIXED CODE ###

def tasu(a):
  out = (a*(a-1))//2 + a
  return out%(10**9 + 7)
    
  
N, K = map(int, input().split())
A_list = list(map(int, input().split()))
count = 0
count1 = 0

for i in range(N):
  for j in range(N):
    if i == j:
      continue
    elif (i<j) & (A_list[i] > A_list[j]):
      count += 1
    elif (i>j) & (A_list[i] > A_list[j]):
      count1 += 1

ans = (tasu(K) * count) + (tasu(K-1) * count1) 
print(ans%(10**9 + 7))
N = int(input())
li = list(map(int, input().split()))
a = 0
while any(j % 2 == 0 for j in li):
  for i in range(N):
    if li[i]%2 == 0:
      li[i] = li[i]/2
      a += 1
      break
print(a)

### FIXED CODE ###

a, b = map(int, input().split())
if a <= 8 and b <= 8:
  print("Yay!")
else:
  print(":(")
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd, floor
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
#import numpy as np

M, D = MAP()

ans = 0
for i in range(1, M+1):
	for j in range(1, D+1):
		if 2 <= j//10 and 2 <= j%10 and (j//10)*(j%10) == i:
			ans += 1

print(ans)

### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

M, D = MAP()
ans = 0
for m in range(1, M+1):
	for d in range(1, D+1):
		if len(str(d)) == 2:
			d1 = int(str(d)[1])
			d10 = int(str(d)[0])
			if 2 <= d1 and 2 <= d10 and d1*d10 == m:
				ans += 1
print(ans)
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
  int N, T; 
  cin >> N >> T;
  vector<int> c[N]
  vector<int> t[N];
  for(int i = 0; i < N; ++i) {
    cin >> c[i] >> t[i];
  }
  int MAX = 1 << 30;
  int ans = MAX;

  for (int i = 0; i < N; ++i){
    if(t[i] <= T){
      ans = min(ans, c[i]);
      
    }
  }

  if (ans <  MAX){
    cout << ans << endl;
  }
  else {
    cout << "TLE" << endl;
  }
}

### FIXED CODE ###

n,T = map(int,input().split())
mn = 1001
for i in range(n):
    c,t = map(int,input().split())
    if t <= T:
        mn = min(mn,c)

if mn == 1001:
    print("TLE")
else :
    print(mn)
import math

r = float(raw_input())
print "{:.6f} {:.6f}".format(math.pi * r * r, s * math.pi * r)

### FIXED CODE ###

import math

r = float(raw_input())
print "{:.6f} {:.6f}".format(math.pi * r * r, 2 * math.pi * r)