Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
line = sys.stdin.readlines()[0].rstrip("\n")
print(line.split(" ").index("0", 1))


Fixed submission:
import sys
lines = list(s.rstrip("\n") for s in sys.stdin)
numbers = list(map(int, lines[0].split(" ")))
for i, value in enumerate(numbers):
    if value == 0:
        print(i + 1)
        break
Buggy python submission (verdict: Runtime Error):
import sys
lines = [s.rstrip("\n") for s in sys.stdin.readlines()]
input = lines.pop(0)
acgt = tuple("ACGT")
max_num_list = []
max_num = 0
for c in input:
    if c in acgt:
        max_num += 1
    else:
        max_num_list.append(max_num)
        max_num = 0
print(max(max_num_list))

Fixed submission:
import sys
lines = [s.rstrip("\n") for s in sys.stdin.readlines()]
input = lines.pop(0)
acgt = tuple("ACGT")
max_num_list = []
max_num = 0
for c in input:
    if c in acgt:
        max_num += 1
    else:
        max_num_list.append(max_num)
        max_num = 0
max_num_list.append(max_num)
print(max(max_num_list))
Buggy python submission (verdict: Time Limit Exceeded):

from sys import stdin
from collections import deque


def main():
    N, M = [int(x) for x in stdin.readline().rstrip().split()]
    ipt = [[int(y) for y in x.rstrip().split()] for x in stdin.readlines()]
    MOD = 100100100100100100

    pl = [0] * (N + 1)

    for a, b in ipt:
        if pl[a] == 0:
            pl[a] = [b]
        else:
            pl[a].append(b)
        if pl[b] == 0:
            pl[b] = [a]
        else:
            pl[b].append(a)

    que = deque([1])
    deep = [MOD] * (N + 1)
    deep[1] = 0
    deep[0] = 0
    arrow = [0] * (N + 1)
    cnt = 1

    while not not que:
        q = que.popleft()
        tmp = False
        for i in pl[q]:
            if deep[i] != MOD:
                continue
            deep[i] = deep[q] + 1
            arrow[i] = q
            tmp = True
            cnt += 1
        if tmp:
            que.extend(pl[q])

    if N != cnt:
        print("No")
    else:
        print("Yes")
        for i in arrow[2:]:
            print(i)


if __name__ == "__main__":
    main()


Fixed submission:

from sys import stdin
from collections import deque


def main():
    N, M = [int(x) for x in stdin.readline().rstrip().split()]
    ipt = [[int(y) for y in x.rstrip().split()] for x in stdin.readlines()]
    MOD = 100100100100100100

    pl = [0] * (N + 1)

    for a, b in ipt:
        if pl[a] == 0:
            pl[a] = [b]
        else:
            pl[a].append(b)
        if pl[b] == 0:
            pl[b] = [a]
        else:
            pl[b].append(a)

    que = deque([1])
    deep = [MOD] * (N + 1)
    deep[1] = 0
    deep[0] = 0
    arrow = [0] * (N + 1)
    cnt = 1

    while not not que:
        q = que.popleft()
        for i in pl[q]:
            if deep[i] != MOD:
                continue
            deep[i] = deep[q] + 1
            arrow[i] = q
            cnt += 1
            que.append(i)

    if N != cnt:
        print("No")
    else:
        print("Yes")
        for i in arrow[2:]:
            print(i)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin
import itertools

n, m, x = [int(x) for x in stdin.readline().rstrip().split()]
c = [[int(y) for y in x.rstrip().split()] for x in stdin.readlines()]
mi = -1

for i in itertools.permutations(c, n):
    cnt = [0]*m
    mon = 0
    for j in i:
        cnt = [cnt[k]+j[k+1] for k in range(len(cnt))]
        mon += j[0]
        if sum(1 for k in cnt if k >= x) == m:
            if mi > mon or mi == -1:
                mi = mon
            break

print(mi)


Fixed submission:
from sys import stdin
import itertools

n, m, x = [int(x) for x in stdin.readline().rstrip().split()]
c = [[int(y) for y in x.rstrip().split()] for x in stdin.readlines()]
c.sort()
mi = -1
r = 0

for j in range(1, m + 1):
    li = [x[j] for x in c]
    li.sort(reverse=True)
    for i in range(1, len(li) + 1):
        if sum(li[:i]) >= x:
            r = max(r, i)
            break

for h in range(r, n + 1):
    for i in itertools.combinations(c, h):
        cnt = [0] * m
        mon = 0
        for j in i:
            cnt = [cnt[k]+j[k+1] for k in range(len(cnt))]
            mon += j[0]
            if sum(1 for k in cnt if k >= x) == m:
                if mi > mon or mi == -1:

                    mi = mon
                break

print(mi)
Buggy python submission (verdict: Runtime Error):
from sys import stdin

s = int(stdin.readline().rstrip())

sl = len(str(s))
cnt = 0

for i in range(sl - 3):
    for j in range(i + 3, sl):
        num = s % (10 ** (sl - i)) // (10 ** (sl - j - 1))
        if num % 2019 == 0 and num > 0:
            cnt += 1

print(cnt)

Fixed submission:
from sys import stdin

s,w = [int(x) for x in stdin.readline().rstrip().split()]
print("safe" if s > w else "unsafe")
Buggy python submission (verdict: Runtime Error):
from sys import stdin
import fractions

n, m = [int(x) for x in stdin.readline().rstrip().split()]
a_list = [int(x) for x in stdin.readline().rstrip().split()]

pick = [ x for x in a_list if x >= sum(a_list) * fractions.Fraction(1, 4 * m )]

print("Yes" if len(pick) > m else "No")

Fixed submission:
from sys import stdin

a, b, c = [int(x) for x in stdin.readline().rstrip().split()]

print('{} {} {}'.format(c, a, b))

Buggy python submission (verdict: Runtime Error):
from sys import stdin

a, b, c = [int(x) for x in stdin.readline().rstrip().split()]

print(f'{c} {a} {b}')

Fixed submission:
from sys import stdin

a, b, c = [int(x) for x in stdin.readline().rstrip().split()]

print('{} {} {}'.format(c, a, b))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = map(int, input().split())
ans = 1
for x in a:
    ans *= x

if ans > 10**18:
    print(-1)
else:
    print(ans)


Fixed submission:
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    a = sorted(map(int, input().split()))
    ans = 1
    for x in a:
        ans *= x
        if ans > 10 ** 18:
            print(-1)
            exit()
    print(ans)

main()
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

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

def main():
    n = int(input())
    cache = set()
    a = prime_factorize(n)
    tmp = 1
    ans = 0
    while a:
        x = a.pop()
        if tmp % x == 0:
            tmp *= x
        else:
            tmp = x
        if tmp in cache:
            continue
        cache.add(tmp)
        ans += 1
        tmp = 1


    print(ans)


main()


Fixed submission:
a, b = input().split()
a = int(a)
b = int(int(b[0])*100+0.1 + int(b[2])*10 + int(b[3]))
print(a*b // 100)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())

a = [0] + list(map(int,input().split()))

explored = [0] * (n+1)
t = 1
cycle = 0
while True:
    if explored[t] == 2:
        k %= cycle
        explored[t] += 1
    elif explored[t] == 1:
        explored[t] += 1
        cycle += 1
    elif explored[t] == 0:
        explored[t] += 1
    k -= 1

    if k == 0:
        break
    else:
        t = a[t]
    

print(a[t])

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

a = [0] + list(map(int,input().split()))

explored = [0] * (n+1)
t = 1
cycle = 0
while True:
    if explored[t] == 2:
        k %= cycle
        if k == 0:
            k = cycle
        explored[t] += 1
    elif explored[t] == 1:
        explored[t] += 1
        cycle += 1
    elif explored[t] == 0:
        explored[t] += 1

    k -= 1
    if k == 0:
        break
    else:
        t = a[t]
    

print(a[t])
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

def main():
    x = int(input())
    p = [0, 1]
    n = [0, -1]
    i = 2
    while p[-1] <= 2*x:
        p.append(pow(i, 5))
        n.append(-pow(i, 5))
        i += 1

    p_ = set(p)
    n_ = set(n)
    for z in p:
        if x - z in n_:
            print(int(pow(x - z, 1 / 5)), int(pow(z, 1 / 5)))
            return

        if x - z in p_:
            print(int(pow(x - z, 1 / 5)), int(-pow(z, 1 / 5)))
            return

main()


Fixed submission:
import sys
input = sys.stdin.readline

def main():
    x = int(input())
    p = [0, 1]
    i = 2
    while p[-1] <= x*x:
        p.append(pow(i, 5))
        i += 1

    p_ = set(p)
    for z in p:
        if z - x in p_:
            print(int(pow(z, 1/5)), int(pow(z-x, 1/5)))
            return

        if x - z in p_:
            print(int(pow(abs(x-z), 1/5)), int(-pow(z, 1/5)))
            return


main()
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate

def helpme(ary):
    v = 0
    for i in ary:
        v += kitaichi(i)
    return v

def kitaichi(n):
    return sum(range(1,n+1)) / n

def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))


    ans = helpme(P[:K])
    tmp = ans
    for i in range(1, N-K+1):
        prev = kitaichi(P[i-1])
        suc = kitaichi(P[i+K-1])
        tmp = tmp-prev+suc
        ans = max(ans, tmp)

    print(ans)



main()

Fixed submission:
from functools import lru_cache

def pleaseAC(ary):
    v = 0
    for i in ary:
        v += kitaichi(i)
    return v

@lru_cache(maxsize=1001)
def kitaichi(n):
    return sum(range(1,n+1)) / n

def main():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))


    best = 0
    best_val = sum(P[:K])
    tmp = best_val
    for i in range(1, N-K+1):
        prev = P[i-1]
        suc = P[i+K-1]
        tmp = tmp-prev+suc
        if best_val < tmp:
            best_val = tmp
            best = i

    print(pleaseAC(P[best:best+K]))



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

scores = [[0, False] for _ in range(n)]

for _ in range(m):
    p, S = input().split()
    p = int(p)

    if scores[p][1]:
        continue

    if S == "AC":
        scores[p][1] = True
        continue

    if S == "WA":
        scores[p][0] += 1

score = pena = 0
for count, ac in scores:
    if ac:
        score += 1
        pena += count

print(score, pena)


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

scores = [[0, False] for _ in range(n+1)]

for _ in range(m):
    p, S = input().split()
    p = int(p)

    if scores[p][1]:
        continue

    if S == "AC":
        scores[p][1] = True
        continue

    if S == "WA":
        scores[p][0] += 1

score = pena = 0
for count, ac in scores:
    if ac:
        score += 1
        pena += count

print(score, pena)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**9)

x = input()
if len(x) < 3:
    print(0)

k = 0
if x[-3] == "0":
    k = 10
else:
    k = int(x[-3])

x = int(x[-2:])

products = [0, 1, 2, 3, 4, 5]

def dfs(comb_):
    if len(comb_) == k:
        return 1 if sum(comb_) == x else 0

    for product in products:
        comb = comb_[:]
        comb.append(product)
        if dfs(comb) == 1:
            return 1

    return 0

print(dfs([]))
        


Fixed submission:
x = int(input())
for i in range(1,100000):
  if 100*i <= x <= 105*i:
    print(1)
    exit()
print(0)
Buggy python submission (verdict: Time Limit Exceeded):
X, Y = map(int,input().split())

MOD = 10**9 + 7

def comb(n, r):
    if n < r or n < 0 or r < 0:
        return 0

    n += 1
    over = 1
    under = 1
    for i in range(1,r + 1):
      over *= (n - i) % MOD
      under *= i % MOD
    return over * pow(under, MOD - 2, MOD) % MOD

if (X + Y) % 3 != 0:
    print(0)
else:
    a = (2 * X - Y) // 3
    b = (2 * Y - X) // 3
    print(comb(a+b, a))



Fixed submission:
X, Y = map(int,input().split())

MOD = 10**9 + 7

def comb(n, r):
    if n < r or n < 0 or r < 0:
        return 0

    n += 1
    over = 1
    under = 1
    for i in range(1,r + 1):
      over = over * (n - i) % MOD
      under = under * i % MOD
    return over * pow(under, MOD - 2, MOD) % MOD

if (X + Y) % 3 != 0:
    print(0)
else:
    a = (2 * X - Y) // 3
    b = (2 * Y - X) // 3
    print(comb(a+b, a))
Buggy python submission (verdict: Runtime Error):

a = sorted([input().split() + [str(i+1)] for i in range(n)])

a.append(['end', '0', '0'])

tmp = []
ans = []

for i in range(n):
    tmp.append(a[i])
    if a[i][0] != a[i+1][0]:
        ans.append(sorted(tmp, key=lambda x: int(x[1]), reverse=True))
        tmp = []

[print(c[2]) for c in ans[0]]


Fixed submission:
n = int(input())


def f(n):
    n[1] = int(n[1])
    return n


a = sorted([input().split() + [str(i+1)] for i in range(n)])

a.append(['end', '0', '0'])

tmp = []
ans = []

for i in range(n):
    tmp.append(a[i])
    if a[i][0] != a[i+1][0]:
        ans.append(sorted(tmp, key=lambda x: int(x[1]), reverse=True))
        tmp = []

for c in ans:
    for d in c:
        print(d[2])
Buggy python submission (verdict: Runtime Error):
n = int(input())
lst = range(2, n)

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

divisors.pop(0)
divisors.pop(1)
print(sum(divisors))

Fixed submission:
import sys
input = sys.stdin.readline

def main():
    n = int(input())

    def yakusu():
        for i in range(1, int(n**0.5)+1):
            if n%i == 0:
                yield i
                if i != n //i:
                    yield n//i

    for m in yakusu():
        m -= 1
        if m == 0:
            continue

        if n // m == n % m:
            yield m

print(sum(main()))

Buggy python submission (verdict: Runtime Error):
n = int(input())
lst = range(2, n)

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

divisors.pop(0)
divisors.pop(1)
print(sum(divisors))

Fixed submission:
import sys
input = sys.stdin.readline

def main():
    n = int(input())

    def yakusu():
        for i in range(1, int(n**0.5)+1):
            if n%i == 0:
                yield i
                if i != n //i:
                    yield n//i

    for m in yakusu():
        m -= 1
        if m == 0:
            continue

        if n // m == n % m:
            yield m

print(sum(main()))
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
from functools import reduce

def main():
    N = int(input())
    A = list(map(int, input().split()))

    def pleaceAC():
        for i in range(N):
            a = reduce(gcd, [0]+A[:i])
            b = reduce(gcd, reversed(A[i+1:]+[0]))
            yield gcd(a, b)

    print(max(pleaceAC()))


main()

Fixed submission:
from fractions import gcd
from itertools import accumulate

def main():
    N = int(input())
    A = list(map(int, input().split()))

    def pleaceAC():
        left = list(accumulate([0]+A, gcd))
        right = list(accumulate(reversed(A+[0]), gcd))
        for i in range(N):
            yield gcd(left[i], right[~(i+1)])

    print(max(pleaceAC()))


main()

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

def main():
    N = int(input())
    A = list(map(int, input().split()))

    def pleaceAC():
        yield reduce(gcd, A[1:])
        yield reduce(gcd, A[:-1])
        for i in range(1,N-1):
            a = reduce(gcd, A[:i])
            b = reduce(gcd, A[i+i:])
            yield gcd(a, b)

    print(max(pleaceAC()))


main()

Fixed submission:
from fractions import gcd
from itertools import accumulate

def main():
    N = int(input())
    A = list(map(int, input().split()))

    def pleaceAC():
        left = list(accumulate([0]+A, gcd))
        right = list(accumulate(reversed(A+[0]), gcd))
        for i in range(N):
            yield gcd(left[i], right[~(i+1)])

    print(max(pleaceAC()))


main()
Buggy python submission (verdict: Runtime Error):
import sys
# input = sys.stdin.readline
from itertools import accumulate

def readlines(n):
    for _ in range(n):
        yield map(int, input().split())


def main():
    s = input()

    subst = 0
    for i in range(len(s)):
        if s[i] in "ACGT":
            subst += 1
        else:
            yield subst
            subst = 0
        
    

print(max(main()))


Fixed submission:
import sys
# input = sys.stdin.readline

def readlines(n):
    for _ in range(n):
        yield map(int, input().split())


def main():
    s = input()

    subst = 0
    for i in range(len(s)):
        if s[i] in "ACGT":
            subst += 1
        else:
            yield subst
            subst = 0
    
    yield subst
    

print(max(main()))
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate

n, q = map(int, input().split())

s = input()

problems = [list(map(int, input().split())) for _ in range(q)]


def count(total, i):
    return total + 1 if s[i-1] + s[i] == 'AC' else total


cumsum = [0, *accumulate(range(1, n), count)]

for l, r in problems:
    print(cumsum[r-1] - cumsum[l-1])

Fixed submission:
from itertools import accumulate

n, q = map(int, input().split())

s = input()

problems = [list(map(int, input().split())) for _ in range(q)]


def count(total, i):
    return total + 1 if s[i:i+2] == 'AC' else total


cumsum = list(accumulate([0] + list(range(n)), count))

for l, r in problems:
    print(cumsum[r-1] - cumsum[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
N, M = [int(c) for c in input().split()]

shops = []
for _ in range(N):
    ab = [int(c) for c in input().split()]
    shops.append(ab)

cost = 0
bought = 0
for i in range(N):
    if i < N - 1:
        target = shops[i][0]
        min_i = i
        for j in range(i+1, N):
            if shops[j][0] < shops[min_i][0]:
                min_i = j
        shops[min_i], shops[i] = shops[i], shops[min_i]

    k = 0
    while k < shops[i][1]:
        if bought == M:
            break
        cost += shops[i][0]
        k += 1
        bought += 1

    if bought == M:
        break

print(cost)

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

shops = []
for _ in range(N):
    ab = [int(c) for c in input().split()]
    shops.append(ab)

cost = 0
bought = 0
s_shops = sorted(shops)

for shop in s_shops:
    buying = 0
    while buying < shop[1]:
        if bought == M:
            break
        cost += shop[0]
        buying += 1
        bought += 1

    if bought == M:
        break

print(cost)
Buggy python submission (verdict: Runtime Error):
a, b, k = [int(s) for s in input().split()]


def f(s, l, k):
    numbers = []
    for i in range(2, s + 1):
        if s % i == 0 and l % i == 0:
            numbers.append(i)

    print(numbers[-k])


if a > b:
    f(b, a, k)
else:
    f(a, b, k)


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


def f(s, l, k):
    numbers = []
    for i in range(1, s + 1):
        if s % i == 0 and l % i == 0:
            numbers.append(i)

    print(numbers[-k])


if a > b:
    f(b, a, k)
else:
    f(a, b, k)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()

count = 0
while True:
    n = len(s)
    ints = sum(map(int, s))
    if n == 0 or ints == 0 or ints == n:
        break
    sn = s + '\n'
    for i in range(n):
        if sn[i-1] + sn[i] == '10' or sn[i-1] + sn[i] == '01':
            s = sn[:i-1] + sn[i+1:n]
            count += 1
            break

print(count * 2)

Fixed submission:
s = input()

zero = s.count('0')
one = s.count('1')

print(2 * min(zero, one))

Buggy python submission (verdict: Runtime Error):
s = input()

count = 0
while True:
    n = len(s)
    if n == 0 or sum(s) == 0 or sum(s) == n:
        break
    sn = s + '\n'
    for i in range(n):
        if sn[i-1] + sn[i] == '10' or sn[i-1] + sn[i] == '01':
            s = sn[:i-1] + sn[i+1:n]
            count += 1
            break

print(count * 2)

Fixed submission:
s = input()

zero = s.count('0')
one = s.count('1')

print(2 * min(zero, one))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()

count = 0
while True:
    n = len(s)
    if n == 0 or all(c == '0' for c in s) or all(c == '1' for c in s):
        break
    sn = s + '\n'
    for i in range(n):
        if sn[i-1] + sn[i] == '10' or sn[i-1] + sn[i] == '01':
            s = sn[:i-1] + sn[i+1:n]
            count += 1
            break

print(count * 2)

Fixed submission:
s = input()

zero = s.count('0')
one = s.count('1')

print(2 * min(zero, one))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()

count = 0
while True:
    sn = s + '\n'
    for i in range(len(s)):
        if sn[i-1] + sn[i] == '10' or sn[i-1] + sn[i] == '01':
            s = sn[:i-1] + sn[i+1:len(sn)-1]
            count += 1
            break
    if len(s) == 0 or all(c == '0' for c in s) or all(c == '1' for c in s):
        break

print(count * 2)

Fixed submission:
s = input()

zero = s.count('0')
one = s.count('1')

print(2 * min(zero, one))
Buggy python submission (verdict: Runtime Error):
n = int(input())

zombies = [int(c) for c in input().split()]


def gcd(a, b):
    mod = a % b
    if mod == 0:
        return b
    else:
        return gcd(b, mod)


def saidai_koyakusu(n, ns):
    if len(ns) == 1:
        return ns[0]
    return gcd(n, saidai_koyakusu(ns[0], ns[1:]))


if len(zombies) == 1:
    print(zombies[0])
else:
    print(saidai_koyakusu(zombies[0], zombies[1:]))


Fixed submission:
n = int(input())

zombies = [int(c) for c in input().split()]


def gcd(a, b):
    c = a % b
    if c == 0:
        return b
    else:
        return gcd(b, c)


m = zombies[0]
for i in range(1, len(zombies)):
    m = gcd(m, zombies[i])

print(m)

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

zombies = [int(c) for c in input().split()]


def gcd(a, b):
    mod = a % b
    if mod == 0:
        return b
    else:
        return gcd(b, mod)


def saidai_koyakusu(n, ns):
    if len(ns) == 1:
        return ns[0]
    return gcd(n, saidai_koyakusu(ns[0], ns[1:]))


print(saidai_koyakusu(zombies[0], zombies[1:]))

Fixed submission:
n = int(input())

zombies = [int(c) for c in input().split()]


def gcd(a, b):
    c = a % b
    if c == 0:
        return b
    else:
        return gcd(b, c)


m = zombies[0]
for i in range(1, len(zombies)):
    m = gcd(m, zombies[i])

print(m)
Buggy python submission (verdict: Runtime Error):
import qualified Data.Map.Strict as Map

primeFactorize :: Integer -> [Integer]
primeFactorize 1 = []
primeFactorize x =
    let v = head $ nativeFactors x in
        v : primeFactorize (x `div` v)
    where
        nativeFactors n = [a | a <- [2..n], n `mod` a == 0]

toCountMap :: (Ord k, Integral a) => [k] -> Map.Map k a
toCountMap xs = Map.fromListWith (+) $ zip xs (repeat 1)

main :: IO ()
main = do
    (n:p:_) <- fmap (map read . words) getLine :: IO[Integer]
    print $ solve n p

solve :: Integer -> Integer -> Integer
solve n p =
    let ps = Map.toList $ toCountMap $ primeFactorize p
    in foldr (\ (x, e) total -> total * (x ^ (e `div` n))) 1 ps
        

Fixed submission:
from collections import Counter
from functools import reduce

N,P = list(map(int,input().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

counter = Counter(prime_factorize(P))

ans = reduce(lambda total, x: total * x[0] ** (x[1]//N), counter.items(), 1)
print(ans)
Buggy python submission (verdict: Runtime Error):
n, k = [int(c) for c in input().split()]
h = [int(input()) for _ in range(n)]

h.sort()

min_d = 100000
for i in range(n-k+1):
    d = h[i+k] - h[i]
    if d < min_d:
        min_d = d

print(min_d)

Fixed submission:
n, k = [int(c) for c in input().split()]
h = [int(input()) for _ in range(n)]

h.sort()

min_d = 1000000000
for i in range(n-k+1):
    d = h[i+k-1] - h[i]
    if d < min_d:
        min_d = d

print(min_d)