Felix6326727/beyond-accuracy-code-comprehension huggingface dataset:
s=list(input())
a=s.count("a")
b=s.count("b")
c=s.count("c")
if min(a,b,c)!=0 and max(a,b,c)-min(a,b,c)<=1:
    print("YES")
else:
    print("NO")


# Example run
# Input:
`g>!d
# Output:
NO
from collections import Counter
S = input()
N = len(S)

c = Counter(S)

def checkf(c1,c2,c3):
  return (c[c1] == c[c2] and c[c2] == c[c3]) or (c[c1] == c[c2] and c[c2] == c[c3]+1) or (c[c1] == c[c2]+1 and c[c2] == c[c3])

flg = checkf('a','b','c') or checkf('a','c','b') or checkf('b','a','c') or checkf('b','c','a') or checkf('c','a','b') or checkf('c','b','a')

print("YES" if flg else "NO")

# Example run
# Input:
U({C
# Output:
YES
s=input()
x=s.count('a')
y=s.count('b')
z=s.count('c')
a=[x,y,z]
if len(s)==1:
  print('YES')
elif len(s)==2:
  if s[0]==s[1]:
    print('NO')
  else:
    print('YES')
else:
  if len(s)%3==0:
    if x==y and y==z:
      print('YES')
    else:
      print('NO')
  else:
    if max(a)-min(a)==1:
      print('YES')
    else:
      print('NO')

# Example run
# Input:
`z*1%oa
# Output:
YES
from collections import Counter
def main():
    s = input()
    if len(s) == 1:
        print('YES')
        return
    if len(s) == 2:
        if len(set(s)) == 1: print('NO')
        else: print('YES')
        return
    cc = Counter(s)
    if all([cc[cha] >= len(s)//3 for cha in list(set(s))]):
        print('YES')
    else:
        print('NO')
    return

if __name__ == '__main__':
    main()
    

# Example run
# Input:
n^)3~X{
# Output:
NO
s = input()
a = s.count('a')
b = s.count('b')
c = s.count('c')
p = [a,b,c]
if max(p) - min(p) <=1:
    print('Yes')
else:print('No')    

# Example run
# Input:
4G9
# Output:
Yes
def resolve():
    s = input()
    count = [s.count(c) for c in "abc"]
    if max(count) - min(count) < 2:
        print("YES")
    else:
        print("NO")


if __name__ == "__main__":
    resolve()


# Example run
# Input:
E76
# Output:
YES
from collections import Counter

S = input()
C = Counter(S)
C.setdefault('a',0)
C.setdefault('b',0)
C.setdefault('c',0)
C = C.values()
if max(C) - min(C) == 0 or max(C) - min(C) == 1:
    print('YES')
else:
    print('NO')

# Example run
# Input:
"O?Wixhv
# Output:
YES
from collections import Counter
S = [i for i in str(input())]
c = Counter(S)
m = c.most_common()

n = len(S) // 3
if len(m) < 3:
  print('NO')
else:
  if len(S) % 3 == 0:
    if (m[0][1]==n) and (m[1][1]==n) and (m[2][1]==n):
      print('YES')
    else:
      print('NO')
  elif len(S) % 3 == 1:
    if (m[0][1]==n+1) and (m[1][1]==n) and (m[2][1]==n):
      print('YES')
    else:
      print('NO')
  else:
    if (m[0][1]==n+1) and (m[1][1]==n+1) and (m[2][1]==n):
      print('YES')
    else:
      print('NO')

# Example run
# Input:
TI~ET:$
# Output:
NO
# cf17-finalB - Palindrome-phobia
from collections import Counter


def main():
    S = input().rstrip()
    C = Counter(S).values()
    flg = (len(C) == 3 and max(C) - min(C) <= 1)
    print("YES" if flg else "NO")


if __name__ == "__main__":
    main()

# Example run
# Input:
nh8|W4Bp
# Output:
NO
from collections import Counter

S = input()
d = Counter(S).values()
if len(S) == 1:
  ans = "YES"
elif len(S) == 2:
  if S[0] != S[1]:
    ans = "YES"
  else:
    ans = "NO"
elif len(d) == 3 and max(d) - min(d) <=1:
  ans = "YES"
else:
  ans = "NO"
print(ans)


# Example run
# Input:
R!dTK>W{j
# Output:
NO
from collections import defaultdict
dic = defaultdict(int)

sl = list(input())
dic["a"] = 0
dic["b"] = 0
dic["c"] = 0
for s in sl:
    dic[s] += 1

if max(dic.values()) - min(dic.values()) <= 1:
    print("YES")
else:
    print("NO")



# Example run
# Input:
hxe
# Output:
YES
from collections import Counter
s = Counter(input())
ss = list(s.values())
ss.sort()
if len(ss) != 3:
  if ss[-1] <= 1:
    print('YES')
  else:
    print('NO')
elif ss[2] - ss[0] <= 1:
  print('YES')
else:
  print('NO')

# Example run
# Input:
pg(K
# Output:
YES
from collections import Counter
S = [i for i in str(input())]
c = Counter(S)
m = c.most_common()

n = len(S) // 3
if len(S) == 1:
  print('YES')
elif len(S) == 2:
  if len(m) == 2:
    print('YES')
  else:
    print('NO')
elif len(m) < 3:
  print('NO')
else:
  if len(S) % 3 == 0:
    if (m[0][1]==n) and (m[1][1]==n) and (m[2][1]==n):
      print('YES')
    else:
      print('NO')
  elif len(S) % 3 == 1:
    if (m[0][1]==n+1) and (m[1][1]==n) and (m[2][1]==n):
      print('YES')
    else:
      print('NO')
  else:
    if (m[0][1]==n+1) and (m[1][1]==n+1) and (m[2][1]==n):
      print('YES')
    else:
      print('NO')

# Example run
# Input:
e3zvshd]
# Output:
NO
s = input()
a = 0
b = 0
c = 0
for i in s:
    if i == "a":
        a += 1
    if i == "b":
        b += 1
    if i == "c":
        c += 1

if max(a,b,c)-min(a,b,c) <= 1:
    print("YES")
else:
    print("NO")


# Example run
# Input:
M/X&w)
# Output:
YES
from collections import Counter

S = input()
c = Counter(S)

if len(c) == 3 and max(c.values()) - min(c.values()) <= 1:
    print("YES")
elif len(c) == 2 and max(c.values()) == min(c.values()):
    print("YES")
elif len(c) == 1:
    print("YES")
else:
    print("NO")


# Example run
# Input:
[TJ
# Output:
YES
from collections import Counter

c = Counter([*input()])
if len(c) <= 2:
    print("NO")
else:
    dif = c.most_common()[0][1] - c.most_common()[2][1]
    print("YES" if dif<=1 else "NO")

# Example run
# Input:
0NxWAS
# Output:
YES
from collections import Counter
S = input()
l = Counter(S)
a = l["a"]
b = l["b"]
c = l["c"]
if max(a, b, c) - min(a, b, c) > 1:
    print("NO")
else:
    print("YES")

# Example run
# Input:
.SD+<7;cq
# Output:
YES
s = input()
print("NO" if len(s) == 3 else "YES")

# Example run
# Input:
=vd`C^/f+
# Output:
YES
s=input()
a=s.count("a")
b=s.count("b")
c=s.count("c")
if max(a,b,c)-min(a,b,c)<=1:
  print("YES")
else:
  print("NO")

# Example run
# Input:
vbzVv
# Output:
YES
s = list(str(input()))
count_0 = s.count("a")
count_1 = s.count("b")
count_2 = s.count("c")
max_c = max(count_0, count_1, count_2)
if abs(max_c - count_0) < 2 and abs(max_c - count_1) < 2 and abs(max_c - count_2) < 2:
    print("YES")
else:
    print("NO")

# Example run
# Input:
u{kD)1)Qb
# Output:
YES
S = input()
ABC = [S.count(s) for s in "abc"]
if max(ABC)- min(ABC) <= 1:
    print("YES")
else:print("NO")

# Example run
# Input:
0}}x#m
# Output:
YES
s = input()

d = dict()
for a in s:
    d[a] = d.get(a, 0) + 1

if len(d) == 1:
    print("YES")
    exit()

if len(d) < 3 and sum(d.values()) > 2:
    print("NO")
    exit()

t = [i - (min(d.values())) for i in d.values()]

if max(t) - min(t) > 1:
    print("NO")
else:
    print("YES")

# Example run
# Input:
jj+
# Output:
NO
s = input()
abc = [s.count("a"),s.count("b"),s.count("c")]
if max(abc)-min(abc)<=1:
  print("YES")
else:
  print("NO")

# Example run
# Input:
7lD
# Output:
YES
from collections import Counter


def main():
    s = input()
    count = list(Counter(list(s)).items())
    even = 0
    even_l = []
    odd = 0
    odd_l = []
    is_possible = True
    for _, n in count:
        if n % 2 == 0:
            even += 1
            even_l.append(n)
        else:
            odd += 1
            odd_l.append(n)
    even_l.sort()
    odd_l.sort()
    if len(s) % 2 == 0:
        if odd == 0 and sum(even_l[:-1]) < even_l[-1]:
            is_possible = False
    else:
        if sum(odd_l) < sum(even_l):
            is_possible = False
    print("YES" if is_possible else "NO")


if __name__ == '__main__':
    main()



# Example run
# Input:
-2.4790525815280387e-112
# Output:
YES
S = [s for s in str(input())]
d = len(S) // 3
from collections import Counter
cntr = sorted(list(Counter(S).values()))
if cntr == [d,d,d] or cntr == [d,d,d+1] or cntr == [d,d+1,d+1]:
  print('YES')
else:
  print('NO')

# Example run
# Input:
.SD+<
# Output:
NO
def ok(s):
    a = b = c = 0
    for ch in s:
        if ch == 'a': a += 1
        if ch == 'b': b += 1
        if ch == 'c': c += 1
    return abs(a - b) <= 1 and abs(b - c) <= 1 and abs(c - a) <= 1

s = input()
if ok(s):
    print('YES')
else:
    print('NO')

# Example run
# Input:
W'fMa)B=
# Output:
YES
S=input()
N=len(S)
from collections import Counter
C=Counter(S)
mn=N
mx=0
for c in ['a','b','c']:
    mx=max(mx,C[c])
    mn=min(mn,C[c])
print('YES' if mx-mn<=1 else 'NO')

# Example run
# Input:
*G\fQJ\
# Output:
YES
s = input()
a = s.count("a")
b = s.count("b")
c = s.count("c")
k = (a > 0) + (b > 0) + (c > 0)
if k == 1:
    print("NO")
    exit()
elif k == 2:
    if len(s) == 2:
        print("YES")
    else:
        print("NO")
    exit()
else:
    if a == b and b == c:
        print("YES")
    else:
        print("NO")

# Example run
# Input:
ulQ
# Output:
YES
from collections import Counter
from itertools import combinations
s = input()
sc = Counter(s)
if len(sc.keys()) == 1:
    if len(s) == 1:
        print('YES')
    else:
        print('NO')
elif len(sc.keys()) == 2:
    if len(s) == 2:
        print('YES')
    else:
        print('NO')
else:
    ans = 'YES'
    for i,j in combinations(sc.values(),2):
        if abs(i-j) > 1:
            ans = 'NO'
            break
    print(ans)

# Example run
# Input:
nan
# Output:
NO
from collections import Counter
s = input()
dic = dict(Counter(s))
if len(dic)==1:
    for v in dic.values():
        if v==1:
            print('YES')
        else:
            print('NO')
elif len(dic)==2:
    for v in dic.values():
        if v>=2:
            print('NO')
            break
    else:
        print('YES')
else:
    a = dic['a']
    b = dic['b']
    c = dic['c']
    if a==b==c:
        print('YES')
    elif a==b and abs(b-c)<=1:
        print('YES')
    elif b==c and abs(c-a)<=1:
        print('YES')
    elif c==a and abs(a-b)<=1:
        print('YES')
    else:
        print('NO')

# Example run
# Input:
6
# Output:
YES
S=input()
from collections import Counter
c=Counter(S).most_common()
x=[i[1] for i in c]
l,k=len(S),len(c)
if k==1:
    y=[1]
elif k==2:
    y=[1,1]
else:
    y=[(l+2)//3,(l+1)//3,l//3]
print('YES' if x==y else 'NO')

# Example run
# Input:
<"=U6
# Output:
NO
from collections import Counter
X= input()
S = Counter(X)
if len(S.keys()) == 3:
    if max(S.values()) - min(S.values()) >= 2:
        print("NO")
    else:
        print("YES")
if len(S.keys()) == 2:
    if max(S.values()) - min(S.values()) >= 1:
        print("NO")
    else:
        print("YES")
if len(S.keys()) == 1:
    if len(X) == 1:
        print("YES")
    else:
        print("NO")

# Example run
# Input:
-1351531223
# Output:
from collections import Counter
S = str(input())
CS = Counter(S)
V = list(CS.values())
ans = 'YES'
if len(V) == 1:
  ans = 'NO'
elif len(V) == 2:
  if V[0] >= V[1]+1:
    ans = 'NO'
else:
  if V[0]-V[2] > 1 or V[1]-V[2] > 1 or V[0]-V[1] > 1:
    ans = 'NO'

print(ans)


# Example run
# Input:
-8.696501326380391e+30
# Output:
YES
s = input()
n = len(s)

dic = {}
for i in range(n):
    if s[i] in dic:
        dic[s[i]] += 1
    else:
        dic[s[i]] = 1

if len(dic) == 1:
    if n == 1:
        print('YES')
    else:
        print('NO')
elif len(dic) == 2:
    if n == 2:
        print('YES')
    else:
        print('NO')
else:
    maxi = max(dic.values())
    mini = min(dic.values())
    if maxi - mini <= 1:
        print('YES')
    else:
        print('NO')

# Example run
# Input:
-9.136833366899127e-50
# Output:
NO
S = input()
c = sorted([S.count('a'), S.count('b'), S.count('c')])
if c[2] - c[0] <= 1:
  print("YES")
else:
  print("NO")


# Example run
# Input:
l[aA$[><G
# Output:
YES
S = input()
a = S.count("a")
b = S.count("b")
c = S.count("c")
print("YES" if max(a, b, c) - min(a, b, c) <= 1 else "NO")

# Example run
# Input:
W1LpB+C
# Output:
YES
s=input()
import collections
p=collections.Counter(s)
#print(p[max(p)])
if len(p)==3:
    if p[max(p,key=p.get)]-p[min(p,key=p.get)]<2:
        print("YES")
    else:
        print("NO")
if len(p)==2:
    if p[max(p,key=p.get)]>1:
        print("NO")
    else:
        print("YES")
if len(p)==1:
    if p[max(p,key=p.get)]==1:
        print("YES")
    else:
        print("No")

# Example run
# Input:
815520
# Output:
s = input()

a = s.count("a")
b = s.count("b")
c = s.count("c")

if max(a, b, c) - min(a, b, c) <= 1:
  print("YES")
else:
  print("NO")

# Example run
# Input:
>x#!w6b>
# Output:
YES
from collections import Counter
s = input()
c = Counter(s)


x = abs(c['a'] - c['b'])
y = abs(c['a'] - c['c'])
z = abs(c['b'] - c['c'])

if max(x, y, z) < 2:
    print('YES')
else:
    print('NO')

# Example run
# Input:
],.2
# Output:
YES
s = input()
a = sorted([s.count('a'), s.count('b'), s.count('c')])
print("YES" if a[1]-a[0]<=1 and a[2]-a[1]<=1 and not a[0]<a[1]<a[2] else "NO")

# Example run
# Input:
<E[f}
# Output:
YES
s = input()

A = s.count("a")
B = s.count("b")
C = s.count("c")

if max(A,B,C) - min(A,B,C) <= 1:
    print("YES")
else:
    print("NO")

# Example run
# Input:
7P~
# Output:
YES
from collections import Counter
S = input()
CS = Counter(S)
a = CS["a"]
b = CS["b"]
c = CS["c"]
a, b, c = sorted([a,b,c])
if a == 0 and b == 0:
    if c == 1:
        print("YES")
    else:
        print("NO")
elif a == 0:
    if c <= 1:
        print("YES")
    else:
        print("NO")
else:
    if c-a<=1:
        print("YES")
    else:
        print("NO")


# Example run
# Input:
akum)9k0
# Output:
YES
from collections import Counter
S = str(input())
CS = Counter(S)
V = list(CS.values())
ans = 'YES'

if V.count(0) == 2:
  ans = 'NO'
elif V.count(0) <= 1:
  if V[0] >= 2*V[1]:
    ans = 'NO'
else:
  if V[0] >= 2*V[1] and V[0] >= 6*V[2]:
    ans = 'NO'

print(ans)

# Example run
# Input:
3NH\]P
# Output:
YES
S = input()

dic = {}

for s in S:
    dic[s] = dic.get(s, 0) + 1

L = dic.values()
sum_L = sum(L)
max_n = max(L)
min_n = min(L)

if (sum_L - max_n) // 2 == min_n:
    if max_n == min_n:
        print('No')
    else:
        print('Yes')
elif max_n == 1 and sum_L == 1:
    print('Yes')
else:
    print('No')

# Example run
# Input:
s?jyi97
# Output:
No
import collections

S = input()

C = collections.Counter(S)

for _ in 'abc':
    if _ not in C:
        C[_] = 0

M, m = max(C.values()), min(C.values())

print('YES' if M-m < 2 else 'NO')


# Example run
# Input:
#("Ua
# Output:
YES
s = input()
a = s.count('a')
b = s.count('b')
c = s.count('c')
if max(abs(a - b), abs(b - c), abs(a - c)) > 1:
    print('NO')
else:
    print('YES')

# Example run
# Input:
eP$0[
# Output:
YES
from collections import Counter
S = input()
counter = Counter(S)
for c in ["a", "b", "c"]:
    if c not in counter:
        counter[c] = 0
if (max(counter.values()) - min(counter.values())) <= 1:
    print("YES")
else:
    print("NO")

# Example run
# Input:
[TJ
# Output:
YES
S=input()
a=S.count("a")
b=S.count("b")
c=S.count("c")
if abs(a-b)<=1 and abs(b-c)<=1 and abs(c-a)<=1:
    print("YES")
else:
    print("NO")


# Example run
# Input:
[%CW?37ZP
# Output:
YES
s = input()
a_cnt = s.count('a')
b_cnt = s.count('b')
c_cnt = s.count('c')
if max(a_cnt, b_cnt, c_cnt) <= min(a_cnt, b_cnt, c_cnt) + 1:
    ans = 'YES'
else:
    ans = 'NO'
print(ans)

# Example run
# Input:
TI~ET:$
# Output:
YES
s = list(str(input()))
# 2文字と3文字で場合分けしてみる
jud = len(set(s))
jud_s = list(set(s))

if jud == 1:
    print("YES")
elif jud == 2:
    count_0 = s.count(jud_s[0])
    count_1 = s.count(jud_s[1])
    if count_0 * 2 == count_1 or count_1 * 2 == count_0:
        print("NO")
    else:
        print("YES")


else:
    count_0 = s.count(jud_s[0])
    count_1 = s.count(jud_s[1])
    count_2 = s.count(jud_s[2])
    if count_0 * 2 == count_1 == count_2 or count_1 * 2 == count_0 == count_2 or count_2 * 2 == count_0 == count_1:
        print("NO")
    else:
        print("YES")

# Example run
# Input:
(:s!syT!
# Output:
NO
from collections import Counter
S = input()
counter = Counter(S)
ca, cb, cc = counter['a'], counter['b'], counter['c']
cabc = [ca, cb, cc]
if max(cabc) - min(cabc) <= 1:
    print('YES')
else:
    print('NO')

# Example run
# Input:
0CAqT-:
# Output:
YES
import collections

s = list(input())

ss = set(s)

if 2 < len(ss):
    print('YES')
else:
    c = collections.Counter(s)
    score_sorted = sorted(c.items(), key=lambda x:-x[1])
    if 1 < score_sorted[0][1]:
        print('NO')
    else:
        print('YES')

# Example run
# Input:
-65934
# Output:
YES
s=list(input())
a=s.count("a")
b=s.count("b")
c=s.count("c")
x=min([a,b,c])
a-=x
b-=x
c-=x
if a>1 or b>1 or c>1:
    print("NO")
else:
    print("YES")


# Example run
# Input:
LJq\
# Output:
YES
from collections import Counter
def solve():
    s = list(input())
    
    abc = Counter(s)
    
    if len(abc.values()) < 3:
        if sum(abc.values()) < 3:
            return 'YES'

        return 'NO'
    else:
        m = min(abc.values())
        two = []
        for i in abc.values():
            if i-m != 0:
                two.append(i-m)
        
        if len(s) == 0 or len(s) == 2:
            if sum(two) <= 2:
                return 'YES'
        else:
            if sum(two) <= 1:
                return 'YES'

        return 'NO'

print(solve())


# Example run
# Input:
3.724352976922704e+32
# Output:
NO
s = input()
a = s.count('a')
b = s.count('b')
c = s.count('c')
mx = max(a,b,c)
mn = min(a,b,c)
if len(s)==1:
    print('YES')
elif len(s)==2 and mx==1:
    print('YES')
elif mx-mn<=1 and a+b+c -mx -mn*2 <=1:
    print('YES')
else:
    print('NO')

# Example run
# Input:
'y?HeBTk
# Output:
YES
s=list(input())
n=len(s)
if len(set(s))==1:
    print("No")
    exit()
    
x,y,z=0,0,0

for i in s:
    if i=="a":
        x+=1
    elif i=="b":
        y+=1
    else:
        z+=1
lis=[x,y,z]

if n%2==0:
    
    lis=sorted(lis,reverse=True)
    if lis[0]>sum(lis[1:])+1:
        print("No")
    else:
        print('Yes')
else:
    if len(set(s))==2:
        print("No")
    else:
        for i in lis:
            if i%2==1:
                odd=i
        for i in lis:
            if i%2==0:
                if i<odd-1 or odd+1<i:
                    print("No")
                    exit()
        print("Yes")


# Example run
# Input:
9'r
# Output:
No
S = input()

a = S.count("a")
b = S.count("b")
c = S.count("c")
m = max(a,b,c)

if m-a <= 1 and m-b <= 1 and m-c <= 1 :
    print("YES")
else :
    print("NO")

# Example run
# Input:
G9$uz\!r(
# Output:
YES
s = list(str(input()))
# 2文字と3文字で場合分けしてみる
jud = len(set(s))
jud_s = list(set(s))

if jud == 1:
    print("NO")
elif jud == 2:
    count_0 = s.count(jud_s[0])
    count_1 = s.count(jud_s[1])
    if count_0 * 2 == count_1 or count_1 * 2 == count_0:
        print("NO")
    else:
        print("YES")


else:
    count_0 = s.count(jud_s[0])
    count_1 = s.count(jud_s[1])
    count_2 = s.count(jud_s[2])
    if count_0 * 2 == count_1 == count_2 or count_1 * 2 == count_0 == count_2 or count_2 * 2 == count_0 == count_1:
        print("NO")
    else:
        print("YES")

# Example run
# Input:
B41C+:dG
# Output:
YES
def mycounter(d,i):
    if i in d:
        d[i]+=1
    else:
        d[i]=1
    return d
s=input()
d=dict()
for i in s:
    d=mycounter(d,i)
l=-(-len(s)//3)
for i in d.values():
    if l<i:
        print('No')
        exit()
print('Yes')

# Example run
# Input:
-1087992429980.8044
# Output:
Yes
S = input()
if len(S) == 1:
    print('YES')
    exit()
if len(set(list(S))) == 1 or (len(set(list(S))) == 2 and len(S) != 2):
    print('NO')
    exit()
cnt = [S.count('a'),S.count('b'),S.count('c')]
if max(cnt)-min(cnt) <= 1:
    print('YES')
else:
    print('NO')

# Example run
# Input:
8r+|E
# Output:
YES
import collections
S=input()
dic=collections.defaultdict(int)
for i in range(len(S)):
  dic[S[i]]+=1
smax=[0,"d"]
for i in dic:
  if dic[i] > smax[0]:
    smax=[dic[i],i]
    
if sum(dic.values()) - smax[0]> smax[0]:
  if smax[0] - min(dic.values()) <= 1:
    print("YES")
    exit(0)

print("NO")


# Example run
# Input:
-8.799030987960761e-56
# Output:
NO
from collections import Counter
S = input()
c = list(Counter(S).values())

ans = "YES"
if len(c) == 1:
    if c[0] > 1:
        ans = "NO"
elif len(c) == 2:
    x, y = c
    if x != y:
        ans = "NO"
else:
    c.sort()
    if c[2] - c[0] > 1 or c[2] - c[0] > 1:
        ans = "NO"
print(ans)


# Example run
# Input:
pAFA?7b@
# Output:
YES
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

from collections import Counter

s = input()
C = Counter(s)

a = C["a"]
b = C["b"]
c = C["c"]

li = [a,b,c]
li.sort()

if li[-1] > li[0]+li[1]:
    print("NO")
else:
    print("YES")

# Example run
# Input:
hxe
# Output:
YES
import collections
s = list(input())
tmp = len(set(s))
c = collections.Counter(s).most_common()
if (c[0][1] >= c[-1][1] + 2 and tmp == 3) or (tmp == 2) or (tmp == 1 and len(s) != 1):
    print('NO')
else:
    print('YES')


# Example run
# Input:
ZduM,J,B`
# Output:
YES
from collections import Counter

s=Counter(input())
b,s=max(s.values()),min(s.values())
if b-s<=1: print("YES")
else: print("NO")

# Example run
# Input:
1.3675062472339184e-89
# Output:
NO
s = input()
a = s.count("a")
b = s.count("b")
c = s.count("c")
if max(a,b,c) - min(a,b,c) <= 1:
  print("YES")
else:
  print("NO")

# Example run
# Input:
e3zvshd]
# Output:
YES
# python3.4.2用
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def lprint(l): print(*l, sep='\n')
def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

S = input()

a_count = S.count("a")
b_count = S.count("b")
c_count = S.count("c")

if abs(a_count - b_count) <= 1 and abs(b_count-c_count) <= 1 and abs(c_count-a_count) <= 1:
    print('YES')
else:
    print('NO')

# Example run
# Input:
`B)goR
# Output:
YES
s = input()
cnt = [s.count("a"),s.count("b"), s.count("c")]
cnt.sort()
cnt = list(set(cnt))
if len(cnt) == 2 and cnt[1]-cnt[0] == 1: ans = "YES"
else: ans = "NO"
print(ans)

# Example run
# Input:
Gz8zI?
# Output:
NO
def main():
    S = input()
    N = len(S)
    a = S.count("a")
    b = S.count("b")
    c = S.count("c")
    ma = max(a, b, c)
    mi = min(a, b, c)
    if ma - mi > 1:
        print("NO")
    else:
        print("YES")


if __name__ == '__main__':
    main()


# Example run
# Input:
fX_C`P
# Output:
YES
import sys
from collections import  Counter
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7



def main():
    S = input()
    count = Counter(S)
    count['a'] += 0
    count['b'] += 0
    count['c'] += 0
    if max(count.values()) - min(count.values()) <= 1:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()

# Example run
# Input:
\dkGQ
# Output:
YES