Harryxun/stf_run huggingface dataset:
import sys
from math import atan2, cos, pi

import numpy as np


def check(engines, theta):
    x, y = 0, 0
    cur = 0
    best = 0
    for dx, dy in engines:
        nx = x + dx
        ny = y + dy
        r = (nx ** 2 + ny ** 2) ** 0.5
        new = r * cos(atan2(ny, nx) - theta)

        if cur < new:
            x, y = nx, ny
            cur = new
            best = r
    return best


n = int(input())
engines = []
for line in sys.stdin:
    x, y = map(int, line.split())
    engines.append((x, y))

ans = 0
for dx, dy in engines:
    ans = max(ans, check(engines, atan2(dy, dx)))
print(ans)


### FIXED CODE ###

import sys
from collections import defaultdict


def dfs(root, links):
    status = {}
    topological = []
    q = [(r, 0, 1) for r in root]
    while q:
        node = q.pop()
        if node[1] == 0:
            v, _, d = node
            q.append((v, 1))
            status[v] = 1
            d += 1
            for u in links[v]:
                if u in status:
                    if status[u] == 1:
                        return False
                else:
                    q.append((u, 0, d))
        else:
            v = node[0]
            status[v] = 2
            topological.append(v)
    topological.reverse()
    return topological


n = int(input())
links = defaultdict(set)
may_root = set()
lines = sys.stdin.readlines()
matches = []
for i in range(n):
    line = lines[i]
    aaa = list(map(int, line.split()))
    match_order = []
    for j in aaa:
        j -= 1
        a, b = (i, j) if i < j else (j, i)
        key = a * n + b
        match_order.append(key)
    matches.append(match_order)
    may_root.add(match_order[0])

for i in range(n):
    kkk = matches[i]
    prev = kkk[0]

    for key in kkk[1:]:
        links[prev].add(key)
        may_root.discard(key)
        prev = key

if not may_root:
    print(-1)
    exit()

topological = dfs(may_root, links)
if topological == False:
    print(-1)
    exit()

ans = 0
depth = defaultdict(lambda: 1)
for v in topological:
    d = depth[v] + 1
    for u in links[v]:
        depth[u] = max(depth[u], d)

print(max(depth.values()))
N=int(input())
lis=[]
for i in range(N):
  lis.append(int(input())
lis2=sorted(lis)
ma1=lis2[-1]
ma2=lis2[-2]

for i in range(N):
  if lis[i] == ma1:
    print(ma2)
  else:
    print(ma1)

### FIXED CODE ###

N=int(input())
lis=[]
for i in range(N):  
  lis.append(int(input()))
lis2=sorted(lis)
ma1=lis2[-1]
ma2=lis2[-2]

for i in range(N):
  if lis[i] == ma1:
    print(ma2)
  else:
    print(ma1)
import math
A,B,H,M = int(input().split())
Ad = H * 30 + M * 0.5
Bd = M * 6
difAB = abs(Ad - Bd)
if difAB >=180:
    difAB = 360-difAB
print(math.sqrt(A**2+B**2-2*A*B*math.cos(math.radians(difAB))))

### FIXED CODE ###

import math
A,B,H,M = map(int,input().split())
Ad = H * 30 + M * 0.5
Bd = M * 6
difAB = abs(Ad - Bd)
if difAB >=180:
    difAB = 360-difAB
print(math.sqrt(A**2+B**2-2*A*B*math.cos(math.radians(difAB))))
n,m,*a=map(int,open(0).read().split())
b=[-1]*(n+1)
if m!=0:
    for i in a:
        b[i]=0
    if a[0]==1:
        b[2]=1
    elif a[0]==2:
        b[1]=1
    else:    
        b[1],b[2]=1,2
else:    
        b[1],b[2]=1,2        
for i in range(3,n+1):
    if b[i]==-1:
        b[i]=(b[i-1]+b[i-2])%1000000007
print(b[-1])

### FIXED CODE ###

n,m,*a=map(int,open(0).read().split())
if n==1:
    print(1)
    exit()
b=[-1]*(n+1)
a+=[0,0]
for i in a:
    b[i]=0
if a[0]==1 and a[1]==2:
    b[1],b[2]=0,0
elif a[0]==1:
    b[2]=1
elif a[0]==2:
    b[1]=1
else:    
    b[1],b[2]=1,2
for i in range(3,n+1):
    if b[i]==-1:
        b[i]=(b[i-1]+b[i-2])%1000000007
print(b[-1])
N, M = list(map(int, input().split()))

A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]

A.sort()
BC.sort(key = lambda x: x[1], reverse = True)
cnt = 0
for b, c in BC:
  for i in range(b):
    if A[cnt] < c:
      A[cnt] = c
      cnt += 1
    else:
      break

print(sum(A))

### FIXED CODE ###

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

A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]

A.sort()
BC.sort(key = lambda x: x[1], reverse = True)
cnt = 0
for b, c in BC:
  for i in range(b):
    if A[cnt] < c:
      A[cnt] = c
      cnt += 1
      if cnt >= N:
        break
    else:
      break
  if cnt >= N:
    break

print(sum(A))
import bisect

N, K = [int(item) for item in input().split()]
x = [int(item) for item in input().split()]

sep = bisect.bisect(x, 0)

R = x[:sep][::-1]
L = x[sep:]

for i in range(len(R)):
  R[i] = -R[i]

ans = 10**6
for i, r in enumerate(R):
  ans = min(ans, r*2+ L[K-(i+1)-1])
for i, l in enumerate(L):
  ans = min(ans, l*2+ R[K-(i+1)-1])
  
print(ans)

### FIXED CODE ###

import bisect
n, k = [int(item) for item in input().split()]
x = [int(item) for item in input().split()]

lft_num = bisect.bisect(x, 0)
rgt_num = n - lft_num

ans = 10**10
for i in range(min(rgt_num, k)):
    r = x[lft_num + i]
    distance = abs(r)
    if i+1 == k: 
        ans = min(ans, distance)
        continue
    if lft_num - (k-i-1) >= 0:
        l = x[lft_num - (k-i-1)]
        distance += abs(r - l)
        ans = min(ans, distance)
for i in range(min(lft_num, k)):
    l = x[lft_num - i - 1]
    distance = abs(l)
    if i+1 == k: 
        ans = min(ans, distance)
        continue
    if lft_num + (k-i-2) < n:
        r = x[lft_num + (k-i-2)]
        distance += abs(r - l)
        ans = min(ans, distance)
    
print(ans)
a, b, x= raw_input().split()
if a%3 == 0:
    print b//x - a//x +1
else:
   print  b//x - a//x +1

### FIXED CODE ###

a, b, x= map(int, raw_input().split())
if a%x == 0:
    print b//x - a//x +1
else:
    print  b//x - a//x
from sys import stdin
#from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd
def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().split())
def li(): return [x for x in mi()]
def si(): return stdin.readline()
n=ii()
print(n*n)

### FIXED CODE ###

"""from sys import stdin
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd
def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().split())
def li(): return [x for x in mi()]
def si(): return stdin.readline()
"""
n=int(input())
print(n*n)
from collections import deque
    
n = int(input())
dll = deque()
    
for i in range(n):
    input_line = input().split()
    if input_line[0] == "insert":
        dll.appendleft(input_line[1])
    elif input_line[0] == "delete":
        try:
            dll.remove(input_line[1])
        except:
            pass
    elif input_line[0] == "deleteFirst":
        dll.popleft()
    else:
        dll.pop()
            
print(*dll

### FIXED CODE ###

from collections import deque
import sys
 
dq = deque()
num = int(sys.stdin.readline())
line = sys.stdin.readlines()
 
for i in range(num):
 
    order = line[i].split()
 
    if order[0] == 'insert':
        dq.appendleft(order[1])
    elif order[0] == 'deleteFirst':
        dq.popleft()
    elif order[0] == 'deleteLast':
        dq.pop()
    else:
        if order[1] in dq:
            dq.remove(order[1])
 
print(' '.join(dq))
s = list(input())
ans = 0

for c in s:
    ans += int(c)

if ans == 7:
    print(s[0]+"+"+s[1]+"+"+s[2]+"+"+s[3]+"=7")

else:
    x = str((ans-7)//2)
    a = s.index(x)
    
    for i in range(4):
        print(s[i], end="")
        if i == 3:
            print("=7")
        if i == a-1:
            print("-", end="")
            a = 100
        else:
            print("+", end="")

### FIXED CODE ###

import copy
import numpy as np

s = input()
n = 3
ans = 0

for i in range(1,3 ** n):
    x = copy.deepcopy(s)
    y = str(np.base_repr(i,3)).rjust(3,'0') #3進数に変換
    if (y[0] == "0" and s[0] == "0") or (y[1] == "0" and s[1] == "0") or (y[2] == "0" and s[2] == "0"):
        continue
    z = 1
    for j in range(3):
        if y[j] == "1": #フラグが立っていたら
            x = x[:j+z] + "+" + x[j+z:]
            z += 1
        if y[j] == "2": #フラグが立っていたら
            x = x[:j+z] + "-" + x[j+z:]
            z += 1
    if eval(x) == 7:
        print(x +"=7")
        exit()
n,k = map(int, input().split())
num = 1
for i in range(n):
    if num*2 < num+k:
        num == num*2
    else:
        num == num+k
print(num)


### FIXED CODE ###

n = int(input())
k = int(input())
num = 1
for i in range(n):
    num = min(num+k,num*2)
print(num)
a,b=map(int,input(),split())
print(a//b,a%b,a/b)

### FIXED CODE ###

a,b=map(int,input().split())
print(a//b,a%b,"{0:10.20f}".format(a/b))
a,p=map(int,input().split())
print((a*3+p)//2

### FIXED CODE ###

a,p=map(int,input().split())
print((a*3+p)//2)
class BIT:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

N = int(input())
WP, BP = [2001]*(N+2), [2001]*(N+2)
for i in range(2*N):
    c, a = input().split()
    if c == 'W':
        WP[int(a)] = i+1
    else:
        BP[int(a)] = i+1
Q = [1, 1]
end = [0]*2*N
for i in range(2*N):
    w, b = Q
    if WP[w] < BP[b]:
        end[i] = WP[w]
        w += 1
    else:
        end[i] = BP[b]
        b += 1
    Q = w, b

Tr = BIT(2*N)
ans = N*(2*N-1)
for i in range(2*N):
    ans -= Tr.sum(end[i])
    Tr.add(end[i], 1)
print(ans)

### FIXED CODE ###

import sys
from itertools import accumulate
readline = sys.stdin.readline

class BIT:
    #1-indexed
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
        self.p = 2**(n.bit_length() - 1)
        self.dep = n.bit_length()
    def get(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
    
    def bl(self, v):
        if v <= 0:
            return -1
        s = 0
        k = self.p
        for _ in range(self.dep):
            if s + k <= self.size and self.tree[s+k] < v:
                s += k
                v -= self.tree[s+k]
            k //= 2
        return s + 1

N = int(readline())
W = [0]*N
B = [0]*N
for i in range(1, 2*N+1):
    c, a = readline().split()
    if c == 'W':
        W[int(a)-1] = i
    else:
        B[int(a)-1] = i

cw = [0]*(N+1)
cb = [0]*(N+1)
T = BIT(2*N)
for i in range(N):
    cw[i+1] = i-T.get(W[i])
    T.add(W[i], 1)
T = BIT(2*N)
for i in range(N):
    cb[i+1] = i-T.get(B[i])
    T.add(B[i], 1)

invw = [None] + [[0] + list(accumulate([1 if W[i] < B[j] else 0 for j in range(N)])) for i in range(N)]
invb = [None] + [[0] + list(accumulate([1 if B[i] < W[j] else 0 for j in range(N)])) for i in range(N)]
    
inf = 10**9+7
dp = [[inf]*(N+1) for _ in range(N+1)]
dp[0][0] = 0
for s in range(2*N):
    for w in range(max(0, s-N), min(N+1, s+1)):
        b = s-w
        if w != N:
            dp[w+1][b] = min(dp[w+1][b], dp[w][b] + invw[w+1][b] + cw[w+1])
        if b != N:
            dp[w][b+1] = min(dp[w][b+1], dp[w][b] + invb[b+1][w] + cb[b+1])
print(dp[N][N])
def main():
  import math
  X=int(input())
  for i in range(0,20):
    a=X+i
    b=a**0.5
    for j in range(2,math.floor(b)):
      if a%b!=0:
        print(a)
        break
  break

main()
     

### FIXED CODE ###

X=int(input())
b=X**0.5
while any(X%i==0 for i in range(2,int(b)+1)):
  X+=1
else:
  print(X)
a,b,c,x = map(int,[input() for i in range(4)]):
ans = 0
  
  for i in range(a+1):
    for j in range(b+1):
      for f in range(c+1):
        if i*500 + j*100 + f*50 == x:
          ans +=1:
            
print(ans)

### FIXED CODE ###

a, b, c, x = map(int, [input() for i in range(4)])
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i * 500 + j * 100 + k * 50 == x:
                ans += 1
print(ans)
N = int(input())
A = map(int,input().split())
ans = 0
for i in range(0,N,2):
  if A[i]%2==1:
    ans+=1
    
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(0,N,2):
  if A[i]%2==1:
    ans+=1
    
print(ans)
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    S = input()
    K = int(input())
    if S[K-1] == '1':
        print('1')
    for i in list(S):
        if i != '1':
            print(i)
            exit()
    print('1')

if __name__ == '__main__':
    main()



### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    S = input()
    K = int(input())
    if len(S) > K and S[K-1] == '1':
        print('1')
        exit()
    for i in list(S):
        if i != '1':
            print(i)
            exit()
    print('1')

if __name__ == '__main__':
    main()
X=map(int,input().split())
for i in range(1,6):
    if X[i]==0:
        print(i)
        exit()

### FIXED CODE ###

X=list(map(int,input().split()))
for i in range(0,5):
    if X[i]==0:
        print(i+1)
        break
N, K = map(int, input().split())
A = list(map(int, input().split()))
m = 10**9+7
B = [abs(a) for a in A]
B.sort(reverse=True)
pos = [*filter(lambda x: x >= 0, A)]
neg = [*filter(lambda x: x < 0, A)]
pos.sort(reverse=True)
neg.sort()

ans = 1
i,j = 0,0
while i+j < K:
    flag = True
    if i == len(pos):
        flag = False
    elif j == len(neg):
        flag = True
    elif pos[i] >= -neg[j]:
        flag = True
    else:
        flag = False

    if flag:
        ans = ans * pos[i] % m
        i += 1
    else:
        ans = ans * neg[j] % m
        j += 1
if len(pos) == 0:
    ans = 1
    for i in range(K):
        ans = ans * neg[len(neg)-1-i] % m
    print(ans)
elif j % 2 == 0 or N==K or len(neg) == 0:
    print(ans)
else:
    # この操作ができないものを分類
    flag = True
    if i >= len(pos)-1:
        flag = False
    elif j >= len(neg)-1:
        flag = True
    elif pos[i]*pos[i+1] >= neg[j]*neg[j+1]:
        flag = True
    else:
        flag = False

    if flag:
        ans = ans * pow(neg[j],m-2,m) % m
        ans = ans * pos[i+1] % m
    else:
        ans = ans * pow(pos[i],m-2,m) % m
        ans = ans * neg[j+1] % m
    print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
m = 10**9+7
pos = [*filter(lambda x: x>=0, A)]
neg = [*filter(lambda x: x<0, A)]
pos.sort(reverse=True)
neg.sort()

ans = 1
i,j = 0,0# 使った数
while i+j < K:
    flag = True
    if i == len(pos):
        flag = False
    elif j == len(neg):
        flag = True
    elif pos[i] >= -neg[j]:
        flag = True
    else:
        flag = False

    if flag:
        ans = ans * pos[i] % m
        i += 1
    else:
        ans = ans * neg[j] % m
        j += 1

if j % 2 == 0 or N==K:
    print(ans)
elif len(pos) == 0:
    ans = 1
    for i in range(K):
        ans = ans * neg[len(neg)-1-i] % m
    print(ans)
else:
    flag2 = True
    if i == 0:
        flag2 = True
    elif j == 0:
        flag2 = False
    elif i == len(pos):
        flag2 = False
    elif j == len(neg):
        flag2 = True
    elif pos[i-1]*pos[i] > neg[j-1]*neg[j]:# = を抜いた
        flag2 = True
    else:
        flag2 = False

    if flag2:
        ans = ans * pow(neg[j-1],m-2,m) % m
        ans = ans * pos[i] % m
    else:
        ans = ans * pow(pos[i-1],m-2,m) % m
        ans = ans * neg[j] % m
    print(ans)
N,H,W = map(int,input().split())
L = []
for i in range(N) :
    a,b = map(int,input().split())
    if (a >= H) and (b >= W) :
        ans += 1
print(ans)


### FIXED CODE ###

N,H,W = map(int,input().split())
L = []
ans = 0
for i in range(N) :
    a,b = map(int,input().split())
    if (a >= H) and (b >= W) :
        ans += 1
print(ans)
judge = False
N, Y = map(int, input().split())
x = 0
while x <= N and (not judge):
    y = 0
    x += 1
    #print('x:' + str(x))
    rest = Y - x * 10000
    if rest <= 0:
        if rest == 0 and x == N:
            judge = True
        break
    while x + y <= N and Y - x * 10000 - y * 5000 >= 0:
        z = (Y - x * 10000 - y * 5000) // 1000
        #print('y:' + str(y) + 'z:' + str(z))
        if x + y + z == N:
            judge = True
            break
        y += 1
if judge:
    print(str(x) + ' ' + str(y) + ' ' + str(z))
else:
    print('-1 -1 -1')


### FIXED CODE ###

judge = False
N, Y = map(int, input().split())
x = -1
while x <= N and (not judge):
    x += 1
    y = z = 0
   # print('x:' + str(x))
    rest = Y - x * 10000
    if rest <= 0:
        if rest == 0 and x == N:
            judge = True
        break
    while x + y <= N and Y - x * 10000 - y * 5000 >= 0:
        z = (Y - x * 10000 - y * 5000) // 1000
      #  print('y:' + str(y) + 'z:' + str(z))
        if x + y + z == N:
            judge = True
            break
        y += 1
if judge:
    print(str(x) + ' ' + str(y) + ' ' + str(z))
else:
    print('-1 -1 -1')
import sys
# sys.setrecursionlimit(1000000)
input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
mod = 998244353

N = [int(x) for x in input()]
K = int(input())
dp = [[[0]*2 for j in range(K+1)] for i in range(len(N)+1)]
dp[0][0][1] = 1
for i in range(len(N)):
    dp[i+1][0][0] = 1
    if N[i] == 0:
        for k in range(1, K+1):
            dp[i+1][k][0] = dp[i][k][0]+dp[i][k-1][0]*9
            dp[i+1][k][1] = dp[i][k][1]
    else:
        for k in range(1, K+1):
            dp[i+1][k][0] = dp[i][k][0]+dp[i][k-1][0]*9+dp[i][k-1][1]*(N[i]-1)+dp[i][k][1]
        for k in range(K-1, -1, -1):
            if dp[i][k][1]:
                print(i, k, N[i])
                dp[i+1][k+1][1] = dp[i][k][1]
                break
print(dp)
print(dp[len(N)][K][0]+dp[len(N)][K][1])


### FIXED CODE ###

N = [int(x) for x in input()]
K = int(input())
dp = [[[0]*2 for j in range(K+1)] for i in range(len(N)+1)]
dp[0][0][1] = 1
for i in range(len(N)):
    dp[i+1][0][0] = 1
    if N[i] == 0:
        for k in range(1, K+1):
            dp[i+1][k][0] = dp[i][k][0]+dp[i][k-1][0]*9
            dp[i+1][k][1] = dp[i][k][1]
    else:
        for k in range(1, K+1):
            dp[i+1][k][0] = dp[i][k][0]+dp[i][k-1][0]*9+dp[i][k-1][1]*(N[i]-1)+dp[i][k][1]
        for k in range(K-1, -1, -1):
            if dp[i][k][1]:
                dp[i+1][k+1][1] = dp[i][k][1]
                break
print(dp[len(N)][K][0]+dp[len(N)][K][1])
count = 0
while True:
    x=input("")
    count+=1
    print("Case",str(count) + ":", x)

### FIXED CODE ###

t=[]
while True:
    x = str(input(""))
    if x == "0":
        break
    else:
        t.append(x)
for i,v in enumerate(t):
    print("Case",str(i+1)+":",v)
S=list(input())
N=len(S)
def main():
  ans=0
  i=0
  while len(S)>0 and i<N-1:
    if (S[i]==0 and S[i+1]==1) or (S[i]==1 and S[i+1]==0):
      S=S.remove(S[i:i+2])
      ans+=1
      i=0
    else:
      ans=ans
      i+=1
  print(ans)
main()

### FIXED CODE ###

S=input()
N=len(S)
a=S.count('0')
b=S.count('1')
t=min(a,b)
print(2*t)
N = int(input())
A = list(map(int,input(). split ()))
  
if 0 in A:
  print(0)
  return
  
prod = 1
for a in A:
  prod *= a
  if prod > 1000000000000000000:
    print(-1)
    return
    
print(prod)
  



### FIXED CODE ###

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

if i>=0:
  if  S[0::2]=='L':
      print('No')
  elif  S[1::2]=='R':
      print('No')
  else:
      print('Yes')

### FIXED CODE ###

S=input()
total=0

for i in range(len(S)):
    if  (i%2)==0:
        if  (S[i]=='R')or(S[i]=='U')or(S[i]=='D'):
            pass
        else:
            total+=1
    else:
        if  (S[i]=='L')or(S[i]=='U')or(S[i]=='D'):
            pass
        else:
            total+=1

if  total==0:
    print('Yes')
else:
    print('No')
x,y = map(int input().split())
a = -y+4x
b = y-2x
if(a%2==0 and b%2==0):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

x,y = map(int, input().split())
a = -y+4*x
b = y-2*x
if(a%2==0 and b%2==0 and a>=0 and b>=0):
  print("Yes")
else:
  print("No")
import sys
n=int(input())
l=[list(input()) for i in range(n)]
colors = [0 for i in range(n)]
es=[[] for i in range(n)]
for i in range(n):
  for j in range(n):
    if l[i][j]=='1':
      es[i].append(j)

def is_bipartite():
    stack = [(0,1)]
    while stack:
        v,color = stack.pop()
        colors[v] = color
        for to in es[v]:
            if colors[to] == color:
                 return False
            if colors[to] == 0:
                 stack.append((to, -color))
    return True
if is_bipartite()==0:
  print(-1)
  sys.exit()

for i in range(len(es)):
  if len(es[i])==1:
    x=i
    break
connection=es
distance1=[-1 for i in range(n)]
distance1[x]=0
next=connection[x]
next2=[]
check=[-1 for i in range(n)]
check[x]=1
checkct=1
ct=0
while len(next)!=0 and checkct!=n:
  ct+=1
  for i in range(len(next)):
    distance1[next[i]]=ct
    check[next[i]]=1
    checkct+=1
    for j in range(len(connection[next[i]])):
      if check[connection[next[i]][j]]==-1:
        next2.append(connection[next[i]][j])
  next=next2
  next2=[]

print(max(distance1)+1)

### FIXED CODE ###

import sys
from collections import deque
sys.setrecursionlimit(10**7)
n=int(input())
l=[list(input()) for i in range(n)]
colors = [0 for i in range(n)]
es=[[] for i in range(n)]
Edges=es
for i in range(n):
  for j in range(n):
    if l[i][j]=='1':
      es[i].append(j)
def dfs(v,color):
    colors[v] = color
    for to in es[v]:
        if colors[to] == color:
            return False
        if colors[to] == 0 and not dfs(to, -color):
            return False
    return True
 
def is_bipartite():
    return dfs(0,1)
if is_bipartite()==0:
  print(-1)
  sys.exit()


def bfs(v):
    Visited=[False]*n
    q=deque()
    q.append((v,0))
    Visited[v]=True
    ret=(v,0)
    while q:
        fr,dist=q.popleft()
        if ret[1]<dist:
            ret=(fr,dist)
        for to in Edges[fr]:
            if not Visited[to]:
                Visited[to]=True
                q.append((to,dist+1))
    return ret

ans=[]
for i in range(n):
  ans.append(bfs(i)[1])
print(max(ans)+1)
import math
'''
時針：Aセンチ，12時間で1周
分針：Bセンチ，1時間で1周
0時ちょうどに針は重なっていた．H時M分のとき，2本の針の端点は何センチ離れているか．
'''
 
A,B,H,M= list(map(int, input().split()))
 
theta = 2*math.pi*H/12+2*math.pi*M*/12/60 #時針の角度
phi = 2*math.pi*M/60 #分針の角度
 
deff_rad = 2*math.pi*(M/60 - H/12)
 
C = math.sqrt(A**2+B**2-2*A*B*math.cos(deff_rad))


### FIXED CODE ###

import math

a, b, h, m = list(map(int, input().split()))
deg_a = (60 * h + m) * (360 / (60 * 12))
deg_b = m * (360 / 60)
deg = abs(deg_a - deg_b)
rad = math.radians(deg)

c2 = a ** 2 + b ** 2 - 2 * a * b * math.cos(rad)
print(c2 ** 0.5)
# solution
import io

nim,mike = map(int,input().split())

sets={int(input()) for _ in range(mike)}

modulous=10**9+7

array=[0]*(nim+1)
array[0]=1
array[1]=1
if 1 in sets:
  array[1]=0

for i in range(2,nim+1):
  if i in sets:
    continue
  array[i]=(array[i-1]+array[i-2])%modulous
print(array[nim])

### FIXED CODE ###

nancy = [int(_) for _ in input().split()]
nancy.sort()
print(nancy[0]+nancy[1])
N = int(input())
a = list(map(int, input().split()))
b = sorted(a)
k = 0
for i in range(N):
  if a[i] != b[i]:
    k += 1
if k >2 :
  print("NO")
else:
  print("YES")
  


### FIXED CODE ###

A, B=map(int,input().split())
k = (A+B)//2 
if (A+B)%2 == 0:
  print(k)
else:
  print("IMPOSSIBLE")
s=list(input())
for i in range(5):
    print(s[i],end='')
print(' ',end='')
for i in range(7):
    print(i+6,end='')
print(' ',end='')
for i in range(5):
    print(s[i+13],end'')

### FIXED CODE ###

s=list(input())
for i in range(5):
    print(s[i],end='')
print(' ',end='')
for i in range(7):
    print(s[i+6],end='')
print(' ',end='')
for i in range(5):
    print(s[i+14],end='')
n = int(input().rstrip())
s = [str(input().rstrip()) for i in range(n)]
print("AC ×",s.count("AC"))
print("WA ×",s.count("WA"))
print("TLE ×",s.count("TLE"))
print("RE ×",s.count("RE"))

### FIXED CODE ###

a = int(input().rstrip())
n = [i for i in range(1,11) if(a <=i *1000)]
print((min(n)*1000) - a)