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

Fixed submission:
x = int(input())
for i in range(1000):
    for j in range(i):
        if i ** 5 - j ** 5 == x:
            print(i, j)
            exit()
        if i ** 5 + j ** 5 == x:
            print(i, -j)
            exit()

Buggy submission (verdict: Runtime Error):
import math
X = int(input())
is_prime = [False] * 2 + [True] * (X + 5)
prime_factors = {}
sup = int(math.sqrt(X)) + 5
ans = (0, 0)
# t := A - B
# A - B > 0 and A >= 0
def dfs(t, key_prime):
    global prime_factors, X, ans
    if key_prime >= len(prime_factors):
        return

    a = 0
    b = a - t
    Y = (a ** 5 - b ** 5) // t
    temp_X = X // t
    while Y <= temp_X:
        if Y == temp_X:
            ans = (a, b)
            return
        a += 1
        b = a - t
        Y = (a ** 5 - b ** 5) // t
        
    dfs(t, key_prime + 1)
    num_prime = list(prime_factors.keys())[key_prime]
    for _ in range(num_prime):
        t *= num_prime
        a = 0
        b = a - t
        Y = (a ** 5 - b ** 5) // t
        temp_X = X // t
        while Y <= temp_X:
            if Y == temp_X:
                ans = (a, b)
                return
            a += 1
            b = a - t
            Y = (a ** 5 - b ** 5) // t
        dfs(t, key_prime + 1)



for i in range(2, sup):
    if is_prime[i]:
        for j in range(i * i, X + 7, i):
            is_prime[j] = False

temp_X = X
for i in range(X + 5):
    if is_prime[i] and temp_X % i == 0:
        prime_factors[i] = 0
        while temp_X % i == 0:
            prime_factors[i] += 1
            temp_X //= i

if X == 1:
    print(1, 0)
else:
    dfs(1, 0)
    print(ans[0], ans[1])
Problem p02814 (python)

Fixed submission:
import math
def LCM(a, b):
    g = math.gcd(a, b)
    return a * b // g

N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(set(A))
N = len(A)
a0 = A[0]
div = 1
while a0 % 2 == 0:
    div *= 2
    a0 //= 2

for i in range(1, N):
    a = A[i] % div
    b = A[i] // div
    if (b % 2 == 0) or (a != 0):
        print(0)
        exit()

for i in range(N):
    A[i] //= 2

if N > 1:
    lcm = LCM(A[0], A[1])
    for i in range(2, N):
        lcm = LCM(lcm, A[i])

if N == 1:
    lcm = A[0]

ans = M // lcm
if ans % 2 == 1:
    print(ans // 2 + 1)
else:
    print(ans // 2)

Buggy submission (verdict: Runtime Error):
import math
def lcm(a, b):
    g = math.gcd(a, b)
    return a * b // g

N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(set(A))
N = len(A)
a0 = A[0]
div = 1
while a0 % 2 == 0:
    div *= 2
    a0 //= 2

for i in range(1, N):
    a = A[i] % div
    b = A[i] // div
    if (b % 2 == 0) or (a != 0):
        print(0)
        exit()

for i in range(N):
    A[i] //= 2

if N > 1:
    lcm = lcm(A[0], A[1])
    for i in range(2, N):
        lcm = lcm(lcm, A[i])

if N == 1:
    lcm = A[0]

ans = M // lcm
if ans % 2 == 1:
    print(ans // 2 + 1)
else:
    print(ans // 2)

Buggy submission (verdict: Runtime Error):
import math
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(set(A))
N = len(A)
for i in range(N):
    A[i] //= 2

for i in range(N):
    if N > 1: 
        gcd = math.gcd(A[0], A[1])
        for i in range(2, N):
            gcd = math.gcd(gcd, A[i])

lcm = gcd
for i in range(N):
    lcm *= A[i] // gcd

print((M - lcm) // lcm // 2 + 1)
Problem p02642 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
a.sort()
mx = a[-1]
c = [0 for _ in range(mx+1)]
ans = 0
if a[0] == 1:
  if n == 1:
    print(1)
    exit()
  if a[1] == 1:
    print(0)
    exit()
  else:
    print(1)
    exit()
i = 0
while i < n:
  if c[a[i]] == 0:
    p = a[i]
    for _ in range(2,mx//a[i]+1):
      p += a[i]
      c[p] = 1
    flag = True
    while i+1 < n and a[i+1] == a[i]:
      i += 1
      flag = False
    if flag:
      ans += 1
  i += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
a.sort()
mx = a[-1]
c = [0 for _ in range(mx+1)]
ans = 0
if a[0] == 1:
  if a[1] == 1:
    print(0)
    exit()
  else:
    print(n)
    exit()
i = 0
while i < n:
  if c[a[i]] == 0:
    p = a[i]
    for _ in range(2,mx//a[i]+1):
      p += a[i]
      c[p] = 1
    flag = True
    while i+1 < n and a[i+1] == a[i]:
      i += 1
      flag = False
    if flag:
      ans += 1
  i += 1
print(ans)
Problem p02714 (python)

Fixed submission:
import sys
input = sys.stdin.readline
n = int(input())
s = str(input())
r = 0
g = 0
for i in range(n):
  if s[i] == "R":
    r += 1
  elif s[i] == "G":
    g += 1
c = r*g*(n-r-g)
for j in range(1,n-1):
  for i in range(1,min(n-j-1,j)+1):
    if (s[j-i] != s[j]) and (s[j] != s[j+i]) and (s[j+i] != s[j-i]):
      c -= 1
print(c)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = str(input())
r = []
g = []
b = []
for i in range(n):
  if s[i] == "R":
    r.append(i)
  elif s[i] == "G":
    g.append(i)
  else:
    b.append(i)
c = len(r)*len(g)*len(b)
for ri in r:
  for gi in g:
    for bi in b:
      if 3*(max(ri,gi,bi)+min(ri,gi,bi)) == 2*sum(ri,gi,bi):
        c -= 1
print(c)
Problem p02715 (python)

Fixed submission:
n,k = map(int,input().split())
x = [0]*k
mod = 10**9+7
def power(a,n):
  ans = 1
  while n:
    if n%2:
      ans = (ans*a)%mod
    a = (a*a)%mod
    n >>= 1
  return ans%mod  
for i in range(k,0,-1):
  c = power(k//i,n)
  j = 2
  while i*j <= k:
    c -= x[i*j-1]
    j += 1
  x[i-1] = c
s = 0
for i in range(1,k+1):
  s = (s + i*x[i-1])%mod
print(s)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
n = int(input())
s = str(input())
r = []
g = []
b = []
ra = r.append
ga = g.append
ba = b.append
for i in range(n):
  if s[i] == "R":
    ra(i)
  elif s[i] == "G":
    ga(i)
  else:
    ba(i)
c = len(r)*len(g)*len(b)
for ri in r:
  for gi in g:
    for bi in b:
      if 3*(max(ri,gi,bi)+min(ri,gi,bi)) == 2*(ri+gi+bi):
        c -= 1
print(c)
Problem p02756 (python)

Fixed submission:
s = str(input())
q = int(input())
state = True
front = ""
ending = ""
for _ in range(q):
  qi = str(input())
  if qi[0] == "2":
    fi,ci = map(str,qi[2:].split())
    if state == True:
      if fi == "1":
        front += ci
      else:
        ending += ci
    else:
      if fi == "1":
        ending += ci
      else:
        front += ci
  else:
    state = not state
if state:
  first = front[::-1]
  lastt = ending
else:
  first = ending[::-1]
  lastt = front
  s = s[::-1]
print(first+s+lastt)

Buggy submission (verdict: Runtime Error):
s = str(input())
q = int(input())
state = True
front = ""
ending = ""
for _ in range(q):
  qi = str(input())
  if qi[0] == "2":
    fi,ci = map(str,qi[2:].split())
    if state == True:
      if fi == "1":
        front += ci
      else:
        ending += ci
    else:
      if fi == "1":
        ending += ci
      else:
        front += ci
  else:
    state = not state
if state:
  first = front[::-1]
  lastt = ending
else:
  first = ending[::-1]
  lastt = front
  s = s[::-1]
for f in first:
  print(f,end="")
for si in s:
  print(s,end="")
for l in lastt:
  print(l,end="")

Buggy submission (verdict: Runtime Error):
s = str(input())
q = int(input())
state = True
front = ""
end = ""
for _ in range(q):
  qi = str(input())
  if qi[0] == "2":
    fi,ci = map(str,qi[2:].split())
    if state == True:
      if fi == "1":
        front += ci
      else:
        end += ci
    else:
      if fi == "1":
        end += ci
      else:
        front += ci
  else:
    state = not state
if state:
  first = front[::-1]
  last = end
else:
  first = end[::-1]
  last = front
  s = s[::-1]
for f in first:
  print(f,end="")
for si in s:
  print(s,end="")
for l in last:
  print(l,end="")

Buggy submission (verdict: Runtime Error):
s = str(input())
q = int(input())
state = True
front = ""
end = ""
for _ in range(q):
  qi = str(input())
  if qi[0] == "2":
    fi,ci = map(str,qi[2:].split())
    if state == True:
      if fi == "1":
        front += ci
      else:
        end += ci
    else:
      if fi == "1":
        end += ci
      else:
        front += ci
  else:
    state = not state
if state:
  first = front[::-1]
  last = end
else:
  first = end[::-1]
  last = front
  s = s[::-1]
for f in first:
  print(f,end="")
for si in s:
  print(s,end="")
for l in last:
  print(l,end="")

Buggy submission (verdict: Runtime Error):
s = str(input())
q = int(input())
state = True
front = []
end = []
for _ in range(q):
  qi = str(input())
  if qi[0] == "2":
    fi,ci = map(str,qi[2:].split())
    if state == True:
      if fi == "1":
        front.append(ci)
      else:
        end.append(ci)
    else:
      if fi == "1":
        end.append(ci)
      else:
        front.append(ci)
  else:
    state = not state
if state:
  first = reversed(front)
  last = end
else:
  first = reversed(end)
  last = front
  s = s[::-1]
for f in first:
  print(f,end="")
for si in s:
  print(s,end="")
for l in last:
  print(l,end="")
Problem p02768 (python)

Fixed submission:
n,a,b = map(int,input().split())
def power(x,b):
  if x == 1:
    return b
  if x%2 == 0:
    return (power(x//2,b)**2)%(10**9+7)
  else:
    return (b*power(x-1,b))%(10**9+7)
ans = power(n,2)-1
x1 = 1
y1 = 1
x2 = 1
y2 = 1
for i in range(a):
  x1 = (x1*(n-i))%(10**9+7)
  y1 = (y1*(i+1))%(10**9+7)
for i in range(b):
  x2 = (x2*(n-i))%(10**9+7)
  y2 = (y2*(i+1))%(10**9+7)
ans -= x1*power(10**9+5,y1)
ans -= x2*power(10**9+5,y2)
print(ans%(10**9+7))

Buggy submission (verdict: Runtime Error):
n = int(input())
a,b = map(int,input().split())
def sp(n):
  	if n == 1:
    	return 2
  	if n%2 == 0:
    	return (sp(n//2)**2)%(10**9+7)
	if n%2 == 1:
  	  return (2*sp(n-1))%(10**9+7)
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


print((sp(n)-cmb(n,a,10**9+7)-cmb(n,b,10**9+7))%(10**9+7))

Buggy submission (verdict: Runtime Error):
n = int(input())
a,b = map(int,input().split())
def sp(n):
  if n == 1:
    return 2
  if n%2 == 0:
    return (sp(n//2)**2)%(10**9+7)
  if n%2 == 1:
    return (2*sp(n-1))%(10**9+7)
def com(n,a):
  if a == 1:
    return n
  return (com(n-1,a-1)+com(n-1,a))%(10**9+7)
print((sp(n)-com(n,a)-com(n,b))%(10**9+7))
Problem p02845 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
x = [0,0,0]
c = 1
for i in range(n):
  cc = 0
  k = 0
  for j in range(3):
    if a[i] == x[j]:
      cc += 1
      k = j
  c = (c*cc)%1000000007
  x[k] += 1
print(c)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = str(input())
c1 = [False for _ in range(10)]
c2 = [0 for _ in range(1000)]
count = 0
for i in range(n-2):
  si = int(s[i])
  if c1[si] != True:
    c1[si] = True
    c3 = [False for _ in range(10)]
    for j in range(i+1,n-1):
      sj = int(s[j])
      if c3[sj] != True:
        c3[sj] = True
        c4 = [False for _ in range(10)]
        for k in range(j+1,n):
          sk = int(s[k])
          if c4[sk] != True:
            c4[sk] = True
            count += 1
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = str(input())
c1 = [False for _ in range(10)]
c2 = [0 for _ in range(1000)]
count = 0
for i in range(n-2):
  si = int(s[i])
  if c1[si] != True:
    c1[si] = True
    c3 = [False for _ in range(10)]
    for j in range(i+1,n-1):
      sj = int(s[j])
      if c3[sj] != True:
        c3[sj] = True
        c4 = [False for _ in range(10)]
        for k in range(j+1,n):
          sk = int(s[k])
          if c4[sk] != True:
            c4[sk] = True
            count += 1
print(count)
Problem p02850 (python)

Fixed submission:
import sys
import resource
sys.setrecursionlimit(10**5)
n = int(input())
l = [[] for _ in range(n+1)]
s = [0 for _ in range(n+1)]
ll = []
for i in range(n-1):
  ai,bi = map(int,input().split())
  l[ai].append([bi,i])
  l[bi].append([ai,i])
  s[ai] += 1
  s[bi] += 1
mx = 0
for i in range(1,n+1):
  if s[i] > mx:
    mx = s[i]
    mxi = i
print(mx)
ans = [0 for _ in range(n-1)]
def dfs(a,b,c):
  i = 1
  for h,j in l[a]:
    if h != b:
      if i == c:
        i += 1
      ans[j] = i
      dfs(h,a,i)
      i += 1
  return
dfs(mxi,0,0)
for x in ans:
  print(x)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = [[] for _ in range(n+1)]
s = [0 for _ in range(n+1)]
ll = []
for i in range(n-1):
  ai,bi = map(int,input().split())
  l[ai].append([bi,i])
  l[bi].append([ai,i])
  s[ai] += 1
  s[bi] += 1
mx = 0
for i in range(1,n+1):
  if s[i] > mx:
    mx = s[i]
    mxi = i
print(mx)
ans = [0 for _ in range(n-1)]
def dfs(a,b,c):
  i = 1
  for h,j in l[a]:
    if h != b:
      if i == c:
        i += 1
      ans[j] = i
      dfs(h,a,i)
      i += 1
  return
dfs(mxi,0,0)
for a in ans:
  print(a)
Problem p02886 (python)

Fixed submission:
n = int(input())
d = list(map(int,input().split()))
print((sum(d)**2-sum(d[i]**2 for i in range(n)))//2)

Buggy submission (verdict: Runtime Error):
n = int(input().split())
d = list(map(int,input().split()))
print((sum(d)**2-sum(d[i]**2 for i in range(n)))//2)

Buggy submission (verdict: Runtime Error):
n = int(input().split())
d = list(map(int(input().split())))
print((sum(d)**2-sum(d[i]**2 for i in range(n)))//2)
Problem p02909 (python)

Fixed submission:
s = str(input())
loop = ["Sunny","Cloudy","Rainy"]
i = loop.index(s)
print(loop[(i+1)%3])

Buggy submission (verdict: Runtime Error):
s = str(input())
loop = ["Sunny","Cloudy","Rainy"]
i = loop.index(s)
print(loop((i+1)%3))
Problem p02936 (python)

Fixed submission:
from collections import deque
def submit():
  n,q = map(int,input().split())
  y = [[] for _ in range(n)]
  c = [0]*n
  for _ in range(n-1):
    ai,bi = map(int,input().split())
    y[ai-1].append(bi-1)
    y[bi-1].append(ai-1)
  for _ in range(q):
    pi,xi = map(int,input().split())
    c[pi-1] += xi
  z = deque([[0,-1]])
  while z:
    j,b = z.popleft()
    for yj in y[j]:
      if yj != b:
        z.append([yj,j])
        c[yj] += c[j]
  for i in range(n):
    print(c[i],end=" ")
submit()

Buggy submission (verdict: Runtime Error):
n,q = map(int,input().split())
y = [[] for _ in range(n)]
c = [0 for _ in range(n)]
for _ in range(n-1):
  ai,bi = map(int,input().split())
  y[ai-1].append(bi-1)
  y[bi-1].append(ai-1)
for _ in range(q):
  pi,xi = map(int,input().split())
  c[pi-1] += xi
def f(j,b):
  for yj in y[j]:
    if yj != b:
      c[yj] += c[j]
      f(yj,j)
f(0,-1)
for i in range(n):
  print(c[i],end=" ")
Problem p02947 (python)

Fixed submission:
n = int(input())
dic = {}
for _ in range(n):
  si = str(input())
  li = [si[i] for i in range(10)]
  li.sort()
  moji = "".join(li)
  if moji in dic.keys():
    dic[moji] += 1
  else:
    dic[moji] = 1
sm = 0
for j in dic.values():
  sm += j*(j-1)//2
print(sm)

Buggy submission (verdict: Runtime Error):
for _ in range(n):
  si = str(input())
  di = {}
  for i in range(10):
    if si[i] in di.keys():
      di[si[i]] += 1
    else:
      di[si[i]] = 1
  frag = True
  for j,st in enumerate(li[0]):
    if di == st:
      li[1][j] += 1
      frag = False
  if frag:
    li[0].append(di)
    li[1].append(1)
sm = 0
for j in li[1]:
  sm += j*(j-1)//2
print(sm)
Problem p02971 (python)

Fixed submission:
n = int(input())
mx = 0
smx = 0
mxi = 0
for i in range(n):
  ai = int(input())
  if ai > mx:
    smx = mx
    mx = ai
    mxi = i
  elif ai > smx:
    smx = ai
for j in range(mxi):
  print(mx)
print(smx)
for j in range(mxi+1,n):
  print(mx)

Buggy submission (verdict: Runtime Error):
n = int(input())
mx = 0
smx = 0
mxi = 0
for i in range(n):
  ai = int(input())
  if a[i] > mx:
    smx = mx
    mx = a[i]
    mxi = i
  elif a[i] > smx:
    smx = a[i]
for j in range(mxi):
  print(mx)
print(smx)
for j in range(mxi+1,n):
  print(mx)
Problem p02985 (python)

Fixed submission:
import sys
sys.setrecursionlimit(100000)
n,k = map(int,input().split())
x = [[] for _ in range(n+1)]
for _ in range(n-1):
  a,b = map(int,input().split())
  x[a].append(b)
  x[b].append(a)
ans = k
def search(i):
  l = len(x[i])
  if l == 0:
    return
  global ans
  for j in range(l):
    ans = (ans*(k-2-j))%1000000007
  for child in x[i]:
    x[child].remove(i)
    search(child)
l1 = len(x[1])
for j in range(l1):
  ans = (ans*(k-1-j))%1000000007
for child1 in x[1]:
  x[child1].remove(1)
  search(child1)
print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
x = [[] for _ in range(n+1)]
for _ in range(n-1):
  a,b = map(int,input().split())
  x[a].append(b)
  x[b].append(a)
ans = k
def search(i):
  l = len(x[i])
  if l == 0:
    return
  global ans
  for j in range(l):
    ans = (ans*(k-2-j))%1000000007
  for child in x[i]:
    x[child].remove(i)
    search(child)
l1 = len(x[1])
for j in range(l1):
  ans = (ans*(k-1-j))%1000000007
for child1 in x[1]:
  x[child1].remove(1)
  search(child1)
print(ans)
Problem p03160 (python)

Fixed submission:
n = int(input())
h = list(map(int,input().split()))
a = [0 for _ in range(n)]
a[1] = abs(h[1]-h[0])
for i in range(2,n):
  a[i] = min(a[i-1]+abs(h[i]-h[i-1]),a[i-2]+abs(h[i]-h[i-2]))
print(a[n-1])

Buggy submission (verdict: Runtime Error):
n = int(input())
h = list(map(int,input().split()))
a = [0 for _ in range(n)]
a[1] = abs(h[1]-h[0])
for i in range(2,n):
  a[i] = min(a[i-1]+abs(h[i]-h[i-1]),a[i-2]+abs(h[i]-h[i-2]))
print(a[n])
Problem p03162 (python)

Fixed submission:
n = int(input())
x = [list(map(int,input().split())) for _ in range(n)]
a = 0
b = 0
c = 0
for i in range(n):
  pa = a
  pb = b
  pc = c
  X = x[i]
  a = max(pb,pc)+X[0]
  b = max(pc,pa)+X[1]
  c = max(pa,pb)+X[2]
  
print(max([a,b,c]))

Buggy submission (verdict: Runtime Error):
n = int(input())
x = [list(map(int,input().split())) for _ in range(n)]
a = 0
b = 0
c = 0
for i in range(n):
  pa = a
  pb = b
  pc = c
  x = x[i]
  a = max(pb,pc)+x[0]
  b = max(pc,pa)+x[1]
  c = max(pa,pb)+x[2]
  
print(max(a,b,c))
Problem p03170 (python)

Fixed submission:
n,k = map(int,input().split())
a = list(map(int,input().split()))
tf = ["" for _ in range(k+1)]
tf[0] = False
for i in range(1,k+1):
  j = 0
  flag = 0
  while j < n and i - a[j] >= 0:
    if tf[i-a[j]] == False:
      tf[i] = True
      flag = 1
      break
    j += 1
  if flag ==0:
    tf[i] = False
if tf[k]:
  print("First")
else:
  print("Second")

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
a = list(map(int,input().split()))
s = [False]*(k+1)
for i in range(k+1):
  for aj in a:
    if i - aj >=0:
      if s[i-aj] == False:
        s[i] = True
        break
if a[k]==True:
  print("First")
else:
  print("Second")
Problem p03194 (python)

Fixed submission:
n,p = map(int,input().split())
if n == 1:
  print(p)
  exit()
a = 1
for k in range(2,1000001):
  c = 0
  while p%k == 0:
    p = p//k
    c += 1
  a *= k**(c//n)
  if p == 1:
    break
print(a)

Buggy submission (verdict: Runtime Error):
n,p = map(int,input().split())
if n==1:
 return p
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
a = primes(int(p**(1/n)))
res = 1
for j in range(len(a)):
 q = p
 if q%int(a[j]**n) == 0:
  c = 0
  while q%int(a[j]**n) == 0:
   q /= (a[j]**n)
   c += 1
  res *= int(a[j]**c)
print(res)

Buggy submission (verdict: Runtime Error):
n,p = map(int,input().split())
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
a = primes(int(p**(1/n)))
res = 1
for j in range(len(a)):
 q = p
 if q%int(a[j]**n) == 0:
  c = 0
  while q%int(a[j]**n) == 0:
   q /= (a[j]**n)
   c += 1
  res *= int(a[j]**c)
print(res)

Buggy submission (verdict: Runtime Error):
n,p = map(int,input().split())
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
a = primes(int(p**(1/n)))
res = 1
for j in range(len(a)):
 q = p
 if q%(a[j]**n) == 0:
  c = 0
  while q%(a[j]**n) == 0:
   q /= (a[j]**n)
   c += 1
  res *= a[j]**c
print(res)

Buggy submission (verdict: Runtime Error):
n,p = map(int,input().split())
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
a = primes(int(p**(1/n)))
res = 1
for j in range(len(a)):
 q = p
 if q%(a[j]**n) == 0:
  c = 0
  while q%(a[j]**n) == 0:
   q = q//(a[j]**n)
   c += 1
  res = res*(a[j]**c)
print(res)
Problem p03210 (python)

Fixed submission:
x = int(input())
if any([x==3,x==5,x==7]):
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
x = int(input())
if any(x==3,x==5,x==7):
  print("YES")
else:
  print("NO")
Problem p03211 (python)

Fixed submission:
s = str(input())
m = abs(753-int(s[0])*100-int(s[1])*10-int(s[2]))
for i in range(1,len(s)-2):
  a = int(s[i])*100+int(s[i+1])*10+int(s[i+2])
  m = min(m,abs(753-a))
  
print(m)

Buggy submission (verdict: Runtime Error):
s = str(input())
m = abs(753,int(s[0])*100+int(s[1])*10+int(s[2]))
for i in range(1,len(s)-2):
  a = int(s[i])*100+int(s[i+1])*10+int(s[i+2])
  m = min(m,abs(753,a))
  
print(m)

Buggy submission (verdict: Runtime Error):
s = str(input())
m = abs(753,s[0]*100+s[1]*10+s[2])
for i in range(1,len(s)-2):
  a = s[i]*100+s[i+1]*10+s[i+2]
  m = min(m,abs(753,a))
  
print(m)
Problem p03241 (python)

Fixed submission:
n,m = map(int,input().split())
g = 1
def fact(k):
  a = []
  for i in range(1,int(k **(0.5))+1):
    if k%i ==0:
      a.append(i)
      a.append(int(k/i))
  b = list(set(a))
  b.sort()
  return b

g = fact(m)
for i in range(len(g)):
  if g[len(g)-i-1] <= m/n:
    print(g[len(g)-i-1])
    break

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
g = 1
for i in range(m):
  if m%i == 0:
    if int(m/i) >= n:
      g = int(m/i)
    else:
      break
      
print(g)
Problem p03243 (python)

Fixed submission:
n = int(input())
k = 0
if int(n/111) == n/111:
  k = int(n/111)
else:
  k = int(n/111) + 1
print(111*k)

Buggy submission (verdict: Runtime Error):
n = int(input())
k = 0
if int(n/111) == n/111:
  k = n/111
else k = int(n/111) + 1
print(111*k)
Problem p03260 (python)

Fixed submission:
a,b = map(int,input().split())
if a%2 == 1 and b%2 ==1:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
if a%2 == 1 and b%2 ==1:
  print(Yes)
else:
  print(No)