Harryxun/stf_run huggingface dataset:
N = int(input())
A = [int(input()) for i in range(N)]
A_sorted = sorted(A)
for i in range(N):
    if A[i] != A_sorted[-1]:
        print(A_sorted[-1])
    else:
        j = len(A_sorted) - 1
        while A[i] == A_sorted[j]:
            j -= 1
        print(A_sorted[j]) 

### FIXED CODE ###

N = int(input())
A = [int(input()) for i in range(N)]
A_sorted = sorted(A)
for i in range(N):
    if A[i] != A_sorted[-1]:
        print(A_sorted[-1])
    else:
        j = len(A_sorted) - 1
        count = 0
        while A[i] == A_sorted[j] and count <= 0:
            j -= 1
            count += 1
        print(A_sorted[j])
N, M = list(map(lambda x:int(x), input().split(' ')))
l = list(map(lambda x:int(x), input().split(' ')))

maxheap = MaxHeap(l)

WARI = 0.5
for _ in range(0, M):
    v = int(maxheap.pop() * WARI)
    maxheap.push(v)

SUM = 0
for _ in range(0, N):
    SUM += maxheap.pop()

print(SUM)

### FIXED CODE ###

d = {'Sunny': 'Cloudy', 'Cloudy':'Rainy', 'Rainy':'Sunny'}
print(d[input()])
s = input()
x, y = map(int, input().split())

XY = [[], []]
b = 0
renzoku = 0
for i in range(len(s)) :
    if s[i] == "T" :
        b = (b+1) % 2
        renzoku = 0
    else :
        if renzoku == 0 :
            XY[b].append(1)
            renzoku = 1
        else :
            XY[b][-1] += 1


#print(XY)

g = 8010

X = [[0 for i in range(g*2)] for j in range(len(XY[0]))]
Y = [[0 for i in range(g*2)] for j in range(len(XY[1]))]



if len(XY[0]) > 0 :
    X[0][g+XY[0][0]] = 1
    if s[0] == "T" :
        X[0][g-XY[0][0]] = 1
        
    for i in range(1, len(XY[0])) :
        for j in range(g*2) :
            #print(X)
            if j - XY[0][i] >= 0 and X[i-1][j - XY[0][i]] == 1 :
                X[i][j] = 1
            if j + XY[0][i] <= g*2-1 and X[i-1][j + XY[0][i]] == 1 :
                X[i][j] = 1

if len(XY[1]) > 0 :

    Y[0][g+XY[1][0]] = 1
    Y[0][g-XY[1][0]] = 1
        
    for i in range(1, len(XY[1])) :
        for j in range(20000) :
            if j - XY[1][i] >= 0 and Y[i-1][j - XY[1][i]] == 1 :
                Y[i][j] = 1
            if j + XY[1][i] <= g*2-1 and Y[i-1][j + XY[1][i]] == 1 :
                Y[i][j] = 1

if X == [] :
    X = [[0 for i in range(g*2)]]
if Y == [] :
    Y = [[0 for i in range(g*2)]]

if ((len(XY[0]) == 0 and x == 0) or X[-1][g+x] == 1) and ((len(XY[1]) == 0 and y == 0) or Y[-1][g+y] == 1) :
    print("Yes")
else :
    print("No")


### FIXED CODE ###

s = input()
x, y = map(int, input().split())
n = len(s)

D = [[], []]
st_x = 0
st_y = 0
st = 0
while st <= len(s)-1 and s[st] == "F":
    x -= 1
    st += 1

di = 0
for i in range(st, n):
    if s[i] == "T":
        di = (di+1) % 2
        D[di].append(0)
    else:
        D[di][-1] += 1

# print(D)


ANS = [0, 0]
st_po = [0, 0]
go_po = [x, y]
for i in range(2):
    mid = sum(D[i]) + 5
    DP = [[0] * (mid*2) for i in range(len(D[i]) + 1)]
    DP[0][st_po[i] + mid] = 1
    for j in range(len(D[i])):
        dd = D[i][j]
        for k in range(len(DP[0])):
            aa = 0
            bb = 0
            if 0 <= k-dd <= len(DP[0])-1:
                aa = DP[j][k-dd]
            if 0 <= k+dd <= len(DP[0])-1:
                bb = DP[j][k+dd]

            DP[j+1][k] = int(aa or bb)

    if 0 <= go_po[i]+mid <= len(DP[0])-1:
        ANS[i] = DP[-1][go_po[i]+mid]
    # print("len",mid*2)
    #if i == 1:
        # print(DP[1][7999+mid])
# print(ANS)

print("Yes" if ANS[0] and ANS[1] else "No")
N, K = map(int, input().split())

#お菓子を持っていない : 1
#お菓子を持っている   : 0
#持っていない人を最終的に導くから
S = [1] * N 

for i in range(K):
    d = int(input())
    t = map(int, input().split())
    for i in range(t):
        #i-1なのは添字と要素tが1ぶんずれているから
        S[i-1] = 1
print(sum(S))

### FIXED CODE ###

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

#お菓子を持っていない : 1
#お菓子を持っている   : 0
#持っていない人を最終的に導くから
S = [1] * N 

for i in range(K):
    d = int(input())
    t = map(int, input().split())
    for i in t:
        #i-1なのは添字と要素tが1ぶんずれているから
        S[i-1] = 0
print(sum(S))
import string


def make_string(string, flag_matched=False, N=5000):
    if string[-1] == 'z':
        string = string[:-1]
        flag_matched = False
    if flag_matched == False or len(string) == N:
        string = string[:-1] + chr(ord(string[-1] )+1)
    else:
        string += 'a'
    return(string)


S = input()
k = int(input())

N = len(S)

c = 0
q = 'a'

while True:
    if q in S:
        c += 1
        if c == k:
            break
        else:
            q  = make_string(q, True, N)
    else:
        q  = make_string(q, False, N)

print(q)


### FIXED CODE ###

import string


def make_string(string, flag_matched=False, N=5000):
    if string[-1] == 'z':
        string = string[:-1]
        flag_matched = False
    if flag_matched == False or len(string) == N:
        string = string[:-1] + chr(ord(string[-1] )+1)
    else:
        string += 'a'
    return(string)


S = input()
k = int(input())

N = len(S)
if N <= 50:

    A = []

    for i in range(N):
        for j in range(1, N+1-i):
            A.append(S[i:i+j])

    A = list(set(A))
    A.sort()

    print(A[k-1])

else:

    c = 0
    q = 'a'

    while True:
        if q in S:
            c += 1
            if c == k:
                break
            else:
                q  = make_string(q, True, N)
        else:
            q  = make_string(q, False, N)

    print(q)
import numpy as np
N = int(input())
a_s = input().split()
for i in range(N):
    a_s[i] = int(a_s[i])
a_s = np.array(a_s)

a_unique = np.unique(a_s)

ans = 0
i = 1
for a in a_unique[1:-1]:
    val = np.sum(a_s==a)
    if (a_unique[i-1]+1==a):
        val += np.sum(a_s==a_unique[i-1])
            
    if (a_unique[i+1]-1==a):
        val += np.sum(a_s==a_unique[i+1])
    
    if val > ans:
        ans = val
    
    i += 1

#i=0
val = np.sum(a_s==a_unique[0])
val += np.sum(a_s==a_unique[1])
if val > ans:
    ans = val   

#i=len(a_unique)-1
val = np.sum(a_s==a_unique[-1])
val += np.sum(a_s==a_unique[-2])
if val > ans:
    ans = val   

#     if ans >= sum(a_counts[i:]):
#         break
        
print(ans)

### FIXED CODE ###

from collections import Counter

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

c = Counter(a_s)
c = sorted(c.items(), key=lambda x:x[0])
a_unique, a_counts = zip(*c)

ans = 0
for i,a in enumerate(a_unique):
    val = a_counts[i]
    if (i>0):
        if (a_unique[i-1]+1==a):
            val += a_counts[i-1]
            
    if (i<len(a_unique)-1):
        if (a_unique[i+1]-1==a):
            val += a_counts[i+1]
    
    if val > ans:
        ans = val
        
print(ans)
n = int(input())
ab = [list(map(int, input().split())) for i in range(n-1)]
ab2 = [[] for i in range(n)]
for i in range(n-1):
  ab2[ab[i][0]-1].append([ab[i][1]-1, i])
  ab2[ab[i][1]-1].append([ab[i][0]-1, i])
coloring = [0]*(n-1)
uc = [set() for i in range(n)]

def f(x, y):
  for i in ab2[x]:
    if i[0] != y:
      c = 1
      while c in uc[x]:
        c += 1
      coloring[i[1]] = c
      uc[x].add(c)
      uc[i[0]].add(c)
      x1 = i[0]
      y1 = x
      f(x1, y1)

f(0, 0)
print(max(coloring))
for i in range(n-1):
  print(coloring[i])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

n = int(input())
ab = [list(map(int, input().split())) for i in range(n-1)]
ab2 = [[] for i in range(n)]
for i in range(n-1):
  ab2[ab[i][0]-1].append([ab[i][1]-1, i])
  ab2[ab[i][1]-1].append([ab[i][0]-1, i])
coloring = [0]*(n-1)

def f(x, y, z):
  c = 0
  for i in ab2[x]:
    if i[0] != y:
      c += 1
      if c == z:
        c += 1
      coloring[i[1]] = c
      x1 = i[0]
      y1 = x
      z1 = c
      f(x1, y1, z1)

f(0, None, None)
print(max(coloring))
for i in range(n-1):
  print(coloring[i])
N,x=map(int,input().split())
l=list(map(int,input().split()))
ans=0
l.sort()

for n in range(N):
    if n!=N-1:
        if l[n]<x:
            x-=l[n]
            ans+=1
        elif l[n]==x:
            x-=l[n]
            ans+=1
            break
        else:
            break
    else:
        if l[n]==x:
            x-=l[n]
            ans+=1
        else:
            break

print(ans)

### FIXED CODE ###

N=int(input())
n=list(map(int,str(N)))
for i in range(3):
    if n[i]==1:
        n[i]=9
    elif n[i]==9:
        n[i]=1
print(n[0]*100+n[1]*10+n[2])
s=str(input())
a=list("zyxwvutsrqponmlkjihgfedcba")
a=a[::-1]
#print(a)


if "zyxwvutsrqponmlkjihgfedcba"==s:
    print(-1)


if len(s)==26:
    s=s[::-1]#後ろから見ていく
    for i in range(len(s)):
        for j in range(i+1):
           # print(i,j,s[i+1],s[j+1])
            if s[i+1]<s[j+1]:#xyzの降順の流れが切れたところを変える
                s=s[::-1]
                print(s[:-(i+1)]+s[-(j+1)])
                exit()
else:
    for i in a:
        if i not in s:
            s+=i
            break
    print(s)




### FIXED CODE ###

s=str(input())
a=list("zyxwvutsrqponmlkjihgfedcba")
a=a[::-1]
#print(a)


if "zyxwvutsrqponmlkjihgfedcba"==s:
    print(-1)
    exit()


if len(s)==26:
    s=s[::-1]#後ろから見ていく
    for i in range(len(s)):
        for j in range(i+1):
            #print(i,j,s[i],s[j])
            if s[i]<s[j]:#xyzの降順の流れが切れたところを変える
                s=s[::-1]
               # print(s)
                print(s[:-(i+1)]+s[-(j+1)])
                exit()
else:
    for i in a:
        if i not in s:
            s+=i
            break
    print(s)
N = int(input())
A = sorted(map(int,input().split()))[::-1]
B = A[:(N+1)//2]
i = (N+1)//2
if B[-1]<=0:
    for i in range(1,N+1//2):
        if B[i]<=0:
            B = B[:i]
            break
C = A[i:2*i][::-1]
D = A[2*i:]
ans = []
if (len(B)+len(C))%2:
    M = B.pop()
else:
    M = C.pop()
while B:
    if len(B)>len(C):
        p = B.pop()
    else:
        p = C.pop()
    ans.append((p,M))
    M = p - M
for d in D:
    ans.append((M,d))
    M = M - d
print(M)
for o in ans:
    print(*o)

### FIXED CODE ###

N = int(input())
*A, = map(int,input().split())

A.sort()

for i,a in enumerate(A):
    if a>=0:break
B = A[:i]
C = A[i:]

ans = []
if not B:
    x = C[0]
    for a in C[1:-1]:
        ans.append((x,a))
        x -= a
    ans.append((C[-1],x))
    x = C[-1] - x
elif not C:
    x = B[-1]
    for a in B[:-1]:
        ans.append((x,a))
        x -= a
else:
    x = B[0]
    for a in C[1:]:
        ans.append((x,a))
        x -= a
    ans.append((C[0],x))
    x = C[0]-x
    for a in B[1:]:
        ans.append((x,a))
        x -= a

print(x)
for out in ans:
    print(*out)
asn=int(0)
for i in range(int(input())):
    if i%3!=0 and i%5!=0:
        ans+=i
print(ans)

### FIXED CODE ###

ans=int(0)
for i in range(int(input())+1):
    if i%3!=0 and i%5!=0:
        ans+=i
print(ans)
N=int(input())
array=list(map(int,input().split()))
array1=sorted(array)
import itertools
list1=list(itertools.combinations(array1,3))
ans=0
for n in range(len(list1)):
  if list[n][0]!=list[n][1] and list[n][1]!=list[n][2]:
    if list[n][0]+list[n][1]>list[n][2]:
      ans=ans+1
print(ans)

### FIXED CODE ###

import itertools
n = int(input())
data = list(map(int, input().split()))
data1=sorted(data)
a = list(itertools.combinations(data1,3))
ans=0
for m in range(len(a)):
  if a[m][0]!=a[m][1] and a[m][1]!=a[m][2]:
    if a[m][0]+a[m][1]>a[m][2]:
      ans=ans+1
print(ans)
a = int(input())
b = int(input())
c = int(input())
l = []

for i in range(a,b+1):
  if i%c==0:
    l.append(i)

print(len(l))

### FIXED CODE ###

L,R,d=map(int,input().split())
a=0
for i in range(L,R+1):
  if i%d==0:
    a+=1
print(a)
a, b = [int(i) for i in input().split]
print(a * b, (a + b) * 2)

### FIXED CODE ###

a, b = [int(i) for i in input().split()]
print(a * b, (a + b) * 2)
import sys

def load(vtype=int):
    return vtype(input().strip())


def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]

A, B, M = tuple(load_list())

a = load_list()
b = load_list()

coupon = dict()
for _ in range(0, M):
    x, y, c = tuple(load_list())
    if (x-1, y-1) in coupon:
        coupon[(x-1,y-1)] = max(coupon[(x-1,y-1)], c)
    else:        
        coupon[(x-1,y-1)] = c 

minv = min(a) + min(b)

for i, j in coupon.keys():
    minv = min(minv, a[i] + b[i] - coupon[(i, j)])

print(minv)




### FIXED CODE ###

import sys

def load(vtype=int):
    return vtype(input().strip())


def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]

A, B, M = tuple(load_list())

a = load_list()
b = load_list()

coupon = dict()
for _ in range(0, M):
    x, y, c = tuple(load_list())
    if (x-1, y-1) in coupon:
        coupon[(x-1,y-1)] = max(coupon[(x-1,y-1)], c)
    else:        
        coupon[(x-1,y-1)] = c 

minv = min(a) + min(b)

for key in coupon.keys():
    i, j = key
    minv = min(minv, a[i] + b[j] - coupon[(i, j)])

print(minv)
import math


n = int(input())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

def main(divisors, o):
    for i in range(o):
        a = divisors[o]
        b = divisors[-o]
        if a < 9 and b < 9:
            return 'Yes'
    return 'No'


divs = make_divisors(n)
if len(divs) % 2 == 0:
    o = len(divs) / 2
else:
    o = int(math.ceil(len(divs) / 2))

print(main(divs, o))


### FIXED CODE ###

import math

n = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

def main(divisors, o):
    for i in range(o):
        a = divisors[i]
        b = divisors[::-1][i]
        
        if a <= 9 and b <= 9:
            return 'Yes'
    return 'No'


divs = make_divisors(n)

o = int(len(divs)/2 + len(divs) % 2)

print(main(divs, o))
a, b = map(int, input().split())
if (a*b%2==0):
  ans = "Even"
else:
  ans = "Odd"
printf(ans)

### FIXED CODE ###

a, b = map(int, input().split())
ans = "Odd"
if(a*b%2==0):
	ans = "Even"
print(ans)
N = int(input())
H = list(map(int, input().split()))
list = []
for i in range(N - 1):
    if H[i] < H[i + 1]:
        list.append('A')
    else:
        list.append('B')
W = ''.join(list)
Wlist = W.split('A')
anslist =[]
for i in range(len(Wlist)):
    anslist.append(len(Wlist[i]))
print(max(anslist))

### FIXED CODE ###

S = list(input())
T = list(input())
count = 0
for i in range(len(S)):
    if S[i] == T[i]:
        count += 1
print(count)
import math


def calc_minkowski_distance(data_x, data_y, types):
    # ???????´???????????¨???????map???????????¬??????????????????????????¨????????¨????????§?¶???????????????????????????§????????????????????????
    distance = list(map(lambda x, y:abs(x - y), data_x, data_y))

    results = []
    for t in types:
        if t == math.inf:
            results.append(max(distance))
        else:
            temp = map(lambda x:math.pow(x, t), distance)
            total = sum(temp)
            results.append(math.pow(total, 1.0/t))
    return results


if __name__ == '__main__':
    # ??????????????\???
    # data_x = [1, 2, 3]
    # data_y = [2, 0, 4]
    num = int(input())
    data_x = [int(x) for x in input().split(' ')]
    data_y = [int(x) for x in input().split(' ')]

    # ???????????????
    types = [1, 2, 3, math.inf]
    results = calc_minkowski_distance(data_x, data_y, types)

    # ???????????¨???
    for r in results:
        print('{0:.8f}'.format(r))

### FIXED CODE ###

import math


def calc_minkowski_distance(data_x, data_y, types):
    # ???????´???????????¨???????map???????????¬??????????????????????????¨????????¨????????§?¶???????????????????????????§????????????????????????
    distance = list(map(lambda x, y:abs(x - y), data_x, data_y))

    results = []
    for t in types:
        if t == 'Inf':
            results.append(max(distance))
        else:
            temp = map(lambda x:math.pow(x, t), distance)
            total = sum(temp)
            results.append(math.pow(total, 1.0/t))
    return results


if __name__ == '__main__':
    # ??????????????\???
    # data_x = [1, 2, 3]
    # data_y = [2, 0, 4]
    num = int(input())
    data_x = [int(x) for x in input().split(' ')]
    data_y = [int(x) for x in input().split(' ')]

    # ???????????????
    types = [1, 2, 3, 'Inf']  # math.inf???python3.5??\?????????
    results = calc_minkowski_distance(data_x, data_y, types)

    # ???????????¨???
    for r in results:
        print('{0:.8f}'.format(r))
X = int(input())

while True:
    
    flag = 0
    
    for i in range(2, X+1): #2からXまでのループ
        if (X+1) % i == 0: #対象はX+1という数
            flag = 1
            break
    if flag == 1:
        X += 1
        continue
    break
    
print(X + 1)
 

### FIXED CODE ###

S, T = input().split()
print(T + S)
# encoding: utf-8
import math
N, M = map(int, input().split())

def distribute(pos, full, tmp):
    return memo[tmp][pos]

# define search range
p_max = int(M / 2) # M is prime if M has a factor p (> p_max)
ip_up = int(math.log2(p_max))

#### O(MlogM) below (if M has a very large prime factor)
M_tmp = M
ips = []
for p in filter(lambda x: M % x == 0, range(2, p_max + 1)):
    # how many times M_tmp can be divided
    p_tmp = p
    for i_p in range(ip_up + 1):
        if M_tmp % p_tmp > 0: break
        p_tmp = p_tmp * p
    # escape if M_tmp cannot be divided
    if i_p < 1: continue
    # calculate later
    ips.append(i_p)
    # next
    M_tmp = M_tmp // (p_tmp // p)
    if M_tmp == 1: break
#### O(Mlog M) above

#### O(N) below
# create memo
## init
if len(ips) > 0: ip_max = max(ips)
else: ip_max = 0
memo = [[None] * N for i in range(ip_max + 1)] # max ip
for j in range(N): memo[0][j] = 1
for i in range(1, ip_max + 1): memo[i][N - 1] = 1
## fill
for i in range(1, ip_max + 1):
    sum_tmp = 0
    vals = list(memo[i - 1])[::-1]
    p_memo = memo[i]
    for j, val in enumerate(vals):
        sum_tmp += val
        p_memo[N - 1 - j] = sum_tmp
#### O(N) above
        
# calculate ans
ans = 1
for i_p in ips: ans = (ans * distribute(0, i_p, i_p)) % (10 ** 9 + 7)
    
print(ans)

### FIXED CODE ###

# encoding: utf-8
import math
N, M = map(int, input().split())

ips = []
M_tmp = M
for p in range(2, int(math.sqrt(M)) + 1):
    if M_tmp % p > 0: continue
    for i_p in range(1, 33):
        if M_tmp % (p ** (i_p + 1)) > 0: break
    ips.append(i_p)
    M_tmp = M_tmp // (p ** i_p)
    if M_tmp == 1: break
else:
    ips.append(1)

#### O(NlogM) below ?
# create memo
## init
if len(ips) > 0: ip_max = max(ips)
else: ip_max = 0
memo = [[None] * N for i in range(ip_max + 1)] # max ip
for j in range(N): memo[0][j] = 1
for i in range(1, ip_max + 1): memo[i][N - 1] = 1
## fill
for i in range(1, ip_max + 1):
    sum_tmp = 0
    vals = list(memo[i - 1])[::-1]
    ptr_memo = memo[i]
    for j, val in enumerate(vals):
        sum_tmp += val
        ptr_memo[N - 1 - j] = sum_tmp
#### O(NlogM) above ?
        
# calculate ans
ans = 1
for i_p in ips:
    ans = (ans * memo[i_p][0]) % (10 ** 9 + 7)

if M == 1: print(1)
elif ip_max < 1: print(N)
else: print(ans)
n = int(input())
for i in range(1, n):
    if n < i ** 2:
        break
print((i - 1) ** 2)

### FIXED CODE ###

n = int(input())
i = 1
while n >= i * i:
    i += 1
print((i - 1) * (i - 1))
import sys
import numpy as np
n = int(input())
A = np.arrange(N+1)
count=0

for i in range(N+1):
  if A[i]%3 !=0 and A[i]%5 != 0 and A[i]%15 != 0:
	count = count + A[i]
print(count)

### FIXED CODE ###

import sys
import numpy as np

N=int(input())
A=np.arange(N+1)
count = 0

for i in range(N+1):
    if A[i]%3 != 0 and A[i]%5 != 0 and A[i]%15 != 0:
        count = count + A[i]
print(count)
n=int(input())
s,t=map(int,input(),split())
word=""
for i in range(n):
  word+=s[i]+t[i]

print(word)

### FIXED CODE ###

n=int(input())
s,t=input().split()

word=""
for i in range(n):
    word+=(s[i]+t[i])
print(word)
n = input('');
k = input('');

int32(1);
for 1:n
  min(int32(2)*ans, ans+K);
end

fprintf("%d\n", ans);

### FIXED CODE ###

r = int(input())
g = int(input())
print( g*2 - r )
import sys
import numpy as np
input = sys.stdin.readline

N, W = map(int, input().split())
dp = np.zeros((N, W+1), dtype='int64')

def solve(N, W):
    for i in range(0, N):
        wi, vi = map(int, input().split())
        dp[i][:wi] = dp[i-1][:wi]
        dp[i][wi:] = np.fmax(dp[i-1][wi:],
                            dp[i-1][:W+1-wi] + vi)
    return dp[N-1][W]

print(solve(N, W))

### FIXED CODE ###

import sys
input = sys.stdin.readline
N, W = map(int, input().split())
vmax = 1000*100+1
wmax = 100*10**9
dp = [wmax] * vmax
dp[0] = 0
 
for i in range(N):
    wi, vi = map(int, input().split())
    ndp = dp[:]
    for j in range(vi, vmax):
        ndp[j] = min(dp[j], dp[j-vi] + wi)
    dp = ndp

v = 0
for i, w in enumerate(dp):    
    if w == wmax:
        continue
    if w <= W:
        v = i
print(v)
X = int(input())

def Sum_Digit(X):
  SUM = 0
  while X >= 1:
    SUM += X%10
    X = int((X - X%10)/10)
  return SUM

print(S)
if X%S == 0:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

X = int(input())

def Sum_Digit(X):
  SUM = 0
  while X >= 1:
    SUM += X%10
    X = int((X - X%10)/10)
  return SUM

S = Sum_Digit(X)
if X%S == 0:
  print("Yes")
else:
  print("No")
n=int(input())
l=list(map(int,input().split()))
for i in range(n):
  if l[n]*2 <=sum(l):
    print("No")
    exit()
print("Yes")

### FIXED CODE ###

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

if max(l)*2 >=sum(l):
  print("No")
  exit()
print("Yes")
a,b = map(raw_input().split())
print max(0,a-2*b)

### FIXED CODE ###

a,b = map(int ,raw_input().split())
print max(0,a-2*b)
N,M = map(int,input().split())
import numpy as np
A = sorted(np.array(list(map(int,input().split()))),reverse=True)
ans = 0
while M>0:
  a = A.pop(0)
  ans += a*2
  M-=1
  if (M>0)and(a>=A[0]*2):
    for i in A:
      ans+=(i+a)*2
      M-=2
      if M==0:
        break
      elif M<0:
        ans-=(i+a)
        break
        
  elif (M>0)and(a<A[0]*2):
    b=A[0]*2-a
    for i in A:
      if i>=b:
        ans+=(i+a)*2
        M-=2
        if M==0:
          break
        elif M<0:
          ans-=(i+a)
          break
      else:
        break
print(ans)

### FIXED CODE ###

N,M = map(int,input().split())
A = sorted(list(map(int,input().split())),reverse=True)
bi = [0]*(A[0]+1)
for a in A:
  bi[a]+=1
  
cum = [0]*(A[0]+1)
for i in range(1,A[0]+1):
  cum[i]=cum[i-1]+bi[i]

cum_max=cum[-1]
left = 0
right = A[0]*2+1
while right-1!=left:
  x = (right+left)//2
  num = 0
  for a in A:
    b = max(x-a,1)
    if b<=A[0]:
      num += cum_max-cum[b-1]
    
  if num>=M:
    left=x
  else:
    right=x

ans = 0
cum_A = [0]*(N+1)
for i in range(1,N+1):
  cum_A[i]=cum_A[i-1]+A[i-1]
for a in A:
  b = max(right-a,1)
  if b>A[0]:
    break
  c = cum_max-cum[b-1]
  M-=c
  ans+=(a*c)+cum_A[c]
  

ans+=M*left
print(ans)
n, x = (int(i) for i in input().split())
l = [int(i) for i in input().split()]
count = 1
current = 0
while current <= x:
    current += l[count-1]
    count += 1
print(count-1)

### FIXED CODE ###

n, x = (int(i) for i in input().split())
l = [int(i) for i in input().split()]
count = 1
current = 0

if sum(l) <= x:
    print(n+1)
else:
    while current <= x:
        current += l[count-1]
        count += 1
    print(count-1)
a=1<<1000000000
b = 1<<a
print(b)

### FIXED CODE ###

if len(set([int(i) for i in input().split()])) == 2:
    print("Yes")
else:
    print("No")
n = int(input())
a = sorted(list(map(int, input().split())))
m = a.pop()

def binary_search(l, value):
    low = 0
    high = len(l)-1
    while low <= high:
        mid = (low + high)//2
        if l[mid] == value:
            print(m, l[mid])
            exit()
        elif l[mid] < value:
            low = mid + 1
        else:
            high = mid - 1
    return low

k = binary_search(a, m//2)
print(m, a[k])


### FIXED CODE ###

from bisect import bisect_left
n = int(input())
a = sorted(list(map(int, input().split())))
if n == 2:
    print(a[1], a[0])
    exit()
m = a.pop()
idx = bisect_left(a, m//2)
if idx == 0:
    print(m, a[0])
    exit()
else: 
    r1 = a[idx-1]
    r2 = a[idx]

    if r1 > m-r2:
        r = r1
    else:
        r = r2

print(m, r)
import math
x1,y1,x2,y2 = map(int,input().split(" "))
yoko = x2 - x1
tate = y2 - y1
print(math.sqrt(yoko**2+tate**2))

### FIXED CODE ###

import math
x1,y1,x2,y2 = map(float,input().split(" "))
yoko = x2 - x1
tate = y2 - y1
print(math.sqrt(yoko**2+tate**2))