Harryxun/stf_run huggingface dataset:
from copy import deepcopy
n = int(input())
v = list(map(int,input().split()))

odd = []
even = []

if len(set(v)) == 1:
    print(n//2)
    exit()

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

box_e = [0]*int(1e5+1)
box_o = [0]*int(1e5+1)
e = {}
o = {}
for i in range(n//2):
    if even[i] in e:
        e[even[i]] += 1
    else:
        e[even[i]] = 1
    if odd[i] in o:
        o[odd[i]] += 1
    else:
        o[odd[i]] = 1
values_e = list(e.values())
keys_e = list(e.keys())
values_o = list(o.values())
keys_o = list(o.keys())
Oddlist = []
Evenlist = []
for i in range(len(keys_e)):
    Evenlist.append([values_e[i],keys_e[i]])
for j in range(len(keys_o)):
    Oddlist.append([values_o[i],keys_o[i]])
Evenlist.sort()
Oddlist.sort()
mode_even = Evenlist[-1]
mode_even_2 = 0
if len(keys_e) >= 2:
    mode_even_2 = Evenlist[-2]
mode_odd = Oddlist[-1]
mode_odd_2 = 0
if len(keys_o) >= 2:
    mode_even_2 = Oddlist[-2]

ans = 0

if mode_even[1] != mode_odd[1]:
    ##print("hoge")
    for i in range(n//2):
        if odd[i] != mode_odd[1]:
            ans += 1
        if even[i] != mode_even[1]:
            ans += 1
else:
    if mode_even[0] > mode_odd[0]:
        for i in range(n//2):
            if odd[i] != mode_odd[1]:
                ans += 1
            if even[i] != mode_even_2[1]:
                ans += 1
    else:
        for i in range(n//2):
            if odd[i] != mode_odd_2[1]:
                ans += 1
            if even[i] != mode_even[1]:
                ans += 1
print(ans)

### FIXED CODE ###

from collections import Counter

def main():
    
    N = int(input())
    V = list(map(int,input().split()))
    odd = V[1::2]
    even = V[0::2]
    mode_o = Counter(odd).most_common()
    mode_o.append([0,0])
    mode_e = Counter(even).most_common()
    mode_e.append([0,0])
    ans = 0
    if mode_o[0][0] != mode_e[0][0]:
        ans = N-mode_o[0][1]-mode_e[0][1]
    else:
        ans = N - max(mode_e[0][1]+mode_o[1][1],mode_e[1][1]+mode_o[0][1])
    print(ans)

if __name__ == "__main__":
    main()
N = map(int, raw_input())
a = []
for i in range(N):
    a.append(map(int, raw_input().split()))


for i in range(N):
    v = a[i]
    j = i-1
    while j>=0 and a[j]>v:
        a[j+1] = a[j]
        j = j-1
        a[j+1] = v
    print(a)


### FIXED CODE ###

N = int(input())
a = input().split()
b = [int(n) for n in a]


for i in range(N):
    v = b[i]
    j = i-1
    while j>=0 and b[j]>v:
        b[j+1] = b[j]
        j = j-1
        b[j+1] = v
    print(" ".join([str(n) for n in b]))
n,q = map(int,raw_input().split())
A = [2**31-1 for i in range(n)]
B = [2**31-1 for i in range(318)]
for i in range(q):
    comi,xi,yi = map(int,raw_input().split())
    if comi and yi<316:
        print min(A[xi:yi+1])
    elif comi and yi >= 316 and xi/316+1 != yi/316:
        print min(min(A[xi:(xi/316 + 1)*316]),min(B[xi/316+1:yi/316]),min(A[(yi/316)*316:yi+1]))
    elif comi and yi >= 316 and (xi/316+1) == yi/316:
        print min(min(A[xi:(xi/316 + 1)*316]),min(A[(yi/316)*316:yi+1]))
    else:
        A[xi]=yi
        B[xi/316] = min(B[xi/316],yi)

### FIXED CODE ###

# coding: utf-8

n, q = map(int,raw_input().split())
A = [(1<<31) - 1 for i in xrange(100000)]
B = [(1<<31) - 1 for i in xrange(101)]
 
def update(i,x):
    if A[i] == (1<<31) - 1:
        A[i] = x
        B[i/1000] = min(x, B[i/1000])
    else:
        A[i] = x
        MIN = (1<<31) - 1
        for j in xrange(i/1000 * 1000, (i/1000 + 1) * 1000):
            if A[j] < MIN:
                MIN = A[j]
        B[i/1000] = MIN
 
def find(s,t):
    MIN = (1<<31) - 1
    if s/1000 == t/1000 or s/1000 + 1 == t/1000:
        for i in xrange(s, t+1):
            if A[i] < MIN:
                MIN = A[i]
    else:
        #left range
        for i in xrange(s, (s/1000 + 1) * 1000):
            if A[i] < MIN:
                MIN = A[i]
        #middle range
        for j in xrange(s/1000 + 1, t/1000):
            if B[j] < MIN:
                MIN = B[j]
         
        #right range
        for i in xrange(t/1000 * 1000, t+1):
            if A[i] < MIN:
                MIN = A[i]
    print MIN   
     
for i in xrange(q):
    com, s, t = map(int,raw_input().split())
    if com: #find
        find(s,t)
    else: #update
        update(s,t)
import sys
import numpy as np

readline = sys.stdin.readline

n = np.array(readline().split(), dtype=np.int64)

a = np.array(list(np.unique(n, return_counts=True))).T
ans = a[:,0][np.where(a[:,1] == 1)]
print(*ans)

### FIXED CODE ###

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

ans = a if b == c else b if c == a else c
print(ans)
import copy
import sys
H, W, M= map(int,input().split())
height = [0] * H
width = [0] * W
object = []
for i in range(H):
   wi = [0] * W
   object.append(wi)
for s in sys.stdin.readlines():
    h, w = map(int, s.split())
    height[h-1] += 1
    width[w-1] += 1
    object[h-1][w-1] = 1
h_max = max(height)
w_max = max(width)
cand_w = []
cand_h = []
for i in range(W):
   if width[i] == w_max:
      cand_w.append(i)
for i in range(H):
   if height[i] == h_max:
      cand_h.append(i)
ans = h_max + w_max - 1
p = len(cand_h)*len(cand_w)
if M >= p:
   for i in range(len(cand_h)):
      for j in range(len(cand_w)):
         if object[cand_h[i]][cand_w[j]] == 0:
            ans = h_max + w_max 
            exit()         
else:
   ans += 1
print(ans) 

### FIXED CODE ###

import copy
import sys
H, W, M= map(int,input().split())
height = [0]*H
width = [0]*W
object = []
for s in sys.stdin.readlines():
    h, w = map(int, s.split())
    height[h-1] += 1
    width[w-1] += 1
    object.append([h-1, w-1])
h_max = max(height)
w_max = max(width)
cand_w = []
cand_h = []
for i in range(W):
   if width[i] == w_max:
      cand_w.append(i)
for i in range(H):
   if height[i] == h_max:
      cand_h.append(i)
ans = h_max + w_max
c = 0
p = len(cand_h)*len(cand_w)
cand_h = set(cand_h)
cand_w = set(cand_w)
if M >= p:
   for i in range(len(object)):
      if object[i][0] in cand_h and object[i][1] in cand_w:
         c += 1
print(ans - (c == p))
N, M = map(int, input().split())
A = list(map(int, input().split()))
match = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}

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

cost = []
for i in range(M):
    cost.append([A[i], match[A[i]]])

dp[0] = 0
for i in range(N):
    for k in range(M):
        if i + 1 - cost[k][1] >= 0:
            dp[i + 1] = max(dp[i + 1], dp[i + 1 - cost[k][1]] + 1)

tmp = 0 #使ったマッチの数
res = ''
cost.sort(key=lambda x: x[0], reverse=True)
for i in range(dp[N]):
    for j in range(M):
        if dp[N - cost[j][1] - tmp] == dp[N - tmp] - 1:
            res = res + str(cost[j][0])
            tmp += cost[j][1]
            break
            
print(res)

### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
match = {1:2, 2:5, 3:5, 4:4, 5:5, 6:6, 7:3, 8:7, 9:6}

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

cost = []
for i in range(M):
    cost.append([A[i], match[A[i]]])

dp[0] = 0
for i in range(N):
    for k in range(M):
        if i + 1 - cost[k][1] >= 0:
            dp[i + 1] = max(dp[i + 1], dp[i + 1 - cost[k][1]] + 1)

tmp = 0 #使ったマッチの数
res = ''
cost.sort(key=lambda x: x[0], reverse=True)
for i in range(dp[N]):
    for j in range(M):
        if N - cost[j][1] - tmp >= 0:
            if dp[N - cost[j][1] - tmp] == dp[N - tmp] - 1:
                res = res + str(cost[j][0])
                tmp += cost[j][1]
                break
            
print(res)
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))
if n < m:
    print('NO')
    exit(0)
dcnt = {}
for x in d:dcnt[x] = 0
ok = True
for x in d:dcnt[x]+=1
for i in range(m):
    if dcnt[t[i]] == 0:ok = False
    dcnt[t[i]] -= 1
if ok:print('YES')
else:print('NO')


### FIXED CODE ###

n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))
if n < m:
    print('NO')
    exit(0)
dcnt = {}
for x in d:dcnt[x] = 0
ok = True
for x in d:dcnt[x]+=1
for i in range(m):
    if t[i] not in dcnt:
        ok = False
        break
    if dcnt[t[i]] == 0:
        ok = False
        break
    dcnt[t[i]] -= 1
if ok:print('YES')
else:print('NO')
print(-((-sum(map(int,input(),split())))//2))

### FIXED CODE ###

a,b=map(int,input().split())
print(-((-a-b)//2))
S=input()

def hoge(str)
	if str == "":
		return True
	for word in ["dreamer", "eraser", "dream", "erase"]
		keyword = word.sort(reverse=True)
		pattern = re.compile(r"^%s" % keyword)
		if(str.startswith(keyword)):
			return hoge(str.relpace(pattern, ""))
	return False

if hoge(S.sort(reverse=True)):
	print("YES")
else:
    print("NO")

### FIXED CODE ###

def main():
    S = input()

    while len(S) >= 5:
        if len(S) >= 7 and S[-7:] == "dreamer":
            S = S[:-7]
            continue

        if len(S) >= 6 and S[-6:] == "eraser":
            S = S[:-6]
            continue

        elif S[-5:] == "dream" or S[-5:] == "erase":
            S = S[:-5]
            continue

        else:
            break

    if len(S) == 0:
        print("YES")
    else:
        print("NO")

main()
import numpy

s = list(input())
t = input()

tmp = s[:]
for i in range(len(tmp)):
    tmp = numpy.roll(tmp, 1)
    if ''.join(tmp) == t:
        print('Yes')
        exit()
print('No')


### FIXED CODE ###

arr = [int(i) for i in input().split()]
arr.sort()
arr.reverse()

result = (arr[0] - arr[1]) + (arr[1] - arr[2])
print(result)
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
N = int(input())
A = [int(x) for x in readline().rstrip().split()]
A = np.array(A, np.int64)
while len(A) > 1:
    A = A[np.nonzero(A)]
    A = np.sort(A)
    minA = A[0]
    A %= minA
    A[0] = minA
A = A[np.nonzero(A)]
print(A[0])

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
N = int(input())
A = list(map(int, input().split()))
A = np.array(A, np.int64)
while len(A) > 1:
    A = A[np.nonzero(A)]
    A = np.sort(A)
    minA = A[0]
    A %= minA
    A[0] = minA
A = A[np.nonzero(A)]
print(A[0])
import copy
import sys
x,n = map(int, input().split())
nums = list(map(int, input().split()))
nums.sort()
if len(nums) == 0:
    print(x)
    sys.exit()
index = nums.index(x)
ind = copy.deepcopy(index)
ans = 0
while True:
    if ind < 0:
        break
    if nums[ind] != x and  nums[ind+1] - nums[ind] > 2:
        ans = nums[ind+1] - 1
        break
    ind -= 1
ind = copy.deepcopy(index)
while True:
    if ind > n-1:
        break
    if nums[ind] != x and  nums[ind] - nums[ind-1] > 2:
        if abs(ans - x) > abs(nums[ind-1] + 1 - x):
            ans = nums[ind-1] + 1
            break
    ind += 1
if index == 0:
    ans = x - 1
if index == n-1:
    if ans != x - 1
    ans = x + 1
print(ans)


### FIXED CODE ###

X, N = map(int, input().split())
P = list(map(int, input().split()))
Q = [q for q in range(-1, 102) if q not in P]
ans = min(Q, key=lambda q: (abs(q - X), q))
print(ans)
n=input()
wa=0
#print(n[2:len(n)-1])
if n[0]=="A" and n[2:len(n)-1].count("C")==1 and n[1]!="C" and n[len(n)]!="C":
    wa+=0
    import re
    a=re.sub('[AC ]', '',n)
else:
    wa+=1
    a=n
for i in range(len(a)):
    if 0<= ord(a[i]) - ord('a') <= 26:
        wa+=0
    else:
        wa+=1
if wa==0:
    print("AC")
else:
    print("WA")

### FIXED CODE ###

n=input()
wa=0
#print(n[2:len(n)-1])
#print(n[len(n)])
if n[0]=="A" and n[2:len(n)-1].count("C")==1 and n[1]!="C" and n[len(n)-1]!="C":
    wa+=0
    import re
    a=re.sub('[AC ]', '',n)
else:
    wa+=1
    a=n
for i in range(len(a)):
    if 0<= ord(a[i]) - ord('a') <= 26:
        wa+=0
    else:
        wa+=1
if wa==0:
    print("AC")
else:
    print("WA")
n = int(input())
no1 = -1
no1_i = -1
no2 = -2
no2_i = -1
S = []
for _ in range(n):
    S.append(int(input()))

for i in range(n):
  	if s[i] > no1:
    	no1_i = i
    	no1 = s[i]
    elif s[i] > no2:
    	no2_i = i
    	no2 = s[i]
      
for i in range(n):
 	if no1_i == i:
    	print(no2)
    else:
    	print(no1)

### FIXED CODE ###

n = int(input())
no1 = -1
no1_i = -1
no2 = -2
no2_i = -1
S = []
for _ in range(n):
    S.append(int(input()))
 
for i in range(n):
  if S[i] > no1:
    no1_i =i
    no1 = S[i]
  elif S[i] > no2:
    no2_i = i
    no2 = S[i]
      
for i in range(n):
  if no1_i == i:
    print(no2)
  else:
    print(no1)
n1, n2, n3, n4=map(int,input().split())
n=[]
n.append(n1, n2, n3, n4)
if 1, ,7 ,9, 4 in n:
  print('YES')
else:
  print('NO')

### FIXED CODE ###

n1, n2, n3, n4=map(int,input().split())
n=[]
n.append(n1)
n.append(n2)
n.append(n3)
n.append(n4)
if 1 in n and 7 in n and 9 in n and 4 in n:
  print('YES')
else:
  print('NO')
import sys
import math

input = sys.stdin.readline

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

s_num = [0] * n
t_num = [0] * m
s_num[0], t_num[0] = 1, 1
l = n * m / math.gcd(n, m)

for i in range(1, n):
    s_num[i] = i * l / n + 1

for i in range(1, m):
    t_num[i] = i * l / m + 1

match_num = list(set(s_num) & set(t_num))
ans = l

for i in range(len(match_num)):
    s_str = s[s_num.index(match_num[i])]
    t_str = t[t_num.index(match_num[i])]

    if s_str != t_str:
        ans = -1
        break

print(ans)


### FIXED CODE ###

import fractions


def binary_search(list, number, item):
    low = 0
    high = len(list) - 1

    while low <= high:
        mid = (low + high) // 2
        guess = list[mid][0]
        if guess == number:
            if list[mid][1] == item:
                return False
            else:
                return True
        if guess > number:
            high = mid - 1
        else:
            low = mid + 1
    # 見つからなかったとき
    return False


n, m = map(int, input().split())
s = input()
t = input()
check = []
l = n * m // fractions.gcd(n, m)
for i in range(n):
    check.append([i * l // n, s[i]])
for i in range(m):
    if binary_search(check, i * l // m, t[i]):
        print(-1)
        exit()
print(l)
n=int(input())
x=list(map(int,input().split()))

a=sum(x)/len(x)
d=[]
for i in range(min(x),max(x)):
    c=0
    for j in x:
        c+=(i-j)**2
    d.append(c)

print(min(d))

### FIXED CODE ###

import sys
n=int(input())
x=list(map(int,input().split()))

if n==1:
    print('0')
    sys.exit()

if x.count(x[0])==n:
    print('0')
    sys.exit()

a=sum(x)/len(x)
d=[]
for i in range(min(x),max(x)):
    c=0
    for j in x:
        c+=(i-j)**2
    d.append(c)

print(min(d))
def f(x):
  return x==x[::-1]
S=input()
n=(len(S)-1)/2
S1,S2=S[:n-1],S[n+1:]
if f(S) and f(S1) and f(S2):
  print('Yes')
else:
  print('No')

### FIXED CODE ###

def f(x):
  return x==x[::-1]
S=input()
n=(len(S)-1)//2
S1,S2=S[:n],S[n+1:]
if f(S) and f(S1) and f(S2):
  print('Yes')
else:
  print('No')
import math

n = int(raw_input())

for i in range(n):
    a = int(raw_input())
    b = int(raw_input())

    if math.log10(a) > 79 or math.log10(b) > 79:
        print 'overflow'
    else:
        c = a + b
        if math.log10(c) > 79:
            print 'overflow'
        else:
            print c

### FIXED CODE ###

n = int(raw_input())

for i in range(n):
    a = raw_input()
    b = raw_input()

    if len(a) > 80 or len(b) > 80:
        print 'overflow'
    else:
        a, b = int(a), int(b)
        c = a + b
        if len(str(c)) > 80:
            print 'overflow'
        else:
            print c
S,W=map(int,input().split())
if S<=W:
    print("unsafe")
else:
    print("safe")

### FIXED CODE ###

a=list(map(int,input().split()))
takahashi=0
takahashicount=0
aoki=0
aokicount=0

for i in range(a[2]):
    aoki+=a[1]
    if (a[2]-aoki)>0:
        aokicount+=1
    elif (a[2]-aoki)==0:
        break
    else:
        break
        
for i in range(a[0]):
    takahashi+=a[3]
    if (a[0]-takahashi)>0:
        takahashicount+=1
    elif (a[0]-takahashi)==0:
        break
    else:
        break
if takahashicount==aokicount:
    print("Yes")
elif takahashicount>aokicount:
    print("Yes")
elif takahashicount<aokicount:
    print("No")
N,M = map(int,input().split())
S = []
C = []
for i in range(M):
    temp1,temp2 = map(int,input().split())
    S.append(temp1)
    C.append(temp2)

Flag = True
temp = [-1,-1,-1]
for i in range(M):
    if S[i] == 3:
        if temp[2] == -1:
            temp[2] = C[i]
        else:
            if temp[2] == C[i]:
                next
            else:
                Flag = False

for i in range(M):
    if S[i] == 2:
        if temp[1] == -1:
            temp[1] = C[i]
        else:
            if temp[1] == C[i]:
                next
            else:
                Flag = False

for i in range(M):
    if S[i] == 1:
        if temp[0] == -1:
            temp[0] = C[i]
        else:
            if temp[0] == C[i]:
                next
            else:
                Flag = False

a = ''
if Flag == False:
    print(-1)
elif temp[0] ==0:
    print(-1)
elif temp[2] == -1:
    if temp[1] == -1:
        print(temp[0])
    elif temp[0] == -1:
        print(int(str(1) + str(temp[1]))
    else:
        if temp[0] == 0:
            print(-1)
        else:
            print(int(str(temp[0]) + str(temp[1])))
else:
    if temp[0] == -1 and temp[1] == -1:
        print(temp[2])
    elif temp[0] == -1 and temp[1] != -1:
        if temp[0] == 0:
            print(-1)
        else:
            print(int(str(temp[1]) + str(temp[2])))
    elif temp[0] != -1 and temp[1] == -1:
        if temp[0] == 0:
            print(-1)
        else:
            print(int(str(temp[0]) + str(0) + str(temp[2])))
    else:
        if temp[0] == 0:
            print(-1)
        else:
            print(int(str(temp[0]) + str(temp[1]) + str(temp[2])))

### FIXED CODE ###

N = int(input())

if N % 2 == 1:
    print(N//2 + 1)
else:
    print(N//2)
class UnionFind():
    def __init__(self, N):
        self.N = N
        self.parents = [-1] * N

    def root(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.root(self.parents[x])
            return self.parents[x]

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)

        if x == y:
            return False
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.root(x)]

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

uf = UnionFind(n)

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    uf.unite(a, b)

ans = 0
for i in range(n):
    ans = max(ans, uf.size(i))

print(n - str(ans))


### FIXED CODE ###

class UnionFind():
    def __init__(self, N):
        self.N = N
        self.parents = [-1] * N

    def root(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.root(self.parents[x])
            return self.parents[x]

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)

        if x == y:
            return False
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.root(x)]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

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

uf = UnionFind(n)

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    uf.unite(a, b)


print(uf.group_count() - 1)
INF = float("inf")
n = int(input())
A = [0]
for i, a in enumerate(sys.stdin):
    a = list(map(int, a.split()))
    if i == 0:
        A.extend(a)
    else:
        A.append(a[1])
C = [[INF] * (n + 1) for _ in range(n + 1)]
for i in range(n + 1):
    C[i][i] = 0
for j in range(1, n):
    for i in range(1, n - j + 1):
        for k in range(i + 1, i + j + 1):
            cost = C[i][k - 1] + C[k][i + j] + A[i] * A[k] * A[i + j + 1]
            if cost < C[i][i + j]:
                C[i][i + j] = cost
print(C[1][n])


### FIXED CODE ###

import sys
INF = float("inf")
n = int(input())
m = [[0] * (n + 1) for _ in range(n + 1)]
li = [list(map(int, a.split())) for a in sys.stdin]
z = (li[0][0], ) + list(zip(*li))[1]
for l in range(1, n):
    for i in range(1, n - l + 1):
        j = i + l
        m[i][j] = INF
        for k in range(i, j):
            m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + z[i - 1] * z[k] * z[j])
print(m[1][n])
import numpy as np
n, W = map(int, input().split())
dp = np.zeros(W+1,'i8')
for i in range(n):
  w, v = map(int, input().split())
  #print(dp[w:],dp[:-w],dp)
  dp[w:] = np.maximum(dp[w:], dp[:-w]+v)
  #print(dp[w:],dp[:-w],dp)
print(dp[-1])

### FIXED CODE ###

N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())

sum_v = sum(v)

dp = [[10**18] * (sum_v + 1) for _ in range(N + 1)]

for i in range(N+1):
    dp[i][0] = 0
    
# dp[i][j](j=0,1,...,W)の値が求まっている状態で、dp[i+1][j]を更新することを考える
for i in range(N):
    for j in range(sum_v + 1):
		# 品物(w[i],v[i])を選ぶとき、j-w[i]>=0に限って、価値v[i]が加算される
        if j - v[i] == 0:
            dp[i + 1][j] = min(w[i],dp[i][j])
        if dp[i][j] != 10**18:
            dp[i+1][j+v[i]] = min(dp[i][j+v[i]],dp[i][j]+w[i])
		# 品物(w[i],v[i])を選ばないとき、何も加算しない
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])

for i in range(sum_v + 1):
    #print(dp[N][sum_v - i],i)
    if dp[N][sum_v - i] <= W and dp[N][sum_v - i] != 0:
        print(sum_v - i)
        exit()

print(0)
h,w = map(int,input().split())
field = [list(input())for i in range(h)]
a= [[0]*w for i in range(h)]

vec = [(-1,0),(1,0),(0,1),(0,-1)]
ans = 0
for i in range(h):
    for j in range(w):
        if field[i][j] == "#":continue
        stack = [(i,j)]
        visited = [[0]*w for i in range(w)]
        a[i][j] = 0
        
        while stack:
            next = []
            for x,y in stack:
                
                if visited[x][y]:continue

                visited[x][y] = 1
                

                for tx,ty in vec:
                    nx = x+tx
                    ny = y+ty
                    if nx < 0 or ny <0 or nx >=h or ny >=w:continue
                    if field[nx][ny] == "#" :continue
                    if visited[nx][ny]:continue
                    next.append((nx,ny))
                    a[nx][ny] = a[x][y] + 1
                    
                    
            stack = next
   
        for i in range(h):
            ans = max(ans,max(a[i]))
            a[i] = [0]*w
print(ans)
            
            
            
            

### FIXED CODE ###

h,w = map(int,input().split())
field = [list(input())for i in range(h)]


vec = [(-1,0),(1,0),(0,1),(0,-1)]
ans = 0
for i in range(h):
    for j in range(w):
        if field[i][j] == "#":continue
        stack = [(i,j)]
        visited = [[0]*w for i in range(h)]
        a= [[0]*w for i in range(h)]
        
        while stack:
            next = []
            for x,y in stack:
                
                if visited[x][y]:continue

                visited[x][y] = 1
                

                for tx,ty in vec:
                    nx = x+tx
                    ny = y+ty
                    if nx < 0 or ny <0 or nx >=h or ny >=w:continue
                    if field[nx][ny] == "#" :continue
                    if visited[nx][ny]:continue
                    next.append((nx,ny))
                    a[nx][ny] = a[x][y]+1
                    
                    
            stack = next
        ans = max(ans,max(max(row)for row in a))
print(ans)
x,a,b=(int(i) for i in input().split())
c = b-c
if c <= 0:
  print('delicious')
elif c <= x:
  print('safe')
else:
  print('dangerous')

### FIXED CODE ###

x,a,b=(int(i) for i in input().split())
c = b-a
if c <= 0:
  print('delicious')
elif c <= x:
  print('safe')
else:
  print('dangerous')
(a, b) = [int(x) for x in input().split()]

di = a // b
m = a % b
df = a / b

print('{0} {1} {2:,8f}'.di, m, df))

### FIXED CODE ###

(a, b) = [int(x) for x in input().split()]

di = a // b
m = a % b
df = a / b

print('{0} {1} {2:.8f}'.format(di, m, df))