Harryxun/stf_run huggingface dataset:
def factorize(n):
    factor = []
    if n % 2 == 0:
        f = [2, 1]
        n //= 2
        while n % 2 == 0:
            n //= 2
            f[1] += 1
        factor.append(f)
    k = 3
    while k * k <= n:
        if n % k == 0:
            f = [k, 1]
            n //= k
            while n % k == 0:
                n //= k
                f[1] += 1
            factor.append(f)
        k += 2
    if n != 1:
        factor.append([n, 1])
    return factor

def factorial(n, mod):
    fac = [0] * (n + 1)
    inv = [0] * (n + 1)
    fac[0], inv[0] = 1, 1
    for i in range(1, n + 1):
        fac[i] = fac[i-1] * i % mod
        inv[i] = inverse(fac[i], mod)
    return fac, inv

def inverse(a, mod):
    a %= mod # 除数が正なら正になる
    p = mod
    x, y = 0, 1
    while a > 0:
        n = p // a
        p, a = a, p % a, 
        x, y = y, x - n * y
    return x % mod # 除数が正なら正になる

n, m = map(int, input().split())
mod = 10 ** 9 + 7
f = factorize(m)
max_k = max(i for _, i in f)
fac, inv = factorial(n + max_k - 1, mod)

ans = 1
for _, k in f:
    ans = ans * fac[n + k - 1] % mod * inv[n - 1] % mod * inv[k] % mod
print(ans)



### FIXED CODE ###

def factorize(n):
    factor = []
    if n % 2 == 0:
        f = [2, 1]
        n //= 2
        while n % 2 == 0:
            n //= 2
            f[1] += 1
        factor.append(f)
    k = 3
    while k * k <= n:
        if n % k == 0:
            f = [k, 1]
            n //= k
            while n % k == 0:
                n //= k
                f[1] += 1
            factor.append(f)
        k += 2
    if n != 1:
        factor.append([n, 1])
    return factor

def factorial(n, mod):
    fac = [0] * (n + 1)
    inv = [0] * (n + 1)
    fac[0], inv[0] = 1, 1
    for i in range(1, n + 1):
        fac[i] = fac[i-1] * i % mod
        inv[i] = inverse(fac[i], mod)
    return fac, inv

def inverse(a, mod):
    a %= mod # 除数が正なら正になる
    p = mod
    x, y = 0, 1
    while a > 0:
        n = p // a
        p, a = a, p % a, 
        x, y = y, x - n * y
    return x % mod # 除数が正なら正になる

n, m = map(int, input().split())
if m == 1:
    print(1)
    quit()
mod = 10 ** 9 + 7
f = factorize(m)
max_k = max(i for _, i in f)
fac, inv = factorial(n + max_k - 1, mod)
ans = 1
for _, k in f:
    ans = ans * fac[n + k - 1] % mod * inv[n - 1] % mod * inv[k] % mod
print(ans)
N = int(input())
sum = eval(input().replace(' ','*'))
print(sum if sum<= 10**8 else -1)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
A.sort()
res = 1
for i in A:
    res*=i;
    if res>10**18:
        res = -1
        break
print(res)
N=int(input())

H=list(input().split())
A=[0 for i in range(N)]
if H[0]>=H[1]:
  A[0]+=1
for i in range(1,N-1):
  if H[i]>=H[i+1]:
    A[i]+=A[i-1]+1
print(max(A))



### FIXED CODE ###

N=int(input())

H=list(map(int,input().split()))
A=[0 for i in range(N)]
if N==1:
  print(0)
else:
  if H[0]>=H[1]:
  	A[0]+=1
  if N>=3:
    for i in range(1,N-1):
      if H[i]>=H[i+1]:
        A[i]+=A[i-1]+1
  print(max(A))
SA = input()
SB = input()
SC = input()

WIN = [0, 0, 0]



card = SA[0]

SA_CNT = 1
SB_CNT = 0
SC_CNT = 0

while True:
    if card == 'a':
        SA_CNT += 1
        if SA_CNT == len (SA):
            print('A')
            break
        else:
            card = SA[SA_CNT]
    if card == 'b':
        SB_CNT += 1
        if SB_CNT == len(SB):
            print('B')
            break
        else:
            card = SB[SA_CNT]
    if card == 'c':
        SC_CNT += 1
        if SC_CNT == len (SC):
            print('C')
            break
        else:
            card = SC[SA_CNT]

### FIXED CODE ###

SA = input()
SB = input()
SC = input()

card = SA[0]

SA_CNT = 1
SB_CNT = 0
SC_CNT = 0


while True:
    if card == 'a':
        if SA_CNT < len (SA):
            card = SA[SA_CNT]
            SA_CNT += 1
        else:
            print('A')
            break
    if card == 'b':
        if SB_CNT < len (SB):
            card = SB[SB_CNT]
            SB_CNT += 1
        else:
            print('B')
            break
    if card == 'c':
        if SC_CNT < len (SC):
            card = SC[SC_CNT]
            SC_CNT += 1
        else:
            print('C')
            break
import math

K = int(input())

Sum = []
for a in range(1, K+1):
    for b in range(1, K + 1):
        gcd2 = math.gcd(i.j)
        for c in range(1, K + 1):
            gcd = math.gcd(gcd2, c)
            Sum.append(gcd)

print(sum(Sum))


### FIXED CODE ###

import math

K = int(input())

Sum = []
for a in range(1, K+1):
    for b in range(1, K + 1):
        gcd2 = math.gcd(a, b)
        for c in range(1, K + 1):
            gcd = math.gcd(gcd2, c)
            Sum.append(gcd)

print(sum(Sum))
combNum = [0]*100
inNum = 0
while True:
    calcResult = 0
    numList1 = list(range(1,n+1,1))
    numList2 = list(range(1,n+1,1))
    numList3 = list(range(1,n+1,1))
    n,x = map(int, input().split())
    if n is x is 0:
        break
    else:
        
        for index1 in range(n):
            for index2 in range(n):
                for index3 in range(n):
                    #index = [numList1[index1], numList2[index2], numList3[index3]]
                    if numList1[index1] is numList2[index2] or numList1[index1] is numList3[index3] or numList2[index2] is numList3[index3] or numList1[index1] is numList2[index2] is numList3[index3]:
                    #if index.count(numList1[index1])>1 or index.count(numList1[index2])>1 or index.count(numList1[index3])>1:
                        pass                
                    else:
                        if numList1[index1]<numList2[index2]<numList3[index3]:
                            calcResult = numList1[index1] + numList2[index2]+numList3[index3]
                            if calcResult == x:
                                combNum[inNum] =combNum[inNum]+1
                                
                        else:
                            pass
        inNum = inNum+1
for index in range(inNum):
    print(combNum[index])


### FIXED CODE ###

dataNum = 0
combNum = [0] * 100
while True:
    n,x=map(int, input().split())
    if n is x is 0:
        break
    else:
        for a in range(1,n-1):
            for b in range(a+1,n):
                for c in range(b+1,n+1):
                    calcResult = a + b + c
                    if calcResult == x:
                        combNum[dataNum] += 1
                    else:
                        pass
    dataNum += 1

for index in range(dataNum):
    print(combNum[index])
N = int(input())
s = [input() for i in range(N)]
S = [[0]*len(s[i]) for i in range(N)]
for i, x in enumerate(s):
    res = []
    q = 0
    for j in range(len(x)):
        if x[j] == ')':
            S[i][j] = -1
        else:
            S[i][j] = 1
s = [0]*N
m = [len(S[i]) for i in range(N)]
for i, x in enumerate(S):
    tmp = 0
    for j in range(len(x)):
        tmp += S[i][j]
        m[i] = min(tmp, m[i])
    s[i] = tmp
if sum(s) == 0:
    ss = [m[i], s[i]) for i in range(N)]
    ss.sort(key=lambda x: (x[1], x[2]), reverse=True)
    tmp = 0
    for x,y in ss:
        for z in x:
            if tmp + x < 0:
                print("No")
                exit(0)
            tmp += y
                    
    print("Yes")

else:
    print("No")


### FIXED CODE ###

N = int(input())
s = [input() for i in range(N)]
S = [[0]*len(s[i]) for i in range(N)]
for i, x in enumerate(s):
    res = []
    q = 0
    for j in range(len(x)):
        if x[j] == ')':
            S[i][j] = -1
        else:
            S[i][j] = 1
s = [0]*N
m = [len(S[i]) for i in range(N)]
for i, x in enumerate(S):
    tmp = 0
    for j in range(len(x)):
        tmp += S[i][j]
        m[i] = min(tmp, m[i])
    s[i] = tmp

if sum(s) == 0:
    sp = [(m[i], s[i]) for i in range(N) if s[i] > 0]
    mp = [(-(s[i]-m[i]), -s[i]) for i in range(N) if s[i] <= 0]#右から見た場合
    sp.sort(key=lambda x: x[0], reverse=True)
    tmp = 0
    for x, y in sp:
        if tmp + x < 0:
            print("No")
            exit(0)
        tmp += y
    mp.sort(key=lambda x: x[0], reverse=True)
    tmp2 = 0
    for x, y in mp:
        if tmp2 + x < 0:
            print("No")
            exit(0)
        tmp2 += y
    print("Yes")

else:
    print("No")
s=input()
q=int(input())

rev=1

for _ in range(0,q):
  n=input()
#  print(n[0:1])
  if n[0:1]=="1":
#    print("!")
    rev*=-1
  else:
    m=n.split()
    x=[]
    if (m[1]=="1" and rev==1) or (m[1]=="2" and rev==-1):
    x.append(m[2])
    x.append(s)
      s=''.join(x)
#      s=m[2]+s
    else:
    x.append(s)
    x.append(m[2])
      s=''.join(x)
#      s=s+m[2]
if rev==1:
  print(s)
else:
  print(s[::-1])


### FIXED CODE ###

s=input()
q=int(input())

rev=1

sf=""
sb=s

for _ in range(0,q):
  n=input().split()
  if n[0]=="1":
    rev*=-1
  else:
    if (n[1]=="1" and rev==1) or (n[1]=="2" and rev==-1):
      sf+=n[2]
    else:
      sb+=n[2]

s=sf[::-1]+sb

if rev==1:
  print(s)
else:
  print(s[::-1])
N = int(input())
L = []
for i in range(int(N/2)):
    if i**2<=N:
        L.append(i**2)
print(max(L))

### FIXED CODE ###

import math
N=int(input())
n=math.sqrt(N)
 
print(int(n)**2)
import math
x1, y1, x2, y2 = map(int, input().split())
X = x1 - x2
Y = y1 - y2
print('{:.5f}'.format(math.sqrt(X * X + Y * Y)))



### FIXED CODE ###

import math
x1, y1, x2, y2 = map(float, input().split())
X = x1 - x2
Y = y1 - y2
print('{:.5f}'.format(math.sqrt(X * X + Y * Y)))
def gcd(A, B):
    while B != 0:
        A, B = B, A%B
    return A

N, M = map(int, input().split())
S = input()
T = input()
can = True
agc = N * M // gcd(N, M)
L_N = agc // N
L_M = agc // M
i = 0

while i*L_M < agc and i*L_N < agc:
    if S[i*L_M] != T[i*L_N]:
        can = False
        break
    i += 1

if can:
    print(agc)
else:
    print(-1)

### FIXED CODE ###

def gcb(A, B):
    while B != 0:
        A, B = B, A%B
    return A

N, M = map(int, input().split())
S = input()
T = input()
can = True
agc = N // gcb(N, M) * M
L_N = agc // N
L_M = agc // M
i = 0
while i*L_M < N and i*L_N < M:
    if S[i*L_M] != T[i*L_N]:
        can = False
        break
    i += 1

if can:
    print(agc)
else:
    print(-1)
def dfs(cur,par,d):
    dist[cur]=d
    for nx,nx_dist in G[cur]:
        if nx==par:continue
        dfs(nx,cur,d+nx_dist)

n=int(input())
G=[[] for i in range(n)]
dist=[0]*n
for i in range(n-1):
    a,b,c=map(int,input().split())
    G[a-1].append([b-1,c])
    G[b-1].append([a-1,c])
q,k=map(int,input().split())
k-=1
dfs(k,-1,0)
for i in range(q):
    x,y=map(int,input().split())
    x-=1
    y-=1
    print(dist[x]+dist[y])

### FIXED CODE ###

# ABC070 D - Transit Tree Path
import heapq
def dijkstra_heap(s):
    """
    始点sから各頂点への最短距離を返す

    Parameters
    ----------
    s : int
        視点とする頂点

    Returns
    -------
    d ：list
    始点sから各頂点への最短距離
    """
    d = [float("inf")] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #未使用の頂点の中から最小の距離のものを探す
        if not used[minedge[0]]:
            continue
        v = minedge[0]
        d[v] = minedge[1]
        used[v] = False
        for e in edge[v]:
            if used[e[0]]:
                heapq.heappush(edgelist,[e[0],e[1]+d[v]])
    return d

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

q,k=map(int,input().split())
k-=1
dist=dijkstra_heap(k)
for i in range(q):
    x,y=map(int,input().split())
    x-=1
    y-=1
    print(dist[x]+dist[y])
n,k=map(int,input().split())
a=list(int(x) for x in input().split())
s=0
if k <= n:
	print(s)
else:
	i for i in range(n-k):
		s += i
		print(s)

### FIXED CODE ###

n,k=map(int,input().split())
a=list(int(x) for x in input().split())
a.sort()
s=0
if n <= k:
	print(0)
else:
		s = sum(a[:n-k])
		print(s)
print(sum(divmod(input(a),2)))

### FIXED CODE ###

a=int(input())
print(sum(divmod(a,2)))
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from collections import defaultdict
import sys
sys.setrecursionlimit(10**5+100)

def main():
  n, m = map(int, input().strip().split())
  memo = [-1] * (n+1)
  graph = defaultdict(list)

  for _ in range(m):
    x, y = map(int, input().strip().split())
    graph[y].append(x)

  def rec(v):
    if memo[v] != -1:
      return memo[v]

    memo[v] = max([0] + [rec(t)+1 for t in graph[v]])
    return memo[v]

  print(max([rec(v) for v in range(1, n+1)]))

if __name__=='__main__':
  main()

### FIXED CODE ###

#!/usr/bin/python3
# -*- coding:utf-8 -*-

from collections import defaultdict
import sys
sys.setrecursionlimit(10**7)

def main():
  n, m = map(int, input().strip().split())
  memo = [-1] * (n+1)
  graph = defaultdict(list)

  for _ in range(m):
    x, y = map(int, input().strip().split())
    graph[y].append(x)

  def rec(v):
    if memo[v] != -1:
      return memo[v]

    lp = 0
    for t in graph[v]:
      lp = max(lp, rec(t)+1)
    memo[v] = lp
    return memo[v]

  lp = 0
  for v in range(1, n+1):
    lp = max(lp, rec(v))
  print(lp)


if __name__=='__main__':
  main()
n, m = map(int, input().split())

eva = {}

ac = 0
wa = 0

for i in range(m):
    q, s = input().split()
    if eva[q] == "AC":
        pass
    else:
        if s == "AC":
            ac += 1
            eva[q] = "AC"
        else:
            wa += 1

print(ac, wa)


### FIXED CODE ###

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

eva = [[0, 0] for _ in range(n)]

ac = 0
penalty = 0

for i in range(m):
    q, s = input().split()
    if eva[int(q) - 1][1] == 0:
        if s == "WA":
            eva[int(q) - 1][0] += 1
        else:
            eva[int(q) - 1][1] += 1
            ac += 1
            penalty += eva[int(q) - 1][0]
    else:
        pass

print(ac, penalty)
s = input()
weather = ["Sunny","Cloudy","Rainy"]

a = weather[s]
if a == 2:
    print("Sunny")
else:
    print(weather[a+1])

### FIXED CODE ###

s = input()
weather = ["Sunny","Cloudy","Rainy"]

a = weather.index(s)
if a == 2:
    print("Sunny")
else:
    print(weather[a+1])
def main ():
  N = int(input())
  A = list(map(int,input().split()))
  prod = 1 
  
  for a in A:
    prod *= a
    if a
    
  if prod > 1000000000000000000:
    print(-1)
    return
  
  else:
    print(prod) 

main()

### FIXED CODE ###

def main ():
  N = int(input())
  A = list(map(int,input().split()))
  prod = 1 
  A.sort()
  for a in A:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      return
  
  print(prod) 
 
main()
inp_list = input().spilt()
if (inp_list[0] / inp_list[1]) <= 80:
    print("Yes") 
else:
    print("No")

### FIXED CODE ###

inp = input()
inp_list = inp.split()
inp_list = [int(i) for i in inp_list] 
if inp_list[0] / inp_list[1] <= inp_list[2]:
    print("Yes") 
else:
    print("No")
n = int(input())
l = []
#l = [l.remove(int(input())) if int(input()) in l else int(input()) for i in range(n)]
for i in range(n):
    l.remove(int(input())) if int(input()) in l else l.append(int(input()))
print(len(l))

### FIXED CODE ###

n = int(input())
l = set()
for i in range(n):
    tmp = int(input())
    l.remove(tmp) if tmp in l else l.add(tmp)
print(len(l))
import sys
sys.setrecursionlimit(10**9)

def f(n, k):
  num_bit = 3 - bin(k).count('1')
  c = [0, 0, 1, 3]
  return 3**n - num_bit*2**n + c[num_bit]

# k = 0:(), 1:(3), 2(5), 3:(3, 5), 4:(7), 5:(3, 7), 6:(5, 7), 7:(3, 5, 7)
def solve(N, k=0):
  n = len(N)
  num_used = bin(k).count('1')
  if n + num_used < 3:
    return 0
  else:
    a = int(N[0])
    base = sum([f(i, k) for i in range(3, n)])
    if a > 7:
      return sum([f(i, k) for i in range(3, n+1)])
    elif a == 7:
      return base + f(n-1, k|2) + f(n-1, k|1) + solve(N[1:], k|4)
    elif a > 5:
      return base + f(n-1, k|2) + f(n-1, k|1)
    elif a == 5:
      return base + f(n-1, k|1) + solve(N[1:], k|2)
    elif a > 3:
      return base + f(n-1, k|1)
    elif a == 3:
      return base + solve(N[1:], k|1)
    elif a > 0:
      return base
    else: # a == 0
      return solve(N[1:])

print(solve(input()))

### FIXED CODE ###

def f(n, k):
  num_bit = 3 - bin(k).count('1')
  c = [0, 0, 1, 3]
  return 3**n - num_bit*2**n + c[num_bit]

# k = 0:(), 1:(3), 2(5), 3:(3, 5), 4:(7), 5:(3, 7), 6:(5, 7), 7:(3, 5, 7)
def solve(N, k=0):
  n = len(N)
  num_used = bin(k).count('1')
  if n==0 and num_used==3:
    return 1
  elif n==0 or n+num_used<3:
    return 0
  else:
    a = int(N[0])
    if a > 7:
      return f(n-1, k|1) + f(n-1, k|2) + f(n-1, k|4)
    elif a == 7:
      return f(n-1, k|2) + f(n-1, k|1) + solve(N[1:], k|4)
    elif a > 5:
      return f(n-1, k|2) + f(n-1, k|1)
    elif a == 5:
      return f(n-1, k|1) + solve(N[1:], k|2)
    elif a > 3:
      return f(n-1, k|1)
    elif a == 3:
      return solve(N[1:], k|1)
    else:
      return 0

N = input()
base = sum([f(i, 0) for i in range(3, len(N))])
print(solve(N) + base)
N, K = map(int, input().split())
h = list(map(int, input().split()))

dp = [10 ** 9 for i in range(N + K)]
dp[0] = 0
for i in range(N):
    for j in range(1, K + 1):
        if i + j < N:
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]))

print(dp[N - 1])


### FIXED CODE ###

# B - Frog2
import numpy as np

N, K = list(map(int, input().split()))
h = np.array(list(map(int, input().split()))+[0]*K)

dp = np.array([10**9]*(N+K))
dp[0] = 0

for i in range(N):
    dp[i+1:i+K+1] = np.minimum(dp[i+1:i+K+1], dp[i]+abs(h[i+1:i+K+1]-h[i]))
print(dp[N-1])
a = int(input())
b = int(input())
print(a - b + 1)

### FIXED CODE ###

a, b = map(int, input().split())
print(a - b + 1)
def cmd(p,q):
    if q <= 0 or q >= p:
        return 1
    else:
        return (cmd(p-1,q-1)+cmd(p-1,q))%(10**9+7)


n,k = map(int,input().split())
for i in range(1,k+1):
    print((cmd(n-k+1,i)*cmd(k-1,i-1))%(10**9+7))

### FIXED CODE ###

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

comb = [[0 for j in range(i+1)] for i in range(n+1)]

for i in range(n+1):
    for j in range(i+1):
        if j == 0 or j == i:
            comb[i][j] = 1
        elif j < 0 or j > i:
            comb[i][j] = 0
        else:
            comb[i][j] = (comb[i-1][j] + comb[i-1][j-1])%(10**9+7)


for i in range(1,k+1):
    if n-k+1 < i:
        print(0)
    else:
        print((comb[n-k+1][i]*comb[k-1][i-1])%(10**9+7))
S = input()
C = [chr(97+i) for i in range(26)]


if S == "".join(C.sort(reverse=True)):
    print(-1)

elif len(S) != 26:
    for c in C:
        if c not in S:
            print(S + c)
            break
else:
    K = []
    for i in range(25, -1, -1):
        K.append(S[i])
        K.sort()
        for j in range(25, -1, -1):
            if K[0] > S[j]:
                print(S[:j])
                exit()



### FIXED CODE ###

S = input()
C = [chr(97+i) for i in range(26)]

if len(S) != 26:
    for c in C:
        if c not in S:
            print(S + c)
            break
else:
    S = list(S)
    for i in range(25, -1, -1):
        if S[i:] != sorted(S[i:], reverse=True):
            Z = sorted(list(filter(lambda x: x > S[i], S[i:])))
            print("".join(S[:i]) + Z[0])
            break
    else:
        print(-1)
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import sys

N = int(sys.stdin.readline())


def Base_10_to_n(X, n):
    m = chr(X%n+ord("a"))
    if (X//n):
        return Base_10_to_n(X//n-1, n)+m
    return m

print(N)print(Base_10_to_n(N-1,26))

### FIXED CODE ###

#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import sys

N = int(sys.stdin.readline())


def Base_10_to_n(X, n):
    m = chr(X%n+ord("a"))
    if (X//n):
        return Base_10_to_n(X//n-1, n)+m
    return m

print(Base_10_to_n(N-1,26))
a = input()
if(a == "ARC"):
  print("ABC")
elsif(a == "ABC"):
  print("ARC")


### FIXED CODE ###

a = input()
if a == "ARC":
  print("ABC")
elif a == "ABC":
  print("ARC")
N = int(input())
A = list(map(int, input().split()))

if 0 in A:
    print(0)
    exit(0)
ans = 1
for i in range(N):
　 ans = ans*A[i]
   if 10**18 < ans:
    print(-1)    
    exit(0)

print(ans)

### FIXED CODE ###

import sys  # sys.exit()を使いたいので

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

if 0 in a:
# 0が1つでもあれば0です
    print(0)
else:
# 0がない場合
    cur = 1  # 現在の数値
    for x in a:
        cur *= x
        if cur > 10 ** 18:
        # 10**18を超えたので終了します
            print(-1)
            sys.exit()
    print(cur)  # 10**18以下なので、出力します
while 1:
    x = map(int,raw_input().split())
    x.sort()
    if sum(x) == 0:
    break
    else:
    print x[0], x[1]

### FIXED CODE ###

while 1:
    x = map(int, raw_input().split())
    x.sort()
    if sum(x) == 0:
        break
    else:
        print x[0],x[1]
#!/usr/bin/env python3

N = float(input())

data = []

for i in range(N):
    price = input().split()
    data.append(price) 

total = 0

for i in range(N):
    if data[i][1] == "JPY":
        total += int(data[i][0])
    elif data[i][1] == "BTC":
        total += 380000 * float(data[i][0])

print(total)


### FIXED CODE ###

#!/usr/bin/env python3

N = int(input())

data = []

for i in range(N):
    price = input().split()
    data.append(price) 

total = 0

for i in range(N):
    if data[i][1] == "JPY":
        total += int(data[i][0])
    elif data[i][1] == "BTC":
        total += 380000 * float(data[i][0])

print(total)
[N, M] = list(map(int, input().split(' ')))
card_list = list(map(int, input().split(' ')))

card_list.sort()

C_list = [0] * N
for i in range(M):
  [B, C] = list(map(int, input().split(' ')))
  if C_list[0] > C:
    continue
  else:
    for k in range(B):
      if C < card_list[k] or C_list[k] >= C:
        break
      else C_list[k] < C:
        C_list[k] = C
  C_list.sort()
  
C_list.sort()

ans = 0
count = 0
for i in range(N):
  if card_list[-1] > C_list[-1]:
    ans += card_list.pop()
    count += 1
  else:
    ans += C_list.pop()
    count += 1
      
print(ans) 

### FIXED CODE ###

[N, M] = list(map(int, input().split(' ')))
card_list = list(map(int, input().split(' ')))

card_list.sort()
compare_list = []

for i in range(M):
  (B, C) = list(map(int, input().split(' ')))
  compare_list.append((C,B))
    
compare_list.sort()

ans = 0
for i in range(N):
  if compare_list == []:
    ans += sum(card_list[i:])
    break
  if card_list[-1] > compare_list[-1][0]:
    ans += card_list.pop()
  elif compare_list[-1][1] > 0:
    ans += compare_list[-1][0]
    tmp = compare_list.pop()
    a = tmp[0]
    b = tmp[1]
    if b != 1:
      compare_list.append((a,b-1)) 
      
print(ans)
input_data = list(map(int,input().split()))
import sys

sys.setrecursionlimit(10**10)
mini = min(input_data[1:])
length=max(input_data[1:])-mini
zahyo = [n-mini for n in input_data[1:]]
energy=[0 for i in range(length+1)]
for i in range(length+1):
    for j in range(input_data[0]):
        energy[i]=energy[i]+(i-zahyo[j])**2
print(min(energy))


### FIXED CODE ###

N= int(input())
input_data = [int(x) for x in input().split()]
mini = min(input_data)
length=max(input_data)-mini
zahyo = [n-mini for n in input_data]
energy=[0 for i in range(length+1)]
for i in range(length+1):
    for j in range(N):
        energy[i]=energy[i]+(i-zahyo[j])**2
print(min(energy))
import math

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

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

b_sum = B - ((B//C) + (B//D) - (B//lcm(C,D)))

a = A-1
a_sum = a - ((a//C) + (a//D) - (a//lcm(C,D)))

print(b_sum-a_sum)

### FIXED CODE ###

from fractions import gcd

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

lcm = (C*D) // gcd(C,D)

b_sum = B - ((B//C) + (B//D) - (B//lcm))

a = A-1
a_sum = a - ((a//C) + (a//D) - (a//lcm))

print(b_sum - a_sum)