Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N,Q = (int(i) for i in input().split())
X = []
for i in range(N-1):
    Y = [int(n) for n in input().split()]
    X.append(Y)
X = sorted(X, key=lambda x:x[1])
Z = [] 
for i in range(N):
    Z.append(0)
    
for i in range(Q):
    Z_1,Z_2 = (int(i) for i in input().split())
    Z[Z_1-1] = Z[Z_1-1] + Z_2

#print(X)
#print(Z)


ans=[Z[0]]

for i in range(1,N):
    ans.append(Z[i])
    for n in range(len(X)):
        if X[n][1] == i+1:
            ans[i] += ans[X[n][0]-1]
            A = n+1
        else:
            for i in range(A):
                X.pop(0)
            break

#print(ans)
print(' '.join(map(str, ans)))

Fixed submission:
N,Q = (int(i) for i in input().split())
X = []
for i in range(N-1):
    Y = [int(n) for n in input().split()]
    X.append(Y)
X = sorted(X, key=lambda x:x[1])
Z = []
for i in range(N):
    Z.append(0)
    
for i in range(Q):
    Z_1,Z_2 = (int(i) for i in input().split())
    Z[Z_1-1] = Z[Z_1-1] + Z_2

#print(X)
#print(Z)


ans=[Z[0]]

for i in range(1,N):
    ans.append(Z[i])
    ans[i] += ans[X[i-1][0]-1]
    
#print(ans)
print(' '.join(map(str, ans)))

Buggy python submission (verdict: Time Limit Exceeded):
N,Q = (int(i) for i in input().split())
X = []
for i in range(N-1):
    Y = [int(n) for n in input().split()]
    X.append(Y)
X = sorted(X, key=lambda x:x[1])
Z = [] 
for i in range(N):
    Z.append(0)
    
for i in range(Q):
    Z_1,Z_2 = (int(i) for i in input().split())
    Z[Z_1-1] = Z[Z_1-1] + Z_2

#print(X)
#print(Z)

ans=[]
for i in range(N):
    ans.append(0)
ans[0]=Z[0]

for i in range(1,N):
    ans[i] += Z[i]
    for n in range(len(X)):
        if X[n][1] == i+1:
            ans[i] += ans[X[n][0]-1]
            A = n+1
        else:
            for i in range(A):
                X.pop(0)
            break

#print(ans)
print(' '.join(map(str, ans)))

Fixed submission:
N,Q = (int(i) for i in input().split())
X = []
for i in range(N-1):
    Y = [int(n) for n in input().split()]
    X.append(Y)
X = sorted(X, key=lambda x:x[1])
Z = []
for i in range(N):
    Z.append(0)
    
for i in range(Q):
    Z_1,Z_2 = (int(i) for i in input().split())
    Z[Z_1-1] = Z[Z_1-1] + Z_2

#print(X)
#print(Z)


ans=[Z[0]]

for i in range(1,N):
    ans.append(Z[i])
    ans[i] += ans[X[i-1][0]-1]
    
#print(ans)
print(' '.join(map(str, ans)))
Buggy python submission (verdict: Runtime Error):
import math
A,B,C,D = (int(i) for i in input().split())

X = (C * D) // math.gcd(C, D)
Y = (C + D) // math.gcd(C, D) - 1

#print(X,Y)

#count = (B - A) // X * Y 
#print(count)


N = A % X 
N_S = N-1
UA = Y - (N_S // C + N_S // D)

#print(UA)
M = B % X
UB = M // C + M // D
if M == 0:
    UB = 0
#print(UB)


SA =  A + ( X - N )
SB =  B - M 
#print(SA,SB)
count = (SB - SA) // X * Y 

#print(count)
add = count + UA + UB
    
Z = B - A - add + 1
print(Z)

Fixed submission:
import fractions
a,b,c,d = map(int,input().split())
e = c * d // fractions.gcd(c,d)

c_count = b // c - (a - 1) // c
d_count = b // d - (a - 1) // d
e_count = b // e - (a - 1) // e

ans = b - a + 1 - c_count - d_count + e_count
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
A,B,C,D = (int(i) for i in input().split())

X = (C * D) // math.gcd(C, D)
Y = (C + D) // math.gcd(C, D) - 1

print(X,Y)

#count = (B - A) // X * Y 
#print(count)


N = A % X 
N_S = N-1
UA = Y - (N_S // C + N_S // D)

print(UA)
M = B % X
UB = M // C + M // D
if M == 0:
    UB = 0
print(UB)


SA =  A + ( X - N )
SB =  B - M 
print(SA,SB)
count = (SB - SA) // X * Y 

print(count)
add = count + UA + UB
    
Z = B - A - add + 1
print(Z)

Fixed submission:
import fractions
a,b,c,d = map(int,input().split())
e = c * d // fractions.gcd(c,d)

c_count = b // c - (a - 1) // c
d_count = b // d - (a - 1) // d
e_count = b // e - (a - 1) // e

ans = b - a + 1 - c_count - d_count + e_count
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
A,B,C,D = (int(i) for i in input().split())

X = (C * D) // math.gcd(C, D)
Y = (C + D) // math.gcd(C, D) - 1

#print(X,Y)

#count = (B - A) // X * Y 
#print(count)


N = A % X 
N_S = N-1
UA = Y - (N_S // C + N_S // D)

#print(UA)
M = B % X
UB = M // C + M // D
if M == 0:
    UB = 0
#print(UB)


SA =  A + ( X - N )
SB =  B - M 
#print(SA,SB)
count = (SA - SB) // X * Y 

add = count + UA + UB
    
Z = B - A - add + 1
print(Z)

Fixed submission:
import fractions
a,b,c,d = map(int,input().split())
e = c * d // fractions.gcd(c,d)

c_count = b // c - (a - 1) // c
d_count = b // d - (a - 1) // d
e_count = b // e - (a - 1) // e

ans = b - a + 1 - c_count - d_count + e_count
print(ans)
Buggy python submission (verdict: Runtime Error):
mod = 10 ** 9 + 7
N,M = map(int,input().split())
X = [1,1]
for i in range(N):
    X.append((X[i]+X[i+1]) % mod)
#print(X)
a = int(input())
ans = X[a - 1]
#print(ans)
tmp = a
check = 0
for _ in range(M-1):
    a = int(input())
    if a - tmp == 1:
        check = 1
    y = a - tmp - 2
    ans *= X[y]
    ans %= mod 
    tmp = a
    #print(ans)
y = N - tmp - 1
ans *= X[y]
ans %= mod 
if check == 1:
    print(0)
else:
    print(ans)

Fixed submission:
mod = 10 ** 9 + 7
N,M = map(int,input().split())
X = [1,1]
for i in range(N):
    X.append((X[i]+X[i+1]) % mod)
if M == 0:
    print(X[N])
else:
    a = int(input())
    ans = X[a - 1]
    #print(ans)
    tmp = a
    check = 0
    for _ in range(M-1):
        a = int(input())
        if a - tmp == 1:
            check = 1
        y = a - tmp - 2
        ans *= X[y]
        ans %= mod
        tmp = a
        #print(ans)
    y = N - tmp - 1
    ans *= X[y]
    ans %= mod 
    if check == 1:
        print(0)
    else:
        print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
r,g,b,n = map(int,input().split())

ans = 0
for i in range(n+1):
    for j in range(n+1):
        z = r * i + g * j
        if z <= n and (n - z) % b == 0:
            ans += 1
print(ans)            


Fixed submission:
r,g,b,n = map(int,input().split())

ans = 0
for i in range(n+1):
    x = n - r * i
    for j in range(x+1):
        y = x - g * j
        if y >= 0 and y % b == 0:
            ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
N = input()
H = [s for s in input().split()]

HIEST = H[0]
COUNT = 0
for i in H:

    if i >= HIEST:
        HIEST = i
        COUNT = COUNT+1

print(COUNT)

Fixed submission:
A,B=(int(x) for x in input().split())

if A == B:
    COINS=2*A
    
elif A > B:
    COINS=2*A-1

else:
    COINS=2*B-1

print(COINS)
Buggy python submission (verdict: Time Limit Exceeded):
def MKNUMBER(ALL,l,r):
    number = ALL[l-1:r]
    return(number)
  
def countAC(number):
    count = 0
    flg = 0
    for i in number:
        if i == 0:
            flg = 0
        if i == 1:
            flg = 1
        if i == 2:
            if flg == 1:
                count = count + 1
            flg = 0
    print(count) 
    
N,Q = input().split()
N = int(N)
Q = int(Q)
S = input()
A=list(S)
ALL = []
for i in A:
        if i == "A":
            ALL.append(1)
        elif i == "C":
            ALL.append(2)
        else:
            ALL.append(0)
###print(ALL)
for i in range(0,Q):
    l,r = input().split()
    l = int(l)
    r = int(r)
    number = MKNUMBER(ALL,l,r)
    countAC(number)

Fixed submission:
N,Q = map(int,input().split())
S = input()
X = []
x = 0
check = 0
for i in S:
    if check == 1 and i == 'C':
        x += 1
        check = 0
    if i == 'A':
        check = 1
    else:
        check = 0
    X.append(x)
#print(X)
A = []
for _ in range(Q):
    l,r = map(int,input().split())
    ans = X[r-1] - X[l-1]
    A.append(ans)
for i in A:
    print(i)

Buggy python submission (verdict: Time Limit Exceeded):
def MKNUMBER(S,l,r):
    slice = S[l-1:r]
    A=list(slice)
    number=[]
    for i in A:
        if i == "A":
            number.append(1)
        elif i == "C":
            number.append(2)
        else:
            number.append(0)
    return(number)
  
def countAC(number):
    count = 0
    flg = 0
    for i in number:
        if i == 0:
            flg = 0
        if i == 1:
            flg = 1
        if i == 2:
            if flg == 1:
                count = count + 1
            flg = 0
    print(count) 
    
N,Q = input().split()
N = int(N)
Q = int(Q)
S = input()

for i in range(0,Q):
    l,r = input().split()
    l = int(l)
    r = int(r)
    number = MKNUMBER(S,l,r)
    countAC(number)

Fixed submission:
N,Q = map(int,input().split())
S = input()
X = []
x = 0
check = 0
for i in S:
    if check == 1 and i == 'C':
        x += 1
        check = 0
    if i == 'A':
        check = 1
    else:
        check = 0
    X.append(x)
#print(X)
A = []
for _ in range(Q):
    l,r = map(int,input().split())
    ans = X[r-1] - X[l-1]
    A.append(ans)
for i in A:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
ans = 0
for _ in range(len(S)):
    check = S[0]
    tmp = ans
    for i in range(1,len(S)):
        if check != S[i]:
            count = 1
            for _ in range(len(S)):
                if i-1-count > 0 and i+count < len(S):
                    if S[i-1-count] != S[i+count]:
                        count += 1
                    else:
                        break
                else:
                    break
            ans += 2 * count
            del S[i-count:i+count]
            break
        check = S[i]
    if len(S) == 0:
        break
    if tmp == ans:
        break
print(ans)

Fixed submission:
S = list(input())
c0 = 0
c1 = 0
for i in S:
    if i == '0':
        c0 += 1
    else:
        c1 += 1
ans = min(c0,c1) * 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
ans = 0
for _ in range(len(S)):
    check = S[0]
    tmp = ans
    for i in range(1,len(S)):
        if check != S[i]:
            count = 1
            for _ in range(len(S)):
                if i-1-count > 0 and i+count < len(S):
                    if S[i-1-count] != S[i+count]:
                        count += 1
                    else:
                        break
                else:
                    break
            ans += 2 * count
            del S[i-count:i+count]
            break
        check = S[i]
    if len(S) == 0:
        break
    if tmp == ans:
        break
print(ans)

Fixed submission:
S = list(input())
c0 = 0
c1 = 0
for i in S:
    if i == '0':
        c0 += 1
    else:
        c1 += 1
ans = min(c0,c1) * 2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
ans = 0
for _ in range(len(S)):
    check = S[0]
    tmp = ans
    for i in range(1,len(S)):
        if check != S[i]:
            ans += 2
            del S[i-1:i+1]
            break
        check = S[i]
    if len(S) == 0:
        break
    if tmp == ans:
        break
print(ans)

Fixed submission:
S = list(input())
c0 = 0
c1 = 0
for i in S:
    if i == '0':
        c0 += 1
    else:
        c1 += 1
ans = min(c0,c1) * 2
print(ans)
Buggy python submission (verdict: Runtime Error):
N,C,K = map(int,input().split())
T = []
for _ in range(N):
    t = int(input())
    T.append(t)
T.sort()
angry = 0
ans = 0
c = 0
for i in T:
    if angry == 0:
        angry = i + K
    c += 1
    if i >= angry :
        #print(i,angry)
        angry = i + K
        ans += 1
        c = 1
    if c == C:
        angry = 0
        ans += 1
        c = 0
    #print(ans,angry,c)
if c > 0:
    ans += 1
if C == 1:
    ans = C
print(ans)  

Fixed submission:
N,M = map(int,input().split())
X = list(map(int,input().split()))
X.sort()
if M <= N :
    ans = 0
else:
    Y = []
    for i in range(M-1):
        Y.append(X[i+1] - X[i])
    Y.sort(reverse=True)
    ans = X[-1] - X[0]
    Y = Y[:N-1]
    for i in Y:
        ans -= i
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()

check = 0
re = 0
t = 'keyence'
len = 0
ans = 0
for i in s:
    if t[len] == i and len < 7:
        len += 1
        re = 0
    else:
        if check == 0:
            check = 1
            re = 1
        elif re == 1:
            tmp = 1
        else:
            ans = 1

if ans == 0 and len == 7:
    print('YES')
else:
    print('NO')



    


Fixed submission:
s = input()
t = 'keyence'
ans = 0
flag = False
for i in range(len(s)):
    for j in range(i,len(s)):
        tmp = s[:i] + s[j:]
        if tmp == t:
            ans = 1
            flag = True
            break
    if flag:
        break
if ans == 1:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
S = str(input())

if len(S) == 2:
    print(S)
    
else:
    print(''.join(A))

Fixed submission:
S = str(input())

if len(S) == 2:
    print(S)
    
else:
    A = list(reversed(S))
    print(''.join(A))
Buggy python submission (verdict: Runtime Error):
A = [ int(i) for i in input().split()]

X = [ abs(A[0] - A[1]),abs(A[1] - A[2]),abs(A[0] -A[2])]

X = X.sort()
ans = X[1] + X[2]
print(ans)

Fixed submission:
A1,A2,A3 =(int(i) for i in input().split())

x = abs(A1-A2)
y = abs(A2-A3)
z = abs(A3-A1)

N = [x,y,z]
N.sort()
ans = N[0] + N[1]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
b = [0]
for i in range(n):
    x = 0
    x += b[i] + a[i]
    b.append(x)
b.sort()
check = 1000000000000
ans = 0
for i in range(n+1):
    if b[i] != check:
        y = b.count(b[i])
        ans += y * (y - 1) //2
        check = b[i]
print(ans)
    



Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = [0]
for i in range(n):
    x = 0
    x += b[i] + a[i]
    b.append(x)
b.sort()
check = b[0]
count = 1
ans = 0
for i in range(1,n+1):
    if b[i] == check:
        count += 1
    else:
        ans += count * (count - 1) // 2
        check = b[i]
        count = 1
ans += count * (count - 1) // 2            
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
b = [0]
for i in range(n):
    x = 0
    x += b[i] + a[i]
    b.append(x)
b.sort()
check = 1000000000000
ans = 0
for i in range(n+1):
    if b[i] != check:
        y = b.count(b[i])
        ans += y * (y - 1) //2
        check = b[i]
print(ans)
    



Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = [0]
for i in range(n):
    x = 0
    x += b[i] + a[i]
    b.append(x)
b.sort()
check = b[0]
count = 1
ans = 0
for i in range(1,n+1):
    if b[i] == check:
        count += 1
    else:
        ans += count * (count - 1) // 2
        check = b[i]
        count = 1
ans += count * (count - 1) // 2            
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
ans = 0
ans += a.count(0)
for i in range(2,n+1):
    tmp = []
    x = 0
    for j in range(i):
        x += a[j]
    if x == 0:
        ans += 1
    for k in range(n - i):
        x += a[k + i] - a[k]
        if x == 0:
            ans += 1
print(ans)        


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = [0]
for i in range(n):
    x = 0
    x += b[i] + a[i]
    b.append(x)
b.sort()
check = b[0]
count = 1
ans = 0
for i in range(1,n+1):
    if b[i] == check:
        count += 1
    else:
        ans += count * (count - 1) // 2
        check = b[i]
        count = 1
ans += count * (count - 1) // 2            
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = list(map(int,input().split()))
for i in range(n):
    xx = x[:i] + x[i+1:]
    xx.sort()
    print(xx[n//2 - 1])


Fixed submission:
n = int(input())
x = list(map(int,input().split()))
y = list(x)
y.sort()
z = n // 2 - 1
a = y[z]
b = y[z + 1]
for i in x:
    if i <= a :
        ans = b
    else:
        ans = a
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,Y = map(int,input().split())
X = Y // 1000
check = 0
for a in range(X // 10 + 1):
    for b in range(X // 5 + 1):
        c = N - a - b
        Z = 10 * a + 5 * b + c
        if c >= 0 and X == Z:
            check = 1
            break
    if check == 1:
        break
if check == 0:
    print(-1,-1,-1)
else:
    print(a,b,c)

Fixed submission:
N,Y = map(int,input().split())
X = Y // 1000
check = 0
for a in range(X // 10 + 1):
    for b in range(X // 5 + 1):
        c = N - a - b
        Z = 10 * a + 5 * b + c
        if c >= 0 and X == Z:
            check = 1
            break
    if check == 1:
        break
if check == 0:
    print(-1,-1,-1)
else:
    print(a,b,c)
Buggy python submission (verdict: Runtime Error):
A,B = (int(i) for i in input().split())
S = str(input())

if S[A] !== '-' or S[:A]in '-' or S[A+1:] in '-'or len(S) != A + B + 1:
    print('No')

else:
    print('Yes')


Fixed submission:
A,B = (int(i) for i in input().split())
S = str(input())
if S[A] != "-" or "-" in S[:A] or "-" in S[-B:]:
    print('No')

else:
    print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
b = set(a)
b = list(b)
x = [0 for i in range(len(b))]
for i in a:
    y = b.index(i)
    x[y] += 1
ans = 0
for i,j in zip(b,x):
    if j < i:
        ans += j
    else:
        ans += j - i
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a.sort()
count = 0
x = 0
tmp_count = 0
for i in a:
    if i != x:
        if tmp_count < x:
            count += tmp_count
        else:
            count += tmp_count - x
        tmp_count = 1
        x = i
    else:
        tmp_count += 1
if tmp_count < x:
    count += tmp_count
else:
    count += tmp_count - x
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
b = set(a)
b = list(b)
x = [0 for i in range(len(b))]
for i in a:
    y = b.index(i)
    x[y] += 1
ans = 0
for i,j in zip(b,x):
    if j < i:
        ans += j
    else:
        ans += j - i
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a.sort()
count = 0
x = 0
tmp_count = 0
for i in a:
    if i != x:
        if tmp_count < x:
            count += tmp_count
        else:
            count += tmp_count - x
        tmp_count = 1
        x = i
    else:
        tmp_count += 1
if tmp_count < x:
    count += tmp_count
else:
    count += tmp_count - x
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
b = set(a)
count = 0
for i in b:
    x = a.count(i) 
    if x < i:
        count += x
    else:
        count += x - i
print(count)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a.sort()
count = 0
x = 0
tmp_count = 0
for i in a:
    if i != x:
        if tmp_count < x:
            count += tmp_count
        else:
            count += tmp_count - x
        tmp_count = 1
        x = i
    else:
        tmp_count += 1
if tmp_count < x:
    count += tmp_count
else:
    count += tmp_count - x
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
b = set(a)
count = 0
for i in b:
    x = a.count(i) 
    if x < i:
        count += x
    else:
        count += x - i
print(count)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a.sort()
count = 0
x = 0
tmp_count = 0
for i in a:
    if i != x:
        if tmp_count < x:
            count += tmp_count
        else:
            count += tmp_count - x
        tmp_count = 1
        x = i
    else:
        tmp_count += 1
if tmp_count < x:
    count += tmp_count
else:
    count += tmp_count - x
print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
P = list(map(int,input().split()))
ans = 0
for i in range(N):
    if P[i] == i + 1:
        P[i],P[i+1] = P[i+1],P[i]
        ans += 1
print(ans)

Fixed submission:
N = int(input())
P = list(map(int,input().split()))
ans = 0
for i in range(N-1):
    if P[i] == i + 1:
        P[i],P[i+1] = P[i+1],P[i]
        ans += 1
if P[-1] == N:
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import fractions
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
mx = a[-1]
if mx < k:
    ans = 'IMPOSSIBLE'
else:
    gcd = fractions.gcd(a[0],a[1])
    for i in range(2,n):
        gcd = fractions.gcd(gcd,a[i])
    if k % gcd == 0:
        ans = 'POSSIBLE'
    else:
        ans = 'IMPOSSIBLE'
print(ans)

Fixed submission:
import fractions
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
mx = a[-1]
if mx < k:
    ans = 'IMPOSSIBLE'
elif n == 1:
    if a[0] == k:
        ans = 'POSSIBLE'
    else:
        ans = 'IMPOSSIBLE'
else:
    gcd = fractions.gcd(a[0],a[1])
    for i in range(0,n):
        gcd = fractions.gcd(gcd,a[i])
    if k % gcd == 0:
        ans = 'POSSIBLE'
    else:
        ans = 'IMPOSSIBLE'
print(ans)

Buggy python submission (verdict: Runtime Error):
import fractions
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
mx = a[-1]
if mx < k:
    ans = 'IMPOSSIBLE'
else:
    gcd = fractions.gcd(a[0],a[1])
    for i in range(2,n):
        tmp_gcd = fractions.gcd(gcd,a[i])
        if tmp_gcd < gcd:
            gcd = tmp_gcd
    if k % gcd == 0:
        ans = 'POSSIBLE'
    else:
        ans = 'IMPOSSIBLE'
print(ans)

Fixed submission:
import fractions
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
mx = a[-1]
if mx < k:
    ans = 'IMPOSSIBLE'
elif n == 1:
    if a[0] == k:
        ans = 'POSSIBLE'
    else:
        ans = 'IMPOSSIBLE'
else:
    gcd = fractions.gcd(a[0],a[1])
    for i in range(0,n):
        gcd = fractions.gcd(gcd,a[i])
    if k % gcd == 0:
        ans = 'POSSIBLE'
    else:
        ans = 'IMPOSSIBLE'
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
b = []
for i in range(n):
    if  i % 2 == 1:
        b = b + [a[i]]
    else:
        b = [a[i]] + b
if n % 2 == 0:
    b.reverse()
print(' '.join(map(str,b)))

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = []
c = []
for i in range(n):
    if  i % 2 == 1:
        b.append(a[i])
    else:
        c.append(a[i])
if n % 2 == 0:
    b.reverse()
    ans = b + c
else:
    c.reverse()
    ans = c + b
print(' '.join(map(str,ans)))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
b = []
for i in range(n):
    if  i % 2 == 1:
        b = b + [a[i]]
    else:
        b = [a[i]] + b
if n % 2 == 0:
    b.reverse()
print(' '.join(map(str,b)))

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = []
c = []
for i in range(n):
    if  i % 2 == 1:
        b.append(a[i])
    else:
        c.append(a[i])
if n % 2 == 0:
    b.reverse()
    ans = b + c
else:
    c.reverse()
    ans = c + b
print(' '.join(map(str,ans)))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
b = []
for i in a:
    b.append(i)
    b.reverse()
print(' '.join(map(str,b)))
    

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = []
c = []
for i in range(n):
    if  i % 2 == 1:
        b.append(a[i])
    else:
        c.append(a[i])
if n % 2 == 0:
    b.reverse()
    ans = b + c
else:
    c.reverse()
    ans = c + b
print(' '.join(map(str,ans)))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
b = []
for i in a:
    b.append(i)
    b.reverse()
print(' '.join(map(str,b)))

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
b = []
c = []
for i in range(n):
    if  i % 2 == 1:
        b.append(a[i])
    else:
        c.append(a[i])
if n % 2 == 0:
    b.reverse()
    ans = b + c
else:
    c.reverse()
    ans = c + b
print(' '.join(map(str,ans)))
Buggy python submission (verdict: Runtime Error):
X,A,B = (int(i) for i in input().split())
Y = A - B
if Y >= 0:
    print('delicious')

elif (-1) * Y =< X :
    print('safe')
    
else:
    print('dangerous')

Fixed submission:
X,A,B = (int(i) for i in input().split())
Y = A - B
if Y >= 0:
    print('delicious')

elif (-1) * Y <= X :
    print('safe')
    
else:
    print('dangerous')