Harryxun/stf_run huggingface dataset:
#!/usr/bin/env python
import sys

def _ia(): return [ int(x) for x in sys.stdin.readline().strip().split() ]

n,t = _ia()
ab = []
asum = 1
imax = -1
amax = -1
bmax = -1
for i in range(n):
    _a,_b = _ia()
    ab.append((_a,_b))
    asum += _a
    if bmax<0 or (_b>=bmax and _a>ab[i-1][0]):
        imax = i
        amax = _a
        bmax = _b
#
del(ab[imax])
asum -= amax
dp = [ 0 ] * (asum)
for a, b in ab:
    prev = dp.copy()
    for atot in range(asum):
        if atot>=a: dp[atot] = max(prev[atot],prev[atot-a]+b)
        else: dp[atot] = prev[atot]
#
if t>asum: print(dp[-1]+bmax)
else: print(max(dp[t-1]+bmax,dp[t]))


### FIXED CODE ###

#!/usr/bin/env python
import sys
from operator import itemgetter

def _ia(): return [ int(x) for x in sys.stdin.readline().strip().split() ]

n,t = _ia()
ab = []
for i in range(n): ab.append(_ia())
ab.sort(key=itemgetter(0))
#
bmax= ab[0][0]
dp = [ [0]*(t) for _ in range(n) ]
for i in range(n-1):
    a,b = ab[i]
    
    prev = dp[i]
    dnew = dp[i+1]
    for atot in range(t):
        if atot>=a: dnew[atot] = max(prev[atot],prev[atot-a]+b)
        else: dnew[atot] = prev[atot]
    #
    bmax = max(bmax,prev[-1]+b)
#
print(max(bmax,dp[-1][-1]+ab[-1][1]))
while True:
        H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    print("#" * W)
    for i in range(H-2):
        print("#"+"."*(W-2)+"#")
    print("#" * W)
    print()


### FIXED CODE ###

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

### FIXED CODE ###

print(int(input())**3)
N, Q = map(int, input().split())
tree = [[] for i in range(200001)]
scores = [0 for i in range(200001)]

def dfs(pre, p):
    for child in tree[p]:
        if child == pre: continue
        scores[child] += scores[p]
        dfs(p, child)

def main():
    for _ in range(N-1):
        a, b = map(int, input().split())
        tree[a].append(b)
        tree[b].append(a)

    for _ in range(Q):
        p, x = map(int, input().split())
        scores[p] += x
    dfs(0, 1)
    print(' '.join(map(str, scores[1:N+1])))

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
from heapq import *
sys.setrecursionlimit(10**8)

input = sys.stdin.readline

tree = [[] for _ in range(200001)]
res = [0]*200001

def dfs(p, pre):
    for child in tree[p]:
        if child == pre: continue
        res[child] += res[p]
        dfs(child, p)

def main():
    """ main """
    N, Q = map(int, input().split())
    for _ in range(N-1):
        a,b = map(int, input().split())
        tree[a].append(b)
        tree[b].append(a)
    for _ in range(Q):
        p,x = map(int, input().split())
        res[p] += x
    dfs(1, 0)

    print(*res[1:N+1])

if __name__ == '__main__':
    main()
n = int(input())
A = list(map(int, input().split()))
import numpy as np
A = np.array(A)
for i in range(N):
    b = np.where(A==i+1)
    print(b[0][0]+1)

### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
B = [0]*n
for i in range(n):
  B[A[i]-1] = i + 1 
for i in range(n):
  print(B[i])
N, M = map(int, input().split())
P = [0] * M
Y = [0] * M
check = [[] for i in range(N)]

for i in range(M):
    P[i], Y[i] = map(int, input().split())
    check[P[i]-1].append(Y[i])

for i in range(N):
    check[i].sort()

for i in range(M):
    tmp1 = ('00000' + str(P[i]))[-6:] 
    tmp2 = ('00000' + str(check[P[i]-1].index(Y[i])+1))[-6:]
    tmp = tmp1 + tmp2
    print(tmp)




### FIXED CODE ###

a, b = map(int,input().split())
print(round(a+b//2))
from math import factorial
def cmb(m,r):
  return factorial(m)//(factorial(r)*factorial(m-r))
n=int(input())
s=[input() for i in range(n)]
s.sort()
cnt=0
ans=0
for i in range(1,n):
  if s[i]==s[i-1]:
    cnt+=1
  else:
    ans+=cmb(cnt+1,2)
    cnt=0
print(ans)


### FIXED CODE ###

from math import factorial
def comb(n,k):
  if n<0 or k<0 or n<k:return 0
  if n==0 and k==0:return 1
  a=factorial(n)
  b=factorial(k)
  c=factorial(n-k)
  return a//(b*c)
n=int(input())
s=[sorted(list(input())) for i in range(n)]
s.sort()
cnt=1
ans=0
for i in range(1,n):
  if s[i]==s[i-1]:
    cnt+=1
  else:
    ans+=comb(cnt,2)
    cnt=1
if cnt>=2:
  ans+=comb(cnt,2)
print(ans)
x = input().split()
n = int(x[0])
k = int(x[1])
 
h = input().split()
 
h = sorted(h)
 
if n-k <= 0:
    print(0)
    exit()
 
c = 0
for i in range(n-k):
    c += int(h[i])
print(c)
    


### FIXED CODE ###

x = input().split()
h = int(x[0])
a = int(x[1])
if h%a == 0:
    print(h//a)
else:
    print(h//a+1)
N = int(input())
sX = input()

origin_count = sX.count('1')
one_r_count = origin_count -1
zero_r_count = origin_count +1

one_mod = 0
zero_mod =0
for i in range(N):
    if(one_r_count != '0'):
        one_mod = (one_mod * 2) + int(sX[i]) % one_r_count
    zero_mod = (zero_mod * 2 ) + int(sX[i]) % zero_r_count

### FIXED CODE ###

N = int(input())
sX = input()

origin_count = sX.count('1')
one_r_count = origin_count -1
zero_r_count = origin_count +1

one_mod = 0
zero_mod =0
for b in sX:
    if one_r_count != 0:
        one_mod = (one_mod * 2 + int(b) )% one_r_count
    zero_mod = (zero_mod * 2  + int(b) )% zero_r_count

f = [0] * 220000
pop = [0]* 220000

for i in range(1,220000):
    pop[i] = pop[i//2] + i % 2
    f[i] = f[i % pop[i]] + 1

onepow = [1] * 220000
zeropow = [1]* 220000

for i in range(1,220000):
    if one_r_count != 0:
        onepow[i] = onepow[i-1] * 2 % one_r_count
    zeropow[i] = zeropow[i-1] * 2 % zero_r_count

for i in range(1,N+1):
    if sX[i-1] == '1':
        if one_r_count != 0:
            Xi_n = one_mod - onepow[N-i]
            Xi_n %= one_r_count
            print(f[Xi_n]+1)
        else:
            print(0)
    if sX[i-1] == '0':
        Xi_n = zero_mod + zeropow[N-i]
        Xi_n %= zero_r_count
        print(f[Xi_n]+1)
def gu(n,a):
  ans=[0]*n
  for i in range(len(a)):
    ii=a[i]
    while True:
      if ii%2==0:
        ans[i]+=1
      else:
        break
  return ans.min()
n=int(input())
a=list(map(int,input().split()))
print(gu(n,a))

### FIXED CODE ###

def count_1(a):
  c=0
  for i in a:
    if i=="1":
      c+=1
  else:
    return c
a=input()
print(count_1(a))
# C
N = int(input())
abc = [list(map(int, input().split())) for i in range(N)]

da, db, dc = 0, 0, 0

for a, b, c in abc:
    na = max(db, dc) + a
    na = max(da, dc) + a
    na = max(da, db) + a
    
print(max(na, nb, nc))

### FIXED CODE ###

# C
N = int(input())
abc = [list(map(int, input().split())) for i in range(N)]

da, db, dc = 0, 0, 0

for a, b, c in abc:
    na = max(db, dc) + a
    nb = max(da, dc) + b
    nc = max(da, db) + c
    da = na
    db = nb
    dc = nc
    
print(max([na, nb, nc]))
import sys
for n in sys.stdin:
    c=0
    for i in range(1,int(n)+1):
        while i%5==0:
            i/=5
            c+=1
    print c

### FIXED CODE ###

while 1:
    n = input()
    if n==0: break
    c = 0
    while n:
        n /= 5
        c += n
    print c
a,b,x = map(int,input().split())

if a <= x and a + b >= x:
  print('YES')
else:
	print('NO)  

### FIXED CODE ###

a,b,x = map(int,input().split())
 
if a <= x and a + b >= x:
  print('YES')
else:
	print('NO')
N = map(int, input())
s = input()
for char in s:
  if char == 'R':
    cnt += 1
  if cnt > N / 2:
    print('Yes')
 	break
else:
  print('No')

### FIXED CODE ###

N = int(input())
s = input()
cnt = 0
for char in s:
  if char == 'R':
    cnt += 1
  if cnt > N / 2:
    print('Yes')
    break
else:
  print('No')
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))
sys.setrecursionlimit(2000)

N, M = input_nums()

G = {}
for i in range(N):
    G[i] = []

for i in range(M):
    x, y = input_nums()
    x -= 1
    y -= 1
    G[x].append(y)

dp = [-1 for _ in range(N+1)]

def rec(v: int):
    if dp[v] != -1:
        return dp[v]
    res = 0
    for nv in G[v]:
        res = max(res, rec(nv) + 1)
    dp[v] = res
    return res

res = 0
for v in range(N):
    res = max(res, rec(v))
print(res)

### FIXED CODE ###

import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))
sys.setrecursionlimit(10**6)

N, M = input_nums()

G = {}
for i in range(N):
    G[i] = []

for i in range(M):
    x, y = input_nums()
    x -= 1
    y -= 1
    G[x].append(y)

dp = [-1 for _ in range(N+1)]

def rec(v: int):
    if dp[v] != -1:
        return dp[v]
    res = 0
    for nv in G[v]:
        res = max(res, rec(nv) + 1)
    dp[v] = res
    return res

res = 0
for v in range(N):
    res = max(res, rec(v))
print(res)
def binaryinsertion(A,x):
    left=0;right=len(A)-1;centre = len(A)//2
    while(True):
        if(right - left < 2):
            if(x[0]<A[left][0]):A.insert(left,x)
            else :
                if(x[0]<A[right][0]):A.insert(right,x)
                else:A.insert(right+1,x)
            break
        else:
            if(x[0] < A[centre][0]) :
                right = centre - 1
            elif(A[centre][0] < x[0]) :
                left = centre + 1
            else : 
                A.insert(centre,x)
                break
            centre = left + (right-left + 1)//2 + 1

[N,L] = [int(x) for x in input().split()]
A = [[int(x),int(i)] for i,x in enumerate(input().split())]
sweep = A[:L]
sweep = sorted(sweep)
ans = [str(sweep[0][0])]
for i in range(L,N) :
    sweep.remove(A[i-L])
    binaryinsertion(sweep,A[i])
    ans.append(str(sweep[0][0]))
print(" ".join(ans))

### 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])
from math import ceil
import bisect

N, D, A = map(int, input().split())
Monsters = sorted([list(map(int, input().split())) for i in range(N)])
X = [x for x, h in Monsters]
H = [ceil(h / A) for x, h in Monsters]

min_n = 0

for i in range(N):
  if H[i] <= 0:
    continue
  #i_2Di = bisect.bisect_left(X, X[i]+2*D)
  for j in range(i+1,N):
    if X[j] - X[i] > 2*D:
      i_2Di = j
      break
  H[i:i_2Di] -= A * ni
  min_n += ni
  
print(min_n)

### FIXED CODE ###

from math import ceil
from collections import deque
N, D, A = map(int, input().split())
Monsters = sorted([list(map(int, input().split())) for i in range(N)])
Monsters = [[x, ceil(h / A)] for x, h in Monsters]


acc_damage = 0
que = deque([])

ans = 0
for x, h in Monsters:
    # 期限切れの蓄積ダメージを削除
    while que and x > que[0][0]:
        limit, damage = que.popleft()
        acc_damage -= damage

    need = max(0, h - acc_damage)
    ans += need
    acc_damage += need

    if need:
        que.append([x + 2 * D, need])

print(ans)
l = sorted(list(map(int,input().split())))
    print(l[0]+l[1])

### FIXED CODE ###

l = sorted(list(map(int,input().split())))
print(l[0]+l[1])
inp = input().split
A = int(inp[0])
B = int(inp[1])
if(A+B >= 10):
  print('error')
else:
  print(A+B)

### FIXED CODE ###

inp = input().split()
A = int(inp[0])
B = int(inp[1])
if A+B >= 10:
  print('error')
else:
  print(A+B)
X,Y,Z = map(int, input().split())
N=0
while sum<= X:
	um = Y*N+Z*(N+1)
	N+=1  
print(N-2)

### FIXED CODE ###

def ABC_78_B():
    X,Y,Z = map(int, input().split())
    sum=0
    N=0
    while sum<= X:
        sum = Y*N+Z*(N+1)
        N+=1  
    print(N-2)


if __name__ == '__main__':

    ABC_78_B()
while True:
    table = int(input())
    if table[0] == 0:
        break
    print(sum(table))



### FIXED CODE ###

while True:
  x = sum(map(int, input()))

  if x == 0:
    break

  print(x)
a, b = map(int, raw???input() .split())

if a<b :
   print a<b
elif a>b :
   print a>b
elif a == b :
   print a=b

### FIXED CODE ###

a, b = map(int, raw_input().split())
  
if a>b:
  print 'a > b'
elif a<b:
  print 'a < b'
elif a==b:
  print 'a == b'
[a,b,c] = [int(i) for i in input().split()]

if a == b:
  l = 4*a
  r = c
else:
  if a+b < c:
  	l = 4*a*b
  	r = (c -(a+b))**2
  else:
    print("No")
    
if l < r:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

import math
[a,b,c] = [int(i) for i in input().split()]

if a == b:
  l = 4*a
  r = c
else:
  if a+b < c:
  	l = 4*a*b
  	r = (c -(a+b))**2
  else:
    l = 2 * math.sqrt(a*b)
    r = c - (a + b)
    
if l < r:
  print("Yes")
else:
  print("No")
N=input()
A=N%1000
print(A)

### FIXED CODE ###

N=int(input())
A=N%1000
if A == 0:
    print(A)
    exit()
A=1000-A
print(A)
import copy

n = int(input())
inputs = input().split(" ")
l = [int(s) for s in inputs]

def calc(rl, ns, skip):
    v = rl[len(rl)-1]
    # print(rl,v,ns)
    lrl = len(rl)
    
    if lrl == 0:
        return ns
    if lrl == 1:
        v1 = rl[len(rl)-2]
        return ns+abs(v-v1)
    if lrl == 2:
        v1 = rl[len(rl)-2]
        v2 = rl[len(rl)-3]
        ns1 = ns + abs(v-v2)
        ns2 = ns + abs(v-v1) + abs(v1-v2)
        return min(ns1,ns2)
    else:
        v1 = rl[len(rl)-2]
        v2 = rl[len(rl)-3]
        return min(calc(rl[:len(rl)-1],ns+abs(v-v1),True),calc(rl[:len(rl)-2],ns+abs(v-v2),False))

print(calc(l,0,False))


### FIXED CODE ###

N = int(input())
h = list(map(int, input().split()))
 
suml = [1e5 for i in range(N)]
suml[0] = 0
suml[1] = abs(h[1] - h[0])
 
for e in range(2, N):
    suml[e] = min(
        abs(h[e]-h[e-1]) + suml[e-1],
        abs(h[e]-h[e-2]) + suml[e-2],
    )
 
# print(suml)
print(suml[N-1])
import sys
import math
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    N = readint()

    ans = {i: 0 for i in range(1, N + 1)}
    for i in range(3, 101):
        for j in range(1, i):
            for k in range(1, i):
                l = i - j - k
                if l <= 0:
                    break
                else:
                    v = j ** 2 + k ** 2 + l ** 2 + j * k + k * l + j * l
                    ans[v] += 1
    for i in range(1, N + 1):
        print(ans[i])


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
import math
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    N = readint()

    ans = {i: 0 for i in range(1, 20000)}
    for i in range(3, 124):
        for j in range(1, i):
            for k in range(1, i):
                l = i - j - k
                if l <= 0:
                    break
                else:
                    v = j ** 2 + k ** 2 + l ** 2 + j * k + k * l + j * l
                    ans[v] += 1
    for i in range(1, N + 1):
        print(ans[i])


if __name__ == "__main__":
    main()
N,M = map(int,input().split())
A = list(map(int,input().split()))
indA = [0 for _ in range(N*M+1)]
for i in range(N):
    indA[A[i]] = 1
B = list(map(int,input().split()))
indB = [0 for _ in range(N*M+1)]
for j in range(M):
    indB[B[j]] = 1
dp = [0 for _ in range(N*M+1)]
dp[N*M] = 1
for k in range(N*M-1,0,-1):
    if indA[k]==1 and indB[k]==1:
        dp[k] = dp[k+1]
    elif indA[k]==1 and indB[k]==0:
        cnt = 0
        for j in range(M):
            if B[j]>k:
                cnt += 1
        dp[k] = (dp[k+1]*cnt)%p
    elif indA[k]==0 and indB[k]==1:
        cnt = 0
        for i in range(N):
            if A[i]>k:
                cnt += 1
        dp[k] = (dp[k+1]*cnt)%p
    else:
        cnt1 = 0
        for i in range(N):
            if A[i]>k:
                cnt1 += 1
        cnt2 = 0
        for j in range(M):
            if B[j]>k:
                cnt2 += 1
        cnt = cnt1*cnt2-(N*M-k)
        dp[k] = (dp[k+1]*cnt)%p
print(dp[1])

### FIXED CODE ###

from bisect import bisect_right
p = 10**9+7
N,M = map(int,input().split())
A = list(map(int,input().split()))
CA = {}
for i in range(N):
    if A[i] not in CA:
        CA[A[i]] = 0
    CA[A[i]] += 1
indA = [0 for _ in range(N*M+1)]
for i in range(N):
    indA[A[i]] = 1
A1 = sorted(A[:])
B = list(map(int,input().split()))
CB = {}
for j in range(M):
    if B[j] not in CB:
        CB[B[j]] = 0
    CB[B[j]] += 1
indB = [0 for _ in range(N*M+1)]
for j in range(M):
    indB[B[j]] = 1
B1 = sorted(B[:])
flag = 0
if N*M not in CA or CA[N*M]!=1:flag=1
if N*M not in CB or CB[N*M]!=1:flag=1
for a in CA:
    if CA[a]>1:
        flag = 1
        break
for b in CB:
    if CB[b]>1:
        flag = 1
        break
if flag==1:
    print(0)
else:
    dp = [0 for _ in range(N*M+1)]
    dp[N*M] = 1
    for k in range(N*M-1,0,-1):
        if indA[k]==1 and indB[k]==1:
            dp[k] = dp[k+1]
        elif indA[k]==1 and indB[k]==0:
            cnt = bisect_right(B1,k)
            cnt = M-cnt
            dp[k] = (dp[k+1]*cnt)%p
        elif indA[k]==0 and indB[k]==1:
            cnt = bisect_right(A1,k)
            cnt = N-cnt
            dp[k] = (dp[k+1]*cnt)%p
        else:
            cnt1 = bisect_right(A1,k)
            cnt1 = N-cnt1
            cnt2 = bisect_right(B1,k)
            cnt2 = M-cnt2
            cnt = cnt1*cnt2-(N*M-k)
            dp[k] = (dp[k+1]*cnt)%p
    print(dp[1])
import sys
s = input()
a = s[0]
if s.count(a) != 2:
  print("No")
  sys.exit()
s.replace(a)
b = s[0]
if s.count(b) != 2:
  print("No")
  sys.exit()
print("Yes")


### FIXED CODE ###

import sys
s = input()
a = s[0]
if s.count(a) != 2:
  print("No")
  sys.exit()
t = s.replace(a,"")

if t[0] != t[1]:
  print("No")
else:
  print("Yes")
import heapq
n, q = map(int, input().split())
event = []
for _ in range(n):
    s, t, x = map(int, input().split())
    event.append((s-x, 1, x))
    event.append((t-x, -1, x))

event.sort(key=lambda y: y[0])
heap = []
xs = set([])

d = [int(input()) for _ in range(q)]
ans = [-1] * q
index = 0
for t, query, x in event:
    if d[index] < t:
        if not xs:
            pass
        else:
            while heap:
                tmp = heapq.heappop(heap)
                if tmp in xs:
                    heapq.heappush(heap, tmp)
                    ans[index] = tmp
                    break
        index += 1
        if index == q:
            break

    if query == 1:
        xs.add(x)
        heapq.heappush(heap, x)
    else:
        xs.remove(x)

while index < q:
    while heap:
        tmp = heapq.heappop(heap)
        if tmp in xs:
            heapq.heappush(heap, tmp)
            ans[index] = tmp
            break
    index += 1

print("\n".join(map(str, ans)))





### FIXED CODE ###

import heapq
n, q = map(int, input().split())
event = []
for _ in range(n):
    s, t, x = map(int, input().split())
    event.append((s-x, 1, x))
    event.append((t-x, -1, x))

event.sort()
heap = []
xs = set([])

d = [int(input()) for _ in range(q)] + [10**9 + 7]
ans = [-1] * q
index = 0
for t, query, x in event:
    while d[index] < t:
        if not xs:
            pass
        else:
            while heap:
                tmp = heapq.heappop(heap)
                if tmp in xs:
                    heapq.heappush(heap, tmp)
                    ans[index] = tmp
                    break
        index += 1

    if query == 1:
        xs.add(x)
        heapq.heappush(heap, x)
    else:
        xs.remove(x)


while index < q:
    while heap:
        tmp = heapq.heappop(heap)
        if tmp in xs:
            heapq.heappush(heap, tmp)
            ans[index] = tmp
            break
    index += 1

print("\n".join(map(str, ans)))
inp=list(map(len,input().split("T")))
inx,iny=list(map(int,input().split()))
memo={}
def tg(g,n,t):
 if (tuple(g),n,t) in memo:
  return memo[(tuple(g),n,t)]
 if g==[]:
  if n==t:
   return True
  else:
   return False
 if tg(g[1:],n+g[0],t)or tg(g[1:],n-g[0],t):
  memo[(tuple(g),n,t)]=True
  return True
 else:
  memo[(tuple(g),n,t)]=False
  return False

if tg(inp[1::2],0,iny)and tg(inp[2::2],inp[0],inx):
 print("Yes")
else:
 print("No")
 

### FIXED CODE ###

import sys
sys.setrecursionlimit(10000)
inp=list(map(len,input().split("T")))
inx,iny=list(map(int,input().split()))
memo={}
def tg(g,n,t):
 g.sort()
 g.reverse()
 def tn(g,n,t):
  if (tuple(g),n,t) in memo:
   return memo[(tuple(g),n,t)]
  if g==[]:
   if n==t:
    return True
   else:
    return False
  if n<t:
   z=tn(g[1:],n+g[0],t)
   memo[(tuple(g),n,t)]=z
   return z
  else:
   z=tn(g[1:],n-g[0],t)
   memo[(tuple(g),n,t)]=z
   return z
 return tn(g,n,t)
 
if tg(inp[1::2],0,iny)and tg(inp[2::2],inp[0],inx):
 print("Yes")
else:
 print("No")
import math
import numpy as np


def main():
    N = int(input())
    SP = [list(input().split()) + [i + 1] for i in range(N)]
    SP.sort(key=lambda x: (x[0], -int(x[1])))
    SP = np.array(SP)
    for i in SP[:, 2]:
        print(i)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import math


def main():
    N = int(input())
    SP = [list(input().split()) + [i + 1] for i in range(N)]
    SP.sort(key=lambda x: (x[0], -int(x[1])))
    for i in map(lambda x: x[2], SP):
        print(i)


if __name__ == '__main__':
    main()
import math
X, Y = list(map(int, input().split()))
"""
print(math.ceil(math.log(Y/X+1, 2)))
"""
count = 0
while X <= Y:
    X *= 2
    count += 1
print(count)

### FIXED CODE ###

a,b,c,d=map(int, input().split())
x = a+b-c-d
if x == 0:
    print("Balanced")
elif x > 0:
    print("Left")
else:
    print("Right")
def main():
    s = int(input.split());
    if s[1] <= s[2]:
        print("unsafe");
    else:
        print("safe");
main()

### FIXED CODE ###

class Main:

    s1, s2= map(int,input().split());

    if s1 <= s2:
        print("unsafe");
    else:
        print("safe");
S,T = input().strip().split(' ')
A,B = map(int, input().strip().split(' '))
U = input().strip()

if U == A:
  print(A-1,B)
else U == T:
  print(A,B-1)



### FIXED CODE ###

S,T = input().strip().split()
A,B = map(int, input().strip().split())
U = input().strip()

if U == S:
  print(A-1,B)
else:
  print(A,B-1)
n=int(input())
List = [int(i) for i in input().split()]
List2=sorted(List)
import numpy as np
A=np.asarray(List2)
ans = 0

for i in range(1,n-1): #aにたいし
  for j in range(i,n):
    tmp1 = List[i]
    tmp2 = List[j]
    ans += np.count_nonzero(A-tmp1-tmp2>0)
    
print(ans)

### FIXED CODE ###

import bisect
n=int(input())
List = [int(i) for i in input().split()]
List2=sorted(List)
ans = 0

for i in range(0,n-1): #aにたいし
  for j in range(i+1,n):
    #print(i,j)
    tmp1 = List2[i]
    tmp2 = List2[j]
    
    a=bisect.bisect_left(List2,tmp1+tmp2)
    ans += a -j-1
    #print(a,List2,tmp1,tmp2,j,ans)
print(ans)
a, b, k = map(int, input().split())
ls = list(range(a, b + 1))
s = set()

if len(ls) > k:
    for i in range(k):
        s.add(ls[i])
        s.add(ls[len(ls) - (i + 1)])
else:
    print(*ls, sep="\n")
    quit()

print(*s, sep="\n")


### FIXED CODE ###

a, b, k = map(int, input().split())
s = set()
if b - a == 0:
    print(a)
elif b - a + 1 <= k:
    print(*range(a, b + 1), sep="\n")
else:
    for i in range(k):
        s.add(a + i)
        s.add(b - i)
    s = sorted(s)
    print(*s, sep="\n")
A,B,C = map(int,input().split())
K = int(input())

n = 0
while B <= A:
  B * 2
  i += 1
  
while C <= B:
  C * 2
  i += 1

print('Yes' if i <= K else 'No)

### FIXED CODE ###

A,B,C = map(int,input().split())
K = int(input())

i = 0
while B <= A:
  B *= 2
  i += 1
  
while C <= B:
  C *= 2
  i += 1

print('Yes' if i <= K else 'No')
s = input().replace('AtCoder ').replace(' Contest')
print('A' + s[0] + 'C')

### FIXED CODE ###

s = input().replace('AtCoder ','').replace(' Contest','')
print('A' + s[0] + 'C')
from itertools import combinations

N=int(input())
d=list(map(int,input()))

c=combinations(d,2)
print(d)

### FIXED CODE ###

from itertools import combinations

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

c=list(combinations(d,2))

ans=0

for i in range(len(c)):
    a=c[i][0]*c[i][1]
    ans+=a

print(ans)