peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
N , A, B = map(int,input().split())

count = 0

for i in range(N+1):
    i100 = i // 100
    i10 = (i - i100*100) // 10
    i1 = (i - i100*100 - i10*10) // 1

    isum = i100 + i10 + i1

    if A <= isum <= B:
        count += i

print(count)
# Judge status: Accepted
N,X=map(int,input().split())
L=list(map(int,input().split()))
c=1
tmp=0
for i in range(N):
  tmp += L[i]
  if tmp <=X:
    c+=1

print(c)
# Judge status: Accepted
# ABC106-C

import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし

S = LI2()
K = I()

for i in range(K):
    if S[i] != 1:
        print(S[i])
        break
    elif i == K-1 and S[i] == 1:
        print(1)
# Judge status: Wrong Answer
s=list(input())

for i in range(len(s)-1):
    if s[i+1]=='B':
        s[i]='#'
        s[i+1]='#'

print(''.join([i for i in s if i != '#']))
# Judge status: Accepted
import sys
lines = [s.rstrip("\n") for s in sys.stdin.readlines()]
s = lines.pop(0)
t = lines.pop(0)
for i in range(len(s)):
    if s[i:] + s[:i] == t:
        print("Yes")
        break
else:
    print("No")
# Judge status: Accepted
import math
N,D = map(int,input().split())
X = [list(map(int, input().split())) for i in range(N)]
count = 0
for i in range(N):
    for j in range(i+1,N):
        n = 0
        for k in range(D):
            n = n + (X[i][k]-X[j][k])**2
        n = math.sqrt(n)
        if n.is_integer():
            count += 1
print(count)
# Judge status: Wrong Answer
K = int(input())
S = input()

if len(S) < K:
  print(S)
else:
  print(S[0:K] + "...")
# Judge status: Accepted
def resolve():
    '''
    code here
    '''
    a, b, x = [int(item) for item in input().split()]
    _a = a // x
    _b = b // x

    if a % x == 0:
        res = _b - _a + 1
    else:
        res = _b - _a
    
    print(res)



if __name__ == "__main__":
    resolve()
# Judge status: Accepted
W, H, N = map(int, input().split())
grid = [[0] * W for _ in range(H)]
for _ in range(N):
    xi, yi, a = map(int, input().split())
    X = range(W)
    Y = range(H)
    if a in (1, 2):
        X = range(xi) if a == 1 else range(xi, W)
    elif a in (3, 4):
        Y = range(yi) if a == 3 else range(yi, H)
    for x in X:
        for y in Y:
            grid[y][x] |= 1
print(sum(map(lambda x: x.count(0), grid)))
# Judge status: Accepted
a=input()
s=[0]*26
for i in range(len(a)):
    s[ord(a[i])-ord("a")]+=1
for i in range(26):
    if s[i]%2!=0:
        print("No")
        break
else:
    print("Yes")
# Judge status: Accepted
k = int(input())
a, b = map(int, input().split())

ans = "NG"

for i in range(a, b+1):
    if i % k == 0:
        ans = "OK"

print(ans)
# Judge status: Accepted
n,d=map(int, input().split())
c=0
t=0
while t<n:
  c+=1
  t+=2*d+1
print(c)
# Judge status: Wrong Answer
print("ABRCC"[input()=="ARC"::2])
# Judge status: Accepted
from fractions import gcd
a,b,c,d = map(int,input().split())
cab = (b//c)-((a-1)//c)
dab = (b//d)-((a-1)//d)
lcm = int(c*d/gcd(c,d))
cdab = (b//lcm)-((a-1)//lcm)
print((b-a+1)-cab-dab+cdab)
# Judge status: Accepted
A,B,C,D=map(int,input().split())
while A>0 and C>0:
    C-=B
    if C<=0:
        print("Yes")
    else :
        A-=D
        if A<=0:
            print("No")
# Judge status: Wrong Answer
from math import pi
import numpy as np
a, b, x = map(int, input().split())

ans_rad = np.arctan(2 * x / (a * b**2))
ans = 90 - ans_rad * (180 / pi)
print("{}".format(ans))
# Judge status: Accepted
N, X, T = map(int, input().split())

ans = 0
while N > 0:
    ans += T
    N -= X

print(ans)
# Judge status: Accepted
x, y = map(int, input().split())

count1 = abs(y + x) + 1
count2 = max(y - x, x - y + 2)

print(min(count1, count2))
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
dai = max(a,b,c)
shou = min(a,b,c)
mid = a + b + c - dai - shou

print(shou * mid / 2)
# Judge status: Wrong Answer
#!/usr/bin/env python3


def kyu(x):
    if x <= 599:
        return 8
    elif x <= 799:
        return 7
    elif x <= 999:
        return 6
    elif x <= 1199:
        return 5
    elif x <= 1399:
        return 3
    elif x <= 1599:
        return 3
    elif x <= 1799:
        return 2
    else:
        return 1


def main():
    x = int(input())
    k = kyu(x)
    print(k)


if __name__ == '__main__':
    main()
# Judge status: Accepted
c = input()
if c == 'a' or c == 'e' or c == 'i' or c == 'o' or c == 'u':
    print("vowel")
else:
    print("consonant")
# Judge status: Accepted
s = input()
memo = {"Sunny": "Cloudy", "Cloudy": "Rainy", "Rainy": "Sunny"}
print(memo[s])
# Judge status: Accepted
n,l=map(int,input().split())
s = sum(range(l,l+n))
ans = 1000
for i in range(l,l+n):
  if abs(i) <= abs(ans):
    ans = i
print(s-ans)
# Judge status: Accepted
import math


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

for i in range(k):
    print(s,end=" ")





blank = pow(10,9)-1
if s == blank:
    blank = 1

for i in range(k,n):
    text = " "
    if  i == n-1:
        text = ""
    print(blank,end=text)
print()
# Judge status: Accepted
import numpy as np
import copy

d=int(input())
c=np.array(list(map(int,input().split())))
curc=copy.deepcopy(c)
s=[]
ans=[]
score=0
for i in range(d):
    s=np.array(list(map(int,input().split())))
    curc+=c
    s1=s+(curc)*(d-i)
    #print(s1)
    x=np.argmax(s1)
    ans.append(x+1)
    curc[x]=0
    score+=s[x]
    for j in range(26):
        score-=curc[j]



#print(score)
for i in range(d):
    print(ans[i])
# Judge status: Wrong Answer
from collections import Counter

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

Q = int(input())
BC = [tuple(map(int, input().split())) for q in range(Q)]

# check
sum_num = sum(A)
for before, after in BC:
    if before in A.keys():
        cnt = A[before]
        del A[before]
        sum_num -= before * cnt
        add = Counter({after: cnt})
        A = A + add
        sum_num += after * cnt
    print(sum_num)
# Judge status: Accepted
s,c = map(int,input().split(" "))
count = 0
if s == 0:
    print(c // 3)
else:
    count += min(s,c // 2)
    if s < c // 2:
        c -= s * 2
        count += c // 4
print(count)
# Judge status: Accepted
import math
H = int(input())
W = int(input())
l = max([H, W])
N = int(input())
print(math.ceil(N/l))
# Judge status: Accepted
import fractions

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

f=fractions.gcd(c,d)
f2=c*d//f

p = b//c - (a-1)//c
q = b//d - (a-1)//d
r = b//(f2) - (a-1)//(f2)

print((b-a+1) - (p+q-r))
# Judge status: Accepted
import collections
n=int(input())
s=list(map(int, input().split()))
L=[i+a for i,a in enumerate(s)]
R=[i-a for i,a in enumerate(s)] 
t=collections.Counter(L)
u=collections.Counter(R)
ans = 0
for i in t.keys():
  ans+=t[i]*u[i]
print(ans)
# Judge status: Accepted
n = int(input())
arr = list(map(int, input().split()))

arr.sort(reverse=True)
answer = [0, 0]
for index in range(len(arr)):
    answer[index % 2] += arr[index]
print(answer[0] - answer[1])
# Judge status: Accepted
# -*- coding: utf-8 -*-

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

ans = n - sum(a)

if ans < 0:
    print(-1)
else:
    print(ans)
# Judge status: Wrong Answer
A, B, K = map(int, input().split())

if A == 0 and B == 0:
    print(A, B)
    exit()

if A >= K:
    remain_A = A - K
    remain_B = B
else:
    remain_A = 0
    remain_B = B - (K - A)

print(remain_A, remain_B)
# Judge status: Accepted
s = input()
print(s+"es" if s[-1]=="s" else s+"s")
# Judge status: Accepted
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if i*500+j*100+k*50 == X:
                count += 1

print(count)
# Judge status: Wrong Answer
N = int(input())
fin = False
ans = ''
t=1
while fin == False:
    print(t)
    num = (N-1)%26
    print(chr(num+97))
    ans=chr(num+97)+ans
    if N<=26:
        fin = True
    t+=1
    N=(N-26^t)//26+1
print(ans)
# Judge status: Accepted
n, c, k, *t = map(int, open(0).read().split())
t.sort()
tmp = 0
cnt = 0
limit = t[0] + k
for time in t:
    if tmp == c or time > limit:
        limit = time + k
        tmp = 1
        cnt += 1
    else:
        tmp += 1
print(cnt + 1)
# Judge status: Accepted
X=int(input())

p = X % 100
q = p // 5
r = p % 5
ans = q
if r > 0:
    ans += 1
ans = ans * 100 + p
if X >= ans:
    print(1)
else:
    print(0)
# Judge status: Wrong Answer
x,y = map(int,input().split())

if x == y:
    print(-1)
else:
    print(min(x,y))
# Judge status: Wrong Answer
import math
n = int(input())
if n < 2:
  print(0)
  exit()
combs = ((n+7)*(n+6)*(n+5)*(n+4)*(n+3)*(n+2)*(n+1)*(n)*(n-1))/(9*8*7*6*5*4*3*2)
combs *= (n-1)*n
print(int(combs % (10**9 + 7)))
# Judge status: Accepted
C1 = list(input())
C2 = list(input())

ok = True
for i in range(3):
    if C1[i]!=C2[2-i]:
        ok=False
print("YES" if ok else "NO")
# Judge status: Accepted
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 28 22:12:42 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

#N = int(input())
X, Y, A, B, C = map(int,input().split())
r = list(map(int,input().split()))
g = list(map(int,input().split()))
n = list(map(int,input().split()))

r.sort()
g.sort()

r = r[-X:]
g = g[-Y:]

all_apple = r+g+n
all_apple.sort()
ans = sum(all_apple[-(X+Y):])

print(ans)
# Judge status: Accepted
a,b,c=map(int,input().split())
print(max(c-(a-b),0))
# Judge status: Accepted
N, T = map(int, input().split())
can = False
res = 1e5
for _ in range(N):
  c, t = map(int, input().split())
  if t <= T:
    can = True
    res = min(res, c)
print(res if can else "TLE")
# Judge status: Wrong Answer
#整数の入力
N= input()
N_list = list(N)

print(N_list[len(N_list)-1])

if(N_list[len(N_list)-1] == "2" or "4" or "5" or "7"or "9"):
  print("hon")
elif(N_list[len(N_list)-1] == "0" or "1" or "6" or "8"):
  print("pon")
else:
  print("bon")
# Judge status: Accepted
from math import ceil
N, K = map(int, input().split())
A = list(map(int, input().split()))
if N == K:
    print(1)
elif (N-1)%(K-1) == 0:
    print((N-1)//(K-1))
elif K == 2:
    print(N-1)
else:
    ans = ceil(N/(K-1))
    print(ans)
# Judge status: Accepted
def main():
    D = int(input())
    C = list(map(int, input().split()))
    S = [list(map(int, input().split())) for _ in range(D)]

    score = 0
    last_day = [-1] * 26

    for d in range(D):
        print(S[d].index(max(S[d])) + 1)


if __name__ == '__main__':
    main()
# Judge status: Accepted
import sys
readline = sys.stdin.readline

D = int(readline())
C = list(map(int,readline().split()))
for i in range(D):
  S = list(map(int,readline().split()))
  
for i in range(D):
  print(1)
# Judge status: Accepted
n,*a=map(int,open(0).read().split())
c=0
for i in range(61):
 i=2**i
 t=sum(i&b and 1for b in a)
 c=(c+t*(n-t)*i)%(10**9+7)
print(c)
# Judge status: Accepted
N = int(input())
A = sorted(list(map(int,input().split())),reverse=True)
ans = A[0]
for i in range(1,N//2):
    ans += 2* A[i]
if N%2 == 1:
    ans += A[N//2]
print(ans)
# Judge status: Wrong Answer
n = int(input())
b,c=map(int, input().split())
if   (c//n) - (b//n)>=1  :
    print('OK')
else    : 
    print('NG')
# Judge status: Accepted
N = int(input())
A = [0] + list(map(int, input().split()))
B = [0] + list(map(int, input().split()))
C = [0] + list(map(int, input().split()))
ans = 0
for i in range(1, N + 1):
    ans += B[A[i]]
    if i >= 2 and A[i - 1] + 1 == A[i]:
        ans += C[A[i - 1]]
print(ans)
# Judge status: Accepted
a,b = map(int, input().split())
socket = 1
ans = 0
while socket < b:
  socket = socket + a-1
  ans += 1
print(ans)
# Judge status: Accepted
n = int(input())
s = input()
alphabets = 'abcdefghijklmnopqrstuvwxyz'
max_chr = 0

for i in range(len(s)-1):
    cnt = 0
    for letter in alphabets:
        if (letter in s[:i+1]) and (letter in s[i+1:]):
            cnt += 1
    max_chr = max(max_chr, cnt)
print(max_chr)
# Judge status: Wrong Answer
N,X,T = (int(x) for x in input().split())
if N%X == 0:
    n = X 
else:
    n = N//X+1
print(n*T)
# Judge status: Accepted
from math import ceil


def main():
    n = int(input())
    a = [0 for _ in range(n)]
    b = [0 for _ in range(n)]
    for i in range(n):
        a[i], b[i] = map(int, input().split())
    added = 0
    for i in range(n - 1, -1, -1):
        added += ceil((a[i] + added) / b[i]) * b[i] - (a[i] + added)
    print(added)


if __name__ == '__main__':
    main()
# Judge status: Accepted
N,K=map(int,input().split())
alist=list(map(int,input().split()))
#print(alist)

memo={0:False}
def isOK(x):
  if x in memo:
    return memo[x]
  
  num_cut=0
  for a in alist:
    num_cut+=-(-(a-x)//x)
    if num_cut>K:
      memo[x]=False
      return False  
    
  memo[x]=True
  return True

l=1
r=max(alist)+1
while l<=r:
  mid=(l+r)//2
  
  if not isOK(mid-1) and isOK(mid):
    print(mid)
    break
  elif isOK(mid-1):
    r=mid
  else:
    l=mid
# Judge status: Wrong Answer
N=int(input())
s=list(input())
from collections import Counter
d=Counter(s)
ans=1
for v in d.values():
  ans*=(v+1)
print(ans-1)
# Judge status: Accepted
s = input()
t = input()
print('Yes' if s == t[:-1] else 'No')
# Judge status: Wrong Answer
string=input()
for m in string:
  m='x'
print(string)
# Judge status: Accepted
n = int(input())
a = [int(i) for i in input().split()]

ans = [0] * n
for i in a:
    ans[i - 1] += 1
print("\n".join(map(str,(ans))))
# Judge status: Accepted
s,_,*q=open(0)
a='%s'
p=1
for q in q:
  try:
    q,f,c=q.split()
    if(f<'2')^p:a+=c
    else:a=c+a
  except:p^=1
print((a%s[:-1])[::p or-1])
# Judge status: Wrong Answer
A,B,M=map(int,input().split())
x = [0] * M
y = [0] * M
c = [0] * M
a = [0] * M
b = [0] * M
#0から入ってる
a=input().split()
b=input().split()

#ただの最小
mina=int(min(a))
minb=int(min(b))
nomal_count=mina+minb
#割引
wari_count=10*10*6
for i in range(M):
  x,y,c=map(int,input().split())
  now_count=int(a[x-1])+int(b[y-1])-c
  if nomal_count>now_count:
    wari_count=now_count
    
print(min(nomal_count,wari_count))
# Judge status: Accepted
from __future__ import division, print_function
import sys
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
#from functools import lru_cache   #use @lru_cache(None)
if os.path.exists('in.txt'): sys.stdin=open('in.txt','r')
if os.path.exists('out.txt'): sys.stdout=open('out.txt', 'w')
#
def input(): return sys.stdin.readline()
def mapi(arg=0): return map(int if arg==0 else str,input().split())
#------------------------------------------------------------------


d,t,s = mapi()
if d/s<=t:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N = int(input())
B = [10**6]+list(map(int,input().split()))+[10**6]
A = [0]*N

for p in range(N):
    A[p] = min(B[p], B[p+1])

print(sum(A))
# Judge status: Accepted
def resolve():
    X = int(input())

    ans = X // 500 * 1000

    X = X % 500

    ans += X // 5 * 5

    print(ans)


resolve()
# Judge status: Wrong Answer
a=int(input())

a=a+a^2+a^3
a=int(a)

print(a)
# Judge status: Wrong Answer
n, m = map(int, input().split())

cnt = 1
a = []
for i in range(1, int(m ** 0.5) + 1):
    if m % i == 0:
        x = m // i
        if x >= n:
            a.append(i)
        if i >= x:
            a.append(x)

print(max(a))
# Judge status: Wrong Answer
N = int(input())

ans = 0

a = (N // 11) * 2
b = N % 11

if b == 0:
    ans = a
elif 0 < b <= 5:
    ans = a + 1
else:
    ans = a + 2

print(ans)
# Judge status: Accepted
c=input()
if "9" in c:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
A, B, C = map(int, input().split())
K = int(input())
max_ = max(A, B, C)

print(max_*2*K + A + B + C - max_)
# Judge status: Accepted
s = str(input())
flag = 0
a = []
if(len(s)%2 != 0):
    print("No")
    exit()
else:
    for i in range(0,len(s),2):
        if(s[i] != "h" or s[i+1] != "i"):
            print("No")
            exit()
print("Yes")
# Judge status: Accepted
s = sorted(input())
alphabet = 'abcdefghijklmnopqrstuvwxyz'
for i in range(26):
    if not alphabet[i] in s:
        print(alphabet[i])
        break
    if alphabet[i] == 'z':
        print("None")
# Judge status: Accepted
X=input()

if X in ["3","5","7"]:
	print("YES")
else:
	print("NO")
# Judge status: Wrong Answer
a,b =map(int,input().split())
print(a*(a-1)/2 + b*(b-1)/2)
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))

cnt4 = 0
cnt2 = 0
for a in A:
    if a % 4 == 0:
        cnt4 += 1
    elif a % 2 == 0:
        cnt2 += 1

if (n - max(0, cnt2 - 1)) // 2 <= cnt4:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
s = set(sorted(a))
v = [i for i in s]
v.reverse()
b_1 = 0
b_2 = 0
for i in v:
    n = a.count(i)
    if n >= 2 and b_1 != 0 and b_2 == 0:
        b_2 = i
    if n >= 2 and b_1 == 0:
        b_1 = i
    if n >= 4 and b_2 == 0:
        b_2 = i
print(b_1*b_2)
# Judge status: Accepted
a, b, c = map(int, input().split())
print("YES" if any((a*i)%b==c for i in range(1, b+1)) else "NO")
# Judge status: Accepted
s=input()
a=int(s[0:2])
b=int(s[2:4])
if 0<a<13:
  if 0<b<13:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if 0<b<13:
    print('YYMM')
  else:
    print('NA')
# Judge status: Wrong Answer
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))

a = int(input())
b = int(input())

if (a == 1 and b == 2):
    print(3)
elif(a == 1 and b == 3):
    print(2)
else:
    print(1)
# Judge status: Wrong Answer
w,h,n = map(int, input().split())
xl, xu, yl, yu = 0, w, 0, h
for _ in range(n):
  x,y,a = map(int,input().split())
  if a == 1:
    xl = max(xl, x)
  elif a == 2:
    xu = min(xu, x)
  elif a == 3:
    yl = max(yl, y)
  else:
    yu = min(yu, y)

print(max((xu-xl)*(yu-yl), 0))
# Judge status: Accepted
l, r, d = map(int, input().split())
count = 0
for i in range(l, r+1):
    if i%d==0:
        count+=1
print(count)
# Judge status: Accepted
A, B = map(int, input().split())
if A == B:
    print("Draw")
elif A == 1 or B == 1:
    print("Alice" if A == 1 else "Bob")
else:
    print("Alice" if A > B else "Bob")
# Judge status: Accepted
import sys
N=int(input())
A=[int(x) for x in sys.stdin.readline().split()]

abssum=0
negative=0
mi=100000000000000
for i in range(N):
	if A[i]<0:
		negative+=1
	abssum+=abs(A[i])
	mi=min(mi,abs(A[i]))

if negative%2==1:
	abssum-=2*mi
print(abssum)
# Judge status: Accepted
N = int(input())
*A, = map(int, input().split())
*B, = map(int, input().split())
ans = 0
for i in range(N):
    left = min(A[i], B[i])
    ans += left
    A[i] -= left
    B[i] -= left

    right = min(A[i+1], B[i])
    ans += right
    A[i+1] -= right
    B[i] -= right
print(ans)
# Judge status: Accepted
S = input()
T = input()
list_s = []
list_t = []
counter = 0
for i in range(0, len(S)):
  list_s.append(S[i])
  list_t.append(T[i])
  if S[i] != T[i]:
    list_s[i] = list_t[i]
    counter += 1
print(counter)
# Judge status: Accepted
x, y = [int(w) for w in input().split()]

d = abs(abs(x) - abs(y))


if d == 0:
    if x - y == 0:
        ans = 0
    else:
        ans = 1
elif y == 0:
    if x < 0:
        ans = abs(x)
    else:
        ans = x + 1
else:
    ans = d

    if x * y > 0:
        if x > y:
            ans += 2
    else:
        if x > y:
            ans += 1
        elif x < 0:
            ans += 1

print(ans)
# Judge status: Wrong Answer
i = 0
for s in input():
    if s == "R":
        i += 1

print(i)
# Judge status: Wrong Answer
import math

zi, hun, H, M = map(int, input().split())
tan = H*30+M*0.5
tyo = M*6
bus = (tan-tyo)/90
ans = math.sqrt((zi**2)+(hun**2)) * bus
print(ans)
# Judge status: Accepted
s=list(input())
print(len(s)-(max(s.count('0'),s.count('1'))-min(s.count('0'),s.count('1'))))
# Judge status: Accepted
A,B,C,D=map(int,input().split())
start=max(A,C)
goal=min(B,D)
dt=goal-start
if dt<0:
    print(0)
else:
    print(dt)
# Judge status: Accepted
h,n=map(int, input().split())
li=list(map(int,input().split()))
if h<=sum(li):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
before = 0
ans = 0
for num in a:
    if num == before:
        if ans == 0:
            ans = num
            before = 0
        else:
            print(ans * num)
            exit()
    else:
        before = num
print(0)
# Judge status: Accepted
h, n = map(int, input().split())
sum = 0
for i in list(map(int, input().split())):
    sum += i
if sum >= h:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
NL = [ x for x in map(int,input().split()) ]
cha = []
i = 0
while i < NL[0]:
  cha.append(input())
  i += 1
print(sorted(cha))
# Judge status: Wrong Answer
from itertools import permutations
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

a, b = 0, 0
perms = list(permutations(range(1, N + 1)))

for per in perms:
    if P == per:
        a = perms.index(per) + 1
    elif Q == per:
        b = perms.index(per) + 1
    if a != 0 and b != 0:
        break
print(abs(a - b))
# Judge status: Accepted
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Created: Jul, 13, 2020 23:02:56 by Nobody
# $Author$
# $Date$
# $URL$
__giturl__ = "$URL$"


from collections import defaultdict
from sys import stdin
input = stdin.readline


def main():
  N = int(input())
  S = [input()[:-1] for _ in range(N)]

  dic = defaultdict(int)

  for i in range(N):
    dic[''.join(sorted(S[i]))] += 1

  ans = 0
  for n in dic.values():
    ans += int(n*(n-1)/2)
  print(ans)


if(__name__ == '__main__'):
  main()
# Judge status: Accepted
def main():
    n = int(input())
    h = list(map(int, input().split()))
    dp = [0] * n

    def cost(i,j):
        return abs(h[i]-h[j])

    dp[1] = cost(0,1)
    for i in range(2,n):
        dp[i] = min(dp[i-2] + cost(i-2,i), dp[i-1] + cost(i-1,i))
    print(dp[n-1])

if __name__ == '__main__':
    main()
# Judge status: Accepted
x,y=map(int,input().split())
count=0
while x<=y:
  x*=2
  count+=1
print(count)
# Judge status: Accepted
a, b = list(map(int, input().strip().split()))
c = a*b
if c%2 == 0:
  print('Even')
else:
  print('Odd')
# Judge status: Accepted
n, k = map(int, input().split())

amari = n % k

print(min(amari, abs(amari - k)))
# Judge status: Accepted
k, x = map(int, input().split())
if 500 * k >= x: print("Yes")
else: print("No")
# Judge status: Wrong Answer
n, k = map(int, input().split())
for i in range(k):
    d = int(input())
    A = set([int(x) for x in input().split()])
print(len(A))
# Judge status: Accepted
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if 500 * i + 100 * j + 50 * k == x:
                ans += 1
print(ans)
# Judge status: Wrong Answer
N,K = map(int,input().split())
cnt = 0
while(N>1):
    N /= K
    cnt += 1
print(cnt)
# Judge status: Accepted
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

s=input()

l = len(s)

if (l % 2 != 0):
    print('No')
    sys.exit()

for i in range(len(s)):
    if (i % 2 == 0 and s[i] != 'h') or (i % 2 == 1 and s[i] != 'i'):
        print('No')
        sys.exit()

print('Yes')
# Judge status: Wrong Answer
N = int(input())
A = list(map(lambda x:int(x)%4, input().split()))
ans_list = []
for i in [0,1,2,3]:
  a = A.count(i)
  ans_list.append(a)
  
ans = ans_list[0] - (ans_list[1] + ans_list[3])
if ans < 0:
  print("No")
  exit(0)
if ans_list[2]%2 == 0 and ans < 1:
  print("No")
  exit(0)
print("Yes")
# Judge status: Accepted
import numpy as np
n = int(input())
ab = np.zeros((n, 2))
for i in range(n):
    l = list(map(int, input().split()))
    ab[i, :] = l
ab = ab[np.argsort(ab[:, 1])]
a_cum = np.cumsum(ab[:, 0])
for i in range(n):
    if a_cum[i] > ab[i, 1]:
        print("No")
        break
else:
    print("Yes")
# Judge status: Wrong Answer
s = int(input())

n = [0, 0, 1]

for i in range(3, s) :
    # print(n[0:i-3])
    next_n = sum(n[0:i-2]) + 1
    n.append(next_n)
    # print(n)

# print(n)
print(n[-1] % (10**9 + 7))