Harryxun/stf_run huggingface dataset:
from sys import stdin

n = int(stdin.readline().rstrip())
flowers = [int(x) for x in stdin.readline().rstrip().split()]


def watering(s, count):
    index_fwd = 10 ** 9
    index_back = 0
    for k in range(len(s)):
        if s[k] > 0:
            index_fwd = k
            break
    if index_fwd == 10 ** 9:
        return count
    for l in range(index_fwd, len(s)):
        if s[l] == 0:
            break
        index_back = l
    for m in range(index_fwd, index_back + 1):
        s[m] -= 1
    count += 1
    return watering(s, count)


print(watering(flowers, 0))

### FIXED CODE ###

from sys import stdin
import sys
sys.setrecursionlimit(10000)

n = int(stdin.readline().rstrip())
flowers = [int(x) for x in stdin.readline().rstrip().split()]


def watering(s, count):
    index_fwd = 10 ** 9
    index_back = 0
    for k in range(len(s)):
        if s[k] > 0:
            index_fwd = k
            break
    if index_fwd == 10 ** 9:
        return count
    for l in range(index_fwd, len(s)):
        if s[l] == 0:
            break
        index_back = l
    for m in range(index_fwd, index_back + 1):
        s[m] -= 1
    count += 1
    return watering(s, count)


print(watering(flowers, 0))
N,K = map(int,input().split())
h_list = [int(input()) for i in range(N)]
h_list.sort()
result = []
print(min([h_list[i+K-1]-h_list[i] for i in range(N-K+1)]))

### FIXED CODE ###

Day = int(input())
if(Day == 25):
  print("Christmas")
elif(Day == 24):
  print("Christmas Eve")
elif(Day == 23):
  print("Christmas Eve Eve")
else:
  print("Christmas Eve Eve Eve")
from collections import deque

h, w = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
base = ["#" *(w+4)]
base.append("#" * (w+4))
for n in range(h):
    base.append("##" + input() + "##")
base.append("#" * (w+4))
base.append("#" * (w+4))
ans = [[-1] * (w+4) for _ in range(h+4)]
for j in range(w+4):
    for i in range(h+4):
        if base[i][j] == "#":
            ans[i][j] = -2
ch+=1; cw+=1
dh+=1; dw+=1
ans[ch][cw] = 0
move = [[1, 0], [-1, 0], [0, 1], [0, -1]]
move2 = [
    [-2, -2], [-2, -1], [-2, 0], [-2, 1], [-2, 2], \
    [-1, -2], [-1, -1], [-1, 0], [-1, 1], [-1, 2], \
    [0, -2], [0, -1], [0, 0], [0, 1], [0, 2], \
    [1, -2], [1, -1], [1, 0], [1, 1], [1, 2], \
    [2, -2], [2, -1], [2, 0], [2, 1], [2, 2]]
q = deque([ch, cw])
one_time = deque()
while q:
    x, y = q.popleft()
    one_time.append([x, y])
    for i, j in move:
        v1, v2 = x+i, y+j
        if ans[v1][v2] == -1:
            ans[v1][v2] = ans[x][y]
            q.append([v1, v2])
    if len(q) == 0:
        while one_time:
            x2, y2 = one_time.popleft()
            for i, j in move2:
                v1, v2 = x2+i, y2+j
                if ans[v1][v2] == -1:
                    ans[v1][v2] = ans[x2][y2] + 1
                    q.append([v1, v2])
print(ans[dh][dw])

### FIXED CODE ###

from collections import deque
 
 
# In[30]:
 
 
def main():
    H,W = map(int, input().split())
    ch,cw = map(int, input().split())
    dh,dw = map(int, input().split())
    s = ["#"*(W+4)]
    s.append("#"*(W+4))
    for i in range(H):
        s.append("##"+input()+"##")
    s.append("#"*(W+4))
    s.append("#"*(W+4))
    
    ans = [[-1]*(W+4) for _ in range(H+4)]
    for i in range(H+4):
        for j in range(W+4):
            if s[i][j] == "#":
                ans[i][j] = -2
    ch += 1; cw += 1
    dh += 1; dw += 1
    ans[ch][cw] = 0
    
    move = [[-1,0],[1,0],[0,-1],[0,1]]
    magic = [
        [-2,-2],[-2,-1],[-2,0],[-2,1],[-2,2],\
        [-1,-2],[-1,-1],[-1,0],[-1,1],[-1,2],\
        [0,-2],[0,-1],[0,0],[0,1],[0,2],\
        [1,-2],[1,-1],[1,0],[1,1],[1,2],\
        [2,-2],[2,-1],[2,0],[2,1],[2,2]
        ]
    
    mylist = deque([[ch,cw]])
    mylist2 = deque([])
    while len(mylist) > 0:
        x,y = mylist.popleft()
        mylist2.append([x,y])
        for p,q in move:
            v1,v2 = x+p,y+q
            if ans[v1][v2] == -1:
                mylist.append([v1,v2])
                ans[v1][v2] = ans[x][y]
        if len(mylist) == 0:
            while len(mylist2) > 0:
                x2,y2 = mylist2.popleft()
                for v1,v2 in magic:
                    i,j = x2+v1,y2+v2
                    if ans[i][j] == -1:
                        ans[i][j] = ans[x2][y2]+1
                        mylist.append([i,j])
    print(ans[dh][dw])
 
if __name__ == "__main__":
    main()
s, w = map(int, input().split(""))
res = "safe"
if w >= s:
    res = "unsafe"
print(res)


### FIXED CODE ###

s, w = map(int, input().split(" "))
res = "safe"
if w >= s:
    res = "unsafe"
print(res)
a, b = map(int, raw_input().split())

print math.floor(a/b), a%b, a/b

### FIXED CODE ###

a, b = map(int, raw_input().split())
print '%d %d %f'%(a/b, a%b, float(a)/b)
a, b, c = map(int, input().split())
print(c % (a - b))


### FIXED CODE ###

a, b, c = map(int, input().split())
if(b + c >= a):
  print(b + c - a)
else:
  print(0)
N, K = map(int, input().split())
S = [int(i) for i in input()]

cnt_arr = [0]
idx = 0
cnt_seq_0 = 1
cnt_seq_1 = 0
cnt_seq_0_arr = []
cnt_seq_1_arr = []
idx_seq_0 = []

prev = 1
for i, s_i in enumerate(S):
    if s_i == 0:
        if prev == 0:
            cnt_seq_0 += 1
        elif prev == 1:
            cnt_seq_1_arr.append(cnt_seq_1)
            cnt_seq_1 = 1
        if prev != 0:
            idx_seq_0.append(i)
        if i == len(S) - 1:
            cnt_seq_0_arr.append(cnt_seq_0)
            cnt_seq_1_arr.append(0)
    elif s_i == 1:
        if prev == 1:
            cnt_seq_1 += 1
        elif prev == 0:
            cnt_seq_0_arr.append(cnt_seq_0)
            cnt_seq_0 = 1
        if i == len(S) - 1:
            cnt_seq_1_arr.append(cnt_seq_1)
    prev = s_i

r_cnt = {}

import heapq
sum_arr = []

if len(cnt_seq_0_arr) == 0:
    print(len(cnt_seq_1_arr))
else:
    sum_0 = cnt_seq_1_arr[0]
    for i in range(K):
        sum_0 += cnt_seq_0_arr[i] + cnt_seq_1_arr[i + 1]

    heapq.heappush(sum_arr, -sum_0)
    sum_i = sum_0

    for i in range(0, len(cnt_seq_0_arr) - K):
        sum_i += -cnt_seq_0_arr[i] - cnt_seq_1_arr[i] + cnt_seq_0_arr[i + K] + cnt_seq_1_arr[i + K + 1]
        heapq.heappush(sum_arr, -sum_i)

    print(-heapq.heappop(sum_arr))

### FIXED CODE ###

N, K = map(int, input().split())
S = [int(i) for i in input()]

now = 1
cnt = 0
nums = []
for i in range(N):
    if S[i] == now:
        cnt += 1
    else:
        nums.append(cnt)
        now = 1 - now
        cnt = 1
if cnt != 0:
    nums.append(cnt)

if len(nums) % 2 == 0:
    nums.append(0)

add = 2 * K + 1

# Calculate cumulative sums
cum_sum = [0]
for i in range(0, len(nums)):
    cum_sum.append(cum_sum[i] + nums[i])

# Solve
ans = 0
for i in range(0, len(nums), 2):
    l = i
    r = min(i + add, len(nums))
    ans = max(ans, cum_sum[r] - cum_sum[l])

print(ans)
def solve(string):
    n, t, *ct = map(int, string.split())
    c = [_c for _c, _t in zip(ct[::2], ct[1::2]) if _t <= t]
    return str(min(c)) if len(c) else "TLE"


if __name__ == '__main__':
    n, t = map(int, input())
    print(solve("{} {}\n".format(n, t) + "\n".join([input() for _ in n])))


### FIXED CODE ###

n, t = map(int, input().split(" "))
ct = [list(map(int, input().split(" "))) for _ in range(n)]
valid = [_ct for _ct in ct if _ct[-1] <= t]
if len(valid) > 0:
    print(sorted(valid, key=lambda x: x[0])[0][0])
else:
    print("TLE")
n, q = map(int, input().split())
g = [[] for i in range(n)]
for i in range(n - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)
xs = [0 for _ in range(n)]
for i in range(q):
    p, x = map(int, input().split())
    p -= 1
    xs[p] += x

costs = [0 for i in range(n)]


def rec(prev_v, v, value):
    next_value = value + xs[v]
    costs[v] = next_value
    for next_v in g[v]:
        if next_v == prev_v:
            continue
        rec(v, next_v, next_value)


rec(-1, 0, 0)
print(' '.join(map(str, costs)))


### FIXED CODE ###

import sys

n, q = map(int, sys.stdin.readline().split())
g = [[] for i in range(n)]
for i in range(n - 1):
    a, b = map(int, sys.stdin.readline().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)
xs = [0 for _ in range(n)]
for i in range(q):
    p, x = map(int, sys.stdin.readline().split())
    p -= 1
    xs[p] += x

visited = [False for _ in range(n)]
# def rec(prev_v, v, value):
#     if visited[v]:
#         return
#     visited[v] = True
#     next_value = value + xs[v]
#     costs[v] = next_value
#     for next_v in g[v]:
#         if next_v == prev_v:
#             continue
#         rec(v, next_v, next_value)
# rec(-1, 0, 0)

current_node = [0]
while len(current_node) > 0:
    next_node = []
    for v in current_node:
        visited[v] = True
        for next_v in g[v]:
            if visited[next_v]:
                continue
            next_node.append(next_v)
            xs[next_v] += xs[v]
    current_node = next_node

print(' '.join(map(str, xs)))
import fractions

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

a = A[0]
for i in range(1, N):
    gcc = a * A[i] // fractions.gcd(a, A[i])
    a = gcc
    
b = 0
for i in range(N):
    b = b + gcc // A[i]

c = b % (1000000000 + 7)
print(c)

### FIXED CODE ###

import fractions

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

a = 1
for i in range(N):
    g = a * A[i] // fractions.gcd(a, A[i])
    a = g
    
b = 0
for i in range(N):
    b = b + g // A[i]

c = b % (1000000007)
print(c)
N=input()

if N==3:
	print "2 5 63"
	quit()
elif N==4:
	print "2 5 20 63"
	quit()

#N>=5
#For 2 and 3
S=[2,3,4]
N-=3


x=N/4	# N=4x+b
b=N%4

for i in range(1,x+1):
	S.append(6*i)
	S.append(6*i+2)
	S.append(6*i+3)
	S.append(6*i+4)

if x%2==0:
	if b==0:
		pass
	elif b==1:
		S.append(6*(x+1)+3)
	elif b==2:
		S.append(6*(x+1))
		S.append(6*(x+1)+3)
	elif b==3:
		S.append(6*(x+1))
		S.append(6*(x+1)+3)
		S.append(6*(x+1)+6)
else:
	if b==0:
		S.remove(6*x+3)
		S.remove(6*x+6)
	elif b==1:
		S.append(6*(x+1))
	elif b==2:
		S.append(6*(x+1)+2)
		S.append(6*(x+1)+4)
	elif b==3:
		S.append(6*(x+1))
		S.append(6*(x+1)+2)
		S.append(6*(x+1)+4)	

for i in S:
	print i,


### FIXED CODE ###

N=input()

if N==3:
	print "2 5 63"
	quit()
elif N==4:
	print "2 5 20 63"
	quit()

#N>=5
#For 2 and 3
S=[2,3,4]
N-=3


x=N/4	# N=4x+b
b=N%4

for i in range(1,x+1):
	S.append(6*i)
	S.append(6*i+2)
	S.append(6*i+3)
	S.append(6*i+4)


if x%2==0:
	if b==0:
		S.remove(6*x+3)
		S.append(6*x+6)
	elif b==1:
		S.append(6*(x+1)+3)
	elif b==2:
		S.append(6*(x+1))
		S.append(6*(x+1)+3)
	elif b==3:
		S.append(6*(x+1))
		S.append(6*(x+1)+3)
		S.append(6*(x+1)+6)
else:
	if b==0:
		pass
	elif b==1:
		S.append(6*(x+1))
	elif b==2:
		S.append(6*(x+1)+2)
		S.append(6*(x+1)+4)
	elif b==3:
		S.append(6*(x+1))
		S.append(6*(x+1)+2)
		S.append(6*(x+1)+4)	

for i in S:
	print i,
def actual(a, b):
    if (a * b) % 2 == 0:
        return 'Even'

    return 'Odd

a, b = map(int, input().split())
print(actual(a, b))

### FIXED CODE ###

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

product = a * b

if product % 2 == 1:
    print('Odd')
else:
    print('Even')
r = input()
if r < 1200:
  print(ABC)
if 1200 <= r < 2800:
  print(ARC)
else:
  print(AGC)

### FIXED CODE ###

r = int(input())
if r < 1200:
  print('ABC')
elif 1200 <= r < 2800:
  print('ARC')
else:
  print('AGC')
ls = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
num = input()
print(ls[int(num)+1])


### FIXED CODE ###

ls = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
num = input()
print(ls[int(num)-1])
import math
def lcm(a,b):
    return (a*b)/int(ath.gcd(a,b))

N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

ans = T[0]
for i in range(1,N):
    ans = int(lcm(ans,T[i]))
print(int(ans))


### FIXED CODE ###

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


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


N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

t = T[0]
for i in range(N - 1):
    t = lcm(t,T[i+1])
print(t)
A = input()
B = input()
C = input()
X = input()
count = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            x = (a*500) + (b*100) + (c*50)
            if x == X:
                count += 1
print(count)
    

### FIXED CODE ###

A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            x = (a*500) + (b*100) + (c*50)
            if x == X:
                count += 1
print(count)
import math

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

n = int(input())
b = [1]*(n+5)
mod = 1e9 + 7
a = [int(i) for i in input().split()]
    
for i in range(n):
    for j in range(i+1,n):
        x = a[i]
        y = a[j]
        m = math.gcd(x,y)
        x //= m
        y //= m
        b[i] = lcm(b[i],y)
        b[j] = lcm(b[j],x)
sum = 0
for i in range(n):
    sum += b[i]
print(int(sum%mod))


### FIXED CODE ###

def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)
n=int(input())
mod=1000000007
s=[int(i) for i in input().split()]
ans=1
for i in s:
    ans*=i//gcd(ans,i)
print(sum(ans//i for i in s)%mod)
N, M = map(int, input().split())

INF = 10**7
dp = [INF]*2**N
dp[0] = 0
bits = set(0)
for i in range(M):
    a, b = map(int, input().split())
    d = sum((1<< (i - 1)) for i in  map(int, input().split()))
    add_set = set() # i個目の鍵を使ってbitsに新しく追加する分の状態を入れる
    for j in bits:
        jord = j | d
        dp[jord] = min(dp[jord], dp[j] + a)
        add_set.add(jord)
    bits |= add_set
    
if dp[- 1] == INF:
    print(- 1)
else:
    print(dp[- 1])

### FIXED CODE ###

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

INF = 10**7
dp = [INF]*2**N
dp[0] = 0

for i in range(M):
    a, b = map(int, input().split())
    d = sum((1<< (i - 1)) for i in  map(int, input().split()))    
    for j in range(2**N):
        jord = j | d
        dp[jord] = min(dp[j] + a, dp[jord])
        
if dp[- 1] == INF:
    print(- 1)
else:
    print(dp[- 1])
import collections
n = int(input())
for i in range(n):
    a = int(input())
  b=collections.Counter(a)
  print(len(b))


### FIXED CODE ###

from collections import Counter
n = int(input())
s = [input() for i in range(n)]
c = Counter(s)
c = list(c.items())
print(len(c))
import math
x = int(input())
b = 0
ans = []
while True:
    n = x - b**5
    a = int(math.pow(n, 1/5))
    if a**5 == n:
       ans.append(a)
       ans.append(-b)
       break
    b += 1

print(*ans)

### FIXED CODE ###

import math
x = int(input())
b = 0
ans = []
while True:
    n = x - b**5
    if n < 0:
        break
    a = int(math.pow(n, 1/5))
    if a**5 == n:
       ans.append(a)
       ans.append(-b)
       break
    b += 1

if len(ans) != 0:
    print(*ans)
else:
    b = 0
    while True:
        n = x + b**5
        a = int(math.pow(n, 1/5))
        if a**5 == n:
           ans.append(a)
           ans.append(b)
           break
        b += 1
    print(*ans)
from collections import deque
import sys
sys.setrecursionlimit(2000000)
N, M = map(int, input().split())
graph = [[] for j in range(M)]
q = deque([])
depth_array = [-1 for i in range(N)]

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

def bfs(graph, q, depth_array):
    # 終了条件
    if len(q) == 0:
        return depth_array

    cur_room = q.popleft()

    # キューに追加
    for r in graph[cur_room]:
        if depth_array[r] == -1: #未訪問なら
            q.append(r)
            depth_array[r] = depth_array[cur_room] + 1

    return bfs(graph, q, depth_array)
    
# init
q.append(0)
depth_array[0] = 0
depth_array = bfs(graph, q, depth_array)

mark_array = [-1 for i in range(N)]
#print(depth_array)

for room, depth in enumerate(depth_array):
    for node in graph[room]:
        if depth_array[node] + 1 == depth_array[room]:
            mark_array[room] = node
if -1 in mark_array[1:]:
    print("No")
else:
    print("Yes")
    for m in mark_array[1:]:
        print(m+1)


### FIXED CODE ###

from collections import deque
import sys
sys.setrecursionlimit(200000)
N, M = map(int, input().split())
graph = [[] for j in range(N)]
q = deque([])
depth_array = [-1 for i in range(N)]

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

def bfs(graph, q, depth_array):
    # 終了条件
    if len(q) == 0:
        return depth_array

    cur_room = q.popleft()

    # キューに追加
    for r in graph[cur_room]:
        if depth_array[r] == -1: #未訪問なら
            q.append(r)
            depth_array[r] = depth_array[cur_room] + 1

    return bfs(graph, q, depth_array)
    
# init
q.append(0)
depth_array[0] = 0
depth_array = bfs(graph, q, depth_array)

mark_array = [-1 for i in range(N)]
#print(depth_array)

for room, depth in enumerate(depth_array):
    for node in graph[room]:
        if depth_array[node] + 1 == depth_array[room]:
            mark_array[room] = node

if -1 in mark_array[1:]:
    print("No")
else:
    print("Yes")
    for m in mark_array[1:]:
        print(m+1)
n,m,x=map(int, input().split())
a=map(int, input().split())

for i in a:
  if x > int(i):
    left += 1
  elif x < int(i):
    righit =+ 1
print(min(left,right))

### FIXED CODE ###

n,m,x=map(int,input().split())
s=sum(int(i)<x for i in input().split())
print(min(s,m-s))
import math
while True:
    n=int(input())
    a=[int(x) for x in input().split()]
    if n==0:
        break
    else:
        m=sum(a)/n
        print("{0:.8f}".format(math.sqrt(sum([(x-m)**2/n for x in a]))))

### FIXED CODE ###

import math
while True:
    n = int(input())
    if n==0: break
    s = list(map(int,input().split()))
    m = sum(s)/float(n)
    print("{0:.8f}".format(math.sqrt(sum([(x-m)**2 for x in s])/n)))
h,n = map(int,input().split())
list1 = list(map(int,input().split()))

if h-sum(list1)<=0:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

h,a = map(int,input().split())

ans =1
while h-a>0:
    h-=a
    ans+=1

print(ans)
if input() == ABC:print("ARC") else:print("ABC")

### FIXED CODE ###

print("ABC" if input() == "ARC" else "ARC")
N = int(input())
A = list(map(int, input().split()))
for i in A:
    if i%2 == 0:
        count += 1
        if i%3 == 0 or i%5 == 0:
            check += 1
if count == check:
	print('APPROVED')
else:
	print('DENIED')

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
count = 0
check = 0
for i in A:
    if i%2 == 0:
        count += 1
        if i%3 == 0 or i%5 == 0:
            check += 1
if count == check:
	print('APPROVED')
else:
	print('DENIED')
n = int(input().split())

num1 =  ( n[0] * 3 + n[1] ) // 2

print(num1)

### FIXED CODE ###

n =input().split()

num1 =  ( int(n[0]) * 3 + int(n[1])) // 2

print(num1)
if len(input().split().set())==2:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

if len(set(input().split()))==2:
  print("Yes")
else:
  print("No")
n = int(input())
t1,x1,y1 = map(int, input().split())
t2,x2,y2 = map(int, input().split())


for p in [x1,y1,x2,y2]:
    if p < 0 or n < p:
        print('No')
        exit()

dt = t2 - t1
d  = abs(x2 - x1) + abs(y2 - y1)

if (d < dt) and (dt%2 == d%2):
    print('Yes')
else:
    print('No')


### FIXED CODE ###

n = int(input())
for i in range(n):
    t, x, y = map(int, input().split())
    if x + y > t or (x + y + t) % 2 == 1:
        print("No")
        exit()
print("Yes")
def main():
    n = int(input())
    a = list(map(int, input().split()))
    d = [0] * n
    ans = 0
    for i in range(n):
        ai = a[i]
        l, r = i + ai, i - ai
        if 0 <= l < n:
            d[l] += 1
        if 0 <= r < n:
            ans += d[r]
        print(d)
    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    n = int(input())
    a = list(map(int, input().split()))
    d = [0] * n
    ans = 0
    for i in range(n):
        ai = a[i]
        l, r = i + ai, i - ai
        if 0 <= l < n:
            d[l] += 1
        if 0 <= r < n:
            ans += d[r]
    print(ans)


if __name__ == "__main__":
    main()
import sys


def gcd(aa, bb):
    return gcd(bb, aa % bb) if aa % bb else bb


def lcm(aa, bb):
    return aa * bb / gcd(aa, bb)

for line in sys.stdin:
    data = line.split()
    a, b, c, d, e, f = data
    ix = lcm(a, d) / a
    jx = lcm(a, d) / d
    iy = lcm(b, e) / b
    jy = lcm(b, e) / e
    x = (c*1.0*iy - f*jy) / (a*iy - d*jy)
    y = (c*1.0*ix - f*jx) / (b*ix - e*jx)
    print "%.3f %.3f" % (round(x, 4), round(y, 4))

### FIXED CODE ###

import sys


def gcd(a, b):
    return gcd(b, a % b) if a % b else b


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

for line in sys.stdin:
    data = map(int, line.split())
    a, b, c, d, e, f = data
    if a == 0:
        y = c * 1.0 / b
        x = (f - e * y) * 1.0 / d
        print "%.3f %.3f" % (round(x, 4), round(y, 4))
        continue
    if b == 0:
        x = c * 1.0 / a
        y = (f - d * x) * 1.0 / e
        print "%.3f %.3f" % (round(x, 4), round(y, 4))
        continue
    if d == 0:
        y = f * 1.0 / e
        x = (c - b * y) * 1.0 / a
        print "%.3f %.3f" % (round(x, 4), round(y, 4))
        continue
    if e == 0:
        x = f * 1.0 / d
        y = (c - a * x) * 1.0 / b
        print "%.3f %.3f" % (round(x, 4), round(y, 4))
        continue

    ix = lcm(a, d) / a
    jx = lcm(a, d) / d
    iy = lcm(b, e) / b
    jy = lcm(b, e) / e
    x = (c*1.0*iy - f*jy) / (a*iy - d*jy)
    y = (c*1.0*ix - f*jx) / (b*ix - e*jx)
    print "%.3f %.3f" % (round(x, 4), round(y, 4))
`a=[0]*5
for i in range(5):
    a[i]=int(input().strip())
k=int(input().strip())
d=max(a)-min(a)
if d<=k:
    print("Yay!")
else:
    print(":(")

### FIXED CODE ###

a=[0]*5
for i in range(5):
    a[i]=int(input().strip())
k=int(input().strip())
d=max(a)-min(a)
if d<=k:
    print("Yay!")
else:
    print(":(")
n = int(input())
d = list(map(int,input().split()))
p = 0
q = 0
m = 0
d.sort()
if (len(d))%2 == 0:
  m = (d[(len(d)//2)-1]+d[len(d)//2])/2
else:
  m = d[(len(d)//2)]
for i in range(len(d)):
  if d[i]>=m:
    if d[i] == d[i+1]:
      break
    else:
      p = d[i]
      q = d[i-1]
      break
print(p-q)

### FIXED CODE ###

n = int(input())
d = sorted(list(map(int,input().split())))
print(d[n//2]-d[n//2-1])
a = input()
b = input()
X = int(a)*int(b)
print(X)


### FIXED CODE ###

a,b = (int(x) for x in input().split())
print(a*b)
import math
r = int(input())
if r == 0:
    print(0,0)
else:
    print("%f %f" % (math.pi * r**2, math.pi * r * 2))

### FIXED CODE ###

import math
r = float(input())
print("%f %f" % (math.pi * r**2, math.pi * r * 2))
s = map(input())
count = 0
if s[0] == '1':
  count += 1
if s[1] == '1':
  count +=1
if s[2] == '1':
  count += 1
print(count)

### FIXED CODE ###

s = list(map(int, input()))
count = 0
for i in range(len(s)):
  if s[i] == 1:
    count +=1
print(count)
from collections import deque

H,W=map(int,input().split())
A=[]
B=deque([])
C=[[-1]*W for i in range(H)]
for h in range(H):
    temp=list(input())
    A.append(temp)
    for w in range(W):
        if A[h][w]=="#":
            B.append([h,w,0])
            C[h][w]=0


step=[[1,0],[-1,0],[0,1],[0,-1]]
ans=[]
while B:
    P=B.popleft()
    for x,y in step:
        if 0<=P[0]+y<=H-1 and 0<=P[1]+x<=W-1:
            if C[P[0]+y][P[1]+x]==-1:
                B.append([P[0]+y,P[1]+x,P[2]+1])
                C[P[0]+y][P[1]+x]=1
                ans.append(P[2]+1)

print(max(ans))




### FIXED CODE ###

from collections import deque

H,W=map(int,input().split())
if H==1 and W==1:
    print(0)
    exit()

A=[]
B=deque([])
C=[[-1]*W for i in range(H)]
ans=[]
for h in range(H):
    temp=list(input())
    A.append(temp)
    for w in range(W):
        if A[h][w]=="#":
            B.append([h,w,0])
            C[h][w]=0
            ans.append(0)



step=[[1,0],[-1,0],[0,1],[0,-1]]

while B:
    P=B.popleft()
    for x,y in step:
        if 0<=P[0]+y<=H-1 and 0<=P[1]+x<=W-1:
            if C[P[0]+y][P[1]+x]==-1:
                B.append([P[0]+y,P[1]+x,P[2]+1])
                C[P[0]+y][P[1]+x]=1
                ans.append(P[2]+1)


print(max(ans))