Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02923 (python)

Fixed submission:
N=int(input())
H=list(map(int,input().split()))
c=0
C=[0]

for i in range(N-1) :

    if H[i] >= H[i+1] :

        c+=1

    if i==N-2 or H[i] < H[i+1]:

        C.append(c)

        c = 0

print(max(C))

Buggy submission (verdict: Runtime Error):

N=int(input())
H=list(map(int,input().split()))
c=0
C=[]

for i in range(N-1) :

    if H[i] >= H[i+1] :

        c+=1

    if i==N-2 or H[i] < H[i+1]:

        C.append(c)

        c = 0

        
print(max(C))

Buggy submission (verdict: Runtime Error):
N=int(input())
H=list(map(int,input().split()))
c=0
C=[]

for i in range(N-1) :

    if N == 1 :

        break



    if H[i] >= H[i+1] :

        c+=1

    if i==len(H)-2 or H[i] < H[i+1]:

        C.append(c)

        c = 0

        
print(max(C))

Buggy submission (verdict: Runtime Error):
N=int(input())
H=list(map(int,input().split()))
c=0
C=[]

for i in range(len(H)-1) :

    if N == 1 :

        break



    if H[i] >= H[i+1] :

        c+=1

    if i==len(H)-2 or H[i] < H[i+1]:

        C.append(c)

        c = 0

        
print(max(C))

Buggy submission (verdict: Runtime Error):
N=int(input())
H=list(map(int,input().split()))
c=0
C=[]

for i in range(len(H)-1) :

    if H[i] >= H[i+1] :

        c+=1

    if i==len(H)-2 or H[i] < H[i+1]:

        C.append(c)

        c = 0

        
print(max(C))
Problem p02924 (python)

Fixed submission:
N = int(input())
print( (N *(N-1)) // 2 )

Buggy submission (verdict: Runtime Error):
N = int(input())


if N % 2 == 0:
    if N == 2:
        print(1%2)

    else:
        print( int( ( N / 2 ) * (N-1) ) + )

elif N % 2 == 1:

    print( int( ( ( N / 2 ) * (N-1) )     ))

Buggy submission (verdict: Runtime Error):
N = int( input() )

L = list(range(1,N+1))



if len(L)==1:
    print(L[0]%1)

elif len(L)==2:
    print(L[0]%2)

elif L[len(L)-1] % 2 == 0:
    print(sum(L[1:len(L)-1]))

else:
    print(sum(L[1:len(L)-1])+1)

Buggy submission (verdict: Runtime Error):
N = int( input() )

L = list(range(1,N+1))



if len(L)==1:
    print(L[0]%1)

elif len(L)==2:
    print(L[0]%2)

    


elif L[len(L)-1] % 2 == 0:
    print(sum(L[1:len(L)-1]))

else:
    print(sum(L[0:len(L)-1]))

Buggy submission (verdict: Runtime Error):
N = int( input() )

R = list(range(1,N+1))
L = list(range(1,N+1))

if N==1:

    print(1%1)

elif N==2:

    R.insert(0,R.pop(1))


else:
    R.insert(len(R)-1,R.pop(1))


    print(sum(list(map(lambda x,y: x % y,L,R))))

Buggy submission (verdict: Runtime Error):
N = int( input() )

R = list(range(1,N+1))
L = list(range(1,N+1))

if N==1:

    print(0)

elif N==2:

    print(1)


else:
    R.insert(len(R)-1,R.pop(1))


    print(sum(list(map(lambda x,y: x % y,L,R))))
Problem p02981 (python)

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

if N*A>=B:
    print(B)
elif N*A<=B:
    print(N*A)

Buggy submission (verdict: Runtime Error):
N, A, B = map(int,input().split())

if NA > B:
    print(B)
elif NA < B:
    print(AN)
else:
    print(AN)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = int(input())
B = int(input())

if N*A > B:
    print(B)
elif N*A < B:
    print(A*N)
else:
    print(A*N)
Problem p03289 (python)

Fixed submission:
S=list(input())

if S[0]!='A':
    print('WA')
    exit()

if S[2:len(S)-1].count('C')!=1:
    print('WA')
    exit()

S.remove('C')
S.remove('A')

for i in S:
    if i not in 'abcdefghizklmnopqrstuvwxyz':
        print('WA')
        exit()


print('AC')

Buggy submission (verdict: Runtime Error):
import re
S=list(input())

if S[0]!='A':
    print('WA')
    exit()

if S[2:len(S)-1].count('C')!=1:
    print('WA')
    exit()

S.remove('C')
S.remove('A')

for i in S:
    if i not in 'abcdefghizklmnopqrstuvwxyz':
        exit('WA')


print('AC')
Problem p03943 (python)

Fixed submission:
s = list(map(int, input().split()))
a=s[0]
b=s[1]
c=s[2]

d="No"
if a==(b+c):
        d="Yes"
if b==(c+a):
        d="Yes"
if c==(a+b):
        d="Yes"
print(d)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
d="No"
if a==(b+c):
        d="Yes"
if b==(c+a):
        d="Yes"
if c==(a+b):
        d="Yes"
print(d)
Problem p03105 (python)

Fixed submission:
A, B, C = (int(i) for i in input().split())
if B > (A*C):
  print(C)
else:
  print(B//A)

Buggy submission (verdict: Runtime Error):
A, B, K = (int(i) for i in input().split())
list = []
for i in range(1, 100):
  if A % == 0 and B % i == 0:
    list.append(i)
print(list[len(list)-K])
Problem p03106 (python)

Fixed submission:
A, B, K = (int(i) for i in input().split())
list = []
 
for i in range(101):
  if i != 0:
    if A % i == 0 and B % i == 0:
      list.append(i)
print(list[len(list)-K])

Buggy submission (verdict: Runtime Error):
A, B, K = (int(i) for i in input().split())
list = []

if A > B:
  judge = A
else:
  judge = B
for i in range(judge):
  if i != 0:
    if A % i == 0 and B % i == 0:
      list.append(i)
print(list[len(list)-K])

Buggy submission (verdict: Runtime Error):
try:
  A, B, K = (int(i) for i in input().split())
  list = []
  for i in range(1, 100):
    if A % == 0 and B % i == 0:
      list.append(i)
  print(list[len(list)-K])
  
except ZeroDivisionError:
    print("ZeroDivisionError!!")

Buggy submission (verdict: Runtime Error):
A, B, K = (int(i) for i in input().split())
list = []
for i in range(1, 101):
  if A % == 0 and B % i == 0:
    list.append(i)
print(list[len(list)-K])

Buggy submission (verdict: Runtime Error):
A, B, K = (int(i) for i in input().split())
list = []
for i in range(101):
  if i != 0:
    if i % A == 0 and i % B == 0:
      list.append(i)
print(list[len(list)-K])

Buggy submission (verdict: Runtime Error):
A, B, K = (int(i) for i in input().split())
list = []


for i in range(1, 100):
  if i % A == 0 and i % B == 0:
    list.append(i)
a = len(list)-K
print(list[a])

Buggy submission (verdict: Runtime Error):
A, B, K = (int(i) for i in input().split())
list = []


for i in range(101):
  if i != 0:
    if i % A == 0 and i % B == 0:
      list.append(i)
print(list[len(list)-K])

Buggy submission (verdict: Runtime Error):
A, B, K = (int(i) for i in input().split())
list = []


for i in range(1, 100):
  if i % A == 0 and i % B == 0:
    list.append(i)
print(list[len(list)-K])

Buggy submission (verdict: Runtime Error):
A, B, K = (int(i) for i in input().split())
list = []

for i in range(1, 100):
  if i % A == 0 and i % B == 0:
    list.append(i)
print(list[K-1])
Problem p03448 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
x = int(input())

counter = 0

for i in range(0, a + 1):
	if x - (500 * i) >= 0:
		x_f = x - (500 * i)

		if x_f == 0:
			counter += 1
			break

		for j in range(0, b + 1):
			if x_f - (100 * j) >= 0:
				x_s = x_f - (100 * j)

				if x_s == 0:
					counter += 1
					break

				for k in range(0, c + 1):
					if x_s - (50 * k) >= 0:
						x_t = x_s - (50 * k)

						if x_t == 0:
							counter += 1
							break


print(counter)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
x = int(input())

counter = 0

for i in range(0, a + 1):
	if x - (500 * i) >= 0:
		x_f = x - (500 * i)

		if x_f == 0:
			counter += 1
			break

    	for j in range(0, b + 1):
    		if x_f - (100 * j) >= 0:
    			x_s = x_f - (100 * j)

    			if x_s == 0:
    				counter += 1
    				break

        		for k in range(0, c + 1):
        			if x_s - (50 * k) >= 0:
        				x_t = x_s - (50 * k)

        				if x_t == 0:
        					counter += 1
        					break


print(counter)
Problem p03126 (python)

Fixed submission:
N,M = map(int,input().split())
res = []
for i in range(N):
    res.append(list(map(int,input().split())))

if N == 1:
    print(res[0][0])
    exit()

s = [0 for i in range(M)]
for i in res:
    for j in i[1:]:
        #print(j)
        s[j-1] += 1

#print(s)

count = 0
for i in range(M):
    if s[i] == N:
        count += 1

print(count)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
res = []
for i in range(N):
    res.append(list(map(int,input().split())))

if N == 1:
    print(res[0][0])
    exit()

s = [0 for i in range(M)]
for i in res:
    for j in i[1:]:
        s[j-1] += 1

count = 0
for i in range(N):
    if s[i] == N:
        count += 1

print(count)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
res = []
for i in range(N):
    res.append(list(map(int,input().split())))

if N == 1:
    print(res[0][0])
    exit()

s = [0 for i in range(M)]
for i in res:
    for j in i[1:]:
        s[j-1] += 1

count = 0
for i in range(N):
    if s[i] == N:
        count += 1
Problem p03194 (python)

Fixed submission:
import traceback
import fractions
from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

class PrimeFractorization:
    def __init__(self):
        self.a = 2

    def decomposit_prime(self, n):
        res = []
        try:
            while n >= self.a * self.a:
                if n % self.a == 0:
                    res.append(self.a)
                    #print(self.a, "* ", end="")
                    n //= self.a
                else:
                    self.a += 1

            res.append(n)
            
            return res

        except Exception as e:
            raise

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

obj = PrimeFractorization()
factor = obj.decomposit_prime(P)

res_fac = factor[:N]
amari = factor[N:]

index = 0
for i in amari:
    if len(res_fac)-1 < index:
        index = 0
    res_fac[index] *= i
    index += 1

print(gcd_list(res_fac))

Buggy submission (verdict: Runtime Error):
import fractions
from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors

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

factor = prime_factors(P)

res_fac = factor[:N]
rem_fac = factor[N:]

index = 0
for i in rem_fac:
    if len(res_fac)-1 < index:
        index = 0
    res_fac[index] *= i
    index += 1

print(gcd_list(res_fac))

Buggy submission (verdict: Runtime Error):
import fractions
from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

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

root = int(P**(1/N))

while P % root != 0:
    root += 1

fac1 = root

fac_list = []

for i in range(N - 1):
    while P % fac1 != 0:
        if P > fac1:
            fac1 += 1
        else:
            fac -= 1
    P /= fac1
    fac_list.append(fac1)

fac_list.append(int(P))

#print(fac_list)

print(int(gcd_list(fac_list)))

Buggy submission (verdict: Runtime Error):
import fractions
from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

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

root = int(P**(1/N))

while P % root != 0:
    root += 1

fac1 = root

fac_list = [fac1]

for i in range(N - 1):
    while P % fac1 != 0:
        if P > fac1:
            fac1 += 1
        else:
            fac -= 1
    P /= fac1
    fac_list.append(fac1)

fac_list.append(int(P))

#print(fac_list)

print(int(gcd_list(fac_list)))
Problem p03260 (python)

Fixed submission:
a,b=[int(i) for i in input().split()]

res = 0
f = False
for i in range(1,4):
    res = a * b * i
    if res % 2 == 1:
        f = True

if f:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N,X =[int(i) for i in input().split()]
c = [int(i) for i in input().split()]

c.append(X)
c.sort()

D = float('inf')

for i in range(1,N+1):
    if c[i] - c[i-1] < D:
        D = abs(c[i] - c[i-1])

print(int(D))

Buggy submission (verdict: Runtime Error):
N,X =[int(i) for i in input().split()]
c = [int(i) for i in input().split()]

c.append(X)
c.sort()

D = float('inf')

for i in range(1,N+1):
    if c[i] - c[i-1] < D:
        D = abs(c[i] - c[i-1])

print(int(D))
Problem p03262 (python)

Fixed submission:
import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


N,X =[int(i) for i in input().split()]
c = [int(i) for i in input().split()]

for i in range(N):
    c[i] = abs(c[i] - X)

print(gcd_list(c))

Buggy submission (verdict: Runtime Error):
N,X =[int(i) for i in input().split()]
c = [int(i) for i in input().split()]

c.append(X)
c.sort()

index_x = c.index(X)

if len(c) == 2:
    print(abs(c[index_x] - c[index_x - 1]))
else:
    print(min(c[index_x] - c[index_x - 1],c[index_x + 1] - c[index_x]))

Buggy submission (verdict: Runtime Error):
N,X =[int(i) for i in input().split()]
c = [int(i) for i in input().split()]

c.append(X)
c.sort()

D = float('inf')

for i in range(1,N+2):
    if c[i] - c[i-1] < D:
        D = c[i] - c[i-1]

print(int(D))
Problem p03309 (python)

Fixed submission:
import collections
 
N = int(input())
A = [int(i) for i in input().split()]
 
sub = [A[i]-(i+1) for i in range(N)]
res = 0
sub = sorted(sub)
b = sub[int(N/2)]
 
res = 0
for i in range(N):
    res += abs(A[i]-(b+i+1))
 
print(res)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]
 
sub = [A[i]-(i+1) for i in range(N)]
res = 0

if N % 2 != 0:
    b = sub[int(N-1/2)+1]
    res = 0
    for i in range(N):
        res += abs(A[i]-(b+i+1))
else:
    b1 = sub[int(N-1/2)]
    b2 = sub[int(N-1/2)+1]
    res1 = 0
    for i in range(N):
        res1 += abs(A[i]-(b1+i+1))
    res2 = 0
    for i in range(N):
        res2 += abs(A[i]-(b2+i+1))
    res = min(res1,res2)

print(res)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]
 
sub = [A[i]-(i+1) for i in range(N)]
res = 0

if N % 2 != 0:
    b = sub[int(N/2)+1]
    res = 0
    for i in range(N):
        res += abs(A[i]-(b+i+1))
else:
    b1 = sub[int(N/2)]
    b2 = sub[int(N/2)+1]
    res1 = 0
    for i in range(N):
        res1 += abs(A[i]-(b1+i+1))
    res2 = 0
    for i in range(N):
        res2 += abs(A[i]-(b2+i+1))
    res = min(res1,res2)

print(res)

Buggy submission (verdict: Runtime Error):
import collections
 
N = int(input())
A = [int(i) for i in input().split()]
 
sub = [A[i]-(i+1) for i in range(N)]
res = 0

if N % 2 != 0:
    b = sub[int(N/2)+1]
    res = 0
    for i in range(N):
        res += abs(A[i]-(b+i+1))
else:
    b1 = sub[int(N/2)]
    b2 = sub[int(N/2)+1]
    res1 = 0
    for i in range(N):
        res1 += abs(A[i]-(b1+i+1))
    res2 = 0
    for i in range(N):
        res2 += abs(A[i]-(b2+i+1))
    res = min(res1,res2)

print(res)
Problem p03328 (python)

Fixed submission:
a,b=[int(i) for i in input().split()]

d = b - a

h = 0
for i in range(1,d):
    h += i

print(h-a)

Buggy submission (verdict: Runtime Error):
a,b=[int(i) for i in input().split()]

d = b - a

for i in range(1,d):
    h += i

print(h-a)

Buggy submission (verdict: Runtime Error):
a,b=[int(i) for i in input().split()]

h = 0
i = 0
while h < a and i < 1000:
    i += 1
    h += i

if i > 999
    print(h-b)
else:
    print(h-a)
Problem p03355 (python)

Fixed submission:
s = list(input())
k = int(input())
sub = []
sub += s[:]
 
for j in range(2,k+1):
    charGram = [''.join(s[i:i+j]) for i in range(len(s)-1)]
    sub += charGram
sub = list(set(sub))
print(sorted(sub)[k-1])

Buggy submission (verdict: Runtime Error):
s = list(input())
k = int(input())
sub = []
sub += s[:]
 
for j in range(2,K+1):
    charGram = [''.join(s[i:i+j]) for i in range(len(s)-1)]
    sub += charGram
sub = list(set(sub))
print(sorted(sub)[k-1])
Problem p03379 (python)

Fixed submission:
N = int(input())
X = [int(i) for i in input().split()]

sortedX = X[:]
sortedX.sort()
lenX = len(X)

for i in X:
    if i > sortedX[int(lenX/2) - 1]:
        print(sortedX[int(lenX/2)-1])
    else:
        print(sortedX[int(lenX/2)])

Buggy submission (verdict: Runtime Error):
mport numpy as np

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

arrayX = np.array(X)
num = arrayX.size

for i in range(num):
    arrayX = np.delete(arrayX,i)
    print(int(np.median(arrayX)))
    arrayX = np.array(X)
Problem p03436 (python)

Fixed submission:
from collections import deque

H,W = map(int,input().split())
_input = []
for i in range(H):
    row = list(map(str,input().split()))
    _input.append(list(row[0]))

sy,sx = 0,0
gy,gx = H-1,W-1

queue = deque([(sy,sx)])

dyx=((1,0),(-1,0),(0,1),(0,-1))

counted_map = [[-1]*W for _ in range(H)]
counted_map[sy][sx] = 0

reach = False

while queue:
    y,x = queue.popleft()

    if (y,x) == (gy,gx):
        reach = True
        break

    for dy,dx in dyx:
        ny = y + dy
        nx = x + dx

        if ny < 0 or nx < 0 or ny >= H or nx >= W:
            continue

        # 空きマスかつ未訪問
        if _input[ny][nx] == '.' and counted_map[ny][nx] == -1:
            counted_map[ny][nx] = counted_map[y][x] + 1
            queue.append((ny,nx))

if not reach:
    print(-1)
    exit()
'''
y,x = gy,gx
move_num = counted_map[gy][gx]
while move_num != 0:
    _input[y][x] = 'o'
    for dy,dx in dyx:
        ny = y + dy
        nx = x + dx

        if ny < 0 or nx < 0 or ny >= H or nx >= W:
            continue
        
        if _input[ny][nx] == '.':
            tmp_dist = counted_map[ny][nx]
            if tmp_dist < move_num:
                move_num = tmp_dist
                next_y,next_x = ny,nx
    
    y,x = next_y,next_x

_input[sy][sx] = 'o'
'''

res = 0

for raw in _input:
    for i in raw:
        if i == '.':
            res += 1

print(res-counted_map[gy][gx]-1)

Buggy submission (verdict: Runtime Error):
from collections import deque

H,W = map(int,input().split())
_input = []
for i in range(H):
    row = list(map(str,input().split()))
    _input.append(list(row[0]))

sy,sx = 0,0
gy,gx = H-1,W-1

queue = deque([(sy,sx)])

dyx=((1,0),(-1,0),(0,1),(0,-1))

counted_map = [[-1]*W for _ in range(H)]
counted_map[sy][sx] = 0

while queue:
    y,x = queue.popleft()

    if (y,x) == (gy,gx):
        break

    for dy,dx in dyx:
        ny = y + dy
        nx = x + dx

        if ny < 0 or nx < 0 or ny >= H or nx >= W:
            continue

        # 空きマスかつ未訪問
        if _input[ny][nx] == '.' and counted_map[ny][nx] == -1:
            counted_map[ny][nx] = counted_map[y][x] + 1
            queue.append((ny,nx))

y,x = gy,gx
move_num = counted_map[gy][gx]
while move_num != 0:
    _input[y][x] = 'o'
    for dy,dx in dyx:
        ny = y + dy
        nx = x + dx

        if ny < 0 or nx < 0 or ny >= H or nx >= W:
            continue
        
        if _input[ny][nx] == '.':
            tmp_dist = counted_map[ny][nx]
            if tmp_dist < move_num:
                move_num = tmp_dist
                next_y,next_x = ny,nx
    
    y,x = next_y,next_x

_input[sy][sx] = 'o'

res = 0

for raw in _input:
    for i in raw:
        if i == '.':
            res += 1

print(res)
Problem p03474 (python)

Fixed submission:
A,B=[int(i) for i in input().split()]
S = input()

if S[A] == '-' and S.count('-') == 1:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
A,B=[int(i) for i in input().split()]
S = input()

if S[0:A-1].isdisit() and S[A] == '-' and S[A+1:].isdisit():
    print('Yes')
else:
    print('No')
Problem p03487 (python)

Fixed submission:
from collections import Counter

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

d = Counter(A).most_common()
d = d[::-1]

reCounter = 0

for i in range(len(d)):
    if d[i][0] < d[i][1]:
        reCounter += d[i][1] - d[i][0]
    if d[i][0] > d[i][1]:
        reCounter += d[i][1]
        
print(reCounter)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]

d = Counter(A).most_common()
d = d[::-1]

reCounter = 0

for i in range(len(d)):
    if d[i][0] < d[i][1]:
        reCounter += d[i][1] - d[i][0]
    if d[i][0] > d[i][1]:
        reCounter += d[i][1]
        
print(reCounter)
Problem p03645 (python)

Fixed submission:
from collections import deque

N, M = map(int, input().split())
route = []
for i in range(M):
    route.append(list(map(int,input().split())))

island_map = {}
for a,b in route:
    if a not in island_map:
        island_map[a] = [b]
    else:
        island_map[a].append(b)

first_island = deque()
first_island += island_map[1]
second_island = deque()

for i in first_island:
    if i in island_map:
        second_island += island_map[i]
    else:
        pass
    for j in second_island:
        if j == N:
            print('POSSIBLE')
            exit()

print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = []
tmp = []
for i in range(M):
    tmp = list(map(str,input().split()))
    a.append(list(tmp))

siCheck = [0 for i in range(N)]
inCheck = [0 for i in range(N)]

for i in range(N):
    if a[i][0] == '1':
        siCheck[int(a[i][1])-1] = True
    else:
        siCheck[int(a[i][1])-1] = False
    if int(a[i][1]) == N:
        inCheck[int(a[i][0])-1] = True
    else:
        inCheck[int(a[i][0])-1] = False

for i in range(N):
    if siCheck[i] and inCheck[i]:
        print('POSSIBLE')
        exit()

print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = []
tmp = []
for i in range(M):
    tmp = list(map(str,input().split()))
    a.append(list(tmp))

siCheck = [0 for i in range(N)]
inCheck = [0 for i in range(N)]

for i in range(M):
    if a[i][0] == '1':
        siCheck[int(a[i][1])-1] = True
    else:
        siCheck[int(a[i][1])-1] = False
    if int(a[i][1]) == N:
        inCheck[int(a[i][0])-1] = True
    else:
        inCheck[int(a[i][0])-1] = False

for i in range(M):
    if siCheck[i] and inCheck[i]:
        print('POSSIBLE')
        exit()

print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
a = []
tmp = []
for i in range(M):
    tmp = list(map(str,input().split()))
    a.append(list(tmp))

siCheck = [0 for i in range(N)]
inCheck = [0 for i in range(N)]

for i in range(M):
    if a[i][0] == '1':
        siCheck[int(a[i][1])-1] = True
    else:
        siCheck[int(a[i][1])-1] = False
    if int(a[i][1]) == N:
        inCheck[int(a[i][0])-1] = True
    else:
        inCheck[int(a[i][0])-1] = False

for i in range(M):
    if siCheck[i] and inCheck[i]:
        print('POSSIBLE')
        exit()

print('IMPOSSIBLE')
Problem p03673 (python)

Fixed submission:
from collections import deque

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

B = deque(maxlen=2*10**5)

if N % 2 == 0:
    for i in range(N):
        if i % 2 == 0:
            B.append(A[i])
        else:
            B.appendleft(A[i])
else:
    for i in range(N):
        if i % 2 == 0:
            B.appendleft(A[i])
        else:
            B.append(A[i])

print(*B)

Buggy submission (verdict: Runtime Error):
from collections import deque

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

B = deque(maxlen=2*10**5)

if N % 2 == 0:
    for i in range(N):
        if i % 2 == 0:
            B.append(A[i])
        else:
            B.insert(0,A[i])
else:
    for i in range(N):
        if i % 2 == 0:
            B.insert(0,A[i])
        else:
            B.append(A[i])

print(*B)

Buggy submission (verdict: Runtime Error):
from collections import deque

N = int(input())
A = [int(i) for i in input().split()]
 
B = deque(maxlen=2*10**5)
 
if N % 2 == 0:
    for i in range(N):
        if i % 2 == 0:
            B.append(A[i])
        else:
            B.insert(0,A[i])
else:
    for i in range(N):
        if i % 2 == 0:
            B.insert(0,A[i])
        else:
            B.append(A[i])

print(*B)