Harryxun/stf_run huggingface dataset:
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
N = int(input())
S = list(input())[:-1]
table = [0]*(N+3)
table[1] = 1
for i in range(2,N+3):
    num = i
    cnt = 0
    while num != 0:
        a = num % 2
        num = num // 2
        cnt += a
    p = i % cnt
    table[i] = table[p]+1
c = 0
for s in S:
    if s == "1":
        c += 1
ans = 0
plus = [0]*N
minus = [0]*N
p = 0
q = 0
for i in range(N):
    ss = S[N-1-i]
    p += int(ss)*pow(2,i,c+1)
    if c != 1:
        q += int(ss)*pow(2,i,c-1)
    p %= (c+1)
    q %= (c-1)
for i in range(N):
    ss = S[i]
    if ss == "0":
        ans = (p+pow(2,N-1-i,c+1))%(c+1)
        print(table[ans]+1)
    else:
        if c == 1:
            print(0)
        else:
            ans = (p-pow(2,N-1-i,c-1))%(c-1)
            print(table[ans]+1)
        

### FIXED CODE ###

import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
N = int(input())
S = list(input())
table = [0]*(N+5)
table[1] = 1
for i in range(2,N+3):
    num = i
    cnt = 0
    while num != 0:
        a = num % 2
        num = num // 2
        cnt += a
    p = i % cnt
    table[i] = table[p]+1
c = 0
for s in S:
    if s == "1":
        c += 1
p = 0
q = 0

for i in range(N):
    ss = S[N-1-i]
    p += int(ss)*pow(2,i,c+1)
    if c != 1:
        q += int(ss)*pow(2,i,c-1)
    p %= (c+1)
    if c != 1:
        q %= (c-1)
for i in range(N):
    ss = S[i]
    if ss == "0":
        ans = (p+pow(2,N-1-i,c+1))%(c+1)
        print(table[ans]+1)
    else:
        if c == 1:
            print(0)
        else:
            if c != 1:
                ans = (q-pow(2,N-1-i,c-1))%(c-1)
                print(table[ans]+1)
            else:
                print(0)
#!/usr/bin/env python

import copy

x = ['Front', 'Right', 'Back', 'Left']
y = ['Top', 'Front', 'Bottom', 'Back']
z = ['Top', 'Left', 'Bottom', 'Right']


def turn(dice, direction):
    turned_dice = copy.deepcopy(dice)
    # x?????????
    if direction == 'Right':
        for i in range(4):
            turned_dice[x[i]] = dice[x[(i+1)%4]]
    if direction == 'Left':
        for i in range(4):
            turned_dice[x[i]] = dice[x[(i-1)%4]]

    # y?????????
    if direction == 'North':
        for i in range(4):
            turned_dice[y[i]] = dice[y[(i+1)%4]]
    if direction == 'South':
        for i in range(4):
            turned_dice[y[i]] = dice[y[(i-1)%4]]

    # z?????????
    if direction == 'East':
        for i in range(4):
            turned_dice[z[i]] = dice[z[(i+1)%4]]
    if direction == 'West':
        for i in range(4):
            turned_dice[z[i]] = dice[z[(i-1)%4]]

    return turned_dice

if __name__ == '__main__':
    while True:
        n = int(input())
        if n == 0:
            break
        dice = {'Top': 1, 'Front': 2, 'Right': 3,
                'Left': 4, 'Back': 5, 'Bottom': 6}

        ret = 1
        for i in range(n):
            dice = turn(dice, input())
            ret += dice['Top']

        print(ret)

### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import copy

x = ['Front', 'Right', 'Back', 'Left']
y = ['Top', 'Front', 'Bottom', 'Back']
z = ['Top', 'Left', 'Bottom', 'Right']


def turn(dice, direction):
    turned_dice = copy.deepcopy(dice)
    # x?????????
    if direction == 'Right':
        for i in range(4):
            turned_dice[x[i]] = dice[x[(i+1)%4]]
    if direction == 'Left':
        for i in range(4):
            turned_dice[x[i]] = dice[x[(i-1)%4]]

    # y?????????
    if direction == 'North':
        for i in range(4):
            turned_dice[y[i]] = dice[y[(i+1)%4]]
    if direction == 'South':
        for i in range(4):
            turned_dice[y[i]] = dice[y[(i-1)%4]]

    # z?????????
    if direction == 'East':
        for i in range(4):
            turned_dice[z[i]] = dice[z[(i+1)%4]]
    if direction == 'West':
        for i in range(4):
            turned_dice[z[i]] = dice[z[(i-1)%4]]

    return turned_dice

if __name__ == '__main__':
    while True:
        n = int(input())
        if n == 0:
            break
        dice = {'Top': 1, 'Front': 2, 'Right': 3,
                'Left': 4, 'Back': 5, 'Bottom': 6}

        ret = 1
        for i in range(n):
            dice = turn(dice, input())
            ret += dice['Top']

        print(ret)
N, M = map(int, input().split())
a_n = list(map(int, input().split()))
a_n = [int(a_n[i]*1/2) for i in range(len(a_n))]
 
def lcm(lis):
    from fractions import gcd
    x = 0
    x = [(x * lis[i]) // gcd(x, lis[i]) for i in range(1, len(lis))]
    return x
res = lcm(a_n)
 
count = 0
p = 0
while res * (2 * p + 1) <= M:
    count += 1
    p += 1
print(count)

### FIXED CODE ###

N,M = map(int, input().split())
a_n = list(map(int, input().split()))
g = a_n.copy()
 
while not any(x%2 for x in g): g = [x//2 for x in g]
if not all(x%2 for x in g): print(0); exit(0)
def gcd(a,b):
  while b: a,b = b,a%b
  return a
lcm = lambda a,b: a*b//gcd(a,b)
tot = 1
for x in a_n: tot = lcm(tot,x//2)
print((M//tot+1)//2)
n = int(input())
data = list(map(int, input().split()))
data_d = data.sort(reverse = True)
a = sum(data_d[: : 2])
b = sum(data_d[1: : 2])
ans = a-b
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b = a.sort(reverse = True)
print(sum(a[::2])-sum(a[1::2]))
n,k=map(int,input())
if (n+1)//2>=k:
  print('YES')
else:
  print('NO')

### FIXED CODE ###

n,k=map(int,input().split())
if (n+1)//2>=k:
  print('YES')
else:
  print('NO')
A, B = int(input().split())
if A+B < 10:
    print(A+B)
else:
    print('error')

### FIXED CODE ###

A, B = list(map(int,input().split()))
if A+B < 10:
    print(A+B)
else:
    print('error')
# coding:utf-8
n,m,q=map(int,input().split())
dp = [[0 for i in range(n)] for j in range(n)]
for i in range(m):
    l,r=map(int,input().split())
    l-=1
    r-=1
    dp[l][r]+=1
for i in range(n):
    for j in range(n-1):
        dp[i][j+1]+=dp[i][j]
for j in range(n):
    for i in range(n-1,0,-1):
        dp[i-1][j]+=dp[i][j]
for i in range(n):
    p,q=map(int,input().split())
    p-=1
    q-=1
    if q==n-1:
        print(dp[p][q])
    else :
     print(dp[p][q]-dp[q][q])


### FIXED CODE ###

# coding:utf-8
n,m,qq=map(int,input().split())
dp = [[0 for i in range(n+5)] for j in range(n+5)]
for i in range(m):
    l,r=map(int,input().split())
    l-=1
    r-=1
    dp[l][r]+=1
for i in range(n):
    for j in range(n-1):
        dp[i][j+1]+=dp[i][j]
for j in range(n):
    for i in range(n-1,0,-1):
        dp[i-1][j]+=dp[i][j]
for i in range(qq):
    p,q=map(int,input().split())
    p-=1
    q-=1
    if q==n-1:
        print(dp[p][q])
    else :
     print(dp[p][q]-dp[q+1][q])
import collections
import math
import operator as op
from functools import reduce
import numpy as np
import math
import bisect


def main():
    A, B = list(map(int, input().split()))

    lcm = (A * B) // math.gcd(A, B)

    print(lcm)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import collections
import math
import operator as op
from functools import reduce
import numpy as np
import math
import bisect

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

def main():
    A, B = list(map(int, input().split()))

    ans = lcm(A, B)

    print(ans)


if __name__ == '__main__':
    main()
a=list(map(int,input().split()))
print (f"{a[2]} {a[0]} {a[1]}")

### FIXED CODE ###


A = list(map(int,input().split()))
n = A[0]
A[0] = A[2]
A[2] = A[1]
A[1] = n
print(A[0], A[1], A[2])
N, M = map(int, input().split())
A = list(map(int, input().split()))
daytofinish = sum(A)
if N-daytofinish < 0:
    print(-1)
else:
    print(N-daytofinish)

### FIXED CODE ###

import math
R = int(input(""))
C = 2 * math.pi * R
print(C)
import sys

S = int(sys.stdin.readline())
h = S / 3600
m = (S - h*3600)/60
s = S - h*3600 - m*60
pirnt("%d:%d:%d" % (h,m,s))

### FIXED CODE ###

import sys

S = int(sys.stdin.readline())
h = S / 3600
m = (S - h*3600)/60
s = S - h*3600 - m*60
print("%d:%d:%d" % (h,m,s))
a, b, c = [int(i) for i in input().split()]

print(c-(a-b))a

### FIXED CODE ###

a, b, c = [int(i) for i in input().split()]
if c-(a-b)<0:
    print(0)
else:
    print(c-(a-b))
s=input()
print("Yes" if （len(s)>=4 and s[:4]=="YAKI"）else "No")

### FIXED CODE ###

s=input()
print("Yes" if len(s)>=4 and s[:4]=="YAKI" else "No")
A, B, C, X, Y = map(int, input().split())
l = 0;
d = C - 0.5*A - 0.5*B
if(d<0):
    l=min(2*X, 2*Y)
else:
    l=0
print(str(int(A*X + B*Y + d*l)))

### FIXED CODE ###

S = input()
n = S.count("o")
print(str(700+100*n))
def main():
    N = int(input())
    A = list(map(int, input().split()))
    p = 10**9 + 7
    MAX = max(A)

    def primes(n):
        is_prime = [True] * (n + 1)
        is_prime[0] = False
        is_prime[1] = False
        for i in range(2, int(n**0.5) + 1):
            if not is_prime[i]:
                continue
            for j in range(i * 2, n + 1, i):
                is_prime[j] = False
        return [i for i in range(n + 1) if is_prime[i]]
    PRIME_LIST = primes(MAX)
    LCM = {num: 0 for num in PRIME_LIST}
    A2Factor = [{num: 0 for num in PRIME_LIST} for _ in range(N)]

    def factorization(n, idx):
        temp = n
        flag = 0
        for i in range(2, int(-(-n**0.5//1))+1):
            if temp%i==0:
                cnt=0
                while temp%i==0:
                    cnt+=1
                    temp //= i
                flag = 1
                LCM[i] = max(LCM[i], cnt)
                A2Factor[idx][i] = cnt
        if temp!=1:
            LCM[temp] = max(LCM[temp], 1)
            A2Factor[idx][temp] = 1 
        if not flag:
            LCM[n] = max(LCM[n], 1)
            A2Factor[idx][n] = 1
        return LCM, A2Factor

    for idx in range(N):
        LCM, A2Factor = factorization(A[idx], idx)

    ans = 0
    for i in range(N):
        ans_dict = {}
        tmp = 1
        for num in PRIME_LIST:
            ans_dict[num] = abs(LCM[num] - A2Factor[i][num])
        for key, value in ans_dict.items():
            tmp *= pow(key, value, p)
            tmp %= p
        ans += tmp%p
    print(ans % p)
main()

### FIXED CODE ###

from math import gcd

def lcm(a, b):
    return a*b//gcd(a,b)
def main():
    N = int(input())
    A = list(map(int, input().split()))
    mod = 10**9 + 7
    LCM = 1
    for a in A:
        LCM = lcm(LCM, a)
    ans = 0
    for a in A:
        ans += (LCM//a)
        

    print(ans % mod)
main()
n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(m)]
ans = n * (n - 1) // 2
result = [ans]
leader = [-1] * n
size = [1] * n
def leader_check(i):
    if leader[i]==-1:
        return i
    ln=leader_check(leader[i])
    leader[i]=ln
    return ln

for a, b in ab[:0:-1]:
    a, b = a - 1, b - 1
    la=leader_check(a)
    lb=leader_check(b)
    if la!=lb:
        leader[la]=lb
        ans-=size[la]*size[lb]
        size[lb]+=size[la]
    result.append(ans)

for i in result[::-1]:
    print(i)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5)
n, m = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(m)]

ans = n * (n - 1) // 2
result = [ans]
leader = [-1] * n
size = [1] * n


def leader_check(i):
    if leader[i] == -1:
        return i
    ln = leader_check(leader[i])
    leader[i] = ln
    return ln

for a, b in ab[:0:-1]:
    a, b = a - 1, b - 1
    la = leader_check(a)
    lb = leader_check(b)
    if la != lb:
        leader[la] = lb
        ans -= size[la] * size[lb]
        size[lb] += size[la]
    result.append(ans)

for i in result[::-1]:
    print(i)
a, b, c = input.split()

print(str(a[0] + str(b[1]) + str(c[2]))

### FIXED CODE ###

a = input()
b = input()
c = input()
print(a[0] + b[1] + c[2])
r = (int)input()
pi = 3.14159265358979

l = 2 * pi * r
s = pi * r**2

print("{0} {1}".format(s, l))

### FIXED CODE ###

r = float(input())
pi = 3.14159265358979

l = 2 * pi * r
s = pi * r**2

print("{0} {1}".format(s, l))
import fractions
N=int(input())
a = list(map(int, input().split()))

#------------最小公倍数---------------------
lcm = 1
for i in range(1, N):
    lmc = lcm * a[i] // fractions.lcm(lcm, a[i])
#------------------------------------------
b= []
for i in range(N):
    b.append(lcm //a[i])
ans=0

for j in b:
    ans +=(lcm// b)%1000000007


print(ans)


### FIXED CODE ###

import fractions
N=int(input())
a = list(map(int, input().split()))

#------------最小公倍数---------------------
lcm = a[0]
for i in range(1, N):
    lcm = lcm * a[i] // fractions.gcd(lcm, a[i])
#------------------------------------------
ans=0
for j in a:
    ans += lcm // j
print(ans % 1000000007)
from math import ceil
N, K = map(int,input().split())
A = list(map(int,input().split()))
def chk(L):
    cnt = 0
    for i in range(N):
        cnt += ceil(A[i]/L)-1
    return cnt <= K
l, r = 1, max(A)
while l <= r:
    m = (l+r)//2
    if chk(m):
        r = m-1
    else:
        l = m+1
print(max([x for x in [m-1,m,m+1] if chk(x)]))

### FIXED CODE ###

from math import ceil
N, K = map(int,input().split())
A = list(map(int,input().split()))
def chk(L):
    cnt = 0
    for i in range(N):
        cnt += ceil(A[i]/L)-1
    return cnt <= K
l, r = 1, max(A)
while l <= r:
    m = (l+r)//2
    if chk(m):
        r = m-1
    else:
        l = m+1
print(min([x for x in [m-1,m,m+1] if x > 0 and chk(x)]))
A,B = map(int, input().split())
X = int((A/0.08)+0.5)
Y = int((B/0.1)+0.5)
min = 0

if X > Y:
    if int(X*0.1) == B:
        min = X
    else :
        min = -1
elif X < Y:
    if int(Y*0.08) == A:
        min = Y
    else :
        min = -1
else :
    min = X

print(min)

### FIXED CODE ###

S = input()
if S == 'AAA' or S == 'BBB':
    print('No')
else :
    print('Yes')
_ = input()
p = [int(x) for x in input().split()]

cnt = 0
for i in range(len(p)):
    if p[i] == i + 1:
        p[i], p[i+1] = p[i+1], p[i]
        cnt += 1
else:
    print(cnt)

### FIXED CODE ###

n = int(input())
p = [int(x) for x in input().split()]

cnt = 0
for i in range(n):
    if p[i] == i + 1:
        cnt += 1
        if i != n - 1:
            p[i], p[i+1] = p[i+1], p[i]
else:
    print(cnt)
N,K = map(int,input().split(" "))


H = sorted([int(input()) for i in range(N)],reverse=True)


#print(H)

L = []

for k in range(N-K+1):
    #print(k,k+1,k+2)
    
    L.append(H[k]-H[k+2])

print(min(L))


### FIXED CODE ###

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


H = sorted([int(input()) for i in range(N)],reverse=True)


#print(H)

L = []

for k in range(N-K+1):
    #print(k,k+1,k+2,k+K)
    
    L.append(H[k]-H[k+K-1])

print(min(L))
ans = "AKIHABARA"


if len(s) >= 9 and s != "AKIHABARA":
    print("NO")
else:
    for i in range(2**(9-len(s)+2)):
        lst = [""]*50
        for j in range(9-len(s)+2):
            if i&(1<<j):
                lst[j] = "A"
        #print(lst)
        
        result = ""               
        for k1,k2 in zip(lst,s+[""]):
            result += k1+k2
        #print(result)
        if result == "AKIHABARA":
            print("YES")
            exit()
        else:
            continue
    else:
        print("NO")

### FIXED CODE ###

s = list(input())

if len(s) >= 9 and "".join(s) != "AKIHABARA":
    print("NO")
elif "".join(s) == "AKIHABARA":
    print("YES")
else:
    for i in range(2**(len(s)+1)):
        lst = [""]*50
        for j in range(len(s)+1):
            if i&(1<<j):
                lst[j] = "A"
        #print(lst)
        
        result = ""               
        for k1,k2 in zip(lst,s+["",""]):
            result += k1+k2
        #print(result)
        if result == "AKIHABARA":
            print("YES")
            exit()
        else:
            continue
    else:
        print("NO")
N, M = map(int, input().split())
if (N==1 and M==1):
    print(0)
if (N==1):
    print(M-2)
if (M==1):
    print(N-2)
else:
    print((N-2)(M-2))

### FIXED CODE ###

from sys import stdin

N, M = map(int, stdin.readline().split())

print(abs(N * M - 2 * (N + M) + 4))
import math
from functools import reduce

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

n = int(input())
li = list(map(int,input().split()))
li2 = list(set(li))
li2.sort()
li3 = [li2[0]]

for i in range(n-1):
    li3.append(abs(li[i+1]-li[i]))

print(gcd_list(li2))


### FIXED CODE ###

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

while len(li) > 1:
  a = min(li)
  for i in range(len(li)):
    if li[i] != a:
      li[i] %= a
  li = list(set(li))
  if 0 in li:
    li.remove(0)
      
print(li[0])
N = int(input())

for x,y in product(range(1,3501), range(1,3501)):
    temp = (4/N) - (1/x) - (1/y)
    if temp > 0:
        z = 1/temp
        int_z = int(z)
        if int_z == z:
            print(x, y, int_z)
            exit()

### FIXED CODE ###

from itertools import product
N = int(input())

for h in range(1, 3501):
    for n in range(1, 3501):
        a = (4 * h * n - N * n - N * h)
        if a > 0 and (N * h * n) % a == 0:
            w = (N * h * n) / a
            int_w = int(w)
            if w == int_w:
                print(n,h,int_w)
                exit()
import math

def test():
    n = int(input())
    a = list(map(int,input().split()))
    ans = a[0]
    for i in a:
        ans = math.gcd(ans,i)
    print(ans)


if __name__ == "__main__":
    test()


### FIXED CODE ###

import fractions

def test():
    n = int(input())
    a = list(map(int,input().split()))
    ans = a[0]
    for i in a:
        ans = fractions.gcd(ans,i)
    print(ans)


if __name__ == "__main__":
    test()
n=int(input())
a=list(map(int,input().split()))
if 0 in a:
  print(0)
else:
  cnt=1
  for i in a:
    cnt*=i
    if cnt>10**18:
      cnt=-1
      break
print(cnt)  

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
if 0 in a:
  print(0)
else:
  cnt=1
  for i in a:
    cnt*=i
    if cnt>10**18:
      cnt=-1
      break
  print(cnt)
a, b = map(int, input().split())
print(a*b, 2*(a+B))

### FIXED CODE ###

a, b = map(int, input().split())
print(a*b, 2*(a+b))
MOD=10**9+7
n,k=map(int,input().split())
a=list(map(int,input().split()))

a.sort(reverse=True)

def mod_combination(n, k, mod):
    # nCk (mod m)
    def mod_permutation(n, k, mod):
        if n<=k:
            return 1
        else:
            return (n * mod_permutation(n-1,k,mod))%mod

    def mod_inv_permutation(k, mod):
        k, mod = int(k), int(mod)
        if k<=1:
            return 1
        else:
            return (pow(k,mod-2,mod) * mod_inv_permutation(k-1, mod))%mod

    return (mod_permutation(n,n-k,mod) * mod_inv_permutation(k, mod))%mod
  
  
c=[]
for i in range(1,k):
  c.append(mod_combination(n-i,k-1,MOD))
lc=len(c)
sum=0
for i in range(lc):
  sum+=c[i]*(a[i]-a[-i-1])%MOD
  
print(sum%MOD)


### FIXED CODE ###

MOD=10**9+7
n,k=map(int,input().split())
a=list(map(int,input().split()))

a.sort(reverse=True)


fact = [1]
fact_inv = [1]
mod=10**9+7
for i in range(10**5+1):
    new_fact = fact[-1]*(i+1)%mod
    fact.append(new_fact)
    fact_inv.append(pow(new_fact,mod-2,mod))


def mod_comb_k(n,k,mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod

  
c=[]
for i in range(1,n-k+1+1):
  c.append(mod_comb_k(n-i,k-1,MOD))
lc=len(c)
#print(c,a)
sum=0
for i in range(lc):
  sum+=c[i]*(a[i]-a[-i-1])%MOD
  
print(sum%MOD)
def main():
	t = map(int, input().split())
	a = map(int, input().split())
	b = map(int, input().split())
	
	d_0_a = a[0]*t[0]
	d_1_a = a[1]*t[1]
	d_0_b = b[0]*t[0]
	d_1_b = b[1]*t[1]
	
	d_ave_a = d_0_a+d_1_a
	d_ave_b = d_0_b+d_1_b
	
	if d_ave_a == d_ave_b:
		return 'infinity'
	
	diff_0 = d_0_a - d_0_b
	diff_1 = d_1_a - d_1_b
	diff_ave = d_ave_a - d_ave_b
	
	if diff_0*diff_1 > 0:
		return 0
		
	diff_diff_0 = diff_ave + diff_0
	diff_diff_1 = diff_ave + diff_1
	
	if diff_0*diff_ave < 0:
		return -diff_diff_0//diff_ave + 1
	else:
		return -diff_diff_1//diff_ave + 1
	
	
if __name__ == '__main__':
	print(main())

### FIXED CODE ###

def main():
    t = list(map(int, input().split()))
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    diff_0 = a[0]-b[0]
    diff_1 = a[1]-b[1]

    if diff_0*diff_1 > 0:
        return 0
    
    d_one_iter = diff_0*t[0]+diff_1*t[1]

    if diff_0*d_one_iter > 0:
        return 0
    if diff_0*d_one_iter == 0:
        return 'infinity'
    
    if abs(diff_0*t[0])%abs(d_one_iter) == 0:
        return 2*abs(diff_0*t[0])//abs(d_one_iter)
    else:
        return 2*(abs(diff_0*t[0])//abs(d_one_iter))+1

if __name__ == "__main__":
    print(main())
s, t=map(int, input().split())
cnt=0
for i in range(0, 3)
if s[i]==t[i]:
  cnt +=1
print(cnt)

### FIXED CODE ###

s = input()
t = input()
cnt = 0
for i in range(3):
  if s[i] == t[i]:
  	cnt += 1
print(cnt)