ZhenlongDai/ACPR huggingface dataset:
Problem: p03688
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
input = sys.stdin.readline

N = int(input())
a = list(map(int, input().split()))
m, n = max(a), min(a)
if m - n > 1 or m >= N:
    print('No')
elif m - n == 0:
    if n == N - 1 or n * 2 <= N:
        print('Yes')
    else:
        print('No')
elif m - n == 1:
    if a.count(n) == 1:
        print('Yes')
    else:
        print('No')

Failing test case input:
5
3 4 3 4 3

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline

N = int(input())
a = list(map(int, input().split()))
m, n = max(a), min(a)
if m - n > 1 or m >= N:
    print('No')
elif m - n == 0:
    print('Yes' if n == N - 1 or n * 2 <= N else 'No')
else:
    print('Yes' if 1 <= m - a.count(n) <= a.count(m)

Problem: p03688
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
N = int(input())

a= list(map(int,input().split()))


X = Counter(a)
if(len(X) >2 ):
    print("No")
    exit()

min_val = min(a)
max_val = max(a)
if not min_val == max_val-1 and  not min_val==max_val:
    print("No")
    exit()

a.sort()


unique_cat = X[min_val]


last_cat =  N- unique_cat

last_colors = max_val - unique_cat

if 2*last_colors <= last_cat and not (last_cat>0 and last_colors==0)\
        and last_colors>0:
    print("Yes")
else:
    print("No")

Failing test case input:
4
2 2 2 2

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
from collections import Counter
N = int(input())

a= list(map(int,input().split()))


X = Counter(a)

min_val = min(a)
max_val = max(a)
if not min_val == max_val-1 and not min_val==max_val:
    print("No")
    exit()
if max_val==min_val and max_val == N-1:
    
    print("Yes")
    exit()


unique_cat = X[min_val] if min_val!=max_val else 0


last_cat =  N- unique_cat
last_colors = max_val - unique_cat



if last_cat>0 and last_colors <=0:
    print("No")
elif  0< 2*last_colors <= last_cat:
    print("Yes")

else:
    print("No")

Problem: p03688
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n = int(input())
A = list(int(x) for x in input().split())

ma = max(A)
mi = min(A)

if ma - mi > 1:
    print("No")
    exit()

if ma == mi:
    if n >= ma * 2 or n == ma + 1:
        print("Yes")
    else:
        print("No")
    exit()


if A.count(mi) <= mi and A.count(ma) >= ma * 2:
    print("Yes")
else:
    print("No")

Failing test case input:
5
3 4 3 4 3

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
n = int(input())
A = list(int(x) for x in input().split())

ma = max(A)
mi = min(A)

if ma - mi > 1:
    print("No")
    exit()

if ma == mi:
    if n >= ma * 2 or n == ma + 1:
        print("Yes")
    else:
        print("No")
    exit()


if A.count(mi) <= mi and A.count(ma) >= (ma - A.count(mi)) * 2:
    print("Yes")
else:
    print("No")
Problem: p03688
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
input = sys.stdin.readline

N = int(input())
a = list(map(int, input().split()))
m, n = max(a), min(a)
if m - n > 1 or m >= N:
    print('No')
elif m - n == 0:
    print('No' if n == N - 1 or n * 2 <= N else 'Yes')
else:
    print('Yes' if a.count(n) == n else 'No')

Failing test case input:
4
2 2 2 2

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline

N = int(input())
a = list(map(int, input().split()))
m, n = max(a), min(a)
if m - n > 1 or m >= N:
    print('No')
elif m - n == 0:
    print('Yes' if n == N - 1 or n * 2 <= N else 'No')
else:
    print('Yes' if 1 <= m - a.count(n) <= a.count(m)

Problem: p03688
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
a = list(map(int, input().split()))
M = max(a)
m = min(a)
if M > m + 1:
    print("No")
else:
    if M == m:
        if M == N-1:
            print("Yes")
        elif M*2 <= N:
            print("Yes")
        else:
            print("No")

    else:
        if a.count(M) > 2:
            print('No')
        else:
            
            c = a.count(m)
            if (M - c) * 2 < N-c and c < M:  
                print("Yes")
            else:
                print("No")


Failing test case input:
5
3 4 3 4 3

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
N = int(input())
a = list(map(int, input().split()))
M = max(a)
m = min(a)
if M > m + 1:
    print("No")
else:
    if M == m:
        if M == N-1:
            print("Yes")
        elif M*2 <= N:
            print("Yes")
        else:
            print("No")

    else:
        
        c = a.count(m)
        if (M - c) * 2 <= N-c and c < M:  
            print("Yes")
        else:
            print("No")

Problem: p03688
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
A = list(map(int,input().split()))

A.sort()
v = len(set(A))
if v > 2:
    print('No')
elif v == 1:
    if A[0]*2 <= n or A[0] == n-1:
        print('Yes')
    else:
        print('No')
else:
    x = A.index(A[-1])
    y = A[0] - x + 1
    if y > 0 and y*2 <= n-x:
        print('Yes')
    else:
        print('No')


Failing test case input:
4
2 4 4 2

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
n = int(input())
A = list(map(int,input().split()))

A.sort()
v = A[-1] - A[0]
if v >= 2:
    print('No')
elif v == 0:
    if A[0]*2 <= n or A[0] == n-1:
        print('Yes')
    else:
        print('No')
else:
    x = A.index(A[-1])
    y = A[0] - x + 1
    if y > 0 and y*2 <= n-x:
        print('Yes')
    else:
        print('No')
Problem: p03688
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):

N=int(input())
A=list(map(int,input().split()))
min_,max_=min(A),max(A)

def f(n,k):
    return n%k==2 if k>0 else False

ans=None
if max_-min_ > 1:
    ans=False
elif max_-min_ == 1:
    k=max_
    nk=len([a for a in A if a==max_])
    nk1=N-nk
    ans=f(nk,k-nk1)
else:
    ans=f(N,min_)

if ans is True:
    print("Yes")
else:
    print("No")


Failing test case input:
5
3 4 3 4 3

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
N=int(input())
A=list(map(int,input().split()))
min_,max_=min(A),max(A)

def f(n,k):
    return n%k==0 if k>0 else False

ans=None
if max_-min_ > 1:
    ans=False
elif max_-min_ == 1:
    k=max_
    nk=len([a for a in A if a==max_])
    nk1=N-nk
    ans=f(nk,k-nk1)
else:
    ans=f(N,min_) or f(N,min_+1)

if ans is True:
    print("Yes")
else:
    print("No")

Problem: p03688
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
if max(a)-1<min(a):exit(print("No"))
if len(set(a))==1:
  m=a[0]
  if m==n-1 or 2*m<=n:print("Yes")
  else:print("No")
else:
  x=a.count(min(a))
  y=n-x
  if x<max(a) and 2*(max(a)-x)<=y:print("Yes")
  else:print("No")

Failing test case input:
4
2 2 2 2

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
if max(a)-min(a)>=2:exit(print("No"))
if len(set(a))==1:
  m=a[0]
  if m==n-1 or 2*m<=n:print("Yes")
  else:print("No")
else:
  x=a.count(min(a))
  y=n-x
  if x<max(a) and 2*(max(a)-x)<=y:print("Yes")
  else:print("No")

Problem: p03688
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
fewer = 0
if max(a) - min(a) >= 2:
  print("No")
else:
  if min(a) == max(a):
    if min(a) == n-1:
      print("Yes")
    else:
      if min(a) <= n/2:
        print("Yes")
      else:
        print("No")
  else:
    for i in range(n):
      if a[i] == min(a):
        fewer += 1
    more = n - fewer
    num_remain = max(a) - fewer
    if num_remain <= more/2:
      print("Yes")
    else:
      print("No")

Failing test case input:
5
3 4 3 3 3

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
m = min(a)
M = max(a)
num_m = 0
num_M = 0
if M - m >= 2:
  print("No")
else:
  if m == M:
    if m == n-1:
      print("Yes")
    else:
      if m <= n/2:
        print("Yes")
      else:
        print("No")
  else:
    for i in range(n):
      if a[i] == m:
        num_m += 1
    more = n - num_m
    num_remain = M - num_m
    if 0 < num_remain <= more/2:
      print("Yes")
    else:
      print("No")
Problem: p03688
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
cats = list(map(int,input().split()))
flag = True
p, q = max(cats), min(cats)
if p > q + 1:
    flag = False
elif p == q:
    if n - p > 1 and n != p * 2:
        flag = False
else:
    if cats.count(q) * 2 > cats.count(p):
        flag = False

if flag:
    print("Yes")
else:
    print("No")

Failing test case input:
5
3 4 3 4 3

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
n = int(input())
cats = list(map(int,input().split()))
flag = True
p, q = max(cats), min(cats)
x = cats.count(p)
y = cats.count(q)
if p - q >= 2:
    flag = False
elif p == q:
    if p != n - 1 and p * 2 > n:
        flag = False
else:
    if y >= p or (p-y) * 2 > x:
        flag = False

if flag:
    print("Yes")
else:
    print("No")

Problem: p03688
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N = int(input())
a = list(map(int, input().split()))
if max(a) - min(a) >= 2:
    print("No")
    exit()
else:
    M = max(a)
    m = min(a)
    if M == m:
        if m <= N / 2 or m == N - 1:
            print("Yes")
        else:
            print("No")
    else:
        if a.count(m) >= M or a.count(M) < 2 * a.count(m):
            print("No")
        else:
            print("Yes")

Failing test case input:
5
3 4 3 4 3

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
N = int(input())
a = list(map(int, input().split()))
if max(a) - min(a) >= 2:
    print("No")
    exit()
else:
    M = max(a)
    m = min(a)
    if M == m:
        if m <= N / 2 or m == N - 1:
            print("Yes")
        else:
            print("No")
    else:
        if a.count(m) >= M or a.count(M) + 2 * a.count(m) < 2 * M:
            print("No")
        else:
            print("Yes")

Problem: p03688
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, *a = map(int, open(0).read().split())
M = max(a)
mcnt = a.count(M - 1)
Mcnt = a.count(M)
if Mcnt + mcnt == n:
	if mcnt == 0:
		if 2 * Mcnt <= n or M == n - 1:
			print("Yes")
			exit()
	else:
		if 0 < 2 * (M - mcnt) <= n - mcnt:
			print("Yes")
			exit()
print("No")

Failing test case input:
4
2 2 2 2

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
n, *a = map(int, open(0).read().split())
M = max(a)
mcnt = a.count(M - 1)
Mcnt = a.count(M)
if Mcnt + mcnt == n:
	if mcnt == 0:
		if 2 * M <= n or M == n - 1:
			print("Yes")
			exit()
	else:
		if 0 < 2 * (M - mcnt) <= n - mcnt:
			print("Yes")
			exit()
print("No")
Problem: p03688
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))
b = list(a)
b.sort()
if b[n-1]-b[0] >=2:
    print("No")
else:
    b = sum(a)%n
    c = int((sum(a)-b)/n)
    if b == 0:
        if 2*c >= n:
            print("No")
        else:
            print("Yes")
    else:
        if b == 1:
            print("No")
        else:
            if n - b/2 >= c+1:
                print("Yes")
            else:
                print("No")

Failing test case input:
4
2 2 2 2

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))
b = list(a)
b.sort()
if b[n-1]-b[0] >=2:
    print("No")
else:
    b = sum(a)%n
    c = int((sum(a)-b)/n)
    if b == 0:
        if 2*c > n and n != c+1:
            print("No")
        else:
            print("Yes")
    else:
        if b == 1:
            print("No")
        else:
            if n - b/2 >= c+1 and n <= c+b:
                print("Yes")
            else:
                print("No")

Problem: p03688
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
cats = list(map(int,input().split()))
flag = True
p, q = max(cats), min(cats)
x = cats.count(p)
y = cats.count(q)
if p > q + 1:
    flag = False
elif p == q:
    if n - p > 1 and p * 2 > n:
        flag = False
else:
    if x >= p or (p-x) * 2 > y:
        flag = False

if flag:
    print("Yes")
else:
    print("No")

Failing test case input:
5
4 3 4 3 4

Expected output:
No

Actual output:
Yes


Fixed submission (verdict: Accepted):
n = int(input())
cats = list(map(int,input().split()))
flag = True
p, q = max(cats), min(cats)
x = cats.count(p)
y = cats.count(q)
if p - q >= 2:
    flag = False
elif p == q:
    if p != n - 1 and p * 2 > n:
        flag = False
else:
    if y >= p or (p-y) * 2 > x:
        flag = False

if flag:
    print("Yes")
else:
    print("No")

Problem: p03688
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
input = sys.stdin.readline

N = int(input())
a = list(map(int, input().split()))
m, n = max(a), min(a)
if m - n > 1 or m >= N:
    print('No')
elif m - n == 0:
    print('Yes' if n == N - 1 or n * 2 <= N else 'No')
else:
    print('No' if a.count(n) == n else 'Yes')

Failing test case input:
5
3 4 3 4 3

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline

N = int(input())
a = list(map(int, input().split()))
m, n = max(a), min(a)
if m - n > 1 or m >= N:
    print('No')
elif m - n == 0:
    print('Yes' if n == N - 1 or n * 2 <= N else 'No')
else:
    print('Yes' if 1 <= m - a.count(n) <= a.count(m)
Problem: p03688
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
a.sort()
if a[-1] - a[0] > 1:
    print('No')
    exit()
elif a[-1] - a[0] == 1:
    actual = a[-1]
    if actual >= n:
        print('No')
    elif a[actual-1] == a[-1]:
        print('Yes')
    else:
        print('No')
    exit()
elif a[-1] - a[0] == 0:
    solve = False
    actual = a[0]
    if n >= actual * 2 or n-1 == actual:
        solve = True
    if solve:
        print('Yes')
    else:
        print('No')
    exit()
else:
    print('No')

Failing test case input:
5
4 3 4 3 4

Expected output:
No

Actual output:
Yes


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
a.sort()

cnt = 0
for i in range(n):
    if a[i] == a[0]:
        cnt = i+1
    else:
        break

if a[-1] - a[0] > 1:
    print('No')
    exit()
elif a[-1] - a[0] == 1:
    actual = a[-1]
    if actual >= n:
        print('No')
    elif cnt <= actual - 1 and actual <= cnt  + (n - cnt) 
        print('Yes')
    else:
        print('No')
    exit()
elif a[-1] - a[0] == 0:
    solve = False
    actual = a[0]
    if n >= actual * 2 or n-1 == actual:
        solve = True
    if solve:
        print('Yes')
    else:
        print('No')
    exit()
else:
    print('No')

Problem: p03688
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())

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



if a[-1]-a[0]>1:
	print("No")
else:
	
	for i in range(1,N):
		
		if a[i]!=a[0]:
			if 1<=a[-1]-i<=int((N-i)/2):
				print("Yes")
			else:
				print("No")
			break
	else:
		
		if 1<=a[0]<=int(N/2):
			print("No")
		else:
			print("Yes")

Failing test case input:
4
2 2 2 2

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
N=int(input())

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



if a[-1]-a[0]>1:
	print("No")
else:
	
	for i in range(1,N):
		
		if a[i]!=a[0]:
			if 1<=a[-1]-i<=int((N-i)/2):
				print("Yes")
			else:
				print("No")
			break
	else:
		
		if 1<=a[0]<=int(N/2) or a[0]==N-1:
			print("Yes")
		else:
			print("No")
Problem: p03688
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))

minColor = min(A)
maxColor = max(A)

if minColor == maxColor:
    if minColor == N - 1:  
        print('Yes')
    elif minColor * 2 <= N:  
        print('Yes')
    else:
        print('No')
    exit()

minCnt = 0
maxCnt = 0

for a in A:
    if a == minColor:
        minCnt += 1
    elif a == maxColor:
        maxCnt += 1
    else:
        print('No')
        exit()

if (maxColor - minCnt) * 2 <= maxCnt and minCnt == maxCnt - 1 and N - minCnt >= 2:
    print('Yes')
else:
    print('No')


Failing test case input:
5
3 4 3 4 3

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))

minColor = min(A)
maxColor = max(A)

if minColor == maxColor:
    if minColor == N - 1:  
        print('Yes')
    elif minColor * 2 <= N:  
        print('Yes')
    else:
        print('No')
    exit()

if minColor + 1 != maxColor:
    print('No')
    exit()

minCnt = 0
maxCnt = 0

for a in A:
    if a == minColor:
        minCnt += 1
    elif a == maxColor:
        maxCnt += 1
    else:
        print('No')
        exit()





if (maxColor - minCnt) * 2 <= maxCnt and maxColor >= minCnt + 1:
    print('Yes')
else:
    print('No')

Problem: p03688
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
L = list(map(int, input().split()))
ans = "Yes"

L_max = max(L)
L_min = min(L)

if L_max - L_min >= 2:
    ans = "No"
else:
    num_alone = L.count(L_min)
    not_alone_L = [v-num_alone for v in L if v == L_max]
    if not_alone_L[0] < 0 or len(not_alone_L) < not_alone_L[0]*2:
        ans = "No"
print(ans)


Failing test case input:
5
3 4 3 3 3

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
L = list(map(int, input().split()))
ans = "Yes"

L_max = max(L)
L_min = min(L)

if L_max - L_min >= 2:
    ans = "No"
elif L_max == L_min:
    if not(N >= L[0]*2 or L[0] == N-1):
        ans = "No"
else:
    num_alone = L.count(L_min)
    not_alone_L = [v-num_alone for v in L if v == L_max]
    if not_alone_L[0] <= 0 or len(not_alone_L) < not_alone_L[0]*2:
        ans = "No"
print(ans)

Problem: p03688
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
if max(a)-2<=min(a):exit(print("No"))
if len(set(a))==1:
  m=a[0]
  if m==n-1 or 2*m<=n:print("Yes")
  else:print("No")
else:
  x=a.count(min(a))
  y=n-x
  if x<max(a) and 2*(max(a)-x)<=y:print("Yes")
  else:print("No")

Failing test case input:
3
2 -1 0

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
if max(a)-min(a)>=2:exit(print("No"))
if len(set(a))==1:
  m=a[0]
  if m==n-1 or 2*m<=n:print("Yes")
  else:print("No")
else:
  x=a.count(min(a))
  y=n-x
  if x<max(a) and 2*(max(a)-x)<=y:print("Yes")
  else:print("No")
Problem: p03688
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
ca=dict(Counter(a))
if len(ca.keys())>2:
  print('No')
elif len(ca.keys())==1:
  if 2*a[0]<=n:
    print('Yes')
  else:
    print('No')
else:
  c=max(ca.keys())
  d=min(ca.keys())
  print('y')
  



Failing test case input:
3
4 -1 -1

Expected output:
No


Actual output:
y


Fixed submission (verdict: Accepted):
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
ca=dict(Counter(a))
if len(ca.keys())>2:
  print('No')
elif len(ca.keys())==1:
  if 2*a[0]<=n or a[0]==n-1:
    print('Yes')
  else:
    print('No')
else:
  c=max(ca.keys())
  d=min(ca.keys())
  
  
  if c!=d+1:
    print('No')
  else:
    tmp=c-ca[d]
    
    if tmp>0 and 2*tmp<=ca[c]:
      print('Yes')
    else:
      print('No')

Problem: p03688
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = [int(a) for a in input().split()]

A.sort()
flag = True
for a in A:
    if a > A[0]+1:
        flag = False

if flag:
    cnt = A.count(A[0])
    if cnt == N and (A[0] == N-1 or A[0]*2 <= N):
        ans = "Yes"
    elif cnt <= A[0] and N-cnt >= 2*A[0]:
        ans = "Yes"
    else:
        ans = "No"
else:
    ans = "No"
print(ans)

Failing test case input:
5
3 4 3 4 3

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
N = int(input())
A = [int(a) for a in input().split()]

A.sort()
flag = True
for a in A:
    if a > A[0]+1:
        flag = False

ans = "No"
if flag:
    cnt = A.count(A[0])
    if cnt == N and (A[0] == N-1 or A[0]*2 <= N):
        ans = "Yes"
    elif cnt == A[0] and cnt < N-1:
        ans = "Yes"
    elif cnt < A[0] and N-cnt >= 2*(A[0]-cnt+1):
        ans = "Yes"
        
print(ans)

Problem: p03688
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
A=[int(i) for i in input().split()]
k=len(set(A))
if k==1:
  if A[0]==n-1 or 2*A[0]<=n:
    print("Yes")
  else:
    print("No")
else:
  ma=min(A)
  ct=0
  for a in A:
    if a==ma:
      ct+=1
  if ma+1>ct and (ma+1-ct)*2<=n-ct:
    print("Yes")
  else:
    print("No")

Failing test case input:
3
1 15 42

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
A=[int(i) for i in input().split()]
k=len(set(A))
if k==1:
  if A[0]==n-1 or 2*A[0]<=n:
    print("Yes")
  else:
    print("No")
elif k>2:
  print("No")
else:
  ma=min(A)
  Ma=max(A)
  if Ma-ma>1:
    print("No")
  else:
    ct=0
    for a in A:
      if a==ma:
        ct+=1
    if ma+1>ct and (ma+1-ct)*2<=n-ct:
      print("Yes")
    else:
      print("No")
Problem: p03688
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

def solve():
  n = int(input())
  a = list(int(i) for i in input().split())
  ans = 'YES'
  alone = 0
  group = 0
  if max(a) - min(a) >= 2: ans = 'NO'
  
  elif max(a) - min(a) == 1:
   for i in a:
     if i == max(a)-1 : alone += 1
     else: group += 1
   if alone < max(a) and 2*(max(a)-alone)<= group: pass
   else: ans = 'NO'
  
  
  elif max(a) - min(a) == 0:
    if a[0] == n-1 or 2*a[0] <= n:
      pass
    else: ans = 'NO'
  return ans

if __name__ == '__main__':
  print(solve())

Failing test case input:
3
-1 1 8

Expected output:
No


Actual output:
NO


Fixed submission (verdict: Accepted):

def solve():
  n = int(input())
  a = list(int(i) for i in input().split())
  ans = 'Yes'
  alone = 0
  group = 0
  ha = max(a)
  la = min(a)
  if ha - la >= 2: ans = 'No'
  
  elif ha - la == 1:
   for i in a:
     if i == ha-1 : alone += 1
     else: group += 1
   if alone < ha and 2*(ha-alone)<= group: pass
   else: ans = 'No'
  
  
  elif ha - la == 0:
    if a[0] == n-1 or 2*a[0] <= n:
      pass
    else: ans = 'No'
  return ans

if __name__ == '__main__':
  print(solve())

Problem: p03688
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
def printans(t):
    print(t)
    sys.exit()

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

if all([a==A[0] for a in A]):
    shurui=A[0]
    if shurui==N-1 or shurui*2<=N:
        printans("Yes")
    else:printans("No")
else:
    maxshurui = max(A)
    if all([a in (maxshurui,maxshurui-1) for a in A]):
        unique = A.count(maxshurui-1)
        shurui = maxshurui-unique
        if shurui<=0:
            printans("No")
        if shurui*2<=N-unique:
            printans("Yes")
        else:printans("No")

Failing test case input:
3
-2 1 8

Expected output:
No


Actual output:

Fixed submission (verdict: Accepted):
import sys
def printans(t):
    print(t)
    sys.exit()

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

if all([a==A[0] for a in A]):
    shurui=A[0]
    if shurui==N-1 or shurui*2<=N:
        printans("Yes")
    else:printans("No")
else:
    maxshurui = max(A)
    if all([a in (maxshurui,maxshurui-1) for a in A]):
        unique = A.count(maxshurui-1)
        shurui = maxshurui-unique
        if shurui<=0:
            printans("No")
        if shurui*2<=N-unique:
            printans("Yes")
        else:printans("No")
    else:printans("No")
Problem: p03688
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
m=map(int,input().split())
a=[int(i) for i in m]
d=max(a)-min(a)
if d>1:
    ans=False
elif d==0:
    if (max(a)<len(a) and max(a)*2>=len(a)):
        ans=True
    else:
        ans=False
else:
    max_num=a.count(max(a))
    min_num=a.count(min(a))
    dif=max(a)-min_num
    if (min_num<max(a) and dif*2<=max_num):
            ans=True
    else:
        ans=False
        
if ans:
    print("Yes")
else:
    print("No")

Failing test case input:
5
3 4 3 4 3

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
n=input()
m=map(int,input().split())
a=[int(i) for i in m]
d=max(a)-min(a)
if d>1:
    ans=False
elif d==0:
    if (max(a)==len(a)-1 or max(a)*2<=len(a)):
        ans=True
    else:
        ans=False
else:
    max_num=a.count(max(a))
    min_num=a.count(min(a))
    dif=max(a)-min_num
    if (min_num<max(a) and dif*2<=max_num):
            ans=True
    else:
        ans=False
        
if ans:
    print("Yes")
else:
    print("No")

Problem: p03688
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
L = list(map(int, input().split()))
ans = "Yes"

L_max = max(L)
L_min = min(L)

if L_max - L_min >= 2:
    ans = "No"
else:
    num_alone = L.count(L_min)
    not_alone_L = [v-num_alone for v in L if v == L_max]
    if not_alone_L[0] <= 0 or len(not_alone_L) < not_alone_L[0]*2:
        ans = "No"
print(ans)


Failing test case input:
4
2 2 2 2

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
L = list(map(int, input().split()))
ans = "Yes"

L_max = max(L)
L_min = min(L)

if L_max - L_min >= 2:
    ans = "No"
elif L_max == L_min:
    if not(N >= L[0]*2 or L[0] == N-1):
        ans = "No"
else:
    num_alone = L.count(L_min)
    not_alone_L = [v-num_alone for v in L if v == L_max]
    if not_alone_L[0] <= 0 or len(not_alone_L) < not_alone_L[0]*2:
        ans = "No"
print(ans)

Problem: p03688
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
N=int(input())
a=[int(i) for i in input().split()]
a.sort()

if a[N-1]-a[0]>1:
  print("No")
  sys.exit()
if a[0]==N-1:
  print("Yes")
  sys.exit()
if a[N-1]==1:
  print("Yes")
  sys.exit()
if a[0]==a[N-1]:
  if 2*a[0]<=N:
    print("Yes")
  else:
    print("No")
  sys.exit()

count=a.index(a[N-1])
if a[0]<=count:
  print("Yes")
else:
  print("No")

Failing test case input:
5
3 4 3 3 3

Expected output:
No


Actual output:
Yes


Fixed submission (verdict: Accepted):
import sys
N=int(input())
a=[int(i) for i in input().split()]
a.sort()

if a[N-1]-a[0]>1:
  print("No")
  sys.exit()
if a[0]==N-1:
  print("Yes")
  sys.exit()
if a[N-1]==1:
  print("Yes")
  sys.exit()
if a[0]==a[N-1]:
  if 2*a[0]<=N:
    print("Yes")
  else:
    print("No")
  sys.exit()

count=a.index(a[N-1])
if count+1<=a[N-1] and a[N-1]<=count+int((N-count)/2):
  print("Yes")
else:
  print("No")
Problem: p03688
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
c = Counter(a)
if len(c)>2: print("No")
elif len(c)==1:
	if a[0]+1==n or n>=2*a[0]: print("Yes")
	else: print("No")
elif c[a[-1]]>=2*a[-1]: print("Yes")
else: print("No")

Failing test case input:
5
3 4 3 4 3

Expected output:
Yes


Actual output:
No


Fixed submission (verdict: Accepted):
from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
c = Counter(a)
if len(c)>2 or a[0]+1<a[-1]: print("No")
elif len(c)==1:
	if a[0]+1==n or n>=2*a[0]: print("Yes")
	else: print("No")
else:
	x,y = c[a[-1]],c[a[0]]
	if y+1<=a[-1]<=x
	else: print("No")
Problem: p03808
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
lis = list(map(int,input().split()))
if sum(lis) % n != 0:
  print("NO")
  exit()
num = sum(lis) 
li = [lis[i] -lis[i-1] -num for i in range(n)]
ans = 0
for i in range(n):
  if li[i] % n != 0:
    print("NO")
    exit()
  ans += li[i] 
if ans == num:
  print("YES")
else:
  print("NO")

Failing test case input:
5
6 9 12 10 8

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
n=int(input())
lis=list(map(int,input().split()))
num=(n*(n+1))
ll=sum(lis)
if ll%num!=0:
  print("NO")
  exit()
ans=0
for i in range(n):
  if abs(lis[i]-lis[i-1]-ll
    print("NO")
    exit()
  ans+=abs(lis[i]-lis[i-1]-ll
if ans == ll
else:print("NO")

Problem: p03808
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = [int(m) for m in input().split()]
p = []
for i in range(n):
    if i == n - 1:
        p.append(a[0] - a[n - 1])
    else:
        p.append(a[i + 1] - a[i])

k = sum(a) 
m = []
for i in range(n):
    mi = (k - p[i]) 
    if int(mi) != mi:
        print("NO")
        exit()
    else:
        m.append(mi)

if sum(m) == k:
    print("YES")
else:
    print("NO")

Failing test case input:
5
4 5 1 2 3

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
n = int(input())
a = [int(m) for m in input().split()]
p = []
for i in range(n):
    if i == n - 1:
        p.append(a[0] - a[n - 1])
    else:
        p.append(a[i + 1] - a[i])

k = sum(a) / ((n * (n + 1)) 
if int(k) != k:
    print("NO")
    exit()
m = []
for i in range(n):
    mi = (k - p[i]) / n
    if int(mi) != mi or mi < 0:
        print("NO")
        exit()
    else:
        m.append(mi)

if sum(m) == k:
    print("YES")
else:
    print("NO")

Problem: p03808
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
A = list(map(int, input().split()))
k = sum(A) 
d = [a1 - a2 + k for a1, a2 in zip(A, A[1:] + A[0:1])]
for di in d:
    if di % n:
        print('NO')
        break
else:
    print('YES')

Failing test case input:
5
6 9 12 10 8

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
n = int(input())
A = list(map(int, input().split()))
k = sum(A) / (n * (n + 1) 
d = [a2 - a1 - k for a1, a2 in zip(A, A[1:] + A[0:1])]
for di in d:
    if di > 0 or di % n:
        print('NO')
        break
else:
    print('YES')

Problem: p03808
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
tot = sum(a)
f = tot*2 
l = [0]*n
for i in range(n-1):
  l[i] = a[i+1] - a[i] - f
l[-1] = a[0] - a[n-1] - f
for x in l:
  if x > 0 or x%n:
    print("NO")
    break
else:
  print("YES")

Failing test case input:
5
6 9 12 10 8

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
k = sum(a) 
if n*(n+1)*k 
  print('NO'); exit(0)
b = [a[i] - a[i-1] - k for i in range(n)]
for x in b:
  if x > 0 or x%n: print('NO'); break
else:
  print('YES')
Problem: p03808
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):


import sys

N = int(input())

A = list(map(int,input().split()))

M = N*(N+1)

if sum(A) % M != 0:
    print ("NO")
    sys.exit()

able = sum(A) 



A.append(A[0])
now = 0

for i in range(N):

    if A[i+1] - A[i] == able:
        continue

    else:
        
        if ((A[i+1]-A[i])-able) % (0-N) != 0:
            print ("NO")
            sys.exit()

        else:
            now += ((A[i+1]-A[i])-able) 


if now <= able:
    print ("YES")
else:
    print ("NO")


Failing test case input:
5
4 5 1 2 3

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):


import sys

N = int(input())

A = list(map(int,input().split()))

M = N*(N+1)

if sum(A) % M != 0:
    print ("NO")
    sys.exit()

able = sum(A) 



A.append(A[0])
now = 0

for i in range(N):

    

    if A[i+1] - A[i] == able:
        continue

    else:
        
        if ((A[i+1]-A[i])-able) % N != 0 or ((A[i+1]-A[i])-able) 
            print ("NO")
            sys.exit()

        else:
            now += ((A[i+1]-A[i])-able) 


if now == able:
    print ("YES")
else:
    print ("NO")

Problem: p03808
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

n = getN()
nums = getList()

n_operate = sum(nums) 

v_valid = n_operate
v_sign = n

for i, j in zip(nums, nums[1:] + [nums[0]]):
    diff = j - i
    if (v_valid - diff) % v_sign != 0:
        print("NO")
        sys.exit()
    n_operate -= (v_valid - diff) 

if n_operate == 0:
    print("YES")
else:
    print("NO")

Failing test case input:
5
6 9 12 10 8

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

n = getN()
nums = getList()
if sum(nums) % ((n * (n+1)) 
    print("NO")
    sys.exit()
n_operate = sum(nums) 

v_valid = n_operate
v_sign = n

for i, j in zip(nums, nums[1:] + [nums[0]]):
    diff = j - i
    if diff > v_valid:
        print("NO")
        sys.exit()
    if (v_valid - diff) % v_sign != 0:
        print("NO")
        sys.exit()
    n_operate -= (v_valid - diff) 
    
if n_operate == 0:
    print("YES")
else:
    print("NO")
Problem: p03808
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    nn = (n*(n+1))
    sum_ = sum(a)
    a += [a[0]]
    cnt = sum_
    if sum_ % nn != 0:
        print("NO")
        return 0
    ans = 0
    for i in range(n):
        p = a[i]-a[i+1]+cnt
        if p % n != 0:
            print("NO")
            break
        ans += p
    if ans == cnt:
        print("YES")
    else:
        print("NO")


main()


Failing test case input:
5
4 5 1 2 3

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    nn = (n*(n+1))
    sum_ = sum(a)
    a += [a[0]]
    cnt = sum_
    if sum_ % nn != 0:
        print("NO")
        return 0
    ans = 0
    for i in range(n):
        p = a[i]-a[i+1]+cnt
        if p % n != 0 or p
            print("NO")
            return 0
        ans += p
    if ans == cnt:
        print("YES")
    else:
        print("NO")


main()

Problem: p03808
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


import sys


INF = float('inf')
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 LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    A = LI()

    
    k = sum(A) 

    A.append(A[0])
    diff = []
    for a1, a2 in zip(A[:-1], A[1:]):
        diff.append(a2 - a1)

    
    

    
    return 'YES' if not any([(d - k) % n for d in diff]) else 'NO'


print(main())


Failing test case input:
5
6 9 12 10 8

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):


import sys


INF = float('inf')
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 LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    A = LI()

    
    k, mod = divmod(sum(A), (n * (n + 1) 
    if mod:
        return 'NO'

    A.append(A[0])
    diff = []
    for a1, a2 in zip(A[:-1], A[1:]):
        diff.append(a2 - a1)

    
    

    
    return 'YES' if not any([(d - k) % n or d > k for d in diff]) else 'NO'


print(main())
Problem: p03808
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
input = sys.stdin.buffer.readline
N = int(input())
a = list(map(int, input().split()))
d = [0] * N
for i in range(1, N):
  d[i] = a[i] - a[i - 1]
d[0] = a[0] - a[-1]
f = 0
m = sum(a) 
c = 0
for i in range(N):
  c += (m - d[i]) 
  if c == m:
    f = 1
  else: f = 0
if c == 0:
  r = m
if c > m:
  l = m
if f:
  print("YES")
else: print("NO")

Failing test case input:
5
4 5 1 2 3

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.buffer.readline
N = int(input())
a = list(map(int, input().split()))
d = [0] * N
for i in range(1, N):
  d[i] = a[i] - a[i - 1]
d[0] = a[0] - a[-1]
if sum(a) % (N * (N + 1) 
  print("NO")
  exit(0)
f = 0
m = sum(a) 
c = 0
for i in range(N):
  if m - d[i] < 0 or (m - d[i]) % N:
    f = 0
    break
  c += (m - d[i]) 
  if c == m:
    f = 1
  else: f = 0
if c == 0:
  r = m
if c > m:
  l = m
if f:
  print("YES")
else: print("NO")

Problem: p03808
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
input = sys.stdin.buffer.readline
N = int(input())
a = list(map(int, input().split()))
d = [0] * N
for i in range(1, N):
  d[i] = a[i] - a[i - 1]
d[0] = a[0] - a[-1]
l = min(a) 
r = max(a)
f = 0
for _ in range(100):
  m = int((l + r) / 2)
  if m == 0: break
  t = [m] * N
  c = 0
  for i in range(N):
    if (t[i] - d[i]) % N: break
    c += (t[i] - d[i]) 
    if c == m:
      f = 1
    else: f = 0
  if f: break
  if c == 0:
    r = m
  if c > m:
    l = m
if f: print("YES")
else: print("NO")

Failing test case input:
5
6 9 12 10 8

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.buffer.readline
N = int(input())
a = list(map(int, input().split()))
d = [0] * N
for i in range(1, N):
  d[i] = a[i] - a[i - 1]
d[0] = a[0] - a[-1]
if sum(a) % (N * (N + 1) 
  print("NO")
  exit(0)
f = 0
m = sum(a) 
c = 0
for i in range(N):
  if m - d[i] < 0 or (m - d[i]) % N:
    f = 0
    break
  c += (m - d[i]) 
  if c == m:
    f = 1
  else: f = 0
if c == 0:
  r = m
if c > m:
  l = m
if f:
  print("YES")
else: print("NO")

Problem: p03808
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int, input().split()))
m = sum(a) 
d = [0] * n
for i in range(n):
    if i == n - 1:
        d[i] = a[0] - a[i] - m
    else:
        d[i] = a[i + 1] - a[i] - m
for i in d:
    if i % n:
        print("NO")
        exit()
print("YES")

Failing test case input:
5
6 9 12 10 8

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int, input().split()))
if sum(a) % ((1 + n) * n 
    print("NO")
else:
    m = sum(a) 
    d = [0] * n
    for i in range(n):
        d[i] = a[(i + 1) % n] - a[i] - m
    for i in d:
        if i % n or i > 0:
            print("NO")
            exit()
    if -sum(d) == n * m:
        print("YES")
    else:
        print("NO")
Problem: p03808
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = list(map(int,input().split()))

s = sum(a)
one = n * (n+1) 
if s % one:
    print('NO')
    exit()
times = s 

cnt = 0
b = a[1:]+[a[0]]
for i,j in zip(a,b):
    dif = j - i
    if (times - dif) % n:
        print('NO')
        exit()
    cnt += (times-dif) 
if times != cnt:
    print('NO')
else:
    print('YES')


Failing test case input:
5
6 9 12 10 8

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
n = int(input())
a = list(map(int,input().split()))

s = sum(a)
one = n * (n+1) 
if s % one:
    print('NO')
    exit()
times = s 

cnt = 0
b = a[1:]+[a[0]]
for i,j in zip(a,b):
    dif = j - i
    if (times - dif) % n:
        print('NO')
        exit()
    if (times-dif) 
        print('NO')
        exit()
    cnt += (times-dif) 
if times != cnt:
    print('NO')
else:
    print('YES')

Problem: p03808
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N=int(input())
a=[int(i) for i in input().split()]
k=sum(a)
D=[]
a.append(a[0])
for i in range(N):
  D.append(a[i+1]-a[i]-k)

for d in D:
  if d%N!=0:
    print("NO")
    exit()
print("YES")
    
  


Failing test case input:
5
6 9 12 10 8

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
N=int(input())
a=[int(i) for i in input().split()]
S=sum(a)
if S%(N*(N+1)
  k=S
else:
  print("NO")
  exit()
D=[]
a.append(a[0])
for i in range(N):
  D.append(a[i+1]-a[i]-k)

for d in D:
  if d>0 or d%N!=0:
    print("NO")
    exit()
    
print("YES")

Problem: p03808
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    nn = (n*(n+1))
    sum_ = sum(a)
    a += [a[0]]
    cnt = sum_
    if sum_ % nn != 0:
        print("NO")
        return 0
    ans = 0
    ans2 = 0
    for i in range(n):
        p = a[i]-a[i+1]+cnt
        ans2 += p 
        if p % n != 0:
            print("NO")
            break
        ans += p
    if ans <= cnt:
        print("YES")
    else:
        print("NO")


main()


Failing test case input:
5
4 5 1 2 3

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    nn = (n*(n+1))
    sum_ = sum(a)
    a += [a[0]]
    cnt = sum_
    if sum_ % nn != 0:
        print("NO")
        return 0
    ans = 0
    for i in range(n):
        p = a[i]-a[i+1]+cnt
        if p % n != 0 or p
            print("NO")
            return 0
        ans += p
    if ans == cnt:
        print("YES")
    else:
        print("NO")


main()
Problem: p03808
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
A = list(map(int, input().split()))
k = sum(A) 
d = [a2 - a1 - k for a1, a2 in zip(A, A[1:] + A[0:1])]
for di in d:
    if di > 0 or di % n:
        print('NO')
        break
else:
    print('YES')

Failing test case input:
5
4 5 1 2 3

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
n = int(input())
A = list(map(int, input().split()))
k = sum(A) / (n * (n + 1) 
d = [a2 - a1 - k for a1, a2 in zip(A, A[1:] + A[0:1])]
for di in d:
    if di > 0 or di % n:
        print('NO')
        break
else:
    print('YES')

Problem: p03808
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

k = sum(A)
D = [0]*N
for i in range(N-1):
    D[i] = A[i+1]-A[i]
D[-1] = A[0]-A[-1]

for i in range(N):
    D[i] -= k

if all(x <= 0 and x % N == 0 for x in D):
    print("YES")
else:
    print("NO")


Failing test case input:
5
4 5 1 2 3

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def solve():
    N = int(input())
    A = list(map(int, input().split()))

    k = sum(A)
    if sum(A) % (N*(N+1)
        return "NO"

    D = [0]*N
    for i in range(N-1):
        D[i] = A[i+1]-A[i]-k
    D[-1] = A[0]-A[-1]-k

    cnt = sum([v
    if all(x <= 0 and -x % N == 0 for x in D)and -cnt == k:
        return "YES"
    else:
        return "NO"


print(solve())

Problem: p03808
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    nn = (n*(n+1))
    sum_ = sum(a)
    a += [a[0]]
    cnt = sum_
    if sum_ % nn != 0:
        print("NO")
        return 0
    ans = 0
    for i in range(n):
        p = a[i]-a[i+1]+cnt
        if p % n != 0:
            print("NO")
            return 0
        ans += p
    if ans == cnt:
        print("YES")
    else:
        print("NO")


main()


Failing test case input:
5
4 5 1 2 3

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    nn = (n*(n+1))
    sum_ = sum(a)
    a += [a[0]]
    cnt = sum_
    if sum_ % nn != 0:
        print("NO")
        return 0
    ans = 0
    for i in range(n):
        p = a[i]-a[i+1]+cnt
        if p % n != 0 or p
            print("NO")
            return 0
        ans += p
    if ans == cnt:
        print("YES")
    else:
        print("NO")


main()
Problem: p03808
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
A = list(map(int, input().split()))
k = sum(A) 
d = [a1 - a2 + k for a1, a2 in zip(A, A[1:] + A[0:1])]
for di in d:
    if di >= 0 and di % n:
        print('NO')
        break
else:
    print('YES')

Failing test case input:
5
6 9 12 10 8

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
n = int(input())
A = list(map(int, input().split()))
k = sum(A) / (n * (n + 1) 
d = [a2 - a1 - k for a1, a2 in zip(A, A[1:] + A[0:1])]
for di in d:
    if di > 0 or di % n:
        print('NO')
        break
else:
    print('YES')

Problem: p03808
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
D = [A[i + 1] - A[i] for i in range(N - 1)] + [A[0] - A[N - 1]]
k = int(sum(A) * 2 / N / (N + 1))
for d in D:
    if d - k > 0 or (d - k) % N != 0:
        print(d - k)
        print("NO")
        exit()

print("YES")


Failing test case input:
5
2 0 8 6 0

Expected output:
NO


Actual output:
-3
NO


Fixed submission (verdict: Accepted):
N = int(input())
A = list(map(int, input().split()))
D = [A[i + 1] - A[i] for i in range(N - 1)] + [A[0] - A[N - 1]]
k = int(sum(A) / (N * (N + 1) / 2))
if sum(A) % (N * (N + 1) / 2) != 0:
    print("NO")
    exit()

for d in D:
    if d - k > 0 or (d - k) % N != 0:
        print("NO")
        exit()

print("YES")

Problem: p03808
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
A = [int(x) for x in input().split()]

ok = True
S = sum(A)
T = (1+N) * N 
if S % T != 0:
    ok = False
else:
    t = S 
    for i in range(N):
        a0, a1 = A[i-1], A[i]
        if -(a1 - a0 - t) % N != 0:
            ok = False
            break
YESNO = lambda tf: print('YES') if tf else print('NO')
YESNO(ok)

Failing test case input:
5
4 5 1 2 3

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
N = int(input())
A = [int(x) for x in input().split()]

ok = True
S = sum(A)
T = (1+N) * N 
if S % T != 0:
    ok = False
else:
    t = S 
    count = 0
    for i in range(N):
        a0, a1 = A[i-1], A[i]
        if -(a1 - a0 - t) < 0:
            ok = False
            break
        if -(a1 - a0 - t) % N != 0:
            ok = False
            break
        count += -(a1 - a0 - t) 
YESNO = lambda tf: print('YES') if tf else print('NO')
YESNO(ok and S
Problem: p03808
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
a = [int(m) for m in input().split()]
p = []
for i in range(n):
    if i == n - 1:
        p.append(a[0] - a[n - 1])
    else:
        p.append(a[i + 1] - a[i])

k = sum(a) 
m = []
for i in range(n):
    mi = (k - p[i]) / n
    if int(mi) != mi:
        print("NO")
        exit()
    else:
        m.append(mi)

if sum(m) == k:
    print("YES")
else:
    print("NO")

Failing test case input:
5
6 9 12 10 8

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
n = int(input())
a = [int(m) for m in input().split()]
p = []
for i in range(n):
    if i == n - 1:
        p.append(a[0] - a[n - 1])
    else:
        p.append(a[i + 1] - a[i])

k = sum(a) / ((n * (n + 1)) 
if int(k) != k:
    print("NO")
    exit()
m = []
for i in range(n):
    mi = (k - p[i]) / n
    if int(mi) != mi or mi < 0:
        print("NO")
        exit()
    else:
        m.append(mi)

if sum(m) == k:
    print("YES")
else:
    print("NO")

Problem: p03808
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


import sys


INF = float('inf')
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 LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    A = LI()

    
    k = sum(A) 

    A.append(A[0])
    diff = []
    for a1, a2 in zip(A[:-1], A[1:]):
        diff.append(a2 - a1)

    
    

    
    return 'YES' if not any([-(d - k) % n or d > k for d in diff]) else 'NO'


print(main())


Failing test case input:
5
6 9 12 10 8

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):


import sys


INF = float('inf')
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 LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    A = LI()

    
    k, mod = divmod(sum(A), (n * (n + 1) 
    if mod:
        return 'NO'

    A.append(A[0])
    diff = []
    for a1, a2 in zip(A[:-1], A[1:]):
        diff.append(a2 - a1)

    
    

    
    return 'YES' if not any([(d - k) % n or d > k for d in diff]) else 'NO'


print(main())