ZhenlongDai/ACPR huggingface dataset:
Problem: p02647
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N, K = [int(x) for x in input().split(' ')]
A = [int(x) for x in input().split(' ')]

S = A
D = [0] * len(S)
for _ in range(K):
  for x in range(N):
    D[x] = 0
  for x in range(N):
    D[max(0, x - S[x])] += 1
    if(x + S[x] + 1 < N):
      D[x + S[x] + 1] -= 1
  S[0] = D[0]
  for x in range(1, N):
    S[x] = S[x-1] + D[x]
      
print(S)
    

Failing test case input:
5 0
0 1 1 0 1

Expected output:
0 1 1 0 1


Actual output:
[0, 1, 1, 0, 1]


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

S = A
D = [0] * N
for _ in range(K):
  for x in range(N):
    D[x] = 0
  for x in range(N):
    D[max(0, x - S[x])] += 1
    if(x + S[x] + 1 < N):
      D[x + S[x] + 1] -= 1
  S[0] = D[0]
  for x in range(1, N):
    S[x] = S[x-1] + D[x]
  if all([x == N for x in S]):
    break
      
print(' '.join([str(x) for x in S]))

Problem: p02647
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import math

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

for i in range(min(math.ceil(math.log(N)), K)):
  B = [0] * N
  for n, A_n in enumerate(A):
    B_min = max(0, n-A_n)
    b_max = min(N-1, n+A_n)
    B[B_min] += 1
    if b_max+1 < N:
      B[b_max+1] -= 1
  
  sum = 0
  for n in range(len(A)):
    sum += B[n]
    A[n] = sum

print(" ".join(list(map(str, A))))

Failing test case input:
5 6
0 1 0 4 0

Expected output:
5 5 5 5 5


Actual output:
3 3 5 5 3


Fixed submission (verdict: Accepted):
import math

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

for i in range(min(41, K)):
  B = [0] * N
  for n, A_n in enumerate(A):
    B_min = max(0, n-A_n)
    b_max = min(N-1, n+A_n)
    B[B_min] += 1
    if b_max+1 < N:
      B[b_max+1] -= 1
  
  sum = 0
  for n in range(len(A)):
    sum += B[n]
    A[n] = sum

print(" ".join(list(map(str, A))))

Problem: p02647
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import math
def update(A,N):
    B=[0 for i in range(N+1)]

    for i in range(N):
        l = max(0,i-A[i])
        r = min(N,i+A[i]+1)
        B[l]+=1
        B[r]-=1
    A[0]=B[0]
    for i in range(1,N):
        B[i]+=B[i-1]
        A[i]=B[i]

def resolve():
    N,M = map(int,input().split())
    A = list(map(int,input().split()))
    for i in range(min(M,1+int(math.log2(N)))):
        update(A,N)
    print(" ".join(map(str,A)))
resolve()

Failing test case input:
5 6
0 1 0 4 0

Expected output:
5 5 5 5 5


Actual output:
4 5 5 5 4


Fixed submission (verdict: Accepted):
def update(A,N):
    B=[0 for i in range(N+1)]

    for i in range(N):
        l = max(0,i-A[i])
        r = min(N,i+A[i]+1)
        B[l]+=1
        B[r]-=1
    x = A[0] == B[0]
    A[0]=B[0]
    for i in range(1,N):
        B[i]+=B[i-1]
        x = x and A[i] == B[i]
        A[i]=B[i]
    return x

def resolve():
    N,M = map(int,input().split())
    A = list(map(int,input().split()))
    for i in range(M):
        x=update(A,N)
        if x:
            break
    print(" ".join(map(str,A)))
resolve()
Problem: p02647
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
from itertools import accumulate

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

    for _ in range(K):
        arr = [0]*(N+1)
        for i, a in enumerate(A):
            left = max(0, i-a)
            right = min(N, i+a+1)
            arr[left] += 1
            arr[right] -= 1
        
        A = list(accumulate(arr[:-1]))
        if all(a == N for a in A):
           break

    print(*A[:-1], sep=" ")



if __name__ == "__main__":
    main()

Failing test case input:
5 2
1 0 0 2 1

Expected output:
3 4 4 4 4


Actual output:
3 4 4 4


Fixed submission (verdict: Accepted):
from itertools import accumulate

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

    for _ in range(K):
        arr = [0]*(N+1)
        for i, a in enumerate(A):
            left = max(0, i-a)
            right = min(N, i+a+1)
            arr[left] += 1
            arr[right] -= 1
        
        A = list(accumulate(arr[:-1]))
        if all(a == N for a in A):
           break

    print(*A, sep=" ")



if __name__ == "__main__":
    main()

Problem: p02647
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N,K = map(int,input().split())
A = list(map(int,input().split()))

def simulate():
    global A
    B = [0]*N
    for i in range(N):
        l = max(0, i-A[i])
        r = min(N-1, i+A[i])
        B[l] += 1
        if r+1 < N:
            B[r+1] -= 1
    for i in range(1,N):
        B[i] += B[i-1]
    if sum(B) == N*K:
        print(*[N]*N)
        print('aaaa')
        exit()
    A = B

for k in range(min(K,43)):
    simulate()
print(*A)

Failing test case input:
5 2
0 1 0 1 1

Expected output:
3 4 5 3 3


Actual output:
5 5 5 5 5
aaaa


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

def simulate():
    global A
    B = [0]*N
    for i in range(N):
        l = max(0, i-A[i])
        r = min(N-1, i+A[i])
        B[l] += 1
        if r+1 < N:
            B[r+1] -= 1
    for i in range(1,N):
        B[i] += B[i-1]
    
    
    
    
    A = B

for k in range(min(K,43)):
    simulate()
print(*A)

Problem: p02647
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):

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

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



cnt = 0

while cnt < k:
    imos = [0] * (n + 1)
    for i in range(n):
        imos[max(i - a[i], 0)] += 1
        imos[min(i + a[i] + 1, n)] -= 1
    for i in range(n):
        imos[i + 1] += imos[i]
    a = imos[0:n]
    cnt += 1
    if max(a) == n:
        break
print(*a)


Failing test case input:
5 6
0 1 0 4 0

Expected output:
5 5 5 5 5


Actual output:
3 3 5 5 3


Fixed submission (verdict: Accepted):

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

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



cnt = 0

while cnt < k:
    imos = [0] * (n + 1)
    for i in range(n):
        imos[max(i - a[i], 0)] += 1
        imos[min(i + a[i] + 1, n)] -= 1
    for i in range(n):
        imos[i + 1] += imos[i]
    a = imos[0:n]
    cnt += 1
    if min(a) == n:
        break
print(*a)
Problem: p02647
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import math

def action(A, N):
  B = [0] * N
  for i in range(N):
    s = max(0, math.ceil(i - A[i] - 0.5))
    e = min(N, math.ceil(i + A[i] + 0.5))
    for j in range(s, e):
      B[j] += 1 
  return B

def main():
  N, K = map(int, input().split())
  A = [int(s) for s in input().split()]

  for i in range(41):
    A = action(A, N)
      
  print(A)

if __name__ == '__main__':
  main()

Failing test case input:
5 0
0 1 1 1 1

Expected output:
0 1 1 1 1


Actual output:
[5, 5, 5, 5, 5]


Fixed submission (verdict: Accepted):
def action(A, N):
  B = [0] * N
  for i, bright in enumerate(A):
    s = max(0, i - bright)
    B[s] += 1
    e = min(N, i + bright)
    if e < N - 1:
      B[e + 1] -= 1
  
  for i in range(N - 1):
    B[i + 1] += B[i]
  return B

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

  for i in range(K):
    A = action(A, N)
    if (A[0] == N) & all(A):
      break
      
  print(*A, sep=" ")

if __name__ == '__main__':
  main()

Problem: p02647
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import math
from itertools import accumulate
n, k = map(int, input().split())
As = list(map(int, input().split()))
_n = math.floor(math.log(n,2)) + 1
for i in range(min(_n, k)):
  _As = [0]*(n+1)
  for j in range(n):
    l = max(0, j - As[j])
    r = min(n - 1, j + As[j])
    _As[l] += 1
    _As[r+1] -= 1
  As = list(accumulate(_As))[:-1]
print(' '.join(map(lambda x:str(x),As)))

Failing test case input:
5 6
0 1 0 4 0

Expected output:
5 5 5 5 5


Actual output:
4 5 5 5 4


Fixed submission (verdict: Accepted):
import math
from itertools import accumulate
n, k = map(int, input().split())
As = list(map(int, input().split()))
for i in range(min(41, k)):
  _As = [0]*(n+1)
  for j in range(n):
    l = max(0, j - As[j])
    r = min(n - 1, j + As[j])
    _As[l] += 1
    _As[r+1] -= 1
  As = list(accumulate(_As))[:-1]
print(' '.join([str(A) for A in As]))

Problem: p02647
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n,k,*l=map(int,open(0).read().split())
for _ in range(min(k,99)):
  s=[0]*(n+1)
  for i in range(n):
    s[max(i-l[i],0)]+=1
    s[min(i+l[i]+1,n)]-=1
  l[0]=min(s[0],n)
  for i in range(1,n):
    l[i]=min(l[i-1]+s[i],n)
print(l)

Failing test case input:
5 2
1 0 0 2 1

Expected output:
3 4 4 4 4


Actual output:
[3, 4, 4, 4, 4]


Fixed submission (verdict: Accepted):
n,k,*l=map(int,open(0).read().split())
for _ in range(min(k,99)):
  s=[0]*(n+1)
  for i in range(n):
    s[max(i-l[i],0)]+=1
    s[min(i+l[i]+1,n)]-=1
  l[0]=min(s[0],n)
  for i in range(1,n):
    l[i]=min(l[i-1]+s[i],n)
print(*l)
Problem: p02647
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N, K = map(int, input().split())
A = list(map(int, input().split()))
A = A + [0]

if K >= N:
    ans = [N] * N
    print(*ans)

else:
    for i in range(K):
        tmp = [0] * (N + 1)
        for j in range(N):
            
            end_l = max(j - A[j], 0)
            end_r = min(j + A[j] + 1, N)
            tmp[end_l] += 1
            tmp[end_r] -= 1

        for j in range(1, N):
            tmp[j] += tmp[j - 1]
            A[j] = tmp[j]
        A[0] = tmp[0]

print(*A[:N])

Failing test case input:
5 6
0 1 0 4 0

Expected output:
5 5 5 5 5


Actual output:
5 5 5 5 5
0 1 0 4 0


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())
A = list(map(int, input().split()))
A = A + [0]

if K >= N - 1:
    ans = [N] * N
    print(*ans)

else:
    for i in range(K):
        tmp = [0] * (N + 1)
        
        for j in range(N):
            end_l = max(j - A[j], 0)
            end_r = min(j + A[j] + 1, N)
            
            tmp[end_l] += 1
            tmp[end_r] -= 1
        
        flg = tmp[0]
        
        for j in range(1, N):
            tmp[j] += tmp[j - 1]
            flg += tmp[0]
            A[j] = tmp[j]
        
        A[0] = tmp[0]
        
        if flg == N**2:
            break
            
    print(*A[:N])

Problem: p02647
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
from math import log2
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = [0]*n

if(k > log2(n)):
    for i in range(n):
        print(n,end=" ")

else:
    for j in range(k):
        b = [0]*n
        for i in range(n):
            l = max(0,i-a[i])
            r = min(n-1,a[i]+i)
            b[l] += 1
            if(r+1<n):
                b[r+1] -= 1
        for i in range(1,n):
            b[i] += b[i-1]
        a = b


    for i in a:
        print(i,end=" ")


Failing test case input:
5 3
0 0 0 0 0

Expected output:
4 4 5 4 4


Actual output:
5 5 5 5 5 

Fixed submission (verdict: Accepted):
from math import log2
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = [0]*n

if(k > 10*log2(n) + 1):
    for i in range(n):
        print(n,end=" ")

else:
    for j in range(k):
        b = [0]*n
        for i in range(n):
            l = max(0,i-a[i])
            r = min(n-1,a[i]+i)
            b[l] += 1
            if(r+1<n):
                b[r+1] -= 1
        for i in range(1,n):
            b[i] += b[i-1]
        a = b


    for i in a:
        print(i,end=" ")
Problem: p02647
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
from itertools import accumulate
N, K = map(int, input().split())
A = list(map(int, input().split()))
if all([a == 0 for a in A]):
    print(*A)
    exit()
for k in range(min(50, K)):
    B = [0]*N
    for i in range(N):
        B[max(0, i-A[i])] += 1
        r = i+A[i]+1
        if r < N:
            B[r] -= 1
    A = list(accumulate(B))
print(*A)


Failing test case input:
5 1
0 0 0 0 0

Expected output:
1 1 1 1 1


Actual output:
0 0 0 0 0


Fixed submission (verdict: Accepted):
from itertools import accumulate
N, K = map(int, input().split())
A = list(map(int, input().split()))
for k in range(min(50, K)):
    B = [0]*N
    for i in range(N):
        B[max(0, i-A[i])] += 1
        r = i+A[i]+1
        if r < N:
            B[r] -= 1
    A = list(accumulate(B))
print(*A)

Problem: p02647
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import math

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

for i in range(min(math.ceil(math.log(N)), K)):
  B = [0] * N
  for n, A_n in enumerate(A):
    B_min = max(0, n-A_n)
    b_max = min(N-1, n+A_n)
    B[B_min] += 1
    if b_max+1 < N:
      B[b_max+1] -= 1
  
  sum = 0
  for n in range(len(A)):
    sum += B[n]
    A[n] = sum

  print(" ".join(list(map(str, A))))

Failing test case input:
5 0
0 1 0 0 1

Expected output:
0 1 0 0 1


Actual output:

Fixed submission (verdict: Accepted):
import math

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

for i in range(min(41, K)):
  B = [0] * N
  for n, A_n in enumerate(A):
    B_min = max(0, n-A_n)
    b_max = min(N-1, n+A_n)
    B[B_min] += 1
    if b_max+1 < N:
      B[b_max+1] -= 1
  
  sum = 0
  for n in range(len(A)):
    sum += B[n]
    A[n] = sum

print(" ".join(list(map(str, A))))

Problem: p02647
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N,K=map(int,input().split())
A=list(map(int,input().split()))
for i in range(K):
    d=[0]*(N+1)
    for j,a in enumerate(A):
        d[max(0,j-a)]+=1
        d[min(N,j+a+1)]-=1
    b=-1
    for j in range(N):
        if b==-1:
            b=d[j]
        elif b!=d[j] or 1<b<N:
            b=0
        d[j+1]+=d[j]
    A=d[:-1]
    if b:
        break
print(*A)

Failing test case input:
5 2
0 0 0 0 0

Expected output:
2 3 3 3 2


Actual output:
1 1 1 1 1


Fixed submission (verdict: Accepted):
N,K=map(int,input().split())
A=list(map(int,input().split()))
for i in range(K):
    d=[0]*(N+1)
    for j,a in enumerate(A):
        d[max(0,j-a)]+=1
        d[min(N,j+a+1)]-=1
    b=1
    for j in range(N):
        if d[j]!=N:
            b=0
        d[j+1]+=d[j]
    A=d[:-1]
    if b>0:
        break
print(*A)
Problem: p02647
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N,K=map(int,input().split())
A=list(map(int,input().split()))
for i in range(K):
    d=[0]*(N+1)
    for j,a in enumerate(A):
        d[max(0,j-a)]+=1
        d[min(N,j+a+1)]-=1
    b=-1
    for j in range(N):
        if b==-1:
            if d[j]==1 or d[j]==N:
                b=d[j]
            else:
                b=0
        elif b!=d[j]:
            b=0
        d[j+1]+=d[j]
    A=d[:-1]
    if b>0:
        break
print(*A)

Failing test case input:
5 3
0 0 0 0 0

Expected output:
4 4 5 4 4


Actual output:
1 1 1 1 1


Fixed submission (verdict: Accepted):
N,K=map(int,input().split())
A=list(map(int,input().split()))
for i in range(K):
    d=[0]*(N+1)
    for j,a in enumerate(A):
        d[max(0,j-a)]+=1
        d[min(N,j+a+1)]-=1
    b=1
    for j in range(N):
        if d[j]!=N:
            b=0
        d[j+1]+=d[j]
    A=d[:-1]
    if b>0:
        break
print(*A)

Problem: p02647
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import math
from itertools import accumulate
n, k = map(int, input().split())
As = list(map(int, input().split()))
_n = math.floor(n ** 0.5) + 1
for i in range(min(_n, k)):
  _As = [0]*(n+1)
  for j in range(n):
    l = max(0, j - As[j])
    r = min(n - 1, j + As[j])
    _As[l] += 1
    _As[r+1] -= 1
  As = list(accumulate(_As))[:-1]
print(As)    

Failing test case input:
5 1
0 0 0 3 1

Expected output:
2 2 2 2 2


Actual output:
[2, 2, 2, 2, 2]


Fixed submission (verdict: Accepted):
import math
from itertools import accumulate
n, k = map(int, input().split())
As = list(map(int, input().split()))
for i in range(min(41, k)):
  _As = [0]*(n+1)
  for j in range(n):
    l = max(0, j - As[j])
    r = min(n - 1, j + As[j])
    _As[l] += 1
    _As[r+1] -= 1
  As = list(accumulate(_As))[:-1]
print(' '.join([str(A) for A in As]))

Problem: p02647
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import math
from itertools import accumulate
n, k = map(int, input().split())
As = list(map(int, input().split()))
_n = math.floor(math.log(n,2)) + 1
for i in range(min(_n, k)):
  _As = [0]*(n+1)
  for j in range(n):
    l = max(0, j - As[j])
    r = min(n - 1, j + As[j])
    _As[l] += 1
    _As[r+1] -= 1
  As = list(accumulate(_As))[:-1]
print(' '.join(list(map(lambda x:str(x),As))))

Failing test case input:
5 6
0 1 0 4 0

Expected output:
5 5 5 5 5


Actual output:
4 5 5 5 4


Fixed submission (verdict: Accepted):
import math
from itertools import accumulate
n, k = map(int, input().split())
As = list(map(int, input().split()))
for i in range(min(41, k)):
  _As = [0]*(n+1)
  for j in range(n):
    l = max(0, j - As[j])
    r = min(n - 1, j + As[j])
    _As[l] += 1
    _As[r+1] -= 1
  As = list(accumulate(_As))[:-1]
print(' '.join([str(A) for A in As]))
Problem: p02647
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
import copy

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

for k in range(K):
    B = [0 for _ in range(N)]
    for i in range(N):
        left = max(i-A[i], 0)
        right = min(i+A[i], N-1)
        for j in range(left, right+1):
            B[j] += 1
    A = copy.deepcopy(B)
print(A)


Failing test case input:
5 0
1 -2 1 1 1

Expected output:
1 -2 1 1 1


Actual output:
[1, -2, 1, 1, 1]


Fixed submission (verdict: Accepted):
import copy

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

for k in range(min(K, 41)):
    B = [0 for _ in range(N)]
    for i in range(N):
        left = max(i-A[i], 0)
        right = min(i+A[i], N-1)
        B[left] += 1
        if (right+1<N):
            B[right+1] -= 1
    for i in range(1, N):
        B[i] += B[i-1]
    A = copy.deepcopy(B)
print(" ".join(list(map(str, A))))

Problem: p02647
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def main():
    n, k = map(int, input().strip().split())
    A = list(map(int, input().strip().split()))
    
    
    
    
    def solve():
        nonlocal A
        for _ in range(k):
            b=[0]*(n+1)
            
            for i in range(n):
                b[max(0,i-A[i])]+=1
                b[min(n,i+A[i]+1)]+=1
            
            
            
            for i in range(1,n):
                b[i]+=b[i-1]
            A=b
            if b[0]==n and b[-1]==n:
                break
        print(*A)
    solve()

if '__main__' == __name__:
    main()

Failing test case input:
5 1
0 2 0 0 0

Expected output:
2 1 2 2 1


Actual output:
2 3 4 6 9 1


Fixed submission (verdict: Accepted):
import sys
from itertools import accumulate
input=sys.stdin.buffer.readline

def main():
    n, k = map(int, input().split())
    A = [*map(int, input().split())]
    
    
    
    for _ in "_"*k:
        b=[0]*(n)
        
        for i,v in enumerate(A):
            if i>v:
            
                b[i-v]+=1
            else:
                b[0]+=1
            j=i-~v
            
            
            if j<n:
                b[j]-=1
        
        
        
        
        
        A=[*accumulate(b)]
        
        if min(A)==n:
            break
    print(" ".join(map(str,A)))

if '__main__' == __name__:
    main()
Problem: p02647
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
from math import log2
n,k = map(int,input().split())
a = list(map(int,input().split()))

def calc(a):
    for _ in range(k):
        b = [0] * n
        for i in range(n):
            for j in range(n):
                if a[j] >=  abs(j - i):
                    b[i] += 1
        a = b
        print(a)
    return a

if(k > 2*log2(n) + 1):
    for i in range(n):
        print(n,end=" ")
else:
    a = calc(a)
    for i in a:
        print(i,end=" ")


Failing test case input:
5 2
1 0 0 0 1

Expected output:
2 4 3 4 2


Actual output:
[1, 2, 1, 2, 1]
[2, 4, 3, 4, 2]
2 4 3 4 2 

Fixed submission (verdict: Accepted):
from math import log2
n,k = map(int,input().split())
a = list(map(int,input().split()))
b = [0]*n

if(k > 10*log2(n) + 1):
    for i in range(n):
        print(n,end=" ")

else:
    for j in range(k):
        b = [0]*n
        for i in range(n):
            l = max(0,i-a[i])
            r = min(n-1,a[i]+i)
            b[l] += 1
            if(r+1<n):
                b[r+1] -= 1
        for i in range(1,n):
            b[i] += b[i-1]
        a = b


    for i in a:
        print(i,end=" ")

Problem: p02647
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n, k = map(int, input().split())
a = list(map(int, input().split()))
current = a[:]
for _ in range(min(50, k)):
    next = [1]*n
    stack = 0
    for j, v in enumerate(current):
        next[j] += stack % 10
        stack 
        if v > 0:
            stack += int('1'*v)
    stack = 0
    for j in range(n-1, -1, -1):
        next[j] += stack % 10
        stack 
        if current[j] > 0:
            stack += int('1' * current[j])
    current = next
print(*current)

Failing test case input:
5 1
0 0 0 2 1

Expected output:
1 2 2 2 2


Actual output:
3 3 3 2 2


Fixed submission (verdict: Accepted):
n, k = map(int, input().split())
a = list(map(int, input().split()))
current = a[:]
for _ in range(min(42, k)):
    nex = [0]*n
    for i, v in enumerate(current):
        l = max(0, i-v)
        r = min(n-1, i+v)
        nex[l] += 1
        if r+1 < n:
            nex[r+1] -= 1
    for i in range(1, n):
        nex[i] += nex[i-1]
    current = nex

print(*current)

Problem: p02647
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N,K = map(int,input().split())
A = list(map(int, input().split()))

for _ in range(K):
  B = [0] * (N+1)
  for i,a in enumerate(A):
    l = max(0, i-a)
    r = min(i+a+1, N)
    B[l] += 1
    B[r] -= 1

  for i in range(N):
    B[i+1] += B[i]

  if all(b==N for b in B[:-1]): break
  A = B

for i in range(N):
  print(A[i])

Failing test case input:
5 0
0 -1 0 1 1

Expected output:
0 -1 0 1 1


Actual output:
0
-1
0
1
1


Fixed submission (verdict: Accepted):
from itertools import accumulate

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

for _ in range(K):
  arr = [0]*(N+1)
  for i, a in enumerate(A):
    left = max(0, i-a)
    right = min(N, i+a+1)
    arr[left] += 1
    arr[right] -= 1
  
  A = list(accumulate(arr[:-1]))
  if all(a == N for a in A):
    break

print(*A, sep=" ")
Problem: p03666
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,a,b,c,d=map(int,input().split())
f=0
for i in range(n):f^=i*c-(~i+n)*d<=b-a<=i*d-(~i+n)*c
print('NYOE S'[f::2])

Failing test case input:
6 4 9 -2 5

Expected output:
YES


Actual output:
NO 


Fixed submission (verdict: Accepted):
n,a,b,c,d=map(int,input().split())
f=0
for i in range(n):f|=i*c-(~i+n)*d<=b-a<=i*d-(~i+n)*c
print('NYOE S'[f::2])

Problem: p03666
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,A,B,C,D = map(int, input().split())

ans = "NO"
B -= A
for i in range(N):
    num = i*D - (N-1-i)*D
    if num-i*(D-C) <= 0 <= num+(N-i-1)*(D-C):
        ans = "YES"
        break

print(ans)

Failing test case input:
4 7 11 4 5

Expected output:
YES


Actual output:
NO


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

ans = "NO"
B -= A
for i in range(N):
    num = i*D - (N-1-i)*D
    if num-i*(D-C) <= B <= num+(N-i-1)*(D-C):
        ans = "YES"
        break

print(ans)

Problem: p03666
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, A, B, C, D = map(int, input().split())
S = abs(A - B)
if (N - 1) * D < S:
    print('NO')
    exit()
if N % 2 == 1 or C <= S <= D:
    print('YES')
else:
    print('NO')

Failing test case input:
4103 11879 10380868 15371973 948970

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
N, A, B, C, D = map(int, input().split())
for i in range(N):
    m = N - 1 - i
    if i * C + -m * D <= B - A <= i * D + -m * C:
        print('YES')
        exit()
print('NO')

Problem: p03666
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

n,a,b,c,d=map(int,input().split())
ans='NO'
maxi=a+d*(n-1)
mini=a+c*(n-1)
if mini<b<maxi:
    print('YES')
    exit()
for i in range(1,n):
    maxi=maxi-d-c
    mini=mini-c-d
    if mini<b<maxi:
        ans='YES'
        break

print(ans)

Failing test case input:
491995 412925347 825318103 59999126 59999339

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):

n,a,b,c,d=map(int,input().split())
ans='NO'
maxi=a+d*(n-1)
mini=a+c*(n-1)
if mini<=b<=maxi:
    ans='YES'

else:
    for i in range(1,n):
        maxi=maxi-d-c
        mini=mini-c-d
        if mini<=b<=maxi:
            ans='YES'
            break

print(ans)

Problem: p03666
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    n, a, b, c, d = map(int, input().split())

    for i in range(n):
        if c * (n-1-i) - d * i <= b - a <= -c * i + d * (n-1-i):
            print("Yes")
            break
    else:
        print("No")


if __name__ == '__main__':
    main()


Failing test case input:
91191 651754 218474247 26672621 948970

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
def main():
    n, a, b, c, d = map(int, input().split())

    for i in range(n):
        if c * (n-1-i) - d * i <= b - a <= -c * i + d * (n-1-i):
            print("YES")
            break
    else:
        print("NO")


if __name__ == '__main__':
    main()
Problem: p03666
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,A,B,C,D = map(int,input().split())
if N > 16 and D > 1:
	flag = 10 **9
else:
	flag = pow(D,N)
B -= A
if N % 2 == 1:
	if (B % (C + D) <= (N - 1) * (D - C) / 2 or abs(B % (C + D) - (C + D)) <= (N - 1) * (D - C) / 2) and B <= flag and B >= -flag:
		print("YES")
	else:
		print("NO")
else:
	m = B % ((C + D) * 2) - (D - C) / 2
	if abs(m) <= (N - 1) * (D - C) / 2 and B <= flag and B >= -flag:
		print("YES")
	else:
		print("NO")

Failing test case input:
4 4 9 4 6

Expected output:
YES


Actual output:
NO


Fixed submission (verdict: Accepted):
N,A,B,C,D = map(int,input().split())
flag = D * (N - 1)
B -= A
if D - C == 0:
	if A == B:
		print("YES")
	else:
		print("NO")
elif N % 2 == 1:
	if (B % (C + D) <= (N - 1) * (D - C) / 2 or abs(B % (C + D) - (C + D)) <= (N - 1) * (D - C) / 2) and B <= flag and B >= -flag:
		print("YES")
	else:
		print("NO")
else:
	if abs(B % (C + D) - (D + C) / 2) <= (N - 1) * (D - C) / 2 and B <= flag and B >= -flag:
		print("YES")
	else:
		print("NO")

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

n,a,b,m,M=map(int,input().split())
x=b-a
print("YES" if any((n-i)*m-i*M <= x <= -i*m+(n-i)*M for i in range(n+1)) else "NO")

Failing test case input:
491995 412925347 465710940 59999126 59999339

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
n,a,b,m,M=map(int,input().split())
print("YES" if any((n-i-1)*m-i*M<=b-a<=-i*m+(n-i-1)*M for i in range(n)) else "NO")

Problem: p03666
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def solve(n, a, b, c, d):
    return d == 0
    if d == 0:
        return a == b
    t = n - 1
    return (b - a - c * t) % (c + d) <= (d - c) * t


print('YES' if solve(*map(int, input().split())) else 'NO')


Failing test case input:
135 363156295 943846071 7145695 54689697

Expected output:
YES


Actual output:
NO


Fixed submission (verdict: Accepted):
def solve(n, a, b, c, d):
    if d == 0:
        return a == b
    t = n - 1
    ab = abs(a - b)
    if ab > d * t:
        return False
    return (ab - c * t) % (c + d) <= (d - c) * t


print('YES' if solve(*map(int, input().split())) else 'NO')

Problem: p03666
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,a,b,c,d =map(int,input().split())
n -= 1
for i in range(n,-n-1,-2):
  ans1 = a+c*i
  ans2 = a+d*i
  if (ans1<= b and b<ans2):
    print("YES")
    exit()
print("NO")

Failing test case input:
263961 412925347 211867885 19648141 4650906

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
n,a,b,c,d =map(int,input().split())
n -= 1
ans1 = a + c*n+d+c
ans2 = a+d*n+c+d
for i in range(n+1):
  ans1 -= d+c
  ans2 -= c+d
  if (ans1<= b and b<=ans2):
    print("YES")
    exit()
print("NO")
Problem: p03666
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


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

N, A, B, C, D = map(int, input().split())


def check(m):
    return C+(N-1-m)-D*m <= B-A <= -C*m+(N-1-m)*D


for m in range(N):
    if check(m):
        print("YES")
        break
else:
    print("NO")


Failing test case input:
95 88395718 943846071 54139452 31638802

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):


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

N, A, B, C, D = map(int, input().split())


def check(m):
    return C*(N-1-m)-D*m <= B-A <= -C*m+(N-1-m)*D


for m in range(N):
    if check(m):
        print("YES")
        break
else:
    print("NO")

Problem: p03666
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,A,B,C,D=map(int,input().split())
l=[]
for i in range(1,N):
    l.append(range(i*C-(N-i)*D,i*D-(N-i)*C+1,2))
l.append(range(-N*D,-N*C+1))
l.append(range(N*C,N*D+1))
for _ in l:
    if B-A in _:
        print("YES")
        break
else:
    print("NO")

Failing test case input:
185 832955436 1140728524 7145695 35969253

Expected output:
YES


Actual output:
NO


Fixed submission (verdict: Accepted):
N,A,B,C,D=map(int,input().split())
N=N-1
l=[]
for i in range(0,N+1):
    l.append(range(i*C-(N-i)*D,i*D-(N-i)*C+1))

for _ in l:
    if B-A in _:
        print("YES")
        break
else:
    print("NO")

Problem: p03666
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, A, B, C, D = map(int, input().split())
if A > B:
    A, B = B, A

flag = False
diff = B-A
d = 0
for i in range(0, N, 2):
    if i > 0:
        d += D-C
    j = N-1 - i
    if j == 0:
        if diff == d:
            flag = True
        break
    k = abs(diff - d) / j
    if (k >= C and k <= D) or diff == d and j % 2 == 0:
        flag = True
        break

if flag:
    print("YES")
else:
    print("NO")


Failing test case input:
4 7 11 4 6

Expected output:
YES


Actual output:
NO


Fixed submission (verdict: Accepted):
N, A, B, C, D = map(int, input().split())
if A > B:
    A, B = B, A

flag = False
diff = B-A
d = 0
for i in range(0, N, 2):
    if i > 0:
        d += D-C
    j = N-1 - i
    if diff == d and j % 2 == 0:
        flag == True
        break
    if j == 0:
        break

    k = abs(diff - d) / j
    if (k >= C and k <= D) or (abs(diff-d) >= C and abs(diff-d) <= D and j % 2 == 1):
        flag = True
        break
    k = abs(diff + d) / j
    if (k >= C and k <= D) or (diff+d >= C and diff+d <= D and j % 2 == 1):
        flag = True
        break

if flag:
    print("YES")
else:
    print("NO")
Problem: p03666
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,A,B,C,D=map(int,input().split())
D-=1
l=[]
for i in range(0,N+1):
    l.append(range(i*C-(N-i)*D,i*D-(N-i)*C+1))

for _ in l:
    if B-A in _:
        print("YES")
        break
else:
    print("NO")

Failing test case input:
4 7 11 4 5

Expected output:
YES


Actual output:
NO


Fixed submission (verdict: Accepted):
N,A,B,C,D=map(int,input().split())
N=N-1
l=[]
for i in range(0,N+1):
    l.append(range(i*C-(N-i)*D,i*D-(N-i)*C+1))

for _ in l:
    if B-A in _:
        print("YES")
        break
else:
    print("NO")

Problem: p03666
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,A,B,C,D = map(int,input().split())
if N > 30 and D > 1:
	flag = 10 **9
else:
	flag = pow(D,N -1)
B -= A
if N % 2 == 1:
	if (B % (C + D) <= (N - 1) * (D - C) / 2 or abs(B % (C + D) - (C + D)) <= (N - 1) * (D - C) / 2) and B <= flag and B >= -flag:
		print("YES")
	else:
		print("NO")
else:
	if abs(B % (C + D) - (D + C) / 2) < (N - 1) * (D - C) / 2 and B <= flag and B >= -flag:
		print("YES")
	else:
		print("NO")

Failing test case input:
4 7 9 4 6

Expected output:
YES


Actual output:
NO


Fixed submission (verdict: Accepted):
N,A,B,C,D = map(int,input().split())
flag = D * (N - 1)
B -= A
if D - C == 0:
	if A == B:
		print("YES")
	else:
		print("NO")
elif N % 2 == 1:
	if (B % (C + D) <= (N - 1) * (D - C) / 2 or abs(B % (C + D) - (C + D)) <= (N - 1) * (D - C) / 2) and B <= flag and B >= -flag:
		print("YES")
	else:
		print("NO")
else:
	if abs(B % (C + D) - (D + C) / 2) <= (N - 1) * (D - C) / 2 and B <= flag and B >= -flag:
		print("YES")
	else:
		print("NO")

Problem: p03666
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, A, B, C, D = map(int, input().split())
lb, ub = A, A
for _ in range(1, N):
    if (lb + ub) / 2 < B:
        lb, ub = lb + C, ub + D
    else:
        lb, ub = lb - D, ub - C
if lb <= B <= ub:
    print('Yes')
else:
    print('No')

Failing test case input:
365986 412925347 465710940 59999126 4650906

Expected output:
NO


Actual output:
No


Fixed submission (verdict: Accepted):
N, A, B, C, D = map(int, input().split())
lb, ub = A, A
for _ in range(1, N):
    if (lb + ub) / 2 < B:
        lb, ub = lb + C, ub + D
    else:
        lb, ub = lb - D, ub - C
if lb <= B <= ub:
    print('YES')
else:
    print('NO')

Problem: p03666
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

n,a,b,c,d=map(int,input().split())
ans='NO'
maxi=a+d*(n-1)
mini=a+c*(n-1)
if mini<b<maxi:
    print('YES')

else:
    for i in range(1,n):
        maxi=maxi-d-c
        mini=mini-c-d
        if mini<b<maxi:
            ans='YES'
            break

    print(ans)

Failing test case input:
491995 412925347 825318103 59999126 59999339

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):

n,a,b,c,d=map(int,input().split())
ans='NO'
maxi=a+d*(n-1)
mini=a+c*(n-1)
if mini<=b<=maxi:
    ans='YES'

else:
    for i in range(1,n):
        maxi=maxi-d-c
        mini=mini-c-d
        if mini<=b<=maxi:
            ans='YES'
            break

print(ans)
Problem: p03666
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,A,B,C,D=map(int,input().split())
l=[]
for i in range(N+1):
    l.append(range(i*C-(N-i)*D,i*D-(N-i)*C+1,2))
for _ in l:
    if B-A in _:
        print("YES")
        break
else:
    print("NO")


Failing test case input:
185 1357504854 1140728524 7145695 35969253

Expected output:
YES


Actual output:
NO


Fixed submission (verdict: Accepted):
N,A,B,C,D=map(int,input().split())
N=N-1
l=[]
for i in range(0,N+1):
    l.append(range(i*C-(N-i)*D,i*D-(N-i)*C+1))

for _ in l:
    if B-A in _:
        print("YES")
        break
else:
    print("NO")

Problem: p03666
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,A,B,C,D = map(int,input().split())
if N > 30 and D > 1:
	flag = 10 **9 * 0
else:
	flag = pow(D,N -1)
B -= A
if N % 2 == 1:
	if (B % (C + D) <= (N - 1) * (D - C) / 2 or abs(B % (C + D) - (C + D)) <= (N - 1) * (D - C) / 2) and B <= flag and B >= -flag:
		print("YES")
	else:
		print("NO")
else:
	if abs(B % (C + D) - (D + C) / 2) <= (N - 1) * (D - C) / 2 and B <= flag and B >= -flag:
		print("YES")
	else:
		print("NO")

Failing test case input:
1788 122437383 943846071 90629745 148553464

Expected output:
YES


Actual output:
NO


Fixed submission (verdict: Accepted):
N,A,B,C,D = map(int,input().split())
flag = D * (N - 1)
B -= A
if D - C == 0:
	if A == B:
		print("YES")
	else:
		print("NO")
elif N % 2 == 1:
	if (B % (C + D) <= (N - 1) * (D - C) / 2 or abs(B % (C + D) - (C + D)) <= (N - 1) * (D - C) / 2) and B <= flag and B >= -flag:
		print("YES")
	else:
		print("NO")
else:
	if abs(B % (C + D) - (D + C) / 2) <= (N - 1) * (D - C) / 2 and B <= flag and B >= -flag:
		print("YES")
	else:
		print("NO")

Problem: p03666
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,a,b,c,d =map(int,input().split())
n -= 1
ans1 = a + c*n+d+c
ans2 = a+d*n+c+d
for i in range(n+1):
  ans1 -= d+c
  ans2 -= c+d
  if (ans1<= b and b<ans2):
    print("YES")
    exit()
print("NO")

Failing test case input:
491995 412925347 825318103 59999126 59999339

Expected output:
YES

Actual output:
NO


Fixed submission (verdict: Accepted):
n,a,b,c,d =map(int,input().split())
n -= 1
ans1 = a + c*n+d+c
ans2 = a+d*n+c+d
for i in range(n+1):
  ans1 -= d+c
  ans2 -= c+d
  if (ans1<= b and b<=ans2):
    print("YES")
    exit()
print("NO")
Problem: p03666
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,A,B,C,D = map(int,input().split())
if N > 30 and D > 1:
	flag = 10 **9
else:
	flag = pow(D,N -1)
B -= A
if N % 2 == 1:
	if (B % (C + D) <= (N - 1) * (D - C) / 2 or abs(B % (C + D) - (C + D)) <= (N - 1) * (D - C) / 2) and B <= flag and B >= -flag:
		print("YES")
	else:
		print("NO")
else:
	if (B - (D + C) / 2) % (C + D) <= (N - 1) * (D - C) / 2 : 
		print("YES")
	else:
		print("NO")

Failing test case input:
4 7 11 4 6

Expected output:
YES


Actual output:
NO


Fixed submission (verdict: Accepted):
N,A,B,C,D = map(int,input().split())
flag = D * (N - 1)
B -= A
if D - C == 0:
	if A == B:
		print("YES")
	else:
		print("NO")
elif N % 2 == 1:
	if (B % (C + D) <= (N - 1) * (D - C) / 2 or abs(B % (C + D) - (C + D)) <= (N - 1) * (D - C) / 2) and B <= flag and B >= -flag:
		print("YES")
	else:
		print("NO")
else:
	if abs(B % (C + D) - (D + C) / 2) <= (N - 1) * (D - C) / 2 and B <= flag and B >= -flag:
		print("YES")
	else:
		print("NO")

Problem: p03666
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, a, b, c, d = [int(item) for item in input().split()]

u, l = 0, 0
while n > 1:
    if b <= a + u + (n-1) * d and b >= a + l + (n-1) * c:
        print("YES")
        exit()
    if b >= a + u + (n-1) * -d and b <= a + l + (n-1) * -c:
        print("YES")
        exit()
    n -= 2
    u += d - c
    l -= d - c
print("NO")

Failing test case input:
130851 84352859 354568526 13404605 484370

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
n, a, b, c, d = [int(item) for item in input().split()]

u, l = 0, 0
while n > 1:
    if b <= a + u + (n-1) * d and b >= a + l + (n-1) * c:
        print("YES")
        exit()
    if b <= a + u + (n-1) * -c and b >= a + l + (n-1) * -d:
        print("YES")
        exit()
    n -= 2
    u += d - c
    l -= d - c
print("NO")

Problem: p03666
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, A, B, C, D = map(int, input().split())

if N % 2 == 1:
    print("YES")
else:
    if C <= abs(A-B) <= D:
        print("YES")
    else:
        print("NO")


Failing test case input:
364 1357504854 2053847691 2734001 4411603

Expected output:
YES


Actual output:
NO


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

for k in range(N):
    if k*C - (N-1-k)*D <= abs(B-A) <= k*D - (N-1-k)*C:
        print("YES")
        break
else:
    print("NO")

Problem: p03666
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,a,b,c,d = map(int,input().split())
lo,hi = -d*n, -c*n
for _ in range(n+1):
  if lo <= a-b <= hi:
    print("YES")
    break
  lo += c+d
  hi += c+d
else:
  print("NO")

Failing test case input:
491995 412925347 465710940 59999126 59999339

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
n,a,b,c,d = map(int,input().split())
lo,hi = -d*(n-1), -c*(n-1)
for _ in range(n):
  if lo <= a-b <= hi:
    print("YES")
    break
  lo += c+d
  hi += c+d
else:
  print("NO")
Problem: p03666
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,A,B,C,D=map(int,input().split())
l=[]
for i in range(N+1):
    l.append(range(i*C-(N-i)*D,int(i*D-(N-i)*C/2)*2+2,2))
for _ in l:
    if B-A in _:
        print("YES")
        break
else:
    print("NO")



Failing test case input:
364 1357504854 2053847691 2734001 2466184

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
N,A,B,C,D=map(int,input().split())
N=N-1
l=[]
for i in range(0,N+1):
    l.append(range(i*C-(N-i)*D,i*D-(N-i)*C+1))

for _ in l:
    if B-A in _:
        print("YES")
        break
else:
    print("NO")

Problem: p03666
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,A,B,C,D = map(int,input().split())
if N > 30 and D > 1:
	flag = 10 **9
else:
	flag = pow(D,N -1)
B -= A
if N % 2 == 1:
	if (B % (C + D) <= (N - 1) * (D - C) / 2 or abs(B % (C + D) - (C + D)) <= (N - 1) * (D - C) / 2) and B <= flag and B >= -flag:
		print("YES")
	else:
		print("NO")
else:
	if (B + (D + C) / 2) % (C + D) <= (N - 1) * (D - C) / 2 : 
		print("YES")
	else:
		print("NO")

Failing test case input:
4 7 9 4 6

Expected output:
YES


Actual output:
NO


Fixed submission (verdict: Accepted):
N,A,B,C,D = map(int,input().split())
flag = D * (N - 1)
B -= A
if D - C == 0:
	if A == B:
		print("YES")
	else:
		print("NO")
elif N % 2 == 1:
	if (B % (C + D) <= (N - 1) * (D - C) / 2 or abs(B % (C + D) - (C + D)) <= (N - 1) * (D - C) / 2) and B <= flag and B >= -flag:
		print("YES")
	else:
		print("NO")
else:
	if abs(B % (C + D) - (D + C) / 2) <= (N - 1) * (D - C) / 2 and B <= flag and B >= -flag:
		print("YES")
	else:
		print("NO")

Problem: p03666
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,a,b,c,d =map(int,input().split())
n -= 1
ans1 = a + c*n+d
ans2 = a+d*n+c
for i in range(n):
  ans1 -= d
  ans2 -= c
  if (ans1<= b and b<ans2):
    print("YES")
    exit()
print("NO")

Failing test case input:
491995 412925347 465710940 59999126 59999339

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
n,a,b,c,d =map(int,input().split())
n -= 1
ans1 = a + c*n+d+c
ans2 = a+d*n+c+d
for i in range(n+1):
  ans1 -= d+c
  ans2 -= c+d
  if (ans1<= b and b<=ans2):
    print("YES")
    exit()
print("NO")

Problem: p03666
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,A,B,C,D=map(int,input().split())
N=N-2
l=[]
for i in range(0,N+1):
    l.append(range(i*C-(N-i)*D,i*D-(N-i)*C+1))

for _ in l:
    if B-A in _:
        print("YES")
        break
else:
    print("NO")


Failing test case input:
491995 412925347 465710940 59999126 59999339

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
N,A,B,C,D=map(int,input().split())
N=N-1
l=[]
for i in range(0,N+1):
    l.append(range(i*C-(N-i)*D,i*D-(N-i)*C+1))

for _ in l:
    if B-A in _:
        print("YES")
        break
else:
    print("NO")
Problem: p03666
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, A, B, C, D = map(int, input().split())
for i in range(N):
    if -D*i + C*(N-1-i) <= B - A <= D*i - C*(N-1-i): print('YES'); break;
else:
    print('NO')

Failing test case input:
2552 9549 10380868 25203917 904720

Expected output:
NO


Actual output:
YES


Fixed submission (verdict: Accepted):
N, A, B, C, D = map(int, input().split())
for i in range(N):
    if -D*i + C*(N-1-i) <= B - A <= D*(N-1-i) - C*i: print('YES'); break;
else:
    print('NO')

Problem: p03666
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,A,B,C,D = map(int,input().split())
if N > 16:
	flag = 10 **9
else:
	flag = pow(D,N)
B -= A
if N % 2 == 1:
	if B % (C + D) <= (N - 1) * (D - C) / 2 or abs(B % (C + D) - (C + D)) <= (N - 1) * (D - C) / 2 and B <= flag and B >= -flag:
		print("YES")
	else:
		print("NO")
else:
	m = B % ((C + D) * 2) - (D - C) / 2
	if abs(m) <= (N - 1) * (D - C) / 2 and B <= flag and B >= -flag:
		print("YES")
	else:
		print("NO")

Failing test case input:
4 7 11 4 5

Expected output:
YES


Actual output:
NO


Fixed submission (verdict: Accepted):
N,A,B,C,D = map(int,input().split())
flag = D * (N - 1)
B -= A
if D - C == 0:
	if A == B:
		print("YES")
	else:
		print("NO")
elif N % 2 == 1:
	if (B % (C + D) <= (N - 1) * (D - C) / 2 or abs(B % (C + D) - (C + D)) <= (N - 1) * (D - C) / 2) and B <= flag and B >= -flag:
		print("YES")
	else:
		print("NO")
else:
	if abs(B % (C + D) - (D + C) / 2) <= (N - 1) * (D - C) / 2 and B <= flag and B >= -flag:
		print("YES")
	else:
		print("NO")

Problem: p03666
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,a,b,c,d = map(int, input().split())
for i in range(n):
  pi = i
  mi = n - i
  if a + c * pi - d * mi <= b <= a + d * pi - c * mi:
    print("YES")
    break
else:
  print("NO")

Failing test case input:
4 7 6 4 5

Expected output:
NO

Actual output:
YES


Fixed submission (verdict: Accepted):
n,a,b,c,d = map(int, input().split())
for i in range(n):
  pi = i
  mi = n - i - 1
  if a + c * pi - d * mi <= b <= a + d * pi - c * mi:
    print("YES")
    break
else:
  print("NO")

Problem: p03666
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,A,B,C,D = map(int,input().split())
if N > 16:
	flag = 10 **9
else:
	flag = pow(D,N)
B -= A
if N % 2 == 1:
	if (B % (C + D) <= (N - 1) * (D - C) / 2 or abs(B % (C + D) - (C + D)) <= (N - 1) * (D - C) / 2) and B <= flag and B >= -flag:
		print("YES")
	else:
		print("NO")
else:
	m = B % ((C + D) * 2) - (D - C) / 2
	if abs(m) <= (N - 1) * (D - C) / 2 and B <= flag and B >= -flag:
		print("YES")
	else:
		print("NO")

Failing test case input:
4 4 9 4 6

Expected output:
YES


Actual output:
NO


Fixed submission (verdict: Accepted):
N,A,B,C,D = map(int,input().split())
flag = D * (N - 1)
B -= A
if D - C == 0:
	if A == B:
		print("YES")
	else:
		print("NO")
elif N % 2 == 1:
	if (B % (C + D) <= (N - 1) * (D - C) / 2 or abs(B % (C + D) - (C + D)) <= (N - 1) * (D - C) / 2) and B <= flag and B >= -flag:
		print("YES")
	else:
		print("NO")
else:
	if abs(B % (C + D) - (D + C) / 2) <= (N - 1) * (D - C) / 2 and B <= flag and B >= -flag:
		print("YES")
	else:
		print("NO")
Problem: p03666
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, A, B, C, D = map(int, input().split())
if A > B:
    A, B = B, A

flag = False
diff = B-A
d = 0
for i in range(0, N, 2):
    if i > 0:
        d += D-C
    j = N-1 - i
    if j == 0:
        if diff == d:
            flag = True
        break
    k = abs(diff - d) / j
    if k >= C and k <= D:
        flag = True
        break

if flag:
    print("YES")
else:
    print("NO")


Failing test case input:
4 7 9 4 6

Expected output:
YES


Actual output:
NO


Fixed submission (verdict: Accepted):
N, A, B, C, D = map(int, input().split())
if A > B:
    A, B = B, A

flag = False
diff = B-A
d = 0
for i in range(0, N, 2):
    if i > 0:
        d += D-C
    j = N-1 - i
    if diff == d and j % 2 == 0:
        flag == True
        break
    if j == 0:
        break

    k = abs(diff - d) / j
    if (k >= C and k <= D) or (abs(diff-d) >= C and abs(diff-d) <= D and j % 2 == 1):
        flag = True
        break
    k = abs(diff + d) / j
    if (k >= C and k <= D) or (diff+d >= C and diff+d <= D and j % 2 == 1):
        flag = True
        break

if flag:
    print("YES")
else:
    print("NO")

Problem: p03666
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,A,B,C,D=map(int,input().split())
l=[]
for i in range(N+1):
    l.append(range(i*C-(N-i)*D,i*D-(N-i)*C+2,2))
for _ in l:
    if B-A in _:
        print("YES")
        break
else:
    print("NO")

Failing test case input:
4 7 11 4 5

Expected output:
YES


Actual output:
NO


Fixed submission (verdict: Accepted):
N,A,B,C,D=map(int,input().split())
N=N-1
l=[]
for i in range(0,N+1):
    l.append(range(i*C-(N-i)*D,i*D-(N-i)*C+1))

for _ in l:
    if B-A in _:
        print("YES")
        break
else:
    print("NO")

Problem: p03666
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,A,B,C,D = map(int,input().split())
if N > 16:
	flag = 10 **9
else:
	flag = pow(D,N)
flag -= A
B -= A
if N % 2 == 1:
	if B % (C + D) <= (N - 1) * (D - C) / 2 or abs(B % (C + D) - (C + D)) <= (N - 1) * (D - C) / 2 and B <= flag and B >= -flag:
		print("YES")
	else:
		print("NO")
else:
	m = B % ((C + D) * 2) - (D - C) / 2
	if abs(m) <= (N - 1) * (D - C) / 2 and B <= flag and B >= -flag:
		print("YES")
	else:
		print("NO")

Failing test case input:
364 1357504854 2053847691 2734001 3302098

Expected output:
YES


Actual output:
NO


Fixed submission (verdict: Accepted):
N,A,B,C,D = map(int,input().split())
flag = D * (N - 1)
B -= A
if D - C == 0:
	if A == B:
		print("YES")
	else:
		print("NO")
elif N % 2 == 1:
	if (B % (C + D) <= (N - 1) * (D - C) / 2 or abs(B % (C + D) - (C + D)) <= (N - 1) * (D - C) / 2) and B <= flag and B >= -flag:
		print("YES")
	else:
		print("NO")
else:
	if abs(B % (C + D) - (D + C) / 2) <= (N - 1) * (D - C) / 2 and B <= flag and B >= -flag:
		print("YES")
	else:
		print("NO")