Harryxun/stf_run huggingface dataset:
n,m,p = map(int,input().split())
graph = [[] for _ in range(n)]
INF = float("inf")
dist = [INF]*n
dist[0] = 0

for _ in range(m):
	f,t,c = map(int,input().split())
	graph[f-1].append((t-1,p-c))
#print(graph)

for _ in range(n):
	update = False
	for f,e in enumerate(graph):
		for t,c in e:
			if dist[f] != INF and dist[t] > dist[f] + c:
				dist[t] = dist[f] + c
				update = True
	if not update:
		break
else:
	prev = dist[-1]
    for _ in range(n):
		for f,e in enumerate(graph):
			for t,c in e:
				if dist[f] != INF and dist[t] > dist[f] + c:
					dist[t] = -INF
	if dist[-1] != prev:
		print(-1)
		exit()
#print(dist)

print(max(0,dist[-1]*(-1)))

### FIXED CODE ###

n,m,p = map(int,input().split())
graph = [[] for _ in range(n)]
INF = float("inf")
dist = [INF]*n
dist[0] = 0

for _ in range(m):
	f,t,c = map(int,input().split())
	graph[f-1].append((t-1,p-c))
#print(graph)

for _ in range(n):
	update = False
	for f,e in enumerate(graph):
		for t,c in e:
			if dist[f] != INF and dist[t] > dist[f] + c:
				dist[t] = dist[f] + c
				update = True
	if not update:
		break
else:
	prev = dist[-1]
	for _ in range(n):
		update = False
		for f,e in enumerate(graph):
			for t,c in e:
				if dist[f] != INF and dist[t] > dist[f] + c:
					dist[t] = dist[f] + c
					update = True
		if not update:
			break
	if dist[-1] != prev:
		print(-1)
		exit()
#print(dist)

print(max(0,dist[-1]*(-1)))
n = int(input())
S = input()
l = int(input())
A = S[l+1]
for i in range(n):
  if S[i] != A:
    S[i] = '*'
print(S)


### FIXED CODE ###

n = int(input())
s = input()
k = int(input())
for i in range(n):
  if s[i] != s[k-1]:
    s = s.replace(s[i], '*')
print(s)
import math
N=int(input())
A=list(map(int,input().split()))
x=0
if 0 in A:
    y=True
    A.remove(0)
for i in A:
    x+=math.log(i,10)
if y==True:
    print(0)
elif x<=18.1:
    prod=1
    for i in A:
        prod=prod*i
    if prod<1e18:
        print(prod)
else:
    print('-1')


### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
A.sort()
if A[0]==0:
    print('0')
    A.remove(0)
    exit()
prod=1
for i in A:
    prod=prod*i
    if prod>1e18:
        print('-1')
        exit()
else:
    print(prod)
N = int(input())
S = [input() for i in range(N)]
S.sort()
c = 1
for i in range(N-1):
  if S[i] == S[i+1]:
    continue
  else: 
    c++
print(c)

### FIXED CODE ###

N = int(input())
S = [input() for i in range(N)]
S.sort()
c = 1
for i in range(N-1):
  if S[i] == S[i+1]:
    continue
  else:
    c += 1
print(c)
import math
n=int(input())
 
for i in range (1,n+1):
  ans=0
  for x in range(1,int(i*2/3)):
   for y in range(1,int(i*2/3)):
    for z in range(1,int(i*2/3)):
     if x+y+z==math.sqrt(i+x*y+x*z+y*z):
       ans+=1
       if x==y and y==z:
        break
  print(ans) 

### FIXED CODE ###

l,r,k=map(int,input().split())
ans=0
for i in range(l,r+1):
 if i%k==0:
  ans+=1
 else:
  pass
print(ans)
import sys

for line in sys.stdin.readlines():
    if line == 0:
        break
    else:
        count = 0
        if i in line:
            count += 1
    print("Case " + str(count) + ": " + str(line))

### FIXED CODE ###

i = 0
while True:
    n = int(input())
    if n == 0: 
        break
    else:
        i += 1
    print("Case " + str(i) + ": " + str(n))
import math
import itertools
import heapq
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque


# d = defaultdict(lambda: 0)
# setrecursionlimit(10**7)
# inf = float("inf")


##### stdin ####
def LM(t, r): return list(map(t, r))
def R(): return stdin.readline()
def RS(): return R().split()
def I(): return int(R())
def F(): return float(R())
def LI(): return LM(int,RS())
def LF(): return LM(float,RS())
def ONE_SL(): return list(input())
def ONE_IL(): return LM(int, ONE_SL())
def ALL_I(): return map(int, stdin)
def ALL_IL(): return LM(int,stdin)

##### tools #####
def ap(f): return f.append
def pll(li): print('\n'.join(LM(str,li)))
def pljoin(li, s): print(s.join(li))

##### main #####



def main():
	x,y = LI()

	ans=
	while x<=y:
		x*=2
		ans+=1
		
	print(ans)

if __name__ == '__main__':
	main()

### FIXED CODE ###

import math
import itertools
import heapq
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque


# d = defaultdict(lambda: 0)
# setrecursionlimit(10**7)
# inf = float("inf")


##### stdin ####
def LM(t, r): return list(map(t, r))
def R(): return stdin.readline()
def RS(): return R().split()
def I(): return int(R())
def F(): return float(R())
def LI(): return LM(int,RS())
def LF(): return LM(float,RS())
def ONE_SL(): return list(input())
def ONE_IL(): return LM(int, ONE_SL())
def ALL_I(): return map(int, stdin)
def ALL_IL(): return LM(int,stdin)

##### tools #####
def ap(f): return f.append
def pll(li): print('\n'.join(LM(str,li)))
def pljoin(li, s): print(s.join(li))

##### main #####



def main():
	x,y = LI()

	ans=0
	while x<=y:
		x*=2
		ans+=1
		
	print(ans)

if __name__ == '__main__':
	main()
x, a, b = map(int, input().split())
 
if abs(x-a) > abs(x-b):
  print(A)
else:
  print(B)

### FIXED CODE ###

x, a, b = map(int, input().split())
 
if abs(x-a) > abs(x-b):
  print("B")
else:
  print("A")
from scipy.special import comb

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

odd = 0
even = 0
for x in a:
    if x % 2 == 1:
        odd += 1
    else:
        even += 1

s_even = 0
for i in range(even):
    s_even += comb(even, i+1, exact=True)

s_odd = 0
ans = 0
if p == 0:
    for i in range(odd)[1::2]:
        s_odd += comb(odd, i+1, exact=True)
        ans = max(1,s_even) * max(1,s_odd) + s_odd
else:
    for i in range(odd)[::2]:
        s_odd += comb(odd, i+1, exact=True)
        ans = max(1,s_even) * max(1,s_odd) + s_odd

print(ans)

### FIXED CODE ###

from scipy.misc import comb

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

odd = 0
even = 0
for x in a:
    if x % 2 == 1:
        odd += 1
    else:
        even += 1

s_even = 0
for i in range(even+1):
    s_even += comb(even, i, exact=True)

s_odd = 0
ans = 0
if p == 0:
    for i in range(odd+1)[::2]:
        s_odd += comb(odd, i, exact=True)
        ans = s_even * s_odd
else:
    for i in range(odd)[1::2]:
        s_odd += comb(odd, i, exact=True)
        ans = s_even * s_odd

print(ans)
import math

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

start = 0
end = int(1e9)

cost = 0
while start <= end:
	n = int(start+(end-start)/2)
	cost = a * n + b * len(str(n))
	# if cost == x:
	# 	break
	if cost < x:
		start = n+1;
	else:
		end = n-1;

print(max(0, start-1))



### FIXED CODE ###

import math

a = input()

b = {
	"SUN":7,
	"MON":6,
	"TUE":5,
	"WED":4,
	"THU":3,
	"FRI":2,
	"SAT":1,
}

print(b[a])
from collections import deque
def resolve():
    N = int(input())
    As = list(map(int, input().split(" ")))
    pos = []
    neg = []
    for a in As:
        if a >= 0:
            pos.append(a)
        else:
            neg.append(a)
    pos = deque(sorted(pos))
    neg = deque(sorted(neg))
    x = 0
    y = 0
    ops = []
    while True:
        if len(pos) > 0 and len(neg) > 0:
            if len(pos) > len(neg):
                x = neg.popleft()
                y = pos.pop()
            else:
                x = pos.pop()
                y = neg.popleft()
        elif len(pos) > 1 and len(neg) == 0:
                x = pos.popleft()
                y = pos.pop()
        elif len(neg) > 1 and len(pos) == 0:
                x = pos.pop()
                y = pos.popleft()
        else:
            print("Error?")
            #raise Exception("Unreachable?")
        
        ops.append("{} {}".format(x, y))
        xmy = x - y

        if len(pos) == 0 and len(neg) == 0:
            print(xmy)
            break

        if xmy >= 0:
            pos.append(xmy)
        else:
            neg.appendleft(xmy)
        
    [print(i) for i in ops]

if '__main__' == __name__:
    resolve()

### FIXED CODE ###

from collections import deque
def resolve():
    N = int(input())
    As = list(map(int, input().split(" ")))
    pos = []
    neg = []
    for a in As:
        if a >= 0:
            pos.append(a)
        else:
            neg.append(a)
    pos = deque(sorted(pos))
    neg = deque(sorted(neg))
    x = 0
    y = 0
    ops = []
    while True:
        if len(pos) > 0 and len(neg) > 0:
            if len(pos) > len(neg):
                x = neg.popleft()
                y = pos.pop()
            else:
                x = pos.pop()
                y = neg.popleft()
        elif len(pos) > 1 and len(neg) == 0:
                x = pos.popleft()
                y = pos.pop()
        elif len(neg) > 1 and len(pos) == 0:
                x = neg.pop()
                y = neg.popleft()
        else:
            raise Exception("Unreachable?")
        
        ops.append("{} {}".format(x, y))
        xmy = x - y

        if len(pos) == 0 and len(neg) == 0:
            print(xmy)
            break

        if xmy >= 0:
            pos.append(xmy)
        else:
            neg.appendleft(xmy)
        
    [print(i) for i in ops]

if '__main__' == __name__:
    resolve()
n=int(input())
 
import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
  
ans=0
for a in range(1,n+1):
    for b in range(1,n+1):
        for c in range(1,n+1):
            
            ans+=gcd(a,b,c)  
print(ans)
n=int(input())

import math
from functools import reduce

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

  
ans=0
for a in range(1,n+1):
    for b in range(1,n+1):
        for c in range(1,n+1):
            
            ans+=gcd(a,b,c)  
print(ans)


### FIXED CODE ###

n=int(input())
 
import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
  
ans=0
for a in range(1,n+1):
    for b in range(1,n+1):
        for c in range(1,n+1):
            
            ans+=gcd(a,b,c)  
print(ans)
from collections import defaultdict
n, m=map(int, input().split())
p=[int(s)-1 for s in input().split()]
pair=[[int(s)-1 for s in input().split()] for _ in range(m)]
 
avl=defaultdict(list)
for pi in pair:
    avl[pi[0]].append(pi[1])
    avl[pi[1]].append(pi[0])
 
def trv(src, dst, alr=[]):
    ans=False
    if src==dst or dst in avl[src]:
        return True
    for a in avl[src]:
        if a not in alr:
            alr.append(a)            
            ans|=trv(a, dst, alr)
    return ans
 
cnt=0
for i,pi in enumerate(p):
    if trv(pi, i, []):
        cnt+=1
print(cnt)

### FIXED CODE ###

class UnionFind():
    def __init__(self,n):
        self.par=[i for i in range(n)]
    def root(self, x):
        if self.par[x]==x:
            return x
        else:
            self.par[x]=self.root(self.par[x])
            return self.par[x]
    def same(self,x,y):
        return self.root(x)==self.root(y)
    def unite(self,x,y):
        x=self.root(x)
        y=self.root(y)
        if x!=y:
            self.par[x]=y

n, m=map(int, input().split())
p=[int(s)-1 for s in input().split()]
pair=[[int(s)-1 for s in input().split()] for _ in range(m)]

uf=UnionFind(n)
for pi in pair:
    uf.unite(pi[0],pi[1])

cnt=0
for i, pi in enumerate(p):
    if uf.same(i,pi):
        cnt+=1
print(cnt)
n = int(input())
l = map(int, input().split())
print(l[::-1])

### FIXED CODE ###

input()
xs=reversed(input().split())
print(" ".join(xs))
N = int(input())
A = map(int, input().split)
print('{:.16g}'.format(1 / sum(x for x in A)))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
print('{:.16g}'.format(1 / sum(1 / x for x in A)))
#include <bits/stdc++.h>
using namespace std;

int main(void)
{
    long long X,K,D;
    long long ans = 0;
    cin >> X >> K >> D;

    if(K * D <  abs(X)){
        ans = abs(X) - K * D;
    }else{
        if( (abs(X) / D) % 2 == 0 ){
            if( K % 2 == 0){
                ans = abs(X) % D;
            }else{
                ans = abs(abs(X) % D  - D);
            }
            
        }else{
            if( K % 2 == 0){
                ans = abs(abs(X) % D  - D);
            }else{
                ans = abs(X) % D;
            }
        }
    }

    cout << ans << endl;

}


### FIXED CODE ###

X, K, D = map(int ,input().split())

if K * D < abs(X):
    ans = abs(X) - K * D
else:
    if abs(X) < D:
        if K % 2 == 0:
            ans = abs(X)
        else:
            ans= abs(abs(X) - D)
    else:
        if abs(X) // D % 2 == 0:
            if K % 2 == 0:
                ans = abs(X) % D
            else:
                ans = abs(abs(X) % D - D)
        else:
            if K % 2 == 0:
                ans = abs(abs(X) % D - D)
            else:
                ans = abs(X) % D

print(ans)
num = int(input())
area = num*num*3.14
circle = 2*3.14*num
print(area,circle)

### FIXED CODE ###

num = float(input())
area = num*num*3.141592653589
circle = 3.141592653589*(num*2)
print(area,circle)
l = [1, 9, 7, 4]

a, b, c, d = map(int, input().split())

if ( a in l && b in l && c in l && d in l):
  print("YES")
else:
  print("NO")



### FIXED CODE ###


ll = [1, 9, 7, 4]

a, b, c, d = map(int, input().split())

if ( a in ll ):
  ll.remove(a)
  if ( b in ll ):
    ll.remove(b)
    if ( c in ll ):
      ll.remove(c)
      if ( d in ll ):
        print("YES")
      else:
        print("NO")
    else:
      print("NO")
  else:
    print("NO")
else:
  print("NO")
N = int(input())

shiritori_set = set()

shiritori = input()
head = shiritori[len(shiritori) -1]

ans = "Yes"

for i in range(N-1):
  shiritori = input()
  if (shirotori[0] == head and shiritori in shiritori_set):
    head = shiritori[len(shiritori)-1]
    shiritori_set.add(shiritori)
    continue
  else:
    ans = "No"
    break

print(ans)


  
  

### FIXED CODE ###

N = int(input())

shiritori_set = set()

shiritori = input()
head = shiritori[len(shiritori) -1]

ans = "Yes"
shiritori_set.add(shiritori)
for i in range(N-1):
  shiritori = input()
  if shiritori[0] == head and shiritori not in shiritori_set:
    head = shiritori[len(shiritori)-1]
    shiritori_set.add(shiritori)
  else:
    ans = "No"
    break

print(ans)
x = str(input())
lx = len(x)
num = lx - 2
head = int(x[:num])
body = int(x[num:])
up = head * 5
ans = int(0)
if body <= up:
    ans = 1
else:
    ans = 0
if int(x) > 615 * 1000000:
    ans = 0
print(ans)

### FIXED CODE ###

x = str(input())
lx = len(x)
num = lx - 2
if int(x) >= 100:
    head = int(x[:num])
    body = int(x[num:])
    up = head * 5
    ans = int(0)
    if body <= up:
        ans = 1
    else:
        ans = 0
else:
    ans = 0
print(ans)
n=int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

m=0
# 0で初期化すると最初が1の時にだめ
at0
for i,ai in enumerate(a):
    m+=b[ai-1]
    if ai == at+1:
        m+=c[at-1]
    at=ai
print(m)

### FIXED CODE ###

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

m=0
at=-1
for i,ai in enumerate(a):
    m+=b[ai-1]
    if ai == at+1:
        m+=c[at-1]
    at=ai
print(m)
import fraction

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

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

dist_list = [abs(X - e) for e in x]
ans = dist_list[0]
for e in dist_list:
    ans = fraction.gcd(e, ans)


print(ans)


### FIXED CODE ###

def gcd(x, y):
    while y != 0:
        temp = y
        y = x % y
        x = temp
    return x


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

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

dist_list = [abs(X - e) for e in x]

ans = dist_list[0]
for e in dist_list:
    ans = gcd(ans, e)


print(ans)
n=int(input())
dict={}
xs=[]
for i in range(n):
  s=input()
  xs+=[s]
  if s not in dict:
    dict[s]=1
  else:
    dict[s]+=1
pin=0
xs=list(set(xs))
for i in xs:
  pin=max(pin,dict[xs])
ans=[]
for i in xs:
  if dict[i]==pin:
    ans*=[i]
ans.sort()
for i in ans:
  print(i)


### FIXED CODE ###

n=int(input())
dict={}
xs=[]
for i in range(n):
  s=input()
  xs+=[s]
  if s not in dict:
    dict[s]=1
  else:
    dict[s]+=1
pin=0
xs=list(set(xs))
for i in xs:
  pin=max(pin,dict[i])
ans=[]
for i in xs:
  if dict[i]==pin:
    ans+=[i]
ans.sort()
for i in ans:
  print(i)
x = int(input())

a = 100
i = 0

while a < x:
  i+ = 1
  a+ = i
  
  
print(i)
  



### FIXED CODE ###

x = int(input())

a = 100
i = 0

while a < x:
  i += 1
  a += a // 100
  
  
print(i)
N, W = map(int, input().split())
p = []
for it in range(N):
    p.append(list(map(int,input().split())))
    
MAX_WEIGHT = 1000000009
dp = [[MAX_WEIGHT for i in range(max_total+1)] for j in range(N+1)]
dp[0][0]=0
i = 0
for w, v in p:
    i += 1
    for target_val in range(0, max_total+1):
        
        if target_val-v >=0 and dp[i-1][target_val] > (dp[i-1][target_val-v]+w):
            dp[i][target_val] = dp[i-1][target_val-v]+w
        else:
            dp[i][target_val] = dp[i-1][target_val]
            
ret = 0
for v, w in enumerate(dp[N]):
    if w<=W and v>ret:
        ret = v
print(ret)

### FIXED CODE ###

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

max_total = 0
p = []
for it in range(N):
    p.append(list(map(int,input().split())))
    max_total += p[-1][1]
    
    
MAX_WEIGHT = 1000000009
dp = [[MAX_WEIGHT for i in range(max_total+1)] for j in range(N+1)]
dp[0][0]=0
i = 0
for w, v in p:
    i += 1
    for target_val in range(0, max_total+1):
        
        if target_val-v >=0 and dp[i-1][target_val] > (dp[i-1][target_val-v]+w):
            dp[i][target_val] = dp[i-1][target_val-v]+w
        else:
            dp[i][target_val] = dp[i-1][target_val]
            
ret = 0
for v, w in enumerate(dp[N]):
    if w<=W and v>ret:
        ret = v
print(ret)
A, B, C, D = map(int, input().split())
while A > 0 and C > 0:
    C = C - B
    A = A - D
if: A == 0:
    ans = 'No'
else:
    ans = 'Yes'
print(ans)


### FIXED CODE ###

A, B, C, D = map(int, input().split())
while A > 0 and C > 0:
    C = C - B
    if C <= 0:
        break
    else:
        A = A - D
if A <= 0:
    ans = 'No'
else:
    ans = 'Yes'
print(ans)
import sys
while 1:
	try:
		temp = input()
		if (temp==0):
			break
		N = temp
		a = []
		for i in range(N):
			a.append(map(int, raw_input().split())+[0])
		a.append([0 for i in range(0,temp+1)])	 
		for i in range(0,temp):#行に関して
			for j in range(0,temp):#列に関して
				a[i][temp] += a[i][j]
		for k in range(0,temp+1):#列に関して
			for l in range(0,temp):#行に関して
				a[temp][k] += a[l][k]
		for m in range(0,temp+1):
			for n in range(0,temp+1):
				sys.stdout.write(str(a[m][n]).rjust(5))
			print ""
	except(RuntimeError):
		pass

### FIXED CODE ###

import sys
try:
	while 1:
		temp = input()
		if (temp==0):
			break
		N = temp
		a = []
		for i in range(N):
			a.append(map(int, raw_input().split())+[0])
		a.append([0 for i in range(0,temp+1)])
		for i in range(0,temp):
			for j in range(0,temp):
				a[i][temp] += a[i][j]
		for k in range(0,temp+1):
			for l in range(0,temp):
				a[temp][k] += a[l][k]
		for m in range(0,temp+1):
			for n in range(0,temp+1):
				sys.stdout.write(str(a[m][n]).rjust(5))
			print ""
except(RuntimeError):
	pass
for time in range(int(input())):
	x,y,z = [int(i) for i in input().split()]
	if x^2 + y^2 == z^2:
		print(???YES???)
	else:
		print(???NO???)

### FIXED CODE ###

def tri(a,b,c):
	return a**2 == b**2 + c**2
for time in range(int(input())):
	x,y,z = [int(i) for i in input().split()]
	if tri(x,y,z) or tri(y,z,x) or tri(z,x,y):
		print("YES")
	else:
		print("NO")
A,P = map(int,input(),split())
print((A*3+P)//2)

### FIXED CODE ###

A,P = map(int,input().split())
print((A * 3+ P) // 2)
x=int(input())
if x==7 or x==5 or x==3:
    print(YES)
else:
    print(NO)

### FIXED CODE ###

x=int(input())

if x==7 or x==5 or x==3:
    print('YES')
else:
    print('NO')
n,k= map(int,input().split())
from math import factorial 
for i in range(1,k+1):
  if n-k+1-i >= i:
    print(int(((factorial(k-1)) * (factorial(n-k+1))/(factorial(i-1))/(factorial(k-i))/(factorial(i))/(factorial(n-k+1-i)))%(10**9+7)))
  else:
    print(0)

### FIXED CODE ###

import math
MOD = 10 ** 9 + 7

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


def f(n):
    return math.factorial(n)


for i in range(K):
    if N - K - i >= 0:
        print(f(N - K + 1) // f(N - K - i) // f(i + 1)
              * (f(K - 1) // f(K - i - 1) // f(i)) % MOD)
    else:
        print(0)
n = int(input())
char_list = input().split()
num_list = list(map(int, char_list))

def is_even(lis):
    return [x for x in lis if x % 2]

mod2_list = is_even(num_list)

i = 0
while mod2_list == []:
    num_list = [x / 2 for x in num_list]
    mod2_list = is_even(num_list)
    i += 1
    
print(i)

### FIXED CODE ###

char_list = list(input())
num_list = list(map(int, char_list))
out = sum(num_list)
print(out)
from fractions import gcd
N, M = map(int, input().split())
an = list(map(int, input().split()))

a = an[0]
for i in range(1, len(an)):
    GCD = gcd(a, an[i])
    x, y = a // GCD, an[i] // GCD
    if x % 2 == y % 2 == 1:
        a = x*y*z
    else:
        print(0)
        break
else:
    print(-(-M//a))

### FIXED CODE ###

import fractions
from functools import reduce
import numpy as np
import sys

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


def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


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


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def listdivide(list):
    numpy = np.array(list)
    numpy = numpy//2
    return numpy.tolist()


def divide2(x):
    res = 0
    while x % 2 == 0:
        x /= 2
        res += 1
    return res


# while gcd_list(an) % 2 == 0:
#     print(gcd_list(an))
an = listdivide(an)

t = divide2(an[0])
for i in range(1, N):
    if divide2(an[i]) != t:
        print(0)
        sys.exit()

for i in range(t):
    an = listdivide(an)
    M = M // 2

LCM = lcm_list(an)

if LCM > M == 0:
    print(0)
else:
    print(-(-(M // LCM)//2))
import itertools

N = int(input())
A = list(int(x) for x in input().split())

mod = 10**9+7
ans = 0
summ = 0

for i in range(N):
    summ += A[i]
    summ %= mod

for i in range(N):
    summ -= A[i]
    if summ < 0:
        sum += mod
    ans += A[i] * summ
    ans %= mod

print(ans)


### FIXED CODE ###

import itertools

N = int(input())
A = list(int(x) for x in input().split())

mod = 10**9+7

sum_ = 0
ans = 0

for i in range(N):
    ans += sum_ * A[i]
    ans %= mod
    sum_ += A[i]
    sum_ %= mod

print(ans)
a,b,c,d = map(int,input().split())
if a+b>c+d:
  print("Left")
elif a+b=c+d:
  print("Balanced")
else:
  print("Right")


### FIXED CODE ###

a,b,c,d = map(int,input().split())
if a+b>c+d:
  print("Left")
elif a+b==c+d:
  print("Balanced")
else:
  print("Right")
def num_divide_two(num: int):
    return int(format(num, 'b')[::-1].find("1"))

N = int(input())
print(sum(map(num_divide_two, map(int, input().split())))

### FIXED CODE ###

def num_divide_two(num: int):
    return int(format(num, 'b')[::-1].find("1"))

N = int(input())
print(sum(map(num_divide_two, map(int, input().split()))))
N, M = map(int, input().split())
A = list(map(int, input().split()))

if len([c for c in A if c > sum(A) / (4 * M)]) > M:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

# 1行、2変数を受け取るとき
X, Y, Z = map(int, input().split())

print("{} {} {}".format(Z, X, Y))
n = int(input())
a = list(map(int, input().split()))
print(max(a)-min)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
print(max(a)-min(a))