TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: A game is played on a strip consisting of N cells consecutively numbered from 1 to N.  Alice has her token on cell A. Borys has his token on a different cell B.  Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once.  The player who can't make a move loses, and the other player wins.  Both players want to win. Who wins if they play optimally?

Submission attempts (in order):
n, a, b = map(int, input().split())
turn = 0
while True: 
  if turn == 0:
    if a + 1 < b:
      a += 1
      print('a', a)
    elif 0 < a :
      a -= 1
      print('a', a)
    else:
      break
    turn = 1
  elif turn == 1:
    if a + 1 < b:
      b -= 1
      print('b', b)
    elif a + 1 == b and b != n:
      b += 1
      print('b', b)
    else:
      break
    turn = 0

if turn == 0:
  print('Borys')
else:
  print('Alice')


n, a, b = map(int, input().split())
turn = 0
while True: 
  if turn == 0:
    if a + 1 < b:
      a += 1
    elif 0 < a :
      a -= 1
    else:
      break
    turn = 1
  elif turn == 1:
    if a + 1 < b:
      b -= 1
    elif a + 1 == b and b != n:
      b += 1
    else:
      break
    turn = 0

if turn == 0:
  print('Borys')
else:
  print('Alice')


Verdicts: Wrong Answer

Accepted
Problem: A game is played on a strip consisting of N cells consecutively numbered from 1 to N.  Alice has her token on cell A. Borys has his token on a different cell B.  Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once.  The player who can't make a move loses, and the other player wins.  Both players want to win. Who wins if they play optimally?

Submission attempts (in order):
N,A,B=map(int,input().split())
if (A-B)%2==0:
  print("Borys")
else:
  print("Alice")

N,A,B=map(int,input().split())
if (A-B)%2==1:
  print("Borys")
else:
  print("Alice")

Verdicts: Wrong Answer

Accepted
Problem: A game is played on a strip consisting of N cells consecutively numbered from 1 to N.  Alice has her token on cell A. Borys has his token on a different cell B.  Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once.  The player who can't make a move loses, and the other player wins.  Both players want to win. Who wins if they play optimally?

Submission attempts (in order):
N,A,B = map(int,input().split())

D = B - A

if N%2 == 1:
    if D%2 == 1:
        print('Borys')
    elif  D%2 == 0:
        print('Draw')
elif N%2 == 1:
    print('Alice')

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

D = B - A

if N%2 == 1:
    if D%2 == 1:
        print('Borys')
    elif  D%2 == 0:
        print('Draw')
elif N%2 == 0:
    print('Alice')

# A - Move and Win
n,a,b=map(int,input().split())
if (b-a)%2==0:
    print('Alice')
else:
    print('Borys')

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: A game is played on a strip consisting of N cells consecutively numbered from 1 to N.  Alice has her token on cell A. Borys has his token on a different cell B.  Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once.  The player who can't make a move loses, and the other player wins.  Both players want to win. Who wins if they play optimally?

Submission attempts (in order):
n,a,b = map(int, input().split())
if n == 2:
  print('Draw')
elif (a - b) % 2 == 1:
  print('Alice')
else:
  print('Borys')

n,a,b = map(int, input().split())
if n == 2:
  print('Borys')
elif a == 1 and b == 2:
  print('Borys')
elif (a - b) % 2 == 0:
  print('Alice')
else:
  print('Borys')

Verdicts: Wrong Answer

Accepted
Problem: A game is played on a strip consisting of N cells consecutively numbered from 1 to N.  Alice has her token on cell A. Borys has his token on a different cell B.  Players take turns, Alice moves first. The moving player must shift his or her token from its current cell X to the neighboring cell on the left, cell X-1, or on the right, cell X+1. Note that it's disallowed to move the token outside the strip or to the cell with the other player's token. In one turn, the token of the moving player must be shifted exactly once.  The player who can't make a move loses, and the other player wins.  Both players want to win. Who wins if they play optimally?

Submission attempts (in order):

def main():
    N,A,B  = map(int, input().split()) 
    while True:
        if(A+1==B):
            print('Borys')
            return
        A = A+1
        if(B-1==A):
            print('Alicce')
            return
        B = B-1


if __name__ == '__main__':
    main()



def main():
    N,A,B  = map(int, input().split()) 
    while True:
        if(A+1==B):
            print('Borys')
            return
        A = A+1
        if(B-1==A):
            print('Alice')
            return
        B = B-1


if __name__ == '__main__':
    main()


Verdicts: Wrong Answer

Accepted
Problem: An adult game master and N children are playing a game on an ice rink. The game consists of K rounds. In the i-th round, the game master announces:    * Form groups consisting of A_i children each!  Then the children who are still in the game form as many groups of A_i children as possible. One child may belong to at most one group. Those who are left without a group leave the game. The others proceed to the next round. Note that it's possible that nobody leaves the game in some round.  In the end, after the K-th round, there are exactly two children left, and they are declared the winners.  You have heard the values of A_1, A_2, ..., A_K. You don't know N, but you want to estimate it.  Find the smallest and the largest possible number of children in the game before the start, or determine that no valid values of N exist.

Submission attempts (in order):




K = int(input())

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

if K == 1:
    print(2,3)
    exit()

if A[-1] != 2:
    print(-1)
    exit()

big = 2
small = 2
for i in reversed(range(K)):



    if A[i] < small:
        t_small = (small // A[i] + 1) * A[i]
    else:
        t_small = A[i]

    big = (big // A[i] + 1) * A[i] - 1
    
    if big < small:
        print(-1)
        exit()


print(small, big)


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

if A[-1] > 2:
    print(-1)
    exit()




HI = 2
LO = 2
for i in range(N):
    
    if LO // A[N-i-1] > 0:
        if LO % A[N-i-1] > 0:
            nxt_LO = (LO // A[N-i-1] + 1) * A[N-i-1]
        else:
            nxt_LO = LO
    else:
        nxt_LO = A[N-i-1]

    
    
    nxt_HI = (HI // A[N-i-1]) * A[N-i-1] + (A[N-i-1] - 1)

    if HI > nxt_HI or LO > nxt_LO  or nxt_HI < nxt_LO:
        print(-1)
        exit()

    LO = nxt_LO
    HI = nxt_HI

print(LO, HI)

Verdicts: Wrong Answer

Accepted
Problem: An adult game master and N children are playing a game on an ice rink. The game consists of K rounds. In the i-th round, the game master announces:    * Form groups consisting of A_i children each!  Then the children who are still in the game form as many groups of A_i children as possible. One child may belong to at most one group. Those who are left without a group leave the game. The others proceed to the next round. Note that it's possible that nobody leaves the game in some round.  In the end, after the K-th round, there are exactly two children left, and they are declared the winners.  You have heard the values of A_1, A_2, ..., A_K. You don't know N, but you want to estimate it.  Find the smallest and the largest possible number of children in the game before the start, or determine that no valid values of N exist.

Submission attempts (in order):
n=int(input())
da=list(map(int ,input().split()))
Min=2
Max=2
ju=True
for i in da[::-1]:
    mi=(Min+i-1)//i
    ma=Max//i
    if mi*i>Max or ma*i<Min:
        ju=False
        break
    Min=mi*i
    Max=ma*i+i-1
if ju:
    print(Max,Min)
else:
    print(-1)

n=int(input())
da=list(map(int ,input().split()))
Min=2
Max=2
ju=True
for i in da[::-1]:
    mi=(Min+i-1)//i
    ma=Max//i
    if mi*i>Max or ma*i<Min:
        ju=False
        break
    Min=mi*i
    Max=ma*i+i-1
if ju:
    print(Min,Max)
else:
    print(-1)


Verdicts: Wrong Answer

Accepted
Problem: An adult game master and N children are playing a game on an ice rink. The game consists of K rounds. In the i-th round, the game master announces:    * Form groups consisting of A_i children each!  Then the children who are still in the game form as many groups of A_i children as possible. One child may belong to at most one group. Those who are left without a group leave the game. The others proceed to the next round. Note that it's possible that nobody leaves the game in some round.  In the end, after the K-th round, there are exactly two children left, and they are declared the winners.  You have heard the values of A_1, A_2, ..., A_K. You don't know N, but you want to estimate it.  Find the smallest and the largest possible number of children in the game before the start, or determine that no valid values of N exist.

Submission attempts (in order):
from fractions import gcd
def calc(n, N, p, q):
    n, N = n*q//gcd(n, q), N*q//gcd(N, q)
    L, R = 0, 10**9
    while L+1 < R:
        M = (L+R)//2
        if n <= p*M:
            R = M
        else:
            L = M
    if n+(q-1) < p*R:
        n = -1
    else:
        n = p*R
    L, R = 0, 10**9
    while L+1 < R:
        M = (L+R)//2
        if N+q <= p*M:
            R = M
        else:
            L = M
    if p*L < N:
        N = -1
    else:
        N = p*L
    return n, N

def main():
    k = int(input())
    a = list(map(int, input().split()))
    f = True
    M, m = 2, 2
    if 2 < a[-1]:
        f = False
    else:
        for i in reversed(range(1, k)):
            m, M = calc(m, M, a[i-1], a[i])
            if m == -1 or M == -1:
                f = False
                break
        M += a[0]-1
    if f:
        print(m, M)
    else:
        print(-1)

if __name__ == "__main__":
    main()

def calc(n, N, x):
    m, M = -1, -1
    L, R = 0, 10**13
    while L+1 < R:
        P = (L+R)//2
        if n <= x*P:
            R = P
        else:
            L = P
    if n <= x*R <= N:
        m = x*R
    L, R = 0, 10**13
    while L+1 < R:
        P = (L+R)//2
        if N < x*P:
            R = P
        else:
            L = P
    if n <= x*L <= N:
        M = x*L + (x-1)
    return m, M

def main():
    k = int(input())
    a = list(map(int, input().split()))
    f = True
    m, M = 2, 2
    for i in reversed(range(k)):
        m, M = calc(m, M, a[i])
        if m == -1 or M == -1:
            f = False
            break
    if f:
        print(m, M)
    else:
        print(-1)

if __name__ == "__main__":
    main()

Verdicts: Wrong Answer

Accepted
Problem: An adult game master and N children are playing a game on an ice rink. The game consists of K rounds. In the i-th round, the game master announces:    * Form groups consisting of A_i children each!  Then the children who are still in the game form as many groups of A_i children as possible. One child may belong to at most one group. Those who are left without a group leave the game. The others proceed to the next round. Note that it's possible that nobody leaves the game in some round.  In the end, after the K-th round, there are exactly two children left, and they are declared the winners.  You have heard the values of A_1, A_2, ..., A_K. You don't know N, but you want to estimate it.  Find the smallest and the largest possible number of children in the game before the start, or determine that no valid values of N exist.

Submission attempts (in order):
# AGC020B - Ice Rink Game
def main():
    K, *A = map(int, open(0).read().split())
    l, h = 2, 2  # low, high
    for i in A[::-1]:
        l = (l + i - 1) // i * i
        h = (h / i + 1) * i - 1
    if l > h:
        print(-1)
    else:
        print(l, h)


if __name__ == "__main__":
    main()

# AGC020B - Ice Rink Game
def main():
    K, *A = map(int, open(0).read().split())
    l, h = 2, 2  # low, high
    for i in A[::-1]:
        l += -l % i
        h += i - 1 - h % i
    if l > h:
        print(-1)
    else:
        print(l, h)


if __name__ == "__main__":
    main()

Verdicts: Wrong Answer

Accepted
Problem: An adult game master and N children are playing a game on an ice rink. The game consists of K rounds. In the i-th round, the game master announces:    * Form groups consisting of A_i children each!  Then the children who are still in the game form as many groups of A_i children as possible. One child may belong to at most one group. Those who are left without a group leave the game. The others proceed to the next round. Note that it's possible that nobody leaves the game in some round.  In the end, after the K-th round, there are exactly two children left, and they are declared the winners.  You have heard the values of A_1, A_2, ..., A_K. You don't know N, but you want to estimate it.  Find the smallest and the largest possible number of children in the game before the start, or determine that no valid values of N exist.

Submission attempts (in order):
N = int(input())
P = list(reversed(list(map(int, input().split()))))

s, t = 2, 2
for i in P:
    p = max((s + i - 1) // i, 1)
    q = t // i
    print(i)
    if q < p:
        print(-1)
        quit(0)
    s, t = p * i, q * i + i - 1

print(s, t)


N = int(input())
ops = list(input().split())
P = []
p = 0
x = 1
for s in range(N-1, -1, -1):
    P.append(int(ops[s]))
ans = int(ops[N-1])
print(P)
for i in range(N-1):
    if P[i] > P[i+1]:
            p = P[i] % P[i+1]
            ans += p
    elif (P[i] * 2) > P[i+1]:
        p = (P[i] * 2) % P[i+1]
        ans += p
    else:
        ans = -1
        break

if ans != -1:
    if ans % P[N-1] != 0:
        ans -= ans % P[N-1]
    while ans < max(P):
        ans += P[N-1]    
    ans2 = ans + P[N-1] -1
    print(str(ans) + " " +str(ans2))
else:
    print(ans)

N = int(input())
P = list(reversed(list(map(int, input().split()))))

s, t = 2, 2
for i in P:
    p = max((s + i - 1) // i, 1)
    q = t // i
    if q < p:
        print(-1)
        quit(0)
    s, t = p * i, q * i + i - 1

print(s, t)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: An adult game master and N children are playing a game on an ice rink. The game consists of K rounds. In the i-th round, the game master announces:    * Form groups consisting of A_i children each!  Then the children who are still in the game form as many groups of A_i children as possible. One child may belong to at most one group. Those who are left without a group leave the game. The others proceed to the next round. Note that it's possible that nobody leaves the game in some round.  In the end, after the K-th round, there are exactly two children left, and they are declared the winners.  You have heard the values of A_1, A_2, ..., A_K. You don't know N, but you want to estimate it.  Find the smallest and the largest possible number of children in the game before the start, or determine that no valid values of N exist.

Submission attempts (in order):
k = int(input())
a = list(map(int,input().split()))
a = a[::-1]

c = 2 #min
d = 2 #max
res = 1 

for i in range(k):
    if d > a[i]:
        res = -1
        break
    if i != k-1:
        if c % a[i] != 0 or d % a[i] != 0:
            res = -1
            break
        else:
            d = d + a[i] -1
            p = c%a[i+1]
            q = d%a[i+1]
            if p == 0:
                c2 = c
            else:
                c2 = c + a[i+1]-p
            d2 = d-q
            
            if c2 <= d2:
                c = c2
                d = d2
            else:
                res = -1
                break
    else:
        d = d + a[i] -1
            
        
    
    
if res == -1:
    print(-1)
else:
    print(str(c) + ' ' + str(d))

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


def g(n,a,k):
    for i in range(k):
        n = n - (n%a[i])
    return n

#print(g(8,a,k))

s = 0
t = 2 + k*max(a)
while t-s > 1:
    m = (s+t)//2
    if g(m,a,k)> 2:
        t = m
    else:
        s = m
    
p = 0
q = 2+k*max(a)
while q-p > 1:
    m = (p+q)//2
    if g(m,a,k) >= 2:
        q = m
    else:
        p = m

c = 1
if g(s,a,k) == 2:
    res = s
elif g(t,a,k) == 2:
    res = t
else:
    c = -1

if g(q,a,k) == 2:
    res2 = q
elif g(p,a,k) == 2:
    res2 = p
else:
    c = -1

if c == 1:
    print(res2,res)
else:
    print(-1)

Verdicts: Wrong Answer

Accepted
Problem: An adult game master and N children are playing a game on an ice rink. The game consists of K rounds. In the i-th round, the game master announces:    * Form groups consisting of A_i children each!  Then the children who are still in the game form as many groups of A_i children as possible. One child may belong to at most one group. Those who are left without a group leave the game. The others proceed to the next round. Note that it's possible that nobody leaves the game in some round.  In the end, after the K-th round, there are exactly two children left, and they are declared the winners.  You have heard the values of A_1, A_2, ..., A_K. You don't know N, but you want to estimate it.  Find the smallest and the largest possible number of children in the game before the start, or determine that no valid values of N exist.

Submission attempts (in order):
K = int(input())
A = list(map(int, input().split()))

def winner_count(N, A=A):
    for a in A:
        N = a*(N//a)
    return N

class lazy_eval_list(list):
    def __init__(self, func, a):
        super().__init__(a)
        self._func = func
        
    def __getitem__(self, key):
        return self._func(super().__getitem__(key))

lazy_winner_count_N = lazy_eval_list(winner_count, range(1,2+sum(A)))

import bisect
_min = bisect.bisect_left(lazy_winner_count_N, 2)
_max = bisect.bisect_right(lazy_winner_count_N, 2)-1

if _min > _max:
	print(-1)
else:
	print(_min, _max)

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

_min=2
_max=2

for a in A[::-1]:
  
  if _min%a:
    if a*(_min//a) + a > _max:
      print(-1)
      break
    else:
      _min = a*(_min//a) + a
  else:
    _min = _min
  
  _max = a*(_max//a) + a-1
else:
  print(_min, _max)

Verdicts: Runtime Error

Accepted
Problem: An adult game master and N children are playing a game on an ice rink. The game consists of K rounds. In the i-th round, the game master announces:    * Form groups consisting of A_i children each!  Then the children who are still in the game form as many groups of A_i children as possible. One child may belong to at most one group. Those who are left without a group leave the game. The others proceed to the next round. Note that it's possible that nobody leaves the game in some round.  In the end, after the K-th round, there are exactly two children left, and they are declared the winners.  You have heard the values of A_1, A_2, ..., A_K. You don't know N, but you want to estimate it.  Find the smallest and the largest possible number of children in the game before the start, or determine that no valid values of N exist.

Submission attempts (in order):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

K = int(input())
aa = reversed(inpl())

MIN = MAX = 2
for a in aa:
    print(a,MIN,MAX)
    if MIN%a == 0 or MAX//a - MIN//a > 0:
        MIN = ((MIN-1)//a+1) *a
        MAX = MAX//a*a+a-1
    else:
        print(-1)
        sys.exit()

print(MIN,MAX)


from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

K = int(input())
aa = reversed(inpl())

MIN = MAX = 2
for a in aa:
    if MIN%a == 0 or MAX//a - MIN//a > 0:
        MIN = ((MIN-1)//a+1) *a
        MAX = MAX//a*a+a-1
    else:
        print(-1)
        sys.exit()

print(MIN,MAX)


Verdicts: Wrong Answer

Accepted
Problem: An adult game master and N children are playing a game on an ice rink. The game consists of K rounds. In the i-th round, the game master announces:    * Form groups consisting of A_i children each!  Then the children who are still in the game form as many groups of A_i children as possible. One child may belong to at most one group. Those who are left without a group leave the game. The others proceed to the next round. Note that it's possible that nobody leaves the game in some round.  In the end, after the K-th round, there are exactly two children left, and they are declared the winners.  You have heard the values of A_1, A_2, ..., A_K. You don't know N, but you want to estimate it.  Find the smallest and the largest possible number of children in the game before the start, or determine that no valid values of N exist.

Submission attempts (in order):
import sys
import math

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


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

    if A[-1] != 2:
        print(-1)
        return

    
    m = 2
    M = 2
    for i in range(K - 2, -1, -1):
        n = (m + A[i] - 1) // A[i]
        tmp_m = n * A[i]
        tmp_M = (n + 1) * A[i] - 1
        if tmp_m > M or tmp_M < m:
            print(-1)
            return
        m = tmp_m
        M = tmp_M

    print(m, M)


if __name__ == "__main__":
    main()


import sys
import math

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


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

    
    m = 2
    M = 2
    for i in range(K - 1, -1, -1):
        n = (m + A[i] - 1) // A[i]
        tmp_m = n * A[i]
        tmp_M = (M / A[i]) * A[i] + A[i] - 1
        if tmp_m > M or tmp_M < m:
            print(-1)
            return
        m = tmp_m
        M = tmp_M

    print(m, M)


if __name__ == "__main__":
    main()


import sys
import math

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


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

    
    m = 2
    M = 2
    for i in range(K - 1, -1, -1):
        n = (m + A[i] - 1) // A[i]
        tmp_m = n * A[i]
        tmp_M = (M // A[i]) * A[i] + A[i] - 1
        if tmp_m > M or tmp_M < m:
            print(-1)
            return
        m = tmp_m
        M = tmp_M

    print(m, M)


if __name__ == "__main__":
    main()


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: An adult game master and N children are playing a game on an ice rink. The game consists of K rounds. In the i-th round, the game master announces:    * Form groups consisting of A_i children each!  Then the children who are still in the game form as many groups of A_i children as possible. One child may belong to at most one group. Those who are left without a group leave the game. The others proceed to the next round. Note that it's possible that nobody leaves the game in some round.  In the end, after the K-th round, there are exactly two children left, and they are declared the winners.  You have heard the values of A_1, A_2, ..., A_K. You don't know N, but you want to estimate it.  Find the smallest and the largest possible number of children in the game before the start, or determine that no valid values of N exist.

Submission attempts (in order):
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

K = int(input())
L = list(map(int, input().split()))

ma = 2
mi = 2
L = reversed(L)

for l in L:
    if l > ma:
        print(-1)
        exit()
    else:
        mi = (mi//l)*l
        ma = (ma//l)*(l)+l-1
print(mi, ma)


from math import ceil
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

K = int(input())
L = list(map(int, input().split()))

maxr = 2
minr = 2
r = 0
for n in reversed(L):
    if ceil(maxr//n) > minr:
        # if any(x % n == 0 for x in range(minr, maxr+1)):
        # if minr//n <= maxr//n:
        minr = ceil(minr/n)*n
        maxr = (maxr)//n*n+n-1
    else:
        n = -1
        break

if n == -1:
    print(n)
else:
    print(int(minr), maxr)


from math import ceil
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

K = int(input())
L = list(map(int, input().split()))

maxr = 2
minr = 2
r = 0
for n in reversed(L):
    if ceil(maxr//n) >= minr:
        # if any(x % n == 0 for x in range(minr, maxr+1)):
        # if minr//n <= maxr//n:
        minr = ceil(minr/n)*n
        maxr = (maxr)//n*n+n-1
    else:
        n = -1
        break

if n == -1:
    print(n)
else:
    print(int(minr), maxr)


from math import ceil
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

K = int(input())
L = list(map(int, input().split()))

maxr = 2
minr = 2
r = 0
for n in reversed(L):
    
    if ceil(maxr//n)*n >= minr:
        minr = ceil(minr/n)*n
        maxr = (maxr)//n*n+n-1
    else:
        print(-1)
        exit()

print(int(minr), maxr)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: An adult game master and N children are playing a game on an ice rink. The game consists of K rounds. In the i-th round, the game master announces:    * Form groups consisting of A_i children each!  Then the children who are still in the game form as many groups of A_i children as possible. One child may belong to at most one group. Those who are left without a group leave the game. The others proceed to the next round. Note that it's possible that nobody leaves the game in some round.  In the end, after the K-th round, there are exactly two children left, and they are declared the winners.  You have heard the values of A_1, A_2, ..., A_K. You don't know N, but you want to estimate it.  Find the smallest and the largest possible number of children in the game before the start, or determine that no valid values of N exist.

Submission attempts (in order):
K = int(input())
A = [int(i) for i in input().split()]
A.reverse()

min_A=2
max_A=3
cnt=True
if A[-1]!=2:
  print(-1)
  cnt=False
for i in range(1,K):
  a=(min_A+A[i]-1)//A[i]*A[i]
  b=max_A//A[i]*A[i]
  if a>b:
    print(-1)
    cnt=False
    break
  else:
    min_A=a
    max_A=b+A[i]-1

if cnt:
  print(min_A,max_A)


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

min_A=2
max_A=3
jud=True
for i in range(1,K):
  if A[i]>max_A:
    print(-1)
    jud=False
    break
  if min_A>A[i]:
    cnt=2
    while True:
      if A[i]*cnt>=min_A:
        min_A=A[i]*cnt
        break
      cnt+=1
    while True:
      if A[i]*(cnt+1)-1>max_A:
        max_A=A[i]*cnt-1
        break
      cnt+=1
  else:
    min_A=A[i]
    max_A=A[i]*2-1
if jud:
  print(min_A,max_A)

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

min_A=2
max_A=3
cnt=True
if A[0]!=2:
  print(-1)
  cnt=False
for i in range(1,K):
  a=(min_A+A[i]-1)//A[i]*A[i]
  b=max_A//A[i]*A[i]
  if a>b and cnt:
    print(-1)
    cnt=False
    break
  else:
    min_A=a
    max_A=b+A[i]-1

if cnt:
  print(min_A,max_A)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: An adult game master and N children are playing a game on an ice rink. The game consists of K rounds. In the i-th round, the game master announces:    * Form groups consisting of A_i children each!  Then the children who are still in the game form as many groups of A_i children as possible. One child may belong to at most one group. Those who are left without a group leave the game. The others proceed to the next round. Note that it's possible that nobody leaves the game in some round.  In the end, after the K-th round, there are exactly two children left, and they are declared the winners.  You have heard the values of A_1, A_2, ..., A_K. You don't know N, but you want to estimate it.  Find the smallest and the largest possible number of children in the game before the start, or determine that no valid values of N exist.

Submission attempts (in order):
from math import floor, ceil
k = int(input())
a = [int(i) for i in input().split()]
l,r = 2,2
for ai in a[::-1]:
    if l // ai >= 1 or r // ai >= 1:
        print(-1)
        exit()
    l = ceil(l/ai)*ai
    r = floor(r/ai) * ai + ai - 1
print(l,r)


from math import floor, ceil
k = int(input())
a = [int(i) for i in input().split()]
l,r = 2,2
for ai in a[::-1]:
    if not(l // ai >= 1 and r // ai >= 1):
        print(-1)
        exit()
    l = ceil(l/ai)*ai
    r = floor(r/ai) * ai + ai - 1
print(l,r)

from math import floor, ceil
k = int(input())
a = [int(i) for i in input().split()]
l,r = 2,2
for ai in a[::-1]:
    xi = ceil(l/ai)
    yi = floor(r/ai)
    if xi > yi:
        print(-1)
        exit()
    l = xi * ai
    r = yi * ai + ai - 1
print(l, r)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: An adult game master and N children are playing a game on an ice rink. The game consists of K rounds. In the i-th round, the game master announces:    * Form groups consisting of A_i children each!  Then the children who are still in the game form as many groups of A_i children as possible. One child may belong to at most one group. Those who are left without a group leave the game. The others proceed to the next round. Note that it's possible that nobody leaves the game in some round.  In the end, after the K-th round, there are exactly two children left, and they are declared the winners.  You have heard the values of A_1, A_2, ..., A_K. You don't know N, but you want to estimate it.  Find the smallest and the largest possible number of children in the game before the start, or determine that no valid values of N exist.

Submission attempts (in order):
def div_ceil(x, y): return (x + y - 1) // y

N = int(input())
*A, = map(int, input().split())
cand_min, cand_max = 2, 2
for a in reversed(A):
    if a > cand_max: print(-1); break
    cand_max = (cand_max // a) * a
    cand_min = div_ceil(cand_min, a) * a
    cand_max = cand_max + a - 1
else:
    cand_max = (cand_max // a) * a
    print(cand_min, cand_max)

def div_ceil(x, y): return (x + y - 1) // y

N = int(input())
*A, = map(int, input().split())
cand_min, cand_max = 2, 2
for a in reversed(A):
    if div_ceil(cand_min, a) * a > cand_max: print(-1); break
    cand_min = div_ceil(cand_min, a) * a
    cand_max = (cand_max // a) * a + a - 1
else:
    print(cand_min, cand_max)

Verdicts: Wrong Answer

Accepted
Problem: An adult game master and N children are playing a game on an ice rink. The game consists of K rounds. In the i-th round, the game master announces:    * Form groups consisting of A_i children each!  Then the children who are still in the game form as many groups of A_i children as possible. One child may belong to at most one group. Those who are left without a group leave the game. The others proceed to the next round. Note that it's possible that nobody leaves the game in some round.  In the end, after the K-th round, there are exactly two children left, and they are declared the winners.  You have heard the values of A_1, A_2, ..., A_K. You don't know N, but you want to estimate it.  Find the smallest and the largest possible number of children in the game before the start, or determine that no valid values of N exist.

Submission attempts (in order):
K=int(input())
A=list(map(int,input().split()))
l,h=2,2
for a in A[::-1]:
    if h<a or h//a==l//a:
        l=h=-1
        break
    else:
        l=-(-l//a)*a
    h=(h//a+1)*a-1
if l==h==-1:
    print(-1)
else:
    print(l,h)

K=int(input())
A=list(map(int,input().split()))
l,h=2,2
for a in A[::-1]:
    l=-(-l//a)*a
    h=(h//a+1)*a-1
    if l>h:
        l=h=-1
        break
if l==h==-1:
    print(-1)
else:
    print(l,h)

Verdicts: Wrong Answer

Accepted
Problem: An adult game master and N children are playing a game on an ice rink. The game consists of K rounds. In the i-th round, the game master announces:    * Form groups consisting of A_i children each!  Then the children who are still in the game form as many groups of A_i children as possible. One child may belong to at most one group. Those who are left without a group leave the game. The others proceed to the next round. Note that it's possible that nobody leaves the game in some round.  In the end, after the K-th round, there are exactly two children left, and they are declared the winners.  You have heard the values of A_1, A_2, ..., A_K. You don't know N, but you want to estimate it.  Find the smallest and the largest possible number of children in the game before the start, or determine that no valid values of N exist.

Submission attempts (in order):
K = int(input())
As = list(map(int, input().split()))

def f(n):
    for a in As:
        x,_ = divmod(n,a)
        n = x*a
    return n

l,r = 1, 10**10
while r-l > 1:
    m = (r+l)//2
    if f(m) < 2:
        l = m
    else:
        r = m
mn = r

l,r = 1, 10**10
while r-l > 1:
    m = (r+l)//2
    if f(m) <= 3:
        l = m
    else:
        r = m
mx = l
if mn < mx:
    print(-1)
else:
    print(mn,mx)


n = int(input())
As = list(map(int, input().split()))
    
def f(m):
    debug = m
    for a in As:
        i = m // a
        m = i * a
    return m


l = 1
r = 10**5+1
while r-l > 1:
    m = (r+l)//2
    if f(m) <= 1: l = m
    else: r = m
ans1 = r
l = 1
r = 10**5 + 1
while r-l > 1:
    m = (r+l)//2
    if f(m) <= 2: l= m
    else: r = m
ans2 = l

if ans1 >= ans2:
    print(-1)
else:
    print(ans1[1],ans2[0])

n = int(input())
As = list(map(int, input().split()))
    
def f(m):
    debug = m
    for a in As:
        i = m // a
        m = i * a
    return m


l = 1
r = 10**20
while r-l > 1:
    m = (r+l)//2
    if f(m) <= 1: l = m
    else: r = m
ans1 = r
l = 1
r = 10**20
while r-l > 1:
    m = (r+l)//2
    if f(m) <= 2: l= m
    else: r = m
ans2 = l

if ans1 > ans2:
    print(-1)
else:
    print(ans1,ans2)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: An adult game master and N children are playing a game on an ice rink. The game consists of K rounds. In the i-th round, the game master announces:    * Form groups consisting of A_i children each!  Then the children who are still in the game form as many groups of A_i children as possible. One child may belong to at most one group. Those who are left without a group leave the game. The others proceed to the next round. Note that it's possible that nobody leaves the game in some round.  In the end, after the K-th round, there are exactly two children left, and they are declared the winners.  You have heard the values of A_1, A_2, ..., A_K. You don't know N, but you want to estimate it.  Find the smallest and the largest possible number of children in the game before the start, or determine that no valid values of N exist.

Submission attempts (in order):
k=int(input())
a=list(map(int,input().split()))
def f(x):
    for i in range(k):
        x-=x%a[i]
    return x
s=k*max(a)+3
t=0
while s-t>1:
    x=(s+t)//2
    if f(x)>2:
        s=x
    else:
        t=x
p=k*max(a)+3
q=0
while p-q>1:
    x=(p+q)//2
    if f(x)>=2:
        q=x
    else:
        p=x
if f(t)==2:
    if f(q)==2:
        print(q,t)
    else:
        print(-1)
else:
    print(-1)
print(f(p))

k=int(input())
a=list(map(int,input().split()))
s=2+k*max(a)
l,r=s+1,0
while l-r>1:
    t=(l+r)//2
    p=t
    for i in a:
        t-=t%i
    if t>=2:
        l=p
    else:
        r=p
e=l
l,r=s+1,0
while l-r>1:
    t=(l+r)//2
    p=t
    for i in a:
        t-=t%i
    if t>2:
        l=p
    else:
        r=p
print(str(max(e,2))+" "+str(r)if r>e or r<2 else -1)

Verdicts: Wrong Answer

Accepted
Problem: An adult game master and N children are playing a game on an ice rink. The game consists of K rounds. In the i-th round, the game master announces:    * Form groups consisting of A_i children each!  Then the children who are still in the game form as many groups of A_i children as possible. One child may belong to at most one group. Those who are left without a group leave the game. The others proceed to the next round. Note that it's possible that nobody leaves the game in some round.  In the end, after the K-th round, there are exactly two children left, and they are declared the winners.  You have heard the values of A_1, A_2, ..., A_K. You don't know N, but you want to estimate it.  Find the smallest and the largest possible number of children in the game before the start, or determine that no valid values of N exist.

Submission attempts (in order):
K=int(input())
A=input().split(' ')
min=2
max=2
flag=0
while K>0:
  K=K-1
  i=int(A[K])
  if max<i:
    print('-1')
    flag=1
    break
  else:
    min=min+i-(min%i)
    max=max+i-(max%i)-1
if flag==0:
  print('{0} {1}'.format(min,max))

K=int(input())
A=input().split(' ')
min=2
max=2
flag=0
while K>0:
  K=K-1
  i=int(A[K])
  if max<i:
    print('-1')
    flag=1
    break
  elif i<min:
    if min%i!=0:min=min+i-(min%i)
    else:min=min+(min%i)
    max=max+i-(max%i)-1
    if min>max:
      print('-1')
      flag=1
      break
  else:
    min=i
    max=max+i-(max%i)-1
if flag==0:
  print('{0} {1}'.format(min,max))

Verdicts: Wrong Answer

Accepted
Problem: An adult game master and N children are playing a game on an ice rink. The game consists of K rounds. In the i-th round, the game master announces:    * Form groups consisting of A_i children each!  Then the children who are still in the game form as many groups of A_i children as possible. One child may belong to at most one group. Those who are left without a group leave the game. The others proceed to the next round. Note that it's possible that nobody leaves the game in some round.  In the end, after the K-th round, there are exactly two children left, and they are declared the winners.  You have heard the values of A_1, A_2, ..., A_K. You don't know N, but you want to estimate it.  Find the smallest and the largest possible number of children in the game before the start, or determine that no valid values of N exist.

Submission attempts (in order):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = LI() + [1]
    if a[-1] != 2:
        return -1
    b = 2
    c = 4
    for i in range(n-1,-1,-1):
        t = a[i]
        if b * 2 <= t:
            return -1
        if b % t == 0:
            pass
        elif b > t:
            b += t-b%t
            if b % t != 0:
                return 1/0
        else:
            b = t
        if c % t == 0:
            pass
        elif c > t:
            c += t-c%t
        else:
            return -1

    return '{} {}'.format(b, c-1)

print(main())




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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def bs(f, mi, ma):
    mm = -1
    while ma > mi:
        mm = (ma+mi) // 2
        if f(mm):
            mi = mm + 1
        else:
            ma = mm
    if f(mm):
        return mm + 1
    return mm

def main():
    n = I()
    a = LI()

    def f(i):
        for c in a:
            i -= i%c
        return i < 2

    def g(i):
        for c in a:
            i -= i%c
        return i <= 2

    mi = bs(f,0,sum(a)+3)
    ma = bs(g,0,sum(a)+3) - 1
    if mi <= ma:
        return '{} {}'.format(mi,ma)
    return -1




print(main())




Verdicts: Wrong Answer

Accepted
Problem: An adult game master and N children are playing a game on an ice rink. The game consists of K rounds. In the i-th round, the game master announces:    * Form groups consisting of A_i children each!  Then the children who are still in the game form as many groups of A_i children as possible. One child may belong to at most one group. Those who are left without a group leave the game. The others proceed to the next round. Note that it's possible that nobody leaves the game in some round.  In the end, after the K-th round, there are exactly two children left, and they are declared the winners.  You have heard the values of A_1, A_2, ..., A_K. You don't know N, but you want to estimate it.  Find the smallest and the largest possible number of children in the game before the start, or determine that no valid values of N exist.

Submission attempts (in order):
K = int(input())
A = list(map(int,input().split()))
a = K-1
p = 2
while 0 <= a:
    if A[a-1] > A[a]*2:
        print('-1')
        exit()
    num = 1
    if A[a] < p:
        while A[a]*num < p:
            num += 1
    p = num*A[a]
    a -= 1
pmax = p
while pmax < A[1]*2:
    pmax += A[0]
pmax -= A[0]
print(p,pmax)


import math
K = int(input())
A = list(map(int,input().split()))
a = 1
L,S = 2,2 

while a <= K:
    if math.ceil(S/A[-a])*A[-a] < S or L < math.ceil(S/A[-a])*A[-a]:
        print('-1')
        exit()
    S = math.ceil(S/A[-a])*A[-a]
    L = math.floor(L/A[-a])*A[-a] + A[-a] -1
    a += 1
print(S,L)

    


Verdicts: Runtime Error

Accepted
Problem: An adult game master and N children are playing a game on an ice rink. The game consists of K rounds. In the i-th round, the game master announces:    * Form groups consisting of A_i children each!  Then the children who are still in the game form as many groups of A_i children as possible. One child may belong to at most one group. Those who are left without a group leave the game. The others proceed to the next round. Note that it's possible that nobody leaves the game in some round.  In the end, after the K-th round, there are exactly two children left, and they are declared the winners.  You have heard the values of A_1, A_2, ..., A_K. You don't know N, but you want to estimate it.  Find the smallest and the largest possible number of children in the game before the start, or determine that no valid values of N exist.

Submission attempts (in order):



# ...

K = int(input())
As = list(map(int, input().split()))
As.reverse()

fail = False
if As[0] != 2:
    fail = True
else:
    mn = 2
    mx = 3
    for a in As[1:]:
        
        
        if mn % a != 0:
            mn = (mn // a) * a + a
        if mx % a != 0:
            mx = (mx // a) * a
        if mn > mx:
            fail = True
            break

        
        mx = mx + (a - 1)
if fail:
    print(-1)
else:




# ...

K = int(input())
As = list(map(int, input().split()))
As.reverse()

fail = False
if As[0] != 2:
    fail = True
else:
    mn = 2
    mx = 3
    for a in As[1:]:
        
        
        if mn % a != 0:
            mn = (mn // a) * a + a
        if mx % a != 0:
            mx = (mx // a) * a
        if mn > mx:
            fail = True
            break

        
        mx = mx + (a - 1)
if fail:
    print(-1)
else:
    print(mn, mx)


Verdicts: Runtime Error

Accepted
Problem: An adult game master and N children are playing a game on an ice rink. The game consists of K rounds. In the i-th round, the game master announces:    * Form groups consisting of A_i children each!  Then the children who are still in the game form as many groups of A_i children as possible. One child may belong to at most one group. Those who are left without a group leave the game. The others proceed to the next round. Note that it's possible that nobody leaves the game in some round.  In the end, after the K-th round, there are exactly two children left, and they are declared the winners.  You have heard the values of A_1, A_2, ..., A_K. You don't know N, but you want to estimate it.  Find the smallest and the largest possible number of children in the game before the start, or determine that no valid values of N exist.

Submission attempts (in order):
n=int(input())
a=reversed([int(i) for i in input().split()])
max_a=3
min_a=2
a0=2
flg=0
an=list(a)
if an[0]!=2:
  f=1
for i in an:
  if i > max_a:
    flg=1
    break
  elif i !=a0:    
    if i>a0:
      min_a +=i-a0
    else:
      min_a+= i - min_a % i 
    max_a=min_a + i -1
  a0=i

if flg==1:
  print('-1')
else:
  print(max_a,min_a)

n=int(input())
a=reversed([int(i) for i in input().split()])
max_a=3
min_a=2
a0=2
flg=0
an=list(a)
if an[0]!=2:
  flg=1

for i in an:
  if i > max_a:
    flg=1
    break
  elif i !=a0:    
    if i>a0:
      min_a +=i-a0
    else:
      min_a+= i - min_a % i 
    max_a=min_a + i -1
  a0=i

if flg==1:
  print('-1')
else:
  print(max_a,min_a)

n=int(input())
a=[int(i) for i in input().split()][::-1]
max_a=3
min_a=2
a0=2
flg=0
an=list(a)
if an[0]!=2:
  flg=1

for i in an:
  if i > max_a:
    flg=1
    break
  elif i !=a0:    
    if i>a0:
      min_a +=i-a0
    else:
      min_a+= i - min_a % i 
    max_a=min_a + i -1
  a0=i

if flg==1:
  print('-1')
else:
  print(max_a,min_a)

input()
l=s=2
for i in map(int,input().split()[::-1]):
  s=i*(s//i+[1,0][s%i==0])
  l=i*(l//i+1)-1
print(-1) if s>l else print(s,l)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted