Harryxun/stf_run huggingface dataset:
group_id = 0
groups = []

def solve(graphs, ps):
    global group_id, groups
    groups = [-1] * (len(ps) + 1)

    for key in range(1, len(ps) + 1):
        if groups[key] == -1:
            group_id += 1
            dfs(graphs, key)

    ans = 0
    for key, value in enumerate(ps, 1):
        if groups[key] == groups[value]:
            ans += 1
    return ans

def dfs(graphs, key):
    if key >= len(graphs):
        return

    global groups
    groups[key] = group_id

    for graph_key in graphs[key]:
        if groups[graph_key] == -1:
            dfs(graphs, graph_key)

def main():
    n, m = map(int, input().split())
    ps = list(map(int, input().split()))

    # 隣接リスト作成 (0, n]
    graphs = [[] for i in range(n + 1)]
    for i in range(m):
        x, y = map(int, input().split())
        graphs[x].append(y)
        graphs[y].append(x)

    ans = solve(graphs, ps)
    print(ans)

if __name__ == "__main__":
    main()


### FIXED CODE ###

class UnionFind:
    def __init__(self, size):
        self.parent = list(range(size))
        self.rank = [0] * size

    def root(self, x):
        if self.parent[x] != x:
            self.parent[x] = self.root(self.parent[x])
        return self.parent[x]

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)

        if x == y:
            return

        if self.rank[x] > self.rank[y]:
            self.parent[y] = x
        else:
            self.parent[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def same(self, x, y):
        return self.root(x) == self.root(y)


def main():
    n, m = map(int, input().split())
    ps = list(map(int, input().split()))

    # 1-origin
    union_find = UnionFind(n + 1)
    for i in range(m):
        x, y = map(int, input().split())
        union_find.unite(x, y)

    ans = 0
    for key, value in enumerate(ps, 1):
        if union_find.same(key, value):
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()
a, b, k = map(int, input().split())

num = []
mini = min(a, b)
for i in range(1, mini):
    if mini % i == 0:
        num.append(i)
num.sort()
print(num[k-1])

### FIXED CODE ###

a, b, k = map(int, input().split())
num = []
mini = min(a, b)
for i in range(1, mini+1):
    if a % i == 0 and b % i == 0:
        num.append(i)
num.sort()
num.reverse()
print(num[k-1])
def lcm(a, b):
    import math
    return a // math.gcd(a, b) * b


def f(x, c, d):
    res = x
    res -= x//c
    res -= x//d
    res += x//lcm(c,d)
    return res

def resolve():
    A, B, C, D = map(int, input().split())

    ans = f(B, C, D) - f(A-1, C, D)
    print(int(ans))

resolve()

### FIXED CODE ###

def lcm(a, b):
    import fractions 
    return a // fractions.gcd(a, b) * b


def f(x, c, d):
    res = x
    res -= x//c
    res -= x//d
    res += x//lcm(c,d)
    return res

A, B, C, D = map(int, input().split())

ans = f(B, C, D) - f(A-1, C, D)
print(int(ans))
N = int(input())


ans = [0]*(N+1)
i = 102
for x in range(1,i):
    for y in range(1,i):
        for z in range(1,i):
            total = (x + y + z)**2 - (x*y + y*z + x*z)
            if total <= N+1:
                ans[total] += 1

for i in range(1,N+1):
    print(ans[i])

### FIXED CODE ###

N = int(input())


ans = [0]*(N+1)
i = 102
for x in range(1,i):
    for y in range(1,i):
        for z in range(1,i):
            total = (x + y + z)**2 - (x*y + y*z + x*z)
            if total <= N:
                ans[total] += 1

for i in range(1,N+1):
    print(ans[i])
import math
from functools import reduce

def gcd(numbers):
    return reduce(math.gcd, numbers)

city_num, ori = list(map(int, input().split()))
cityies = list(map(int, input().split()))
stan = cityies[0]
difference = [abs(ori-stan)]
if len(cityies) > 1:
    for city in cityies[1:]:
        diff = abs(city - stan)
        difference.append(diff)

max_num = gcd(difference)
print(max_num)


### FIXED CODE ###

import fractions
from functools import reduce

def gcd(numbers):
    return reduce(fractions.gcd, numbers)

city_num, ori = list(map(int, input().split()))
cityies = list(map(int, input().split()))
stan = cityies[0]
difference = [abs(ori-stan)]

if len(cityies) > 1:
    for city in cityies[1:]:
        diff = abs(city - stan)
        difference.append(diff)

max_num = gcd(difference)
print(max_num)
a, b, c = map(int, raw_input().split())
print 'YES' if b - a = c - b else 'NO'

### FIXED CODE ###

a, b, c = map(int, raw_input().split())
print 'YES' if b - a == c - b else 'NO'
n,m=map(int,input().split())
l=[list(map(int,input().split()))for i in range(m)]
dist=[[1<<29]*n for i in range(n)]
for i in range(m): dist[i][i]=0
for a in l:
  dist[a[0]-1][a[1]-1] = min(dist[a[0]-1][a[1]-1],a[2])
  dist[a[1]-1][a[0]-1] = min(dist[a[1]-1][a[0]-1],a[2])
# print(dist)
for k in range(n):
  for i in range(n):
    for j in range(n):
      dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
# 経路復元
ans=m
for a in l:
  flag=False
  for j in range(n): 
    if dist[j][a[0]-1]+a[2]==dist[j][a[1]-1]: flag=True
  if flag: ans-=1
print(ans)

### FIXED CODE ###

n,m=map(int,input().split())
l=[list(map(int,input().split()))for i in range(m)]
dist=[[1<<29]*n for i in range(n)]
for i in range(n): dist[i][i]=0
for a in l:
  dist[a[0]-1][a[1]-1] = min(dist[a[0]-1][a[1]-1],a[2])
  dist[a[1]-1][a[0]-1] = min(dist[a[1]-1][a[0]-1],a[2])
# print(dist)
for k in range(n):
  for i in range(n):
    for j in range(n):
      dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
# 経路復元
ans=m
for a in l:
  flag=False
  for j in range(n): 
    if dist[j][a[0]-1]+a[2]==dist[j][a[1]-1]: flag=True
  if flag: ans-=1
print(ans)
YM=0
MY=0
F=int(X[0] + X[1])
B=int(X[2] + X[3])
if 0<F<=12 :
    MY += 1
else:
    pass

if 0<B<=12 :
    YM += 1
else:
    pass

if YM == 1 and MY == 1 :
    print("AMBIGUOUS")
elif YM == 1 and MY == 0 :
    print("YYMM")
elif YM == 0 and MY == 1 :
    print("MMYY")
else :
    print("NA")

### FIXED CODE ###

X=input()
YM=0
MY=0
F=int(X[0] + X[1])
B=int(X[2] + X[3])
if 0<F<=12 :
    MY += 1
else:
    pass

if 0<B<=12 :
    YM += 1
else:
    pass

if YM == 1 and MY == 1 :
    print("AMBIGUOUS")
elif YM == 1 and MY == 0 :
    print("YYMM")
elif YM == 0 and MY == 1 :
    print("MMYY")
else :
    print("NA")
n=int(input())
p=[list(map(int,input().split()))for i in range(n)]
for i in range(n):
  if p[i][2]==0:
    p.del(i)
if len(p)==1:
  print(p[0][0],p[0][1],p[0][2])
else:
  for i in range(0,101):
    for j in range(0,101):
      k=1
      l=p[0][2]+abs(i-p[0][0])+abs(j-p[0][1])
      for x,y,h in p:
        if h==0:
          continue
        m=h+abs(i-x)+abs(j-y)
        if l!=m:
          k=0
      if k:
        ans=[i,j,l]
  print(ans[0],ans[1],ans[2])


### FIXED CODE ###

n=int(input())
p=[list(map(int,input().split()))for i in range(n)]
d=[]
for i in range(n):
  if p[i][2]==0:
    d.append(i)
d.sort(reverse=1)
for i in d:
  del p[i]
if len(p)==1:
  print(p[0][0],p[0][1],p[0][2])
else:
  for i in range(0,101):
    for j in range(0,101):
      k=1
      l=p[0][2]+abs(i-p[0][0])+abs(j-p[0][1])
      for x,y,h in p:
        if h==0:
          continue
        m=h+abs(i-x)+abs(j-y)
        if l!=m:
          k=0
      if k:
        ans=[i,j,l]
  print(ans[0],ans[1],ans[2])
from collections import defaultdict

N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))

dict = defaultdict(int)

for i in range(M):
  B, C = map(int, input().split())
  dict[C] += B

idx = 0
for k, v in sorted(dict.items(), key=lambda x: -x[0]):
  for _ in range(v):
    if A[idx] < k and idx-1 <= len(A):
      A[idx] = k
      idx += 1
    else:
      break
else:
  continue
break
      
      
print(sum(A))
  

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

from collections import defaultdict

N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))

dict = defaultdict(int)

for i in range(M):
  B, C = map(int, input().split())
  dict[C] += B

idx = 0
for k, v in sorted(dict.items(), key=lambda x: -x[0]):
  for _ in range(v):
    if idx+1 <= len(A):
      if A[idx] < k:
      	A[idx] = k
      	idx += 1
      else:
        print(sum(A))
        exit()
    else:
      print(sum(A))
      exit()
      
      
print(sum(A))
n = input()
c=0
a = [x for i in range(n)]
for x in a:
  if len(str(x)) % 2 == 1:
    c += 1
    
print(c)

### FIXED CODE ###

n = int(input())
c=0
a = [i for i in range(n+1)]
for x in a:
  if len(str(x)) % 2 == 1:
    c += 1
    
print(c-1)
a = int(input())
b = int(input())
print(int((a+b+1)/2))

### FIXED CODE ###

a, b = map(int,input().split(' '))
print(int((a+b+1)/2))
n,m=map(int,input().split())
a=[]
for i in range(m):
  b=list(map(int,input()))
  a+=b

for i in range(n):
  dumy=a.count(i+1)
  print(dumy)


### FIXED CODE ###

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

for i in range(n):
  dumy=a.count(i+1)
  print(dumy)
import heapq

n, m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a) 

for i in range(m):
  max_ = a.heappop()
  d = max_ // 2
  a.heappush(d)

print(sum(a))

### FIXED CODE ###

import heapq

n, m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a) 

for i in range(m):
  max_ = -heapq.heappop(a)
  d = max_ // 2
  heapq.heappush(a, -d)

c = 0
for i in range(len(a)):
  c -= heapq.heappop(a)
print(c)
from sys import stdin
from itertools import accumulate
n = int(stdin.readline().rstrip())
if n == 1:
    print(0)
else:
    a = list(range(1, n))
    b = list(accumulate(a))
    print(max(b))

### FIXED CODE ###

from sys import stdin

n = int(stdin.readline().rstrip())
point = n*(n-1)//2
print(point)
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n - 1)]

adj = [[] for _ in range(n)]
for a, b in ab:
    a -= 1
    b -= 1
    adj[a].append(b)
    adj[b].append(a)


class Tree:
    WHITE = 0
    GRAY = -1
    BLACK = 1

    def __init__(self, adj):
        n = len(adj)
        self.adj = adj
        self.colors = [self.WHITE] * n
        self.depths = [-1] * n
        self.depth = 0

    def init(self):
        self.__init__(self.adj)

    def dfs(self, u):
        if self.colors[u] == self.BLACK:
            return

        self.colors[u] = self.GRAY
        self.depths[u] = self.depth

        for v in self.adj[u]:
            if self.colors[v] == self.WHITE:
                self.depth += 1
                self.dfs(v)
                self.depth -= 1

        self.colors[u] = self.BLACK


tree = Tree(adj)
tree.dfs(0)

ev = [i for i, e in enumerate(tree.depths) if e % 2 == 0]
od = [i for i, e in enumerate(tree.depths) if e % 2]

l_ev = len(ev)
l_od = len(od)

mod0 = [e for e in range(1, n + 1) if e % 3 == 0]
mod1 = [e for e in range(1, n + 1) if e % 3 == 1]
mod2 = [e for e in range(1, n + 1) if e % 3 == 2]

ans = [0] * n


def f(li1, li2):
    while li1 and li2:
        i = li1.pop()
        num = li2.pop()
        ans[i] = num


if l_ev > n / 3 and l_od > n / 3:
    f(ev, mod1)
    f(od, mod2)
    f(ev, mod0)
    f(od, mod0)

elif l_ev <= n / 3:
    f(ev, mod0)
    f(od, mod0)
    f(od, mod1)
    f(od, mod2)

else:
    f(od, mod0)
    f(ev, mod0)
    f(ev, mod1)
    f(ev, mod2)

print(*ans)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)

n = int(input())
ab = [list(map(int, input().split())) for _ in range(n - 1)]

adj = [[] for _ in range(n)]
for a, b in ab:
    a -= 1
    b -= 1
    adj[a].append(b)
    adj[b].append(a)


class Tree:
    WHITE = 0
    GRAY = -1
    BLACK = 1

    def __init__(self, adj):
        n = len(adj)
        self.adj = adj
        self.colors = [self.WHITE] * n
        self.depths = [-1] * n
        self.depth = 0

    def init(self):
        self.__init__(self.adj)

    def dfs(self, u):
        if self.colors[u] == self.BLACK:
            return

        self.colors[u] = self.GRAY
        self.depths[u] = self.depth

        for v in self.adj[u]:
            if self.colors[v] == self.WHITE:
                self.depth += 1
                self.dfs(v)
                self.depth -= 1

        self.colors[u] = self.BLACK


tree = Tree(adj)
tree.dfs(0)

ev = [i for i, e in enumerate(tree.depths) if e % 2 == 0]
od = [i for i, e in enumerate(tree.depths) if e % 2]

l_ev = len(ev)
l_od = len(od)

mod0 = [e for e in range(1, n + 1) if e % 3 == 0]
mod1 = [e for e in range(1, n + 1) if e % 3 == 1]
mod2 = [e for e in range(1, n + 1) if e % 3 == 2]

ans = [0] * n


def f(li1, li2):
    while li1 and li2:
        i = li1.pop()
        num = li2.pop()
        ans[i] = num


if l_ev > n / 3 and l_od > n / 3:
    f(ev, mod1)
    f(od, mod2)
    f(ev, mod0)
    f(od, mod0)

elif l_ev <= n / 3:
    f(ev, mod0)
    f(od, mod0)
    f(od, mod1)
    f(od, mod2)

else:
    f(od, mod0)
    f(ev, mod0)
    f(ev, mod1)
    f(ev, mod2)

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

h =[]

if a[0] > a[1]:
    h.append(a[0] - a[1])
    a[1] += (a[0]- a[1]) 
else:
    h.append(0)
    
for i in range(2,n):
    if a[i-1] > a[i]:
        h.append(a[i-1]- a[i])
        a[i] += (a[i-1]- a[i]) 
    else:
        h.append(0)
        
print(sum(h))
    

### FIXED CODE ###

import sys

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

h =[]

if n == 1:
    print(0)
    sys.exit()

if a[0] > a[1]:
    h.append(a[0] - a[1])
    a[1] = a[0]
else:
    h.append(0)
    
for i in range(2,n):
    if a[i-1] > a[i]:
        h.append(a[i-1]- a[i])
        a[i] = a[i-1]
    else:
        h.append(0)
        
print(sum(h))
from string import*
from itertools import*
b = ascii_lowercase
s = input()
if len(s) < 26:
    x = z = s, y = b, d = 0
else:
    d = -[p*len(list(k)) for p, k in groupby([i < j for i, j in zip(s[-1::-1], s[-2::-1])])][0] - 2
    x, y, z = s[:d], s[d+1:], b[:ord(s[d]) - 97]
print(-(d < -26) or x + sorted(set(y) - set(z))[0])

### FIXED CODE ###

#!/usr/bin/env python3
from string import*
from itertools import*
b = ascii_lowercase
s = input()
l = len(s)
if l < 26:
    print(s + sorted(set(b) - set(s))[0])
else:
    t = s[::-1]
    a = [(p, len(list(k))) for p, k in groupby([i < j for i, j in zip(t, t[1:])])][0]
    d = - a[0]*a[1] - 2
    print(-(d < -26) or s[:d] + sorted(set(s[d+1:]) - set(b[:ord(s[d]) - 97]))[0])
R = int(input())
G = int(input())

print(2*G/R)

### FIXED CODE ###



R = int(input())
G = int(input())

print(2*G-R)
S = list(input())
L = len(S)
Slist = set()
for i in range(L):
    Slist.add(ord(S[i]))
Slist = list(Slist)
Slist.sort()
j = 97
ok = 0
for i in range(L):
    if Slist[i] == j:
        j += 1
        continue
    ans = chr(j)
    ok = 1
    break
if len(Slist) == 26:
    ans = "None"
elif ok == 0:
    ans = chr(j)
print(ans)


### FIXED CODE ###

S = list(input())
L = len(S)
Slist = set()
for i in range(L):
    Slist.add(ord(S[i]))
Slist = list(Slist)
Slist.sort()
ans = "None"
j = 0
L = len(Slist)
for i in range(97, 123):
    if Slist[j] == i:
        j += 1
        if j >= L and i+1 < 123:
            ans = chr(i+1)
            break
        continue
    ans = chr(i)
    break
print(ans)
import numpy as np

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

dp = np.zeros(W+1, dtype=int)

for i in range(N):
    w, v = map(int, input().split())
    dp[w:] = np.maximum(dp[:-w] + v, dp[w:])

print(dp[-1])

### FIXED CODE ###

import numpy as np

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

dp = [float("INF")]*(N*10**3 + 1)
dp = np.array(dp)
dp[0] = 0

for i in range(N):
    w, v = map(int, input().split())
    dp[v:] = np.minimum(dp[:-v] + w, dp[v:])

print(np.max(np.where(dp <= W)))
N = input()
 
for n in range(N):
    data = map(float,raw_input().split( ))
    slopes = []
    for i in range(2):
        _x1 = data.pop(0)
        _y1 = data.pop(0)
        _x2 = data.pop(0)
        _y2 = data.pop(0)
         
        if _x1 != _x2:
            slopes.append((_y1 - _y2)/(_x1 - _x2))
     
    if len(slopes) == 0:
        print "YES"
    elif len(slopes) == 1:
        print "NO"
    elif abs(slopes[0] - slopes[1]) < 1e-10:
        print "YES"
    else:
        print "NO"

### FIXED CODE ###

N = input()
 
for n in range(N):
    data = map(float,raw_input().split( ))
    slopes = []
    for i in range(2):
        _x1 = data.pop(0)
        _y1 = data.pop(0)
        _x2 = data.pop(0)
        _y2 = data.pop(0)
         
        if _x1 != _x2:
            slopes.append((_y1 - _y2)/(_x1 - _x2))
     
    if len(slopes) == 0:
        print "YES"
    elif len(slopes) == 1:
        print "NO"
    elif abs(slopes[0] - slopes[1]) < 1e-10:
        print "YES"
    else:
        print "NO"
import collections

n = int(input())
s_list = list(input())

ans = 0
for i in range(1000):
    key = str(i).zfill(3)
    k = 0
    t = key[k]
    for s in s_list:
        if t == s[j]:
            k += 1
            if k == 3:
                ans += 1
                break
            t = key[k]
print(ans)


### FIXED CODE ###

n = int(input())
s_list = list(input())

ans = 0
for i in range(1000):
    key = str(i).zfill(3)
    k = 0
    t = key[k]
    for s in s_list:
        if t == s:
            k += 1
            if k == 3:
                ans += 1
                break
            t = key[k]
print(ans)
import sys
num_bill, y = map(int, input().split())

for num_10000 in range(y // 10000 + 1):
    for num_5000 in range(min((y - num_10000 * 10000) // 5000 + 1, num_bill - num_10000 + 1)):
        if ((num_bill - num_10000 - num_5000) * 1000 + num_5000 * 5000 + num_10000 * 10000 == y) & (num_10000 + num_5000 + num_1000 == num_bill):
            print(num_10000, num_5000, (num_bill - num_10000 - num_5000))
            sys.exit()

print('-1 -1 -1')

### FIXED CODE ###

import sys
num_bill, y = map(int, input().split())
bills = [1000, 5000, 10000]

num_1000, num_5000, num_10000 = 0, 0, 0

for num_10000 in range(y // 10000 + 1):
    if (num_1000 * 1000 + num_5000 * 5000 + num_10000 * 10000 == y) & (num_10000 + num_5000 + num_1000 == num_bill):
        print(num_10000, num_5000, num_1000)
        sys.exit()
        
    iter_num = min(((y - num_10000 * 10000) // 5000 + 1), (num_bill - num_10000 + 1))
    for num_5000 in range(iter_num):
        if (num_1000 * 1000 + num_5000 * 5000 + num_10000 * 10000 == y) & (num_10000 + num_5000 + num_1000 == num_bill):
            print(num_10000, num_5000, num_1000)
            sys.exit()
        
        num_1000 = num_bill - num_10000 - num_5000
        if (num_1000 * 1000 + num_5000 * 5000 + num_10000 * 10000 == y) & (num_10000 + num_5000 + num_1000 == num_bill):
            print(num_10000, num_5000, num_1000)
            sys.exit()

print('-1 -1 -1')
a = -1
n,m = map(int, input().split())
s_and_c = [tuple(map(int,input().split())) for i in range(m)]
s = []
c = []
l = [0]*m
for t in s_and_c:
  l[t[0]-1] = t[1]
for _ in s_and_c:
  s.append(_[0])
  c.append(_[1])
if max(s) == n and l[0] == len(l)-1 or l[0] != 0:
  a = "".join([str(i) for i in l])
else:
  pass
print(a)

### FIXED CODE ###

n,m = map(int,input().split())
x = [tuple(map(int,input().split())) for i in range(m)]
f=True
for i in range(0,1001):
    i = str(i)
    if len(i)==n:
        if all([i[t[0]-1]==str(t[1]) for t in x]):
            print(i)
            f=False
            break
if f:
    print(-1)
s=input()
n=len(s)
list=['A','C','G','T']
ans=[]
for i in range(n):
  k=0
  while i+k<=n-1:
    if all(a in list for a in s[i:i+k+1]):
      ans.append(k+1)
    k+=1
print(max(ans))

### FIXED CODE ###

s=input()
n=len(s)
list=['A','C','G','T']
ans=[]
for i in range(n):
  k=0
  while i+k<=n-1:
    if all(a in list for a in s[i:i+k+1]):
      ans.append(k+1)
    k+=1
if len(ans)==0:
  print(0)
else:
  print(max(ans))
import sys

input = sys.stdin.readline


def main():
    x, y = map(int, input().split())
    table = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5, "F": 6}
    x = table[x]
    y = table[y]
    if x < y:
        print("<")
    elif x == y:
        print("=")
    else:
        print(">")


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys

input = sys.stdin.readline


def main():
    x, y = input().split()
    table = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5, "F": 6}
    x = table[x]
    y = table[y]
    if x < y:
        print("<")
    elif x == y:
        print("=")
    else:
        print(">")


if __name__ == "__main__":
    main()
import sys
s = sys.stdin.readlines().replace("\n", "").lower()
for i in 'abcdefghijklmnopqrstuvwxyz':
    print(i, ":", s.count(i))


### FIXED CODE ###

import sys
from collections import Counter
m = Counter(sys.stdin.read().lower())
for i in 'abcdefghijklmnopqrstuvwxyz':
    print(i, ":", m[i])
N = int(input()) #5
K = int(input()) #3
X = int(input())
Y = int(input())

total = 0
for a in range(1, 6): #6 , 1, 2, 3, 4, 5
	if a < K:
      total += X
    else:
      total += Y

print(total)

### FIXED CODE ###

N = int(input()) #5
K = int(input()) #3
X = int(input())
Y = int(input())

total = 0
for a in range(1, N+1): #6 , 1, 2, 3, 4, 5
    if a <= K:
        total += X
    else:
        total += Y

print(total)
import math as np
a,b,c=map(int, input().split())
r=(1-((a**2/c**2)+(b**2/c**2)))**2
if r>4*a*b:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k=int(input())
print(a[k-1])
# D
def perm(N, k):
    a = 1
    for i in range(int(k)):
        a*=N
        N-=1
        return a
from math import factorial
# from math import perm

tmp = list(map(int, input().split()))
X = tmp[0]
Y = tmp[1]

x = (2*Y-X)/3
y = (2*X-Y)/3

if not x.is_integer():
    print(0)
elif not y.is_integer():
    print(0)
else:
    if x>y:
        denominator = perm(x+y, x)%(10**9+7)
        numerator = factorial(y)%(10**9+7)
        tmp = denominator//numerator
        print(int(tmp))
    else:
        denominator = perm(x+y, y)%(10**9+7)
        numerator = factorial(x)%(10**9+7)
        tmp = denominator//numerator
        print(int(tmp))

### FIXED CODE ###

#!/usr/bin/env python3

import math

mod = 10**9+7

x, y = list(map(int, input().split()))

# dp = [[0]*(y+1) for _ in range(x+1)]
# dp[0][0] = 1
# for x_tmp in range(1, x+1):
#     for y_tmp in range(1, y+1):
#         print(x_tmp, y_tmp)

#         if x_tmp-2 >= 0 and y_tmp-1 >= 0:
#             dp[x_tmp][y_tmp] += dp[x_tmp-2][y_tmp-1] % mod
#         if x_tmp-1 >= 0 and y_tmp-2 >= 0:
#             dp[x_tmp][y_tmp] += dp[x_tmp-1][y_tmp-2] % mod

# print(dp[-1][-1] % mod)


def comb(n, r):
    X = Y = 1
    if r < 0 or n < r:
        return 0
    if r == 0:
        return 1
    if n-r < r:
        r = n-r
    for i in range(1, r+1):
        Y = Y*i % mod
        X = X*(n-i+1) % mod
    Y = pow(Y, mod-2, mod)
    return X*Y


if (x+y) % 3 != 0:
    print(0)
    exit()

num = min(x, y)-(x+y)//3
if num < 0:
    print(0)
    exit()

# print((x+y)//3, num)
print(comb((x+y)//3, num) % mod)
n=int(input())
a=list(map(int,input().split()))

c=[0]*(max(a)+10)

for i in range(n):
    c[a[i]]+=1

short_edge=0
long_edge=0
for i in range(len(c)):
    if c[i]>=4:
        long_edge=i
        short_edge=i
    elif c[i]>=2:
        short_edge=long_edge
        long_edge=i
    else:
        pass

print(long_edge*short_edge)

### FIXED CODE ###

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

cnt=Counter(a)
edge=[0,0]

for i in cnt:
    if cnt[i]>=4:
        edge.append(i)
    if cnt[i]>=2:
        edge.append(i)

edge.sort(reverse=True)
print(edge[0]*edge[1])
import numpy as np
def main():
    ttt = []
    n = int(input())
    e = [list(map(int, input().split())) for _ in range(n)]
    #e = [[int(i) for i in input().split()] for i in range(int(input()))]
    #n = 3
    #e = [[21,-11],[81234,94124,52141]]
    for j in range(n):
        t = e[0][0] - e[1][j]*0.006
        tt = abs(e[0][1] - t)
        ttt.append(tt)
    ttt = np.array(ttt)
    print(np.argmin(ttt)+1)
    ttt = []
main()


### FIXED CODE ###

import numpy as np
def main():
    ttt = []
    n = int(input())
    N, M = map(int, input().split())
    e = list(map(int, input().split()))
    #e = [[int(i) for i in input().split()] for i in range(int(input()))]
    #n = 3
    #e = [[21,-11],[81234,94124,52141
    for j in range(n):
        t = N - e[j]*0.006
        tt = abs(M - t)
        ttt.append(tt)
    ttt = np.array(ttt)
    print(np.argmin(ttt)+1)
main()
x = input()
print '%d' % x^3

### FIXED CODE ###

x = input()
print x**3