Harryxun/stf_run huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;
 
int main(void){
    int n;
    cin >> n;
    vector<pair<pair<string,int>,int>> rest(n);
    for(int i = 0;i < n;i++){
        cin >> rest[i].first.first >> rest[i].first.second;
        rest[i].first.second *= -1;
        rest[i].second = i+1;
    }
 
    sort(rest.begin(),rest.end());
 
    for(int i = 0;i < n;i++){
        cout << rest[i].second << endl;
    }
 
    return 0;
}

### FIXED CODE ###

def main():
    N = int(input())
    A = []
    for i in range(N):
        S, P = input().split()
        A.append((S,int(P),i+1))
 
    sort_A = sorted(A, key=lambda x:(x[0], -x[1])) 
    for i in range(N):
        print(sort_A[i][2])
 
main()
x,y = map(int, input().split())
if abs(x) <= abs(y):
    c = abs(abs(x) - abs(y))
    if x >= 0 and y >= 0:
        print(c)
    elif x < 0 and y < 0:
        print(c+2)
    else:
        print(c+1)
else:
    c = abs(abs(x) - abs(y))
    if y = 0:
        print(c)
    elif x >= 0 and y >= 0:
        print(c+2)
    elif x < 0 and y < 0:
        print(c)
    else:
        print(c+1)

### FIXED CODE ###

x,y = map(int, input().split())
if abs(x) <= abs(y):
    c = abs(abs(x) - abs(y))
    if x >= 0 and y >= 0:
        print(c)
    elif x < 0 and y < 0:
        print(c+2)
    else:
        print(c+1)
else:
    c = abs(abs(x) - abs(y))
    if y == 0 and x < 0:
        print(c)
    elif y ==0 and x>=0:
        print(c+1)
    elif x >= 0 and y >= 0:
        print(c+2)
    elif x < 0 and y < 0:
        print(c)
    else:
        print(c+1)
N,M=map(int,input().split())
n1=min(N,M//2)
print(ans+(M-2*n1)//4)


### FIXED CODE ###

N,M=map(int,input().split())
n1=min(N,M//2)
print(n1+(M-2*n1)//4)
a=list(input())
b=a.copy()
b.reverse()
n=len(a)
k=0
r=''
s=''
rr=''
t=''
if (n-1)//2>n:
    k+=1
else:
    t=a[:(n-1)//2]
    s=t.copy()
    s.reverse()
if (n+3)//2-1>n:
    k+=1
else:

    r=a[(n+3)//2-1:n]
    rr=r.copy()
    rr.reverse()
if k>0:
    print('No')
else:
    if a==b and r==rr and t==s:
        print('Yes')
    else:
        print('No')


### FIXED CODE ###

def reverse(s):
    return s[::-1]
a=str(input())
b=reverse(a)
n=len(a)
c=a[:(n-1)//2]
d=reverse(c)
e=a[(n+3)//2-1:n]
f=reverse(e)

if a==b and c==d and e==f:
    print('Yes')
else:
    print('No')
s=input()
t=s.reverse()
if s==t:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

from copy import deepcopy as dp
s=list(input())
t=dp(s)
s.reverse()
if s==t:
  print("Yes")
else:
  print("No")
from collections import defaultdict

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

maze = [[0]*W for _ in range(H)]
for _ in range(M):
  h,w = map(int,input().split())
  h -= 1
  w -= 1
  maze[h][w] = 1

max_row = 0
rows = defaultdict(list)
for i in range(H):
  s = sum(maze[i])
  rows[s].append(i)
  max_row = max(max_row, s)

max_col = 0
cols = defaultdict(list)
for i in range(W):
  s = 0
  for j in range(H):
    s += maze[j][i]
  cols[s].append(i)
  max_col = max(max_col, s)

r_cans = rows[max_row]
c_cans = cols[max_col]

ans = 0
for r_can in r_cans:
  for c_can in c_cans:
    t = max_row + max_col
    if maze[r_can][c_can]: t -= 1
    ans = max(ans, t)

print(ans)

### FIXED CODE ###

from collections import defaultdict

H,W,M = map(int,input().split())
dic = defaultdict(bool)
h_c = [ 0 for _ in range(H) ]
w_c = [ 0 for _ in range(W) ]

for _ in range(M):
  h,w = map(int,input().split())
  h -= 1
  w -= 1
  h_c[h] += 1
  w_c[w] += 1
  dic[(h,w)] = True

h_cans,w_cans = [],[]
h_max,w_max = max(h_c),max(w_c)
for i in range(H):
  if h_c[i] == h_max:
    h_cans.append(i)

for i in range(W):
  if w_c[i] == w_max:
    w_cans.append(i)

ans = h_max + w_max - 1
for h in h_cans:
  for w in w_cans:
    if not dic[(h,w)]: 
      print(ans+1)
      exit()

print(ans)
import math
from bisect import bisect
x1,y1,x2,y2 = map(int,input().split())
N = int(input())
src = [tuple(map(int,input().split())) for i in range(N)]
src.sort()
if x1 > x2:
    x1,x2 = x2,x1
    y1,y2 = y2,y1

arc = 5 * math.pi

if x1 == x2:
    if y1 > y2:
        y1,y2 = y2,y1
    ans = 100 * (y2-y1)
    for x,y in src:
        if x == x1 and y1 < y < y2:
            ans += arc*2 - 20
            break
    print(ans)
    exit()

if y1 == y2:
    if x1 > x2:
        x1,x2 = x2,x1
    ans = 100 * (x2-x1)
    for x,y in src:
        if y == y1 and x1 < x < x2:
            ans += arc*2 - 20
            break
    print(ans)
    exit()

#assert x1 < x2

if y1 < y2:
    lis = []
    for x,y in src:
        if x < x1: continue
        if x > x2: break
        if not y1 <= y <= y2: continue
        i = bisect(lis, y)
        if i == len(lis):
            lis.append(y)
        else:
            lis[i] = y
    ans = 100 * (x2-x1 + y2-y1)
    ans += len(lis) * (arc - 20)
    print(ans)
else:
    lds = []
    for x,y in src:
        if x < x1: continue
        if x > x2: break
        if not y2 <= y <= y1: continue
        if i == 0:
            lds.append(y)
        else:
            lds[-i] = y
    ans = 100 * (x2-x1 + y1-y2)
    ans += len(lds) * (arc - 20)
    print(ans)

### FIXED CODE ###

import math
from bisect import bisect
x1,y1,x2,y2 = map(int,input().split())
N = int(input())
src = [tuple(map(int,input().split())) for i in range(N)]
src.sort()
if x1 > x2:
    x1,x2 = x2,x1
    y1,y2 = y2,y1

arc = 5 * math.pi

if x1 == x2:
    if y1 > y2:
        y1,y2 = y2,y1
    ans = 100 * (y2-y1)
    for x,y in src:
        if x == x1 and y1 < y < y2:
            ans += arc*2 - 20
            break
    print(ans)
    exit()

if y1 == y2:
    if x1 > x2:
        x1,x2 = x2,x1
    ans = 100 * (x2-x1)
    for x,y in src:
        if y == y1 and x1 < x < x2:
            ans += arc*2 - 20
            break
    print(ans)
    exit()

if y1 < y2:
    lis = []
    for x,y in src:
        if x < x1: continue
        if x > x2: break
        if not y1 <= y <= y2: continue
        i = bisect(lis, y)
        if i == len(lis):
            lis.append(y)
        else:
            lis[i] = y
    ans = 100 * (x2-x1 + y2-y1)
    if len(lis) in (x2-x1+1, y2-y1+1):
        ans += (len(lis)-1) * (arc - 20)
        ans += arc*2 - 20
    else:
        ans += len(lis) * (arc - 20)
    print(ans)
else:
    lds = []
    for x,y in src:
        if x < x1: continue
        if x > x2: break
        if not y2 <= y <= y1: continue
        i = bisect(lds, -y)
        if i == len(lds):
            lds.append(-y)
        else:
            lds[i] = -y
    ans = 100 * (x2-x1 + y1-y2)
    if len(lds) in (x2-x1+1, y1-y2+1):
        ans += (len(lds)-1) * (arc - 20)
        ans += arc*2 - 20
    else:
        ans += len(lds) * (arc - 20)
    print(ans)
n,m,k=map(int, input().split( ))
mod = 998244353

ans=0
if m==1:##コーナー
  	print(1 if k==n-1 else 0)
    exit()
tmp=m*pow(m-1,n-1,mod)
m_inv=pow(m-1,mod-2,mod)
invs=[0]+[pow(i+1,mod-2,mod) for i in range(n)]
for i in range(1,k+2):
    ans+=tmp
    #print(ans)
    tmp*=m_inv
    if i<n:##?
        tmp*=n-i
        tmp*=invs[i]
    tmp%=mod
print(ans%mod)



### FIXED CODE ###

n,m,k=map(int, input().split( ))
mod = 998244353

ans=0
if m==1:##コーナー
  	print(1 if k==n-1 else 0)
  	exit()
tmp=m*pow(m-1,n-1,mod)
m_inv=pow(m-1,mod-2,mod)
invs=[0]+[pow(i+1,mod-2,mod) for i in range(n)]
for i in range(1,k+2):
    ans+=tmp
    #print(ans)
    tmp*=m_inv
    if i<n:##?
        tmp*=n-i
        tmp*=invs[i]
    tmp%=mod
print(ans%mod)
print(x*x*x)


### FIXED CODE ###

print(int(input())**3)
from collections import Counter

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

v1=[]
v2=[]

for i in range(n):
  if i%2==0:
    v1.append(v[i])
  else:
    v2.append(v[i])

v1c = Counter(v1).most_common()
v2c = Counter(v2).most_common()
ans2=float("inf")
ans3=float("inf")


if v1c[0][0]!=v2c[0][0]:
  ans=len(v1)-v1c[0][1]+len(v2)-v2c[0][1]
  print(ans)

else:
  if len(v1c) !=1:
  	ans2=len(v1)-v1c[1][1]+len(v2)-v2c[0][1]
  elif len(v2c) !=1:
    ans3=len(v1)-v1c[0][1]+len(v2)-v2c[1][1]
  else:
    ans4=min(len(v1),len(v2))
  print(min(ans2,ans3,ans4))
 
  

### FIXED CODE ###

from collections import Counter

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

v1=[]
v2=[]

for i in range(n):
  if i%2==0:
    v1.append(v[i])
  else:
    v2.append(v[i])

v1c = Counter(v1).most_common()
v2c = Counter(v2).most_common()

ans2=float("inf")
ans3=float("inf")
ans4=float("inf")


if v1c[0][0]!=v2c[0][0]:
  ans=len(v1)-v1c[0][1]+len(v2)-v2c[0][1]
  print(ans)

else:
  if len(v1c) !=1:
    ans2=len(v1)-v1c[1][1]+len(v2)-v2c[0][1]
  if len(v2c) !=1:
    ans3=len(v1)-v1c[0][1]+len(v2)-v2c[1][1]
  else:
    ans4=min(len(v1),len(v2))
  print(min(ans2,ans3,ans4))
INF = float('inf')
class BellmanFord:
    
    def bellmanford(self,s,V,E):
        dist = [INF for _ in range(V)]
        dist[s] = 0
        while (True):
            update = False
            for e in E:
                u,v,cost = e
                if dist[u] != INF and dist[v] > dist[u] + cost:
                    dist[v] = dist[u]+cost
                    update = True
            if not update:break
        return dist
    
    def findneg(self,V,E):
        dist = [0 for _ in range(V)]
        neg = [False for _ in range(N)]
        for i in range(V):
            for e in E:
                u,v,cost = e
                if dist[u] == INF:continue
                if dist[u] != INF and dist[v] > dist[u] + cost:
                    dist[v] = dist[u]+cost
                    neg[v] = True
                    if i == V-1:return True
                if neg[u]:
                    neg[v] = True 
        return neg

def main():
    N,M = map(int,input().split())
    E = []
    for _ in range(M):
        a,b,c = map(int,input().split())
        a -= 1
        b -= 1
        E.append((a,b,-c))
    bf = BellmanFord()
    neg = bf.findneg(N,E)
    if neg[-1]:
        print("inf")
    else:
        dist = bf.bellmanford(0,N,E)
        ans = dist[-1]
        print(-ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

INF = float('inf')
class BellmanFord:
    
    def bellmanford(self,s,V,E):
        dist = [INF for _ in range(V)]
        dist[s] = 0
        for i in range(V):
            for e in E:
                u,v,cost = e
                if dist[u] != INF and dist[v] > dist[u] + cost:
                    dist[v] = dist[u]+cost
                    if i == V-1 and v == V-1:
                        return -1
        return dist
    

def main():
    N,M = map(int,input().split())
    E = []
    for _ in range(M):
        a,b,c = map(int,input().split())
        a -= 1
        b -= 1
        E.append((a,b,-c))
    bf = BellmanFord()
    dist = bf.bellmanford(0,N,E)
    if dist == -1:
        print('inf')
    else:
        ans = dist[-1]
        print(-ans)

if __name__ == "__main__":
    main()
n = int(raw_input())
l = []
max = -10^9
x=0
for i in range(n-1):
    l.append(int(raw_input())

for s in range(n-1):
 for t in range(s-1):
  x= l[n-s-1] - l[n-t-1]
  if max<x:
   max=x
printf('%d')%(max)

### FIXED CODE ###

n = int(raw_input())
max = -10**9
x1 = input() 
min = x1

for i in range(n-1):
 x = int(raw_input())

 if max < x-min:
  max = x- min
 if x< min:
  min = x
  
print max
def workC():
    
    x,n = map(int,input().split())
    l = list(map(int,input().split()))

    if n == 0:
        return x
    
    if n == 100:
        return 0
    
    for i in range(x,maxx):
        if not i in l:
            u = i
            #dic.setdefault(i,abs(i-x))
            break
    
    for i in range(x,minx,-1):
        if not i in l:
            d = i
            #dic.setdefault(i,abs(x-i))
            break
    
    if abs(x-u) == abs(x-d):
        return min(u,d)
    elif abs(x-u) < abs(x-d):
        return u
    else:
        return d

ans = workC()
print(ans)

### FIXED CODE ###

import sys

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

for d in range(X + 1):
    for s in [-1, +1]:
        a = X + s * d
        if p.count(a) == 0:
            print(a)
            sys.exit(0)
a, b = map(int, input().split())
if a > 10 | b > 10:
 	print (-1)
	else:
  	print(a * b)


### FIXED CODE ###

a, b = map(int, input().split())
if a > 9 or b > 9:
 	print (-1)
else:
  	print(a * b)
#!/usr/bin/python
# -*- coding: UTF-8 -*-

import math
import sys


def calc_p(a, b, c):
    u = {a, b, c}
    if len(u) == 3:
        return 6
    if len(u) == 2:
        return 3
    if len(u) == 1:
        return 1
    else:
        raise


def std_in():
    return sys.stdin.readline().strip()


def _main():
    N = int(std_in())
    fn = [0] * (N + 1)
    x_max = int(math.sqrt(N - 2)) - 1

    n2 = [i**2 for i in range(1, x_max + 1)]

    ij = [[0 for _ in range(1, x_max + 1)] for _ in range(1, x_max + 1)]
    for i in range(x_max):
        for j in range(i, x_max):
            ij[i][j] = (i+1) * (j+1)

    for x in range(1, x_max + 1):
        y_min = x
        x2 = n2[x-1]
        for y in range(y_min, x_max + 1):
            z_min = y
            y2 = n2[y-1]
            xy = ij[x-1][y-1]
            tmp_n = x2 + xy + y2
            if tmp_n > N:
                break
            for z in range(z_min, x_max + 1):
                z2 = n2[z-1]
                yz = ij[y-1][z-1]
                zx = ij[x-1][z-1]
                n = tmp_n + z2 + yz + zx
                if n > N:
                    break
                fn[n] += calc_p(x, y, z)

    for i in range(1, N + 1):
        print(fn[i])


if __name__ == "__main__":
    _main()


### FIXED CODE ###

#!/usr/bin/python
# -*- coding: UTF-8 -*-

import math
import sys


def calc_p(a, b, c):
    u = {a, b, c}
    if len(u) == 3:
        return 6
    if len(u) == 2:
        return 3
    if len(u) == 1:
        return 1
    else:
        raise


def std_in():
    return sys.stdin.readline().strip()


def _main():
    N = int(std_in())
    fn = [0] * (N + 1)
    if N == 1:
        x_max = 1
    else:
        x_max = int(math.sqrt(N - 2)) - 1

    n2 = [i**2 for i in range(1, x_max + 1)]

    ij = [[0 for _ in range(1, x_max + 1)] for _ in range(1, x_max + 1)]
    for i in range(x_max):
        for j in range(i, x_max):
            ij[i][j] = (i+1) * (j+1)

    for x in range(1, x_max + 1):
        y_min = x
        x2 = n2[x-1]
        for y in range(y_min, x_max + 1):
            z_min = y
            y2 = n2[y-1]
            xy = ij[x-1][y-1]
            tmp_n = x2 + xy + y2
            if tmp_n > N:
                break
            for z in range(z_min, x_max + 1):
                z2 = n2[z-1]
                yz = ij[y-1][z-1]
                zx = ij[x-1][z-1]
                n = tmp_n + z2 + yz + zx
                if n > N:
                    break
                fn[n] += calc_p(x, y, z)

    for i in range(1, N + 1):
        print(fn[i])


if __name__ == "__main__":
    _main()
N ,K = map(int, input().split())

A = list(map(int, input().split()))
d = [0] * N

#二分探索
min = 0
max = max(A)

while True:
    X = (min + max)//2
    for i in range(N):
        d[i] = A[i]//X
    if sum(d) <= K:
        max = X
    else:
        min = X
    print(min, max)
    
    if min + 1 == max:
        print(int(max))
        break


### FIXED CODE ###

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

A = list(map(int, input().split()))
d = [0] * N

#二分探索
min1 = 0
max1 = max(A) + 1

while True:
    X = (min1 + max1)//2
    for i in range(N):
        if A[i] % X == 0:
            d[i] = A[i]//X - 1
        else:
            d[i] = A[i]//X
    if sum(d) <= K:
        max1 = X 
    else:
        min1 = X
    #print(min1, max1)

    if max1 - min1 <= 1:
        print(int(max1))
        break
a, b = map(int, input())
avg = (a+b) /2
if (avg*10)%10 == 0:
  print(avg)
else:
  print(avg+1)

### FIXED CODE ###

a, b = map(int, input().split())
avg = (a+b) /2
ans = avg*10 // 10
if (avg*10)%10 == 0:
  print(int(ans))
else:
  print(int(ans+1))
N,Q=map(int,input().split())
a=[0 for i in range(N-1)]
b=[0 for i in range(N-1)]
p=[0 for i in range(Q)]
q=[0 for i in range(Q)]
for i in range(N-1):
  a[i],b[i]=map(int,input().split())
for i in range(Q):
  p[i],q[i]=map(int,input().split())
#print(N,Q)
#print(a)
#print(b)
#print(p)
#print(q)

c=list(zip(a,b))
c.sort()
a,b=list(zip(*c))

K=[0 for i in range(N)]
for i in range(N-1):
  K[p[i]-1]+=q[i]
#print(K)

for i in range(N-1):
  K[b[i]-1]+=K[a[i]-1]
#print(K)

print(" ".join(map(str,K)))

### FIXED CODE ###

import collections

N,Q=map(int,input().split())
M=[[] for i in range(N+1)]
P=[0 for i in range(N+1)]
for i in range(N-1):
  a,b=map(int,input().split())
  M[a].append(b)
  M[b].append(a)
#print("M:",M)

S=[0 for i in range(N+1)]
for i in range(Q):
  p,x=map(int,input().split())
  S[p]+=x
#print(S)
  
d=collections.deque([1])

while len(d):
  dd=d.popleft()
  if P[dd]==0:
    P[dd]=1
    for i in M[dd]:
      if P[i]==0:
        S[i]+=S[dd]
      d.append(i)
  #print(d,S)
print(*S[1:])
k=int(inout())
if k%2==0:
  print((k/2)**2)
elif k%2==1:
  print((k/2)*(k/2+1))

### FIXED CODE ###

k=int(input())
if k%2==0:
  print(int((k/2))**2)
elif k%2==1:
  print(int((k/2))*int((k/2+1)))
n, k , s = map(int, input().split())
ans = []
for i in range(n):
    if k != 0:
        ans.append(s)
        k -= 1
    else:
      	if s == 10**9:
          ans.append(s-1)
        else if s == 1:
          ans.append(s+1)
        else:
          ans.append(s+1)
print(" ".join([str(x) for x in ans]))


### FIXED CODE ###

n, k , s = map(int, input().split())
ans = []
for i in range(n):
    if k != 0:
        ans.append(s)
        k -= 1
    else:
        ans.append(s+1 if s != 10**9 else s-1)
print(" ".join([str(x) for x in ans]))
s = input()

dp = [[0]*2019 for i in range(len(s))]

mod = 2019

for l in range(0, len(s)-1):
    dp[l][int(s[l])] += 1
    for m in range(0, mod):
        if dp[l][m] != 0:
            num = int(s[l+1])
            dp[l+1][(10*m+num)%mod] += dp[l][m]
            
cnt = 0
for l in range(0, len(s)):
    if dp[l][0] != 0:
        cnt += dp[l][0]
        
print(cnt)

### FIXED CODE ###

s = input()
mod = 2019
array = [0]*(len(s)+1)

for i in range(len(s)):
    array[i+1] = (array[i] + pow(10,i,mod)*int(s[len(s)-(i+1)])) % mod
    

    
array.sort()

cnt = 0
w = 1

for i in range(0, len(array)-1):
    if array[i] == array[i+1]:
        w += 1
    else:
        if w >= 2:
            cnt += w*(w-1)/2
            w = 1
            
if w != 1:
    cnt += w*(w-1)/2
    
print(int(cnt))
input_line=input().rstrip().slpit()
num1 = int(input_line[0])
num2 = int(input_line[1])
if (num1>num2):
  num = num2
elif(num1<num2):
  num = num1
elif(num1=num2):
  num = num1
count = num
for i in range(count):
  print(num)

### FIXED CODE ###

input_line=input().rstrip().split()
num1 = int(input_line[0])
num2 = int(input_line[1])
 
if (num1 > num2):
  print(str(num2)*num1)
elif (num1 < num2):
  print(str(num1)*num2)
elif (num1 == num2):
  print(str(num1)*num2)
N = int(input())
A = list(map(int, input().split()))
left = [0]*N
right = [0]*N

left_gcd = A[0]
left[0] = A[0]
for i in range(1, N-1):
    left[i] = math.gcd(left_gcd, A[i])

right_gcd = A[-1]
right[-1] = A[-1]
for i in range(N-2, 0, -1):
    right[i] = math.gcd(right_gcd, A[i])

# print(left, right)
max_val = max(left[-2], right[1])
for i in range(1, N-1):
    max_val = max(max_val, math.gcd(left[i-1], right[i+1]))

print(max_val)

### FIXED CODE ###

from fractions import gcd

NN = 202020
MOD = 10**9+7
INF = float("inf")

N = int(input())
A = list(map(int, input().split()))
left = [0]*N
right = [0]*N

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

right[-1] = A[-1]
for i in range(N-2, 0, -1):
     right[i] = gcd(right[i+1], A[i])

# print(left, right)
max_val = max(left[-2], right[1])
for i in range(1, N-1):
    max_val = max(max_val, gcd(left[i-1], right[i+1]))

print(max_val)
:cross: 

### FIXED CODE ###

a,b=map(int,input().split());a,b=(a+11)%13,(b+11)%13
if a>b:print("Alice")
elif a==b:print("Draw")
else:print("Bob")
def actual(A, B, C, X):
    count = 0

    for n_500yen in range(A + 1):
        for n_100yen in range(B + 1):
            for n_050yen in range(C + 1):
                amount = 500 * n_500yen + 100 * n_100yen + 50 * n_050yen

                if amount == X:
                    count += 1

    return count

A = int(input())
B = int(input())
C = int(input())
X = int(input())

print(actual(A, B, C, X))


### FIXED CODE ###

def actual(s):
    if set(s) == {'a', 'b', 'c'}:
        return 'Yes'

    return 'No'

s = input()
print(actual(s))
N, M, K = map(int, input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
c = 0
while K > 0:
    if not A == [] and not B == []:
        if A[0] >= B[0]:
            K = K - A[0]
            A.remove(A[0])
            if K >= 0:
                c += 1
        else:
            K = K - B[0]
            B.remove(B[0])
            if K >= 0:
                c += 1
    if A == []:
        K = K - B[0]
        B.remove(B[0])
        if K >= 0:
                c += 1
    if B == []:
        K = K - A[0]
        A.remove(A[0])
        if K >= 0:
                c += 1
print(c)

### FIXED CODE ###

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

a, b = [0], [0]
for i in range(N):
    a.append(a[i] + A[i])
for j in range(M):
    b.append(b[j] + B[j])

ans = 0
j = M
for i in range(N+1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j = j -1
    ans = max(ans, i+j)
    
print(ans)
# Read the values of A and B from the screen, save them as integers
a = int(input())
b = int(input())

# Use a for-loop to check if there is integer C, A <= C <= B
# such that A*B*C is odd
got_an_odd = False
for c in range(a, b+1):
    if a*b*c % 2 == 1:
        got_an_odd = True

# Print the answer on the screen
if got_an_odd:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

# Read the values of A and B from the screen, save them as integers
a, b = [int(i) for i in input().split()]

# Note that all we have to do is check if both A and B are odd.
if a*b % 2 == 1:
    print("Yes")
else:
    print("No")
str1=input()
str2=input()
str3=input()

if str1[-1:]==str2[:1] and str2[-1:]==str3[:1]:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

str1,str2,str3=input().split()
if str1[-1:]==str2[:1] and str2[-1:]==str3[:1]:
    print("YES")
else:
    print("NO")
s = input()
while len(s) <= 4:
  s.replace("eraser", "")
  s.replace("erase", "")
  s.replace("dreamer", "")
  s.replace("dream", "")
  if len(s) == 0:
    print('YES')
    return
print('NO')

### FIXED CODE ###

s=input().replace("eraser","").replace("erase","").replace("dreamer","").replace("dream","")
if s:
    print("NO")
else:
    print("YES")
a, b, c=map(int, input().split(','))
print(a, b, c)

### FIXED CODE ###

a, b, c=map(str, input().split(','))
print(a, b, c)
S = list(map(str, input().split()))
del S[2]
S.insert(2,7)
print(S)

### FIXED CODE ###

S = list(input())
S[3] = "8"
print("".join(S))
r,g,b = map(int,input().split())
num = r*100+g*10+b
if (num%4=0):
    print("YES")
else:
    print("NO")

### FIXED CODE ###

r,g,b = map(int,input().split())
num = r*100+g*10+b
if (num%4==0):
    print("YES")
else:
    print("NO")
s = str(input())
K = int(input())

lis = list(set(list(s)))
lis.sort()

ans_lis = []
for i in range(min(5, len(lis))):
    i = lis[i]
    s2 = s
    while 1:
        idx = s2.find(i)
        if idx==-1:
            break
        ans_lis += [s2[idx:idx+l+1] for l in range(min(5, len(s2)-idx-1))]
        s2 = s2[idx+1:]
ans_lis = list(set(ans_lis))
ans_lis.sort()
print(ans_lis[4])

### FIXED CODE ###

s = str(input())
K = int(input())

lis = list(set(list(s)))
lis.sort()

ans_lis = []
for i in range(min(5, len(lis))):
    i = lis[i]
    s2 = s
    while 1:
        idx = s2.find(i)
        if idx==-1:
            break
        ans_lis += [s2[idx:idx+l+1] for l in range(min(5, len(s2)-idx))]
        s2 = s2[idx+1:]
ans_lis = list(set(ans_lis))
ans_lis.sort()
print(ans_lis[K-1])
N = int(input())
h = list(map(int , input().split()))

def dfs(i,c):
    if i == N:
        return 10000
    if i == N-1:
        return abs(h[i] - c)
    return min(dfs(i+1, h[i])+abs(h[i]-c),dfs(i+2, h[i])+abs(h[i]-c))

print(dfs(0,h[0]))


### FIXED CODE ###

N = int(input())
h = list(map(int , input().split()))
dp = [10**9+1]*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])