Harryxun/stf_run huggingface dataset:
n,k_num = map(int,input().split())
info =[list(map(int,input().split())) for i in range(n)]
li_x = []
li_y = []

for i in range(n):
 # if info[i][0] not in li_x:
    li_x.append(info[i][0])
 # if info[i][1] not in li_y:
    li_y.append(info[i][1])

li_x = sorted(li_x)
li_y = sorted(li_y)

bunpu = [[0]*n for i in range(n)]
for i in range(n):
  for j in range(n):
    if info[i][0]==li_x[j]:
      zahyo_x=j
      break
  for k in range(n):
    if info[i][0]==li_y[k]:
      zahyo_y=k
      break
  bunpu[zahyo_x][zahyo_y]=1

ruiseki = [[0]*n for i in range(n)]


for i in range(0,n):
  for j in range(0,n):
    ruiseki[i][j] = bunpu[i][j]
#横方向(j)の累積
for i in range(n):
  for j in range(1,n):
    ruiseki[i][j] = ruiseki[i][j-1] + ruiseki[i][j]
#縦方向(i)の累積
for j in range(n):
  for i in range(1,n):
    ruiseki[i][j] = ruiseki[i-1][j] + ruiseki[i][j]

#print(bunpu)
#print(ruiseki)

ans = float("inf")

#for i in range(len(li_x)):
#  for j in range(i,len(li_x)):
#    for k in range(len(li_y)):
#      for l in range(j,len(li_y)):
#        count = ruiseki[j][l]
#        if 0<=k-1:
#          count -= ruiseki[j][k-1]
#        if 0<=i-1:
#          count -= ruiseki[i-1][l]
#        if 0<=k-1 and 0<=i-1:
#          count += ruiseki[i-1][k-1]      
#        if count ==k_num:
#          ans = min(ans,(li_x[j]-li_x[i])*(li_y[l]-li_y[k]))
print(1)

### FIXED CODE ###

n,k_num = map(int,input().split())
info =[list(map(int,input().split())) for i in range(n)]
li_x = []
li_y = []

for i in range(n):
 # if info[i][0] not in li_x:
    li_x.append(info[i][0])
 # if info[i][1] not in li_y:
    li_y.append(info[i][1])

li_x = sorted(li_x)
li_y = sorted(li_y)

bunpu = [[0]*n for i in range(n)]
for i in range(n):
  for j in range(n):
    if info[i][0]==li_x[j]:
      zahyo_x=j
      break
  for k in range(n):
    if info[i][1]==li_y[k]:
      zahyo_y=k
      break
  bunpu[zahyo_x][zahyo_y]=1

ruiseki = [[0]*n for i in range(n)]


for i in range(0,n):
  for j in range(0,n):
    ruiseki[i][j] = bunpu[i][j]
#横方向(j)の累積
for i in range(n):
  for j in range(1,n):
    ruiseki[i][j] = ruiseki[i][j-1] + ruiseki[i][j]
#縦方向(i)の累積
for j in range(n):
  for i in range(1,n):
    ruiseki[i][j] = ruiseki[i-1][j] + ruiseki[i][j]

#print(bunpu)
#print(ruiseki)

ans = float("inf")

for i in range(len(li_x)):
  for j in range(i,len(li_x)):
    for k in range(len(li_y)):
      for l in range(k,len(li_y)):
        count = ruiseki[j][l]
        if 0<=k-1:
          count -= ruiseki[j][k-1]
        if 0<=i-1:
          count -= ruiseki[i-1][l]
        if 0<=k-1 and 0<=i-1:
          count += ruiseki[i-1][k-1]      
        if count ==k_num:
          ans = min(ans,(li_x[j]-li_x[i])*(li_y[l]-li_y[k]))
print(ans)
def a(t,i):
    if i = l - 1:
        if eval(t==7):
            print(t+"=7")
            exit()
        return
    a(t+"+"+N[i+1],i+1)
    a(t+"-"+N[i+1],i+1)

N = input()
l = len(N)
a(N[0],0)




 




### FIXED CODE ###

def dfs(i, Str, res):
    if i==3:
        if res==7:
            print(Str+"=7")
            exit()
        return
    
    dfs(i+1,Str+"+"+s[i+1],res+int(s[i+1]))
    dfs(i+1,Str+"-"+s[i+1],res-int(s[i+1]))

s=input()
dfs(0,s[0],int(s[0]))
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")
N=int(input())
A =list(map(int,input.split()))
for i in range(N):
  print(A.count(i+1))
  

### FIXED CODE ###

N =int(input())
A =list(map(int,input().split()))
l =[0]*N
for i in A:
  l[i-1]+=1
print(*l,sep="\n")
n,d=map(int,input().split())
x=[list(map(int,input().split()))]
ans=0
for i in range(n-1):
    for j in range(1,n-i):
        l=0
        for k in range(d):
            l+=(x[i][k]-x[i+j][k])**2
        l=l**0.5
        if l.is_integer()==True:
            ans+=1
print(ans)

### FIXED CODE ###

n,d=map(int,input().split())
x=[list(map(int,input().split()))for _ in range(n)]
ans=0
for i in range(n-1):
    for j in range(1,n-i):
        l=0
        for k in range(d):
            l+=(x[i][k]-x[i+j][k])**2
        l=l**0.5
        if l.is_integer()==True:
            ans+=1
print(ans)
import numpy as np
n = int(input())
print(np.sum(np.arange(n)))

### FIXED CODE ###

n = int(input())
d,m = divmod(n,2)
if m != 0:
    print(n*d)

else:
    print(n*(d - 1) + d)
a = input()
print(a*a*a)
print()


### FIXED CODE ###

a = input()
a = int(a)

print( a**3)
print('red' if int(int(input())<3200 else input())

### FIXED CODE ###

print('red' if int(input())<3200 else input())
import numpy as np
N, M = map(int, input().split())

l = [list(map(int, input().split())) for _ in range(M)]
l = np.array(l)
ans = list(range(l[:, 0].max(), l[:, 1].min() + 1))
print(len(ans))

### FIXED CODE ###

import numpy as np
N, M = map(int, input().split())

l = [list(map(int, input().split())) for _ in range(M)]
l = np.array(l)
ans = list(range(l[:, 0].max(), l[:, 1].min() + 1))
print(len(ans))
n,k=map(int,input().split())
a = list(map(int,input().split()))
minus = [abs(a[i]) for i in range(n) if a[i] < 0][::-1]

plus = [a[i] for i in range(n) if a[i] > 0]

min_ = 10**18

if len(plus) == 0:
  print(minus[k-1])
elif len(minus) == 0:
  print(plus[k-1])
elif len(plus) < len(minus):
  for i in range(min(k, len(plus))):
    min_ = min(min_, 2*plus[i]+minus[k-2-i], plus[i]+2*minus[k-2-i])
  print(min_)
else:
  for i in range(min(k, len(minus))):
    min_ = min(min_, 2*minus[i]+plus[k-2-i], minus[i]+2*plus[k-2-i])
  print(min_)  
  


### FIXED CODE ###

n,k=map(int,input().split())
a = list(map(int,input().split()))
minus = [0]+[abs(a[i]) for i in range(n) if a[i] < 0][::-1]

plus = [0]+[a[i] for i in range(n) if a[i] >= 0]

min_ = 10**18

if len(plus) == 1:
  print(minus[k])
elif len(minus) == 1:
  print(plus[k])
else:
  for i in range(min(k+1, len(plus))):
    if k-i < len(minus):
      min_ = min(min_, 2*plus[i]+minus[k-i], plus[i]+2*minus[k-i])
  print(min_)
N=(int)(input())
p=(input()).split(' ')

count=0


now=1
for k in p:
    if (int)(k)==now:
        p[now-1:now+1]=[p[now],p[now-1]]
        count=count+1
    now=now+1

print(count)

### FIXED CODE ###

N=(int)(input())
p=(input()).split(' ')

count=0


now=1
for k in p:
    if (int)(k)==now:
        p[now-1:(now+1 if now<len(p) else now-3)]=[p[now-2],p[now-1]]
        count=count+1
    now=now+1

print(count)
# -*- coding: utf-8 -*-
import sys,math
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    def dfs(res, flag, depth):
        if depth == N:
            return res
        if flag:
            return dfs(math.gcd(res, A[depth]), True, depth + 1)
        else:
            return max( dfs(res, True, depth + 1), dfs(math.gcd(res, A[depth]), False, depth + 1))

    N = int(lines.pop(0))
    A = list(map(int, lines.pop(0).split(' ')))
    print(dfs(0, False, 0) )
lines = [x.strip() for x in sys.stdin.readlines()]
solve(lines)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys,fractions
from functools import reduce
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    N = int(lines.pop(0))
    A = list(map(int, lines.pop(0).split(' ')))

    _l = 0
    L = []
    for i in range(N-1):
        _l = fractions.gcd(_l, A[i])
        L.append(_l)
    L.insert(0,0)

    _r = 0
    R = []
    for i in range(N-1):
        _r = fractions.gcd(_r, A[N-i-1])
        R.append(_r)
    R.reverse()
    R.append(0)

    print(max([fractions.gcd(l,r) for l, r in zip(L,R)]))



lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)
import numpy as np
import copy
n,k=map(int,input().split())
p=list(map(int,input().split()))
p = np.array(p)
s = copy.deepcopy(p)
P = np.empty((k-1, n))
for i in range(k-1):
    P[i] = np.roll(p,(-i-1))
    s = s+P[i]
    s[-i-1] = 0
s.sort()
ans = (s[-1]/2)+0.5*k
print(ans)

### FIXED CODE ###

n,k=map(int,input().split())
p=list(map(int,input().split()))
s=[(i+1)/2 for i in p]
cans=sum(s[:k])
ans=cans
for i in range(n-k):
    cans=cans-s[i]+s[i+k]
    ans=max(ans,cans)
print(ans)
import sys
 
sys.setrecursionlimit(10 ** 8)

n = int(input())

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

odd = []
even = []

ans = [-1] * n
def dfs(x, last = -1, d = 0):
    if d%2 == 0: even.append(x)
    else: odd.append(x)
    for nxt in edge[x]:
        if nxt == last:
            continue
        dfs(nxt, x, d + 1)

dfs(0)

nums = [[],[],[]]
for i in range(1,n+1):
    nums[i%3].append(i)

for num in nums[1]:
    ans[odd.pop()] = num
for num in nums[2]:
    ans[even.pop()] = num
rest = nums[0] + nums[1] + nums[2]
for num in rest:
    if len(odd):
        ans[odd.pop()] = num
    elif len(even):
        ans[even.pop()] = num

print(*ans)


### FIXED CODE ###

import sys
 
sys.setrecursionlimit(10 ** 6)
n = int(input())
 
edge = [[] for i in range(n)]
ans = [-1] * n
odd = []
even =[]
nums = [[],[],[]]
for i in range(1,n+1):
    nums[i % 3].append(i)
 
def dfs(x, last = -1, d = 0):
    if d % 2 == 0: even.append(x)
    else: odd.append(x)
    for nxt in edge[x]:
        if nxt == last:continue
        dfs(nxt, x, d + 1)
 
for i in range(n-1):
    a, b = map(int, input().split())
    a-=1
    b-=1
    edge[a].append(b)
    edge[b].append(a)
 
dfs(0)
 
zerocnt = len(nums[0])
 
if len(even) <= zerocnt:
    for even_node in even:
        ans[even_node] = nums[0].pop()
    rest = nums[0] + nums[1] + nums[2]
    for odd_node in odd:
        ans[odd_node] = rest.pop()
 
elif len(odd) <= zerocnt:
    for odd_node in odd:
        ans[odd_node] = nums[0].pop()
    rest = nums[0] + nums[1] + nums[2]
    for even_node in even:
        ans[even_node] = rest.pop()
 

else:
    for num in nums[1]:
        ans[even.pop()] = num
    for num in nums[2]:
        ans[odd.pop()] = num
    rest = nums[0]
    for even_node in even:
        ans[even_node] = rest.pop()
    for odd_node in odd:
        ans[odd_node] = rest.pop()
 
print(*ans)
a = list(int(input()) for _  in range(5))
k = int(input())
ans='Yay!'
for i in a:
  for j in len(a):
    if a[j] - i >k:
      ans = ':('
print(ans)


### FIXED CODE ###

a = list(int(input()) for _  in range(5))
k = int(input())
ans='Yay!'
for i in a:
  for j in range(len(a)):
    if a[j] - i >k:
      ans = ':('
print(ans)
sys.setrecursionlimit(1000000)
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)
n = int(input())
A = list(map(int, input().split()))
def left(i):
    if i < 1:
        return 0
    return gcd(left(i-1), A[i-1])
def right(i):
    if i+1 > n-1:
        return 0
    return gcd(right(i+1), A[i+1])
ans = 0
for i in range(n):
    print(i, gcd(left(i), right(i)))
    ans = max(ans, gcd(left(i), right(i)))
print(ans)

### FIXED CODE ###

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)
n = int(input())
A = list(map(int, input().split()))
L = [0]*n
R = [0]*n
for i in range(n-1):
    R [i+1] = gcd(R[i], A[i])
    L[i+1] = gcd(L[i], A[-i-1])
print(max(gcd(R[i], L[-i-1]) for i in range(n)))
a,b,c=[int(x) for x in input().split()]
if a<b<c:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

a,b,c=[int(x) for x in input().split()]
if a<b<c:
    print("Yes")
else:
    print("No")
import bisect
n, k =  [ int(v) for v in input().split() ]
num_list = sorted([ tuple(map(int, input().split())) for i in range(n) ])
order_list, value_list = [ 0 for i in range(n) ], [ 0 for i in range(n) ]
for i in range(n):
	order_list[i] = num_list[i][1] + order_list[i-1]
	value_list[i] = num_list[i][0]


print(value_list[bisect.bisect(order_list,k)])

### FIXED CODE ###

n, k =  [ int(v) for v in input().split() ]
num_list = sorted([ tuple(map(int, input().split())) for i in range(n) ])
order_list, value_list = [ 0 for i in range(n) ], [ 0 for i in range(n) ]
for i in range(n):
	order_list[i] = num_list[i][1] + order_list[i-1]
	value_list[i] = num_list[i][0]


for i in range(n):
	if order_list[i] - k >= 0:
		print(value_list[i])
		break
import numpy as np
import sys
read = sys.stdin.buffer.read


N, M, K = map(int, input().split())
AB = np.array(read().split(), np.int32)
A = [0] + np.cumsum(AB[:N]).tolist()
B = [0] + np.cumsum(AB[N:]).tolist()
assert (N == len(A) - 1) and (M == len(B) - 1)

left = 0
for i, b in enumerate(B):
    if b > K:
        left = i - 1
        break

ans = 0
if A[-1] + B[-1] <= K:
    ans = N + M
else:
    for i in range(len(A)):
        if A[i] > K:
            break

        while A[i] + B[left] > K:
            left -= 1

        ans = max(ans, left + i)

print(ans)

### FIXED CODE ###

import numpy as np
import sys
read = sys.stdin.read


N, M, K = map(int, input().split())
AB = np.array(read().split(), np.int32)
A = [0] + np.cumsum(AB[:N]).tolist()
B = [0] + np.cumsum(AB[N:]).tolist()
assert (N == len(A) - 1) and (M == len(B) - 1)

ans = 0
left = M
for i in range(len(A)):
    if A[i] > K:
        break

    while A[i] + B[left] > K:
        left -= 1

    ans = max(ans, left + i)

print(ans)
a, b = map(str, input().split())
c = int(a+b)
ans = 0
for i in range(c+1):
    if i ** 2 == c:
        ans +=1
        break
if ans == 1:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

l = list(map(int, input().split()))
l.sort()

i = 0
while l[1] != l[2]:
  l[0], l[1] = l[0]+1, l[1]+1
  i += 1

if l[0] == l[1]:
  print(i)
  exit()
elif l[0]%2 == l[1]%2:
  i += (l[1] - l[0])//2
  print(i)
  exit()
else:
  i += (l[1]+1-l[0])//2+1
  print(i)
  exit()
def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	divisors.sort()
	return divisors


N = int(input())
divs = make_divisors(N)
if len(divs) % 2 == 0:
    print(divs[len(divs)//2 - 1] + divs[len(divs)//2] - 2)
else:
    print(divs[len(divs//2)] * 2 - 2)


### FIXED CODE ###

def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	divisors.sort()
	return divisors


N = int(input())
divs = make_divisors(N)
if len(divs) % 2 == 0:
    print(divs[len(divs)//2 - 1] + divs[len(divs)//2] - 2)
else:
    print(divs[len(divs)//2] * 2 - 2)
# -*- coding:utf-8 -*-
import sys

def dfs(x, y, sym):
	tile[x][y] = "."
	for i in range(len(DX)):
		nx = x + DX[i]
		ny = y + DY[i]
		if nx>=0 and nx<N and ny>=0 and ny<M and tile[nx][ny]==sym:
			dfs(nx, ny, sym)

def solve():
	res = 0
	for i in range(N):
		for j in range(M):
			sym = tile[i][j]
			if tile[i][j] != ".":
				if tile[i][j] == sym:
					dfs(i, j, sym)
					res += 1
	print(res)

counter=0
DX = [-1, 0, 1, 0]
DY = [0, -1, 0, 1]
sys.setrecursionlimit(1000000)
tile = [[0 for i in range(1)] for j in range(1)]
while True:
	counter+=1
	line = input()
	if ' ' in line:
		nums = line.split(" ")
		N = int(nums[0])
		M = int(nums[1])
		tile = [[0 for i in range(N)] for j in range(M)]
	if N is 0 and M is 0:
		break
	else:
		tile[counter-2] = list(line)
	if (counter-1)==M:
		solve()
		counter = 0

### FIXED CODE ###

# -*- coding:utf-8 -*-
import sys
def dfs(x, y, sym):
	tile[x][y] = "."
	for i in range(len(DX)):
		nx = x + DX[i]
		ny = y + DY[i]
		if (0<=nx and nx<N and 0<=ny and ny<M and tile[nx][ny] is sym):
			dfs(nx, ny, sym)

def solve():
	res = 0
	for i in range(N):
		for j in range(M):
			sym = tile[i][j]
			if tile[i][j] != ".":
				if tile[i][j] is sym:
					dfs(i, j, sym)
					res += 1
	print(res)

counter=0
DX = [-1,0,1,0]
DY = [0,-1,0,1]
sys.setrecursionlimit(10**7)
while True:
	line = input()
	if " " in line:
		nums = line.split(" ")
		N = int(nums[0])
		M = int(nums[1])
		tile = [[0 for i in range(M)] for j in range(N)]
	else:
		tile[counter-1] = list(line)
	if N is 0 and M is 0:
		break
	counter += 1
	if counter-1 is N:
		solve()
		counter = 0
N=int(input())
A=list(map(int,input().split()))
tmp=0
fugo=-1
for i in range(N):
    fugo*=-1
    tmp+=fugo*A[i]
ans.append(tmp)

for i in range(N):
    x=ans[i%N]
    ans.append(2*A[i%N]-x)

for x in ans:
    print(x_, end=' ')
print()

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
tmp=0
fugo=-1
ans=[]
for i in range(N):
    fugo*=-1
    tmp+=fugo*A[i]
ans.append(tmp)

for i in range(N-1):
    x=ans[i%N]
    ans.append(2*A[i%N]-x)

for x in ans:
    print(x, end=' ')
print()
import sys
input = sys.stdin.readline

MOD = 1000000007
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]

dp = [0]*(n+1)
dp[0] = 1

for i in range(1, n+1):
    if i in a:
        dp[i] = 0
    else:
        dp[i] += dp[i-1] + dp[i-2]
        dp[i] %= MOD

print(dp[n])

### FIXED CODE ###

l = list(map(int, input().split()))
l.sort()
print(sum(l[:2]))
a,b,c=map(input().split())
A=a.upper()
B=b.upper()
C=c.upper()
print(A[0]+B[0]+C[0])


### FIXED CODE ###

a,b,c=map(str,input().split())
A=a.upper()
B=b.upper()
C=c.upper()
print(A[0]+B[0]+C[0])
a, b = map(str, input().split())
import math

def square(a, b):
  total = int(a+b)
  if math.square(total).is_integer() == True
    print('yes')
  else:
    print('no')
 
square(a, b)

### FIXED CODE ###

a, b = map(str, input().split())
import math
 
def square(a, b):
  total = int(a+b)
  if math.sqrt(total).is_integer() == True:
    print('Yes')
  else:
    print('No')
 
square(a, b)
def addbit(i):
    i += 1
    while i <= N:
        BIT[i] += 1
        i += i & (-i)
def getsum(i):
    ret = 0
    i += 1
    while i != 0:
        ret += BIT[i]
        i -= i&(-i)
    return ret
def bit(L):
    global BIT
    BIT=[0] * (N+1)
    re = 0
    for l in L:
        re += getsum(l)
        addbit(l)
    return N*(N-1)//2 - re
def calc(Z):
    Z.sort()
    l, r, lc, rc = -1<<32, 1<<32, N*(N-1)//4, N*(N-1)//4
    f = 1
    while r - l > 0.000000001:
        m = (l * rc + r * lc) / (lc + rc)
        A = [a&((1<<16)-1) for a in sorted([(int((s*m+t)*2**40)<<16)+i for i, (s, t) in enumerate(Z)])]
        c = bit(A)
        if c > N*(N-1)//4:
            l = m
            lc = c - N*(N-1)//4
        else:
            r = m
            rc = max(N*(N-1)//4 - c, 1)
        
        f ^= 1
    return l

N = int(input())
X, Y = [], []
for _ in range(N):
    a, b, c = map(int, input().split())
    X.append((-a/b, c/b))
    Y.append((-b/a, c/a))
print(calc(X), calc(Y))

### FIXED CODE ###

def addbit(i):
    i += 1
    while i <= N:
        BIT[i] += 1
        i += i & (-i)
def getsum(i):
    ret = 0
    i += 1
    while i != 0:
        ret += BIT[i]
        i -= i&(-i)
    return ret
def bit(L):
    global BIT
    BIT=[0] * (N+1)
    re = 0
    for l in L:
        re += getsum(l)
        addbit(l)
    return N*(N-1)//2 - re
def calc(Z):
    Z.sort()
    l, r, lc, rc = -1<<28, 1<<28, N*(N-1)//4+1, N*(N-1)//4+1
    f = 1
    while (r - l) / max(abs(l), 1) > 0.000000001:
        m = (l+r) / 2 if f else (l * rc + r * lc) / (lc + rc)
        A = [a&((1<<16)-1) for a in sorted([(int((s*m+t)*2**40)<<16)+i for i, (s, t) in enumerate(Z)])]
        c = bit(A)
        if c > N*(N-1)//4:
            l = m
            lc = (c - N*(N-1)//4) * 2
        else:
            r = m
            rc = (N*(N-1)//4 - c) * 2 + 1
        f ^= 1
    return l

N = int(input())
X, Y = [], []
for _ in range(N):
    a, b, c = map(int, input().split())
    X.append((-a/b, c/b))
    Y.append((-b/a, c/a))
print(calc(X), calc(Y))
t=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
p,q=[0],[0]
x,y=[(a[0]-b[0])*t[0],(a[1]-b[1])*t[1]]
if x+y==0:
    print("infinity")
elif (x<0 and y<0) or (x>0 and y>0):
    print(0)
elif (x<0 and x+(x+y)>0) or (x>0 and x+(x+y)<0):
    print(1)
elif x<0 and x+y>0:
    print(abs(x//(x+y))*2-1)
else:
    print(hhh)

### FIXED CODE ###

T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())
 
P = (A1 - B1) * T1
Q = (A2 - B2) * T2
if P > 0:
	P *= -1
	Q *= -1
 
if P + Q < 0:
	print(0)
elif P + Q == 0:
	print("infinity")
else:
	S = (-P) // (P + Q)
	T = (-P) % (P + Q)
	if T != 0:
		print(S * 2 + 1)
	else:
		print(S * 2)
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 23 21:04:33 2020

@author: naoki
"""

N = int(input()) # input the row A length "N" 
A = list(map(int,input().split())) # input the row of A 
Q = int(input()) # input the number of trying operation 
BC = [list(map(int,input().split())) for i in range(Q)]
S = 0
num = [0 for i in range(100001)] 
for i in A:
    S += i # Sum of all conponents of the row "A"
    num[i]+=1 

for B,C in BC:
    S = S + (C - B) * num[B+1]
    num[C+1] += num[B+1]
    num[B+1] = 0 
    print(S)



### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Tue Jun 23 21:04:33 2020

@author: naoki
"""

N = int(input()) # input the row A length "N" 
A = list(map(int,input().split())) # input the row of A 
Q = int(input()) # input the number of trying operation 
BC = [list(map(int,input().split())) for i in range(Q)]
S = 0
num = [0 for i in range(100001)] 
for i in A:
    S += i # Sum of all conponents of the row "A"
    num[i]+=1 

for B,C in BC:
    S = S + (C - B) * num[B]
    num[C] += num[B]
    num[B] = 0 
    print(S)
import itertools

N, M, X = list(map(int, input().split()))
a = [list( map( int, input().split() ) ) for i in range(N)]

for x in itertools.product([0,1], repeat=2):
  cost = 0
  level = [] * M
  judge = True
  ans = 1234567
  for i in range(N):
    if a[i] == 1:
      cost += a[i][0]
      level = [y + z for (y, z) in zip(level, a[i][1:])]
  for j in range(M):
    if any(level[k] < x for k in range(M)):
      judge = False
  if judge:
    ans = min(ans, cost)

if ans == 1234567:
  print(-1)
else:
  print(ans)

### FIXED CODE ###

n,m,x=map(int,input().split())
ca=[list(map(int,input().split())) for i in range(n)]
ans=100000000000000000
for i in range(2**n):
    check=[0]*m
    ans_=0
    for j in range(n):
        if ((i>>j)&1):
            ans_+=ca[j][0]
            for k in range(m):
                check[k]+=ca[j][k+1]
    #print(ans_)
    if all([l>=x for l in check]):
        #print(ans_)
        ans=min(ans,ans_)
if ans==100000000000000000:
    print(-1)
else:
    print(ans)
import heapq

N, M = tuple(map(int, input().split()))
A = list(map(lambda a: -1*int(a), input().split()))
heapq.heapify(A)

for _ in range(M):
    x = heapq.heappop(A)
    heapq.heappush(A, -(-x//2))

print(-1*sum(A))

### FIXED CODE ###

S  = list(input())

a = S[0]

if a =="S":
    print("Cloudy")
elif a == "C":
    print("Rainy")
else:
    print("Sunny")
n,m = [int(i) for i in input().split()]
a = [[]for i in range(n)]


for i in range(m):
    c,d = map(int,input().split())
    a =[c-1].append((d,i))
ans = [0]*m
for i,b in enumerate(a):
    b.sort()
    for k,(d,j) in enumerate(b):
        ans[j] = str(i+1).zfill(6)+str(k+1).zfill(6)
print(*ans,sep="\n")

### FIXED CODE ###

N,M=map(int, input().split())
A=[[] for i in range(N)]
 
for i in range(M):
  p,y=map(int, input().split())
  A[p-1].append((y, i))
 
X=[0]*M
for i,d in enumerate(A):
  d.sort()
  for k,(y,j) in enumerate(d):
    X[j]=str(i+1).zfill(6)+str(k+1).zfill(6)
print(*X,sep='\n')
n,m,q=map(int,input().split())
counts=[[0 for _ in range(n)]for _ in range(n)]

for _ in range(m):
    l,r=map(int,input().split())
    for i in range(l):
        for j in range(r-1,n):
            counts[i][j]+=1
for _ in range(q):
    l,r=map(int,input().split())
    print(counts[l-1][r-1])


### FIXED CODE ###

a,b=map(int,input().split())
print((a-1)*(b-1))
H,W,N = [int(input()) for i in range(3)]
a = N / W
b = N / H
if H < W :
  print(a)
  else:
    print(b)


### FIXED CODE ###

H,W,N = [int(input()) for i in range(3)]
for o in range(1,10000):
  if H <= W and N / o <= W:
    break
  elif H >= W and N / o <= H:
    break
print(o)
import psyco
psyco.full()

n = int(input())
values = input().split()
mult = 1

for i in range(len(values)):
  mult *= int(values[i])
  if mult > 10**18:
    mult = -1
    break
    
print(mult)


### FIXED CODE ###

def main():
  n = int(input())
  values = list(map(int, input().split()))
  if 0 in values:
    print(0)
    return

  mult = 1
  for i in values:
    mult *= i
    if mult > 1000000000000000000:
      print(-1)
      return
  print(mult)

main()