Harryxun/stf_run huggingface dataset:
import math
import heapq
import copy
N = int(input())
A = [0] * N
for i in range(N):
    A[i] = int(input())
X = [0] * N
for i in range(N):
    B = copy.copy(A)
    del B[i]
    max = max(B)
    X[i] = max
    print(X[i])

### FIXED CODE ###

import math
import copy
N = int(input())
A = [0] * N
for i in range(N):
    A[i] = int(input())
#修正ver
max_item = max(A)
count = 0
second_item = 0
for i in range(N):
    if A[i] == max_item:
        count += 1
    elif second_item < A[i]:
        second_item = A[i]
    if count > 1:
        break
X = [0] * N
judge = False
for i in range(N):
    if count > 1:
        judge = True
        break
    if A[i] == max_item:
        X[i] = second_item
    else:
        X[i] = max_item

if judge:
    for i in range(N):
        X[i] = max_item
for i in range(N):
    print(X[i])
n, d, a = map(int, input().split())
monster = []
for _ in range(n):
  x, h = map(int, input().split())
  monster.append([x, h])
monster.sort()
bomb = 0
j = 0
for i in range(n):
  while j < n and monster[j][0] - monster[i][0] <= 2 * d:
    j += 1
  if monster[i][1] <= 0:
    continue
  b = (monster[i][1] - 1) // a + 1
  atk = a * b
  bomb += b
  for k in range(i+1, j):
    monster[k][1] -= atk
print(bomb)

### FIXED CODE ###

h, a = map(int, input().split())
print((h-1)//a + 1)
import math

x=int256(input())
s=math.floor(x/3)
f=math.floor(x/5)
sf=math.floor(x/15)

s_sum=math.floor(3*s*(s+1)/2)
f_sum=math.floor(5*f*(f+1)/2)
sf_sum=math.floor(15*sf*(sf+1)/2)

sum=s_sum+f_sum-sf_sum
print(math.floor(sum))


### FIXED CODE ###

import math

x=int(input())
s=math.floor(x/3)
f=math.floor(x/5)
sf=math.floor(x/15)
sum=math.floor(x*(x+1)/2)

s_sum=math.floor(3*s*(s+1)/2)
f_sum=math.floor(5*f*(f+1)/2)
sf_sum=math.floor(15*sf*(sf+1)/2)

fl=sum-(s_sum+f_sum-sf_sum)
print(math.floor(fl))
def f1(a,b,s):
	print(s[a:b+1])
	return s

def f2(a,b,s):
	temp = s[a:b+1]
	return s[:a] + temp[::-1] + s[b+1:]

def f3(a,b,p,s):
	return s[:a] + p + s[b+1:]

data = input()
q = int(input())
functions = {'print':f1, 'reverse':f2, 'replace':f3}

for i in range(q):
	temp = [s if s.isalpha() else int(s) for s in input().split(' ')]
	f = temp.pop(0)
	data = functions[f](*temp,data)

### FIXED CODE ###

def f1(s,a,b):
	print(s[a:b+1])
	return s

def f2(s,a,b):
	temp = s[a:b+1]
	return s[:a] + temp[::-1] + s[b+1:]

def f3(s,a,b,p):
	return s[:a] + p + s[b+1:]

data = input()
q = int(input())
functions = {'print':f1, 'reverse':f2, 'replace':f3}

for i in range(q):
	temp = [s if s.isalpha() else int(s) for s in input().split(' ')]
	f = temp.pop(0)
	data = functions[f](data,*temp)
from fractions import gcd # python 3.4
# from math import gcd # from python 3.5 
def lcm(a,b):
    return int(a*b/gcd(a,b))

N,M = map(int, input().split())
S = input()
T = input()
L= lcm(N,M)
ans = ["?"]*L
for i in range(N):
    idx = i*(L//N)
    ans[idx] = S[i]

for j in range(M):
    idx = j*(L//M)
    if ans[idx]!="?":
        if ans[idx]==T[j]:
            continue
        else:
            print(-1)
            break
else:
    print(L)

### FIXED CODE ###

from fractions import gcd # python 3.4
# from math import gcd # from python 3.5 
def lcm(a,b):
    return int(a*b/gcd(a,b))

N,M = map(int, input().split())
S = input()
T = input()
L= lcm(N,M)
ans = dict()
for i in range(N):
    idx = i*(L//N)
    ans[idx] = S[i]

for j in range(M):
    idx = j*(L//M)
    if idx in ans.keys():
        if ans[idx]==T[j]:
            continue
        else:
            print(-1)
            break
else:
    print(L)
while True:
    h,w = map(int, input().split())
    if h == 0 and w == 0:
        break
    else:
        for i in range(h):
            if i == 0 or i == h-1
                print("#" * w)
            else:
                print("#" + "." * (w-2) + "#")
    print()


### FIXED CODE ###

#
# 5b
#

def main():
    while True:
        H, W = map(int, input().split())
        if H == W == 0:
            break
        for i in range(H):
            if i == 0 or i == H - 1:
                print("#" * W)
            else:
                print("#" + "." * (W-2) + "#")
        print()


if __name__ == '__main__':
    main()
w=eval(input(""))
s=eval(input(""))
if(w>=s):
  print("unsafe")
else:
  print("safe")

### FIXED CODE ###

str = input("")
li = str.split()
if(eval(li[0])<=eval(li[1])):
  print("unsafe")
else:
  print("safe")
n = int(input())
p = map(int,input().split())

ans = 0

for i in range(1,n-1):
  if p[i-1]<p[i]<p[i+1] or p[i+1]<p[i]<p[i-1]:
    ans += 1
    
print(ans)
    

### FIXED CODE ###

n = int(input())
p = list(map(int,input().split()))
 
ans = 0
 
for i in range(1,n-1):
  if p[i-1]<p[i]<p[i+1] or p[i+1]<p[i]<p[i-1]:
    ans += 1
    
print(ans)
N = int(input())
flg = 0

for i in range(1, 10, 1):
  for j in range(1, 10, 1):
    if i*j==N:
      print(Yes)
      flg= 1
      
if flg==1:
  print(No)
      


### FIXED CODE ###

N = int(input())
flg = 0

for i in range(1, 10, 1):
  if flg==1:
    break
  for j in range(1, 10, 1):
    if i*j==N:
      print("Yes")
      flg= 1
      break
    
      
if flg==0:
  print("No")
s = input()
s_list = list(s)
s_list[3] = "8"
print("",join(s_list))

### FIXED CODE ###

s = input()
s_list = list(s)
s_list[3] = "8"
print("".join(s_list))
a,b,k = map(int,input().split())
def cf(x1,x2):
    cf=[]
    for i in range(2,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

l = cf(a,b)

print(l[-k])

### FIXED CODE ###

import sys
a,b,k = map(int,input().split())
c = 0
if a > b:    
    for i in range(b,0,-1):
        if (b%i == 0) and (a%i == 0):
            c += 1
            if c == k:
                print(i)
                sys.exit()
else:
    for i in range(a,0,-1):
        if (b%i == 0) and (a%i == 0):
            c += 1
            if c == k:
                print(i)
                sys.exit()
a , b = map(int,input().split())
if (a * b) % 2 ==0:
    print("even")
    else:
      print("odd")
      


### FIXED CODE ###

a , b = map(int,input().split())
if (a * b) % 2 ==0:
    print("Even")
else:
    print("Odd")
N = int(input())
ans = 0
S = {}
for i in range(N):
    s = ''.join(sorted(input()))
    if s not in S.keys():
        S[s] = 0
        continue
    print(S)
    S[s] += 1
    ans += S[s]
print(ans)


### FIXED CODE ###

N = int(input())
ans = 0
S = {}
for i in range(N):
    s = ''.join(sorted(input()))
    if s not in S.keys():
        S[s] = 0
        continue
    S[s] += 1
    ans += S[s]
print(ans)
a,b,c,d = map(int, input().split())
if abs(a-c) <= d or (abs(a-b) <= d and abs(b-c) <= d):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a,b = map(int, input().split())
if a <= b:
  print(a)
else:
  print(a-1)
N = int(input())
T = int(input())
d = {}
for i in range(N):
	c = int(input())
	t = int(input())
	d[c] = t
for c, t in sorted(d.items(), key=lambda x: x[0]):
	if t <= T:
		print(c)
		break
else:
	print("TLE")

### FIXED CODE ###

NT_in = input()
NT = NT_in.split()
N = int(NT[0])
T = int(NT[1])
d = {}
for i in range(N):
	str_num = input()
	num = str_num.split()
	d[int(num[0])] = int(num[1])
for c, t in sorted(d.items(), key=lambda x: x[0]):
	if t <= T:
		print(c)
		break
else:
	print("TLE")
import sys
from collections import Counter

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

if arr.count(0) > 1:
    print(0)
    sys.exit()

if len(arr) % 2 == 0 and arr.count(0) > 0:
    print(0)
    sys.exit()

cnt = Counter(arr)

li = list(cnt.values())

if li.count(2) != n // 2:
    print(0)
    sys.exit()

if not all([x <= 2 for x in li]):
    print(0)
    sys.exit(0)

print(reduce(mul, li))

### FIXED CODE ###

import sys
from collections import Counter

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

if len(arr) % 2 == 0:
    if 0 in arr:
        print(0)
        sys.exit()
else:
    if arr.count(0) != 1:
        print(0)
        sys.exit()
    else:
        arr.remove(0)

cnt = Counter(arr)

values = list(cnt.values())

if values.count(2) != len(values):
    print(0)
    sys.exit()

mod = 10**9 + 7

print(2**(n // 2) % mod)
a,b,c = map(int,input().split())
if b−a==c−b:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

a,b,c = map(int,input().split())
if b-a == c-b:
  print("YES")
else:
  print("NO")
import sys

def main():
    N, M = list(map(int, input().split()))
    
    inputs = [input().split() for i in range(M)]
    has_been_solved = set()

    penalty = {}
    correct = 0

    for i in inputs:
        
        num = int(i[0])
        if num in has_been_solved:
            continue

        if i[1] == 'AC':
            correct += 1
            has_been_solved.add(num)
        else:
            if num not in penalty:
                penalty[num] = 1
            else:
                penalty[num] += 1
    print(correct, sum([penalty[p] for p in has_been_solved]))         
        

if __name__ == "__main__":
    main()


### FIXED CODE ###

n,m=map(int,input().split())
a=[0]*n
w=[0]*n
ac=0
wc=0
for _ in range(m):
    p,s=input().split()
    p=int(p)-1
    if a[p]==0:
        if s=='AC':
            a[p]=1
            ac+=1
            wc+=w[p]
        else:
            w[p]+=1
print(ac,wc)
A, B, C  =  map(int, input().sprt))

### FIXED CODE ###

a,b,c=map(int,input().split())
if a>b:
    a,b=b,a
print("Yes" if a<=c<=b else "No")
MOD = 10**9+7 # p=MOD
n, a, b = map(int, input().split())
whole = pow(2, n, MOD)-1 # 2^n-1(mod p)を計算。
# nCaの計算
comb1=1
for i in range(n-a+1,n+1): # n*(n-1)*(n-2)*...*(n-a+1)(mod p)を計算
  comb1 *= i
  comb1 %= mod
for i in range(1,a+1): # 1/a!(mod p)を計算 フェルマーの小定理:1/a = a^p-2(mod p)を利用
  comb1 *= pow(i,mod-2,mod)
  comb1 %= mod
comb2=1
for i in range(n-b+1,n+1): # n*(n-1)*(n-2)*...*(n-b+1)(mod p)を計算
  comb2 *= i
  comb2 %= mod
for i in range(1,b+1):
  comb2 *= pow(i,mod-2,mod)
  comb2 %= mod
whole -= (comb1+comb2)
whole %= mod
print(whole)

### FIXED CODE ###

mod = 10**9+7 
n, a, b = map(int, input().split())
whole = pow(2, n, mod)-1 # 2^n-1(mod p)を計算。
# nCaの計算
comb1=1
for i in range(n-a+1,n+1): # n*(n-1)*(n-2)*...*(n-a+1)(mod p)を計算
  comb1 *= i
  comb1 %= mod
for i in range(1,a+1): # 1/a!(mod p)を計算 フェルマーの小定理:1/a = a^p-2(mod p)を利用
  comb1 *= pow(i,mod-2,mod)
  comb1 %= mod
comb2=1
for i in range(n-b+1,n+1): # n*(n-1)*(n-2)*...*(n-b+1)(mod p)を計算
  comb2 *= i
  comb2 %= mod
for i in range(1,b+1):
  comb2 *= pow(i,mod-2,mod)
  comb2 %= mod
whole -= (comb1+comb2)
whole %= mod
print(whole)
a,b=input().split()
if a*b%2==0:
  print("Even")
else:
  print("Odd")

### FIXED CODE ###

a,b=map(int, input().split())
if a*b%2==0:
  print("Even")
else:
  print("Odd")
s = list(map(str,input().split()))
t = list(map(str,input().split()))
count = 0
for i in range(len(s)):
    if(s[i] != t[i]):
        count += 1
print(count)

### FIXED CODE ###

a = int(input())
print(a+(a*a)+a*a*a)
from sys import stdin

a = map((int(x) for x in stdin.readline().split()))

print(len(a))


### FIXED CODE ###

from sys import stdin

a = set((int(x) for x in stdin.readline().split()))

print(len(a))
n,q=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
d=[int(input()) for i in range(q)]
L1=[]
L2=[]
L2=set(L2)
for i in range(n):
  L1.append([l[i][0]-l[i][2],1,l[i][2]])
  L1.append([l[i][1]-l[i][2],-1,l[i][2]])
L1.sort()

def minset(n):
  if len(L2)!=0:
    return min(n)
  else:
    return -1

ctd=0
for i in range(len(L1)):
  while L1[i][0]>d[ctd]:
    print(minset(L2))
    ctd+=1
  if L1[i][1]==1:
    L2.add(L1[i][2])
  else:
    L2.remove(L1[i][2])
while ctd<q:
  print(minset(L2))
  ctd+=1

### FIXED CODE ###

import sys
input=sys.stdin.readline
import heapq
n,q=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
L1=[]
for i in range(n):
  L1.append((l[i][0]-l[i][2],1,l[i][2]))
  L1.append((l[i][1]-l[i][2],-1,l[i][2]))
for i in range(q):
  L1.append((int(input()),2,0))
L1.sort()
L2=[]
heapq.heapify(L2)
L3=[]
L3=set(L3)
for i in range(len(L1)):
  if L1[i][1]==1:
    heapq.heappush(L2,L1[i][2])
    L3.add(L1[i][2])
  elif L1[i][1]==-1:
    L3.remove(L1[i][2])
  else:
    while L2 and L2[0] not in L3:
      heapq.heappop(L2)
    if L2:
      print(L2[0])
    else:
      print(-1)
a=int(input())
b=int(input())
print(a*b)

### FIXED CODE ###

a,b=map(int,input().split())
print(a*b)
def comb(a, b):
    if(a < b or b < 0):return 0
    if(b == 0):return 1
    if(b > a - b):return comb(a, a - b)
    return comb(a, b - 1) * (a - b + 1) / b

a, b, c = map(int, raw_input().split())
c -= a * b
print comb(c + a - 1, c)

### FIXED CODE ###

def fact(x):
    res = 1
    for i in xrange(1, x + 1):
        res *= i
    return res

def comb(a, b):
    if(a < b or b < 0):return 0
    if(b == 0):return 1
    return fact(a)/fact(b)/fact(a-b)

a, b, c = map(int, raw_input().split())
c -= a * b
print comb(c + a - 1, c)
import math
from functools import reduce

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

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

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

j = lcm_list(a)

cnt = 0
for i in a:
    cnt += (j-1)%i

print(cnt)


### FIXED CODE ###

import fractions

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

ans = a[0]
for i in range(1,N):
    ans = ans * a[i] // fractions.gcd(ans, a[i])

cnt = 0
for i in a:
    cnt += (ans-1)%i

print(cnt)
N, M = input().split(' ')
lis1 = input().split(' ')
S = sum(lis1)
thresh = S / (4 * M)
lis2 = sorted(lis1)
if lis2[M - 1] < thresh:
  print 'No'
else:
  print 'Yes'

### FIXED CODE ###

X, Y, Z = map(int, input().split(' '))
print(Z, X, Y)
N , K = map(int, input().split())
flag = "F"

lenN = len(N)
lenK = len(K)
N = abs(N-K*(abs(len(N)-len(K)))) 

while 1:
    
    
    a = N
    N = abs(N - K)
    

    if a<=K and N <= K:
        if a < N:
            result = a
            flag="T"
        else:
            result = N
            flag="T"
    if flag == "T":
        break
print(result)

### FIXED CODE ###

import math

N , K = map(int, input().split())
flag = "F"
if N !=0:
    while 1:
        lenN = int (math.log10(N) + 1)
        lenK = int (math.log10(K) + 1)
        N = abs(N-K*(10**abs(lenN-lenK-1)))
        lenN = int (math.log10(N) + 1)
        if abs(lenN-lenK)<2:
            break



        
while 1:
    
    
    a = N
    N = abs(N - K)
    

    if a<=K and N <= K:
        if a < N:
            result = a
            flag="T"
        else:
            result = N
            flag="T"
    if flag == "T":
        break
print(result)
H,W = map(int,input().split())

A=[]
for i in range(H):
    A.append(list(map(int,input().split())))

num=0
ans=''

for i in range(H):
    for j in range(W):
        if i%2==0:
            n=j
        else:
            n=W-1-j
        if A[i][n]%2==1:
            A[i][n]-=1
            if i!=H-1 and (i%2==0 and n==W-1) or (i%2==1 and n==0):
                num+=1
                A[i+1][n]+=1
                ans+='{} {} {} {}\n'.format(i+1,n+1,i+2,n+1)
            if (i%2==0 and n!=W-1) or (i%2==1 and n!=0):
                num+=1
                A[i][n+(-1)**(i%2)]+=1
                ans+='{} {} {} {}\n'.format(i+1,n+1,i+1,n+1+(-1)**(i%2))
print(num)
print(ans[:-1])



### FIXED CODE ###

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

A=[]
for i in range(H):
    A.append(list(map(int,input().split())))

ans=[]

for i in range(H):
    for j in range(W):
        if i%2==0:
            n=j
        else:
            n=W-1-j
        if A[i][n]%2==1:
            A[i][n]-=1
            if i<H-1 and ((i%2==0 and n==W-1) or (i%2==1 and n==0)):
                A[i+1][n]+=1
                ans.append('{} {} {} {}'.format(i+1,n+1,i+2,n+1))
            if (i%2==0 and n!=W-1) or (i%2==1 and n!=0):
                A[i][n+(-1)**(i%2)]+=1
                ans.append('{} {} {} {}'.format(i+1,n+1,i+1,n+1+(-1)**(i%2)))

print(len(ans))
for s in ans:
    print(s)
a,b = input().strip().split()
if (a * b)%2 == 0:
  print("Even") 
else:
  print("Odd")


### FIXED CODE ###

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

multi = a * b

if multi % 2 == 0:
    print("Even")
else:
    print("Odd")
s=int(input())

for i in range(3):
  if s[i] == s[i+1]:
    print("Bad")
    exit()
else:
  print("Good")

### FIXED CODE ###

s=input()

for i in range(3):
  if s[i] == s[i+1]:
    print("Bad")
    exit()
else:
  print("Good")
n_list = set(input().split())

if len(n_list)= 2:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n_list = set(input().split())

if len(n_list)== 2:
  print("Yes")
else:
  print("No")
True:
    line = raw_input()
    if line == '-1 -1 -1':
        break
    middle, final, re = map(int, line.split())
    if middle == -1 or final == -1:
        grade = 'F'
    elif middle + final >= 80:
        grade = 'A'
    elif 65 <= middle + final < 80:
        grade = 'B'
    elif 50 <= middle + final < 65:
        grade = 'C'
    elif 30 <= middle + final < 50:
        if 50 <= re:
            grade = 'C'
        grade = 'D'
    elif middle + final < 30:
        grade = 'F'
    print grade
    

### FIXED CODE ###

# coding=utf-8

def main():
    while True:
        line = raw_input()
        if line == '-1 -1 -1':
            break
        middle, final, re = map(int, line.split())
        if middle == -1 or final == -1:
            grade = 'F'
        elif middle + final >= 80:
            grade = 'A'
        elif 65 <= middle + final < 80:
            grade = 'B'
        elif 50 <= middle + final < 65:
            grade = 'C'
        elif 30 <= middle + final < 50:
            if 50 <= re:
                grade = 'C'
            else:
                grade = 'D'
        elif middle + final < 30:
            grade = 'F'
        print grade

if __name__ == '__main__':
    main()
hoge = []
for i in range(10001):
    if i % 3 == 0 and i % 5 == 0:
        hoge.append("FizzBuzz")
    elif i % 3 == 0:
        hoge.append("Fizz")
    elif i % 5 == 0:
        hoge.append("Buzz")
    else:
        hoge.append(str(i))

while True:
    m, n = map(int, input().split())
    if m == 0:
        break
    man = [str(i) for i in range(1, m+1)]
    a, b = divmod(n, m)
    man = a*man+man[:b]
    idx = 0
    for i in range(1, n+1):
        if hoge[i] == input():
            idx += 1
        else:
            v = man[idx]
            man = list(filter((v).__ne__, man))
    print(*sorted(list(set(man))))

### FIXED CODE ###

hoge = ["FizzBuzz" if i % 15 == 0 else("Fizz" if i % 3 == 0 else("Buzz" if i % 5 == 0 else str(i))) for i in range(10001)]

while True:
    m, n = map(int, input().split())
    if m == 0:
        break
    man = list(range(1, m+1))
    game = [input() for _ in range(n)]
    idx = 0
    for i in range(n):
        if game[i] != hoge[i+1]:
            del man[idx]
            if len(man) == 1:
                break
        else:
            idx += 1
        idx %= len(man)
    print(*man)
from math import gcd

N = int(input())
A = [int(i) for i in input().split()]


ans = -1
for i in range(N):
    flg = 0
    tmp = A[:i] + A[i+1:]
    Gcd = tmp[0]
    for j in range(N-2):
        g = gcd(tmp[j], tmp[j+1])
        Gcd = gcd(Gcd, g)
        if Gcd < ans:
            flg = 1
            break
    if flg:
        continue
    ans = max(ans, Gcd)

print(ans)


### FIXED CODE ###

N = int(input())
A = [int(i) for i in input().split()]


def gcd(a: int, b: int) -> int:
    while a % b != 0:
        r = a % b
        a = b
        b = r
    return b


L = [0] * N
R = [0] * N
for i in range(1, N):
    L[i] = gcd(L[i-1], A[i-1])
    R[N-i-1] = gcd(R[N-i], A[N-i])

for i in range(N):
    if i == 0:
        ans = R[i]
    elif i == N-1:
        ans = max(ans, L[i])
    else:
        ans = max(ans, gcd(L[i], R[i]))

print(ans)
while(1):
    [N,M]=[int(x) for x in raw_input().split()]
    if N==0:
        break
    else:
        H=[]
        W=[]
        for i in range(N):
            H.append(int(raw_input()))
        for i in range(M):
            W.append(int(raw_input()))
        S=0
        for top in range(N):
            for left in range(M):
                h=0
                w=0
                right=left
                for bottom in range(top,N):
                    h=h+H[bottom]
                    while w<h and right<M:
                        w=w+W[right]
                        right=right+1
                    if w==h:
                        S=S+1
        print S

### FIXED CODE ###

import bisect
while(1):
    [N,M]=[int(x) for x in raw_input().split()]
    if N==0:
        break
    else:
        hlist=[]
        wlist=[]
        bef=[]
        for i in range(N):
            newh=int(raw_input())
            news=[newh+a for a in bef]
            hlist+=news
            hlist.append(newh)
            bef=news+[newh]
        bef=[]
        for i in range(M):
            neww=int(raw_input())
            news=[neww+a for a in bef]
            wlist+=news
            wlist.append(neww)
            bef=news+[neww]
        hlist.sort()
        #print hlist,wlist
        ans=0
        for w in wlist:
            ans+=bisect.bisect(hlist,w)-bisect.bisect_left(hlist,w)
        print ans
n, k = [int(i) for i in input().split()]
d = {}
for i in range(n):
    a, b = [int(i) for i in input().split()]
    if a in d:
        d[a] += b
    else:
        d[a] = b
c = []
for k, v in sorted(d.items(), key=lambda x: x[0]):
    c += [k] * v
print(c[k])


### FIXED CODE ###

n, k = [int(i) for i in input().split()]
cnt = [0] * int(10e5)
for i in range(n):
    a, b = [int(i) for i in input().split()]
    cnt[a] += b

for i in range(1, len(cnt)):
    if k <= cnt[i]:
        print(i)
        break
    k -= cnt[i]
import math

def f():
    x = 0; y = 1; r = 2
    for w in L_w:
        A = (tx-w[x])**2 + (ty-w[y])**2 - w[r]**2
        B = (sx-w[x])**2 + (sy-w[y])**2 - w[r]**2
        if 0 < A and 0 < B and (tx-w[w])*(sx-w[x]) < 0:
            P = abs((sy-ty)*w[x] - (sx-tx)*w[y] - (sy-ty)*tx + ty)
            Q = math.sqrt((sy-ty)**2 + (sx-tx)**2)
            print (float(P)/Q)
            if (float(P)/Q) <= w[r]:
                print 'Safe'
                break
        elif A*B < 0:
            print 'Safe'
            break
    else:
        print 'Danger'
   
while True:
    N = input()
    if N == 0: break
    L_w = [map(int, raw_input().split()) for i in range(N)]
    for i in range(input()):
        tx, ty, sx, sy = map(int, raw_input().split())
        f()

### FIXED CODE ###

import math

def f():
    for x, y, r in W:
        A = (tx-x)**2 + (ty-y)**2 - r**2
        B = (sx-x)**2 + (sy-y)**2 - r**2
        if A * B < 0:
            print 'Safe'
            break
        elif 0 < A and 0 < B:
            if tx == sx:
                d = abs(x-tx)
            else:
                P = abs((sy-ty)*x - (sx-tx)*y - (sy-ty)*tx + (sx-tx)*ty)
                Q = math.sqrt((sy-ty)**2 + (sx-tx)**2)
                d = P / Q
            if d <= r:
                if (tx-sx)*(x-sx) + (ty-sy)*(y-sy) > 0:
                    if (sx-tx)*(x-tx) + (sy-ty)*(y-ty) > 0:
                        print 'Safe'
                        break
    else:
        print 'Danger'
   
while True:
    N = input()
    if N == 0: break
    W = [map(int, raw_input().split()) for i in range(N)]
    for i in range(input()):
        tx, ty, sx, sy = map(int, raw_input().split())
        f()
N,W=map(int,input().split())
dp=[0]*(W+1)
L = sorted([list(map(int,input().split())) for i in range(N)])
s=0
 
for w, v in L:
    s+=w
    for j in range(min(W,s),w-1,-1):
        if dp[j-w]+v > dp[j]: dp[j]=dp[j-w]+v
    
print(max(dp))

### FIXED CODE ###

N = int(input())
H = [int(x) for x in input().split()]
dp = [0]*N
dp[0] = 0
dp[1] = abs(H[1]-H[0])
for i in range(2,N):
    dp[i] = min(dp[i-1]+abs(H[i]-H[i-1]),dp[i-2]+abs(H[i]-H[i-2]))
    
print(dp[N-1])