Harryxun/stf_run huggingface dataset:
N,M=map(int,input().split())
LRC=sorted([list(map(int,input().split())) for i in range(M)])
d=[10**15]*N
d[0]=0
class SegTree:
    'min'
    def __init__(self,size,default=10**15):
        self.d=default
        self.N=size
        self.v=[self.d]*(2*self.N-1)
    def update(self,i,x):
        i+=self.N-1
        self.v[i]=x
        while i>0:
            i=(i-1)//2
            self.v[i]=min(self.v[i*2+1],self.v[i*2+2])
    def min(self,a,b,i=0,l=0,r=1e9):
        if r==1e9:
            r=self.N
        if r<=a or b<=l:
            return self.d
        if a<=l and r<=b:
            return self.v[i]
        return min(self.min(a,b,i*2+1,l,(l+r)//2),self.min(a,b,i*2+2,(l+r)//2,r))
s=SegTree(2**14)
s.update(0,0)
for l,r,c in LRC:
    d2=s.min(l-1,r-1)+c
    if d2<d[r-1]:
        d[r-1]=d2
        s.update(r-1,d2)
print(-1 if d[-1]==10**15 else d[-1])

### FIXED CODE ###

N,M=map(int,input().split())
LRC=sorted([list(map(int,input().split())) for i in range(M)],key=lambda x:x[0])
class rmq:
    def __init__(self,N):
        self.N0=2**(N-1).bit_length()
        self.INF=2**63-1
        self.data=[self.INF]*(2*self.N0)
        self.lazy=[None]*(2*self.N0)
    def gindex(self,l, r):
        L = l + self.N0; R = r + self.N0
        lm = (L // (L & -L)) >> 1
        rm = (R // (R & -R)) >> 1
        while L < R:
            if R <= rm:
                yield R
            if L <= lm:
                yield L
            L >>= 1; R >>= 1
        while L:
            yield L
            L >>= 1
    def propagates(self,*ids):
        for i in reversed(ids):
            v = self.lazy[i-1]
            if v is None:
                continue
            self.lazy[2*i-1] = self.data[2*i-1] = self.lazy[2*i] = self.data[2*i] = v
            self.lazy[i-1] = None
    def update(self,l, r, x):
        *ids, = self.gindex(l, r)
        self.propagates(*ids)
        L = self.N0 + l; R = self.N0 + r
        while L < R:
            if R & 1:
                R -= 1
                self.lazy[R-1] = self.data[R-1] = x
            if L & 1:
                self.lazy[L-1] = self.data[L-1] = x
                L += 1
            L >>= 1; R >>= 1
        for i in ids:
            self.data[i-1] = min(self.data[2*i-1], self.data[2*i])
    def rmin(self,l, r):
        self.propagates(*self.gindex(l, r))
        L = self.N0 + l; R = self.N0 + r
        s = self.INF
        while L < R:
            if R & 1:
                R -= 1
                s = min(s, self.data[R-1])
            if L & 1:
                s = min(s, self.data[L-1])
                L += 1
            L >>= 1; R >>= 1
        return s
d=rmq(N)
d.update(0,1,0)
for l,r,c in LRC:
    d.update(r-1,r,min(d.data[d.N0+r-2],d.rmin(l-1,r-1)+c))
a=d.rmin(N-1,N)
print(a if a<d.INF else -1)
n=int(input())
h=list(map(int,input().split()))
ans='Yes'
a[0]-=1
for i in range(n-1):
  if a[i]>a[i+1]:
    ans='No'
  elif a[i+1]>a[i]:
    a[i+1]-=1
print(ans)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
ans='Yes'
a[0]-=1
for i in range(n-1):
  if a[i]>a[i+1]:
    ans='No'
  elif a[i+1]>a[i]:
    a[i+1]-=1
print(ans)
x,a,b=(int,input() for _ in range(3))
print((x - a)%b)


### FIXED CODE ###

x,a,b=(int(input()) for _ in range(3))
print((x - a)%b)
A,B,C,X,Y = (int(i) for i in input().split())
i = 0
a = []
while i <= 100000:
    p = i * 2*C + A*max(0,X-i)+B*max(0,Y-i)
    a.append(p)
    i += 1
print(min(a)

### FIXED CODE ###

A,B,C,X,Y = (int(i) for i in input().split())
i = 0
a = []
while i <= 100000:
    p = i * 2*C + A*max(0,X-i)+B*max(0,Y-i)
    a.append(p)
    i += 1
print(min(a))
def main():
    n = int(input())
    for _ in range(n):
        a, b = map(int, input().split())
        ref = a * b - 1
        rng = int(ref ** 0.5)
        res = rng * 2
        if ref // rng == rng:
            res -= 2
        elif a > rng and b > rng:
            res -= 0
        else:
            res -= 1
        print(res)
if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    n = int(input())
    for _ in range(n):
        a, b = map(int, input().split())
        ref = a * b - 1
        rng = int(ref ** 0.5) - 2
        while rng ** 2 < a * b:
            rng += 1
        rng -= 1
        if a == b or abs(a - b) == 1:
            print(2 * min(a, b) - 2)
        elif rng * (rng + 1) >= a * b:
            print(2 * rng - 2)
        else:
            print(2 * rng - 1)
if __name__ == '__main__':
    main()
n=int(input())
A=list(map(int,input().split()))
q=0
Z=[]
t=min(A)
for b in range(int((max(A)-min(A))//2)):
  q=0
  for j in range(n):
    q+=abs(A[j]-b-t-j-1)
  Z.append(q)
print(min(Z))


### FIXED CODE ###

import sys
import math
mod=10**9+7
inf=float("inf")
from math import sqrt
from collections import deque
from collections import Counter
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from functools import lru_cache
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#######ここから天ぷら########
n=int(input())
A=list(map(int,input().split()))
SA=[0 for i in range(n)]
for i in range(n):
    SA[i]=A[i]-i-1
SA.sort()

if n%2==0:
    geta=(SA[n//2]+SA[n//2-1])//2
else:
    geta=SA[n//2]
ans=0
for i in range(n):
    ans+= abs(A[i]-(geta+i+1))
print(ans)
[A,V]=[int(i) for i in input().split()]
[B,W]=[int(i) for i in input().split()]
T=int(input())
if abs(A-B)=>T*abs(V-W):print("NO")
else:print("YES")


### FIXED CODE ###

[A,V]=[int(i) for i in input().split()]
[B,W]=[int(i) for i in input().split()]
T=int(input())
if W-V>0 or abs(B-A)>T*abs(W-V):print("NO")
else:print("YES")
n=int(input())
a=list(map(int,input().split()))
ct=0

M=max(a)
for i in range(25):
  if 2**i>M:
    x=i
    break
L=[]
for j in range(2**x-1):
  L.append(0)

for j2 in range(n):
  L[a[j2]-1]+=1

for k in range(x,1,-1):
  l1=L[0:2**(k-1)-1]
  l2=L[2**(k-1):2**k]
  l2.reverse()
  if L[2**(k-1)-1]>=2:
    ct+=int(L[2**(k-1)-1]/2)
  for m in range(len(l1)):
    if l1[m]>=1 and l2[m]>=1:
      ct+=min(l1[m],l2[m])
      l1[m]-=min(l1[m],l2[m])
      l2[m]-=min(l1[m],l2[m])
  L=l1
ct+=int(L[0]/2)
print(ct)

### FIXED CODE ###

import math
import bisect
n=int(input())
a=list(map(int,input().split()))
a.sort()
b=[]
for i in range(1,50):
  b.append(2**i)
ct=0
check=[1]*n
for i in range(n-1,-1,-1):
  if a[i]==1:
    break
  if check[i]==1 and a[i] not in b:
    check[i]=0
    x=math.floor(math.log2(a[i]))
    x=b[x]-a[i]
    y=bisect.bisect_left(a,x)
    z=bisect.bisect_right(a,x)
    t=bisect.bisect_left(check[y:z],1)+y
    if t!=z:
      check[t]=0
      ct+=1

ctb=0
w=1
for i in range(n):
  if a[i] in b or a[i]==1:
    if a[i]==w:
      if check[i]==1:
        ctb+=1
    else:
      ct+=ctb//2
      w=a[i]
      if check[i]==1:
        ctb=1
      else:
        ctb=0
  else:
    ct+=ctb//2
    ctb=0
ct+=ctb//2

print(ct)
s=input()
 if s<='2019/4/30':
 	print("Heisei")
 else:
 	print("TBD")



### FIXED CODE ###

S = input()
print('Heisei' if S <= '2019/04/30' else 'TBD')
import sys
import numpy as np
def main():
  input = sys.stdin.readline
  n, k = map(int , input().split())
  p_list = np.array(list(map(int, input().split())))
  c_list = np.array(list(map(int, input().split())))
  
  dp = [[float('-inf')]*n for _ in range(k+1)]
  dp[0] = [0]*n
  for i in range(k):
    for j in range(n):
      if i==0:
        dp[i+1][p_list[j]-1] = dp[i][j]+c_list[j]
      else:
        dp[i+1][p_list[j]-1] = max(dp[i][p_list[j]-1], dp[i][j]+c_list[j])
  print(max(dp[-1]))

if (__name__=='__main__'):
  main()

### FIXED CODE ###

import sys
def main():
  input = sys.stdin.readline
  n, k = map(int , input().split())
  p_list = list(map(int, input().split()))
  c_list = list(map(int, input().split()))
  res = -float('inf')
  
  for s in range(n):
    S = []
    i = p_list[s] - 1
    S.append(c_list[i])
    while i != s:
      i = p_list[i]-1
      S.append(S[-1] + c_list[i])
    if k <= len(S):
      score = max(S[:k])
    elif S[-1] <= 0:
      score = max(S)
    else:
      score1 = S[-1] * (k//len(S) - 1)
      score1 += max(S)
      
      score2 = S[-1] * (k//len(S))
      r = k%len(S)
      if r!=0:
        score2 += max(0, max(S[:r]))
      score = max(score1, score2)
    res = max(res, score)
  print(res)
      

if (__name__=='__main__'):
  main()
n = int(input())
 
s = [str(input()) for i in range(n)]

set_key = set(s)
dic = dict(set_key, [0]*len(set_key))

for c in s:
  dic[c] += 1
  
n_max = max(dic.values())
str_argmax = dic.keys()[dic.values() == n_max]
str_argmax.sort()

for i in str_argmax:
  print(i)

### FIXED CODE ###

n = int(input())
 
s = [str(input()) for i in range(n)]

set_key = list(set(s))
set_key.sort()
dic = dict(zip(set_key, [0]*len(set_key)))

for c in s:
  dic[c] += 1

n_max = max(dic.values())

for c in set_key:
  if dic[c] == n_max:
    print(c)
d={'A':'a','B':'b','C':'c'}
N,K=map(input().split())
S=input()
print(S[:K-1]+d[S[K-1]]+S[K:])

### FIXED CODE ###

d={'A':'a','B':'b','C':'c'}
N,K=map(int,input().split())
S=input()
print(S[:K-1]+d[S[K-1]]+S[K:])
N, M = map(int, input().split())

ans = [-1 for i in range(N-1)]
path = [[] for i in range(N)]

for i in range(M):
  A, B = map(int, input().split())
  path[A-1].append(B)
  path[B-1].append(A)
nows = [1]
COUNTER = 0
while len(nows)>0 :
  buf = []
  for now in nows:
    for p in path[now-1]:
      if ans[p-2]==-1:
        ans[p-2]=now
        buf.append(p)
        #print(COUNTER)
        COUNTER+=1
  nows = buf
  
print("Yes")
for i in ans:
  print(i)


### FIXED CODE ###

x = input()[-1]
 
if x in ["2","4","5","7","9"]:
  print("hon")
elif x in ["0","1","6","8"]:
  print("pon")
else:
  print("bon")
a,b,c,d=map(int,input().split())

from math import gcd
c_d=c*d/gcd(c,d)
if a%c==0:
    wari_c=int(b//c-a//c+1)
else:
    wari_c=int(b//c-a//c)
if a%d==0:
    wari_d=int(b//d-a//d+1)
else:
    wari_d=int(b//d-a//d)
if a%c_d==0:
    wari_c_d=int(b//c_d-a//c_d+1)
else:
    wari_c_d=int(b//c_d-a//c_d)

print(b-a+1-(wari_c+wari_d-wari_c_d))

### FIXED CODE ###

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

import fractions
lcmcd = c * d // fractions.gcd(c,d)
bc = b // c
ac = a // c
bd = b // d
ad = a // d
blcmcd = b // lcmcd
alcmcd = a // lcmcd

if a % c != 0:
    ac += 1
if a % d != 0:
    ad += 1
if a % lcmcd != 0:
    alcmcd += 1

print((b - a + 1) - ((bc - ac + 1) + (bd - ad + 1) - (blcmcd -alcmcd + 1)))
def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if Pcount > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
import math
import  functools

def gcd(numbers):
    return functools.reduce(math.gcd,numbers)

N = int(input())
A = [int(x) for x in input().split()]
a2 = A.copy()
max = 0
for i,_ in enumerate(A):
    A.pop(i)
    temp = gcd(A)
    max = temp if temp >= max else max
    A = a2.copy()


print(max)

### FIXED CODE ###

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


gcdL = []
gcdR = []

N = int(input())
A = [int(x) for x in input().split()]
gcdL.append(0)
length_A = len(A)
for i in range(1,length_A):
    gcdL.append(gcd(A[i-1],gcdL[i-1]))


gcdR.append(0)
for i in range(1,length_A):
    gcdR.append(gcd(A[length_A-i],gcdR[i-1]))



list_gcd = []
for i in range(length_A):
        list_gcd.append(gcd(gcdL[i],gcdR[length_A-i-1]))

print(max(list_gcd))
import numpy as np

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

a = np.zeros([n, m])
for i in range(n):
    a[0] = list(map(int, input().split()))

b = np.zeros(m)
for i in range(m):
    b[i] = int(input())

c = a.dot(b)
for i in c:
    print(i)

### FIXED CODE ###

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

a = [0] * n 
for i in range(n):
    a[i] = list(map(int, input().split()))

b = [0] * m
for i in range(m):
    b[i] = int(input())

c = [0] * n    
for i in range(n):
    for aj, bj in zip(a[i], b):
        c[i] += aj * bj
    
for ci in c:
    print(ci)
def dfs(node, paths, visited, n):
  # 全て訪問済みだったら全部を訪問できる経路として1を返す
  if not False in visited:
    return 1

  count = 0

  for nn in paths[node]:
    # 既に訪問済みなら処理をしない
    if(visited[nn]):
      continue

    visited[nn] = True
    count += dfs(nn, paths, visited, n)
    visited[nn] = False

  return count

def main():
  N, M = list(map(int, input().split()))
  paths = [[] for i in range(M)]
  visited = [False] * M

  for i in range(M):
    a, b = list(map(int, input().split()))
    paths[a-1].append(b-1)
    paths[b-1].append(a-1)

  visited[0] = True
  print(dfs(0, paths, visited, N))


if __name__ == "__main__":
    main()

### FIXED CODE ###


def dfs(node, paths, visited, n):
  # 全て訪問済みだったら全部を訪問できる経路として1を返す
  if not False in visited:
    return 1

  count = 0

  for nn in paths[node]:
    # 既に訪問済みなら処理をしない
    if(visited[nn]):
      continue

    visited[nn] = True
    count += dfs(nn, paths, visited, n)
    visited[nn] = False

  return count

def main():
  N, M = list(map(int, input().split()))
  paths = [[] for i in range(N)]
  visited = [False] * N

  for i in range(M):
    a, b = list(map(int, input().split()))
    paths[a-1].append(b-1)
    paths[b-1].append(a-1)

  visited[0] = True
  print(dfs(0, paths, visited, N))


if __name__ == "__main__":
    main()
A, B, K = map(int, input().split())
S = []
for i in range(100):
  if A%i==0 and B%i==0:
    S.append(i)
print(S[K-1])

### FIXED CODE ###

A, B, K = map(int, input().split())
S = []
for i in range(100):
  if A%(i+1)==0 and B%(i+1)==0:
    S.append(i+1)
print(S[len(S)-K])
# this is a test for investigating why runtime error has happen
def comb(x, y, exact=False):
  return x + y

def factorial(x, y, exact=False):
  return x + y

n, k = tuple(map(int, input().split(' ')))
for i in range(1, k+1):
  s = comb(k-1, i-1, exact=True) * (factorial(n-k+1, exact=True) / (factorial(n-k-i+1, exact=True) * factorial(i, exact=True)))
  print(int(s) % (10 ** 9 + 7))


### FIXED CODE ###

from scipy.misc import comb

n, k = tuple(map(int, input().split(' ')))
for i in range(1, k+1):
    # 青玉k個をi個の群に分割する。これはk個の青玉の間のk-1箇所のいずれかからi-1個を選んで仕切りとすることで可能
    # これはk-1Ci-1
    # その上で、できたi個の群の前後i+1箇所に赤玉を埋めていく
    # はじめに、i個の群の内側であるi-1箇所には必ず1つ以上赤玉が存在しなければならないので、予めi-1個の赤玉を配置したものとみなす
    # 結局、n-k-(i-1)=n-k-i+1個の赤玉をi+1箇所のどこかにおいていくことと同値
    # これはn-k-i+1個の赤玉とi個の仕切りの並べ方であるので、(n-k+1)Ci
    # 以上より、求める答えはk-1Ci-1 * (n-k+1)Ci
    s = comb(k-1, i-1, exact=True) * comb(n-k+1, i, exact=True)
    print(int(s) % (10 ** 9 + 7))
S=input()
n=len(S)
ans=0

for i in range(n):
    for j in range(i,n):
        if S[i:j+1].count(("A","C","G","T"))==j-i+1:
            ans=max(ans,j-i+1)
print(ans)

### FIXED CODE ###

S=input()

ans=0
tmp=0
for i in range(len(S)):
    if S[i] in ("A","C","G","T"):
        tmp+=1
    else:
        ans=max(ans,tmp)
        tmp=0
ans=max(ans,tmp)
print(ans)
import numpy as np
x = int(input())
b = 0
ans = []
while True:
    n = x - b**5
    a = int(np.power(n, 1/5))
    if a**5 == n:
       ans.append(a)
       ans.append(-b)
       break
    b += 1

print(*ans)

### FIXED CODE ###

import math
x = int(input())
b = 0
ans = []
while True:
    n = x - b**5
    if n < 0:
        break
    a = int(math.pow(n, 1/5))
    if a**5 == n:
       ans.append(a)
       ans.append(-b)
       break
    b += 1

if len(ans) != 0:
    print(*ans)
else:
    b = 0
    while True:
        n = x + b**5
        a = int(math.pow(n, 1/5))
        if a**5 == n:
           ans.append(a)
           ans.append(b)
           break
        b += 1
    print(*ans)
import sympy

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

if n % m == 0:
  print(int(n/m))
  exit()
else:
  lst = sympy.divisors(m)[::-1]
  for i in lst:
    if i == 1:
      print(i)
      exit()
    if m - i*(n-1) > 0:
      if (m - i*(n-1)) % i == 0:
        print(i)
        exit()
    else:
      continue

### FIXED CODE ###

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)

    divisors.sort()
    return divisors

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

if n % m == 0:
  print(int(n/m))
  exit()
else:
  lst = make_divisors(m)[::-1]
  for i in lst:
    if i == 1:
      print(i)
      exit()
    if m - i*(n-1) > 0:
      if (m - i*(n-1)) % i == 0:
        print(i)
        exit()
    else:
      continue
N,X = map(int,input().split())

PforL = [1]
HforL = [1]
for i in range(1,51):
    PforL.append(PforL[i-1]*2+1)
    HforL.append(HforL[i-1]*2+3)

def recursive(n,x):
    if x<=n:
        return 0
    if x<=HforL[n-1]+1:
        return recursive(n-1,x-1)
    else:
        return PforL[n-1]+1+recursive(n-1,x-HforL[n-1]-2)

print(recursive(N,X))


### FIXED CODE ###

D = int(input())
if(D==22):
    print('Christmas Eve Eve Eve')
elif(D==23):
    print('Christmas Eve Eve')
elif(D==24):
    print('Christmas Eve')
else:
    print('Christmas')
n=int(input())
a=list(map(int,input().split()))
b=[]
cnt+0
for i in a:
  if b==[] or min(b)>=i:
    cnt+=1
    b.append(i)
  else:
    b.append(i)
print(cnt)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=2*10**5
cnt=0
for i in a:
  if b>=i:
    cnt+=1
    b=i

print(cnt)
num = input()
moji_list = input().split()
new_moji = ""
for i in range(num):
	new_moji = moji_list[0][i]+moji_list[1][i]
print(new_moji)

### FIXED CODE ###

num = input()
moji_list = input().split()
new_moji = ""
for i in range(int(num)):
	new_moji += moji_list[0][i]+moji_list[1][i]
print(new_moji)
A,B = map(int,input(),split())
a = A+B
b = A-B
c = A*B
abc = [a,b,c]
max(abc)

### FIXED CODE ###

A,B = map(int,input().split())
a = A+B
b = A-B
c = A*B
List = [a,b,c]
print(max(List))
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
al=sorted(a)
bl=sorted(b)
cl=sorted(c)
 
abl=[0]*n
bcl=[0]*n
i=n-1
for j in range(n-1,-1,-1):
    while al[i]>=bl[j]:
        i-=1
        if i==-1:
            break
    if i==-1:
        abl[j]=0
    else:
        abl[j]=i+1
j=0
bcl=[0]*n
k=0
for j in range(n):
    while cl[k]<=bl[j]:
        k+=1
        if k==n:
            break
    if k==n:
        bcl[j]=0
    else:
        bcl[j]=(n-k)
ans=0
for s in range(n):
    ans+=abl[s]*bcl[s]
print(ans)


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
al=sorted(a)
bl=sorted(b)
cl=sorted(c)
 
abl=[0]*n
bcl=[0]*n
i=n-1
for j in range(n-1,-1,-1):
    if i==-1:
        abl[j]=0
        continue
    while al[i]>=bl[j]:
        i-=1
        if i==-1:
            break
    if i==-1:
        abl[j]=0
    else:
        abl[j]=i+1
j=0
bcl=[0]*n
k=0
for j in range(n):
    if k==n:
        bcl[j]=0
        continue
    while cl[k]<=bl[j]:
        k+=1
        if k==n:
            break
    if k==n:
        bcl[j]=0
    else:
        bcl[j]=(n-k)
ans=0
for s in range(n):
    ans+=abl[s]*bcl[s]
print(ans)
x = int(input())
if x:
  print(0)
 else:
  print(1)

### FIXED CODE ###

x = int(input())
if x:
    print(0)
else:
    print(1)
a, b = map(int, input().split())
d = a // b
r = a % b
f = a / b
print(d,r,{0:.5f}.format)

### FIXED CODE ###

a, b = map(int, input().split())
d = a // b
r = a % b
f = a / b
print(d,r,"{0:.5f}".format(f))
a,b,c=input().split()
s[0]=int(a)+int(b)
s[1]=int(b)+int(c)
s[2]=int(c)+int(a)
print(min(s[0],s[1],s[2]))

### FIXED CODE ###

a,b,c=input().split()
s=[0,0,0]
s[0]=int(a)+int(b)
s[1]=int(b)+int(c)
s[2]=int(c)+int(a)
print(min(s))
# coding: utf-8
# Your code here!
 
import sys
sys.setrecursionlimit(1000000)
 
N = int(input())
A = list(map(int, input().rstrip().split(' ')))
 
A_dash = [x - i - 1 for i, x in enumerate(A)]
 
def recursive(X):
    if len(X) == 1:
        return sum([abs(x - X[0]) for x in A_dash])
    elif len(X) == 2:
        if sum([abs(x - X[1]) for x in A_dash]) - sum([abs(x - X[0]) for x in A_dash]) > 0:
            return sum([abs(x - X[0]) for x in A_dash])
        else:
            return sum([abs(x - X[1]) for x in A_dash])
        
    if sum([abs(x - X[len(X)//2]) for x in A_dash]) - sum([abs(x - X[len(X)//2 - 1]) for x in A_dash]) < 0:
        return recursive(X[len(X)//2:])
    else:
        return recursive(X[:len(X)//2 + 1])
 
print(recursive(list(range(min(A_dash), max(A_dash) + 1))))

### FIXED CODE ###

# coding: utf-8
# Your code here!
 
import statistics
 
N = int(input())
A = list(map(int, input().rstrip().split(' ')))
 
A_dash = sorted([x - i - 1 for i, x in enumerate(A)])
med = int(statistics.median(A_dash))

print(sum([abs(x - med) for x in A_dash]))
a, b = input().split()

if ((a + b) % 2) == 0:
    print((a + b) / 2)
else:
    print("IMPOSSIBLE")

### FIXED CODE ###

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

if(a < b):
  swap = b
  b = a
  a = swap

k = (a + b) // 2

if ((((a + b) % 2) == 0) and (a >= k) and (k >= b)) :
    print(k)
else:
    print("IMPOSSIBLE")
n = int(input())
d = {y: x for x, y in zip("abcdefghijklmnopqrstuvwxyz", range(1, 27))}
array = []
while n > 0:
    array.append(n % 26)
    n //= 26
print("".join([d[x] for x in array[::-1]]))

### FIXED CODE ###

def Base_10_to_n(X, n):
    X_dumy = X
    out = []
    while X_dumy > 0:
        X_dumy-=1
        out.append(X_dumy % n)
        X_dumy = int(X_dumy / n)
    return out

n = int(input())
d = {y: x for x, y in zip("abcdefghijklmnopqrstuvwxyz", range(26))}

res = []
array = Base_10_to_n(n, 26)

print("".join([d[x] for x in array[::-1]]))
N,K=map(int,input().split())
h=[int(input()) for i in range(N)]
h.sort()
a=1000
for i in range(N-K+1):
  a=min(a,h[k+i-1]-h[i])
print(a)


### FIXED CODE ###

N,K=map(int,input().split())
h=[int(input()) for i in range(N)]
h.sort()
a=10**9
for i in range(N-K+1):
  a=min(a,h[K+i-1]-h[i])
print(a)
a,b,c=map(int,input().split())
x=sorted[a,b,c]
if x[0]+x[1]=x[2]:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

a,b,c=map(int,input().split())
x=sorted([a,b,c])
if x[0]+x[1]==x[2]:
    print("Yes")
else:
    print("No")
n = int(row())
print n

### FIXED CODE ###

n = int(input())
x = n / 15
res = 800 * n - 200 * int(x)
print(res)
c = input()
alp = 'abcdefghijklmnopqrstuvwxyz'

ans = alp[s.find(c)+1]
print(ans)


### FIXED CODE ###

c = input()
alp = 'abcdefghijklmnopqrstuvwxyz'

ans = alp[alp.find(c)+1]
print(ans)
cnt = 0

N, D = map(int, input().split())
X = []
for l in range(N):
    X.append(list(map(int, input().strip().split())))

for i in range(0, N - 1):
    for j in range(i + 1, N):
        sum = 0
        for k in range(0, D):
            sum += (X[i][k] - X[j][k])**2
        if math.sqrt(sum) == int(math.sqrt(sum)):
            cnt += 1
print(cnt)

### FIXED CODE ###

import math

cnt = 0

N, D = map(int, input().split())
X = []
for l in range(N):
    X.append(list(map(int, input().strip().split())))

for i in range(0, N - 1):
    for j in range(i + 1, N):
        sum = 0
        for k in range(0, D):
            sum += (X[i][k] - X[j][k])**2
        if math.sqrt(sum) == int(math.sqrt(sum)):
            cnt += 1
print(cnt)