Harryxun/stf_run huggingface dataset:
import sys
import itertools
import numpy as np

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N = int(readline())
A = [[int(x) - 1 for x in row.split()] for row in readlines()]


ids = [[0 for j in range(1005)] for i in range(1005)]
V = 0
for i in range(N):
    for j in range(N):
        ids[i][j] = V
        V += 1

MAXV = 1005 * 1005 // 2

visited = [False for i in range(MAXV)]
calculated = [False for i in range(MAXV)]
dp = [0 for i in range(MAXV)]

def dfs(v):
    if visited[v]:
        if not calculated[v]:
            print(-1)
            exit()

        return dp[v]

    visited[v] = True
    dp[v] = 1
    for u in to[v]:
        dp[v] = max(dp[v], dfs(u) + 1)

    calculated[v] = True
    return dp[v]

to = [[] for i in range(MAXV)]
for i in range(N):
    for j in range(N - 1):
        a = i
        b = A[i][j]
        if a > b:
            a, b = b, a
        A[i][j] = ids[a][b]
    for j in range(N - 2):
        to[A[i][j + 1]].append(A[i][j])

ans = 0
for i in range(V):
    ans = max(ans, dfs(i))

print(ans)

### FIXED CODE ###

import sys
import itertools
import numpy as np

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N = int(readline())
A = [[-1] + [int(x) - 1 for x in row.split()][::-1] for row in readlines()]

# A.append([-1])

def f(cand):
    cand1 = set()
    can_use = []
    for n in cand:
        if A[A[n][-1]][-1] == n:
            can_use.append(n)
    for n in can_use:
        A[n].pop()
        cand1.add(n)
        if A[n][-1] != -1:
            cand1.add(A[n][-1])
    return len(can_use), cand1

answer = 0
rest = N*(N-1)
cand = set(range(N))
while True:
    answer += 1
    x, cand = f(cand)
    if x == 0:
        answer = -1
        break
    rest -= x
    if rest == 0:
        break

print(answer)
import sys
lines = sys.stdin.readlines()

S = input()

#10**nのmod計算
A = []
p =1
for i in range(len(S)):
  A.append(p)
  p = p*10%2019

#左からi文字以降の数字列のmod計算
X = []
a = 0
for i in range(len(S)):
  a = (a + int(S[len(S)-i-1])*A[i]) %2019
  X.append(a)
X.sort()
flag =1
n = 0

#modが同じになる組み合わせ、またはもともとmodが0になる数字列の個数の総和計算
for i in range(len(X)-1):
  if X[i]==0:
    n +=1
  if X[i]==X[i+1]:
    flag += 1
  else:
    n += flag*(flag-1)//2
    flag = 1
print(n)

### FIXED CODE ###

S = str(input())

#10**nのmod計算
A = []
p =1
for i in range(len(S)):
  A.append(p)
  p = p*10%2019

#左からi文字以降の数字列のmod計算
X = []
a = 0
for i in range(len(S)):
  a = (a + int(S[len(S)-i-1])*A[i]) %2019
  X.append(a)
X.sort()
flag =1
n = 0

#modが同じになる組み合わせ、またはもともとmodが0になる数字列の個数の総和計算
for i in range(len(X)-1):
  if X[i]==0:
    n +=1
  if X[i]==X[i+1]:
    flag += 1
  else:
    n += int(flag*(flag-1)/2)
    flag = 1
n += int(flag*(flag-1)/2)
if X[len(X)-1]==0:
  n +=1
print(n)
L = [0, 0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0]

x, y = map(int, input().split())

if L(x) == L(y):
    print("Yes")
else:
    print("No")


### FIXED CODE ###

L = [0, 0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0]

x, y = map(int, input().split())

print(["No", "Yes"] [L[x] == L[y]])
s = list(map(str, input()))
a = s.count(+)
b = s.count(-)
print(a - b)


### FIXED CODE ###

s = list(input())
a = s.count("+")
b = s.count("-")
print(a - b)
N=int(input())
s=[input() for _ in range(N)]
cnt=0

A_count=0
B_count=0
BA_count=0
for u in s:
    cnt+=u.count("AB")
    if u[0]=="B":
        B_count+=1
    if u[-1]=="A":
        A_count+=1
    if u[0]=="B" and u[-1]=="A":
        BA_count+=1
if A_count==B_count==BA_count:
    if A_count==0:
        print(cnt)
    else:
        print(cnt+A_count-1)
else:
    print(cnt+min(A_count,B,count))

### FIXED CODE ###

N=int(input())
s=[input() for _ in range(N)]
cnt=0

A_count=0
B_count=0
BA_count=0
for u in s:
    cnt+=u.count("AB")
    if u[0]=="B":
        B_count+=1
    if u[-1]=="A":
        A_count+=1
    if u[0]=="B" and u[-1]=="A":
        BA_count+=1
if A_count==B_count==BA_count:
    if A_count==0:
        print(cnt)
    else:
        print(cnt+A_count-1)
else:
    print(cnt+min(A_count,B_count))
S=input()
if S==MON:
  print(6)
elif S==TUE:
  print(5)
elif S==WED:
  print(4)
elif S==THU:
  print(3)
elif S==FRI:
  print(2)
elif S==SAT:
  print(1)
elif S==SUN:
  print(7)
  

### FIXED CODE ###

S=input()
if S=="MON":
  print(6)
elif S=="TUE":
  print(5)
elif S=="WED":
  print(4)
elif S=="THU":
  print(3)
elif S=="FRI":
  print(2)
elif S=="SAT":
  print(1)
elif S=="SUN":
  print(7)
W, H, w, y, r = map(int, input().split())

if x -r < 0 or x + r > W:
    print("No")

### FIXED CODE ###

w, h, x, y, r = map(int, input().split())

if x + r <= w and y + r >= 0 and x - r >= 0 and y + r <= h:
    print("Yes")
else:
    print("No")
n,m,x,y = map(int,input().split())
a = max(max(list(map(int,input().split())),x)
b = min(min(list(map(int,input().split())),y)
print("No War" if a<b else "War")

### FIXED CODE ###

n,m,x,y = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
print("No War" if max(max(a),x)<min(min(b),y) else "War")
from math import gcd
def lcm( x, y):
    return (x*y)//gcd(x,y)
a,b,c,d=map(int,input().split())
C =b//c-a//c
D= b//d-a//d
EX=  lcm(c,d)
EX=b//EX-a//EX
print(b-a+1-(C+D)+EX)

### FIXED CODE ###

def gcd(x,y):
    if x<y:
        x,y=y,x
    if y==0:
        return x
    c=x%y
    return gcd(y,c)   
def lcm( x, y):
    return (x*y)//gcd(x,y)
a,b,c,d=map(int,input().split())
C =b//c-(-(-a//c))
D= b//d-(-(-a//d))
EX=  lcm(c,d)
EX=b//EX+(-a//EX)
print(b-a-(C+D)+EX)
from itertools import combinations, groupby
from operator import mul
from functools import reduce

def ncr(n,r):
  r = min(r, n-r)
  if r == 0: return 1
  numer = reduce(mul, range(n, n-r, -1))
  denom = reduce(mul, range(1, r+1))
  return numer//denom

N, K = map(int,input().split())
MOD = 10**9 + 7

for k in range(1,K+1):
  print((ncr(N-K+1,k)*ncr(K-1,k-1))%MOD)

### FIXED CODE ###

from itertools import combinations, groupby
from operator import mul
from functools import reduce

def ncr(n,r):
  if r == 0: return 1
  numer = reduce(mul, range(n, n-r, -1), 1)
  denom = reduce(mul, range(1, r+1), 1)
  return numer//denom

N, K = map(int,input().split())
MOD = 10**9 + 7

for k in range(1,K+1):
  print((ncr(N-K+1,k)*ncr(K-1,k-1))%MOD)
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 20:47:47 2019

@author: Owner
"""

# -*- coding: utf-8 -*-
"""
Created on Sat Apr 13 09:53:12 2019

@author: Owner
"""

from operator import itemgetter
import itertools
import bisect

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

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

BC = [(0, 0)]*M
for m in range(M):
    BC[m] = tuple(map(int, input().split()))
BC.sort(key=itemgetter(1), reverse = True)

def main(): 
    #print(BC)
    res = 0
    num = 0
    for i in range(M):
        idx = 0         
        idx = bisect.bisect_left(A, BC[i][1])
        if idx == 0:
            break
        else:
            less =min(idx, BC[i][0]) 
            num += less
            res += BC[i][1]*less

    print(res+sum(A[num：]))
                
                
                
            
            
                

    
if __name__ == '__main__':
    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sat Apr 20 20:47:47 2019
 
@author: Owner
"""
 
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 13 09:53:12 2019
 
@author: Owner
"""
 
from operator import itemgetter
import itertools
import collections
import bisect
 
N, M = list(map(int, input().split()))
 
A = list(map(int, input().split()))
A.sort()

A = collections.deque(A)

BC = [(0, 0)]*M
for m in range(M):
    BC[m] = tuple(map(int, input().split()))
BC.sort(key=itemgetter(1), reverse = True)
 
def main(): 
    #print(BC)
    res = 0
    for i in range(M):
        idx = 0         
        idx = bisect.bisect_left(A, BC[i][1])
        if idx == 0:
            break
        else:
            less =min(idx, BC[i][0])
            for n in range(less):
                A.popleft()
            res += BC[i][1]*less
 
    print(res+sum(A))
                
                
                
            
            
                
 
    
if __name__ == '__main__':
    main()
def b_picking_up(N, Positions):
    from collections import defaultdict
    difference_count = defaultdict(int)  # xの差分とyの差分の組について、現れた回数
    before_x, before_y = Positions[0]
    for x, y in Positions[1:]:
        diff_x, diff_y = x - before_x, y - before_y
        difference_count[(diff_x, diff_y)] += 1
        before_x, before_y = x, y
    # print(difference_count)
    difference_count = sorted(difference_count.items(), key=lambda x: x[1], reverse=True)
    # print(difference_count)
    if difference_count[0][0] == (0, 0):
        if len(difference_count) == 1:
            return N
        else:
            p, q = difference_count[1][0]
    else:
        p, q = difference_count[0][0]

    ans = 1
    before_x, before_y = Positions[0]
    for x, y in Positions[1:]:
        diff_x, diff_y = x - before_x, y - before_y
        if (diff_x, diff_y) != (p, q):
            ans += 1
        before_x, before_y = x, y
    return ans

N = int(input())
Positions = [[int(i) for i in input().split()] for j in range(N)]
print(b_picking_up(N, Positions))

### FIXED CODE ###

def b_picking_up(N, Positions):
    if N == 1:
        return 1  # 最初のボールに移動するのは必ずコスト1

    from collections import defaultdict
    difference_count = defaultdict(int)  # xの差分とyの差分の組について、現れた回数

    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            # diff_x と diff_y がともに0となることは、入力の制約よりありえない
            diff_x = Positions[j][0] - Positions[i][0]
            diff_y = Positions[j][1] - Positions[i][1]
            difference_count[(diff_x, diff_y)] += 1
    return N - max(difference_count.values())  # 第2項はコスト0で移動できる座標の数

N = int(input())
Positions = [[int(i) for i in input().split()] for j in range(N)]
print(b_picking_up(N, Positions))
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
if a>=0:
    h=list(map(lambda x:abs(t-x*0.006-a),h))
else:
    h=list(map(lambda x:t-x*0.006-a),h)

print(h.index(min(h))+1)

### FIXED CODE ###

n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
h=list(map(lambda x:t-x*0.006,h))
tmp=[abs(i-a) for i in h]
print(tmp.index(min(tmp))+1)
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

s = input()
k = ni()
ans_idx = len(s)
for i in range(len(s)):
    if s[i] == "1":
        continue
    else:
        ans_idx = i
        break
if ans_idx - 1 >= k:
    print("1")
else:
    print(s[ans_idx])


### FIXED CODE ###

import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

s = input()
k = ni()
keta = 0
for i in range(len(s)):
    if s[i] == "1":
        continue
    else:
        keta = i
        break
if k < keta + 1:
    print("1")
else:
    print(s[keta])
a=str(input())
b=int(a[0])
c=int(a[1])
d=int(a[2])
if b==1:
  b="9"
elif b==9:
  b="1"
if c==1:
  c="9"
elif c==9:
  c="1"
if d==1:
  d="9"
elif d==9:
  d=="1"
e=int(b+c+d)
print(e)

### FIXED CODE ###

a=int(input())
print(1110-a)
i = 0
while !n = (int)raw_input():
  i += 1
  print 'Case {0}: {1}'.format(i,n)

### FIXED CODE ###

n = input()
i = 1
while n != 0:
  print "Case %d: %d" % (i, n)
  n = input()
  i += 1;
h,w = map(int,input().split())
t = "."*(w+2)
b = [t]
for i in range(h):
  s = str(input())
  s = "."+ s + "."
  b.append(s)
b.append(t)
for i in range(1,h+1):
  for j in range(1,w+1):
    if s[i][j] == "#":
      if all([s[i-1][j]==".",s[i+1][j]==".",s[i][j-1]==".",s[i][j+1]=="."]):
        print("No")
        exit()
print("Yes")

  

### FIXED CODE ###

h,w = map(int,input().split())
t = "."*(w+2)
b = [t]
for i in range(h):
  s = str(input())
  s = "."+ s + "."
  b.append(s)
b.append(t)
for i in range(1,h+1):
  for j in range(1,w+1):
    if b[i][j] == "#":
      if all([b[i-1][j]==".",b[i+1][j]==".",b[i][j-1]==".",b[i][j+1]=="."]):
        print("No")
        exit()
print("Yes")
# coding: UTF-8
from collections import deque
visited = set()
d = {}
arrow = {}
nodes = deque()

raw = input().split()
N = int(raw[0])
M = int(raw[1])

for i in range(1,N+1):
  arrow[i] = deque()
  d[i] = 0
  nodes.append(i)

for i in range(M):
  raw = list(map(int,input().split()))
  L = raw[0]
  R = raw[1]
  D = raw[2]
  arrow[L].append((R,D))
  arrow[R].append((L,-D))

def dfsl(v):
  #矛盾が見つかればFalseを返す
  visited.add(v)
  while arrow[v]:
    w,cost = arrow[v].pop()
    
    if w not in visited:
      d[w] = d[v] + cost
      return dfsl(w)
    else:
      if d[w] != d[v] + cost:
        return False
  return True

ans = True
while nodes:
  u = nodes.pop()
  if u not in visited:
    d[u] = 0
    ans = dfsl(u)
    if not ans:
      break

if ans:
  print("Yes")
else:
  print("No")     
      

### FIXED CODE ###

# coding: UTF-8
from collections import deque
N,M = map(int,input().split())
link = [ [] for _ in range(N+1)]
value = [ -1 for _ in range(N+1)]

for _ in range(M):
  L,R,D = map(int,input().split())
  link[L].append((R,D))
  link[R].append((L,-D))

searched = set()
queue = deque()
for u in range(N+1):
  if u not in searched:
    queue.append(u)
    searched.add(u)
    value[u] = 0
    while queue:
      v = queue.popleft()
      for w,d in link[v]:
        if w not in searched:
          value[w] = value[v] + d
          queue.append(w)
          searched.add(w)

#verification
for v in range(N+1):
  for w,d in link[v]:
    if value[w] != value[v] + d:
      print("No")
      exit()
print("Yes")
import itertools

s = input()

x = ['+','-']

l = list(itertools.product(x,x,x))

res = int(s[0])
for sign in l:
  res = int(s[0])
  for i in range(3):
    if sign[i] == '+':
      res += int(s[i+1])
    else:
      res -= int(s[i+1])
  if res == 7:
    print(s[0],end="")
    for i in range(3):
      print(sign[i],end="")
      print(s[i+1],end="")
    print("=7")
	exit(0)

### FIXED CODE ###

import itertools

s = input()

x = ['+','-']

l = list(itertools.product(x,x,x))

res = int(s[0])
for sign in l:
  res = int(s[0])
  for i in range(3):
    if sign[i] == '+':
      res += int(s[i+1])
    else:
      res -= int(s[i+1])
  if res == 7:
    print(s[0],end="")
    for i in range(3):
      print(sign[i],end="")
      print(s[i+1],end="")
    print("=7")
    exit(0)
n, h,  *ab = map(int, open(0).read().split())
a = ab[::2]
x = max(a)
b = sorted([i for i in ab[1**2] if i > x], reverse=1)
ans = 0
for i in b:
    ans += 1
    h -= i
    if h <= 0:
        break
ans += (h + x = 1) // x
print(ans)


### FIXED CODE ###

n, h = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(n)]
A,B = zip(*AB)
a = max(A)
B = [b for b in B if b > a]
B.sort(reverse=True)
ans = 0
hp = h
attack_cnt = 0
for b in B:
    if hp <= 0:
        break
    attack_cnt += 1
    hp -= b
if hp > 0:
    attack_cnt += (hp - 1) // a + 1
print(attack_cnt)
def get_min_cost(S):
    if len(S) == 0:
        return 0
    if len(S) == 1:
        return 0
    return min(1 + get_min_cost(S[1:]), get_cost_change_black(S))

def get_cost_change_black(S):
    return S.count(".")

N = int(input())
S = str(input())

if '#' in S:
    answer = get_min_cost(S[S.index('#'):])
    print(answer)
else:
    print(0)


### FIXED CODE ###

def get_cost_change_black(S):
    return S.count(".")

N = int(input())
S = str(input())

indexs = [i for i, x in enumerate(S) if x == "#"]
if len(indexs) == 0:
    print(0)
else:
    answer = 10000000000
    change_white = 0
    change_black = get_cost_change_black(S[indexs[0]:])
    for i, ind in enumerate(indexs):
        x = change_white + change_black
        if x < answer:
            answer = x
        change_white = change_white + 1
        if i == len(indexs) - 1:
            if change_white < answer:
                answer = change_white
            break
        change_black = change_black - (indexs[i+1] - indexs[i] - 1)
    print(answer)
S = list(input())
K = int(input())
if K == 1:
    print(S[0])
else:
    x = 0
    while int(S[x]) == 1:
        x += 1
    print(S[x])

### FIXED CODE ###

S = list(map(int,input()))
K = int(input())
ans = 1
if K == 1 or S.count(S[0]) == len(S) or S.count(1) == len(S):
    ans = S[0]
else:
  for x in range(K):
    if S[x] != 1:
      ans = S[x]
      break
print(ans)
n=int(input())
    from math import sqrt as S 
    pf=[]
    for i in range(2,int(S(n))+1):
        if n%i==0:
            c=0 
            while n%i==0:
                n//=i 
                c+=1 
            pf.append([i,c])
    if n>1:
        pf.append([n,1])
    cnt=0 
    def search(x):
        i=1 
        while i(i+1)//2<=x:
            i+=1 
        return i-1 
    for x in range(len(pf)):
        a=pf[x][0]
        b=pf[x][1]
        cnt+=search(b)
    print(cnt)

### FIXED CODE ###

n=int(input())
from math import sqrt as S 
pf=[]
for i in range(2,int(S(n))+1):
    if n%i==0:
        c=0 
        while n%i==0:
            n//=i 
            c+=1 
        pf.append([i,c])
if n>1:
    pf.append([n,1])
cnt=0 
def search(x):
    lo=0
    hi=10**9 
    ans=0 
    while lo<=hi:
        mi=(lo+hi)//2 
        if mi*(mi+1)//2<=x:
            ans=mi 
            lo=mi+1 
        else:
            hi=mi-1 
    return ans 
for x in range(len(pf)):
    a=pf[x][0]
    b=pf[x][1]
    cnt+=search(b)
print(cnt)
def main():
    k = int(input())
    gcds = list(sorted([gcd(i, j) for i in range(1, k+1) for j in range(1, k+1)]))
    j = 0
    s = list(set(gcds))
    m = k**2-1
    gcdss = [0]*len(s)
    for i, l in enumerate(s):
        while gcds[j] == l:
            j += 1
            gcdss[i] += 1
        if j == m:
            break
    ans = sum([gcd(i, j)*n for i in range(1, k+1) for j, n in zip(s, gcdss)])
    print(ans)
            
    
def gcd(a, b):
    if a < b:
        a, b = b, a
    if a % b == 0:
        return b
    else:
        return gcd(b, a%b)


if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    k = int(input())
    gcds = list(sorted([gcd(i, j) for i in range(1, k+1) for j in range(1, k+1)]))
    j = 0
    s = list(sorted(list(set(gcds))))
    m = k**2-1
    gcdss = [0]*len(s)
    flag = False
    for i, l in enumerate(s):
        while gcds[j] == l:
            gcdss[i] += 1
            if j == m:
                flag = True
                break
            j += 1
        if flag:
            break
    ans = sum([gcd(i, p)*n for i in range(1, k+1) for p, n in zip(s, gcdss)])
    print(ans)
            
    
def gcd(a, b):
    if a < b:
        a, b = b, a
    if a % b == 0:
        return b
    else:
        return gcd(b, a%b)


if __name__ == "__main__":
    main()
N = int(input())
A = list(map, input().split())
li = []
for i, a in enumerate(A):
  li += [[a,i]]

li.sort()
for i in range(N):
  print(li[1])

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
li = []
for i, a in enumerate(A):
  li += [[a,i]]
  
li.sort()

for i in range(N):
  print(li[i][1]+1)
N=int(input())
A=list(map(int, input().split()))
B=[0 for _ in range(10001)]
C=A
for i in range(1,N):
    M=max(C[:i])
    if M>A[i]:
        B[i]=M-A[i]
        C[i]=M
print(sum(B))


### FIXED CODE ###

N=int(input())
A=list(map(int, input().split()))
ans=0
M=A[0]
for i in range(1,N):
    if A[i]>M:
        M=A[i]
    else:
        ans+=M-A[i]
print(ans)
x,y,z=map(int,input().split())
print(z x y)

### FIXED CODE ###

x,y,z=map(int,input().split())
print(z, x, y)
from functools import reduce
from fractions import gcd
A, B = map(int,input().split())
def Eratosthenes(n):
    if n == 1:
      return [1]
    if n == 2:
      return [1, 2]
    dp = [False]*n
    dp[0] = dp[1] = True
    prime = []
    l = [1]
    for i in range(2, n):
        if dp[i]:
            continue
        prime.append(i)
        if n%i==0:
          l.append(i)
        for j in range(i*2, n, i):
            dp[j] = True
            i += 1
    return l
print(len(Eratosthenes(reduce(gcd,[A,B]))))

### FIXED CODE ###

A, B = map(int,input().split())
def factorization(n):
    if n == 1:
      return [1]
    elif n == 2:
      return [1, 2]
    arr = [1]
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(i)
    if temp!=1:
        arr.append(temp)
    if arr==[]:
        arr.append(n)
    return arr
print(len(set(factorization(A))&set(factorization(B))))
import math


def main():
    ans = 0
    t = []
    for _ in range(5):
        x = input()
        if x[-1] == '0':
            ans += int(x)
        else:
            t.append(int(x))
    t.sort(key=lambda x: str(x)[-1])
    for i in range(1, len(t)):
        ans += math.ceil(t[i] / 10) * 10
    ans += t[0]
    print(ans)


main()


### FIXED CODE ###

import math


def main():
    ans = 0
    t = []
    for _ in range(5):
        x = input()
        if x[-1] == '0':
            ans += int(x)
        else:
            t.append(int(x))
    if len(t) > 0:
        t.sort(key=lambda x: str(x)[-1])
        for i in range(1, len(t)):
            ans += math.ceil(t[i] / 10) * 10
        ans += t[0]
    print(ans)


main()
a,b=map(int,input().split())
ans=0
if a==b:
  print(0)
  exit()  
if b>0:
  if abs(a)<abs(b):
    if a<0:
      ans+=1
      ans+=b+a  
    else:
      ans+=b-a  
  else:
    if a<0:
      raise "eerot"
      ans+=abs(a)-b+1  #正
    else:
      ans+=a-b+1 #正
else:
  if abs(a)<abs(b):
    if a<0:  
      ans+=2
      ans+=a-b
    else:
      ans+=abs(b)-a
      ans+=1 
  else:
    if a<0:  #正
      ans+=b-a
    else:
      ans+=a+b+1  #正
print(ans) 

### FIXED CODE ###

a,b=map(int,input().split())
ans=0
if a==b:
  print(0)
  exit()  
if b>0:
  if abs(a)<abs(b):
    if a<0:
      ans+=1
      ans+=b+a  
    else:
      ans+=b-a  
  else:
    if a<0:
      ans+=abs(a)-b+1
    else:
      ans+=a-b+2
else:
  if abs(a)<abs(b):
    if a<0:  
      ans+=2
      ans+=a-b
    else:
      ans+=abs(b)-a
      ans+=1 
  else:
    if a<0:
      ans+=b-a
    else:
      ans+=a+b+1
print(ans)
a=int(input())
b=list(map(int, input().split()))
cou,ju=0,0
ans=[]
while cou<a:
  i=1
  su=0
  while i*(cou+1)<a:
    su+=b[i*(cou+1)]
    i+=1
  if su%2!=b[cou]:
    ans+=[cou+1]
  cou+=1
if ans==[]:
  print("0")
else:
  s=""
  for i in ans:
    s+=str(i)+" "
  print(s)

### FIXED CODE ###

a=int(input())
b=[int(input()) for i in range(a)]
sr=list(reversed(sorted(b)))
if sr[1]==sr[0]:
  for i in range(a):
    print(sr[0])
else:
  for i in b:
    if i==sr[0]:
      print(sr[1])
    else:
      print(sr[0])
n = int(input())
x = [int(i) for i in input().split()]
d = []

b = 0
for i in range(min(x), max(x)):
  a = 0
  for j in x:
    a += (i - j)**2
#    print("({}-{})**2={}".format(j,i,(j - i)**2))
  d.append(a)
print(min(d))


### FIXED CODE ###

n = int(input())
x = [int(i) for i in input().split()]
d = []
for i in range(min(x), max(x)+1):
  a = 0
  for j in x:
    a += (j - i)**2
#    print("({}-{})**2={}".format(j,i,(j - i)**2))
  d.append(a)
print(min(d))
N=input()
N=N.replace('7')
print('Yes' if len(N)<3 else 'No')

### FIXED CODE ###

N=input()
N=N.replace('7','')
print('Yes' if len(N)<3 else 'No')
n = int(input())
i = 1
j = 1
k = 1
ans = 0
while i < n+1:
    j = 1
    while j < n+1:
        k = 1
        p = gcd(i,j)
        while k < n+1:
            if (p-1)*(k-1) == 0:
                ans += 1
            else:
                ans += gcd(k,p)
            k += 1
        j += 1
    i += 1
print(ans)

### FIXED CODE ###

def gcd(x,y):
    if y == 0:
        return x
    elif x == 1 or y == 1:
        return 1
    else:
        return gcd(y,x%y)

G = []
i,j = 1,1
while i < 201:
    j = 1
    g0 = []
    while j < 201:
        g0.append(gcd(i,j))
        j += 1
    g0 = tuple(g0)
    G.append(g0)
    i += 1
n = int(input())
i = 1
j = 1
k = 1
ans = 0
while i < n+1:
    j = 1
    while j < n+1:
        k = 1
        p = G[i-1][j-1]
        while k < n+1:
            ans += G[k-1][p-1]
            k += 1
        j += 1
    i += 1
print(ans)