Harryxun/stf_run huggingface dataset:
import sys
N,M=map(int, input().split())
a=[]
b=[]
c=[]
for m in range (0,M):
  A,B,C=map(int, input().split() )
  a+=[A]
  b+=[B]
  c+=[C]
V=[0]*N# iに到達するときの最大得点
moji=[1]+[0]*(N-1)#infなら0をかえす
 
for n in range(N-1):
  for m in range(M):
    u=a[m]
    v=b[m]
    if moji[a[m]-1]:#共に有限の時はやる
      if moji[b[m]-1]:
        V[b[m]-1]=max(V[b[m]-1],V[a[m]-1]+c[m])
      else:
        V[b[m]-1]=V[a[m]-1]+c[m]
        moji[b[m]-1]=1
 
moji2=[0]*N
for n in range(N):
  for m in range(M):
    u=a[m]
    v=b[m]
    if moji[a[m]-1]:#共に有限の時はやる
      if moji[b[m]-1]:
        V[b[m]-1]=max(V[b[m]-1],V[a[m]-1]+c[m])
      else:
        V[b[m]-1]=W[a[m]-1]+c[m]
        moji2[b[m]-1]=1
    if moji2[a[m-]1]:
      moji2[b[m]-1]
if moji2[N-1]:
  print("inf")
else:
  print(V[N-1])

### FIXED CODE ###

import sys
N,M=map(int, input().split())
a=[]
b=[]
c=[]
for m in range (0,M):
  A,B,C=map(int, input().split() )
  a+=[A]
  b+=[B]
  c+=[C]
V=[0]+[-10**12]*(N-1)# iに到達するときの最大得点
 
for n in range(N-1):
  for m in range(M):
    u=a[m]
    v=b[m]
    if V[b[m]-1]<V[a[m]-1]+c[m]:#共に有限の時はやる
      V[b[m]-1]=V[a[m]-1]+c[m]
 
moji2=[0]*N
for n in range(N):
  for m in range(M):
    u=a[m]
    v=b[m]
    if V[b[m]-1]<V[a[m]-1]+c[m]:#共に有限の時はやる
      V[b[m]-1]=V[a[m]-1]+c[m]
      moji2[b[m]-1]=1
      if moji2[N-1]:
        print("inf")
        sys.exit()
print(V[N-1])
N,X=map(int,input().split())
m=[]
for i in range(N):
    mix=int(input())
    m.append(mix)
lowest=sum(m)
X=X-lowest
def dp(rm,num):
    if rm<m[num]:return 0
    
    if num<N-1:
        return max(1+dp(rm-m[num],num),dp(rm,num+1))
    else :
        return 1+dp(rm-m[num],num)
print(dp(X,0)+N)

### FIXED CODE ###


N,X=map(int,input().split())
m=[]
for i in range(N):
    mix=int(input())
    m.append(mix)
lowest=sum(m)
X=X-lowest
minimum=min(m)
ans=N
while X>=minimum:
    ans+=1
    X=X-minimum
print(ans)
# Aizu Problem ITP_1_5_D: Structured Programming
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")

res = []


def CHECK_NUM(n, i):
    x = i
    if x % 3 == 0:
        res.append(i)
    else:
        while True:
            if x % 10 == 3:
                res.append(i)
                break
            x //= 10
            if x == 0:
                break
    i += 1
    if i <= n:
        CHECK_NUM(n, i)
        
        
def call(n):
    CHECK_NUM(n, 1)
    

n = int(input())
call(n)
print(' ' + ' '.join([str(r) for r in res]))

### FIXED CODE ###

# Aizu Problem ITP_1_5_D: Structured Programming
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")

res = []


def CHECK_NUM2(n, i):
    x = i
    if x % 3 == 0:
        res.append(i)
    else:
        while True:
            if x % 10 == 3:
                res.append(i)
                break
            x //= 10
            if x == 0:
                break
    i += 1
    if i <= n:
        CHECK_NUM(n, i)
        
def CHECK_NUM(n, i):
    while True:
        x = i
        if x % 3 == 0:
            res.append(i)
        else:
            while True:
                if x % 10 == 3:
                    res.append(i)
                    break
                x //= 10
                if x == 0:
                    break
        i += 1
        if i > n:
            break
        
def call(n):
    CHECK_NUM(n, 1)
    

n = int(input())
#n=1000
call(n)
print(' ' + ' '.join([str(r) for r in res]))
from scipy.sparse.csgraph import bellman_ford, csgraph_from_dense
import numpy as np

n, m = map(int, input().split())
abc = [list(map(int, input().split())) for _ in range(m)]

adj = [[] for _ in range(n)]
for a, b, c in abc:
	a -= 1
	b -= 1
	adj[a].append([b, -c])

g = [[np.inf] * n for _ in range(n)]


def dfs(s):
	stack = [s]
	passed = [0] * n
	passed[s] = 1

	while stack:
		u = stack.pop()
		for v, c in adj[u]:
			if passed[v] == 0:
				passed[v] = 1
				stack.append(v)
			g[u][v] = c

	return passed


connected = dfs(0)
connected_nodes = [i for i, e in enumerate(connected) if e]
new = [-1] * n
for i, e in enumerate(connected_nodes):
	new[e] = i
l = len(connected_nodes)

g2 = [[np.inf] * l for _ in range(l)]
for i, e in enumerate(connected_nodes):
	for j, c in enumerate(g[e]):
		if new[j] != -1:
			g2[e][new[j]] = c


try:
	graph = csgraph_from_dense(g2, null_value=np.inf)
	dist = bellman_ford(graph, indices=0)
	ans = -int(dist[n-1])
	print(ans)

except:
	print("inf")


### FIXED CODE ###

n, m = map(int, input().split())
abc = [list(map(int, input().split())) for _ in range(m)]


def bellman_ford(s, g):
	dist = [float("inf")] * n
	dist[s] = 0
	negative = [False] * n
	for i in range(2 * n):
		for a, b, c in abc:
			a -= 1
			b -= 1
			c = -c

			if dist[b] > dist[a] + c:
				dist[b] = dist[a] + c
				if i >= n:
					negative[b] = True

	if negative[g]:
		ret = "inf"

	else:
		ret = -dist[g]

	return ret


ans = bellman_ford(0, n - 1)
print(ans)
N=int(input())
A=list(map(int,input().split()))

from functools import lru_cache
@lru_cache(None)

def gcd(x,y):
    if y>x:
        x,y=y,x
    if y==0:
        return x
    else:
        return gcd(y,x-y)

pairwise=True
setwise=True
gcds=[]
for i in range(N):
    for j in range(i+1,N):
        g=gcd(A[i],A[j])
        if g in gcds:
            setwise=False
        else:
            gcds.append(g)
        if g > 1:
            pairwise=False
        if pairwise==False and setwise==False:
            break
    if pairwise==False and setwise==False:
        break
        

if pairwise==True:
    print("pairwise coprime")
elif setwise==True:
    print("setwise coprime")
else:
    print("not coprime")

### FIXED CODE ###

import sys

N=int(input())
A = list(map(int,input().split()))
 
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

if gcd_list(A) > 1:
    print("not coprime")
    sys.exit()

D = [i for i in range(max(A)+1)] #iを割り切る最小の素数を格納
p = 2
 
while(p*p<=max(A)):
    if D[p]==p:
        for i in range(p*p,max(A)+1,p):
            if D[i]==i:
                D[i]=p
 
    p+=1
    
prime = set()
for a in A:
    tmp=D[a]
    L=set()
    while(a>1):
        a=a//tmp
        L.add(tmp)
        tmp=D[a]

    for l in L:
        if l in prime:
            print("setwise coprime")
            sys.exit()
        else:
            prime.add(l)

print("pairwise coprime")
n, k = map(int, input().split())
if k!=1:
    print(n-k)
else:
    pritn('0')

### FIXED CODE ###

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

if k!=1:
    print(n-k)
else:
    print('0')
M, D = map(int, inputs[0].split())
good_dates = []
for date in range(D):
    d10 = (date+1) // 10
    d1 = (date+1) % 10
    if d1 >= 2 and d10 >= 2:
        if d1*d10 <= M:
            good_dates.append((d1*d10, date))
print(len(good_dates))

### FIXED CODE ###

import sys
inputs = sys.stdin.readlines()

M, D = map(int, inputs[0].split())

good_dates = []
for date in range(D):
    d10 = (date+1) // 10
    d1 = (date+1) % 10
    if d1 >= 2 and d10 >= 2:
        if d1*d10 <= M:
            good_dates.append((d1*d10, date))
print(len(good_dates))
N = int(input())
A = [int(input()) for _ in range(N)]

A.sort()
if N % 2 == 0:
    print((sum(A[N//2:]) - sum(A[:N//2]))*2 - (A[N//2+1] - A[N//2]))
else:
    print((sum(A[N//2+1:]) - sum(A[:N//2]))*2 - min(A[N//2+1] - A[N//2], A[N//2] - A[N//2-1]))

### FIXED CODE ###

N = int(input())
A = []
for i in range(N):
    A.append(int(input()))

A.sort()

if N % 2 == 1:
    w = -2*sum(A[:N//2]) +A[N//2] +A[N//2 + 1] + 2*sum(A[N//2 + 2:])
    m = -2*sum(A[:N//2-1]) - A[N//2 - 1] - A[N//2] + 2*sum(A[N//2+1:])
    print(max(w, m))
else:
    print(-2*sum(A[:N//2-1]) - A[N//2-1] + A[N//2] + 2*sum(A[N//2+1:]))
n, x = map(int, input().split())

l = [0]*(n+1)
l[0] = 1
for i in range(1,n+1):
  l[i] = l[i-1]*2+3

p = [0]*(n+1)
p[0] = 1
for i in range(1,n+1):
  p[i] = p[i-1]*2+1
  
ans = 0  
def bts(a,b):
  global ans
  if b = 1:
    ans += 0
  elif 1 < b < l[a-1]+1:
    bts(a-1,b-1)
  elif b == l[a-1]+1:
    ans += p[a-1]
  elif b == l[a-1]+2:
    ans += p[a-1]+1
  elif l[a-1]+2 < b < l[a-1]*2+2:
    ans += p[a-1]+1
    bts(a-1,b-2-l[a-1])
  else:
    ans += p[a-1]+2

bts(n,x)
  
print(ans)


### FIXED CODE ###

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

l = [0]*(n+1)
l[0] = 1
for i in range(1,n+1):
  l[i] = l[i-1]*2+3

p = [0]*(n+1)
p[0] = 1
for i in range(1,n+1):
  p[i] = p[i-1]*2+1
  
ans = 0  
def bts(a,b):
  global ans
  if b == 1:
    ans += 0
  elif 1 < b < l[a-1]+1:
    bts(a-1,b-1)
  elif b == l[a-1]+1:
    ans += p[a-1]
  elif b == l[a-1]+2:
    ans += p[a-1]+1
  elif l[a-1]+2 < b < l[a-1]*2+2:
    ans += p[a-1]+1
    bts(a-1,b-2-l[a-1])
  else:
    ans += p[a]

bts(n,x)
  
print(ans)
def cmb(n,k):
  x,y=n,k
  for i in range(1,k):
    x*=n-i
    y*=k-i
  return x//y

n,m=[int(x) for x in input().split()]
N=cmb(m,2) if n>=2 else 0
M=cmb(n,2) if m>=2 eles 0
print(N+M)

### FIXED CODE ###

def cmb(n,k):
  x,y=n,k
  for i in range(1,k):
    x*=n-i
    y*=k-i
  return x//y

n,m=[int(x) for x in input().split()]
N=cmb(n,2) if n>=2 else 0
M=cmb(m,2) if m>=2 else 0
print(N+M)
import sys

a, v = map(int, inpu().split())
b, w = map(int, inpu().split())
t = int(input())
if (a == b):
  print('YES')
  sys.exit(0)
if (v <= w):
  print('NO')
  sys.exit(0)
res = abs(a - b) / (v - w)
if (res > t):
  print('NO')
else:
  print('YES')
sys.exit(0)
  

### FIXED CODE ###

import sys

a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())
if (a == b):
    print('YES')
    sys.exit(0)
if (v <= w):
    print('NO')
    sys.exit(0)
res = abs(a - b) / (v - w)
if (res > t):
    print('NO')
else:
    print('YES')
sys.exit(0)
a = map(int, input().split())
print(f'{2 * a * 3.1415926}')
print(f'{a * a * 3.1415926}')



### FIXED CODE ###

r = float(input())
p = 3.141592653589
print(p*r*r, 2*p*r)
N = input()
A = int(N[-3])*100 + int(N[-2])*10 + int(N[-1])
if A == 0:
    print("0")
else:
 print(1000 - A)

### FIXED CODE ###

N = input()
if len(N) >= 3:
    A = int(N[-3])*100 + int(N[-2])*10 + int(N[-1])
    if A == 0:
        print(0)
    else:
        print(1000 - A)
elif len(N) == 2:
    A = int(N[-2])*10 + int(N[-1])
    print(1000 - A)
elif len(N) == 1:
    A = int(N[-1])
    print(1000 - A)
37564
whydidyoudesertme

### FIXED CODE ###

P = 10**9 + 7

K = int(input())
S = input()
L = len(S)

d = [0]*(L+K+1)
d[0] = 1
for i in range(1, L+K+1):
    d[i] = (d[i-1]*i)%P

ans = 0
for i in range(K+1):
    temp = pow(26, i, P) * pow(25, K-i, P)
    temp %= P
    temp *= d[L-1+K-i]
    temp %= P
    temp *= pow(d[L-1], P-2, P)
    temp %= P
    temp *= pow(d[K-i], P-2, P)
    temp %= P
    ans += temp
    ans %= P

print(ans)
n = int(input())
a = list(map(int, input().split()))

if 0 in a:
  print(0)
  exit()
total = 1 
for i in range(n):
  total* = a[i]
  if total > 10 ** 18:
  print(-1)
  break
print(total)
  


### FIXED CODE ###

n = int(input())
l = list(map(int, input().split()))
if 0 in l:
  print(0)
  exit()
ans = 1
for i in range(n):
  ans *= l[i]
  if ans > 10**18:
    ans = -1
    break
print(ans)
n,k=input2()
A=input_array()

# ある地点から循環に陥る
tmps=[1] #循環手前
loops=[] #循環
st=0 #循環が始まる地点
count=0 #参照地点

for i in range(10**5):
	if A[count] not in tmps:
		tmps.append(A[count])
	elif (A[count] in tmps) and (A[count] not in loops):
		loops.append(A[count])
		st=i
	else:
		break
	count=A[count]-1


if k<=st:
	print(tmps[k-1])
else:
	ans=(k-(st-1))%len(loops)
	print(loops[ans])

### FIXED CODE ###

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))
  
n,k=input2()
A=input_array()

# ある地点から循環に陥る
judge=[True]*n
tmps=[1] #循環手前
count=0 #参照地点

for i in range(2*(10**5)+1):
	if judge[count]==True:
		judge[count]=False
		count=A[count]-1
		tmps.append(count+1)
	else:
		break

loop_st=tmps.index(tmps[-1])
loops=tmps[loop_st:-1]


if k<loop_st:
	print(tmps[k])
else:
	k=k-loop_st
	k%=len(loops)
	print(loops[k])
N = int(input())
nums = sorted(list(map(int, input().split())) Reverse = True)
print(sum(A[::2]) - sum(B[1::2]))


### FIXED CODE ###

N = int(input())
nums = sorted(list(map(int, input().split())), reverse = True)
print(sum(nums[::2]) - sum(nums[1::2]))
import sys

from math import pi

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(get_ints())
def input(): return sys.stdin.readline().strip().split()

r = int(input())
print(2*pi*r)

### FIXED CODE ###

import sys


from math import pi

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(get_ints())
def input(): return sys.stdin.readline().strip()

r = int(input())
print(2*pi*r)
import math

r= float(input().rstrip().split(' ')

a = 2r * math.PI

b = r * math.PI

print(a, b)

### FIXED CODE ###

import math

r= float(input())

a = r * r * math.pi

b = 2 * math.pi * r

print(a, b)
A, B, C = list(ma(int, input().split()))
if A<B<C:
    print('Yes')
else:
    prit('No')

### FIXED CODE ###

a, b, c = list(map(int, input().split()))
if a<b<c:
    print('Yes')
else:
    print('No')
r=int(input())
g=int(input())

print(2g-r)

### FIXED CODE ###

r=int(input())
g=int(input())

print(2*g-r)
a,b,k = map(int,input().split())
c = list(range(a,a+k))
d = list(range(b-k+1,b+1))
e = list(range(a,b+1))
if a+k-1 < b-k+1:
  ans_list = c+d
else:
  ans_list = e
for num in ans_list:
  print(num)

### FIXED CODE ###

a,b,k = map(int,input().split())
if b+2 <= a+2*k:
  for i in range(a,b+1):
    print(i)
else:
  for i in range(a,a+k):
    print(i)
  for i in range(b+1-k,b+1):
    print(i)
print("1") if input() == 0; else("0")

### FIXED CODE ###

x = int(input())
if x == 1:
  print("0")
else:print("1")
n=int(input())

ba=[]
for _ in range(n):
  a,b=map(int,input().split())
  ba.append(b,a)
  
ba.sort()

time=0
for item in ba:
  b=item[0]
  a=item[1]
  
  time+=b
  if time>a:
    print("No")
    exit()
print("Yes")
  

### FIXED CODE ###

n=int(input())

ba=[]
for _ in range(n):
  a,b=map(int,input().split())
  ba.append([b,a])
  
ba.sort()

time=0
for item in ba:
  b=item[0]
  a=item[1]
  #print(a,b,time)
  
  time+=a
  if time>b:
    print("No")
    exit()
print("Yes")
N,K = map(int,input().split())
tree = sorted([int(input())for i in range(N)])
d = 10**18  

for i in range(N-K+1):
  d = min(d,tree[i+2]-tree[i])
print(d)

### FIXED CODE ###

N,K = map(int,input().split())
tree = sorted([int(input())for i in range(N)])
d = 10**18  


for i in range(N-K+1):
  d = min(d,tree[i+K-1]-tree[i])
print(d)
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
for i in range(2 ** n):
  k = 0
  m = 0
  for j in range(n):
    if (i >> j) & 1:
      k += v[j]
      c += c[j]
  ans = max(ans, k - m)
print(ans)

### FIXED CODE ###

n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
for i in range(n):
  if v[i] > c[i]:
    ans += v[i] - c[i]
print(ans)
#!/usr/bin/env python3

import sys

sys.setrecursionlimit(10**7)

# Override `input` function because `stdin.readline()` is 10x faster than built-in `input()`
input = sys.stdin.readline


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h(typ) if m > 1 else typ(input()) for _ in range(n)]


def main():
    S, = read_h(typ=str)
    n = len(S)

    MOD = 10**9 + 7

    dp = [[0] * 13 for _ in range(10**5)]
    dp[0][0] = 1
    #  print('initial dp:', dp)

    for i, s in enumerate(S):
        c = -1 if s == '?' else ord(s) - ord('0')
        #  print('c:', c)

        for j in range(10):
            if c != -1 and c != j:
                continue

            for k in range(13):
                dp[i + 1][(k * 10 + j) % 13] += dp[i][k]

            #  print('updated dp:', dp[:])

        for j in range(13):
            dp[i + 1][j] %= MOD

        #  print('final dp:', dp[:])

    res = dp[n][5]
    print(res)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3

import sys

sys.setrecursionlimit(10**7)

# Override `input` function because `stdin.readline()` is 10x faster than built-in `input()`
input = sys.stdin.readline


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h(typ) if m > 1 else typ(input()) for _ in range(n)]


def main():
    S, = read_h(typ=str)
    n = len(S)

    MOD = 10**9 + 7

    dp = [[0] * 13 for _ in range(10**5 + 2)]
    dp[0][0] = 1
    #  print('initial dp:', dp)

    for i, s in enumerate(S):
        c = -1 if s == '?' else ord(s) - ord('0')
        #  print('c:', c)

        for j in range(10):
            if c != -1 and c != j:
                continue

            for k in range(13):
                dp[i + 1][(k * 10 + j) % 13] += dp[i][k]

            #  print('updated dp:', dp[:])

        for j in range(13):
            dp[i + 1][j] %= MOD

        #  print('final dp:', dp[:])

    res = dp[n][5]
    print(res)


if __name__ == '__main__':
    main()
import itertools


input()
s = list(input())
r =[]
g =[]
b =[]
n= len(s)
ans =0
for i in range(n):
    if s[i]== "R":
        r.append(i+1)
    elif s[i]== "G":
        g.append(i+1)
    else:
        b.append(i+1)

for ri , gi in itertools.product(r,g):
    rg=gi-a
    if rg+gi in b:
        ans -=1
    if  ri-rg in b:
        ans -=1
    if (gi+ri)/2 in b:
        ans -=1

ans += len(r)*len(b)*len(g)
print(ans)

### FIXED CODE ###

n = list(input())
if "7" in n:
    print("Yes")
else:
    print("No")
import sys
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def solve():
    global x,k,d
    if x > 0:
        i = x//d
        if i<k:
            x -= d*i
        else:
            print(x-d*k)
            return
    elif x<0:
        i = -x//d
        if i<k:
            x += d*i
        else:
            print(abs(x+d*k))
            return
    else:
        if k%2==1:
            print(abs(d))
        else:
            print(0)
            return
    
    k -= i
    if k%2==1:
        if abs(x-d)<abs(x+d):
            print(abs(x-d))
        else:
            print(abs(x+d))
    else:
        print(abs(x))
    return

if __name__=='__main__':
    x,k,d = IL()
    solve()

### FIXED CODE ###

import sys
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def solve():
    global x,k,d
    i = min(k,abs(x//d))
    if abs(x-d*i)<abs(x+d*i):
        x -= d*i
    else:
        x += d*i
    k -= i
    if k%2==1:
        if abs(x-d)<abs(x+d):
            print(abs(x-d))
        else:
            print(abs(x+d))
    else:
        print(abs(x))
    return

if __name__=='__main__':
    x,k,d = IL()
    solve()
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n = I()
    a = LI()
    d = collections.defaultdict(int)
    for c in a:
        d[c] += 1
    t = sorted(list(d.keys()))
    if t[-1] - t[0] > 1:
        return 'No'
    if len(t) == 1:
        if t[0] == n - 1:
            return 'Yes'
        if t[0] > n / 2.0:
            return 'No'
        return 'Yes'
    b = t[1] - d[t[0]]
    n2 = d[t[1]]
    if n2 == 2 and b == n2 - 1:
        return 'Yes'
    if b < 1:
        return 'No'
    return 1/0
    if b >= n2 - 2:
        return 'No'

    return 'Yes'


print(main())


### FIXED CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n = I()
    a = LI()
    d = collections.defaultdict(int)
    for c in a:
        d[c] += 1
    t = sorted(list(d.keys()))
    if t[-1] - t[0] > 1:
        return 'No'
    if len(t) == 1:
        if t[0] == n - 1:
            return 'Yes'
        if t[0] > n / 2.0:
            return 'No'
        return 'Yes'
    b = t[1] - d[t[0]]
    n2 = d[t[1]]
    if n2 == 2 and b == n2 - 1:
        return 'Yes'
    if b < 1:
        return 'No'
    if b >= n2 - 2:
        return 'No'
    if b > n2 / 2.0:
        return 'No'

    return 'Yes'


print(main())
n = int(input())

i0 = 2
i1 = 1
for i in range(n-1):
    ans = i0+i1
    i0 = i1
    i1  = ans
print(ans)

### FIXED CODE ###

n = int(input())

i0 = 2
i1 = 1
if n>1:
    for i in range(n-1):
        ans = i0+i1
        i0 = i1
        i1  = ans
if n==0:
    print(2)
elif n==1:
    print(1)
else:
    print(ans)
while True:
 x,y =map(int,raw_input.split())
 if(x==y==0):
   break
 elif(x>y):
  print"%s %s"%(x,y)
 elif(x<=y):
  print"%s %s"%(y,x)

### FIXED CODE ###

while True:
 x,y =map(int, raw_input().split())
 if(x==0 and y==0):
   break
 elif(x>y):
  print y,x  
 elif(x<=y):
  print x,y
N = [int(_) for _ in input().split()]

H, W = N[0], N[1]


def solve(H, W):
    acnt = floor(W / 2) + 1
    bcnt = W - acnt
    
    if H == 1 or W == 1:
        return 1
    
    if H % 2 == 0:
        cnt = acnt * floor(H/2) + bcnt * floor(H/2)
    else:
        cnt = acnt * (floor(H/2) + 1) + bcnt * floor(H/2)
    return cnt

print(solve(H, W))

### FIXED CODE ###

from math import floor

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

H, W = N[0], N[1]


def solve(H, W):
    acnt = floor(W / 2) + 1
    bcnt = W - acnt
    
    if H == 1 or W == 1:
        return 1
    else:
        return floor((H * W + 1) / 2)
    
    # if H % 2 == 0:
    #     cnt = acnt * floor(H/2) + bcnt * floor(H/2)
    # else:
    #     cnt = acnt * (floor(H/2) + 1) + bcnt * floor(H/2)
    # return cnt

print(solve(H, W))
#!/usr/bin/env python3
n, *a = map(int, open(0).read().split())
b = [0] * (10**5 + 1)
for i in a:
    b[i] += 1
print(sum(i % 2 > 0 for i in b))


### FIXED CODE ###

#!/usr/bin/env python3
from collections import defaultdict
n, *a = map(int, open(0).read().split())
b = defaultdict(int)
for i in a:
    b[i] += 1
print(sum(i % 2 > 0 for i in b.values()))
import math,cmath
def f(m):
  b*=1j
  c=math.acos(a/2)
  p1=cmath.exp(b+c)+p0
  p2=cmath.exp(b-c)+p0
  s1,s2=0,0
  for k in N:
    if k==i or k==j:continue
    if abs(p1-X[k])<=1:s1+=1
    if abs(p2-X[k])<=1:s2+=1
  if s1>m:m=s1
  if s2>m:m=s2
  return m

while 1:
  n=input()
  if n==0:break
  N=range(n)
  X=[]
  for i in range(n):
    x,y=map(float,input())
    X+=[complex(x,y)]
  m=0
  for i in N:
    p0=X[i]
    for j in N:
      if i==j:continue
      a,b=cmath.polar(p0-X[j])
      if a<=2:m=f(m)
  print m+2

### FIXED CODE ###

import math,cmath
def f(m):
  c=1j*math.acos(a/2)
  r=cmath.exp(b+c)+p
  s=cmath.exp(b-c)+p
  u,v=2,2
  for t in A:
    if t in[p,q]:continue
    if abs(t-r)-1<1e-6:u+=1
    if abs(t-s)-1<1e-6:v+=1
  return max(m,u,v)

while 1:
  n=input()
  if n==0:break
  N=range(n)
  A=[]
  for i in N:
    x,y=map(float,input())
    A+=[x+1j*y]
  m=1
  for i in N:
    p=A[i]
    for q in A[i+1:]:
      a,b=cmath.polar(q-p)
      b*=1j
      if a<=2:m=f(m)
  print m