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

Fixed submission:
N, Q = map(int, input().split())
S = input()

dp = [0] * (N + 1)
for i in range(N):
    if S[i : i + 2] == 'AC':
        dp[i + 1] += 1
        
for i in range(1, N + 1):
    dp[i] += dp[i - 1]
    
for i in range(Q):
    l, r = map(int, input().split())
    print(dp[r - 1] - dp[l - 1])

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

A = []
for i in range(Q):
    l, r = map(int, input().split())
    A.append(S[l - 1 : r])
    
for a in A:
    print(a.count('AC'))
Problem p03096 (python)

Fixed submission:
from collections import defaultdict
 
mod = 10 ** 9 + 7
n = int(input())
C = [int(input()) for i in range(n)]
 
for i in range(n - 1, 0, -1):
    if C[i] == C[i - 1]:
        del C[i]
        #重複部分を圧縮したCを作成
        
D = defaultdict(int)
ans = 1
for c in C:
    ans += D[c]
    D[c] = ans
    #print(D, ans)

print(ans % mod)

Buggy submission (verdict: Runtime Error):
from collections import Counter
mod = 10 ** 9 + 7
n = int(input())
C = [int(input()) for i in range(n)]

for i in range(n - 1, 0, -1):
    if C[i] == C[i - 1]:
        del C[i]

D = [0] * n
for i in range(2, n):
    D[i] = D[i - 1] + i - 1
        
ans = 1
for i in Counter(C).values():
    ans += D[i]
    
print(ans % mod)
Problem p03138 (python)

Fixed submission:
N, K = map(int, input().split())
Ai = list(map(int, input().split()))
 
D = 40
Bi = []
for a in Ai:
    b = bin(a)[2:]
    b = ("0" * (D - len(b))) + b
    Bi.append(b)
 
result = ""
for i in range(D):
    count = 0 # 1の個数
    for i, b in enumerate(Bi):
        if b[0] == '1':
            count += 1
        Bi[i] = b[1:]
    if count >= N / 2:
        result += "0"
    else:
        result += "1"
    #count = count // 2
x = 0
for i in range(D):
    if result[0] == '1':
        a = pow(2, D - i - 1)
        if x + a <= K:
            x += a
    result = result[1:]
 
ans = 0
for a in Ai:
    ans += (a ^ x)
print(ans)

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

tmp = 0
for i in range(n):
    tmp += int(bin(A[i])[2:])
    
cand = ''
for i in str(tmp):
    if int(i) >= n / 2:
        cand += '0'
    else:
        cand += '1'
        
if int(cand, 2) > k:
    cand = str(k)
else:
    while True:
        cand = '1' + cand
        if int(cand, 2) <= k:
            pass
        else:
            cand = cand[1:]
            break
    
ans = 0
for i in range(n):
    ans += int(cand, 2) ^ A[i]
    
print(ans)
Problem p03161 (python)

Fixed submission:
import numpy as np

n, k = map(int, input().split())
H = np.array(list(map(int, input().split())))
dp = np.zeros(n, dtype = int)

for i in range(1, n):
    s = max(i - k, 0)
    dp[i] = min(dp[s : i] + abs(H[i] - H[s : i]))
    
print(dp[-1])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
INF = float('inf')
dp = [INF] * n

dp[0] = 0
for i in range(1, N):
    for k in range(1, K + 1):
        start = max(i - k, 0)
        dp[i] = min(dp[i], dp[start] + abs(A[i] - A[start]))
    
print(dp[-1])

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

inf = float('inf')
dp = [inf] * N
dp[0] = 0

for i in range(1, N):
    for k in range(1, K + 1):
        dp[i] = min(dp[i], dp[i - k] + abs(H[i] - H[i - k]))
    
print(dp[-1])
Problem p03166 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 8)

N, M = map(int, input().split())
        
G = [[] for i in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    G[a - 1].append(b - 1)
    
dp = [-1] * (N)

def dfs(v):
    if dp[v] != -1:
        return dp[v]
    
    res = 0
    for g in G[v]:
        res = max(res, dfs(g) + 1)
        
    dp[v] = res
    return res

ans = 0
for i in range(N):
    ans = max(ans, dfs(i))
        
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
        
G = [[] for i in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    G[a - 1].append(b - 1)
    
dp = [-1] * (N)

def dfs(v):
    if dp[v] != -1:
        return dp[v]
    
    res = 0
    for g in G[v]:
        res = max(res, dfs(g) + 1)
        
    dp[v] = res
    return res

ans = 0
for i in range(N):
    ans = max(ans, dfs(i))
        
print(ans)
Problem p03219 (python)

Fixed submission:
a, b = map(int, input().split())
print(int(a + b/2))

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())/2
print(a+b)
Problem p03231 (python)

Fixed submission:
def gcd(x, y):
    while y != 0:
        x, y = y, x%y
    return x

def lcm(x, y):
    return (x * y) // gcd(x, y)

n, m = map(int, input().split())
S = input()
T = input()

l = lcm(n, m)
        
if S[::n // gcd(n, m)] == T[::m // gcd(n, m)]:
    print(l)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
S = input()
T = input()

def gcd(x, y):
    while y > 0:
        x, y = y, x%y
    return x

def lcm(x, y):
    return (x * y) // gcd(x, y)

l = lcm(n, m)
memoS = [0] * (l + 1)
memoT = [0] * (l + 1)

numS = [1]
numT = [1]

for i in range(1, n):
    num = i * l // n + 1
    numS.append(num)

for i in range(1, m):
    num = i * l // m + 1
    numT.append(num)
    
dictS = {}
dictT = {}

for i in range(n):
    dictS[numS[i]] = S[i]
    memoS[numS[i]] = 3

for i in range(m):
    dictT[numT[i]] = T[i]
    memoT[numT[i]] = 1

ans = l
for i in range(l):
    if memoS[i] - memoT[i] == 2:
        if dictS[i] != dictT[i]:
            ans = -1
            break
                
print(ans)
Problem p03241 (python)

Fixed submission:
n, m = map(int, input().split())
a = m // n
ans = 0

for i in range(1, a + 1):
    if m % i == 0:
        ans = i
        
        if (m // i) > i and (m // i) <= a:
            ans = m // i
            break
        
print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = m // n

for i in range(2, a + 1):
    if m % i == 0:
        ans = i
        
print(ans)
Problem p03262 (python)

Fixed submission:
from fractions import gcd
from functools import reduce
n,x = map(int,input().split())
 
l=list(map(int,input().split()))
l=list(map(lambda i: abs(i-x),l))
 
x = reduce(gcd,l)
print(x)

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
x_list = list(map(int, input().split()))

x_abs = []
for i in x_list:
    x_abs.append(abs(X - i))

def gcd(i, j):
    if i % j == 0:
        return j
    else:
        k = i % j
        gcd(j, k)

x_abs.sort(reverse=True)
ans = 0
if len(x_abs) == 1:
    ans = x_abs[0]
else:
    for i in range(N-2):
        temp = gcd(x_abs[i], x_abs[i + 1])
        ans = gcd(temp, x_abs[i + 2])
    
print(ans)

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

N, X = map(int,input().split()) 
nums=list(map(int,input().split()))
nums=list(map(lambda i: abs(i - X),nums))
 
D = reduce(gcd, nums)
print(D)

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

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

N, X = map(int, input().split())
nums = list(map(int, input().split()))
nums.append(X)
nums.sort()
dists = []

for i in range(N):
    dist = nums[i + 1] - nums[i]
    dists.append(dist)
    
D = gcd(*dists)

print(D)

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

N, X = map(int, input().split())
nums = list(map(int, input().split()))
nums = list(map(lambda i: abs(i - X), nums))

D = reduce(gcd, nums)
print(D)

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

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

N, X = map(int, input().split())
nums = list(map(int, input().split()))
nums.append(X)
nums.sort()
dists = []

for i in range(N):
    dist = nums[i + 1] - nums[i]
    dists.append(dist)
    
D = gcd(*dists)

print(D)
Problem p03263 (python)

Fixed submission:
h,w = map(int,input().split())
coin = [list(map(int,input().split())) for i in range(h)]
ans = []
c = 0
for i in range(h):
  for j in range(w-1):
    if coin[i][j] % 2:
      coin[i][j+1] += 1
      ans.append([i+1,j+1,i+1,j+2])
      c += 1
 
for k in range(h-1):
  if coin[k][w-1] % 2:
    coin[k+1][w-1] += 1
    ans.append([k+1,w,k+2,w])
    c += 1
    
print(c)
for i in range(c):
  print(ans[i][0],ans[i][1],ans[i][2],ans[i][3])

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
A = [[int(i) for i in input().split()] for i in range(h)]
count = 0
B = []

for i in range(h):
    for j in range(w):
        if A[i][j] % 2 == 1:
            count += 1
            A[i][j+1] += 1
            B.append([i+1, j+1, i+1, j+2])

for i in range(h-1):
    if A[i][w-1] % 2 == 1:
        count += 1
        A[i+1][w-1] += 1
        B.append([i+1, w, i+2, w])
        
print(count)
for i in range(count):
    print(B[i][0], B[i][1], B[i][2], B[i][3])
Problem p03328 (python)

Fixed submission:
a, b = map(int, input().split())
n = b - a

ans = 0
for i in range(1, n + 1):
    ans += i
    
print(ans - b)

Buggy submission (verdict: Runtime Error):
def f(x):
    if x == 1:
        return 1
    return x + f(x - 1)

a, b = map(int, input().split())
x = b - a
ans = f(x) - b

print(ans)

Buggy submission (verdict: Runtime Error):
def f(x):
    if x == 0:
        return 0
    return x + f(x - 1)

a, b = map(int, input().split())
x = b - a
ans = f(x) - b

print(ans)
Problem p03354 (python)

Fixed submission:
N, M = map(int, input().split())
P = [int(i) for i in input().split()]

class UnionFind:
    def __init__(self, n):
        self.n = n
        self.par = [-1 for _ in range(n)]
        
    def same(self, x, y):
        return self.root(x)==self.root(y)
 
    def root(self, x):
        if self.par[x]<0:
            return x
        self.par[x] = self.root(self.par[x])
        return self.par[x]
 
    def unite(self,x,y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
 
        if self.par[x] > self.par[y]:
            x,y = y,x
 
        self.par[x] += self.par[y]
        self.par[y] = x
        
uf = UnionFind(N)

for i in range(M):
    x, y = map(int, input().split())
    uf.unite(x - 1, y - 1)
    
cnt = 0
for i in range(N):
    if uf.same(i, P[i] - 1):
        cnt += 1
        #print(i, P[i])
        
print(cnt)

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

class UnionFind:
    def __init__(self, n):
        self.n = n
        self.par = [-1 for _ in range(n)]
        
    def same(self, x, y):
        return self.root(x)==self.root(y)
 
    def unite(self,x,y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
 
        if self.par[x] > self.par[y]:
            x,y = y,x
 
        self.par[x] += self.par[y]
        self.par[y] = x
        
uf = UnionFind(N)

for i in range(M):
    x, y = map(int, input().split())
    uf.unite(x - 1, y - 1)
    
cnt = 0
for i in range(N):
    if uf.same(i, P[i] - 1):
        cnt += 1
        #print(i, P[i])
        
print(cnt)
Problem p03386 (python)

Fixed submission:
a, b, k = map(int, input().split())

if b - a < 2 * k:
    for i in range(a, b + 1):
        print(i)

else:
    ans = []
    for i in range(k):
        ans.append(a + i)
    for i in range(k-1, -1, -1):
        ans.append(b - i)

    for i in ans:
        print(i)

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
r = list(range(a, b + 1))
for i in sorted(set(r[:k]) | set(r[- k:])):
    print(i)
Problem p03393 (python)

Fixed submission:
S = input()
 
chars = "abcdefghijklmnopqrstuvwxyz"
char_set = set(chars)
 
if len(S) == 26:
    for i in range(len(S)-1, -1, -1):
        x = chars.index(S[i])
        y = sorted(set(chars[x+1:])-set(S[:i]))
        # print(i, y)
        if len(y):
            print(S[:i]+y[0])
            exit()
else:
    t = sorted(set(chars)-set(S))[0]
    print(S+t)
    exit()
print(-1)

Buggy submission (verdict: Runtime Error):
M = 'abcdefghijklmnopqrstuvwxyz'
S = input()

if len(S) != 26:
    print(S + sorted(list(set(M) - set(S)))[0])
else:
    if S == 'zyxwvutsrqponmlkjihgfedcba':
        print(-1)
    else:
        for i in range(26):
            if S[i] != M[i]:
                if S[i] == 'z':
                    ans = S[: i - 1] + M[i]
                    break
                else:
                    ans = S[: i] +str(list(M)[list(M).index(S[i]) + 1])
                    break
        print(ans)

Buggy submission (verdict: Runtime Error):
M = 'abcdefghijklmnopqrstuvwxyz'
S = input()

if len(S) != 26:
    print(S + sorted(list(set(M) - set(S)))[0])
else:
    if S == 'zyxwvutsrqponmlkjihgfedcba':
        print(-1)
    else:
        for i in range(26):
            if S[i] != M[i]:
                ans = S[: i - 1] + M[i]
                break
        print(ans)
Problem p03471 (python)

Fixed submission:
n, y = map(int, input().split())
 
ans =[-1, -1, -1]
for i in range(n + 1):
    for j in range(n + 1 - i):
            if i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
                ans = [i, j, n - i - j]
                break
print(' '.join(map(str, ans)))

Buggy submission (verdict: Runtime Error):
n, y = map(int, input().split())
s = min(n, y // 10000)
t = min(n, y // 5000)
u = min(n, y // 1000)

ans =[-1, -1, -1]
for i in range(s, -1, -1):
    for j in range(t, -1, -1):
        for u in range(u, -1, -1):
            if i * 10000 + j * 5000 + k * 1000 == y and i + j + k == n:
                ans = [i, j, k]
                break
print(' '.join(map(str, ans)))
Problem p03494 (python)

Fixed submission:
n = int(input())
A = [int(i) for i in input().split()]
ans = 10 ** 9
if all(A[i] % 2 == 0 for i in range(n)):
    for i in range(n):
        count = 0
        while A[i] % 2 == 0:
            A[i] //= 2
            count += 1
        ans = min(ans, count)
else:
    ans = 0
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = [int(i) for i in input().split()]
if all(A[i] % 2 == 0 for i in range(n)):
    ans = 10 ** 9
    for i in range(n):
        count = 0
        while A[i] % 2 == 0:
            A[i] //= 2
            count += 1
        ans = min(ans, count)
print(ans)
Problem p03503 (python)

Fixed submission:
n = int(input())
F = [[int(i) for i in input().split()] for i in range(n)]
P = [[int(i) for i in input().split()] for i in range(n)]

ans = -10 ** 10
for i in range(1, 2 ** 10):
    tmp = i
    A = []
    while tmp:
        A.append(tmp % 2)
        tmp //= 2
    while len(A) != 10:
        A.append(0)

    temp = 0
    for s in range(n):
        count = 0
        for t in range(10):
            if F[s][t] == 1 and A[t] == 1:
                count += 1
        temp += P[s][count]
    ans = max(ans, temp)
        
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
F = [[int(i) for i in input().split()] for i in range(n)]
P = [[int(i) for i in input().split()] for i in range(n)]

def f(x):
    if x % 2 == 0:
        return 1
    else:
        return 0
    
ans = -10 ** 10
for i in range(1, 2 ** 10):
    for j in range(10):
        A[j] = f(i // (2 ** (10 - i)))

    temp = 0
    for s in range(n):
        count = 0
        for t in range(10):
            if F[s][t] == 1 and A[t] == 1:
                count += 1
        temp += P[s][count]
    ans = max(ans, temp)
        
print(ans)
Problem p03504 (python)

Fixed submission:
N, C = map(int, input().split())
STC = [[int(i) for i in input().split()] for i in range(N)]
STC.sort()

R = [[STC[0][1], STC[0][2]]]
for s, t, c in STC[1:]:
    for i in range(len(R)):
        t_r, c_r = R[i][0], R[i][1]
        if c == c_r and t_r <= s:
            R[i] = [t, c]
            break
        if c != c_r and t_r < s:
            R[i] = [t, c]
            break
    else:
        R.append([t, c])
        
print(len(R))

Buggy submission (verdict: Runtime Error):
N, C = map(int, input().split())
STC = [[int(i) for i in input().split()] for i in range(N)]
STC.sort()

R = [[STC[0][1], STC[0][2]]]
for s, t, c in STC[1:]:
    for i in range(len(R)):
        R[i][0], R[i][1] = t_r, c_r
        if c == c_r and t_r <= s:
            R[i] = [t, c]
            break
        if c != c_r and t_r < s:
            R[i] = [t, c]
            break
    else:
        R.append([t, c])
        
print(len(R))

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

A = [[] for i in range(C + 1)]
for i in range(N):
    s, t, c = map(int, input().split())
    A[c].extend(list(range(s - 1, t + 1)))
    
dp = [0] * (10 ** 5 + 1)
for a in A:
    if a == []:
        continue
    a.sort()
    dp[a[0]] += 1
    dp[a[-1] + 1] -= 1
    
for i in range(1, 10 ** 5 + 1):
    dp[i] += dp[i - 1]
    
print(max(dp))

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

A = [[0] * (10 ** 5 + 1) for i in range(C + 1)]
for i in range(N):
    s, t, c = map(int, input().split())
    A[c][s] += 1
    A[c][t + 1] -= 1
    
for i in range(C + 1):
    for j in range(1, 10 ** 5 + 1):
        A[i][j] += A[i][j - 1]
        
for j in range(10 ** 5 + 1):
    for i in range(1, C + 1):
        A[i][j] += A[i - 1][j]
        
print(max(A[-1]))
Problem p03545 (python)

Fixed submission:
A = input()

def f(x):
    if x % 2 == 0:
        return 1
    else:
        return -1

B = []
for i in range(8):
    if int(A[0]) + f(i//4) * int(A[1]) + f(i//2) * int(A[2]) + f(i) * int(A[3]) == 7:
        if f(i//4) == 1:
            B.append('+')
        else:
            B.append('-')
        if f(i//2) == 1:
            B.append('+')
        else:
            B.append('-')
        if f(i) == 1:
            B.append('+')
        else:
            B.append('-')
        flag = 1
        break
        
if flag == 1:
    print('{}{}{}{}{}{}{}{}'.format(A[0], B[0], A[1], B[1], A[2], B[2], A[3], '=7'))

Buggy submission (verdict: Runtime Error):
A = input()

def f(x):
    if x % 2 == 0:
        return 1
    else:
        return -1

B = []
for i in range(8):
    if int(A[0]) + f(i//4) * int(A[1]) + f(i//2) * int(A[2]) + f(i) * int(A[3]) == 7:
        if f(i//4) == 1:
            B.append('+')
        else:
            B.append('-')
        if f(i//2) == 1:
            B.append('+')
        else:
            B.append('-')
        if f(i) == 1:
            B.append('+')
        else:
            B.sppend('-')
        flag = 1
        break
        
if flag == 1:
    print('{}{}{}{}{}{}{}{}'.format(A[0], B[0], A[1], B[1], A[2], B[2], A[3], '=7'))
Problem p03557 (python)

Fixed submission:
import bisect

n = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

ans = 0
for b in B:
    ans += bisect.bisect_left(A, b) * (n - bisect.bisect_right(C, b))
    
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

ans = 0
for b in B:
    ans += bisect.bisect_left(A, b) * (n - bisect.bisect_right(C, b))
    
print(ans)
Problem p03565 (python)

Fixed submission:
S = input()
T = input()

ans = 'UNRESTORABLE'
for i in range(len(S) - len(T) + 1):
    flag = 1
    for j in range(len(T)):
        if S[i+j] == T[j] or S[i+j] == '?':
            continue
        else:
            flag = 0
    if flag:
        ans = S[0:i] + T + S[i+len(T):]
        ans = ans.replace('?', 'a')
    
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
n = len(S)
m = len(T)

ans = 'UNRESTORABLE'
for i in range(n - m + 1):
    for j in range(m):
        if S[i + j] != '?' and S[i + j] != T[j]:
            break
    else:
        S2 = S[: i] + T + S[i + m :]
ans = S2.replace('?', 'a')
        
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
 
ans = 'UNRESTORABLE'
for i in range(len(S) - len(T) + 1):
    s = S[i:i+len(T)+1]
    flag = 1
    for j in range(len(T)):
        if s[j] == T[j] or s[j] == '?':
            pass
        else:
            flag = 0
    if flag:
        ans = S[0:i] + T + S[i+len(T)]
        ans = ans.replace('?', 'a')
print(ans)
Problem p03645 (python)

Fixed submission:
n, m = map(int, input().split())
S = set()
G = set()

for i in range(m):
    s, g = map(int, input().split())
    if s == 1:
        G.add(g)
    if g == n:
        S.add(s)

if len(S&G) != 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Buggy submission (verdict: Runtime Error):
import bisect
n, m = map(int, input().split())
AB = [[int(i) for i in input().split()] for i in range(m)]
S = []
G = []

for ab in AB:
    if ab[0] == 1:
        S.append(ab[1])
    if ab[1] == n:
        G.append(ab[0])

S.sort()
G.sort()
        
ans = 'IMPOSSIBLE'
if len(S) != 0 and len(G) != 0:
    for s in S:
        idx = bisect.bisect_left(G, s)
        if s == G[idx]:
            ans = 'POSSIBLE'
print(ans)

Buggy submission (verdict: Runtime Error):
import bisect
n, m = map(int, input().split())
AB = [[int(i) for i in input().split()] for i in range(m)]
S = []
G = []

for ab in AB:
    if ab[0] == 1:
        S.append(ab[1])
    if ab[1] == n:
        G.append(ab[0])

S.sort()
G.sort()
        
ans = 'IMPOSSIBLE'
if len(G) != 0:
    for s in S:
        idx = bisect.bisect_left(G, s)
        if s == G[idx]:
            ans = 'POSSIBLE'
print(ans)

Buggy submission (verdict: Runtime Error):
import bisect
n, m = map(int, input().split())
AB = [[int(i) for i in input().split()] for i in range(m)]
S = []
G = []

for ab in AB:
    if ab[0] == 1:
        S.append(ab[1])
    if ab[1] == n:
        G.append(ab[0])
        
ans = 'IMPOSSIBLE'
if len(G) != 0:
    for s in S:
        idx = bisect.bisect_left(G, s)
        if s == G[idx]:
            ans = 'POSSIBLE'
print(ans)
Problem p03720 (python)

Fixed submission:
n, m = map(int, input().split())
A = [0] * n

for i in range(m):
    x, y = map(int, input().split())
    A[x-1] += 1
    A[y-1] += 1

for i in range(n):
    print(A[i])

Buggy submission (verdict: Runtime Error):
from collections import Counter
n, m = map(int, input().split())
A = []
for i in range(m):
    x, y = map(int, input().split())
    A.append(x)
    A.append(y)
C = sorted(Counter(A).most_common())
for i in range(n):
    print(C[i][1])

Buggy submission (verdict: Runtime Error):
from collections import Counter
n, m = map(int, input().split())
A = []
for i in range(m):
    x, y = map(int, input().split())
    A.append(x)
    A.append(y)
C = sorted(Counter(A).most_common(), reverse = True, key = lambda x: x[1])
for i in range(n):
    print(C[i][1])
Problem p03828 (python)

Fixed submission:
n = int(input())
mod = 10 ** 9 + 7

def nprf(n):
    pf = {}
    for i in range(2, n + 1):
        for j in range(2, i + 1):
            while i % j == 0:
                if not j in pf:
                    pf[j] = 0
                pf[j] += 1
                i //= j
    return pf
    
cnt = 1
for v in nprf(n).values():
    cnt *= (v + 1)
    
print(cnt % mod)

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

def nprf(n):
    pf = {}
    for i in range(2, n + 1):
        for j in range(2, i + 1):
            while i % j == 0:
                if not j in pf:
                    pf[j] = 0
                pf[j] += 1
                i //= j
    return pf
    
cnt = 1
for v in nprf(n).values():
    cnt *= (v + 1)
    
print(cnt % mod)