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

Fixed submission:
import collections
N=int(input())
lst=input().split()
s=0
dic=collections.Counter(lst)
for i in dic.values():
    s+=(i*i-i)//2
for i in lst:
    print(s+1-dic[i])

Buggy submission (verdict: Runtime Error):
def com(n):
    return n*(n-1)//2
ans=0
n=int(input())
a=list(map(int,input().split()))
coun=[0]*(n+1)
for i in range(n):
    coun[a[i]]+=1
foi i in range(n+1):
    ans+=com(coun[i])
for i in range(n):
    m=com(coun[a[i]]-1)
    o=com(coun[a[i]])
    print(ans-o+m)

Buggy submission (verdict: Runtime Error):
def com(n):
    return n*(n-1)//2
ans=0
n=int(input())
a=list(map(int,input().split()))
coun=[0]*n
for i in range(n):
    coun[a[i]]+=1
for i in range(n+1):
    ans+=com(coun[i])
for i in range(n):
    m=com(coun[a[i]]-1)
    o=com(coun[a[i]])
    print(ans-o+m)

Buggy submission (verdict: Runtime Error):
def com(n):
    return n*(n-1)//2
ans=0
n=int(input())
a=list(map(int,input().split()))
coun=[0]*n
for i in range(n+1):
    coun[a[i]]+=1
for i in range(n+1):
    ans+=com(coun[i])
for i in range(n+1):
    m=com(coun[a[i]]-1)
    o=com(coun[a[i]])
    print(ans-o+m)

Buggy submission (verdict: Runtime Error):
def com(n):
    return n*(n-1)//2
ans=0
n=int(input())
a=list(map(int,input().split()))
coun=[0]*n
for i in range(n):
    coun[a[i]]+=1
for i in range(n):
    ans+=com(coun[i])
for i in range(n):
    m=com(coun[a[i]]-1)
    o=com(coun[a[i]])
    print(ans-o+m)

Buggy submission (verdict: Runtime Error):
def com(n):
    return n*(n-1)//2
ans=0
n=int(input())
a=list(map(int,input().split()))
coun=[0]*n
for i in range(n):
    coun[a[i]]+=1
foi i in range(n):
    ans+=com(coun[i])
for i in range(n):
    m=com(coun[a[i]]-1)
    o=com(coun[a[i]])
    print(ans-o+m)

Buggy submission (verdict: Runtime Error):
import collections
N=int(input())
lst=input().split()
s=0
dic=collections.Counter(lst)
for i in dic.values():
    s+=(i*i-i)//2
for i in lst:
    print(s+1-dict[i])
Problem p02767 (python)

Fixed submission:
N=int(input())
lst=list(map(int,input().split()))
P=round(sum(lst)/N)
print(sum([(i-P)**2 for i in lst]))

Buggy submission (verdict: Runtime Error):
N=int(input())
lst=list(map(int,input().split()))
P=round(sum(lst)/N)
print(sum[(i-P)**2 for i in lst])

Buggy submission (verdict: Runtime Error):
N=int(input())
lst=list(map(int,input().split()))
P=round(lst/N)
print(sum[(i-P)**2 for i in lst])
Problem p03544 (python)

Fixed submission:
print([2,1,3,4,7,11,18,29,47,76,123,199,322,521,843,1364,2207,3571,5778,9349,15127,24476,39603,64079,103682,167761,271443,439204,710647,1149851,1860498,3010349,4870847,7881196,12752043,20633239,33385282,54018521,87403803,141422324,228826127,370248451,599074578,969323029,1568397607,2537720636,4106118243,6643838879,10749957122,17393796001,28143753123,45537549124,73681302247,119218851371,192900153618,312119004989,505019158607,817138163596,1322157322203,2139295485799,3461452808002,5600748293801,9062201101803,14662949395604,23725150497407,38388099893011,62113250390418,100501350283429,162614600673847,263115950957276,425730551631123,688846502588399,1114577054219522,1803423556807921,2918000611027443,4721424167835364,7639424778862807,12360848946698171,20000273725560978,32361122672259149,52361396397820127,84722519070079276,137083915467899403,221806434537978679,358890350005878082,580696784543856761,939587134549734843][int(input())])

Buggy submission (verdict: Runtime Error):
print([2,1,3,4,7,11,18,29,47,76,123,199,322,521,843,1364,2207,3571,5778,9349,15127,24476,39603,64079,103682,167761,271443,439204,710647,1149851,1860498,3010349,4870847,7881196,12752043,20633239,33385282,54018521,87403803,141422324,228826127,370248451,599074578,969323029,1568397607,2537720636,4106118243,6643838879,10749957122,17393796001,28143753123,45537549124,73681302247,119218851371,192900153618,312119004989,505019158607,817138163596,1322157322203,2139295485799,3461452808002,5600748293801,9062201101803,14662949395604,23725150497407,38388099893011,62113250390418,100501350283429,162614600673847,263115950957276,425730551631123,688846502588399,1114577054219522,1803423556807921,2918000611027443,4721424167835364,7639424778862807,12360848946698171,20000273725560978,32361122672259149,52361396397820127,84722519070079276,137083915467899403,221806434537978679,358890350005878082,580696784543856761][int(input())])
Problem p02548 (python)

Fixed submission:
def main():
    n = int(input())
    ans = 0
    for a in range(1, n):
        ans += (n-1) // a
    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math
import sympy


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

    dp = [0] * (n+1)
    dp[0] = 0
    dp[1] = 0
    for i in range(2, n+1):
        dp[i] = dp[i-1] + sympy.divisor_count(i-1)

    print(dp[-1])


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math
import sympy


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

    dp = [0] * (n+1)
    dp[0] = 0
    dp[1] = 0
    for i in range(2, n+1):
        dp[i] = dp[i-1] + sympy.divisor_count(i-1)

    print(dp[-1])


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sympy



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

    dp = [0] * (n+1)
    dp[0] = 0
    dp[1] = 0
    for i in range(2, n+1):
        dp[i] = dp[i-1] + len(sympy.divisors(i-1))

    print(dp[-1])


if __name__ == '__main__':
    main()
Problem p02813 (python)

Fixed submission:
import math
import copy


def main():
    n = int(input())
    p = list(map(int, input().split()))
    q = list(map(int, input().split()))

    p_order = 1
    q_order = 1

    p_diff = []
    q_diff = []
    p_sort = list(range(1, 9))
    q_sort = list(range(1, 9))

    for i in range(n):
        # 残っている要素の下から何番目かを順番に特定する
        p_diff.append(p_sort.index(p[i]))
        q_diff.append(q_sort.index(q[i]))
        p_sort.remove(p[i])
        q_sort.remove(q[i])

    for i in range(n):
        rest_p = len(p_diff[i+1:]) if i < n else 0
        rest_q = len(q_diff[i+1:]) if i < n else 0
        p_order += p_diff[i] * math.factorial(rest_p)
        q_order += q_diff[i] * math.factorial(rest_q)

    answer = abs(p_order - q_order)
    print(answer)


'''
    while p != []:
        i = 0
        diff = p[i] - min(p)
        if diff > 2:
            p_order += math.factorial(len(p) - 1)
        p.pop(i)
'''

'''
    pq_diff = [p[i] - q[i] for i in range(n)]

    answer = 0
    for i in range(n):
        if pq_diff[i] == 0:
            continue
        answer += (pq_diff[i] - 1) * math.factorial(n-i-1)
    print(answer
'''


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
    n = int(input())
    p = tuple(map(int, input().split()))
    q = tuple(map(int, input().split()))

    s = itertools.permutations(range(1, n+1))
    l = []
    for v in s:
        l.append(v)
    p_index = l.index(p)
    q_index = l.index(q)

    print(abs(p_index - q_index))
Problem p03136 (python)

Fixed submission:
def main():
    n = int(input())
    l = list(map(int, input().split()))

    max_l = max(l)
    l.remove(max_l)

    sum_exc_l = sum(l)

    if max_l < sum_exc_l:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    l = list(map(int, input().split()))

    max_l = max(l)
    exc_l = l.remove(max_l)

    sum_exc_l = sum(exc_l)

    if max_l < sum_exc_l:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()
Problem p02582 (python)

Fixed submission:
s = input()
ans = 0
if s == 'SSS':
    print(0)
elif s == 'SSR' or s == 'RSS' or s == 'SRS' or s == 'RSR':
    print(1)
elif s == 'SRR' or s == 'RRS':
    print(2)
else:
    print(3)

Buggy submission (verdict: Runtime Error):
s = input()
ans = 0
if s == 'SSS':
    print(3)
elif s == 'SSR' or s == 'RSS':
    print(2)
elif s == 'SRR' or s == 'RSR' s == 'RRS' or s == 'SRS':
    print(1)
else:
    print(0)
Problem p02658 (python)

Fixed submission:
import sys
N = int(input())
num_list = [int(i) for i in input().split()]
if 0 in num_list:
  print(0)
else:
  mul = 1
  for a in num_list:
    mul *= a
    if mul > 10**18:
      print(-1)
      sys.exit()
  print(mul)

Buggy submission (verdict: Runtime Error):
import sys
N = int(input())
num_list = 0
for i in range(N):
  a = int(input())
  num_list.append(a)
if 0 in num_list:
  print(0)
else:
  mul = 1
  for a in num_list:
    mul *= a
    if mul > 10**18:
      print(-1)
      sys.exit()
  print(mul)
Problem p02732 (python)

Fixed submission:
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]

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

m = Counter(A)
s = 0
for x, y in m.items():
    if y != 1:
        s += c(y)
for a in A:
    print(s - (m[a] - 1))

Buggy submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]

f_list = [0 for i in range(N+1)]
f_list[0] = 1
for i in range(1, N+1):
    f_list[i] = f_list[i-1]*i

def c(n):
    return f_list[n]//f_list[n-2]//2

m = Counter(A)
s = 0
for x, y in m.items():
    else:
        s += c(y)
for a in A:
    print(s - (m[a] - 1))

Buggy submission (verdict: Runtime Error):
from collections import Counter, defaultdict
N = int(input())
A = [int(i) for i in input().split()]

f_list = [0 for i in range(N+1)]
f_list[0] = 1
for i in range(1, N+1):
    f_list[i] = f_list[-1]*i

def c(n):
    return f_list[n]//f_list[n-2]//2

m = Counter(A)
ans = defaultdict(int)
s = 0
for x, y in m.items():
    if y == 1:
        ans[x] = 0
    else:
        ans[x] = c(y)
        s += ans[x]
for a in A:
    print(s - (m[a] - 1))
Problem p02744 (python)

Fixed submission:
from collections import deque
import sys
n = int(input())
if n == 1:
    print('a')
    sys.exit()

q = deque([])
q.append((1, 'a', '1'))
cur = 1
while cur != n:
    num = len(q)
    j = 0
    while j < num:
        a, b, c = q.popleft()
        for i in range(1, max(map(int, list(c)))+2):
            q.append((i, b + chr(96+i), c + str(i)))
        j += 1
    cur += 1

for i in range(len(q)):
    a, b, c = q.popleft()
    print(b)

Buggy submission (verdict: Runtime Error):
from collections import deque
import sys
n = int(input())
if n == 1:
    print('a')
    sys.exit()

q = deque([])
q.append((1, 'a', 1))
cur = 1
while cur != n:
    num = len(q)
    j = 0
    while j < num:
        a, b, c = q.popleft()
        for i in range(1, c+2):
            q.append((i, b + chr(96+i), max(map(int, list(b + chr(96+i)))))
        j += 1
    cur += 1

for i in range(len(q)):
    a, b, c = q.popleft()
    print(b)

Buggy submission (verdict: Runtime Error):
from collections import deque
import sys
n = int(input())
if n == 1:
    print('a')
    sys.exit()

q = deque([])
q.append((1, '1', 1))
cur = 1
while cur != n:
    num = len(q)
    j = 0
    while j < num:
        a, b, c = q.popleft()
        for i in range(1, c+2):
            q.append((i, b + str(i), max(i, a)))
        j += 1
    cur += 1

d = dict()
for i in range(1, n+1):
    d[str(i)] = chr((i-1) + 97)

for i in range(len(q)):
    a, b, c = q.popleft()
    print(b.translate(str.maketrans(d)))

Buggy submission (verdict: Runtime Error):
from collections import deque
import sys
n = int(input())
if n == 1:
    print('a')
    sys.exit()

q = deque([])
q.append((1, '1'))
cur = 1
while cur != n:
    num = len(q)
    j = 0
    while j < num:
        a, b = q.popleft()
        for i in range(1, a+2):
            q.append((i, b + str(i)))
        j += 1
    cur += 1

d = dict()
for i in range(1, n+1):
    d[str(i)] = chr((i-1) + 97)

for i in range(len(q)):
    a, b = q.popleft()
    print(b.translate(str.maketrans(d)))
Problem p02768 (python)

Fixed submission:
from functools import reduce
n, a, b = map(int, input().split())
mod = 10**9 + 7

def f(A):
    bunsi = reduce(lambda x, y: x*y%mod, range(n, n-A, -1))
    bunbo = reduce(lambda x, y: x*y%mod, range(1, A+1))
    return bunsi * pow(bunbo, mod-2, mod) % mod

ans = pow(2, n, mod) - f(a) -f(b) - 1
ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
from functools import reduce
n, a, b = map(int, input().split())
mod = 10**9 + 7

def f(A):
    bunsi = reduce(lambda x, y: x*y%mod, range(N, N-A, -1))
    bunbo = reduce(lambda x, y: x*y%mod, range(1, A+1))
    return bunsi * pow(bunbo, mod-2, mod) % mod
  
ans = pow(2, n, mod) - f(a) -f(b) - 1
ans %= mod
print(ans)
Problem p02801 (python)

Fixed submission:
a = input()
print(chr(ord(a)+1))

Buggy submission (verdict: Runtime Error):
a = input()
print(char(ord(a)+1))
Problem p02817 (python)

Fixed submission:
ls = list(map(str, input().split()))
print(ls[1]+ls[0])

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
print(a+b)

Buggy submission (verdict: Runtime Error):
print(input()+input())
Problem p02883 (python)

Fixed submission:
def main():
    import copy
    from heapq import heappop, heapify, heappush
    import math
    N, K = map(int, input().split())
    A = [int(i) for i in input().split()]
    F = [int(i) for i in input().split()]
    ans = 0
    A.sort(reverse=True)
    F.sort()
    s = []
    for i in range(N):
        s.append([A[i]*F[i], A[i], F[i]])
    s.sort(reverse=True, key=lambda x: x[0])

    def f(S, T):
        cur = 0
        num = 0
        while cur <= K:
            if num == N:
                break
            a, b, c = S[num]
            if a <= T:
                break
            cur += math.ceil((a - T)/c)
            num += 1
        if cur <= K:
            return True
        else:
            return False

    ok, ng = s[0][0], -1
    while abs(ok-ng) > 1:
        mid = (ok+ng)//2
        if f(s, mid) == True:
            ok = mid
        else:
            ng = mid
    print(ok)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import copy
from heapq import heappop, heapify, heappush
import math
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
F = [int(i) for i in input().split()]
ans = 0
A.sort(reverse=True)
F.sort()
s = []
for i in range(N):
    s.append([A[i]*F[i], A[i], F[i]])
s.sort(reverse=True, key=lambda x: x[0])

def f(l, T):
    cur = 0
    num = 0
    S = copy.deepcopy(l)
    while cur <= K:
        if len(S) == 0:
            break
        a, b, c = S[num]
        if a <= T:
            break
        cur += math.ceil((a - T)/c)
        num += 1
    if cur <= K:
        return True
    else:
        return False

ok, ng = s[0][0], -1
while abs(ok-ng) > 1:
    mid = (ok+ng)//2
    if f(s, mid) == True:
        ok = mid
    else:
        ng = mid
print(ok)
Problem p02936 (python)

Fixed submission:
from collections import deque

n, q = map(int, input().split())
# 隣接リストを作成
adj = [[] for i in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)

queries = [0 for i in range(n)]
for i in range(q):
    p, x = map(int, input().split())
    queries[p-1] += x

ans = [0 for i in range(n)]

# スタックによるdfs(位置, 上からの加算, 親の位置)
st = deque([(0,0,-1)])
# stが空になるまで操作
while st:
    l = st.pop()
    ans[l[0]] = l[1] + queries[l[0]]
    for v in adj[l[0]]:
        if v != l[2]:
            st.append((v, ans[l[0]], l[0]))
print(*ans)

Buggy submission (verdict: Runtime Error):
from collections import deque

n, q = map(int, input().split())
# 隣接リストを作成
adj = [[] for i in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)

queries = [0 for i in range(n)]
for i in range(q):
    p, x = map(int, input().split())
    queries[p-1] += x

ans = [0 for i in range(n)]

# スタックによるdfs(位置, 上からの加算, 親の位置)
st = deque([(0,0,-1)])
# stが空になるまで操作
while st:
    l = st.pop()
    ans[l[0]] = l[1] + queries[l[0]]
    for v in adj[l[0]]:
        if v != l[2]:
            st.append((v, ans[l[0], l[0]]))
print(*ans)
Problem p02983 (python)

Fixed submission:
import sys
L, R= map(int, input().split())
ans = []
for i in range(L, R):
    for j in range(i+1, R+1):
        if (i*j)%2019 == 0:
            print(0)
            sys.exit()
        else:
            ans.append((i*j)%2019)
print(min(ans))

Buggy submission (verdict: Runtime Error):
L, R= map(int, input().split())
ans = []
for i in range(L, R):
    for j in range(i+1, R+1):
        if (i*j)%2019 == 0:
            print(0)
            sys.exit()
        else:
            ans.append((i*j)%2019)
print(min(ans))

Buggy submission (verdict: Runtime Error):
L, R= map(int, input().split())
L, R = L%2019, R%2019
ans = []
for i in range(L, R):
    for j in range(i+1, R+1):
        ans.append((i*j)%2019)
print(min(ans))
Problem p03007 (python)

Fixed submission:
import sys
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
a = A[0]
b = A[-1]
if N == 2:
    print(A[1]-A[0])
    print(A[1],A[0])
    sys.exit()
ans = []
for x in A[1:-1]:
    if x <= 0:
        ans.append([b, x])
        b = b - x
    else:
        ans.append([a, x])
        a = a - x
ans.append([b,a])
M = b-a
print(M)
for x in ans:
    print(x[0], x[1])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
a = A[0]
b = A[-1]
if N == 2:
    print(A[1]-A[0])
    print(A[1],A[0])
    sys.exit()
ans = []
for x in A[1:-1]:
    if x <= 0:
        ans.append([b, x])
        b = b - x
    else:
        ans.append([a, x])
        a = a - x
ans.append([b,a])
M = b-a
print(M)
for x in ans:
    print(x[0], x[1])
Problem p03029 (python)

Fixed submission:
A, P = map(int, input().split())
print((3*A+P)//2)

Buggy submission (verdict: Runtime Error):
A, P = map(int, input().split())
print((3*A+P)//2)Ｖ
Problem p03031 (python)

Fixed submission:
from itertools import product
N, M = map(int, input().split())
denkyu = []
for i in range(M):
    denkyu.append([int(j) for j in input().split()])
p = [int(i) for i in input().split()]
ls = [0, 1]
ans = 0
for x in product(ls, repeat=N):
    num = 0
    for j, denkyu_ in enumerate(denkyu):
        num_light_on = 0
        for i, s in enumerate(denkyu_):
            if i != 0 and x[s-1] == 1:
                num_light_on += 1
        if num_light_on%2 == p[j]:
            num += 1
    if num == M:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import product
N, M = map(int, input().split())
denkyu = []
for i in range(M):
    denkyu.append([int(j) for j in input().split()])
p = [int(i) for i in input().split()]
ls = [0, 1]
ans = 0
for x in product(ls, repeat=N):
    num = 0
    for denkyu_, j in enumerate(denkyu):
        judge_light_on = 0
        for s, i in enumerate(denkyu_):
            if i != 0 and x[s-1] == 1:
                judge_light_on += 1
        if judge_light_on%2 == p[j]:
            num += 1
    if num == 0 or num == M:
        ans += 1
print(ans)
Problem p03032 (python)

Fixed submission:
N, K = map(int, input().split())
V = [int(i) for i in input().split()]
ans = 0
for M in range(K+1):
    for m in range(M+1):
        ls = []
        for i, x in enumerate(V):
            if i < m:
                ls.append(x)
        for i, x in enumerate(V[::-1]):
            if i < min(M-m, N-m):
                ls.append(x)
        ls.sort()
        s = sum(ls)
        for i, x in enumerate(ls):
            if i < K-M and x < 0:
                s -= x
        ans = max(ans, s)
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
V = [int(i) for i in input().split()]
ans = 0
for M in range(K+1):
    for m in range(M+1):
        ls = []
        cur1 = 0
        for i, x in enumerate(V):
            if i < m:
                ls.append(x)
                cur += 1
        cur2 = 0
        for i, x in enumerate(V[::-1]):
            if i < min(M-m, N-cur1):
                ls.append(x)
                cur2 += 1
        ls.sort()
        s = sum(ls)
        for i, x in enumerate(ls):
            if i < K-(cur1+cur2):
                s -= x
        ans = max(ans, s)
print(ans)
Problem p03106 (python)

Fixed submission:
A, B, K = map(int, input().split())

ans = []

for i in range(1, min(A, B)+1):
    if A%i == 0 and B%i == 0:
        ans.append(i)
ans.sort(reverse=True)
print(ans[K-1])

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())

ans = []

for i in range(1, max(A, B)):
    if A%i == 0 and B%i == 0:
        ans.append(i)
ans.reverse()
print(ans[K-1])

Buggy submission (verdict: Runtime Error):
A, B, K = map(int, input().split())

ans = []

for i in range(1, max(A, B)):
    if A%i == 0 and B%i == 0:
        ans.append(i)
print(ans[K-1])
Problem p03110 (python)

Fixed submission:
N = int(input())
x = [0]*N
u = [0]*N
for i in range(N):
    x[i], u[i] = input().split()
y = list(map(float, x))

ans = 0
for i in range(N):
    if u[i] == 'JPY':
        ans += y[i]
    else:
        ans += y[i]*380000
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
x = [0]*N
u = [0]*N
for i in range(N):
    x[i], u[i] = [int(i) for i in input().split()]

ans = 0
for i in range(N):
    if u[i] == 'JPY':
        ans += x[i]
    else:
        ans += x[i]*380000
print(ans)
Problem p03194 (python)

Fixed submission:
N, P = [int(i) for i in input().strip().split()]
dic={}
ans = 1

if N == 1:
    print(P)
    quit()
elif P == 1:
    print(1)
    quit()
    
for i in range(2,int(P**(1/2))+1):
    num = 0
    while P%i == 0:
        num = num +1
        P = int(P/i)
    dic[i] = num//N
    ans = ans*(i**(dic[i]))

print(ans)

Buggy submission (verdict: Runtime Error):
M, P = [int(i) for i in input().strip().split()]
dic={}

import numpy as np

def seachPrimeNum(N):
    max = int(np.sqrt(N))
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum

for i in seachPrimeNum(P):
    num = 0
    while P%i == 0:
        num = num +1
        P = P/i
        dic[i] = num
        
ans = 1
for i in dic:
    if M == 1:
        ans = P
        break
    elif dic[i] != 0:
        ans = ans*(i**(dic[i]//M))
print(ans)

Buggy submission (verdict: Runtime Error):
N, P = [int(i) for i in input().strip().split()]
dic={}

import numpy as np

def seachPrimeNum(N):
    max = int(np.sqrt(N))
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum

for i in seachPrimeNum(P):
    num = 0
    while P%i == 0:
        num = num +1
        P = P/i
        dic[i] = num
        
ans = 1
for i in dic:
    if N == 1:
        ans = P
        break
    elif dic[i] != 0:
        ans = ans*(i**(dic[i]//N))
print(ans)

Buggy submission (verdict: Runtime Error):
N, P = [int(i) for i in input().strip().split()]
dic={}

for i in range(2,int(P**(1/2))+1):
    num = 0
    while P%i == 0:
        num = num +1
        P = P/i
    dic[i] = num
    
for i in dic:
    for j in dic:
        if i < j:
            if j%i == 0:
                del dic[j]
                
ans = 1
for i in dic:
    if N == 1:
        ans = P
        break
    elif dic[i] != 0:
        ans = ans*(i**(dic[i]//N))
print(ans)

Buggy submission (verdict: Runtime Error):
N, P = [int(i) for i in input().strip().split()]
dic={}

for i in range(2,int(P**(1/2))+1):
    num = 0
    while P%i == 0:
        num = num +1
        P = P/i
    dic[i] = num
    
for i in range(dic):
    for j in range(dic):
        if i < j:
            if j%i == 0:
                del dic[j]
                
ans = 1
for i in dic:
    if N == 1:
        ans = P
        break
    elif dic[i] != 0:
        ans = ans*(i**(dic[i]//N))
print(ans)

Buggy submission (verdict: Runtime Error):
N, P = [int(i) for i in input().strip().split()]
dic={}

for i in range(2,int(P**(1/2))+1):
    num = 0
    while P%i == 0:
        num = num +1
        P = P/i
    dic[i] = num
    
ans = 1
for i in dic:
    if dic[i] != 0:
        ans = ans*(i**(dic[i]//N))
if N = 1:
    ans = P
print(ans)