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

Fixed submission:
import sys,math
W,H,x,y = map(int,input().split())
if W/2 == x and H/2 == y:
    print(W*H/2,'1')
else:
    print(W*H/2,'0')

Buggy submission (verdict: Runtime Error):
import sys,math
W,H,x,y = map(int,input().split())
if W % x == 0 and H % y == 0 and H!=y and W!=x and H!=0 and W!=0:
    print(W*H/2,'1')
else:
    print(W*H/2,'0')

Buggy submission (verdict: Runtime Error):
import sys,math
W,H,x,y = map(int,input().split())
if W % x == 0 and H % y == 0:
    print(W*H/2,1)
else :
    print(W*H/2,0)
Problem p03006 (python)

Fixed submission:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = [inpl() for i in range(n)]
a.sort(key=lambda x:x[1])
a.sort()
z = []
# pprint.pprint(a)
for i in range(n):
    for j in range(i,n):
        if i == j:
            continue
        z.append((a[i][0]-a[j][0], a[i][1]-a[j][1]))
c = Counter(z)
# pprint.pprint(c)
if n == 1:
    print(1)
else:
    print(n-c.most_common()[0][1])
# print(n-c.most_common()[0][1])

Buggy submission (verdict: Runtime Error):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = [inpl() for _ in range(n)]
c = []
for i,(x,y) in enumerate(a):
    for j,(z,w) in enumerate(a):
        if i == j: continue
        c.append(((x-z), (y-w)))
h = Counter(c)
print(n-max(h.values()))

Buggy submission (verdict: Runtime Error):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = [inpl() for i in range(n)]
a.sort(key=lambda x:x[1])
a.sort()
z = []
# pprint.pprint(a)
for i in range(n):
    for j in range(i,n):
        if i == j:
            continue
        z.append((a[i][0]-a[j][0], a[i][1]-a[j][1]))
c = Counter(z)
# pprint.pprint(c)
print(n-c.most_common()[0][1])
Problem p03044 (python)

Fixed submission:
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

def dfs(x):
    for p in g[x]:
        # print(p[0])
        if color[p[0]] != -1:
            continue
        if p[1] % 2: #odd
            if color[x]: #pre=white
                color[p[0]] = 0
            else:
                color[p[0]] = 1
        else:
            if color[x]: #pre=white
                color[p[0]] = 1
            else:
                color[p[0]] = 0
        dfs(p[0])
n = inp()
g = [[] for i in range(n)]
#0:黒 1:白 -1:未訪問
color = [-1] * n

for i in range(n-1):
    u,v,w = inpl()
    g[u-1].append([v-1,w])
    g[v-1].append([u-1,w])
# print(g)
color[0] = 0
dfs(0)
for i in range(1,n):
    if color[i] != -1:
        continue
    dfs(i)
for i in range(n):
    print(color[i])

Buggy submission (verdict: Runtime Error):
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

def dfs(x):
    for p in g[x]:
        # print(p[0])
        if color[p[0]] != -1:
            continue
        if p[1] % 2: #odd
            if color[x]: #pre=white
                color[p[0]] = 0
            else:
                color[p[0]] = 1
        else:
            if color[x]: #pre=white
                color[p[0]] = 1
            else:
                color[p[0]] = 0
        dfs(p[0])
n = inp()
g = [[] for i in range(n)]
#0:黒 1:白 -1:未訪問
color = [-1] * n

for i in range(n-1):
    u,v,w = inpl()
    g[u-1].append([v-1,w])
    g[v-1].append([u-1,w])
# print(g)
color[0] = 0
dfs(0)
for i in range(1,n):
    if color[i] != -1:
        continue
    dfs(i)
for i in range(n):
    print(color[i])
Problem p03050 (python)

Fixed submission:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
if n == 1:
    print(0)
    quit()
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort(reverse=True)
    return divisors
m = make_divisors(n)
res = m[:len(m)//2]
if n //(res[-1]-1) != n % (res[-1]-1):
    res[-1] = 1
print(sum(res) - len(res))

Buggy submission (verdict: Runtime Error):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
if n == 1:
    print(0)
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort(reverse=True)
    return divisors
m = make_divisors(n)
res = m[:len(m)//2]
if n //(res[-1]-1) != n % (res[-1]-1):
    res[-1] = 1
print(sum(res) - len(res))

Buggy submission (verdict: Runtime Error):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort(reverse=True)
    return divisors
m = make_divisors(n)
res = m[:len(m)//2]
if n //(res[-1]-1) != n % (res[-1]-1):
    res[-1] = 1
print(sum(res) - len(res))
Problem p03069 (python)

Fixed submission:
import fractions,math,sys
from collections import Counter
n = int(input())
s = list(input())
cnt = Counter(s)
white_l = 0
black_l = 0
min = cnt['.']
for i in range(n):
    if s[i] == '#':
        black_l += 1
        cnt['#'] -= 1
    else:
        white_l += 1
        cnt['.'] -= 1
    if black_l + cnt['.'] < min:
        min = black_l + cnt['.']
print(min)

Buggy submission (verdict: Runtime Error):
import sys
N = int(input())
S = input()
s_list = list(S)
temp_start = N+1
count_1 = 0
count_2 = 0
for i in range(N-1):
    if s_list[i] == "#":
        temp_start = i
        break
if temp_start == N+1:
    print(0)
    sys.exit()
for i in range(N)[::-1]:
    if s_list[i] != "#":
        temp_end = i
        break
for i in range(temp_start,temp_end + 1):
    if s_list[i] == "#":
        count_1 += 1
    else :
        count_2 += 1
print(min(count_1,count_2))

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
s_list = list(S)
count_1 = 0
count_2 = 0
for i in range(N-1):
    if s_list[i] == "#" and s_list[i+1] == ".":
        temp_start = i
        break

for i in range(N)[::-1]:
    if s_list[i] != "#":
        temp_end = i
        break

for i in range(temp_start,temp_end + 1):
    if s_list[i] == "#":
        count_1 += 1
    else :
        count_2 += 1
print(min(count_1,count_2))
Problem p03074 (python)

Fixed submission:
n,k = map(int,input().split())
s = input()
tmp = s[0]
cnt = 1
ans = 0
ss = []
res = [0]
sum = 0
if s[0] == '0':
    ss.append(0)

for i in range(1,n):
    if s[i] == tmp:
        cnt += 1
    else:
        tmp = s[i]
        ss.append(cnt)
        cnt = 1
ss.append(cnt)
if s[-1] == '0':
    ss.append(0)
ll = len(ss)
for i in range(ll):
    sum += ss[i]
    res.append(sum)

if ll//2 <= k:
    print(n)
else:
    for i in range(ll-k*2)[::2]:
        ans = max(ans, res[i+k*2+1]-res[i])
    print(ans)

Buggy submission (verdict: Runtime Error):
import numpy
n,k = map(int,input().split())
s = input()
tmp = s[0]
cnt = 1
ans = 0
ss = []
res = [0]
sum = 0
if s[0] == '0':
    ss.append(0)

for i in range(1,n):
    if s[i] == tmp:
        cnt += 1
    else:
        tmp = s[i]
        ss.append(cnt)
        cnt = 1
ss.append(cnt)
if s[-1] == '0':
    ss.append(0)
ll = len(ss)
for i in range(ll):
    sum += ss[i]
    res.append(sum)

if ll//2 <= k:
    print(n)
else:
    for i in range(ll-k*2)[::2]:
        ans = max(ans, res[i+k*2+1]-res[i])
    print(ans)
Problem p03106 (python)

Fixed submission:
a,b,k = map(int,input().split())
cnt = 0
tmp = []
for i in range(1,min(a,b)+1):
    if a % i == 0 and b % i == 0:
        cnt += 1
        tmp.append(i)
print(tmp[cnt - k])

Buggy submission (verdict: Runtime Error):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

a,b,k = inpl()
c = math.gcd(a,b)
res = []
for i in range(1,c+1):
    if a%i == 0 and b%i == 0:
        res.append(i)
res.sort(reverse = True)
print(res[k-1])
Problem p03164 (python)

Fixed submission:
from collections import Counter,defaultdict
import sys,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

n,w = inpl()
ww = [0] * n
vv = [0] * n
for i in range(n):
    ww[i],vv[i] = inpl()
dp = [[mod for i in range(sum(vv)+1)] for j in range(n+1)]
dp[0][0] = 0

for i in range(n):
    for j in range(sum(vv)+1):
        if j >= vv[i]:
            dp[i+1][j] = min(dp[i][j], dp[i][j-vv[i]]+ww[i])
        else:
            dp[i+1][j] = dp[i][j]
for i in range(sum(vv)+1)[::-1]:
    if dp[n][i] <= w:
        print(i)
        break

Buggy submission (verdict: Runtime Error):
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,W = inpl()
value = []
weight = []
for i in range(n):
    a,b = inpl()
    value.append(a)
    weight.append(b)
dp = [[0 for i in range(n+5)] for j in range(W+5)]
for i in range(n):
    for w in range(W+1):
        if w >= weight[i]:
            dp[i+1][w] = max(dp[i][w-weight[i]] + value[i], dp[i][w])
        else:
            dp[i+1][w] = dp[i][w]
print(dp[n][w])

# n=6
# (weight,value)=(2,3),(1,2),(3,6),(2,1),(1,3),(5,85)
# W=8

# >> 91
Problem p03196 (python)

Fixed submission:
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
#素因数分解
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

n,p = inpl()
soin = prime_factorize(p)
cnt = Counter(soin)
res = 1
for key in cnt.keys():
    if cnt[key] >= n:
        res *= key ** (cnt[key]//n)
print(res)

Buggy submission (verdict: Runtime Error):
import sympy
n,p = map(int,input().split())
cnt = sympy.factorint(p)
ans = 1

for i in cnt:
    while cnt[i] >= n:
        ans *= i
        cnt[i] -= n
print(ans)
Problem p03244 (python)

Fixed submission:
import math,fractions
from collections import Counter
n = int(input())
v = [int(i) for i in input().split()]
a = [v[i] for i in range(n) if i%2]
b = [v[i] for i in range(n) if i%2==0]
cnt_a = Counter(a)
cnt_b = Counter(b)
max_a = cnt_a.most_common()[0][1]
max_b = cnt_b.most_common()[0][1]

str_a = cnt_a.most_common()[0][0]
str_b = cnt_b.most_common()[0][0]

max_2a = 0
max_2b = 0

for i in cnt_a:
    if str_a != i  and cnt_a[i] > max_2a:
        max_2a = cnt_a[i]

for i in cnt_b:
    if str_b != i  and cnt_b[i] > max_2b:
        max_2b = cnt_b[i]

if str_a != str_b:
    print(n//2 - max_a + n//2 - max_b)
else:
    tmp_a = n//2 - max_2a + n//2 - max_b
    tmp_b = n//2 - max_a + n//2 - max_2b
    print(min(tmp_a,tmp_b))

Buggy submission (verdict: Runtime Error):
import math,fractions
from collections import Counter
n = int(input())
v = [int(i) for i in input().split()]
a = Counter(v[1::2]).most_common()
b = Counter(v[0::2]).most_common()
a.append(0,0)
b.append(0,0)

if a[0][0] != b[0][0]:
    print(n//2 - a[0][1] + n//2 - b[0][1])
else:
    tmp_x = n//2 - a[1][1] + n//2 - b[0][1]
    tmp_y = n//2 - a[0][1] + n//2 - b[1][1]
    print(min(tmp_x, tmp_y))

Buggy submission (verdict: Runtime Error):
import math,fractions
from collections import Counter
n = int(input())
v = [int(i) for i in input().split()]
a = Counter(v[1::2]).most_common()
b = Counter(v[0::2]).most_common()

if a[0][0] != b[0][0]:
    print(n//2 - a[0][1] + n//2 - b[0][1])
else:
    tmp_x = n//2 - a[1][1] + n//2 - b[0][1]
    tmp_y = n//2 - a[0][1] + n//2 - b[1][1]
    print(min(tmp_x, tmp_y))
Problem p03311 (python)

Fixed submission:
from statistics import median
import math
n = int(input())
a = [int(i) for i in input().split()]
for i in range(n):
    a[i] -= i+1
a_fl = math.floor(median(a))
a_ce = math.ceil(median(a))
ans_fl=ans_ce=0

for i in range(n):
    ans_fl += abs(a[i]-a_fl)
    ans_ce += abs(a[i]-a_ce)
print(int(min(ans_fl,ans_ce)))

Buggy submission (verdict: Runtime Error):
from statistics import mean
import math
n = int(input())
a = [int(i) for i in input().split()]
for i in range(n):
    a[i] -= i+1
a_fl = math.floor(median(a))
a_ce = math.ceil(median(a))
ans_fl=ans_ce=0

for i in range(n):
    ans_fl += abs(a[i]-a_fl)
    ans_ce += abs(a[i]-a_ce)
print(int(min(ans_fl,ans_ce)))
Problem p03380 (python)

Fixed submission:
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
a.sort()
ma = a.pop()
mi = -1
dif = mod
for i in range(n-1):
    if abs(ma/2-a[i]) < dif:
        mi = i
        dif = abs(ma/2-a[i])
print(ma,a[mi])

Buggy submission (verdict: Runtime Error):
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
a.sort()
mm = a.pop()
ind = bisect.bisect_left(a,mm/2)
print(mm,a[ind])
Problem p03569 (python)

Fixed submission:
from collections import Counter,defaultdict,deque
from heapq import heapify,heappop,heappush
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
n = len(s)
l = 0
r = n-1
res = 0
while l < r:
    if s[l] == s[r]:
        l += 1
        r -= 1
    elif s[l] == 'x':
        res += 1
        l += 1
    elif s[r] == 'x':
        res += 1
        r -= 1
    else:
        print(-1)
        break
else:
    print(res)

Buggy submission (verdict: Runtime Error):
from collections import Counter,defaultdict,deque
from heapq import heapify,heappop,heappush
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = input()
n = len(s)
snx = []

for i in range(n):
    if s[i] != 'x':
        snx.append(s[i])
ln = len(snx)
for i in range(ln//2):
    if snx[i] != snx[ln-i-1]:
        print(-1)
        quit()

j = 0
if ln%2:
    for l in range(n):
        if s[l] == snx[j]:
            j += 1
            if j >= ln//2+1:  
                break
    print(n-l-l-1)
else:
    for l in range(n):
        if s[l] == snx[j]:
            j += 1
            if j >= ln//2:  
                break 
    j = ln-1
    for r in range(n)[::-1]:
        if s[r] == snx[j]:
            j -= 1
            if j <= ln//2-1:
                break

    print(abs(n-r-l-1))
Problem p03612 (python)

Fixed submission:
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
cnt = 0
for i in range(n):
    if i == n-1 and a[i] == i+1:
        cnt += 1
        continue
    if a[i] == i+1:
        a[i], a[i+1] = a[i+1], a[i]
        cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
a = inpl()
cnt = 0
for i in range(n):
    if i == n and a[i] == i+1:
        cnt += 1
        continue
    if a[i] == i+1:
        a[i], a[i+1] = a[i+1], a[i]
        cnt += 1
print(cnt)
Problem p03633 (python)

Fixed submission:
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue,fractions
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))
def inpl_str(): return list(sys.stdin.readline().split())
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

n = inp()
t = inpln(n)
tmp = t[0]
for i in range(n-1):
    tmp = lcm(tmp, t[i+1])
print(tmp)

Buggy submission (verdict: Runtime Error):
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue,fractions
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))
def inpl_str(): return list(sys.stdin.readline().split())
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

n = inp()
t = inpln(n)
tmp = t[0]
for i in range(n-1):
    tmp = lcm(tmp, t[i+1])
print(tmp)
Problem p03635 (python)

Fixed submission:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inpl()
print((n-1)*(m-1))

Buggy submission (verdict: Runtime Error):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inp()
print((n-1)*(m-1))
Problem p04035 (python)

Fixed submission:
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,l = inpl()
a = inpl()
for i in range(1,n):
    if a[i] + a[i-1] >= l:
        print('Possible')
        for j in range(1,i):
            print(j)
        for k in range(i+1,n)[::-1]:
            print(k)
        print(i)
        break
else:
    print('Impossible')

Buggy submission (verdict: Runtime Error):
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,l = inpl()
a = inpl()
aa = []
for i in range(1,n):
    aa.append([i,a[i-1] + a[i]])
# print(aa)
if n == 2: 
    if a[0] + a[1] < l:
        print('Impossible')
    else:
        print('Possible')
        print(1)
elif n == 3:
    if aa[0][1] < l and aa[1][1] < l:
            print('Impossible')
    else:
        aa.sort(key=lambda x:x[1])
        print('Possible')
        for i in range(n-1):
            print(aa[i][0])
else:
    for i in range(1,n-1):
        if aa[i-1][1] < l and aa[i][1] < l and aa[i+1][1] < l:
            print('Impossible')
            break
    else:
        aa.sort(key=lambda x:x[1])
        print('Possible')
        for i in range(n-1):
            print(aa[i][0])