Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())
a = list(map(int,input().split()))

used = collections.Counter(a)
a.sort()
a.reverse()

two = [2]
i = 0
while two[i]*2 <= 2*10**9:
    two.append(two[i]*2)
    i += 1
two.reverse()

counter = 0
for i in range(n):
    if used[a[i]] > 0:
        while two[-1] > 2*a[i]:
            two.pop(-1)
        for k in range(len(two)):
            if used[two[k]-a[i]] >= 1:
                if two[k]-a[i] != a[i]:
                    counter += 1
                    used[two[k]-a[i]] -= 1
                    used[a[i]] -= 1
                else:
                    if used[a[i]] >= 2:
                        counter += 1
                        used[two[k]-a[i]] -= 1
                        used[a[i]] -= 1
print(counter)

Fixed submission:
import collections
n = int(input())
a = list(map(int,input().split()))

used = collections.Counter(a)
a.sort()
a.reverse()

two = [2]
i = 0
while two[i]*2 <= 2*10**9:
    two.append(two[i]*2)
    i += 1

counter = 0
for i in range(n):
    if used[a[i]] > 0:
        used[a[i]] -= 1
        while two[-1] > 2*a[i]:
            two.pop(-1)

        if used[two[-1]-a[i]] >= 1:
            counter += 1
            used[two[-1]-a[i]] -= 1

print(counter)
Buggy python submission (verdict: Runtime Error):
x  = int(input())
if x == 3 or x == 5 or x == 7:
    print('YES')
else:
    print('NO')

Fixed submission:
x  = int(input())
if x == 3 or x == 5 or x == 7:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
x = list(map(int,input().split()))

l = 0
r = k-1
mnm = 1000100010
while r<n:
    a = abs(x[l])+abs(x[l]-x[r])
    b = abs(x[r])+abs(x[r]-x[l])
    if a<=b:
        if a < mnm:
            mnm = a
    else:
        if b < mnm:
            mnm = b
    l += 1
    r += 1
print(mnm)

Fixed submission:
n,i = map(int,input().split())
print(n-i+1)
Buggy python submission (verdict: Runtime Error):
invtwos = [1]
i = 0
while abs(invtwos[i]) <= 10**9:
    invtwos.append(invtwos[i]*(-2))
    i += 1
invtwos.append(invtwos[-1]*(-2))

n = int(input())
ans = []
i = 0
while n != 0:
    if n%abs(invtwos[i+1]) != 0:
        ans.append(1)
        n -= invtwos[i]
    else:
        ans.append(0)
    i += 1
ans.reverse()
for i in range(len(ans)):
    if i != len(ans)-1:
        print(ans[i],end="")
    else:
        print(ans[i])

Fixed submission:
invtwos = [1]
i = 0
while abs(invtwos[i]) <= 10**10:
    invtwos.append(invtwos[i]*(-2))
    i += 1
invtwos.append(invtwos[-1]*(-2))

n = int(input())
ans = []
i = 0
while n != 0:
    if n%abs(invtwos[i+1]) != 0:
        ans.append(1)
        n -= invtwos[i]
    else:
        ans.append(0)
    i += 1
ans.reverse()

if len(ans) == 0:
    print("0")
else:
    for i in range(len(ans)):
        if i != len(ans)-1:
            print(ans[i],end="")
        else:
            print(ans[i])
Buggy python submission (verdict: Runtime Error):
a,b = int(input().split())
if a+b==15:
  print('+')
elif a*b == 15:
  print('*')
else:
  print('x')

Fixed submission:
a,b = map(int,input().split())
if a+b==15:
  print('+')
elif a*b == 15:
  print('*')
else:
  print('x')
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if a >= 9 or b >= 9:
	print(':(')
else:
	print('Yay!')

Fixed submission:
a,b = map(int,input().split())
if a >= 9 or b >= 9:
	print(':(')
else:
	print('Yay!')
Buggy python submission (verdict: Runtime Error):
import collections
n = int(input())
s = input()
ans = []
for i in range(1,n-1):
    counter = 0
    seg = s[0:i]
    another = s[i:n]
    d = collections.Counter(seg)
    for k in d:
        if k in another:
            counter += 1
    ans.append(counter)
print(max(ans))

Fixed submission:
import collections
n = int(input())
s = input()
ans = []
if n != 2:
    for i in range(1,n-1):
        counter = 0
        seg = s[0:i]
        another = s[i:n]
        d = collections.Counter(seg)
        for k in d:
            if k in another:
                counter += 1
        ans.append(counter)
    print(max(ans))
else:
    if s[0] == s[1]:
        print('1')
    else:
        print('0')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
counter = n
for i in range(n-1):
	k = i+1
	cumsum = a[i]
	while k <= n-1 and cumsum^a[k] == cumsum+a[k]:
		counter += 1
		cumsum += a[k]
		k += 1
print(counter)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
counter = n
prev = [[0,0]]

total = [0]
for i in range(n):
	total.append(total[i]+a[i])

for i in range(n-1):
	k = prev[i][1]+1
	counter += prev[i][1]-i
	cumsum = total[k]-total[i]
	while k <= n-1 and cumsum^a[k] == cumsum+a[k]:
		counter += 1
		cumsum += a[k]
		k += 1
	prev.append([i,k-1])
print(counter)
Buggy python submission (verdict: Runtime Error):
x = int(input())
table = [1]
for i in range(2,1000):
	b = 2
	while i**b <= 1000:
		table.append(i**b)
		b += 1
table.sort()
k = 0
while table[k] <= x:
	k += 1
print(table[k-1])

Fixed submission:
x = int(input())
table = [1]
for i in range(2,1000):
	b = 2
	while i**b <= 1000:
		table.append(i**b)
		b += 1
table.sort()
k = 0
while k <= len(table)-1 and table[k] <= x:
	k += 1
print(table[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
import collections
n,m = map(int,input().split())
p = list(map(int,input().split()))
base = 0
basemap = []
for i in range(n):
	if (i+1) == p[i]:
		base += 1
		basemap.append(i+1)

branch = dict()
for i in range(1,n+1):
	branch[i] = []

for i in range(m):
	x,y = map(int,input().split())
	branch[x].append(y)
	branch[y].append(x)
compare = [0 for i in range(n+1)]
for i in range(1,n+1):
	if branch[i] != []:
		compare[i] = 1

arrival = [0 for i in range(n+1)]
ans = []
q = []

while arrival != compare:
	counter = base
	for i in range(1,n+1):
		if arrival[i] == 0 and compare[i] == 1:
			q.append(i)
			arrival[i] = 1
			break
	section = [q[0]]
	while len(q) > 0:
		next = branch[q[0]]
		for i in range(len(next)):
			if arrival[next[i]] == 0:
				section.append(next[i])
				arrival[next[i]] = 1
				q.append(next[i])
		q.pop(0)
	psec = []
	for i in range(len(section)):
		psec.append(p[section[i]-1])
	t = section + psec + basemap
	search = collections.Counter(t)
	for i in search:
		if search[i] == 2:
			 counter += 1
	ans.append(counter)
print(max(ans))

Fixed submission:
import collections
n,m = map(int,input().split())
p = list(map(int,input().split()))
base = 0
basemap = []
for i in range(n):
	if (i+1) == p[i]:
		base += 1
		basemap.append(i+1)

branch = dict()
for i in range(1,n+1):
	branch[i] = []

for i in range(m):
	x,y = map(int,input().split())
	branch[x].append(y)
	branch[y].append(x)
compare = [0 for i in range(n+1)]
for i in range(1,n+1):
	if branch[i] != []:
		compare[i] = 1

arrival = [0 for i in range(n+1)]
ans = []
q = []

ind = 1
while arrival != compare:
	counter = base
	while not(arrival[ind] == 0 and compare[ind] == 1):
		ind += 1
	q.append(ind)
	arrival[ind] = 1
	section = [q[0]]
	while len(q) > 0:
		next = branch[q[0]]
		for i in range(len(next)):
			if arrival[next[i]] == 0:
				section.append(next[i])
				arrival[next[i]] = 1
				q.append(next[i])
		q.pop(0)
	psec = []
	for i in range(len(section)):
		psec.append(p[section[i]-1])
	t = section + psec + basemap
	search = collections.Counter(t)
	for i in search:
		if search[i] == 2:
			 counter += 1
	ans.append(counter)
print(max(ans))
Buggy python submission (verdict: Time Limit Exceeded):
h,w,d = map(int,input().split())
a = []
branch = dict()
for i in range(1,h*w+1):
	branch[i] = []
for i in range(h):
	atemp = list(map(int,input().split()))
	for k in range(w):
		branch[atemp[k]].append(i+1)
		branch[atemp[k]].append(k+1)
	a.append(atemp)
q = int(input())
l = []
r = []
for i in range(q):
	ltemp,rtemp = map(int,input().split())
	l.append(ltemp)
	r.append(rtemp)

for i in range(q):
	ans = 0
	now = l[i]
	while now != r[i]:
		ans += abs(branch[now][0]-branch[now+d][0])+abs(branch[now][1]-branch[now+d][1])
		now = now+d
	print(ans)

Fixed submission:
h,w,d = map(int,input().split())
branch = dict()
for i in range(1,h*w+1):
	branch[i] = []
for i in range(h):
	atemp = list(map(int,input().split()))
	for k in range(w):
		branch[atemp[k]].append(i+1)
		branch[atemp[k]].append(k+1)

q = int(input())
l = []
r = []
for i in range(q):
	ltemp,rtemp = map(int,input().split())
	l.append(ltemp)
	r.append(rtemp)

calc = dict()
for i in range(d):
	calc[i+1] = []
for i in range(1,d+1):
	now = i
	calc[i].append(0)
	k = 0
	while now+d <= h*w:
		calc[i].append(calc[i][k]+abs(branch[now][0]-branch[now+d][0])+abs(branch[now][1]-branch[now+d][1]))
		now = now+d
		k += 1

for i in range(q):
	div = l[i]//d
	if l[i]%d != 0:
		sur = l[i]%d
	else:
		sur = d
	ansdiv = r[i]//d
	if sur == d:
		print(calc[sur][ansdiv-1]-calc[sur][div-1])
	else:
		print(calc[sur][ansdiv]-calc[sur][div])
Buggy python submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
if n%2 == 0
	if a == 1:
		if b == n or b == 2:
			print('Borys')
		else:
			print('Alice')
	if b == n
		print('Alice')
else:
	if a == 1:
		if b == n-1:
			print('Borys')
		else:
			print('Alice')
	elif b == n:
		if a == n-1:
			print('Alice')
		else:
			print('Borys')
	else:
		if (b-a)%2 == 1:
			print('Borys')
		else:
			print('Alice')

Fixed submission:
n,a,b = map(int,input().split())
if n%2 == 0:
	if (b-a)%2 == 1:
		print('Borys')
	else:
		print('Alice')
else:
	if (b-a)%2 == 1:
		print('Borys')
	else:
		print('Alice')
Buggy python submission (verdict: Runtime Error):
def minandmax(bottom,up,mod): #bottom< n < upなるmodで割り切れるnの値の最大値と最小値を返す
    if bottom%mod == 0:
        mnm = bottom
    else:
        mnm = bottom + (mod-bottom%mod)
        if mnm > up:
            mnm = None
    if up%mod == 0:
        mxm = up
    else:
        mxm = up - up%mod
        if mxm < bottom:
            mxm = None
    ans = [mnm,mxm]
    return ans

k = int(input())
a = list(map(int,input().split()))
i = k-1
bottom = 2
up = 2

check = True
if a[-1] != 2:
    check = False
while i >= 1 and check:
    bottom = minandmax(bottom,up+a[i]-1,a[i-1])[0]
    up = minandmax(bottom,up+a[i]-1,a[i-1])[1]
    if bottom == None and up == None:
        check = False
    elif bottom == None:
        bottom = up
    elif up == None:
        up = bottom
    i += -1

if check:
    bottom = minandmax(bottom,bottom+a[0]-1,1)[0]
    up = minandmax(up,up+a[0]-1,1)[1]
    print(bottom,up)
else:
    print("-1")

Fixed submission:
def minandmax(bottom,up,mod): #bottom< n < upなるmodで割り切れるnの値の最大値と最小値を返す
    if bottom%mod == 0:
        mnm = bottom
    else:
        mnm = bottom + (mod-bottom%mod)
        if mnm > up:
            mnm = None
    if up%mod == 0:
        mxm = up
    else:
        mxm = up - up%mod
        if mxm < bottom:
            mxm = None
    ans = [mnm,mxm]
    return ans

k = int(input())
a = list(map(int,input().split()))
i = k-1
bottom = 2
up = 2

check = True
if a[-1] != 2:
    check = False
while i >= 1 and check:
    nbottom = minandmax(bottom,up+a[i]-1,a[i-1])[0]
    nup = minandmax(bottom,up+a[i]-1,a[i-1])[1]
    if nbottom == None and nup == None:
        check = False
    elif nbottom == None:
        nbottom = nup
    elif nup == None:
        nup = nbottom
    i += -1
    bottom = nbottom
    up = nup

if check:
    bottom = minandmax(bottom,bottom+a[0]-1,1)[0]
    up = minandmax(up,up+a[0]-1,1)[1]
    print(bottom,up)
else:
    print("-1")
Buggy python submission (verdict: Runtime Error):
n,h = map(int,input().split())
a = []
b = []
for i in range(n):
	c,d = map(int,input().split())
	a.append(c)
	b.append(d)

total = 0
b.sort()
b.reverse()
counter = 0
am = max(a)
for i in b:
	if i >= am:
		total += i
		counter += 1
	else:
		break

if (h-total)%am == 0:
	print(counter+(h-total)//am)
else:
	print(counter+(h-total)//am+1)

Fixed submission:
s = input()
print(s.replace('2017','2018'))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
table = [[0 for i in range(3)] for k in range(n-1)]
for i in range(n-1):
	c,s,f = map(int,input().split())
	table[i][0] = c
	table[i][1] = s
	table[i][2] = f
for i in range(n-1):
	total = table[i][1]+table[i][0]
	for k in range(i+1,n-1):
		if total <= table[k][1]:
			total = table[k][1] + table[k][0]
		else:
			times = 1
			while (times*table[k][2] + table[k][1]) < total:
				times += 1
			total = times*table[k][2] + table[k][1] + table[k][0]
	print(total)
print('0')

Fixed submission:
n = int(input())
table = [[0 for i in range(3)] for k in range(n-1)]
for i in range(n-1):
	c,s,f = map(int,input().split())
	table[i][0] = c
	table[i][1] = s
	table[i][2] = f
for i in range(n-1):
	total = table[i][1]+table[i][0]
	for k in range(i+1,n-1):
		if total <= table[k][1]:
			total = table[k][1] + table[k][0]
		else:
			sur = total%table[k][2]
			if sur == 0:
				total = total + table[k][0]
			else:
				total = (total - sur) + table[k][2] + table[k][0]
	print(total)
print('0')

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
table = [[0 for i in range(3)] for k in range(n-1)]
for i in range(n-1):
	c,s,f = map(int,input().split())
	table[i][0] = c
	table[i][1] = s
	table[i][2] = f
sum = []
for i in range(n-1):
	total = table[i][1]+table[i][0]
	for k in range(i+1,n-1):
		if total <= table[k][1]:
			total = table[k][1] + table[k][0]
		else:
			times = 1
			while (times*table[k][2] + table[k][1]) < total:
				times += 1
			total = times*table[k][2] + table[k][1] + table[k][0]
	sum.append(total)
for i in range(n-1):
	print(sum[i])
print('0')

Fixed submission:
n = int(input())
table = [[0 for i in range(3)] for k in range(n-1)]
for i in range(n-1):
	c,s,f = map(int,input().split())
	table[i][0] = c
	table[i][1] = s
	table[i][2] = f
for i in range(n-1):
	total = table[i][1]+table[i][0]
	for k in range(i+1,n-1):
		if total <= table[k][1]:
			total = table[k][1] + table[k][0]
		else:
			sur = total%table[k][2]
			if sur == 0:
				total = total + table[k][0]
			else:
				total = (total - sur) + table[k][2] + table[k][0]
	print(total)
print('0')
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = []
l.append(2)
l.append(1)
for i in range(2,n+1):
	li = l[i-2] + l[i-1]
	l.append(li)
print(li)

Fixed submission:
n = int(input())
l = []
l.append(2)
l.append(1)
if n == 1:
	print(1)
else:
	for i in range(2,n+1):
		li = l[i-2] + l[i-1]
		l.append(li)
	print(li)
Buggy python submission (verdict: Runtime Error):
def max(a,b):
  	if a>=b:
      	return a
    else:
      	return b

n,z,w = map(int,input().split())
a = list(map(int,input().split()))
print(max(abs(a[n-1]-w),abs(a[n-1]-a[n-2]))

Fixed submission:
def max(a,b):
	if a>=b:
		return a
	else:
		return b

n,z,w = map(int,input().split())
a = list(map(int,input().split()))
print(max(abs(a[n-1]-w),abs(a[n-1]-a[n-2])))
Buggy python submission (verdict: Runtime Error):
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))
for i in range(n):
	for k in range(len(d)):
		if len(t) == 0:
			answer = 1
			break
		elif t[0] == d[k]:
			del d[k]
			del t[0]
			break
if answer == 1:
	print('YES')
else:
	print('NO')

Fixed submission:
import collections
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))
dcounter = collections.Counter(d)
tcounter = collections.Counter(t)
check = True
for i in tcounter.items():
	if dcounter[i[0]] < i[1]:
		check = False
if check:
	print('YES')
else:
	print('NO')
Buggy python submission (verdict: Runtime Error):
s = input()
if len(s) <= 3:
	print('No')
else:
	if s[0] == Y and s[1] == A and s[2] == K and s[3] == I:
		print('Yes')
	else:
		print('No')

Fixed submission:
s = input()
if len(s) <= 3:
	print('No')
else:
	if s[0] == 'Y' and s[1] == 'A' and s[2] == 'K' and s[3] == 'I':
		print('Yes')
	else:
		print('No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
K = int(input())
x = list(map(int,input().split()))
L = 0
for i in range(N):
  if K - x[i] <= x[i]:
    L = L + x[i]
  else:
    L = K -x[i]
print (2 * L)

Fixed submission:
N = int(input())
a = int(input())
print (N *N - a)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for i in range(n):
	s = int(input())
	if s in a:
		a.remove(s)
	else:
		a.append(s)
print(len(a))

Fixed submission:
n = int(input())
a = []
for i in range(n):
	s = int(input())
	a.append(s)
a.sort()
a.append(0)
length = 0
i = 0
while i < n:
	counter = 1
	count = 0
	for k in range(i+1,n+1):
		if a[i] != a[k] and counter%2 == 1:
			length += 1
			i = i+count+1
			break
		elif a[i] != a[k] and counter%2 == 0:
			i = i+count+1
			break
		elif a[i] == a[k]:
			counter += 1
			count += 1
print(length)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for i in range(n):
	s = int(input())
	if s in a:
		x = a.index(s)
		a.pop(x)
	else:
		a.append(s)
print(len(a))

Fixed submission:
n = int(input())
a = []
for i in range(n):
	s = int(input())
	a.append(s)
a.sort()
a.append(0)
length = 0
i = 0
while i < n:
	counter = 1
	count = 0
	for k in range(i+1,n+1):
		if a[i] != a[k] and counter%2 == 1:
			length += 1
			i = i+count+1
			break
		elif a[i] != a[k] and counter%2 == 0:
			i = i+count+1
			break
		elif a[i] == a[k]:
			counter += 1
			count += 1
print(length)
Buggy python submission (verdict: Runtime Error):
x,t = int(input()),int(input())
y = x - t
print('{0}'.format(y))

Fixed submission:
l = input().split()
x = int(l[0])
t = int(l[1])
y = x - t
if y > 0:
	print('{0}'.format(y))
else:
	print('0')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
count = []
b = len(a)
if b >= n:
	for i in range(0,n):
		counter = 0
		for k in range(0,n):
			if (a[i] - 1) <= a[k] <= (a[i] + 1):
				counter += 1
		count.append(counter)
else:
	for i in range(0,b-1):
		counter = 0
		for k in range(0,b-1):
			if (a[i] - 1) <= a[k] <= (a[i] + 1):
				counter += 1
		count.append(counter)
	
mx = max(count)
print('{0}'.format(mx))

Fixed submission:
import collections
n = int(input())
a = list(map(int,input().split()))
count = collections.Counter(a)
max = 0
for i in count:
    if count[i] + count[i-1] + count[i+1] > max:
        max = count[i] + count[i-1] + count[i+1]
print(max)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
count = []
for i in range(0,n):
	counter = 0
	for k in range(0,n):
		if (a[i] - 1) <= a[k] <= (a[i] + 1):
			counter += 1
	count.append(counter)
	
mx = max(count)
print('{0}'.format(mx))

Fixed submission:
import collections
n = int(input())
a = list(map(int,input().split()))
count = collections.Counter(a)
max = 0
for i in count:
    if count[i] + count[i-1] + count[i+1] > max:
        max = count[i] + count[i-1] + count[i+1]
print(max)
Buggy python submission (verdict: Runtime Error):
def euclid(a,b):
	if b == 0:
		return a
	else:
		return euclid(b,a % b)
		
n = int(input())
t = []
for i in range(n):
	x = int(input())
	t.append(x)

for i in range(0,n-1):
	t[i+1] = t[i] * t[i+1] / euclid(t[i],t[i+1])

print(int(t[n-1]))

Fixed submission:
def euclid(a,b):
	if b == 0:
		return a
	else:
		return euclid(b,a % b)
		
n = int(input())
t = []
for i in range(n):
	x = int(input())
	t.append(x)

for i in range(0,n-1):
	t[i+1] = t[i] * t[i+1] // euclid(t[i],t[i+1])

print(int(t[n-1]))
Buggy python submission (verdict: Runtime Error):
s = input()
a = len(s)
print(s[0] + (a-2) + s[-1])

Fixed submission:
s = input()
a = len(s)
print('{0}{1}{2}'.format(s[0],a-2,s[-1]))
Buggy python submission (verdict: Time Limit Exceeded):
def bfs(branch,n):
	arrival = [0 for i in range(n+1)]
	q = [1]
	arrival[q[0]] = 1
	while len(q) >= 1:
		for k in range(len(branch[q[0]])):
			if arrival[branch[q[0]][k]] == 0:
				arrival[branch[q[0]][k]] = arrival[q[0]] + 1
				q.append(branch[q[0]][k])
		q.pop(0)
	return arrival

n,m = map(int,input().split())
branch = dict()
for i in range(n):
	branch[i+1] = []
for i in range(m):
	a,b = map(int,input().split())
	branch[a].append(b)
	branch[b].append(a)

arrival = bfs(branch,n)
if arrival[n]-arrival[1] == 2:
	print('POSSIBLE')
else:
	print('IMPOSSIBLE')

Fixed submission:
n,m = map(int,input().split())
branch = dict()
for i in range(n):
	branch[i+1] = []
for i in range(m):
	a,b = map(int,input().split())
	branch[a].append(b)
	branch[b].append(a)

q = []
for i in range(len(branch[1])):
	q.append(branch[1][i])

check = False
for i in range(len(q)):
	if n in branch[q[i]]:
		check = True
		break
if check:
	print('POSSIBLE')
else:
	print('IMPOSSIBLE')

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
branch = dict()
for i in range(1,n+1):
	branch[i] = []
for i in range(m):
	a,b = map(int,input().split())
	branch[a].append(b)
	branch[b].append(a)
arrival = [0 for i in range(n+1)]
q = [1]
arrival[1] = 1
while len(q)>0:
	next = branch[q[0]]
	for i in range(len(next)):
		if arrival[next[i]] == 0:
			arrival[next[i]] = arrival[q[0]]+1
			q.append(next[i])
	q.pop(0)
if arrival[n] == 3:
	print('POSSIBLE')
else:
	print('IMPOSSIBLE')

Fixed submission:
n,m = map(int,input().split())
branch = dict()
for i in range(n):
	branch[i+1] = []
for i in range(m):
	a,b = map(int,input().split())
	branch[a].append(b)
	branch[b].append(a)

q = []
for i in range(len(branch[1])):
	q.append(branch[1][i])

check = False
for i in range(len(q)):
	if n in branch[q[i]]:
		check = True
		break
if check:
	print('POSSIBLE')
else:
	print('IMPOSSIBLE')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
x = sum(a)
difference = []
for i in range(n-1):
	x = x - a[i]
	difference.append(abs(sum(a)-2*x))
print(min(difference))

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
x = sum(a)
t = sum(a)
difference = []
for i in range(n-1):
	x = x - a[i]
	difference.append(abs(t-2*x))
print(min(difference))

Buggy python submission (verdict: Runtime Error):
def abs(n):
	if n >= 0:
		return n
	else:
		return -n
		
n = int(input())
a = list(map(int,input().split()))
x = 0
y = 0
difference = []
total = 0
if n % 2 != 0:
	n += 1

for i in range(n):
	total += a[i]
for i in range(1,n//2 +1):
	for k in range(i):
		x += a[k]
	y = total - x
	b = x - y
	difference.append(abs(b))
difference.sort()
print(difference[0])

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
x = sum(a)
t = sum(a)
difference = []
for i in range(n-1):
	x = x - a[i]
	difference.append(abs(t-2*x))
print(min(difference))
Buggy python submission (verdict: Runtime Error):
s = str(input())
n = len(s)
s = s.rstrip(s[n-1])
for i in range(n):
	a = len(s)
	if (a % 2) == 0:
		ss = s[0:a//2]
		if s.count(ss) == 2:
			print(a)
			break
		else:
			s = s.rstrip(s[a-1])
	else:
		s = s.rstrip(s[a-1])

Fixed submission:
s = input()
n = len(s)
check = True
i = 2
while check:
    if s[0:(n-i)//2] == s[(n-i)//2:(n-i)]:
        check = False
    else:
        i += 2
print(n-i)

Buggy python submission (verdict: Runtime Error):
s = str(input())
n = len(s)
s = s.rstrip(s[n-1])
for i in range(n):
	a = len(s)
	if (a % 2) == 0:
		ss = s[0:a//2]
		print(s.count(ss))
		if s.count(ss) == 2:
			print(a)
			break
		else:
			s = s.rstrip(s[a-1])
	else:
		s = s.rstrip(s[a-1])

Fixed submission:
s = input()
n = len(s)
check = True
i = 2
while check:
    if s[0:(n-i)//2] == s[(n-i)//2:(n-i)]:
        check = False
    else:
        i += 2
print(n-i)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
b = []
for i in range(n):
	b.append(a[i])
	b.reverse()
for i in range(n-1):
	print(b[i] ,end=" ")
print(b[n-1])

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a.insert(0,0)
b = []
if n%2==0:
	i=n
	while i>=2:
		b.append(a[i])
		i += -2
	k=1
	while k<=n-1:
		b.append(a[k])
		k += 2
else:
	i=n
	while i>=1:
		b.append(a[i])
		i += -2
	k=2
	while k<=n-1:
		b.append(a[k])
		k+=2
for i in range(n-1):
	print(b[i],end=' ')
print(b[n-1])