Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N, M = map(int, input().split())
H = list(map(int, input().split()))
H.insert(0, 0)

A = np.zeros(M, dtype=int)
B = np.zeros(M, dtype=int)

for i in range(M):
    A[i], B[i] = map(int, input().split())
#print(A, B)

ans = 0
for j in range(1, N+1):
    ind = np.concatenate([[0], A[B==j], B[A==j]])
#    print(j, ind)
    if H[j] > max(list(map(lambda x: H[x], ind))):
        ans += 1
print(ans)

Fixed submission:
n, m = map(int, input().split())
H = list(map(int, input().split()))
MaxHeight = [0]*n
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    MaxHeight[a] = max(MaxHeight[a], H[b])
    MaxHeight[b] = max(MaxHeight[b], H[a])
ans = 0
for h, mh in zip(H, MaxHeight):
    ans = ans + 1 if h > mh else ans
print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np

N, M = map(int, input().split())
H = list(map(int, input().split()))
H.insert(0, 0)

A = np.zeros(M, dtype=int)
B = np.zeros(M, dtype=int)

for i in range(M):
    A[i], B[i] = map(int, input().split())
#print(A, B)

ans = 0
for j in range(1, N+1):
    ind = np.concatenate([[0], A[B==j], B[A==j]])
#    print(j, ind)
    if H[j] > max(list(map(lambda x: H[x], ind))):
        ans += 1
print(ans)

Fixed submission:
n, m = map(int, input().split())
H = list(map(int, input().split()))
MaxHeight = [0]*n
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    MaxHeight[a] = max(MaxHeight[a], H[b])
    MaxHeight[b] = max(MaxHeight[b], H[a])
ans = 0
for h, mh in zip(H, MaxHeight):
    ans = ans + 1 if h > mh else ans
print(ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np

N, M = map(int, input().split())
H = list(map(int, input().split()))
H.insert(0, 0)

A = np.zeros(M, dtype=int)
B = np.zeros(M, dtype=int)

for i in range(M):
    A[i], B[i] = map(int, input().split())
print(A, B)

ans = 0
for j in range(1, N+1):
    ind = np.concatenate([[0], A[B==j], B[A==j]])
#    print(j, ind)
    if H[j] > max(list(map(lambda x: H[x], ind))):
        ans += 1
print(ans)

Fixed submission:
n, m = map(int, input().split())
H = list(map(int, input().split()))
MaxHeight = [0]*n
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    MaxHeight[a] = max(MaxHeight[a], H[b])
    MaxHeight[b] = max(MaxHeight[b], H[a])
ans = 0
for h, mh in zip(H, MaxHeight):
    ans = ans + 1 if h > mh else ans
print(ans)
Buggy python submission (verdict: Runtime Error):
def hoge(K, A, B):
    K = int(input())
    A, B = map(int, input().split())
    
    ans = 0
    for n in range(A, B+1):
        if n%K == 0:
            ans = 1
            return ans
    return ans

if hoge(K, A, B):
    print('OK')
else:
    print('NG')

Fixed submission:
def hoge(K, A, B):
    ans = 0
    for n in range(A, B+1):
        if n%K == 0:
            ans = 1
            return ans
    return ans

K = int(input())
A, B = map(int, input().split())
if hoge(K, A, B):
    print('OK')
else:
    print('NG')
Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = map(int, input().split())
ans = 0
for x in range(1, min(B-1, N)+1):
    now = (A*(x%B) - (A*x)%B)/B
    ans = max(now, ans)
print(int(ans))

Fixed submission:
A, B, N = map(int, input().split())
x = min(B-1, N)

ans = int(A*x/B) - A*int(x/B)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = map(int, input().split())
ans = 0
for x in range(1, N+1):
    now = (A*(x%B) - (A*x)%B)/B
    ans = max(now, ans)
print(int(ans))

Fixed submission:
A, B, N = map(int, input().split())
x = min(B-1, N)

ans = int(A*x/B) - A*int(x/B)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = map(int, input().split())
ans = 0
for x in range(1, N+1):
    now = (A*x)//B - A*(x//B)
    ans = max(now, ans)
print(ans)

Fixed submission:
A, B, N = map(int, input().split())
x = min(B-1, N)

ans = int(A*x/B) - A*int(x/B)
print(ans)
Buggy python submission (verdict: Runtime Error):
strS = input()
S = int(strS)
lenS = len(strS)
 
ans = 0
for i in range(lenS - 3):
    for j in range(i+3, lenS):
#        print(i,j)
        if int(strS[i:j+1])%2019 == 0:
#            print(int(str(S)[i:j]), i, j)
            ans += 1
print(ans)

Fixed submission:
S, W = map(int, input().split())
if W >= S:
    print('unsafe')
else:
    print('safe')

Buggy python submission (verdict: Runtime Error):
strS = input()
S = int(strS)
lenS = len(strS)

ans = 0
for i in range(lenS):
    if i+3 <= lenS:
        for j in range(i+3, lenS):
#            print(i,j)
            if int(strS[i:j+1])%2019 == 0:
#                print(int(str(S)[i:j]), i, j)
                ans += 1
print(ans)

Fixed submission:
S, W = map(int, input().split())
if W >= S:
    print('unsafe')
else:
    print('safe')

Buggy python submission (verdict: Runtime Error):
S = int(input())
lenS = len(str(S))

ans = 0
for i in range(lenS):
    if i+3 <= lenS:
        for j in range(i+3, lenS):
#            print(i,j)
            if int(str(S)[i:j+1])%2019 == 0:
#                print(int(str(S)[i:j]), i, j)
                ans += 1
print(ans)

Fixed submission:
S, W = map(int, input().split())
if W >= S:
    print('unsafe')
else:
    print('safe')
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())

A = list(range(N+1))
for n in range(N+1):
    if np.mod(n, 3) == 0 or np.mod(n, 5) == 0:
        A[n] = 0

print(sum(A))

Fixed submission:
N = int(input())

A = list(range(N+1))
for n in range(N+1):
    if n%3 == 0 or n%5 == 0:
        A[n] = 0

print(sum(A))
Buggy python submission (verdict: Time Limit Exceeded):
import math

k = int(input())

ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            ans += math.gcd(math.gcd(a, b), c)
print(ans)

Fixed submission:
import math

k = int(input())

ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            ans += math.gcd(math.gcd(a, b), c)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

num_R = S.count('R')
num_G = S.count('G')
num_B = S.count('B')
S = '_' + S

count = 0
for i in range(1, N+1):
    for j in range(i, N+1):
        for k in range(j, N+1):
            if j - i == k - j and S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
                count += 1
#                print(i, j, k)
print(num_R*num_G*num_B - count)

Fixed submission:
N = int(input())
S = input()

num_R = S.count('R')
num_G = S.count('G')
num_B = S.count('B')
S = '_' + S

count = 0
for i in range(1, N+1):
    for j in range(i, N+1):
        k = 2*j - i
        if j <= k and k <= N:
            if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
                count += 1
#                 print(i, j, k)
print(num_R*num_G*num_B - count)
Buggy python submission (verdict: Runtime Error):
X, Y, A, B, C = map(int, input().split())
P = map(int, input().split())
Q = map(int, input().split())
R = map(int, input().split())

P = sorted(P, reverse=True)[:X]
Q = sorted(Q, reverse=True)[:Y]

L = sorted(P + Q + R, reverse=True)
print(sum(L[:X+Y]))


Fixed submission:
X, Y, A, B, C = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

P = sorted(P, reverse=True)[:X]
Q = sorted(Q, reverse=True)[:Y]
R = sorted(R, reverse=True)

L = sorted(P + Q + R, reverse=True)
print(sum(L[:X+Y]))
Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split())

Que = []
while len(Que) < N:
    Que = Que + [1]*A
    Que = Que + [0]*B
Que[0:N].count(1)

Fixed submission:
n, a, b = map(int, input().split())
print(n//(a+b)*a + min([n%(a+b), a]))
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
n = int(input())

d = 1
S1 = ''
S2 = ''
for i in range(n):
    Q = list(input().split())
    if Q[0] == '1':
        d *= -1
    else:
        f = Q[1]
        c = Q[2]
        if f == '1':
            if d == 1:
                S1 += c
            else:
                S2 += c
        else:
            if d == 1:
                S2 += c
            else:
                S1 += c
if d == 1:
    ans = S1[::-1] + S + S2
else:
    ans = S2[::-1] + S[::-1] + S1

print(ans)

Fixed submission:
S = input()
n = int(input())

d = 1
S1 = []
S2 = []
for i in range(n):
    Q = list(input().split())
    if Q[0] == '1':
        d *= -1
    else:
        f = Q[1]
        c = Q[2]
        if f == '1':
            if d == 1:
                S1.append(c)
            else:
                S2.append(c)
        else:
            if d == 1:
                S2.append(c)
            else:
                S1.append(c)
if d == 1:
    ans = ''.join(S1[::-1]) + S + ''.join(S2)
else:
    ans = ''.join(S2[::-1]) + S[::-1] + ''.join(S1)

print(ans)

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

d = 1
for i in range(q):
    t = input()
    if t == '1':
        d *= -1
#        print(d)
    else:
        _, f, c = t.split()
        f = int(f)
        if d == 1 and f == 1:
            s = c + s
        elif d == 1 and f == 2:
            s = s + c
        elif d == -1 and f == 1:
            s = s + c[::-1]
        elif d == -1 and f == 2:
            s = c[::-1] + s
#        print(d, f, c, s)

if d == -1:
    s = s[::-1]
print(s)

Fixed submission:
S = input()
n = int(input())

d = 1
S1 = []
S2 = []
for i in range(n):
    Q = list(input().split())
    if Q[0] == '1':
        d *= -1
    else:
        f = Q[1]
        c = Q[2]
        if f == '1':
            if d == 1:
                S1.append(c)
            else:
                S2.append(c)
        else:
            if d == 1:
                S2.append(c)
            else:
                S1.append(c)
if d == 1:
    ans = ''.join(S1[::-1]) + S + ''.join(S2)
else:
    ans = ''.join(S2[::-1]) + S[::-1] + ''.join(S1)

print(ans)

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

for i in range(q):
    t = input()
    if t == '1':
        s = s[::-1]
    else:
        _, f, c = t.split()
        if f == '1':
            s = c + s
        else:
            s = s + c
print(s)

Fixed submission:
S = input()
n = int(input())

d = 1
S1 = []
S2 = []
for i in range(n):
    Q = list(input().split())
    if Q[0] == '1':
        d *= -1
    else:
        f = Q[1]
        c = Q[2]
        if f == '1':
            if d == 1:
                S1.append(c)
            else:
                S2.append(c)
        else:
            if d == 1:
                S2.append(c)
            else:
                S1.append(c)
if d == 1:
    ans = ''.join(S1[::-1]) + S + ''.join(S2)
else:
    ans = ''.join(S2[::-1]) + S[::-1] + ''.join(S1)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
S = [input() for _ in range(n)]
SetS = sorted(set(S))
Hit = [0]*n
for i, item in enumerate(SetS):
    Hit[i] = S.count(item)
Ind = [i for i, x in enumerate(Hit) if x == max(Hit)]
for ind in Ind:
    print(SetS[ind])

Fixed submission:
n = int(input())
S = [input() for _ in range(n)]

from collections import Counter

C = Counter(sorted(S))

ans = []
numMax = C.most_common()[0][1]
for key, num in C.most_common():
    if num == numMax:
        ans.append(key)
[print(a) for a in sorted(ans)]
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
P = list(map(int, input().split()))

ExP = list(map(lambda x: (x+1)/2, P))
ans = 0
for i in range(n-k+1):
#    print(ExP[i: i+k])
    ans = max(ans, sum(ExP[i: i+k]))
print(ans)

Fixed submission:
n, k = map(int, input().split())
P = list(map(int, input().split()))
ExP = list(map(lambda x: (x+1)/2, P))
ans = 0
prev = 0

#for i = 0
now = sum(ExP[0: k])
#print(0, now)
ans = max(ans, now)
prev = now

for i in range(1, n-k+1):
    now = prev - ExP[i-1] + ExP[i+k-1]
#    print(i, now)
    ans = max(ans, now)
    prev = now
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
P = list(map(int, input().split()))
ExP = list(map(lambda x: (x+1)/2, P))
ans = 0
for i in range(n-k+k):
#     print(ExP[i: i+k])
    ans = max(ans, sum(ExP[i: i+k]))
print(ans)

Fixed submission:
n, k = map(int, input().split())
P = list(map(int, input().split()))
ExP = list(map(lambda x: (x+1)/2, P))
ans = 0
prev = 0

#for i = 0
now = sum(ExP[0: k])
#print(0, now)
ans = max(ans, now)
prev = now

for i in range(1, n-k+1):
    now = prev - ExP[i-1] + ExP[i+k-1]
#    print(i, now)
    ans = max(ans, now)
    prev = now
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
h = int(input())
monster = [h]

count = 0
while len(monster) > 0:
    p = monster.pop()
    if p == 1:
        count += 1
    else:
        count += 1
        monster.append(p//2)
        monster.append(p//2)
print(count)

Fixed submission:
h = int(input())
def attack(h):
    count = 0
    if h == 1:
        count += 1
        return count
    else:
        count += 1
        count += 2*attack(h//2)
        return count

print(attack(h))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
X = [[] for _ in range(N)]
L = [[] for _ in range(N)]

for i in range(N):
    X[i], L[i] = map(int, input().split())
    
    
def indexSort(L):
    D = dict(zip(range(len(L)), L))
    E = sorted(D.items(), key=lambda x: x[1])
    F = [e[0] for e in E]
    return F

L1 = [x-l for x, l in zip(X, L)]
L2 = [x+l for x, l in zip(X, L)]


Ind = indexSort(L2)

Remain = [Ind[0]]
i = 0
while i < len(Ind)-1:
    now = Remain[-1]
    After = Ind[i+1:]

    skip = 0
    for after in After:
        if L2[now] > L1[after]:
#            print(L2[now], L1[after])
            skip += 1
        else:
#            print(after)
            Remain.append(after)
            break
    i += 1 + skip  
print(len(Remain))

Fixed submission:
import numpy as np

N = int(input())
X = [[] for _ in range(N)]
L = [[] for _ in range(N)]

for i in range(N):
    X[i], L[i] = map(int, input().split())
    
    
def indexSort(L):
    D = dict(zip(range(len(L)), L))
    E = sorted(D.items(), key=lambda x: x[1])
    F = [e[0] for e in E]
    return F

L1 = [x-l for x, l in zip(X, L)]
L2 = [x+l for x, l in zip(X, L)]


Ind = np.argsort(L2)

Remain = [Ind[0]]
i = 0
while i < len(Ind)-1:
    now = Remain[-1]
    After = Ind[i+1:]

    skip = 0
    for after in After:
        if L2[now] > L1[after]:
#            print(L2[now], L1[after])
            skip += 1
        else:
#            print(after)
            Remain.append(after)
            break
    i += 1 + skip  
print(len(Remain))
Buggy python submission (verdict: Runtime Error):
n = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

import itertools

A = list(itertools.permutations(list(range(1, n+1))))
 
a = A.index(P)
b = A.index(Q)
print(abs(a-b))

Fixed submission:
n = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

import itertools

A = list(itertools.permutations(list(range(1, n+1))))
 
a = A.index(tuple(P))
b = A.index(tuple(Q))
print(abs(a-b))
Buggy python submission (verdict: Runtime Error):
a = int(input)
b = int(input)

A = [1, 2, 3]
A.pop(a-1)
A.pop(b-2)
print(A[0])

Fixed submission:
a = int(input())
b = int(input())

A = [1, 2, 3]
A[a-1]= 0
A[b-1] = 0
print(sum(A))

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

A = [1, 2, 3]
A.pop(a-1)
A.pop(b-2)
print(A[0])

Fixed submission:
a = int(input())
b = int(input())

A = [1, 2, 3]
A[a-1]= 0
A[b-1] = 0
print(sum(A))

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

A = [1, 2, 3]
A.pop(a-1)
A.pop(b-2)
print(A[0])

Fixed submission:
a = int(input())
b = int(input())

A = [1, 2, 3]
A[a-1]= 0
A[b-1] = 0
print(sum(A))
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())

import math
print(a*b//math.gcd(a, b))

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

import fractions
print(a*b//fractions.gcd(a, b))
Buggy python submission (verdict: Runtime Error):
X = int(input())

Dp = [False for _ in range(X+1)]

Dp[0] = True
for i in range(X+1):
    if any([Dp[i - j] == True for j in range(100, 107)]):
        Dp[i] = True
if Dp[X]:
    print(1)
else:
    print(0)

Fixed submission:
X = int(input())

Dp = [False for _ in range(X+1)]

Dp[0] = True
for i in range(100, X+1):
    if any([Dp[i - j] == True for j in range(100, 106)]):
        Dp[i] = True
if Dp[X]:
    print(1)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
n = int(input())
S = input()

ANS = ''
for s in S:
    if ord(s) + n < ord('Z'):
        ANS += chr(ord(s) + n)
    else:
        ANS += chr(ord(s) + n -26(ord(s) + n)%26)
print(ANS)

Fixed submission:
n = int(input())
S = input()

ANS = ''
for s in S:
    if ord(s) + n <= ord('Z'):
        ANS += chr(ord(s) + n)
    else:
        ANS += chr(ord(s) + n -26)
print(ANS)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
sqrtN = n**(1/2)
if sqrtN.is_integer():
    Pos = [int(sqrtN), int(sqrtN)]
else:
    for i in range(int(sqrtN), n+1):
        if n%i == 0:
            Pos = [i, n//i]
            break
print(sum(Pos) - 2)

Fixed submission:
n = int(input())
sqrtN = n**(1/2)
if sqrtN.is_integer():
    Pos = [int(sqrtN), int(sqrtN)]
#    print(Pos)
else:
    for i in range(int(sqrtN), 0, -1):
#        print(i)
        if n%i == 0:
            Pos = [i, n//i]
#            print(Pos)
            break
print(sum(Pos) - 2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
S = input()

T = S[0]
for i in range(1, len(S)):
    if S[i-1] != S[i]:
        T += S[i]
print(len(T))

Fixed submission:
n = int(input())
S = input()

count = 1
for i in range(1, len(S)):
    if S[i-1] != S[i]:
        count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
L = list(map(int, input().split()))


from itertools import combinations as Cmb

count = 0
for cmb in Cmb(L, 3):
    a = cmb[0]
    b = cmb[1]
    c = cmb[2]
    if a < b + c and b < c + a and c < a + b:
        count += 1
print(count)
    

Fixed submission:
n = int(input())
L = sorted(list(map(int, input().split())), reverse=True)
L.append(0)

def is_ok(arg):
    # 条件を満たすかどうか？問題ごとに定義
    judge = L[i] < L[j] + L[arg]
#    print(judge, i, j, arg, L[i], L[j], L[arg])
    return judge

def meguru_bisect(ng, ok):
    '''
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義すべし
    ng ok は  とり得る最小の値-1 とり得る最大の値+1
    最大最小が逆の場合はよしなにひっくり返す
    '''
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok

count = 0
for i in range(n):
    for j in range(i+1, n):
        k = meguru_bisect(n+1, j)
        if k > j:
            #print(i, j, k, L[i], L[j], L[k])
            count += k - j
print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))

D  = [0 for _ in range(N-1)]
for i in range(N-1):
    if H[i] >= H[i+1]:
        D[i] = 1

from itertools import groupby
DC = [sum(item) for val, item in groupby([1 if x == 1 else 0 for x in D])]
print(max(DC))

Fixed submission:
N = int(input())
H = list(map(int, input().split()))

D  = [0 for _ in range(N-1)]
for i in range(N-1):
    if H[i] >= H[i+1]:
        D[i] = 1

from itertools import groupby
DC = [sum(item) for val, item in groupby([1 if x == 1 else 0 for x in D])]
if DC == []:
    print(0)
else:
    print(max(DC))

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

D  = [0 for _ in range(N-1)]
for i in range(N-1):
    if H[i] >= H[i+1]:
        D[i] = 1

from itertools import groupby
DC = [sum(item) for val, item in groupby([1 if x == 1 else -1 for x in D])]
print(max(DC))

Fixed submission:
N = int(input())
H = list(map(int, input().split()))

D  = [0 for _ in range(N-1)]
for i in range(N-1):
    if H[i] >= H[i+1]:
        D[i] = 1

from itertools import groupby
DC = [sum(item) for val, item in groupby([1 if x == 1 else 0 for x in D])]
if DC == []:
    print(0)
else:
    print(max(DC))
Buggy python submission (verdict: Runtime Error):
N = int(input())
print(N*(n-1)//2)

Fixed submission:
N = int(input())
print(N*(N-1)//2)
Buggy python submission (verdict: Runtime Error):
import math
N, K = map(int, input().split())

B = [[] for _ in range(N)]
for i, a in enumerate(range(1, N+1)):
    B[i] = max(math.ceil(math.log2(K/a)), 0)
#print(B)

ans = 0
for b in B:
    ans += 1/2**b
print(ans/N)

Fixed submission:
import math
N, K = map(int, input().split())

B = [[] for _ in range(N)]
for i, a in enumerate(range(1, N+1)):
    B[i] = max(math.ceil(math.log2(K/a)), 0)
#print(B)

ans = 0
for b in B:
    ans += 1/2**b
print(ans/N)
Buggy python submission (verdict: Runtime Error):
from collections import Counter

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


ans = 1
C = Counter(prime_factorize(P))
#print(C)
for item in C.items():
    i = item[0]
    v = item[1]
    if v >= N:
        ans *= i**(v//N)
print(ans)

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

from collections import Counter

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


ans = 1
C = Counter(prime_factorize(P))
#print(C)
for item in C.items():
    i = item[0]
    v = item[1]
    if v >= N:
        ans *= i**(v//N)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
PY = [list(map(int, input().split())) for _ in range(M)]

A = [[] for _ in range(N+1)]
for py in PY:
    A[py[0]].append(py[1])

for i in range(N+1):
    A[i] = sorted(A[i])

for py in PY:
    pref = py[0]
    city = A[pref].index(py[1])+1
    print(str(pref).zfill(6) + str(city).zfill(6))

Fixed submission:
N, M = map(int, input().split())
PY = [list(map(int, input().split())) for _ in range(M)]

A = [[] for _ in range(N+1)]

for i, py in enumerate(PY):
    A[py[0]].append([py[1], i])

City = []
for i in range(N+1):
    A[i] = sorted(A[i])
    for j, a in enumerate(A[i]):
        pref = i
        city = j+1
        City.append([a[1], str(pref).zfill(6) + str(city).zfill(6)])

City = sorted(City)
for city in City:
    print(city[1])
Buggy python submission (verdict: Runtime Error):
n = int(input())
V = list(map(int, input().split()))

from collections import Counter

C0 = Counter(V[0::2])
C1 = Counter(V[1::2])

n0 = C0.most_common()[0][0]
n1 = C1.most_common()[0][0]



if n0 == n1:
    if C0.most_common()[1][1] >= C1.most_common()[1][1]:
        n0 = C0.most_common()[1][0]
    else:
        n1 = C1.most_common()[1][0]
    
count = 0
for v in V[0::2]:
    if v != n0:
        count += 1

for v in V[1::2]:
    if v != n1:
        count += 1
print(count)

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

import sys
from collections import Counter

C0 = Counter(V[0::2])
C1 = Counter(V[1::2])

n0 = C0.most_common()[0][0]
n1 = C1.most_common()[0][0]

minV = min(V)
if all([v == minV for v in V]):
    print(len(V)//2)
    sys.exit()

if n0 == n1:
    if C0.most_common()[1][1] >= C1.most_common()[1][1]:
        n0 = C0.most_common()[1][0]
    else:
        n1 = C1.most_common()[1][0]
    
count = 0
for v in V[0::2]:
    if v != n0:
        count += 1

for v in V[1::2]:
    if v != n1:
        count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
N = int(input())
T = [int(input()) for _ in range(N)]

import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

print(lcm_list(T))


Fixed submission:
N = int(input())
T = [int(input()) for _ in range(N)]

import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

print(lcm_list(T))