Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from math import gcd
a, b = map(int, input().split())

gcd = gcd(a, b)
ans = 1
for i in range(2, gcd//2 + 1):
    if gcd%i == 0:
        ans += 1
        while gcd%i == 0:
            gcd //= i
    if gcd < i:
        break
if ans == 1 and gcd != 1:
    ans = 2
print(ans)

Fixed submission:
from math import gcd
a, b = map(int, input().split())

gcd = gcd(a, b)
ans = 1
n = int(gcd**0.5) + 2
for i in range(2, n):
    if gcd%i == 0:
        ans += 1
        while gcd%i == 0:
            gcd //= i
    if gcd < i:
        break
if gcd >= n:
    ans += 1
if ans == 1 and gcd != 1:
    ans = 2
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from math import gcd
a, b = map(int, input().split())

gcd = gcd(a, b)
ans = 1
for i in range(2, gcd):
    if gcd%i == 0:
        ans += 1
        while gcd%i == 0:
            gcd //= i
    if gcd < i:
        break
if ans == 1 and gcd != 1:
    ans = 2
print(ans)

Fixed submission:
from math import gcd
a, b = map(int, input().split())

gcd = gcd(a, b)
ans = 1
n = int(gcd**0.5) + 2
for i in range(2, n):
    if gcd%i == 0:
        ans += 1
        while gcd%i == 0:
            gcd //= i
    if gcd < i:
        break
if gcd >= n:
    ans += 1
if ans == 1 and gcd != 1:
    ans = 2
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from math import gcd
a, b = map(int, input().split())

gcd = gcd(a, b)
ans = 1
for i in range(2, gcd + 1):
    if gcd%i == 0:
        ans += 1
        while gcd%i == 0:
            gcd //= i
    if gcd < i:
        break

print(ans)

Fixed submission:
from math import gcd
a, b = map(int, input().split())

gcd = gcd(a, b)
ans = 1
n = int(gcd**0.5) + 2
for i in range(2, n):
    if gcd%i == 0:
        ans += 1
        while gcd%i == 0:
            gcd //= i
    if gcd < i:
        break
if gcd >= n:
    ans += 1
if ans == 1 and gcd != 1:
    ans = 2
    
print(ans)

Buggy python submission (verdict: Runtime Error):
from math import gcd
a, b = map(int, input().split())

def get_prime(n):
    num = [True]*(n + 1)
    for i in range(2, int(n**0.5) + 1):
        if num[i]:
            for j in range(i*2, n + 1, i):
                num[j] = False
    ans = [i for i in range(1, n + 1) if num[i]]
    return ans

gcd = gcd(a, b)
p = get_prime(gcd)
ans = 0
for i in p:
    if gcd%i == 0:
        ans += 1
print(ans)

Fixed submission:
from math import gcd
a, b = map(int, input().split())

gcd = gcd(a, b)
ans = 1
n = int(gcd**0.5) + 2
for i in range(2, n):
    if gcd%i == 0:
        ans += 1
        while gcd%i == 0:
            gcd //= i
    if gcd < i:
        break
if gcd >= n:
    ans += 1
if ans == 1 and gcd != 1:
    ans = 2
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

for i in range(m):
    a.append(a[-1]/2)
    del a[-2]
    a.sort()

ans = 0
for i in range(n):
    ans += int(a[i])
print(ans)

Fixed submission:
from heapq import heapify, heappop, heappush
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [-i for i in a]
heapify(a)

for i in range(m):
    x = heappop(a)
    heappush(a, int(x/2))

ans = 0
for i in range(n):
    ans += -a[i]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

for i in range(m):
    a.append(a[-1]/2)
    del a[-2]
    a.sort()

ans = 0
for i in range(n):
    ans += int(a[i])
print(ans)

Fixed submission:
from heapq import heapify, heappop, heappush
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [-i for i in a]
heapify(a)

for i in range(m):
    x = heappop(a)
    heappush(a, int(x/2))

ans = 0
for i in range(n):
    ans += -a[i]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse = True)

for i in range(m):
    a.append(a[0]/2)
    del a[0]
    a.sort(reverse = True)
    
ans = 0
for i in range(n):
    ans += int(a[i])
print(ans)

Fixed submission:
from heapq import heapify, heappop, heappush
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [-i for i in a]
heapify(a)

for i in range(m):
    x = heappop(a)
    heappush(a, int(x/2))

ans = 0
for i in range(n):
    ans += -a[i]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0
for i in range(n):
    ans += i

print(ans)

Fixed submission:
n = int(input())
ans = 0
for i in range(n):
    ans += i

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
sl = []
for i in range(n):
    s = list(input())
    s.sort()
    sl.append(s)
sl.sort()
ans = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        if sl[i] == sl[j]:
            ans += 1
        else:
            break
print(ans)

Fixed submission:
from collections import Counter
n = int(input())
sl = []
for i in range(n):
    s = list(input())
    s.sort()
    sl.append("".join(s))
d = Counter(sl)

def cul(n):
    return n*(n - 1)//2

ans = 0
val = d.values()
for i in val:
    if i > 1:
        ans += cul(i)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
sl = []
for i in range(n):
    s = list(input())
    s.sort()
    sl.append(s)

ans = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        if sl[i] == sl[j]:
            ans += 1
print(ans)

Fixed submission:
from collections import Counter
n = int(input())
sl = []
for i in range(n):
    s = list(input())
    s.sort()
    sl.append("".join(s))
d = Counter(sl)

def cul(n):
    return n*(n - 1)//2

ans = 0
val = d.values()
for i in val:
    if i > 1:
        ans += cul(i)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
sl = []
for i in range(n):
    d = Counter(list(input()))
    sl.append(d)

ans = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        jud = True
        for k in list(sl[i].keys()):
            if sl[j][k] != sl[i][k]:
                jud = False
                break
        if jud:
            ans += 1
print(ans)

Fixed submission:
from collections import Counter
n = int(input())
sl = []
for i in range(n):
    s = list(input())
    s.sort()
    sl.append("".join(s))
d = Counter(sl)

def cul(n):
    return n*(n - 1)//2

ans = 0
val = d.values()
for i in val:
    if i > 1:
        ans += cul(i)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
ans = [0]*len(s)
for i in range(len(s)):
    cnt = 0
    if s[i] == "R":
        while s[i + cnt] == "R":
            cnt += 1
        if cnt%2 == 0:
            ans[i + cnt] += 1
        else:
            ans[i + cnt - 1] += 1
    else:
        while s[i - cnt] == "L":
            cnt += 1
        if cnt%2 == 0:
            ans[i - cnt] += 1
        else:
            ans[i - cnt + 1] += 1

an = [str(i) for i in ans]
print(" ".join(an))


Fixed submission:
s = list(input())
ans = [0]*len(s)

i = 0
while i != len(s):
    cnt1 = 0
    cnt2 = 0
    while s[i + cnt1] == "R":
        cnt1 += 1
    ans[i + cnt1] += cnt1//2
    ans[i + cnt1 - 1] += cnt1//2 + cnt1%2
    while s[i + cnt1 + cnt2] == "L":
        cnt2 += 1
        if i + cnt1 + cnt2 == len(s):
            break
    ans[i + cnt1] += cnt2//2 + cnt2%2
    ans[i + cnt1 - 1] += cnt2//2
    i += cnt1 + cnt2

an = [str(i) for i in ans]
print(" ".join(an))

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
for i in range(len(s)):
    if s[i] == "R":
        s[i] = 1
    else:
        s[i] = -1

ans = [0]*len(s)
for i in range(len(s)):
    now = i
    for _ in range(1000):
        now += s[now]
    ans[now] += 1 

an = [str(i) for i in ans]
print(" ".join(an))

Fixed submission:
s = list(input())
ans = [0]*len(s)

i = 0
while i != len(s):
    cnt1 = 0
    cnt2 = 0
    while s[i + cnt1] == "R":
        cnt1 += 1
    ans[i + cnt1] += cnt1//2
    ans[i + cnt1 - 1] += cnt1//2 + cnt1%2
    while s[i + cnt1 + cnt2] == "L":
        cnt2 += 1
        if i + cnt1 + cnt2 == len(s):
            break
    ans[i + cnt1] += cnt2//2 + cnt2%2
    ans[i + cnt1 - 1] += cnt2//2
    i += cnt1 + cnt2

an = [str(i) for i in ans]
print(" ".join(an))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
d = {}
key = []
s = 0
for i in range(n):
    a, b = map(int, input().split())
    if b not in key:
        key.append(b)
        d.update({b:a})
    else:
        d[b] += a
    s += a
key.sort(reverse = True)
ans = True
for k in key:
    if k < s:
        ans = False
        break
    s -= d[k]
if ans:
    print("Yes")
else:
    print("No")

Fixed submission:
n = int(input())
d = {}
s = 0
for i in range(n):
    a, b = map(int, input().split())
    if b not in d:
        d.update({b:a})
    else:
        d[b] += a
    s += a
key = list(d.keys())
key.sort(reverse = True)
ans = True
for k in key:
    if k < s:
        ans = False
        break
    s -= d[k]
if ans:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n, m = map(int, input().split())
l = []
a0 = 0
for i in range(m):
    a = int(input())
    if a - a0 == 0:
        print(0)
        exit()
    l.append(a - a0 - 1)
    a0 = a + 1
l.append(n - a0)
d = Counter(l)
key = list(d.keys())

def cmb(n, r):
    if r > n//2:
        r = n - r
    val = 1
    for i in range(r):
        val *= n - i
        val //= i + 1
    return val

ans = 1
for k in key:
    val = 0
    for i in range(k//2 + 1):
        val += cmb(k - i, i)
    ans *= val**d[k]
    ans %= 10**9 + 7
print(ans)

Fixed submission:
from collections import Counter
n, m = map(int, input().split())
l = []
a0 = 0
for i in range(m):
    a = int(input())
    if a - a0 == 0:
        print(0)
        exit()
    l.append(a - a0 - 1)
    a0 = a + 1
l.append(n - a0)
d = Counter(l)
key = list(d.keys())

ma = max(key)
fib = [1]*(ma + 1)
for i in range(2, ma + 1):
    fib[i] = fib[i - 2] + fib[i - 1]

ans = 1
for k in key:
    ans *= fib[k]**d[k]
    ans %= 10**9 + 7

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n, m = map(int, input().split())
l = []
a0 = 0
for i in range(m):
    a = int(input())
    if a - a0 == 0:
        print(0)
        exit()
    l.append(a - a0 - 1)
    a0 = a + 1
l.append(n - a0)
d = Counter(l)
key = list(d.keys())

def cmb(n, r):
    if r > n//2:
        r = n - r
    val = 1
    for i in range(r):
        val *= n - i
        val //= i + 1
    return val

ans = 1
for k in key:
    val = 0
    for i in range(k//2 + 1):
        val += cmb(k - i, i)
        val %= 10**9 + 7
    ans *= val**d[k]
    ans %= 10**9 + 7
print(ans)

Fixed submission:
from collections import Counter
n, m = map(int, input().split())
l = []
a0 = 0
for i in range(m):
    a = int(input())
    if a - a0 == 0:
        print(0)
        exit()
    l.append(a - a0 - 1)
    a0 = a + 1
l.append(n - a0)
d = Counter(l)
key = list(d.keys())

ma = max(key)
fib = [1]*(ma + 1)
for i in range(2, ma + 1):
    fib[i] = fib[i - 2] + fib[i - 1]

ans = 1
for k in key:
    ans *= fib[k]**d[k]
    ans %= 10**9 + 7

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())

ans = 0
for r in range(N//R + 1):
    for g in range((N - r*R)//G + 1):
        for b in range((N - r*R - g*G)//B + 1):
            if r*R + g*G + b*B == N:
                ans += 1
print(ans)

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

ans = 0
for r in range(N//R + 1):
    for g in range((N - r*R)//G + 1):
        if (N - r*R - g*G)%B == 0:
                ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())

ans = [0]*9000000
for r in range(N//R + 1):
    for g in range(N//G + 1):
        for b in range(N//B + 1):
            k = r*R + g*G + b*B
            ans[k] += 1

print(ans[N])

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

ans = 0
for r in range(N//R + 1):
    for g in range((N - r*R)//G + 1):
        if (N - r*R - g*G)%B == 0:
                ans += 1
print(ans)

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

ans = [0]*(N//R + 1)*(N//G + 1)*(N//B + 1)
for r in range(N//R + 1):
    for g in range(N//G + 1):
        for b in range(N//B + 1):
            k = r*R + g*G + b*B
            ans[k] += 1
print(ans)
print(ans[N])

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

ans = 0
for r in range(N//R + 1):
    for g in range((N - r*R)//G + 1):
        if (N - r*R - g*G)%B == 0:
                ans += 1
print(ans)

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

ans = [0]*(N//R + 1)*(N//G + 1)*(N//B + 1)
for r in range(N//R + 1):
    for g in range(N//G + 1):
        for b in range(N//B + 1):
            n = r*R + g*G + b*B
            ans[n] += 1
print(ans[n])

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

ans = 0
for r in range(N//R + 1):
    for g in range((N - r*R)//G + 1):
        if (N - r*R - g*G)%B == 0:
                ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())

ans = 0
for r in range(N//R + 1):
    for g in range(N//G + 1):
        for b in range(N//B + 1):
            if r*R + g*G + b*B == N:
                ans += 1 
print(ans)

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

ans = 0
for r in range(N//R + 1):
    for g in range((N - r*R)//G + 1):
        if (N - r*R - g*G)%B == 0:
                ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
from math import gcd
n, m = map(int, input().split())
s = list(input())
t = list(input())

ans = n*m//gcd(n, m)
sp_a, sp_b = ans//n, ans//m
l = [False]*(ans + 1)
jud = True
for i in range(n):
    l[i*sp_a] = s[i]

for i in range(m):
    if not l[i*sp_b]:
        l[i*sp_b] = t[i]
    else:
        if l[i*sp_b] != t[i]:
            jud = False
            break
if jud:
    print(ans)
else:
    print(-1)

Fixed submission:
from math import gcd
n, m = map(int, input().split())
s = list(input())
t = list(input())
g = gcd(n, m)
ans = n*m//g
sp_a, sp_b = m//g, n//g
jud = True
for i in range(ans//sp_a):
    if i*sp_a % sp_b == 0:
        if s[i % n] != t[i*sp_a//sp_b]:
            jud = False

if jud:
    print(ans)
else:
    print(-1)

Buggy python submission (verdict: Runtime Error):
from math import gcd
n, m = map(int, input().split())
s = list(input())
t = list(input())

ans = n*m//gcd(n, m)
sp_a, sp_b = ans//n, ans//m
l = [False]*ans
jud = True
for i in range(n):
    l[i*sp_a] = s[i]

for i in range(m):
    if not l[i*sp_b]:
        l[i*sp_b] = t[i]
    else:
        if l[i*sp_b] != t[i]:
            jud = False
            break
if jud:
    print(ans)
else:
    print(-1)

Fixed submission:
from math import gcd
n, m = map(int, input().split())
s = list(input())
t = list(input())
g = gcd(n, m)
ans = n*m//g
sp_a, sp_b = m//g, n//g
jud = True
for i in range(ans//sp_a):
    if i*sp_a % sp_b == 0:
        if s[i % n] != t[i*sp_a//sp_b]:
            jud = False

if jud:
    print(ans)
else:
    print(-1)

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
s = list(input())
t = list(input())

def gcd(a, b):
    while b != 0:
        c = a%b
        a = b
        b = c
    return a

ans = n*m//gcd(n, m)
sp_a, sp_b = ans//n, ans//m
l = [False]*ans
jud = True
for i in range(n):
    l[i*sp_a] = s[i]

for i in range(m):
    if not l[i*sp_b]:
        l[i*sp_b] = t[i]
    else:
        if l[i*sp_b] != t[i]:
            jud = False
            break
if jud:
    print(ans)
else:
    print(-1)

Fixed submission:
from math import gcd
n, m = map(int, input().split())
s = list(input())
t = list(input())
g = gcd(n, m)
ans = n*m//g
sp_a, sp_b = m//g, n//g
jud = True
for i in range(ans//sp_a):
    if i*sp_a % sp_b == 0:
        if s[i % n] != t[i*sp_a//sp_b]:
            jud = False

if jud:
    print(ans)
else:
    print(-1)
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
l = []
for h in range(H):
    l.append(input())

for h in range(H):
    for w in range(W):
        if l[h][w] == "#":
            j = False
            if h != 0:
                if l[h - 1][w] == "#":
                    j = True
            if h != H - 1:
                if l[h + 1][w] == "#":
                    j = True
            if w != 0:
                if l[h][w - 1] == "#":
                    j = True
            if w != W - 1:
                if l[h][w + 1] == "#":
                    j = True
            if not j:
                break
if j:
    print("Yes")
else:
    print("No")


Fixed submission:
H, W = map(int, input().split())
l = []
for h in range(H):
    l.append(input())

j = True
for h in range(H):
    if not j:
        break
    for w in range(W):
        if l[h][w] == "#":
            j = False
            if h != 0:
                if l[h - 1][w] == "#":
                    j = True
            if h != H - 1:
                if l[h + 1][w] == "#":
                    j = True
            if w != 0:
                if l[h][w - 1] == "#":
                    j = True
            if w != W - 1:
                if l[h][w + 1] == "#":
                    j = True
            if not j:
                break
if j:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
s = list(input())
l = [chr(i) for i in range(ord("a"), ord("z") + 1)]
if len(s) == 26:
    if s == reversed(l):
        print(-1)
        exit()
    else:
        fi = False
        for i in range(26)[-2::-1]:
            if fi:
                break
            for j in range(25, i, -1):
                if s[i] < s[j]:
                    s[i] = s[j]
                    s = s[:i+1]
                    fi = True
                    break
for i in range(26)[-1::-1]:
    if l[i] in s:
        del l[i]
s.append(l[0])
print("".join(s))

Fixed submission:
s = list(input())
l = [chr(i) for i in range(ord("a"), ord("z") + 1)]
if len(s) == 26:
    if s == l[-1::-1]:
        print(-1)
        exit()
    else:
        for i in range(26)[-2::-1]:
            for j in range(25, i, -1):
                if s[i] < s[j]:
                    s[i] = s[j]
                    print("".join(s[:i+1]))
                    exit()
for i in range(26)[-1::-1]:
    if l[i] in s:
        del l[i]
s.append(l[0])
print("".join(s))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
d = {}
l = []

for i in range(n):
    a = int(input())
    if a not in l:
        l.append(a)
        d.update({a:1})
    else:
        if d[a] == 0:
            d[a] = 1
        else:
            d[a] = 0

ans = len(l)
for i in range(len(l)):
    if d[l[i]] == 0:
        ans -= 1
print(ans)

Fixed submission:
n = int(input())
A = []

for i in range(n):
    a = int(input())
    A.append(a)
A.sort()
i = 0
ans = 0
while True:
    cnt = 0
    while A[i + cnt] == A[i]:
        cnt += 1
        if i + cnt == n:
            break
    if cnt%2 == 1:
        ans += 1
    i += cnt
    if i == n:
        break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
A = []
l = []

for i in range(n):
    a = int(input())
    A.append(a)
    if a not in l:
        l.append(a)

d = Counter(A)
ans = len(l)
for i in range(len(l)):
    if d[l[i]]%2 == 0:
        ans -= 1
print(ans)

Fixed submission:
n = int(input())
A = []

for i in range(n):
    a = int(input())
    A.append(a)
A.sort()
i = 0
ans = 0
while True:
    cnt = 0
    while A[i + cnt] == A[i]:
        cnt += 1
        if i + cnt == n:
            break
    if cnt%2 == 1:
        ans += 1
    i += cnt
    if i == n:
        break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
A = []
l = []

for i in range(n):
    a = int(input())
    A.append(a)
    if a not in l:
        l.append(a)

d = Counter(A)
ans = len(l)
for i in range(len(l)):
    if d[l[i]]%2 == 0:
        ans -= 1
print(ans)

Fixed submission:
n = int(input())
A = []

for i in range(n):
    a = int(input())
    A.append(a)
A.sort()
i = 0
ans = 0
while True:
    cnt = 0
    while A[i + cnt] == A[i]:
        cnt += 1
        if i + cnt == n:
            break
    if cnt%2 == 1:
        ans += 1
    i += cnt
    if i == n:
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
l1 = []
l2 = []
l3 = []
l4 = []
for i in A:
    if i in l1:
        if i in l2:
            if i in l3:
                if i not in l4:
                    l4.append(i)
            else:
                l3.append(i)
        else:
            l2.append(i)
    else:
        l1.append(i)
for i in l4:
    l2.append(i)
if len(l2) < 2:
    print(0)
else:
    l2.sort()
    print(l2[-1]*l2[-2])

Fixed submission:
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
d = Counter(A)
key = d.keys()
ans = []
for k in key:
    if d[k] >= 2:
        ans.append(k)
        if d[k] >= 4:
            ans.append(k)
if len(ans) < 2:
    print(0)
else:
    ans.sort()
    print(ans[-1]*ans[-2])

Buggy python submission (verdict: Runtime Error):
W, H, x, y = map(int, input().split())
v = x/W
h = y/H
if v and h == 0.5 :
    print(W*H/2, 1)
else:
    print(W*H/2, 0)

Fixed submission:
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
d = Counter(A)
key = d.keys()
ans = []
for k in key:
    if d[k] >= 2:
        ans.append(k)
        if d[k] >= 4:
            ans.append(k)
if len(ans) < 2:
    print(0)
else:
    ans.sort()
    print(ans[-1]*ans[-2])
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
l1 = []
ln = []
for _ in range(m):
    a, b = map(int, input().split())
    if a == 1:
        l1.append(b)
    elif b == 1:
        l1.append(a)
    elif a == n:
        ln.append(b)
    elif b == n:
        ln.append(a)
l1.sort()
ln.sort()
ans = False
for i in l1:
    for j in ln:
        if i == j:
            ans = True
            break
        if i < j:
            break
    if ans:
        break
if ans:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Fixed submission:
n, m = map(int, input().split())
l1 = []
ln = []
for _ in range(m):
    a, b = map(int, input().split())
    if a == 1:
        l1.append(b)
    elif b == 1:
        l1.append(a)
    elif a == n:
        ln.append(b)
    elif b == n:
        ln.append(a)
l1.sort()
ln.sort()
ans = False
for i in l1:
    low = 0
    high = len(ln) - 1
    while low <= high:
        mid = (low + high)//2
        if ln[mid] == i:
            ans = True
            break
        elif ln[mid] > i:
            high = mid - 1
        else:
            low = mid + 1
    if ans:
        break
if ans:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
l1 = []
ln = []
for _ in range(m):
    a, b = map(int, input().split())
    if a == 1:
        l1.append(b)
    elif b == 1:
        l1.append(a)
    elif a == n:
        ln.append(b)
    elif b == n:
        ln.append(a)

ans = False
for i in l1:
    if i in ln:
        ans = True
        break
if ans:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Fixed submission:
n, m = map(int, input().split())
l1 = []
ln = []
for _ in range(m):
    a, b = map(int, input().split())
    if a == 1:
        l1.append(b)
    elif b == 1:
        l1.append(a)
    elif a == n:
        ln.append(b)
    elif b == n:
        ln.append(a)
l1.sort()
ln.sort()
ans = False
for i in l1:
    low = 0
    high = len(ln) - 1
    while low <= high:
        mid = (low + high)//2
        if ln[mid] == i:
            ans = True
            break
        elif ln[mid] > i:
            high = mid - 1
        else:
            low = mid + 1
    if ans:
        break
if ans:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")