ZhenlongDai/ACPR huggingface dataset:
Problem: p02974
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int, input().split())
dp = {}

dp[(0, 0, 0)] = 1

def perm(i, j, k):
  if (i, j, k) in dp:
    return dp[(i, j, k)]
  
  if i < 0 or j < 0 or k < 0 or i < j:
    return 0
  
  dp[(i, j, k)] = ((j+j+1)*perm(i-1, j, k-2*j)\
                + (j+1)*(j+1)*perm(i-1, j+1, k-2*j)\
                +  1*perm(i-1, j-1, k-2*j))%int(10e9+7)
  return dp[(i, j, k)]

print(perm(n, 0, k))

Failing test case input:
20 26

Expected output:
311240781


Actual output:
1311240788


Fixed submission (verdict: Accepted):
n, k = map(int, input().split())
dp = {}

dp[(0, 0, 0)] = 1

def perm(i, j, k):
  if (i, j, k) in dp:
    return dp[(i, j, k)]
  if i == 0:
      if k == 0 and j == 0:
          return 1
      else:
          return 0
  elif k < 0 or j < 0 or i < j:
      return 0
  else:
    dp[(i, j, k)] = ((j+j+1)*perm(i-1, j, k-2*j)\
                  + (j+1)*(j+1)*perm(i-1, j+1, k-2*j)\
                  +  1*perm(i-1, j-1, k-2*j))%(10**9+7)
    return dp[(i, j, k)]

print(perm(n, 0, k))

Problem: p02974
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int, input().split())
dp = {}

dp[(0, 0, 0)] = 1

def perm(i, j, k):
  if (i, j, k) in dp:
    return dp[(i, j, k)]
  
  if i == 0 and (j is not 0 or k is not 0):
    return 0
  
  if i < 0 or j < 0 or k < 0 or i < j:
    return 0
  
  dp[(i, j, k)] = ((j+j+1)*perm(i-1, j, k-2*j)\
                + (j+1)*(j+1)*perm(i-1, j+1, k-2*j)\
                +  1*perm(i-1, j-1, k-2*j))%int(10e9+7)
  return dp[(i, j, k)]

print(perm(n, 0, k))

Failing test case input:
31 28

Expected output:
740494022


Actual output:
5740497837


Fixed submission (verdict: Accepted):
n, k = map(int, input().split())
dp = {}

dp[(0, 0, 0)] = 1

def perm(i, j, k):
  if (i, j, k) in dp:
    return dp[(i, j, k)]
  if i == 0:
      if k == 0 and j == 0:
          return 1
      else:
          return 0
  elif k < 0 or j < 0 or i < j:
      return 0
  else:
    dp[(i, j, k)] = ((j+j+1)*perm(i-1, j, k-2*j)\
                  + (j+1)*(j+1)*perm(i-1, j+1, k-2*j)\
                  +  1*perm(i-1, j-1, k-2*j))%(10**9+7)
    return dp[(i, j, k)]

print(perm(n, 0, k))
Problem: p02974
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N, K = map(int, input().split())
m = 1000000007

dp = [[[0] * (K+2*N+1) for _ in range(N+1)] for _ in range(N+1)]

dp[0][0][0] = 1
for i in range(0, N):
  for j in range(0, i+1):
    for k in range(0, K+1):
      dp[i+1][j+1][k+2*(j+1)] = dp[i+1][j+1][k+2*(j+1)] + dp[i][j][k] % m
      dp[i+1][j][k+2*j] = dp[i+1][j][k+2*j] + dp[i][j][k] % m
      dp[i+1][j][k+2*j] = dp[i+1][j][k+2*j] + 2*j * dp[i][j][k] % m
      if j > 0:
      	dp[i+1][j-1][k+2*(j-1)] = dp[i+1][j-1][k+2*(j-1)] + j*j * dp[i][j][k] % m
print(dp[N][0][K])

Failing test case input:
44 26

Expected output:
218927913


Actual output:
1218927920


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

dp = [[[0] * (K+2*N+1) for _ in range(N+1)] for _ in range(N+1)]

dp[0][0][0] = 1
for i in range(0, N):
  for j in range(0, i+1):
    for k in range(0, K+1):
      dp[i+1][j+1][k+2*(j+1)] += dp[i][j][k]
      dp[i+1][j+1][k+2*(j+1)] %= m
      dp[i+1][j][k+2*j] += dp[i][j][k]
      dp[i+1][j][k+2*j] %= m
      dp[i+1][j][k+2*j] += 2*j * dp[i][j][k]
      dp[i+1][j][k+2*j] %= m
      if j != 0:
        dp[i+1][j-1][k+2*(j-1)] += j*j * dp[i][j][k]
        dp[i+1][j-1][k+2*(j-1)] %= m
print(dp[N][0][K])

Problem: p02974
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int, input().split())
dp = {}

dp[(0, 0, 0)] = 1

def perm(i, j, k):
  if (i, j, k) in dp:
    return dp[(i, j, k)]
  
  if i < 0 or j < 0 or k < 0:
    return 0
  
  dp[(i, j, k)] = ((j+j+1)*perm(i-1, j, k-2*j)\
                + (j+1)*(j+1)*perm(i-1, j+1, k-2*j)\
                +  1*perm(i-1, j-1, k-2*j))%int(10e9+7)
  return dp[(i, j, k)]

print(perm(n, 0, k))

Failing test case input:
47 22

Expected output:
733787098


Actual output:
6733790416


Fixed submission (verdict: Accepted):
n, k = map(int, input().split())
dp = {}

dp[(0, 0, 0)] = 1

def perm(i, j, k):
  if (i, j, k) in dp:
    return dp[(i, j, k)]
  if i == 0:
      if k == 0 and j == 0:
          return 1
      else:
          return 0
  elif k < 0 or j < 0 or i < j:
      return 0
  else:
    dp[(i, j, k)] = ((j+j+1)*perm(i-1, j, k-2*j)\
                  + (j+1)*(j+1)*perm(i-1, j+1, k-2*j)\
                  +  1*perm(i-1, j-1, k-2*j))%(10**9+7)
    return dp[(i, j, k)]

print(perm(n, 0, k))
Problem: p02974
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N, K = map(int, input().split())
m = 1e9+7

dp = [[[0] * (K+2*N+1) for _ in range(N+1)] for _ in range(N+1)]

dp[0][0][0] = 1
for i in range(0, N):
  for j in range(0, i+1):
    for k in range(0, K+1):
      dp[i+1][j+1][k+2*(j+1)] += dp[i][j][k] % m
      dp[i+1][j][k+2*j] += dp[i][j][k] % m
      dp[i+1][j][k+2*j] += 2*j * dp[i][j][k] % m
      if j > 0:
      	dp[i+1][j-1][k+2*(j-1)] += j*j * dp[i][j][k] % m
print(int(dp[N][0][K]))


Failing test case input:
44 16

Expected output:
171958174


Actual output:
1171958181


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

dp = [[[0] * (K+2*N+1) for _ in range(N+1)] for _ in range(N+1)]

dp[0][0][0] = 1
for i in range(0, N):
  for j in range(0, i+1):
    for k in range(0, K+1):
      dp[i+1][j+1][k+2*(j+1)] += dp[i][j][k]
      dp[i+1][j+1][k+2*(j+1)] %= m
      dp[i+1][j][k+2*j] += dp[i][j][k]
      dp[i+1][j][k+2*j] %= m
      dp[i+1][j][k+2*j] += 2*j * dp[i][j][k]
      dp[i+1][j][k+2*j] %= m
      if j != 0:
        dp[i+1][j-1][k+2*(j-1)] += j*j * dp[i][j][k]
        dp[i+1][j-1][k+2*(j-1)] %= m
print(dp[N][0][K])

Problem: p02974
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N, K = map(int, input().split())
m = 1e9+7

dp = [[[0] * (K+2*N+1) for _ in range(N+1)] for _ in range(N+1)]

dp[0][0][0] = 1
for i in range(0, N):
  for j in range(0, i+1):
    for k in range(0, K+1):
      dp[i+1][j+1][k+2*(j+1)] = dp[i+1][j+1][k+2*(j+1)] + dp[i][j][k] % m
      dp[i+1][j][k+2*j] = dp[i+1][j][k+2*j] + dp[i][j][k] % m
      dp[i+1][j][k+2*j] = dp[i+1][j][k+2*j] + 2*j * dp[i][j][k] % m
      if j > 0:
      	dp[i+1][j-1][k+2*(j-1)] = dp[i+1][j-1][k+2*(j-1)] + j*j * dp[i][j][k] % m
print(int(dp[N][0][K]))


Failing test case input:
44 26

Expected output:
218927913


Actual output:
1218927920


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

dp = [[[0] * (K+2*N+1) for _ in range(N+1)] for _ in range(N+1)]

dp[0][0][0] = 1
for i in range(0, N):
  for j in range(0, i+1):
    for k in range(0, K+1):
      dp[i+1][j+1][k+2*(j+1)] += dp[i][j][k]
      dp[i+1][j+1][k+2*(j+1)] %= m
      dp[i+1][j][k+2*j] += dp[i][j][k]
      dp[i+1][j][k+2*j] %= m
      dp[i+1][j][k+2*j] += 2*j * dp[i][j][k]
      dp[i+1][j][k+2*j] %= m
      if j != 0:
        dp[i+1][j-1][k+2*(j-1)] += j*j * dp[i][j][k]
        dp[i+1][j-1][k+2*(j-1)] %= m
print(dp[N][0][K])
Problem: p02963
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = int(input())
x1 = 0
y1 = 0
x2 = 10**9
y2 = 1
x3 = S%x2
y3 = S
print(x1,y1,x2,y2,x3,y3)


Failing test case input:
2048226053

Expected output:
0 0 1000000000 1 951773947 3


Actual output:
0 0 1000000000 1 48226053 2048226053


Fixed submission (verdict: Accepted):
S = int(input())
x1 = 0
y1 = 0
x2 = 10**9
y2 = 1
x3 = (x2-S%x2)%x2
y3 = -(-S
print(x1,y1,x2,y2,x3,y3)

Problem: p02963
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
S = int(input())
X1 = 0
Y1 = 0
X2 = 0
Y2 = 0
X3 = 0
Y3 = 0
if  S <= 10 ** 9:
    X2 = S
    Y3 = 1
else:
    X2 = int(math.sqrt(S))+1
    Y3 = X2
    s = X2 ** 2  - S 
    for i in range(1, int(math.sqrt(s) + 1)):
        if s%i == 0 and s%i <= 10 ** 8 and i <= 10 ** 8:
                X3 = i
                Y2 = s
                break


print (X1, Y1, X2, Y2, X3, Y3)


Failing test case input:
3592841737

Expected output:
0 0 1000000000 1 407158263 4


Actual output:
0 0 59941 81744 1 59941


Fixed submission (verdict: Accepted):
import math
S = int(input())
X1 = 0
Y1 = 0
X2 = 0
Y2 = 0
X3 = 0
Y3 = 0
if  S <= 10 ** 9:
    X2 = S
    Y3 = 1
elif S == 1000000000000000000:
    X2 = int(math.sqrt(S))
    Y3 = X2
else:
    X2 = int(math.sqrt(S) + 1)
    Y3 = X2
    s = X2 ** 2  - S 
    for i in range(1, int(math.sqrt(s) + 1)):
        if s%i == 0 and s
            X3 = i
            Y2 = s
            break

print (X1, Y1, X2, Y2, X3, Y3)

Problem: p02963
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = int(input())
x1 = 0
y1 = 0
x2 = 10**9
y2 = 1
x3 = S
y3 = S%10**9
print(x1,y1,x2,y2,x3,y3)


Failing test case input:
2702759365

Expected output:
0 0 1000000000 1 297240635 3


Actual output:
0 0 1000000000 1 2702759365 702759365


Fixed submission (verdict: Accepted):
S = int(input())
x1 = 0
y1 = 0
x2 = 10**9
y2 = 1
x3 = (x2-S%x2)%x2
y3 = -(-S
print(x1,y1,x2,y2,x3,y3)

Problem: p02963
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):

import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    s = int(input())
    x1, y1, x2, y2 = 0, 0, 10 ** 9, 1

    y3 = s 
    x3 = y3 * (10 ** 9) - s

    print(x1, y1, x2, y2, x3, y3)

if __name__ == '__main__':
    main()


Failing test case input:
4637362376438

Expected output:
0 0 1000000000 1 637623562 4638


Actual output:
0 0 1000000000 1 4637362371800637623562 4637362376438


Fixed submission (verdict: Accepted):

import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    S = int(input())

    y = -(-S 
    x = y * (10 ** 9) - S

    print(0, 0, 10 ** 9, 1, x, y)


if __name__ == '__main__':
    main()
Problem: p02963
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
input=sys.stdin.readline

s=int(input())




if s<=10**9:
    print(0,0,1,0,0,s)
    exit()

y=s
x=s%(10**9)

print(0,0,10**9,1,x,y)




Failing test case input:
997880852067

Expected output:
0 0 1000000000 1 119147933 998


Actual output:
0 0 1000000000 1 880852067 997880852067


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

s=int(input())




if s<=10**9:
    print(0,0,1,0,0,s)
    exit()

y=(-1*s
x=10**9*y-s

print(0,0,10**9,1,x,y)

Problem: p02963
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
s=int(input())
c=math.ceil(math.sqrt(s))
sa=c*c-s
for i in range(2, s):
  if sa%i==0:
    print("0 0 {} {} {} {}".format(c, i, sa/i, c))
    exit()
    

Failing test case input:
2316920905502219

Expected output:
0 0 1000000000 1 94497781 2316921


Actual output:
0 0 48134405 2 19600903.0 48134405


Fixed submission (verdict: Accepted):
import math
s=int(input())
if s==1:
  print("0 0 1 0 0 1")
  exit()
c=math.ceil(math.sqrt(s))
sa=c**2-s
for i in range(1, s):
  if sa%i==0 and sa/i <= 10**9:
    print("0 0 {} {} {} {}".format(c, i, sa
    exit()

Problem: p02963
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def f():
    s = int(input())
    y = s
    x = 10**9 - s%(10**9)

    ans = [0, 0, 10**9, 1, x, y]
    
    print(*ans)

if __name__ == '__main__':
    f()


Failing test case input:
89738690024091

Expected output:
0 0 1000000000 1 309975909 89739


Actual output:
0 0 1000000000 1 309975909 89738690024091


Fixed submission (verdict: Accepted):
def f():
    s = int(input())
    i9 = 10**9
    if s == i9 ** 2:
        print(i9, 0, 0, i9, 0, 0)
    else:
        print(i9 - (s%i9), s

if __name__ == '__main__':
    f()

Problem: p02963
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):

import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    s = int(input())
    x1, y1, x2, y2 = 0, 0, 10 ** 9, 1

    y3, x3 = divmod(s, 10**9)

    print(x1, y1, x2, y2, x3, y3)

if __name__ == '__main__':
    main()


Failing test case input:
207714184920692

Expected output:
0 0 1000000000 1 815079308 207715


Actual output:
0 0 1000000000 1 184920692 207714


Fixed submission (verdict: Accepted):

import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    S = int(input())

    y = -(-S 
    x = y * (10 ** 9) - S

    print(0, 0, 10 ** 9, 1, x, y)


if __name__ == '__main__':
    main()
Problem: p02963
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
S = int(input())
X1 = 0
Y1 = 0
X2 = 0
Y2 = 0
X3 = 0
Y3 = 0
if  S <= 10 ** 9:
    X2 = S
    Y3 = 1
else:
    X2 = int(math.sqrt(S) + 1)
    Y3 = X2
    s = X2 ** 2  - S 
    for i in range(1, int(math.sqrt(s) + 1)):
        if s%i == 0 and s%i <= 10 ** 8 and i <= 10 ** 8:
                X3 = i
                Y2 = s
                break

print (X1, Y1, X2, Y2, X3, Y3)


Failing test case input:
12126851871

Expected output:
0 0 1000000000 1 873148129 13


Actual output:
0 0 110122 3013 1 110122


Fixed submission (verdict: Accepted):
import math
S = int(input())
X1 = 0
Y1 = 0
X2 = 0
Y2 = 0
X3 = 0
Y3 = 0
if  S <= 10 ** 9:
    X2 = S
    Y3 = 1
elif S == 1000000000000000000:
    X2 = int(math.sqrt(S))
    Y3 = X2
else:
    X2 = int(math.sqrt(S) + 1)
    Y3 = X2
    s = X2 ** 2  - S 
    for i in range(1, int(math.sqrt(s) + 1)):
        if s%i == 0 and s
            X3 = i
            Y2 = s
            break

print (X1, Y1, X2, Y2, X3, Y3)

Problem: p02963
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = int(input())
X1 = 0
Y1 = 0
if S <= 10**9:
    X2 = S
    Y2 = 0
    X3 = 0
    Y3 = 1
else:
    S = 10**18 - S
    X2 = 10**9
    Y3 = 10**9
    X3 = S
    Y2 = 1
print(X1,Y1,X2,Y2,X3,Y3)
    

Failing test case input:
8917942752828

Expected output:
0 0 1000000000 1 57247172 8918


Actual output:
0 0 1000000000 1 999991082057247172 1000000000


Fixed submission (verdict: Accepted):
S = int(input())
X1 = 0
Y1 = 0
if S <= 10**9:
    X2 = S
    Y2 = 0
    X3 = 0
    Y3 = 1
elif 10**9 < S < 10**18:
    T = S % 10**9
    X2 = 10**9
    Y3 = (S 
    X3 = 10**9 - T 
    Y2 = 1
else:
  X2 = 0
  Y2 = 10**9
  X3 = 10**9
  Y3 = 0
print(X1,Y1,X2,Y2,X3,Y3)

Problem: p02963
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n=int(input())
m=1000000000
l=[0,0]
if(n<=m):
    l.append(1)
    l.append(0)
    l.append(0)
    l.append(n)
else:
    l.append(1)
    l.append(m)
    x=n%m
    y=n
    l.append(m-x)
    l.append(y)
for i in l:
    print(i,end=" ")



Failing test case input:
3205777036179

Expected output:
0 0 1000000000 1 222963821 3206


Actual output:
0 0 1 1000000000 222963821 3205777036179 

Fixed submission (verdict: Accepted):
n=int(input())
m=1000000000
l=[0,0]
if(n<=m):
    l.append(1)
    l.append(0)
    l.append(0)
    l.append(n)
elif(n == 1000000000000000000):
    l.append(m)
    l.append(0)
    l.append(0)
    l.append(m)
else:
    l.append(m)
    l.append(1)
    x=n%m
    l.append(m-x)
    l.append(((n)
for i in l:
    print(i,end=" ")

Problem: p02963
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = int(input())
x1 = 0
y1 = 0
x2 = 10**9
y2 = 0
x3 = S
y3 = S%x2
print(x1,y1,x2,y2,x3,y3)

Failing test case input:
2202554345611

Expected output:
0 0 1000000000 1 445654389 2203


Actual output:
0 0 1000000000 0 2202554345611 554345611


Fixed submission (verdict: Accepted):
S = int(input())
x1 = 0
y1 = 0
x2 = 10**9
y2 = 1
x3 = (x2-S%x2)%x2
y3 = -(-S
print(x1,y1,x2,y2,x3,y3)
Problem: p02963
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def resolve():
    s = int(input())
    
    x2, y2 = 10 ** 9, 1
    y3 = s 
    x3 = s % 10 ** 9
    print(0, 0, x2, y2, x3, y3)


if __name__ == "__main__":
    resolve()


Failing test case input:
93932089064978059

Expected output:
0 0 1000000000 1 935021941 93932090


Actual output:
0 0 1000000000 1 64978059 93932089064978059


Fixed submission (verdict: Accepted):
def resolve():
    s = int(input())
    
    x2, y2 = 10 ** 9, 1
    y3 = -(-s 
    x3 = y3 * 10 ** 9 - s
    print(0, 0, x2, y2, x3, y3)


if __name__ == "__main__":
    resolve()

Problem: p02963
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N =int(input())
print(0,0,1,10**9,0,N%10**9)

Failing test case input:
238429723295099

Expected output:
0 0 1000000000 1 276704901 238430


Actual output:
0 0 1 1000000000 0 723295099


Fixed submission (verdict: Accepted):
N =-int(input())
M=10**9
print(0,0,1,M,0-N

Problem: p02963
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = int(input())
x1 = 0
y1 = 0
x2 = 10**9
y2 = 0
x3 = S
y3 = (x2-S%x2)%x2
print(x1,y1,x2,y2,x3,y3)

Failing test case input:
904368770264

Expected output:
0 0 1000000000 1 631229736 905


Actual output:
0 0 1000000000 0 904368770264 631229736


Fixed submission (verdict: Accepted):
S = int(input())
x1 = 0
y1 = 0
x2 = 10**9
y2 = 1
x3 = (x2-S%x2)%x2
y3 = -(-S
print(x1,y1,x2,y2,x3,y3)

Problem: p02963
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):

import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    s = int(input())
    x1, y1, x2, y2 = 0, 0, 10 ** 9, 1

    x3, y3 = divmod(s, 10**9)

    print(x1, y1, x2, y2, x3, y3)

if __name__ == '__main__':
    main()


Failing test case input:
2680236341369

Expected output:
0 0 1000000000 1 763658631 2681


Actual output:
0 0 1000000000 1 2680 236341369


Fixed submission (verdict: Accepted):

import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    S = int(input())

    y = -(-S 
    x = y * (10 ** 9) - S

    print(0, 0, 10 ** 9, 1, x, y)


if __name__ == '__main__':
    main()

Problem: p02963
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = int(input())
l = [0,0,10**9,1,0,0]
l[5] = s
l[4] = 10**9-(s%(10**9))
print(*l)

Failing test case input:
1731666236414

Expected output:
0 0 1000000000 1 333763586 1732


Actual output:
0 0 1000000000 1 333763586 1731666236414


Fixed submission (verdict: Accepted):
s = int(input())
l = [0,0,10**9,1,10**9-(s%(10**9)),s
if s == 10**18:
  l = [0,0,10**9,0,0,10**9]
print(*l)
Problem: p02963
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
  return list(map(int,input().split()))
def m(): 
  return map(int,input().split())
def onem(): 
  return int(input())
def s(x): 
  a = []
  if len(x) == 0:
    return []
  aa = x[0]
  su = 1
  for i in range(len(x)-1):
    if aa != x[i+1]:
      a.append([aa,su])
      aa = x[i+1]
      su = 1
    else:
      su += 1
  a.append([aa,su])
  return a
def jo(x): 
  return " ".join(map(str,x))
def max2(x): 
  return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans



s = onem()

x = [0,10**9,0]
y = [0,1,0]

x[-1] = s % 10**9
y[-1] = s 

print(x[0],y[0],x[1],y[1],x[2],y[2])



Failing test case input:
2048226053

Expected output:
0 0 1000000000 1 951773947 3


Actual output:
0 0 1000000000 1 48226053 2048226053


Fixed submission (verdict: Accepted):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
  return list(map(int,input().split()))
def m(): 
  return map(int,input().split())
def onem(): 
  return int(input())
def s(x): 
  a = []
  if len(x) == 0:
    return []
  aa = x[0]
  su = 1
  for i in range(len(x)-1):
    if aa != x[i+1]:
      a.append([aa,su])
      aa = x[i+1]
      su = 1
    else:
      su += 1
  a.append([aa,su])
  return a
def jo(x): 
  return " ".join(map(str,x))
def max2(x): 
  return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans



s = onem()

x = [0,10**9,0]
y = [0,1,0]

x[-1] = -s % 10**9
y[-1] = -(-s 

print(x[0],y[0],x[1],y[1],x[2],y[2])

Problem: p02963
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = int(input())

X1, Y1 = 0, 0

X2 = 10**9
Y3 = S

X3 = 1
Y2 = (10**9) - S%(10**9)

print(X1, Y1, X2, Y2, X3, Y3)

Failing test case input:
238429723295099

Expected output:
0 0 1000000000 1 276704901 238430


Actual output:
0 0 1000000000 276704901 1 238429723295099


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





X1, Y1 = 0, 0

X2 = 10**9
Y3 = -(-S

X3 = 1
Y2 = -(S%-(10**9))

print(X1, Y1, X2, Y2, X3, Y3)

Problem: p02963
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S = int(input())
x1 = 0
y1 = 0
x2 = 10**9
y2 = 1
x3 = S
y3 = (x2-S%x2)%x2
print(x1,y1,x2,y2,x3,y3)

Failing test case input:
3592841737

Expected output:
0 0 1000000000 1 407158263 4


Actual output:
0 0 1000000000 1 3592841737 407158263


Fixed submission (verdict: Accepted):
S = int(input())
x1 = 0
y1 = 0
x2 = 10**9
y2 = 1
x3 = (x2-S%x2)%x2
y3 = -(-S
print(x1,y1,x2,y2,x3,y3)
Problem: p03783
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):

N = int(input())
P = [list(map(int, input().split())) for i in range(N)]

INF = 10**18

from heapq import heappush, heappop

l0, r0 = P[0]

L = [-l0+1]
R = [l0-1]
s = t = 0

def debug(L, s, t, R):
    L0 = L[:]
    Q1 = []; Q2 = []
    while L0:
        Q1.append(-s-heappop(L0))
    R0 = R[:]
    while R0:
        Q2.append(t+heappop(R0))
    print("debug:", *Q1[::-1]+Q2)



res = 0
for i in range(N-1):
    l0, r0 = P[i]
    l1, r1 = P[i+1]
    
    s += (r1 - l1); t += (r0 - l0)
    if -s-L[0] <= l1-1 <= t+R[0]:
        
        heappush(L, -l1+1-s)
        heappush(R, l1-1-t)
        
    elif l1-1 < -s-L[0]:
        
        heappush(L, -l1+1-s)
        heappush(L, -l1+1-s)
        p = -heappop(L)-s
        d = p - (-L[0]-s)
        heappush(R, p-t)
        
        if d == 0:
            res += p - (l1-1)
        else:
            res += d
    elif t+R[0] < l1-1:
        
        heappush(R, l1-1-t)
        heappush(R, l1-1-t)
        p = heappop(R) + t
        d = R[0]+t - p
        heappush(L, -p-s)
        
        if d == 0:
            res += (l1-1) - p
        else:
            res += d
    
    
print(res)


Failing test case input:
5
70352 110697
26 77
12 34189511
107865 80582
0 33

Expected output:
178107


Actual output:
150845


Fixed submission (verdict: Accepted):

N = int(input())
P = [list(map(int, input().split())) for i in range(N)]

INF = 10**18

from heapq import heappush, heappop

l0, r0 = P[0]

L = [-l0+1]
R = [l0-1]
s = t = 0

def debug(L, s, t, R):
    L0 = L[:]
    Q1 = []; Q2 = []
    while L0:
        Q1.append(-s-heappop(L0))
    R0 = R[:]
    while R0:
        Q2.append(t+heappop(R0))
    print("debug:", *Q1[::-1]+Q2)



res = 0
for i in range(N-1):
    l0, r0 = P[i]
    l1, r1 = P[i+1]
    
    s += (r1 - l1); t += (r0 - l0)
    if -s-L[0] <= l1-1 <= t+R[0]:
        
        heappush(L, -l1+1-s)
        heappush(R, l1-1-t)
        
    elif l1-1 < -s-L[0]:
        
        heappush(L, -l1+1-s)
        heappush(L, -l1+1-s)
        p = -heappop(L)-s
        
        heappush(R, p-t)
        
        
        res += (p - (l1-1))
    elif t+R[0] < l1-1:
        
        heappush(R, l1-1-t)
        heappush(R, l1-1-t)
        p = heappop(R) + t
        
        heappush(L, -p-s)
        
        res += (l1-1 - p)
    
    
print(res)
Problem: p03766
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
input = sys.stdin.readline

MOD = 10**9 + 7
N = int(input())

dp = [0] * (N+10)
dp_cum = [0] * (N+10)

dp[1] = N-1; dp_cum[1] = N-1
dp[2] = N-1; dp_cum[2] = 2*(N-1)
for n in range(3,N+1):
    dp[n] = dp[n-1] + dp_cum[n-3]
    dp_cum[n] = (dp_cum[n-1] + dp[n]) % MOD

answer = sum(dp[1:N])*N + dp[-1] + 1
answer %= MOD
print(answer)

Failing test case input:
395899

Expected output:
310829317


Actual output:
112394772


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

MOD = 10**9 + 7
N = int(input())

dp = [0] * (N+10)
dp_cum = [0] * (N+10)

dp[1] = N-1; dp_cum[1] = N-1
dp[2] = N-1; dp_cum[2] = 2*(N-1)
for n in range(3,N+1):
    dp[n] = dp[n-1] + dp_cum[n-3]
    dp_cum[n] = (dp_cum[n-1] + dp[n]) % MOD

answer = sum(dp[1:N])*N + dp[N] + 1
answer %= MOD
print(answer)
Problem: p03374
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,c=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]

rev=[None]*(n+1)
norm=[None]*(n+1)
rev[0]=(0,0)
norm[0]=(0,0)
ans=0


for i in range(1,n+1):
    x,v=l[i-1]
    norm[i]=(x,v+norm[i-1][1])


for i in range(1,n+1)[::-1]:
    x,v=l[i-1]
    if i==n:
        rev[i]=(c-x,v)
    else:
        rev[i]=(c-x,v+rev[i+1][1])

for i in range(n+1):
    for j in range(n-i):
        cost=min(norm[i][0]+2*rev[-j][0],2*norm[i][0]+rev[-j][0])
        ans=max(ans,rev[-j][1]+norm[i][1]-cost)

print(ans)

Failing test case input:
3 13
0 56
2 85
25 2

Expected output:
165


Actual output:
139


Fixed submission (verdict: Accepted):
n,c=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]

rev=[None]*(n+1)
norm=[None]*(n+1)
revmax=[None]*(n+1)

rev[0]=(0,0)
revmax[0]=(0,0)
norm[0]=(0,0)
ans=0


for i in range(1,n+1):
    x,v=l[i-1]
    norm[i]=(x,v+norm[i-1][1])


for i in range(1,n+1)[::-1]:
    x,v=l[i-1]
    if i==n:
        rev[i]=(c-x,v)
    else:
        rev[i]=(c-x,v+rev[i+1][1])

for i in range(1,n+1):
    revmax[-i]=(max(revmax[-i+1][0],rev[-i][1]-2*rev[-i][0]),max(revmax[-i+1][1],rev[-i][1]-rev[-i][0]))

for i in range(n+1):
    v1=norm[i][1]-norm[i][0]+revmax[i-n][0]
    v2=norm[i][1]-2*norm[i][0]+revmax[i-n][1]
    ans=max(ans,v1,v2)

print(ans)

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

xv = []
go = [0]
goback = [0]
back = [0]
backgo = [0]

mid = 0

for i in range(n):
    xv.append(list(map(int,input().split())))
    if 2*xv[i][0]<= c: mid = i

temp = 0
for i in range(mid+1):
    temp += xv[i][1]
    go.append(temp-xv[i][0])
    goback.append(temp-2*xv[i][0])
temp = 0
for i in range(mid+1,n)[::-1]:
    temp += xv[i][1]
    back.append(temp-(c-xv[i][0]))
    backgo.append(temp-2*(c-xv[i][0]))

print(max(max(go)+max(backgo),max(back)+max(goback)))


Failing test case input:
3 10
2 80
9 120
16 0

Expected output:
203


Actual output:
196


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

xv = []
go = []
goback = []
back = []
backgo = []

max1 = 0
sumt = 0

for i in range(n):
    xv.append(list(map(int,input().split())))
    sumt += xv[i][1]
    max1 = max(max1,sumt - xv[i][0])
    go.append(max1)
    goback.append(sumt - 2*xv[i][0])

max1 = 0
sumt = 0

for i in range(n)[::-1]:
    sumt += xv[i][1]
    max1 = max(max1, sumt - (c - xv[i][0]))
    back.append(max1)
    backgo.append(sumt - 2 * (c - xv[i][0]))

res = 0

for i in range(n-1):
    res = max(res,backgo[i]+go[-2-i],goback[i]+back[-2-i])

res = max(res,go[-1],back[-1],0)

print(res)
Problem: p03959
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
T = list(map(int, input().split(" ")))
A = list(map(int, input().split(" ")))
h = [-1 for i in range(N)]
mod = 10 ** 9 + 7

h[0] = T[0]
h[N - 1] = A[N - 1]
for i in range(N - 1):
    if T[i] < T[i + 1]:
        h[i + 1] = T[i + 1]

for i in range(N - 1):
    if A[i + 1] < A[i] and (h[i] == -1 or h[i] == A[i]):
        h[i] = A[i]
    elif A[i + 1] < A[i]:
        h[i] = 0

ans = 1
for i in range(N):
    if h[i] == 0:
        ans *= h[i]
        break
    elif h[i] == -1:
        ans *= min(T[i], A[i])
        ans %= mod

if A[N - 1] != T[0]:
    print(0)
else:
    print(ans % mod)

Failing test case input:
10
1 3776 3776 8848 8848 8848 8848 8848 8848 8848
8848 8848 8848 8848 8848 8848 8848 8848 3776 5

Expected output:
884111967

Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
T = list(map(int, input().split(" ")))
A = list(map(int, input().split(" ")))
h = [0 for i in range(N)]
mod = 10 ** 9 + 7

h[0] = T[0]
for i in range(N - 1):
    if T[i] < T[i + 1]:
        h[i + 1] = T[i + 1]
    else:
        h[i + 1] = -T[i + 1]

if h[N - 1] == 0:
    h[N - 1] = A[N - 1]
else:
    if -h[N - 1] >= A[N - 1]:
        h[N - 1] = A[N - 1]
    elif h[N - 1] != A[N - 1]:
        h[N - 1] = 0

for i in range(1, N):
    if A[i - 1] > A[i]:
        if -h[i - 1] >= A[i - 1]:
            h[i - 1] = A[i - 1]
        elif h[i - 1] != A[i - 1]:
            h[i - 1] = 0
    else:
        if h[i - 1] < 0:
            h[i - 1] = -min(-h[i - 1], A[i - 1])


ans = 1
for hi in h:
    if hi <= 0:
        ans *= -hi
        ans %= mod

print(ans)
Problem: p03959
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
T = list(map(int, input().split()))
A = list(map(int, input().split()))

M = [[-1, 10**9] for i in range(N)]

for i in range(N):
    if i == 0:
        M[i][0] = T[i]
    else:
        if T[i] != T[i-1]:
            M[i][0] = T[i]
        else:
            M[i][1] = T[i]

for i in range(N-1, -1, -1):
    if i == N-1:
        if M[i][0] != -1 and M[i][0] != A[i]:
            print(0)
            exit(0)
        else:
            M[i][0] = A[i]

    else:
        if A[i] != A[i+1]:
            if M[i][0] != -1 and M[i][0] != A[i]:
                print(0)
                exit(0)
            else:
                M[i][0] = A[i]
        else:
            M[i][1] = min(M[i][1], A[i])
print(M)
ans = 1
mod = (10 ** 9) + 7
for x, y in M:
    if x == -1:
        ans *= y
        ans %= mod

print(ans)


Failing test case input:
10
1 3776 3776 8848 8848 8848 8848 8848 8848 8848
8848 8848 8848 8848 8848 8848 8848 8848 3776 5

Expected output:
884111967

Actual output:
[[1, 8848], [3776, 8848], [-1, 3776], [8848, 8848], [-1, 8848], [-1, 8848], [-1, 8848], [8848, 8848], [3776, 8848], [5, 8848]]
884111967


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

M = [[-1, 10**9] for i in range(N)]

for i in range(N):
    if i == 0:
        M[i][0] = T[i]
    else:
        if T[i] != T[i-1]:
            M[i][0] = T[i]
        else:
            M[i][1] = T[i]

for i in range(N-1, -1, -1):
    if i == N-1:
        if M[i][0] != -1 and M[i][0] != A[i]:
            print(0)
            exit(0)
        else:
            if M[i][1] >= A[i]:
                M[i][0] = A[i]
            else:
                print(0)
                exit(0)

    else:
        if A[i] != A[i+1]:
            if M[i][0] != -1 and M[i][0] != A[i]:
                print(0)
                exit(0)
            else:
                if A[i] <= M[i][1]:
                    M[i][0] = A[i]
                else:
                    print(0)
                    exit(0)
        else:
            M[i][1] = min(M[i][1], A[i])
ans = 1
mod = (10 ** 9) + 7
for x, y in M:
    if x == -1:
        ans *= y
        ans %= mod

print(ans)
Problem: p03959
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
T = list(map(int,input().split()))
A = list(map(int,input().split()))
ans = 1; MOD = pow(10,9)+7
if N == 1:
  if A[0] == T[0]:
    print(1)
  else:
    print(0)
  exit()
for i in range(N):
  if i == 0: 
    if A[i] == A[i+1]: 
      fac = T[0]
    else: 
      if A[i] > T[0]: 
        fac = 0
      else:
        fac = 1
  elif i < N-1: 
    if T[i] == T[i-1]: 
      if A[i] == A[i+1]: 
        fac = min(T[i],A[i])
      else: 
        if A[i] > T[i]: 
          fac = 0
        else:
          fac = 1
    else: 
      if A[i] == A[i+1]: 
        if T[i] > A[i]: 
          fac = 0
        else:
          fac = 1
      else: 
        if T[i] == A[i]:
          fac = 1
        else:
          fac = 0
  else: 
    if T[i] == T[i-1]: 
      if A[i] > T[i]: 
        fac = 0
      else:
        fac = 1
    else: 
      if T[i] == A[i]:
        fac = 1
      else:
        fac = 0
  ans = (ans*fac)%MOD
print(ans%MOD)
      
      
    

Failing test case input:
5
2 3 3 3 3
3 3 2 2 2

Expected output:
4


Actual output:
8


Fixed submission (verdict: Accepted):
N = int(input())
T = list(map(int,input().split()))
A = list(map(int,input().split()))
ans = 1; MOD = pow(10,9)+7
if N == 1:
  if A[0] == T[0]:
    print(1)
  else:
    print(0)
  exit()
for i in range(N):
  if i == 0: 
    if A[i] == A[i+1]: 
      fac = 1
    else: 
      if A[i] > T[0]: 
        fac = 0
      else:
        fac = 1
  elif i < N-1: 
    if T[i] == T[i-1]: 
      if A[i] == A[i+1]: 
        fac = min(T[i],A[i])
      else: 
        if A[i] > T[i]: 
          fac = 0
        else:
          fac = 1
    else: 
      if A[i] == A[i+1]: 
        if T[i] > A[i]: 
          fac = 0
        else:
          fac = 1
      else: 
        if T[i] == A[i]:
          fac = 1
        else:
          fac = 0
  else: 
    if T[i] == T[i-1]: 
      if A[i] > T[i]: 
        fac = 0
      else:
        fac = 1
    else: 
      if T[i] == A[i]:
        fac = 1
      else:
        fac = 0
  ans = (ans*fac)%MOD
print(ans%MOD)
Problem: p03959
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):








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

Tsa = [0]*n
Asa = [0]*n

if n == 1:
	if T[0] != A[0]:
		print(0)
	else:
		print(1)
elif T[0] != A[-1]:
	print(0)
else:
	
	dai = T[0]
	shou = T[0]
	Tsa[0] = (shou, dai)

	for i in range(1, n):
		if T[i] == dai:
			Tsa[i] = (shou, dai)
		else:
			shou = dai
			dai = T[i]
			Tsa[i] = (dai, dai)

	
	dai = A[-1]
	shou = A[-1]
	Asa[-1] = (shou, dai)

	for i in reversed(range(-n, -1)):
		if A[i] == dai:
			Asa[i] = (shou, dai)
		else:
			shou = dai
			dai = A[i]
			Asa[i] = (dai, dai)

	ans = 1
	for i in range(n):
		d = max(Tsa[i][0], Asa[i][0])
		u = min(Tsa[i][1], Asa[i][1])

		if d > u:
			ans = 0
			break
		else:
			ans *= u - d + 1
	print(ans)


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

Expected output:
4

Actual output:
0


Fixed submission (verdict: Accepted):







MOD = int(1e9) + 7
n = int(input())
T = list(map(int, input().split()))
A = list(map(int, input().split()))

Tsa = [0]*n
Asa = [0]*n

if n == 1:
	if T[0] != A[0]:
		print(0)
	else:
		print(1)
elif T[-1] != A[0]:
	print(0)
else:
	
	dai = T[0]
	shou = T[0]
	Tsa[0] = (shou, dai)

	for i in range(1, n):
		if T[i] == dai:
			Tsa[i] = (1, dai)
		else:
			dai = T[i]
			Tsa[i] = (dai, dai)

	
	dai = A[-1]
	shou = A[-1]
	Asa[-1] = (shou, dai)

	for i in reversed(range(-n, -1)):
		if A[i] == dai:
			Asa[i] = (1, dai)
		else:
			dai = A[i]
			Asa[i] = (dai, dai)

	
	ans = 1
	for i in range(n):
		d = max(Tsa[i][0], Asa[i][0])
		u = min(Tsa[i][1], Asa[i][1])

		if d > u:
			ans = 0
			break
		else:
			ans *= u - d + 1
			ans %= MOD
	print(ans)
Problem: p03959
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

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

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n=I()

  a=LI()
  b=LI()

  if n==1 and a[0]!=b[0]:
    return 0

  if n==1 and a[0]==17 and b[0]==17:
    exit()

  l1=[]
  l2=[]

  amx=a[0]
  l1.append(1)
  for i in range(1,len(a)):
    x=a[i]
    if amx<x:
      
      if x>b[i]:
        print(0)
        exit()

      l1.append(1)
      amx=x
    elif amx==x:
      l1.append(amx)
    else:
      print(0)
      exit()

  b.reverse()
  l1.reverse()

  bmx=b[0]
  l2.append(1)
  for i in range(1,len(b)):
    x=b[i]
    if bmx<x:
      
      if x>a[n-i-1]:
        print(0)
        exit()

      l2.append(1)
      bmx=x
    elif bmx==x:
      l2.append(min(bmx,l1[i]))
    else:
      print(0)
      exit()

  ans=1
  for x in l2:
    ans*=x
    ans%=mod

  return ans


print(main())


Failing test case input:
1
17
17

Expected output:
1

Actual output:

Fixed submission (verdict: Accepted):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

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

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n=I()

  a=LI()
  b=LI()

  if n==1 and a[0]!=b[0]:
    return 0

  l1=[]
  l2=[]

  amx=a[0]
  l1.append(1)
  for i in range(1,len(a)):
    x=a[i]
    if amx<x:
      
      if x>b[i]:
        print(0)
        exit()

      l1.append(1)
      amx=x
    elif amx==x:
      l1.append(amx)
    else:
      print(0)
      exit()

  b.reverse()
  l1.reverse()

  bmx=b[0]
  l2.append(1)
  for i in range(1,len(b)):
    x=b[i]
    if bmx<x:
      
      if x>a[n-i-1]:
        print(0)
        exit()

      l2.append(1)
      bmx=x
    elif bmx==x:
      l2.append(min(bmx,l1[i]))
    else:
      print(0)
      exit()

  ans=1
  for x in l2:
    ans*=x
    ans%=mod

  return ans

print(main())
Problem: p03959
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
T=list(map(int,input().split()))
A=list(map(int,input().split()))
if T[len(A)-1]!=A[0]:
    print(-1)
else:
        
    t=[1]
    for i in range(1,N):
        if T[i-1]!=T[i]:
            t.append(1)
        else:
            t.append(T[i])
        if T[i-1]>T[i]:
            print(-1)
            exit()
    A=A[::-1]
    a=[1]
    for i in range(1,N):
        if A[i-1]!=A[i]:
            a.append(1)
        else:
            a.append(A[i])
        if A[i-1]>A[i]:
            print(-1)
            exit()
    A=A[::-1]
    a=a[::-1]
    
    ans=1
    for i in range(N):
        ans*=min(t[i],a[i])
        ans%=(10**9+7)
    print(ans)

Failing test case input:
5
3 0 0 0 -1
20 5 -1 0 -11

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
N=int(input())
T=list(map(int,input().split()))
t=[1]
for i in range(1,N):
    if T[i]!=T[i-1]:
        t.append(1)
    else:
        t.append(T[i])
    if T[i]<T[i-1]:
        print(0)
        exit()
A=list(map(int,input().split()))
A=A[::-1]
a=[1]
for i in range(1,N):
    if A[i]!=A[i-1]:
        a.append(1)
    else:
        a.append(A[i])
    if A[i]<A[i-1]:
        print(0)
        exit()
A=A[::-1]
a=a[::-1]


M=max(A)

for i in range(N):
    if T[i]==M:
        if A[i]==M:
            break
        else:
            print(0)
            exit()

for i in range(N):
    if A[N-1-i]==M:
        if T[N-1-i]==M:
            break
        else:
            print(0)
            exit()
ans=1
mod=(10**9+7)
for i in range(N):
    ans*=min(t[i],a[i])
    ans%=mod
print(ans)

Problem: p03959
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
l= list(map(int, input().split()))
r= list(map(int, input().split()))
l=[0]+l
r.append(0)

res=1
for i in range(n):
	if( (l[i]<l[i+1]) or (r[i]>r[i+1]) ):
		if( ( (l[i]<l[i+1]) and (r[i]>r[i+1]) ) and (l[i+1]!=r[i]) ):
			res*=0
	else:
		res*=min(l[i],r[i])
		res%=1000000007
print(res)


Failing test case input:
5
3 0 1 0 2
8 10 -2 0 -7

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
n=int(input())
l= list(map(int, input().split()))
r= list(map(int, input().split()))
l=[0]+l
r.append(0)
 
res=1
if(l[-1]!=r[0]):
	res=0
for i in range(n):
	if( (l[i]<l[i+1]) or (r[i]>r[i+1]) ):
		if( ( (l[i]<l[i+1]) and (r[i]>r[i+1]) ) and (l[i+1]!=r[i]) ):
			res=0
		if( ( (l[i]<l[i+1]) and (r[i]==r[i+1]) ) and (l[i+1]>r[i]) ):
			res=0
		if( ( (l[i]==l[i+1]) and (r[i]>r[i+1]) ) and (l[i+1]<r[i]) ):
			res=0
	else:
		res*=min(l[i],r[i])
		res%=1000000007
print(res)
Problem: p03959
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
t=[int(j) for j in input().split()]
a=[int(j) for j in input().split()]
tmp=0
l=[]
for i in t:
    if tmp<i:
        l.append(-i)
        tmp=i
    else:
        l.append(i)
tmp=0
ans=1
mod=10**9+7
for i in range(n)[::-1]:
    if tmp<a[i]:
        if l[i]>=a[i]:
            tmp=a[i]
        else:
            if l[i]>0:
                print(0)
                exit()
    else:
        if l[i]>0:
            ans=(ans*min(a[i],l[i]))%mod
print(ans)

Failing test case input:
5
7 -1 1 -2 -2
20 3 -8 0 -1

Expected output:
0


Actual output:
999999999


Fixed submission (verdict: Accepted):
n=int(input())
t=[int(j) for j in input().split()]
a=[int(j) for j in input().split()]
tmp=0
l=[]
for i in t:
    if tmp<i:
        l.append(-i)
        tmp=i
    else:
        l.append(i)
tmp=0
ans=1
mod=10**9+7
for i in range(n)[::-1]:
    if tmp<a[i]:
        tmp=a[i]
        if l[i]<a[i]:
            if l[i]>0 or -l[i]!=a[i]:
                print(0)
                exit()
    else:
        if l[i]>0:
            ans=(ans*min(a[i],l[i]))%mod
print(ans)

Problem: p03959
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def read():
	return [int(i) for i in input().split(" ")]
N = int(input())
T = read()
A = read()
t = [(i != j, i) for i, j in zip(T, [None] + T)]
a = [(i != j, i) for i, j in zip(A, (A + [None])[1:])]
P = 1
for p, q in zip(t, a):
	if(p[0]):
		if(q[0]):
			if(p[1] != q[1]):
				print(0)
				exit()
		elif(q[1] < p[1]):
			print(0)
			exit()
	elif(q[0]):
		if(p[1] < q[1]):
			print(0)
			exit()
	else:
		P *= min(p[1], q[1]) % (10 ** 9 + 7)
print(P)


Failing test case input:
10
1 3776 3776 8848 8848 8848 8848 8848 8848 8848
8848 8848 8848 8848 8848 8848 8848 8848 3776 5

Expected output:
884111967

Actual output:
2615575902420992


Fixed submission (verdict: Accepted):
def read():
	return [int(i) for i in input().split(" ")]
N = int(input())
T = read()
A = read()
t = [(i != j, i) for i, j in zip(T, [None] + T)]
a = [(i != j, i) for i, j in zip(A, (A + [None])[1:])]
P = 1
for p, q in zip(t, a):
	if(p[0]):
		if(q[0]):
			if(p[1] != q[1]):
				print(0)
				exit()
		else:
			if(q[1] < p[1]):
				print(0)
				exit()
	elif(q[0]):
		if(p[1] < q[1]):
			print(0)
			exit()
	else:
		P = P * min(p[1], q[1]) % (10 ** 9 + 7)
print(P)
Problem: p03959
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
A = list(map(int, input().split()))
T = list(map(int, input().split()))

mod = int(1e9+7)

dp = [0] * (N)
dp[0] = 1


Amax = max(A)
Aleft, Tright = -1, -1
Tmax = max(T)
for i in range(N):
  if Amax == A[i]:
    Aleft = i
    break
for i in range(N-1,-1,-1):
  if Tmax == T[i]:
    Tright = i
    break
if Aleft > Tright:
  print(0)
  exit(0)
  
for i in range(1,N-1):
  if A[i-1] < A[i] or T[i] > T[i+1]:
    dp[i] = dp[i-1]
    if A[i] != T[i]:
      print(0)
      exit(0)
  else:
    dp[i] = dp[i-1] * min(A[i], T[i]) % mod
    
print(dp[N-2])


Failing test case input:
10
1 3776 3776 8848 8848 8848 8848 8848 8848 8848
8848 8848 8848 8848 8848 8848 8848 8848 3776 5

Expected output:
884111967

Actual output:
0


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

mod = int(1e9+7)

dp = [0] * (N)
dp[0] = 1


Amax = max(A)
Aleft, Tright = -1, -1
Tmax = max(T)
for i in range(N):
  if Amax == A[i]:
    Aleft = i
    break
for i in range(N-1,-1,-1):
  if Tmax == T[i]:
    Tright = i
    break
if Aleft > Tright:
  print(0)
  exit(0)
if A[-1] != T[0]:
  print(0)
  exit(0)
  
for i in range(1,N-1):
  if A[i-1] < A[i] or T[i] > T[i+1]:
    dp[i] = dp[i-1]
  else:
    dp[i] = dp[i-1] * min(A[i], T[i]) % mod
  
print(dp[N-2])

Problem: p03959
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n=int(input())

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


print(0)
exit()

kakute=[0]*n
kakute[0]=1

for i in range(1,n):
    if t[i]>t[i-1]:
        kakute[i]=1

a=a[::-1]
ans=1

for i in range(1,n):
    index=n-i-1
    
    if a[i]>a[i-1]:
        
        if a[i]>t[index]:
            print(0)
            exit()
        elif kakute[index]==1:
            if a[i] != t[index]:
                print(0)
                exit()
    
    else:
        
        if kakute[index]==1:
            if t[index]>a[i]:
                print(0)
                exit()
        else:
            ans=ans*min(a[i],t[index])%(10**9+7)

print(ans%(10**9+7))


            

        









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

Expected output:
4

Actual output:
0


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

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


kakute=[0]*n
kakute[0]=1

if n==1:
    if t[0]!=a[0]:
        print(0)
        exit()

for i in range(1,n):
    if t[i]>t[i-1]:
        kakute[i]=1

a=a[::-1]
ans=1

for i in range(1,n):
    index=n-i-1
    
    if a[i]>a[i-1]:
        
        if a[i]>t[index]:
            print(0)
            exit()
        
        elif kakute[index]==1:
            if a[i] != t[index]:
                print(0)
                exit()
    
    else:
        
        if kakute[index]==1:
            if t[index]>a[i]:
                print(0)
                exit()
        
        else:
            ans=ans*min(a[i],t[index])%(10**9+7)

print(ans%(10**9+7))
Problem: p03959
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


def main():
    N = int(input())
    t = list(map(int, input().split()))
    a = list(reversed(list(map(int, input().split()))))

    m = [0] * N

    b = 0
    for i,h in enumerate(t):
        if b != h:
            m[i] = h
        b = h
    b = 0
    for j,h in enumerate(a):
        if b != h:
            if m[N-j-1] != 0 and m[N-j-1] != h:
                print(0)
                return
            else:
                m[N-j-1] = h
        b = h
    res = 1
    for k,h in enumerate(m):
        if h == 0:
            print(a[N-k-1], t[k])
            res = res * min(a[N-k-1], t[k]) % (pow(10, 9) + 7)
    print(res)

main()


Failing test case input:
10
1 3776 3776 8848 8848 8848 8848 8848 8848 8848
8848 8848 8848 8848 8848 8848 8848 8848 3776 5

Expected output:
884111967

Actual output:
8848 3776
8848 8848
8848 8848
8848 8848
884111967


Fixed submission (verdict: Accepted):


def main():
    N = int(input())
    t = list(map(int, input().split()))
    a = list(reversed(list(map(int, input().split()))))

    m = [0] * N

    b = 0
    for i,h in enumerate(t):
        if b != h:
            m[i] = h
            if a[N-i-1] < h:
                print(0)
                return
        b = h
    b = 0
    for j,h in enumerate(a):
        p = N-j-1
        if b != h:
            if m[p] != 0 and m[p] != h:
                print(0)
                return
            else:
                m[p] = h
                if t[p] < h:
                    print(0)
                    return
        b = h
    res = 1
    for k,h in enumerate(m):
        if h == 0:
            res = res * min(a[N-k-1], t[k]) % (pow(10, 9) + 7)
    print(res)
    return

main()

Problem: p03959
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
mod = 10 ** 9 + 7

N = int(input())
T = [0] + list(map(int, input().split()))
A = list(map(int, input().split())) + [0]

H = [0] * N
for i in range(1, N + 1):
    if T[i - 1] < T[i]:
        H[i - 1] = T[i]
for i in range(N - 1, -1, -1):
    if A[i + 1] < A[i]:
        if H[i] == 0 or H[i] == A[i]:
            H[i] = A[i]
        else:
            print(0)
            exit()

ans = 1
T.pop(0)
A.pop(-1)
for h, t, a in zip(H, T, A):
    if h == 0:
        ans *= min(t, a)
        ans %= mod
print(ans)

Failing test case input:
5
16 0 0 -1 0
20 24 -1 0 -11

Expected output:
0


Actual output:
999999996


Fixed submission (verdict: Accepted):
mod = 10 ** 9 + 7

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

H = [0] * N
for i in range(N):
    if i == 0 or T[i - 1] < T[i]:
        H[i] = T[i]

for i in range(N - 1, -1, -1):
    if i == N - 1 or A[i] > A[i + 1]:
        H[i] = A[i]
    
ans = 1
for i in range(N):
    if H[i] == 0:
        H[i] = min(T[i], A[i])
        ans *= min(T[i], A[i])
        ans %= mod

flag = True
M = 0
for i in range(N):
    M = max(M, H[i])
    flag &= (M == T[i])
M = 0
for i in range(N - 1, -1, -1):
    M = max(M, H[i])
    flag &= (M == A[i])

if flag is True:
    print(ans)
else:
    print(0)