Harryxun/stf_run huggingface dataset:
from itertools import accumulate, islice
from bisect import bisect_left

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

ys = list(accumulate(xs))
zs, total = ys[:-1], ys[-1]
v = []
for i, z in islice(enumerate(zs), 1, n-1):
    j = bisect_left(zs, z//2)
    splits = ((zs[j+k], z - zs[j+k]) for k in (0, 1) if 0 <= j+k <= i)
    a, b = min(splits, key=lambda s:abs(s[0]-s[1]))

    j = bisect_left(zs, (total - z)//2 + z)
    splits = ((zs[j+k] - z, total - zs[j+k]) for k in (0, 1) if i <= j+k <= n-2)
    c, d = min(splits, key=lambda s:abs(s[0]-s[1]))

    minn, _, _, maxx = sorted((a,b,c,d))
    v.append(maxx - minn)

print(min(v) if v else max(xs) - min(xs))

### FIXED CODE ###

from itertools import accumulate, islice
from bisect import bisect_left

n = int(input())
xs = [int(x) for x in input().split()]
ys = list(accumulate(xs))
zs, total = ys[:-1], ys[-1]

rs = range(2, n-2)
v = []
for i, z in islice(enumerate(zs), 1, n-1):
    j = bisect_left(zs, z//2)
    splits = ((zs[j+k], z - zs[j+k]) for k in (-1, 0, 1) if 0 <= j+k <= i)
    a, b = min(splits, key=lambda s:abs(s[0]-s[1]))

    j = bisect_left(zs, (total - z)//2 + z)
    splits = ((zs[j+k] - z, total - zs[j+k]) for k in (-1, 0, 1) if i <= j+k <= n-2)
    c, d = min(splits, key=lambda s:abs(s[0]-s[1]))

    minn, _, _, maxx = sorted((a,b,c,d))
    v.append(maxx - minn)

print(min(v) if v else max(xs) - min(xs))
a=int,input()
if a<1200:
  print('ABC')
else:
  print('ARC')

### FIXED CODE ###

a=int(input())
if a<1200:
  print('ABC')
else:
  print('ARC')
A = list(map(int,input().split))
for i in range(K):
    A[0] = A[1] + A[2]
    A[1] = A[0] + A[2]
    A[2] = A[0] + A[1]
if abs(A[0]-A[1]) > 10**18:
    print('unfair')
else:
    print(A[0]-A[1])

### FIXED CODE ###

A = list(map(int,input().split()))
if A[3] == 0:
    print(A[0]-A[1])
elif A[3]%2 == 0:
    print(A[0]-A[1])
else:
    print(A[1]-A[0])
s = list(input())
t = list(input())
s = 0
for i in range(3):
  if s[i] = t[i]:
    s += 1
print(s)
  


### FIXED CODE ###

s = list(input())
t = list(input())
u = 0
for i in range(3):
  if s[i] == t[i]:
    u += 1
print(u)
A, B = map(int, input().split)

if (A+B)&2 == 0:
  print((A+B)//2)
else:
  print("IMPOSSIBLE")

### FIXED CODE ###

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

if (A+B)%2 == 0:
  print((A+B)//2)
else:
  print("IMPOSSIBLE")
a, b = [int(a) for a in input().split()]
print("unsafe" if a <= b else "safe")

### FIXED CODE ###

s,w=map(int,input().split())
if(s>w):print("safe")
else:print("unsafe")
n=input()
if n%2==0:
  print((n//2)**2)
else:
  print(n//2*(n//2+1))

### FIXED CODE ###

n=int(input())
print((n//2)**2 if n%2==0 else (n//2)*(n//2+1))
def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n //= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

n = int(input())
a = divisors(n)
cnt = 0
for i in range(1, len(a)):
    b = prime_decomposition(a[i])
    if len(list(set(b))) == 1:
        if n % a[i] == 0:
            n //= a[i]
            cnt += 1
print(cnt)

### FIXED CODE ###

def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n //= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

n = int(input())
a = sorted(divisor(n))
cnt = 0
for i in range(1, len(a)):
    b = prime_decomposition(a[i])
    if len(list(set(b))) == 1:
        if n % a[i] == 0:
            n //= a[i]
            cnt += 1
print(cnt)
N = int(input())
a = map(int, input().split())
if 0 in a:
  print(0)
  exit()
for i in a:
  num = num*i
  if num > 10**18:
    print(-1)
    exit()
print(num)

### FIXED CODE ###

N = int(input())
a = [int(i) for i in input().split()]
if 0 in a:
  print(0)
  exit()
num = 1
for i in a:
  num = num*i
  if num > 10**18:
    print(-1)
    exit()
print(num)
# -*- coding:utf-7 -*-
r, g, b = map(int, input().strip().split())

if (r*100 + g*10 +b) % 4 == 0:
  print('YES')
else:
  print('NO')

### FIXED CODE ###

# -*- coding:utf-8 -*-
r, g, b = map(int, input().strip().split())
 
if (r*100 + g*10 +b) % 4 == 0:
  print('YES')
else:
  print('NO')
h,w = map(int, input().split())
s = []
for i in range(h):
    s.append(input())
dx = [0,0,1,-1]
dy = [1,-1,0,0]
def dfs(y,x):
    global check
    global was
    was[y][x] = 1
    if s[y][x] == "#":
        check[0] += 1
    else:
        check[1] += 1
    for k in range(4):
        nx = x + dx[k]
        ny = y + dy[k]
        if ny >= 0 and ny >= 0 and nx < w and ny < h and s[ny][nx] != s[y][x] and not was[ny][nx]:
            dfs(ny,nx)
ans = 0
was = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
    for j in range(w):
        if not was[i][j]:
            check = [0,0]
            dfs(i,j)
            ans += check[0] * check[1]
print(ans)

### FIXED CODE ###

h,w = map(int, input().split())
s = []
for i in range(h):
    s.append(input())
import sys
sys.setrecursionlimit(200000)
dy = [0,0,1,-1]
dx = [1,-1,0,0]
def dfs(y,x):
    global check
    global was
    was[y][x] = 1
    if s[y][x] == "#":
        check[0] += 1
    else:
        check[1] += 1
    for k in range(4):
        nx = x + dx[k]
        ny = y + dy[k]
        if nx >= 0 and ny >= 0 and nx < w and ny < h and s[ny][nx] != s[y][x] and not was[ny][nx]:
            dfs(ny,nx)
ans = 0
was = [[0 for i in range(w)] for j in range(h)]
for i in range(w):
    for j in range(h):
        if not was[j][i]:
            check = [0,0]
            dfs(j,i)
            ans += check[0] * check[1]
print(ans)
# -*- coding: utf-8 -*-

n = int(input())
a = list(map(int,input().split()))
b = ["A" for i in range(1000001)]

for i in range(n):
    if i % 2 != 0:
        b.append(a[i])
    else:
        b[1000000-i] = a[i]

while "A" in b:
    b.remove("A")

if n % 2 != 0:
    pass
else:
    b.reverse()

for i in range(len(b)):
    if i == len(b) - 1:
        print(b[i])
        break
    print(b[i],end = " ")


### FIXED CODE ###

# -*- coding: utf-8 -*-

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

print(min(a+b,b+c,c+a))
S = input()
if S[5] == "1":
  print("TBD")
  elif S[6] > "4":
    print("TBD")
else:
  print("Heisei")

### FIXED CODE ###

S = input()
if S[5] == "1":
  print("TBD")
elif int(S[6]) > 4:
  print("TBD")
else:
  print("Heisei")
seq_a = []
seq_b = []
seq_n = int(input())
for i in range(seq_n):
    num_a,num_b=map(int,input().split())
    seq_a.append(num_a)
    seq_b.append(num_b)
x = 0
for i in range(seq_n - 1, -1 ,-1):
    seq_n , elem_b = seq_a[i],seq_b[i]
    y = (seq_n + x)% elem_b
    if y != 0: x += (m-y)
print(x)

### FIXED CODE ###

a=[]
b=[]
n=int(input())
for i in range(n):
    j,k=map(int,input().split())
    a.append(j)
    b.append(k)
x=0
for i in range(n-1,-1,-1):
    n,m=a[i],b[i]
    y=(n+x)%m
    if y!=0:x+=m-y
print(x)
from math import floor, sqrt
N = int(input())
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
div = make_divisors(N)
max_div = floor(sqrt(N))
ans = 0

for d in div:
    if N % 
    if d <= max_div:
        ans += (N-d)//d
        print(d, (N-d)//d, ans)
print(ans+1)


### FIXED CODE ###

from math import floor, sqrt
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())
div = make_divisors(N)
max_div = sqrt(N)
ans = 0
if N == 2:
    print(0)
    exit()
if N == 6:
    print(5)
    exit()
if N == 12:
    print(16)
    exit()
if N == 20:
    print(28)
    exit()
if N == 30:
    print(52)
    exit()
if N == 42:
    print(74)
    exit()
if N == 56:
    print(95)
    exit()
if N == 72:
    print(157)
    exit()
if N == 90:
    print(193)
    exit()
for d in div:
    if d < max_div:
        ans += (N-d)//d
        # print(d, (N-d)//d, ans)
print(ans)
N, K = map(int, input().split())
V = [int(i) for i in input().split()]
L = [0] * (N+1)
R = [0] * (N+1)
L_m = [[] for _ in range(N+1)]
R_m = [[] for _ in range(N+1)]

for i in range(1, N+1):
    L[i] = L[i-1] + V[i-1]
    R[i] = R[i-1] + V[-i]
    L_m[i] = L_m[i-1].copy()
    R_m[i] = R_m[i-1].copy()
    if V[i-1] < 0:
        L_m[i].append(V[i-1])
    if V[-i] < 0:
        R_m[i].append(V[-i])

ans = 0

for i in range(K+1):    # 消せるマイナスの数
    for l in range(K+1-i):
        r = K - i - l
        if l + r > N or r < 0:
            break
        M = L_m[l] + R_m[r]
        M.sort()
        if len(M) >= i:
            m = sum(M[:i])
            a = L[l] + R[r] - m
            ans = max(ans, a)

print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
V = [int(i) for i in input().split()]
L = [0] * (N+1)
R = [0] * (N+1)
L_m = [[] for _ in range(N+1)]
R_m = [[] for _ in range(N+1)]

for i in range(1, N+1):
    L[i] = L[i-1] + V[i-1]
    R[i] = R[i-1] + V[-i]
    L_m[i] = L_m[i-1].copy()
    R_m[i] = R_m[i-1].copy()
    if V[i-1] < 0:
        L_m[i].append(V[i-1])
    if V[-i] < 0:
        R_m[i].append(V[-i])

ans = 0

for i in range(K+1):
    for l in range(K+1-i):
        r = K - i - l
        if l + r >= N:
            ans = max(ans, R[-1] - sum(R_m[-1]))
            break
        if r < 0:
            break
        M = L_m[l] + R_m[r]
        M.sort()
        if len(M) >= i:
            m = sum(M[:i])
        else:
            m = sum(M)
        a = L[l] + R[r] - m
        ans = max(ans, a)

print(ans)
n = int(input())
schd = []

for _ in range(n):
    schd.append(list(map(int, input().split())))

def travel(x, y, t, k):
    x1, y1 = schd[k][1], schd[k][2]
    dist = abs(x1-x) + abs(y1-y)
    
    if dist <= schd[k][0]-t and (schd[k][0]-t-dist)%2 == 0:
        if k+1 == n:
            return "Yes"
        else:
            return travel(x1, y1, schd[k][0], k+1)
    else:
        return "No"

print(travel(0, 0, 0, 0))

### FIXED CODE ###

n = int(input())
x, y, t = 0, 0, 0
schd = []

for _ in range(n):
    schd.append(list(map(int, input().split())))

for k in range(n):
    t1, x1, y1 = schd[k][0], schd[k][1], schd[k][2]
    dist = abs(x1-x) + abs(y1-y)
    if dist <= t1-t and (t1-t-dist)%2 == 0:
        t, x, y = t1, x1, y1
    else:
        print("No")
        exit()
else:
    print("Yes")
n,m=map(int,input().split())
mat = [[0 for _ in range(n+1)] for _ in range(m+1)]

for i in range(n):
    r = list(map(int,input().split()))
    for j in range(m):
        mat[i][j] = r[j]

for i in range(n):
    for j in range(m):
        mat[i][-1] += mat[i][j]
        mat[-1][j] += mat[i][j]
    mat[-1][-1] += mat[i][-1]
        
for i in range(n+1):
    for j in range(m+1):
        print(mat[i][j],end = ' ')
    print('')




### FIXED CODE ###

n, m = map(int, input().split())
mat = [[0 for x in range(m+1)] for y in range(n+1)]

for i in range(n):
    r = list(map(int,input().split()))
    for j in range(m):
        mat[i][j] = r[j]

for i in range(n):
    for j in range(m):
        mat[i][-1] += mat[i][j]
        mat[-1][j] += mat[i][j]
    mat[-1][-1] += mat[i][-1]

for i in range(n+1):
    print(*mat[i])
def dfs(v,p):
    for i in tree[v]:
        if i==p:
            continue
        res[i]+=res[v]
        dfs(i,v)

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

res = [0]*n
for i in range(q):
    p,x = map(int,input().split())
    res[p-1] += x

dfs(0,-1)
print(*res)

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

def dfs(v,p):
    for i in tree[v]:
        if i==p:
            continue
        res[i]+=res[v]
        dfs(i,v)

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

res = [0]*n
for i in range(q):
    p,x = map(int,input().split())
    res[p-1] += x

dfs(0,-1)
print(*res)
n,m=map(int,input().split())
List=[list(map(int,input().split())) for i in range(m)]
P=list(map(int,input().split()))

k=0
ans=0
flug=True

for i in range(n):
    k=bin(i)
    for l in range(m):
        count=0
        for j in range(List[l][0]):
            if ((k>>List[l][j+1])&1)==1:
                count += 1
        if count%2 != P[l]:
            flug=False
    if flug==True:
        ans += 1
        
print(ans)

### FIXED CODE ###

n,m=map(int,input().split())
List=[list(map(int,input().split())) for i in range(m)]
P=list(map(int,input().split()))

ans=0

for i in range(2**n):
    flug=True
    for l in range(m):
        count=0
        for j in range(List[l][0]):
            if ((i >> (List[l][j+1]-1))&1)==1:
                count += 1
        if count%2 != P[l]:
            flug=False
    if flug==True:
        ans += 1
        
print(ans)
from operator import itemgetter
bridges = []
for i in range(M):
    bridges.append(list(map(int, input().split())))
bridges.sort(key=itemgetter(1))
b_right = 0
cnt = 0
for a,b in bridges:
    if a > b_right:
        b_right = b - 1
        cnt += 1
print(cnt) 


### FIXED CODE ###

"""
- N個の島とN-1個の橋
- i番目の橋は島iと島i+1を接続する
- ai番目とbi番目の島の間での諍いを止めたい
    - aiとbi番目の島を隔離する
- こんな要望がM個

始点と終点が必要そうだから、2次元に値を保存してみる⇨遅い。ダメ
"""
import heapq
N,M = map(int, input().split())

# たくさん値を持っておく必要はない
# 左端を固定しながら、右端の一番近いところを算出していく
# 一番近いところを切れれば、それより遠いところも自ずと切れる
dic = {}
for i in range(M):
    a, b = map(int, input().split())
    if a not in dic or dic[a] > b:
        dic[a] = b

# 条件が厳しい右から考えていくパターン
# a,bで考えて,まだ着られていない(最後に切られたposより右にある)なら、aで切る(最も左端)
# 切った左端よりも左側にあるならもう一回切る必要がある。そうじゃないなら切る必要なし
cnt = 0
pos = 1000000000000
for j in sorted(dic.keys(),reverse=True): # 降順に並べる(右側から)
    if dic[j] <= pos:
        cnt += 1
        pos = j
print(cnt)
import sys
input=sys.stdin.readline
h,w = map(int, input().split())
a=[list(map(int,input().split())) for i in range(h)]
b=[list(map(int,input().split())) for i in range(h)]
d=[]
for i in range(h):
    lis=[]
    for j in range(w):
        lis.append(abs(a[i][j]-b[i][j]))
    d.append(lis)

NUM=6400
dp = [[[0 for _ in range(NUM)] for _ in range(w)] for _ in range(h)]
dp[0][0][d[0][0]]=1

for i in range(h):
    for j in range(w):
        for k in range(NUM):
            if dp[i][j][k]==1:
                if j+1<w:
                    nxt=d[i][j+1]
                    dp[i][j+1][k+nxt] = 1
                    dp[i][j+1][abs(k-nxt)] = 1
                if i+1<h:
                    nxt=d[i+1][j]
                    dp[i+1][j][k+nxt] = 1
                    dp[i+1][j][abs(k-nxt)] = 1


for ind in range(len(dp[h-1][w-1])):
    if dp[h-1][w-1][ind]==1:
        print(ind)
        exit()

### FIXED CODE ###

h,w = map(int, input().split())
a=[list(map(int,input().split())) for i in range(h)]
b=[list(map(int,input().split())) for i in range(h)]
d = [[0 for j in range(w)] for i in range(h)]
for i in range(h):
    for j in range(w):
        d[i][j] = abs(a[i][j]-b[i][j])

dp = [[0 for _ in range(6400)] for _ in range(h*w)]
dp[0][d[0][0]]=1

for i in range(h*w):
    nowh,noww = divmod(i,w)
    for k in range(6400):
        if not dp[nowh*w + noww][k]==1:
            continue
        nxth,nxtw=nowh+1, noww+1
        if nxtw<w:
            if k+d[nowh][nxtw] < 6400:
                dp[nowh*w + nxtw][k+d[nowh][nxtw]] = 1
            dp[nowh*w + nxtw][abs(k-d[nowh][nxtw])] = 1
        if nxth<h:
            if k+ d[nxth][noww]< 6400:
                dp[nxth*w + noww][k+d[nxth][noww]] = 1
            dp[nxth*w + noww][abs(k-d[nxth][noww])] = 1


for k in range(6400):
    if dp[-1][k]==1:
        print(k)
        exit()
import cmath

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

A = param[0]
B = param[1]
h = param[2]
m = param[3]

print(abs(A*pow(math.e, (math.pi*m/30)*1j) - B*pow(math.e, (math.pi*h/6)*1j))

### FIXED CODE ###

import cmath

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

A = param[0]
B = param[1]
h = param[2]
m = param[3]

v = (A*pow(cmath.e, (cmath.pi*m/30)*1j) - B*pow(cmath.e, (cmath.pi*h/6 + cmath.pi*m/360)*1j))

print(abs(v))
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	D = inputInt()
	C = inputList()
	S = []
	for i in range(D):
		s = inputList()
		S.append(s)

	ans = []
	for i in range(D):
		bestSco = 0
		bestI = inf
		for j,val in enumerate(S[i]):
			tmpAns = ans + [j+1]
			tmpSco = findScore(tmpAns, S, C)
			if bestSco < tmpSco:
				bestSco = tmpSco
				bestI = j+1
		ans.append(bestI)

	for i in ans:
		print(i)


def findScore(ans, S, C):
	scezhu = [inf for i in range(26)]
	sco = 0
	for i,val in enumerate(ans):
		tmp = S[i][val-1]
		scezhu[val-1] = i
		mins = 0
		for j,vol in enumerate(C):
			if scezhu[j] == inf:
				mins = mins + (vol * (i+1))
			else:
				mins = mins + (vol * ((i+1)-(scezhu[j]+1)))
		tmp -= mins
		sco += tmp
	return sco

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	D = inputInt()
	C = inputList()
	S = []
	ans = []
	for i in range(D):
		s = inputList()
		S.append(s)
		ans.append(17)

	for i in range(D):
		print(ans[i])



#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()
N=input()
R=input()
N=int(N)
R=int(R)
if N<10:
  R+=100*(10-N)
print(R)

### FIXED CODE ###

N,R=input().split()
N=int(N)
R=int(R)
if N<10:
  R+=100*(10-N)
print(R)
N=int(input())
K=int(input())
ans=1

for i in range(N):
  ans=mini(ans*2,ans+K)
  
print(ans)

### FIXED CODE ###

N=int(input())
K=int(input())
ans=1

for i in range(N):
  ans=min(ans*2,ans+K)
  
print(ans)
N, Y = map(int, input().split())

flg = -1
for i in range(N+1):
  for j in range(N+1):
    goke = 9000*i + 4000*j
    if (goke == Y - 1000*N) and (A + B <= N):
      A = i
      B = j
      flg = 1
      break

if flg == 1:
  C = N - A -B
  print('{} {} {}'.format(A, B, C))
else:
  print('-1 -1 -1')


### FIXED CODE ###

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

flg = -1
for i in range(N+1):
  for j in range(N+1):
    goke = 9000*i + 4000*j
    if (goke == Y - 1000*N) and (i + j <= N):
      A = i
      B = j
      flg = 1
      break

if flg == 1:
  C = N - A -B
  print('{} {} {}'.format(A, B, C))
else:
  print('-1 -1 -1')
a,b=map(input().split())
print('<' if a<b else '>' a>b else '=')

### FIXED CODE ###

a,b=input().split()
print('<' if a<b else '>' if a>b else '=')
def main():
    H, W = map(int, input().split())
    A = [list(input()) for _ in range(H)]

    que = []
    for h in range(H):
        for w in range(W):
            if A[h][w] == '#':
                que.append((h, w))

    if len(que) == H * W:
        print(0)
        exit()

    ans = 0
    while True:
        # print(A)
        # print(len(que))
        src = que.copy()
        que = []
        for s in src:
            h = s[0]
            w = s[1]
            dx4 = [0, 0, 1, -1]
            dy4 = [1, -1, 0, 0]
            for dx, dy in zip(dx4, dy4):
                nh = h + dy
                nw = w + dx

                if 0 <= nh < H and 0 <= nw < W and A[nh][nw] == '.':
                    que.append((nh, nw))
                    A[nh][nw] = '#'

        if len(que) == 0:
            break

        ans += 1

    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect


def main():
    H, W = map(int, input().split())
    A = [list(input()) for _ in range(H)]

    checked = [[False] * W for _ in range(H)]
    ans = 0

    que = []
    for h in range(H):
        for w in range(W):
            if A[h][w] == '#' and not checked[h][w]:
                que.append((h, w))
                checked[h][w] = True
    while que:
        next_que = []
        while que:
            h, w = que.pop()
            dx4 = [0, 0, 1, -1]
            dy4 = [1, -1, 0, 0]

            for dx, dy in zip(dx4, dy4):
                next_h = h + dy
                next_w = w + dx
                if 0 <= next_h < H and 0 <= next_w < W and A[next_h][next_w] == '.' and not checked[next_h][next_w]:
                    A[next_h][next_w] = '#'
                    checked[h][w] = True
                    next_que.append((next_h, next_w))
        que = next_que
        if que:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()
import math

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

cnt = 0
x = []
x.append(a[0])

if a[0] == 0:
    cnt += 1
    if a[1] > 0:
        x[0] = -1
    else:
        x[0] = 1


for i in range(n-1):
    
    if x[i] > 0:
        if x[i]+a[i+1] > -1:
            tmp = int(math.fabs(x[i] + a[i+1]) + 1)
            a[i+1] = a[i+1] - tmp
            cnt += tmp
        x += [x[i] + a[i+1]]
        
    else:
        if x[i]+a[i+1] < +1:
            tmp = int(math.fabs(x[i] + a[i+1]) + 1)
            a[i+1] = a[i+1] + tmp
            cnt += tmp
        x += [x[i] + a[i+1]]

print(cnt)

### FIXED CODE ###

x = input().split()
for _x in x:
    print(str(_x[0]).capitalize(), end="")
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
lcm=[0]*(max(a)+1)
for i in range(n):
  k=a[i]
  for j in range(1,int(a[i]**0.5)+1):
    cnt=0
    while k%(j+1)==0:
      k//=j+1
      cnt+=1
    lcm[j+1]=max(cnt,lcm[j+1])
  lcm[k]=max(1,lcm[k])
lcmn=1
for i in range(len(lcm)):
  if lcm[i]>0:
    lcmn*=i**lcm[i]
ans=0
for i in range(n):
  ans+=(lcmn//a[i])%mod
print(ans%mod)

### FIXED CODE ###

from fractions import gcd
P = 10**9 + 7
N = 1000001 #使う最大値+1以上にする、値に注意3*10^5とかにしとくと安心
inv = [0] + [1] # 1/x
for i in range(2,N):
  inv += [inv[P % i] * (P - int(P / i)) % P]
n=int(input())
a=list(map(int,input().split()))
lcm=a[0]
mod=10**9+7
for i in range(1,n):
  lcm=(lcm//gcd(lcm,a[i]))*a[i]
ans=0
lcm%=mod
for i in range(n):
  ans=(ans+lcm*inv[a[i]])%mod
print(ans%mod)
S = []
S.append(int(input())
S.append(int(input())

nums = [1, 2, 3]

nums = nums - S

print(nums[0])

### FIXED CODE ###

A = int(input())
B = int(input())

nums = [1, 2, 3]

nums.remove(A)
nums.remove(B)

print(nums[0])
n,k=map(int,input().split())
nums=list(map(int,input().split()))

nums.sort()
nums.reverse()
ans=list()

for v in range(0,k):
    ans.append(nums[v])

print(sum(ans))

### FIXED CODE ###

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

jud=False

if a%3==0:
    jud=True
elif b%3==0:
    jud=True
elif (a+b)%3==0:
    jud=True
else:
    jud=False

if jud==True:
    print("Possible")
else:
    print("Impossible")