Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

n,m = map(int,input().split())
h = list(map(int,input().split()))
a = [0]*m
b = [0]*m
for i in range(m):
    a[i],b[i] = map(int,input().split())

z = zip(a,b)
lis = [i for i in range(1,n+1)]
cnt = n

for i,j in z:
    if h[i-1] > h[j-1]:
        if j in lis:
            lis.remove(j)
            cnt -= 1
    elif h[j-1] > h[i-1]:
        if i in lis:
            lis.remove(i)
            cnt -= 1
    else:
        if j in lis:
            lis.remove(j)
            cnt -= 1
        if i in lis:
            lis.remove(i)
            cnt -= 1

print(cnt)

### FIXED CODE ###

import collections

n,m = map(int,input().split())
h = list(map(int,input().split()))
a = [0]*m
b = [0]*m
for i in range(m):
    a[i],b[i] = map(int,input().split())

z = zip(a,b)
lis = [0]*n

for i,j in z:

    if h[i-1] > h[j-1]:
        lis[j-1] = 1
    elif h[i-1] < h[j-1]:
        lis[i-1] = 1
    else:
        lis[i-1]=1
        lis[j-1]=1

print(collections.Counter(lis)[0])
### BUGGY CODE ###

class UnionFind():
    def __init__(self,n):
        self.n=n
        self.par=[i for i in range(n)]
        self.size=[1]*n
    def find(self,x):
        if x==self.par[x]:
            return self.par[x]
        else:
            self.par[x]=self.find(self.par[x])
            return self.par[x]
    def unite(self,x,y):
        x=self.find(x)
        y=self.find(y)
        if x==y:
            return
        if self.size[x]>self.size[y]:
            self.size[x]+=self.size[y]
            self.par[y]=x
        else:
            self.size[y]+=self.size[x]
            self.par[x]=y

n=int(input())

x_list=[]
y_list=[]

for i in range(n):
    x,y=map(int,input().split())
    x_list.append((x,i))
    y_list.append((y,i))
x_list.sort()
y_list.sort()
edges=[]

for i in range(1,n):
    edges.append((x_list[i][0]-x_list[i-1][0],x_list[i][1],x_list[i-1][1]))

    edges.append((y_list[i][0]-y_list[i-1][0],y_list[i][1],y_list[i-1][1]))

edges.sort()
uf=UnionFind(n)
ans=0
for e in edges:
    wt=e[0]
    x=e[1]
    y=e[2]
    if uf.find(x)==uf.find(y):
        continue
    ans+=wt
    uf.unite(x,y)
print(ans)



### FIXED CODE ###

class UnionFind():
    def __init__(self,n):
        self.n=n
        self.par=[i for i in range(n)]
        self.size=[1]*n
    def find(self,x):
        if x==self.par[x]:
            return self.par[x]
        else:
            self.par[x]=self.find(self.par[x])
            return self.par[x]
    def unite(self,x,y):
        x=self.find(x)
        y=self.find(y)
        if x==y:
            return
        if self.size[x]>self.size[y]:
            self.size[x]+=self.size[y]
            self.par[y]=x
        else:
            self.size[y]+=self.size[x]
            self.par[x]=y

import sys
input=sys.stdin.buffer.readline
n=int(input())

x_list=[]
y_list=[]

for i in range(n):
    x,y=map(int,input().split())
    x_list.append((x,i))
    y_list.append((y,i))
x_list.sort()
y_list.sort()
edges=[]

for i in range(1,n):
    edges.append((x_list[i][0]-x_list[i-1][0],x_list[i][1],x_list[i-1][1]))

    edges.append((y_list[i][0]-y_list[i-1][0],y_list[i][1],y_list[i-1][1]))

edges.sort()
uf=UnionFind(n)
ans=0
for e in edges:
    wt=e[0]
    x=e[1]
    y=e[2]
    if uf.find(x)==uf.find(y):
        continue
    ans+=wt
    uf.unite(x,y)
print(ans)
### BUGGY CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
A = [a - 1 for a in A]
D = 60
MAX_N = 200005
to = [[0] * MAX_N for _ in range(D)]
for i, a in enumerate(A):
    to[0][i] = a

for i in range(D - 1):
    for j in range(N):
        to[i + 1][j] = to[i][to[i][j]]

v = 0
for i in range(D - 1, -1, -1):
    l = 1 << i
    if l <= K:
        v = to[i][v]
        K -= l
print(v + 1)

### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
s = []
d = [-1] * (N + 1)
v = 1
c, l = 1, 0
while d[v] == -1:
    d[v] = len(s)
    s.append(v)
    v = A[v - 1]
c = len(s) - d[v]
l = d[v]
if K < l:
    print(s[K])
else:
    K -= l
    K %= c
    print(s[l + K])
### BUGGY CODE ###

def main():
    n, k = list(map(int, input().split()))
    p = list(map(int, input().split()))
    
    s = []
    for i in range(n-k+1):
        s.append((sum(p[i:i+k])+k)/2)    
    print(max(s))
    
if __name__ == '__main__':
    main()

### FIXED CODE ###

import itertools as iter

def main():
    n, k = list(map(int, input().split()))
    p = [0]
    p.extend(list(iter.accumulate([(1+int(x))/2 for x in input().split()])))
    #print(p)
    
    s = []
    for i in range(n-k+1):
        s.append(p[i+k]-p[i])
    #print(s)
    print(max(s))
    
if __name__ == '__main__':
    main()
### BUGGY CODE ###

# 1行目
p_str=input().split()
(N,K)=[int(n) for n in p_str]
# 2行目
p_str=input().split()
p_int=[int(n) for n in p_str]
(A,B)=(1,1)
for i in range(N-K):
  (A,B)=(1,1)
  for j in range(K):
    B += p_int[i+j]
  for j in range(K):
    A += p_int[i+j+1]
#  print(B,A,i)
  if B < A :
    print("Yes")
  else:
    print("No")
    


### FIXED CODE ###

# 1行目
p_str=input().split()
(N,K)=[int(n) for n in p_str]
# 2行目
p_str=input().split()
p_int=[int(n) for n in p_str]
(A,B)=(1,1)
for i in range(N-K):
  B=p_int[i]
  A=p_int[i+K]
  #  print(B,A,i)
  if B < A :
    print("Yes")
  else:
    print("No")
### BUGGY CODE ###

def main():
    _ = input()
    A = list(map(int, input().split()))
    cnt = 1 

    for a in A:
        cnt *= a 
    if cnt > 1e18:
        print(-1)
    else:
        print(cnt)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    _ = input()
    A = list(map(int, input().split()))
    cnt = 1 
    mi = min(A)
    if mi == 0:
        print(0)
    else:
        for a in A:
            cnt *= a 
            if cnt > 1e18 and mi > 0:
                print(-1)
                break
        else:
            if cnt < 0:
                print(-1)
            else:
                print(cnt)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

#https://atcoder.jp/contests/abc129/tasks/abc129_c

def dp1(n,a):
    dp=[0]*(n+1)
    dp[0]=1
    if 1 not in a:
        dp[1]=1
    if n==1:
        return dp[1]
    else:
        for i in range(2,n+1):
            if i not in a:
                dp[i]=dp[i-1]+dp[i-2]    
    return dp[n]

def main():
    n, m= map(int, input().split())
    a = [int(input()) for _ in range(m)]    
    print(dp1(n,a)%1000000007)

main()

### FIXED CODE ###

def dp1(n,a):
    dp=[0]*(n+1)
    dp[0]=1
    ok=[True]*(n+1)
    for x in a:
        ok[x]=False
    if 1 not in a:
        dp[1]=1
    if n==1:
        return dp[1]
    else:
        for i in range(2,n+1):
            if ok[i]:
                dp[i]=(dp[i-1]+dp[i-2])%1000000007 
    return dp[n]

def main():
    n, m= map(int, input().split())
    a = [int(input()) for _ in range(m)]    
    print(dp1(n,a))

main()
### BUGGY CODE ###

n = int(input())
x = list(map(int, input().split()))
for i in range(n):
    y = x[:]
    y[i] = 0
    y = list(sorted(y))
    s = n // 2
    print(y[-s])

### FIXED CODE ###

n = int(input())
x = list(map(int, input().split()))
y = sorted(x[:])
for i in x:
    s = n // 2
    ss= y[-s]
    if i >= ss:
        print(y[-(s+1)])
    else:
        print(y[-s])
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
L = [A[0]]
for i in range(1,N):
  L.append(L[i-1]+A[i])
k = 0
for i in range(N):
  if (L[i] == 0):
    k += 1
  for j in range(i+1,N):
    if (L[i] - L[j] == 0):
      k += 1
print(k)

### FIXED CODE ###

N = int(input())
L = list(map(int,input().split()))
S = [0]
c = 0
for i in range(N):
  c = S[i] + L[i]
  S.append(c)
S.sort()
S.append(S[N]+1)
k = 0
p = 1
ans = 0
while k <= N:
  if S[k] == S[k+1]:
    p += 1
    k += 1
  else:
    ans += p*(p-1)//2
    p = 1
    k += 1
print(ans)
### BUGGY CODE ###

X = int(input())
for B in range(X + 1):
    p_A = (B ** 5 + X) ** (1 / 5)
    n_A = ((-1 * B) ** 5 + X) ** (1 / 5)
    if isinstance(p_A, complex):
        pass
    elif isinstance(n_A, complex):
        pass
    else:
        if int(p_A) ** 5 - B ** 5 == X:
            print(int(p_A), B)
            break
        if int(n_A) ** 5 - (-1 * B) ** 5 == X:
            print(int(n_A), -1 * B)
            break
        

### FIXED CODE ###

X = int(input())
stop = False
for A in range(-118, 120):
    for B in range(-119, 129):
        if A ** 5 - B ** 5 == X:
            print(A, B)
            stop = True
    if stop:
        break
### BUGGY CODE ###

N, K = map(int, input().split())
hlist = list(map(int, input().split())) + [0] * (K + 2)
inf = float("inf")
dp = [inf] * (N * K + 2)


def abs_sbn(a, b):
    return abs(hlist[b] - hlist[a])


dp[0] = 0
for i in range(N):
    for j in range(1, K + 1):
        dp[i + j] = min(dp[i + j], dp[i] + abs_sbn(i, i + j))

print(dp[N - 1])


### FIXED CODE ###

N, K = map(int, input().split())
h = list(map(int, input().split()))
inf = 10**9
dp = [inf] * N
dp[0] = 0


def chmin(num: int, sbn: int):
    dp[num + sbn] = min((dp[num + sbn], dp[num] + abs(h[i + sbn] - h[num])))


for i in range(N):
    for sbn in range(K):
        try:
            chmin(i, sbn + 1)
        except IndexError:
            break
print(dp[-1])
### BUGGY CODE ###

def heap_localsort(Array, i):
    lsub, rsub = 2*i+1, 2*i+2
    maxIndex = i
    if lsub <= len(Array)-1 and Array[lsub] > Array[maxIndex]:
        maxIndex = lsub
    if rsub <= len(Array)-1 and Array[rsub] > Array[maxIndex]:
        maxIndex = rsub
    Array[i], Array[maxIndex] = Array[maxIndex], Array[i]
    return(Array)

def heap_sort(Array):
    for i in reversed(range(int(len(Array)/2))):
        heap_localsort(Array, i)
    return(Array)

def heap_push(Array, addElem):
    Array.append(addElem)
    return(heap_sort(Array))

def heap_pop(Array):
    init = A[0]
    Array.pop(0)
    heap_sort(A)
    return(init)
 
def function(A, M):
    heap_sort(A)
    for i in range(M):
        max = heap_pop(A)
        heap_push(A, int(max / 2))
    return sum(A)

N = list(map(int, (input().split(' '))))
A = list(map(int, (input().split(' '))))
print(function(A, N[1]))

### FIXED CODE ###

import heapq

N = list(map(int, (input().split(' '))))
A = list(map(lambda x: x*(-1), map(int, (input().split(' ')))))

heapq.heapify(A)
for i in range(N[1]):
    heapq.heappush(A, int(heapq.heappop(A) / 2))

print(-sum(A))
### BUGGY CODE ###

import math
import numpy as np

n,k=(int(x) for x in input().split())
a = [int(x) for x in input().split()]


for _ in range(min(k,500)):
    new_a = []
    c = 0
    a_in = [max(i-j,0) for i,j in enumerate(a)]
    a_out = [min(i+j,n) for i,j in enumerate(a)]
    for x in range(n):
        c += a_in.count(x)
        c -= a_out.count(x-1)
        new_a.append(c)
    a = new_a

print(" ".join([str(x) for x in a]))

### FIXED CODE ###

import math
import numpy as np

n,k=(int(x) for x in input().split())
a = [int(x) for x in input().split()]


for _ in range(k):
    new_a = np.zeros(n+1,dtype=int)
    np.add.at(new_a, np.maximum(0,np.arange(0, n)-a), 1)
    np.add.at(new_a, np.minimum(n,np.arange(0, n)+a+1), -1)
    a = new_a.cumsum()[:-1]
    if np.all(a==n):
        break

print(" ".join([str(x) for x in a]))
### BUGGY CODE ###

import sys #追加
sys.setrecursionlimit(10**6)
n,q = map(int,input().split())

from collections import defaultdict
dic = defaultdict(list)


for _ in range(n-1):
    a,b = map(int,input().split())
    dic[a-1].append(b-1)
    dic[b-1].append(a-1)


dic2 = defaultdict(int)

for _ in range(q):
    p,x = map(int,input().split())
    dic2[p-1] += x

ansl = [0 for i in range(n)]
used = [-1 for i in range(n)]
used[0] = 1
def dfs(pos):
    for p in dic[pos]:
        if used[p] == -1:
            ansl[p] = ansl[pos] + dic2[pos]
            used[p] = 1
            dfs(p)

dfs(0)
for idx, a in enumerate(ansl):
    print(a + dic2[idx])





### FIXED CODE ###

n,q = map(int,input().split())
m = [[] for i in range(n)]
for _ in range(n-1):
   a,b = map(int,input().split())
   m[a-1].append(b-1)
   m[b-1].append(a-1)

from collections import defaultdict
dic = defaultdict(int)
for _ in range(q):
   p,x = map(int,input().split())
   dic[p-1] += x

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

used = [0 for i in range(n)]
used[0] = 1
quu = [0]
while quu:
   k = quu.pop()
   for l in m[k]:
      if used[l] == 0:
         used[l] = 1
         quu.append(l)
         ans[l] = ans[k] + dic[l]

for i in ans:
   print(i)
### BUGGY CODE ###

import math

a,b,n=map(int,input().split())
num=-100
i=1
if n<b:
    num=max(num,math.floor(a*n/b)-a*math.floor(n/b))
else:
    while b*i-1<=n:
        j=b*i-1
        num=max(num,math.floor(a*j/b)-a*math.floor(j/b))
        i+=1
print(num)


### FIXED CODE ###

import math

a,b,n=map(int,input().split())
num=-100
i=1
if n<b:
    num=max(num,math.floor(a*n/b)-a*math.floor(n/b))
else:
    j=b-1
    num=max(num,math.floor(a*j/b)-a*math.floor(j/b))
print(num)
### BUGGY CODE ###

N,D,A=[int(x) for x in input().split()]
xh = [[int(x) for x in input().split()] for _ in range(N)]
xh = sorted(xh)
r=0
l=0
ans = 0
mi = 10**9
for l in range(N):
  if xh[l][1]==0:
    continue
  for _ in range(N):
    if  l<N and r<N and 2*D>xh[r][0]-xh[l][0]:
      if 2*D<abs(xh[l][0]-xh[min(r+1,N-1)][0]):
        break
      else:
        r+=1
  #print(1,l,r)
  la = (xh[l][1]+A-1)//A
  ans +=(xh[l][1]+A-1)//A
  for i in range(l,min(r+1,N)):
    xh[i][1]=max(0,xh[i][1]-la*A)
    #print(xh[i][1],i)
  if r==l:
    r+=1
print(ans)


### FIXED CODE ###

N,D,A=[int(x) for x in input().split()]
xh = [[int(x) for x in input().split()] for _ in range(N)]
xh = sorted(xh)
r=0
l=0
ans = 0
mi = 10**9
d = [0]*(N+1)
for l in range(N):
  if d[l]<xh[l][1]:
    la = (xh[l][1]-d[l]+A-1)//A
    for _ in range(N):
      if l<N and r<N and 2*D>=xh[r][0]-xh[l][0]:
        r+=1
      else:
        break
    ans += la
    d[l]+=la*A
    d[r]-=la*A
  d[l+1]+=d[l]
print(ans)
### BUGGY CODE ###

N = int(input())
A = list(map(str, input().split()))
a = '+'.join(A)

Q = int(input())
for i in range(Q):
    B, C= map(str, input().split())
    a = a.replace(B, C)
    print(eval(a))


### FIXED CODE ###

import collections

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
C = collections.Counter(A)
ans = sum(A)

for _ in range(Q):
    b, c = map(int, input().split())
    ans += c*C[b] - b*C[b]
    C[c] += C[b]
    C[b] = 0
    print(ans)
### BUGGY CODE ###

from bisect import bisect_left as bl
n=int(input())
a=list(map(int,input().split()))
t=[[]for i in range(n)]
for i in range(n-1):
    u,v=map(int,input().split())
    t[u-1].append(v-1)
    t[v-1].append(u-1)
b=[1]+[0]*(n-1)
q=[[0,[a[0]]+[2**64]*(n-1),1]]
while q:
    c,d,e=q.pop(0)
    for i in t[c]:
        if b[i]==0:
            s=d[::]
            g=e
            h=bl(d,a[i])
            s[h]=a[i]
            if e<=h:
                g+=1
            b[i]=g
            q.append([i,s,g])
for i in range(n):
    print(b[i])

### FIXED CODE ###

from bisect import bisect_left as bl
import sys
sys.setrecursionlimit(10**6)
n=int(input())
a=list(map(int,input().split()))
t=[[]for i in range(n)]
for i in range(n-1):
    u,v=map(int,input().split())
    t[u-1].append(v-1)
    t[v-1].append(u-1)
b=[0]*n
dp=[float("inf")]*n
def f(c,d):
    h=bl(dp,a[c])
    g=dp[h]
    dp[h]=min(dp[h],a[c])
    b[c]=bl(dp,float("INF"))
    for i in t[c]:
        if i!=d:f(i,c)
    dp[h]=g
f(0,-1)
for i in b:
    print(i)
### BUGGY CODE ###

import collections
n = int(input())
A = list(map(int, input().split()))

def prime_factorize(n):
    r = []
    while n % 2 == 0:
        r.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            r.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        r.append(n)
    return collections.Counter(r)

fa = collections.Counter()
p = []
for a in A:
    tt = prime_factorize(a)
    fa = fa | tt
    p.append(tt)

ans = 0
mod = 10**9+7
for i in range(n):
    t = 1
    fb = fa - p[i]
    for k, v in fb.items():
        t *= pow(k, v, mod)
    ans += t % mod
print(ans % mod)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
from math import gcd
cm = 1
for i in range(n):
    cm = cm*a[i]//gcd(cm, a[i])
ai = sum(pow(x, mod-2, mod) for x in a)
print(int(ai*cm%mod))
### BUGGY CODE ###

N = int(input())
L = list(map(int, input().split()))

Ans = 0

for i in range(len(L)):
    for j in range(i+1,len(L)):
        #print(L[i] * L[j])
        Ans += (L[i] * L[j])%(10**9+7)
        #Ans += L[i] * L[j]
        #if Ans >= 10**9+7:
            #Ans = Ans%(10**9+7)
Ans = Ans%(10**9+7)
print(Ans)

### FIXED CODE ###

N = int(input())
L = list(map(int, input().split()))

Ans = 0

sum_L = L[0]

l = len(L)

for i in L[1:]:
    Ans += sum_L*i%(10**9+7)
    sum_L += i
Ans = Ans%(10**9+7)
print(Ans)
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))

LIM= 10**18
ans=1
for e in a:
    ans*=e
    if ans > LIM:
        ans = -1

if ans <0:
    ans = -1

print(ans)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))

LIM= 10**18
ans=1
for e in a:
    ans*=e
    if ans > LIM or ans<-1:
        ans = -1

if ans <0:
    ans = -1

print(ans)
### BUGGY CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,M = map(int,readline().split())
A = [0]+list(map(int,readline().split()))
B = list(map(int,read().split()))

N,M

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

ticket_sum = [0]*(N*N)

# 各区間 [L,R] に対して、採用される点数を見る
for n in range(M):
    arr = B[n::M]
    # 安いチケットから入れていく -> 連結成分上で採用される
    left = list(range(N))
    right = list(range(N))
    filled = [False]*N
    for i in sorted(range(N), key=arr.__getitem__):
        filled[i] = True
        l = i if (i==0) or (not filled[i-1]) else left[i-1]
        r = i if (i==N-1) or (not filled[i+1]) else right[i+1]
        left[r] = l; right[l] = r
        # [l,i] x [i,r] に arr[i] を加える
        x = arr[i]
        ticket_sum[l*N+i]+=x
        if i<N-1:
            ticket_sum[(i+1)*N+i]-=x
        if r<N-1:
            ticket_sum[l*N+r+1]-=x
        if i<N-1 and r<N-1:
            ticket_sum[(i+1)*N+r+1]+=x

# 2d累積和
for i in range(1,N):
    for j in range(N):
        ticket_sum[N*i+j]+=ticket_sum[N*(i-1)+j]
for i in range(N):
    for j in range(1,N):
        ticket_sum[N*i+j]+=ticket_sum[N*i+j-1]

dist = [0]*(N*N)
for i in range(N):
    for j in range(i,N):
        dist[i*N+j] = A[j]-A[i]

answer = max(x-y for x,y in zip(ticket_sum,dist))
print(answer)

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools

INF=10**10

N,M = map(int,readline().split())
A = [0,0]+list(map(int,readline().split()))
B = [[INF]*M]+[list(map(int,line.split())) for line in readlines()]

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

answer = 0
INF = 10**12
diff = [INF]+[0]*N
left = [list(range(-1,N)) for m in range(M)]
arr = [INF,2,1,2]
for i in range(1,N+1):
    for m in range(M):
        p=i; prev_val=0
        q=left[m][p]
        x = B[i][m]
        while prev_val<=x:
            diff[p] += x-prev_val
            diff[q] -= x-prev_val
            p=q; q=left[m][p]
            prev_val=B[p][m]
        left[m][i]=p
    # 出発地点ごとの収入
    ticket_sum = list(itertools.accumulate(diff[::-1]))[::-1]
    for start in range(1,i+1):
        happy = ticket_sum[start] + A[start]-A[i]
        if answer < happy:
            answer = happy

print(answer)
### BUGGY CODE ###

a1,b0,cn1,d=map(int,input().split())
Output = 0

for i in range(d):
  if i < a1:
    Output = Output + 1
  elif i < a1+b0:
    pass
  else:
    Output = Output - 1  
print(Output)

### FIXED CODE ###

a1,b0,cn1,d=map(int,input().split())
Output = 0

if a1 < d:
    Output = a1
    if a1+b0 < d:
      c = d-a1-b0
      Output = Output - c
    elif a1 + b0 >= d:
      pass
elif a1 >= d:
    Output = d
else:
  print("weird")
print(Output)
### BUGGY CODE ###

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

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

step = 1
t = 0
if k<=5:
    for i in range(0, k):
        step = a[step]
    print(step)
else:

    for i in range(0, 4):
        step = a[step]

        step1 = step
    while(True):
        t += 1
        step1 = a[step1]
        if step1 == step:
            break
    result = step
    k = (k-4) % t
    for i in range(0, k):
        result = a[result]

    print(result)


### FIXED CODE ###

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

a = [0] + list(map(int, input().split()))
a1 = [0] * (n+1)

step = 1
start = 0
while(True):
    start += 1
    a1[step] += 1
    step = a[step]
    if a1[step] == 1:
        break
c = step
gap = 0
while(True):
    gap += 1
    step = a[step]
    if step == c:
        break
result = 1
if k > start:
    k = (k-start) % gap
    result = c
for _ in range(k):
    result = a[result]

print(result)
### BUGGY CODE ###

from collections import Counter
n = int(input())
a = list(map(int,input().split()))
x = 0
count = Counter(a)
q = int(input())
b,c = [],[]
for i in range(q):
    bi,ci = map(int,input().split())
    b.append(bi),c.append(ci)
for i in range(q):
    bi,ci = b[i],c[i]
    count[ci]+=count[bi]
    count[bi] = 0
    x = 0
    for k,v in count.items():
        x+=k*v
    print(x)


### FIXED CODE ###

from collections import Counter
n = int(input())
a = list(map(int,input().split()))
x = sum(a)
count = Counter(a)

q = int(input())
b,c = [],[]

for i in range(q):
    bi,ci = map(int,input().split())
    b.append(bi),c.append(ci)
for i in range(q):
    bi,ci = b[i],c[i]
    x -= bi*count[bi]
    x += ci*count[bi]
    count[ci]+=count[bi]
    count[bi] = 0
    print(x)
### BUGGY CODE ###

N,K=map(int,input().split())
h=list(map(int,input().split()))
DP=[0]*N
DP[0]=0
for i in range(1,N):
  #j=1
  #while j<=K and j<=i:
  #  DP[i]=min(DP[i],abs(h[i]-h[i-j])+DP[i-j])
  #for j in range(max(0, i-K),i):
    #DP[i]=min(DP[i],abs(h[i]-h[j])+DP[j])
  DP[i]=min([abs(h[i]-h[j])+DP[j] for j in range(max(0, i-K),i)])
print(DP[-1])




### FIXED CODE ###

def main():
  #import sys
  #input = sys.stdin.readline
  N,K=map(int,input().split())
  h=list(map(int,input().split()))
  DP=[0]*N
  DP[0]=0
  for i in range(1,N):
  #j=1
  #while j<=K and j<=i:
  #  DP[i]=min(DP[i],abs(h[i]-h[i-j])+DP[i-j])
  #for j in range(max(0, i-K),i):
    #DP[i]=min(DP[i],abs(h[i]-h[j])+DP[j])
    r=max(0, i-K)
    DP[i]=min([abs(h[i]-h[j])+DP[j] for j in range(r,i)])
  print(DP[-1])
if __name__ == '__main__':
  main()
### BUGGY CODE ###

def main():
    L, R = map(int, input().split())
    minCount = float('inf')

    for i in range(L, R+1):
        count = 0
        for j in range(i+1, R+1):
            if count <= 2019:
                minCount = min(minCount, i * j % 2019)
                count += 1
            else:
                break
    print(minCount)

if __name__ == "__main__":
     main()

### FIXED CODE ###

def main():
    L, R = map(int, input().split())
    minCount = float('inf')

    for i in range(L, R+1):
        for j in range(i+1, R+1):
            ans = i * j % 2019
            minCount = min(minCount, ans)
            if ans == 0:
                print(0)
                return
    print(minCount)

if __name__ == "__main__":
     main()
### BUGGY CODE ###

N, P = map(int, input().split())

if N == 1:
    print(P)
else:
    ans = 1
    for x in range(1, P):
        k = x**N
        if k > P:
            break
        if P % k == 0:
            ans = max(ans, x)
    print(ans)

### FIXED CODE ###

from collections import Counter

N, P = map(int, input().split())

# n以下の全ての素数のセットを返す関数
def prime_set(n):
    primes = set(range(2, n+1))
    for i in range(2, int(n**0.5) + 1):
        primes.difference_update(range(i*2, n+1, i))
    return primes

# nを素因数分解して素因数の全リストを返す関数
def prime_factors(n):
    f = []
    for i in prime_set(int(n**0.5) + 1):
        while n % i == 0:
            f.append(i)
            n //= i
    if n > 1:
        f.append(n)
    return f

c = Counter(prime_factors(P))
ans = 1

for x in c.keys():
    ans *= pow(x, int(c[x]//N))

print(ans)