Harryxun/stf_run huggingface dataset:
from fractions import gcd


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


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

cumlcm = A[0]
for a in A[1:]:
    cumlcm = lcm(cumlcm, a)
m = cumlcm - 1
f = sum(map(lambda a: m % a if a != 0 else m, A))
print(f)


### FIXED CODE ###

from fractions import gcd


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


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

cumlcm = A[0]
for a in A[1:]:
    cumlcm = lcm(cumlcm, a)
m = cumlcm - 1
f = sum(map(lambda a: m % a, A))
print(f)
import sys
def input(): return sys.stdin.readline().strip()

n=int(input())
xs=input()
xj=xs.count("1")

x=int(xs,2)
xip=x%(xj+1)
if xj!=0:
    xim=x%(xj-1)

i1=1<<n
for i in range(n-1,-1,-1):
    i1=i1>>1
    xi=x^i1
    if xi==0:
        print(0)
        continue
    if xs[n-1-i]=="0":
        pxi=xj+1
        xi=(xip+i1%pxi)%pxi
    elif xj==1:
        print(0)
        continue
    else:
        pxi=xj-1
        xi=(xim-i1%pxi)%pxi
    xi=xi%pxi
    if xi==0:
        print(1)
        continue
    icnt=1
    while xi>0:
#        print("i",i,"xi",xi,"icnt",icnt)
        icnt+=1
        xi=xi%(bin(xi).count("1"))
    print(icnt)



### FIXED CODE ###

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

n=int(input())
xs=input()
xj=xs.count("1")

x=int(xs,2)
xip=x%(xj+1)
if xj!=1:
    xim=x%(xj-1)

for i in range(n-1,-1,-1):
    if xs[n-1-i]=="0":
        pxi=xj+1
        i2=pow(2,i,pxi)
        xi=(xip+i2)%pxi
    elif xj==1:
        print(0)
        continue
    else:
        pxi=xj-1
        i2=pow(2,i,pxi)
        xi=(xim-i2)%pxi
    xi=xi%pxi
    if xi==0:
        print(1)
        continue
    icnt=1
    while xi>0:
#        print("i",i,"xi",xi,"icnt",icnt)
        icnt+=1
        xi=xi%(bin(xi).count("1"))
    print(icnt)
N,D = map(int,input().split(" "))
count=0
for _ in range(N):
  p,q=map(int,input().split(" "))
  if (p*p + q*q)<=D*D:
    count+=1
print(count)

### FIXED CODE ###

X=int(input())

if X>=30:
  print("Yes")
else:
  print("No")
def main():
N = int(input())
A = list(map(int, input().split()))
SUM = 1

if 0 in A:
    print(0)
    return

for a in A:
    SUM = SUM * a
    if SUM > 1000000000000000000:
        print(-1)
        return

    print(SUM)

main()

### FIXED CODE ###

def main():
    N = int(input())
    A = list(map(int, input().split()))
    SUM = 1

    if 0 in A:
        print(0)
        return

    for a in A:
        SUM = SUM * a
        if SUM > 1000000000000000000:
            print(-1)
            return

    print(SUM)
main()
N=int(input())
s=0
L=[i for i in range(N)]
A=list(map(int,input().split()))
dic1={[i,i+a]:0 for i,a in zip(L,A)}
dic2={[i,i-a]:0 for i,a in zip(L,A)}
for p in range(N):
    z=[k for k,v in dic1.items() if k[2]==p]
    w=[k for k,v in dic2.items() if k[2]==p]
    s+=len(z)*len(w)
print(s)

### FIXED CODE ###

def count(dic,x):
    if x in dic:
        dic[x]+=1
    else:
        dic[x]=1

N=int(input())
A=list(map(int,input().split()))
dic1={}
dic2={}
s=0
for i in range(N):
    count(dic1,i-A[i])
    count(dic2,i+A[i])
for x in dic1:
    if x in dic2:
        s+=dic1[x]*dic2[x]
print(s)
N = int(input())
S = list(input())

Dic={}

def ff(i,L):
    if(len(S)>i):
        ff(i+1,L+S[i])
        ff(i+1,L)
    else:
        Dic[L]=1
ff(0,"")
print(len(Dic)-1)

### FIXED CODE ###

n = int(input())
s = input()
l = {}
for c in s:
    if c in l:
        l[c] += 1
    else:
        l[c] = 1
ans = 1
for i in l.values():
    ans *= i+1
print((ans-1)%(10**9+7))
A, B, C = map(int, input().split())
five = 0
seven = 0
check = [A, b, C]
for s in check:
    if s == 5:
        five += 1
    if s == 7:
        seven += 1
if five == 2 and seven == 1:
    print('YES')
else:
    print('NO')

### FIXED CODE ###

a, b, c = map(int, input().split())
five = 0
seven = 0
check = [a, b, c]
for s in check:
    if s == 5:
        five += 1
    if s == 7:
        seven += 1
if five == 2 and seven == 1:
    print('YES')
else:
    print('NO')
from sys import stdin

a,b=  stdin.readline().rstrip().split()

count = 0
for i,j in zip(a,b):
    if i ==j:
        count += 1



print(count)

### FIXED CODE ###

from sys import stdin

a=  stdin.readline().rstrip()
b=  stdin.readline().rstrip()

count = 0
for i,j in zip(a,b):
    if i ==j:
        count += 1



print(count)
A,B = map(int,input().split())
print(max(A,B)+max(max(A-1,B),max(A,B-1))

### FIXED CODE ###

A,B = map(int,input().split())
X = max(A,B)
Y = min(A,B)
if X+Y >= 2:
    print(max(A,B)+max(max(A,B)-1,min(A,B)))
else:
    print(X+Y)
str = raw_input()
print "Yes" if((str[0] == str[1] and str[1] == str[2] and str[2] == str[3]) or (str[1] == str[2] and str[2] == str[3] and str[3] == str[4])) else "NO"

### FIXED CODE ###

str = raw_input()
print "Yes" if((str[0] == str[1] and str[1] == str[2]) or (str[1] == str[2] and str[2] == str[3]))else "No"
a = 0
while True:
    x = int(input())
    a += 1
    if x == 0: break
    print ("Case {}: {}".format(a. x))


### FIXED CODE ###

i=1
x = int(input())
while x != 0 :
    print("Case {0}: {1}".format(i, x))
    x = int(input())
    i=i+1
a = input()
b = input()
a=int(a)
b=int(b)
if a>0:
    print("positive")
elif a ==0 or b==0:
   print(0)
elif a  <0 and b>0:
    print(0)
elif (b-a)%2==0:
    print('negative')
else:
    print("positibe")

### FIXED CODE ###

a, b = map(int,input().split())
if a <= 0 <= b:
    print("Zero")
elif a > 0:
    print("Positive")
elif (b-a) % 2 == 0:
    print("Negative")
else:
    print("Positive")
from sys import stdin
import numpy as np

N, i = map(int, raw_input().split() )
print n-1 + 1

### FIXED CODE ###

# -*- coding: utf-8 -*-
# Luis Yoichi Morales January 2019

from sys import stdin
import numpy as np

N, i = map(int, raw_input().split() )
print N-i + 1
from bisect import bisect_left,bisect_right
p=10**9+7
n,k=map(int,input().split())
a=sorted(list(map(int,input().split())))
minus=bisect_left(a,0) #負の数の個数
plus=n-bisect_right(a,0) #正の数の個数
neg=a[:minus] #負の数(絶対値大きい順)
pog=a[n-plus::][::-1] #正の数(絶対値大きい順)
zer=n-plus-minus #ゼロの数
ans=1
poi=0
nei=0
flag=0
co=0
sgn=1
if plus==1:
  alartp=1
else:
  alartp=0
if minus==1:
  alartn=1
else:
  alartn=0
if plus==0:
  if zer!=0 and k%2==1:
    print(0)
  else:
    for i in range(k):
      ans=ans*neg[-1-i]%p
    print(ans)
elif plus+minus<k:
  print(0)
elif minus==0:
  for _ in range(k):
    ans=ans*pog[poi]%p
    poi+=1
  print(ans)
else:
  i=0
  for i in range(k-2):
    if -neg[nei]>pog[poi]:
      ans=ans*neg[nei]%p
      sgn*=-1
      nei+=1
      if nei==minus-1:
        alartn=1
    else:
      ans=ans*pog[poi]%p
      poi+=1
      if poi==plus-1:
        alartp=1
    if alartp or alartn:
      break
  if alartn:
    if sgn==-1:
      ans=ans*neg[nei]%p
      i+=1
    for _ in range(k-i):
      ans=ans*pog[poi]%p
      poi+=1
  elif alartp==1:
    if (sgn==1 and (k-i)%2==1) or (sgn==-1 and (k-i)%2==0):
      ans=ans*pog[poi]
      i+=1
    for _ in range(k-i):
      ans=ans*neg[nei]
      nei+=1
  else:
    if sgn==1:
      a=max(pog[poi]*pog[poi+1],neg[nei]*neg[nei+1])
      ans=ans*a%p
    else:
      ans=ans*pog[poi]*neg[nei]%p
  print(ans)

### FIXED CODE ###

from bisect import bisect_left,bisect_right
p=10**9+7
n,k=map(int,input().split())
a=sorted(list(map(int,input().split())))
pi=1
ni=0
ans=1
i=0
while i<k-1:
  if a[ni]*a[ni+1]>a[-pi]*a[-pi-1]:
    ans=ans*a[ni]*a[ni+1]%p
    ni+=2
    i+=2
  else:
    ans=ans*a[-pi]%p
    pi+=1
    i+=1
if i==k-1:
  ans=ans*a[-pi]%p
if a[-1]<0 and k%2==1:
  ans=1
  for i in a[n-k:]:
    ans=ans*i%p
print(ans)
from collections import defaultdict

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

# 2辺の和リスト
d = [0] * (l[-1] * 2)
ans = 0

for i in range(n):
  for val in d[l[i] + 1:]:
    # 長さd[i]より小さい組み合わせはOK
    ans += val

  # 自身との組み合わせをdに追加
  for j in range(i):
    d[l[i] + l[j]] += 1

print(ans)


### FIXED CODE ###

from collections import defaultdict

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

# 2辺の和リスト
d = [0] * (l[-1] * 3)
ans = 0

for i in range(n):
  for val in d[l[i] + 1:]:
    # 長さd[i]より小さい組み合わせはOK
    ans += val

  # 自身との組み合わせをdに追加
  for j in range(i):
    d[l[i] + l[j]] += 1

print(ans)
def main():
 n,a=map(int,open(0).read().split());d,s=[0]*n,0
 for i,x in enumerate(a):
  if i+x<n:d[i+x]+=1
  if i-x>=0:s+=d[i-x]
 print(s)
main()

### FIXED CODE ###

from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
d = defaultdict(int)
for i in range(n):
  d[i+a[i]] += 1
ans = 0
for i in range(n):
  ans += d[i-a[i]]
print(ans)
import math
a, b, x = map(int, input().split())
if (a**2)*b/2 < x:
    s = math.degrees(math.atan(2*a/(3*(b-(x/(a**2))))))
else:
    s = math.degrees(math.atan(2*x/(a*b**2)))
print(90-s)

### FIXED CODE ###

import math
a, b, x = map(int, input().split())
if a**2*b == x:
    s = 90
elif (a**2)*b/2 < x:
    s = math.degrees(math.atan(a/(2*(b-(x/(a**2))))))
else:
    s = math.degrees(math.atan(2*x/(a*b**2)))
print(90-s)
print(x**3)

### FIXED CODE ###

x =int(input())
print(x**3)
cardArray = list(map(int,input().split()))

if cardArray[0]== carArray[1]:
  print("Draw")
elif cardArray[0] < cardArray[1]:
  if cardArray[0] == 1:
    print("Alice")
  else:
    print("Bob")
else:
  if cardArray[1] == 1:
    print("Bob")
  print("Alice")


### FIXED CODE ###

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

if cardArray[0]== cardArray[1]:
  print("Draw")
elif cardArray[0] < cardArray[1]:
  if cardArray[0] == 1:
    print("Alice")
  else:
    print("Bob")
else:
  if cardArray[1] == 1:
    print("Bob")
  else:
    print("Alice")
import heapq
N = int(input())
V = list(map(int, input().split()))
 
heapq.heapfy(V)
for i in range(N-2):
  heapq.heappush((heapq.heappop(V)+heapq.heappop(V))/2)
print(sum(V)/2)
  

### FIXED CODE ###

import heapq
N = int(input())
V = list(map(int, input().split()))
 
heapq.heapify(V)
for i in range(N-2):
  heapq.heappush(V, (heapq.heappop(V)+heapq.heappop(V))/2)
print(sum(V)/2)
while 1:
   x, y = map(int, raw_input().split())
   if x == 0 and y == 0:
      break
   elif y < x:
      print '%d %d' %(y,x)
   else:
      print '%d %d' %(x,y)
    

### FIXED CODE ###

while 1:
   x, y = map(int, raw_input().split())
   if x == 0 and y == 0:
      break
   elif x > y:
      print '%s %s' % (y,x)
   else:
      print '%s %s' % (x,y)
import sys
n = int(sys.stdin.readline())
p = [int(i) for i in sys.stdin.readline().split()]

if p == sorted(p):
    print('YES')
elif len(p) == 2:
    print('YES')
else:
    swap_index = []
    for i, v in enumerate(p[:-1]):
        if v > p[i + 1]:
            if len(swap_index) == 0:
                swap_index.append(i)
            else:
                swap_index.append(i + 1)
                break
    if len(swap_index) == 1:
        print('NO')
    p[swap_index[0]], p[swap_index[1]] = p[swap_index[1]], p[swap_index[0]]

    if p == sorted(p):
        print('YES')
    else:
        print('NO')


### FIXED CODE ###

import sys
n = int(sys.stdin.readline())
p = [int(i) for i in sys.stdin.readline().split()]

if p == sorted(p):
    print('YES')
elif len(p) == 2:
    print('YES')
else:
    swap_index = []
    for i, v in enumerate(p[:-1]):
        if v > p[i + 1]:
            if len(swap_index) == 0:
                swap_index.append(i)
            else:
                swap_index.append(i + 1)
                break
    if len(swap_index) == 1:
        print('NO')
    else:
        p[swap_index[0]], p[swap_index[1]] = p[swap_index[1]], p[swap_index[0]]
        if p == sorted(p):
            print('YES')
        else:
            print('NO')
from math import gcd
n = int(input())
p = 10**9 + 7
iwashi = {}
bad = 0
ans = 1
for i in range(n):
    x, y = map(int, input().split())
    if(x == 0 and y == 0):
      bad += 1
      continue
    elif(x == 0):
		try:
        	iwashi[(0, -1)] += 1
		except KeyError:
            iwashi[(0, -1)] = 1
        continue
    elif(y == 0):
        try:
        	iwashi[(-1, 0)] += 1
		except KeyError:
            iwashi[(-1, 0)] = 1
        continue
    else:
        g = gcd(x, y)
        x, y = x // g, y // g
        if x < 0:
            x, y = -x, -y
        try:
        	iwashi[(x, y)] += 1
        except KeyError:
            iwashi[(x, y)] = 1
            
for x, y in iwashi:
    a = iwashi[(x, y)]
    if y > 0:
    	rx,ry = y, -x
    else:
      	rx,ry = y, -x
    try:
        b = iwashi[(rx,ry)]
        iwashi[(rx,ry)] = 0
    except KeyError:
      	b = 0
    ans *= pow(2, a, p) + pow(2, b, p) - 1
    ans %= p
    iwashi[(x, y)] = 0
print((ans + bad - 1) % p)


### FIXED CODE ###

from math import gcd
n = int(input())
p = 10**9 + 7
iwashi = {}
bad = 0
ans = 1
for i in range(n):
    x, y = map(int, input().split())
    if(x == 0 and y == 0):
      bad += 1
      continue
    elif(x == 0):
        try:
        	iwashi[(0, 1)] += 1
        except KeyError:
            iwashi[(0, 1)] = 1
            continue
    elif(y == 0):
        try:
        	iwashi[(1, 0)] += 1
        except KeyError:
            iwashi[(1, 0)] = 1
        continue
    else:
        g = gcd(x, y)
        x, y = x // g, y // g
        if x < 0:
            x, y = -x, -y
        try:
        	iwashi[(x, y)] += 1
        except KeyError:
            iwashi[(x, y)] = 1
            
for x, y in iwashi:
    a = iwashi[(x, y)]
    if y > 0:
    	rx,ry = y, -x
    else:
      	rx,ry = -y, x
    try:
        b = iwashi[(rx,ry)]
        iwashi[(rx,ry)] = 0
    except KeyError:
      	b = 0
    ans *= pow(2, a, p) + pow(2, b, p) - 1
    ans %= p
    iwashi[(x, y)] = 0
print((ans + bad - 1) % p)
from sympy import sieve
x = int(input())
s = [i for i in sieve.primerange(2,100004) if i >= x]
print(s[0])


### FIXED CODE ###

import math
x = int(input())
def prime_get():
    if x <= 1:
        return []
    prime = [2]
    limit = int(math.sqrt(x))
    data = [i+1 for i in range(2,100004,2)]

    while limit >= data[0]:
        prime.append(data[0])
        data = [j for j in data if j % data[0] != 0]
    return prime+data

ans = prime_get()
ans = [i for i in ans if i >= x]
print(ans[0])
s = sorted(list(map(int, input().split())))
a = s.pop(-1)
b,c = a // 2, a - (a//2)
d = s[0] * a[1]
print(abs(d * b - d * c))

### FIXED CODE ###

s = sorted(list(map(int, input().split())))
a = s.pop(-1)
b = a // 2
c = a - (a//2)
d = s[0] * s[1]
print(abs(d * b - d * c))
nums = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
N, M = map(int, input().split())
A = list(map(int, input().split()))

# 使うマッチ棒の本数が等しい場合は大きい数だけ考えれば良い
A.sort(reverse=True)
s = set()
candidates = [] # [a, nums[a]]
for a in A:
  if nums[a] in s:
    continue
  s.add(nums[a])
  candidates.append([a, nums[a]])

# dp[i] : ちょうどi本のマッチ棒で作ることができる最大の整数
dp = [0] * (N+1)
for a, n in candidates:
  dp[n] = a

for i in range(N+1):
  for a, n in candidates:
    if i >= n and dp[i-n]:
      temp = list(str(dp[i-n])) + [str(a)]
      temp.sort(reverse=True)
      temp = int(''.join(temp))
      dp[i] = max(dp[i], temp)

print(dp[-1])

### FIXED CODE ###

nums = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
N, M = map(int, input().split())
A = list(map(int, input().split()))

# 使うマッチ棒の本数が等しい場合は大きい数だけ考えれば良い
A.sort(reverse=True)
s = set()
candidates = [] # [a, nums[a]]
for a in A:
  if nums[a] in s:
    continue
  s.add(nums[a])
  candidates.append([a, nums[a]])


dp1 = [0] * (N+1)
dp2 = [-1] * (N+1)
d = {}
for a, n in candidates:
  if n <= N:
    dp1[n] = 1
    dp2[n] = 0
    d[n] = a

for i in range(N+1):
  for a, n in candidates:
    if i >= n and dp1[i-n]:
      if dp1[i] < dp1[i-n] + 1:
        dp1[i] = dp1[i-n] + 1
        dp2[i] = i-n

ans = []
idx = N
while idx:
  next_idx = dp2[idx]
  ans.append(d[idx - next_idx])
  idx = next_idx

ans.sort(reverse=True)
print(''.join(list(map(str, ans))))
N = int(input())
a = map(int, input().split())

num = 0
for i in range(N):
  if a[i] == (num + 1):
    num += 1

if num == 0:
  print(-1)
else:
  print(N-num)

### FIXED CODE ###

N = int(input())
a = [i for i in map(int, input().split())]
     
num = 0
for i in range(N):
  if a[i] == (num + 1):
    num += 1
    
if num == 0:
  print(-1)
else:
  print(N-num)
def main():
    N, M, K = map(int, input().split())
    bookA = list(map(int, input().split()))
    bookB = list(map(int, input().split()))
    Ai = 0
    Bi = 0
    C = 0

    while K > 0:
        if Ai - N == 0 and Bi - M == 0:
            break
        if Ai - N == 0:
            K = K - bookB[Bi]
            if K == 0:
                C = C + 1
                break
            elif K < 0:
                break
            C = C + 1
            Bi = Bi + 1
        elif Bi - M == 0:
            K = K - bookB[Bi]
            if K == 0:
                C = C + 1
                break
            elif K < 0:
                break
            C = C + 1
            Ai = Ai + 1
        else:
            if bookA[Ai] < bookB[Bi]:
                K = K - bookA[Ai]
                if K == 0:
                    C = C + 1
                    break
                elif K < 0:
                    break
                C = C + 1
                Ai = Ai + 1
            else:
                K = K - bookB[Bi]
                if K == 0:
                    C = C + 1
                    break
                elif K < 0:
                    break
                C = C + 1
                Bi = Bi + 1
    
    print(C)
    
    

main()

### FIXED CODE ###

def main():
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    a, b = [0], [0]
    for i in range(N):
        a.append(a[i] + A[i])

    for i in range(M):
        b.append(b[i] + B[i])

    ans, j = 0, M
    for i in range(N + 1):
        if a[i] > K:
            break
        while b[j] > K - a[i]:
            j -= 1
        ans = max(ans, i + j)

    print(ans)
main()
while 1:
	n,m = map(int,raw_input().split())
	if n == 0: break
	scene = [map(int,raw_input().split()) for i in range(n)]
	pic = [map(int,raw_input().split()) for i in range(m)]
	ans = "NA"
	for rot in range(4):
		for y in range(n-m):
			for x in range(n-m):
				flag = 0
				for dy in range(m):
					for dx in range(m):
						if pic[dy][dx] > -1 and scene[y+dy][x+dx] - pic[dy][dx] != 0:
							flag = 1
							break
					if flag == 1: break
				if flag == 0:
					flag1 = 0
					for dy in range(m):
						for dx in range(m):
							if pic[dy][dx] > -1:
								ans = str(x+dx+1)+" "+str(y+dy+1)
								flag1 = 1
								break
						if flag1 == 1: break
			if flag == 0: break
		if flag == 0: break
		pic = [[pic[j][i] for j in range(m-1,-1,-1)] for i in range(m)]
	print ans

### FIXED CODE ###

def getxy(P,x,y,ans):
	for dy in range(m):
		for dx in range(m):
			if P[dy][dx] > -1:
				xy = [x+dx+1,y+dy+1]
				if xy[1] < ans[1] or (xy[1] == ans[1] and xy[0] < ans[0]):
					return xy
				else:
					return ans

# try-except is necessary
while 1:
	try:
		n,m = map(int,raw_input().split())
		if n == 0: break
		S = [map(int,raw_input().split()) for i in range(n)]
		P = [map(int,raw_input().split()) for i in range(m)]
		ans = [n+1,n+1]
		for rot in range(4):
			for y in range(min(ans[1],n-m+1)):
				for x in range(n-m+1):
					flag = 0
					for dy in range(m):
						for dx in range(m):
							if P[dy][dx] > -1 and S[y+dy][x+dx] - P[dy][dx] != 0:
								flag = 1
								break
						if flag == 1: break
					if flag == 0:
						ans = getxy(P,x,y,ans)
						break
				if flag == 0: break
			P = [[P[j][i] for j in range(m-1,-1,-1)] for i in range(m)]
		print "NA" if ans == [n+1,n+1] else " ".join(map(str,ans))
	except:
		pass
from collections import Counter


N = int(input())
C = input()
C_cntr = Counter(C)

ans = 0
for i in range(C_cntr["R"]):
　if C[i] == "W":
        ans += 1

print(ans)


### FIXED CODE ###

from collections import Counter


N = int(input())
C = input()
C_cntr = Counter(C)

all_R_cnt = 0
all_W_cnt = 0
R_W_cnt = 0
for i in range(N):
    if C[i] == "W":
        all_R_cnt += 1
    elif C[i] == "R":
        all_W_cnt += 1
    if i < C_cntr.get("R", 0) and C[i] == "W":
        R_W_cnt += 1

print(min(all_R_cnt, all_W_cnt, R_W_cnt))
import math
 
num = [int(input()) for _ in range(5)]
num2 = [n if n % 10 == 0 else n - (n%10) + 10  for n in num]

c = []
for i, j  in enumerate(num):
    n = j
    for k,l in enumerate(num2):
        if  k == i:
            continue
        else:
            n += l

print(min(c))


### FIXED CODE ###

num = [int(input()) for _ in range(5)]
num2 = [n if n % 10 == 0 else n - (n%10) + 10  for n in num]

c = []
for i, j  in enumerate(num):
    n = j
    for k,l in enumerate(num2):
        if  k == i:
            continue
        else:
            n += l
    c.append(n)

print(int(min(c)))
a,b = map(int,input().split())
if(a*b<=0)
	print(Zero)
elif(a<0 and (b-a)%2==0)
	print(Positive)
else
	print(Negative)

### FIXED CODE ###

a,b = map(int,input().split())
if a*b<=0:
    print("Zero")
elif a<0 and (b-a)%2==0:
    print("Negative")
else:
    print("Positive")
n, k = map(int, input().split())
pp = tuple(sorted(map(int, input().split())))
intv = []
for i in range(1, len(pp)):
    intv.append(pp[i] - pp[i - 1])
intv = sorted(intv)

ans = pp[-1] - pp[0]
for i in range(n - 1):
    ans -= intv[-i - 1]
print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
pp = tuple(sorted(map(int, input().split())))

if n >= k:
    print(0)
    exit(0)

intv = []
for i in range(1, len(pp)):
    intv.append(pp[i] - pp[i - 1])
intv = sorted(intv)

ans = pp[-1] - pp[0]
for i in range(n - 1):
    ans -= intv[-i - 1]
print(ans)
n, k = map(int,input().split())
c = [0]*k

for i in range(k):
	d = int(input())
	for j in range(d):
		d = list(map(int, input().split()))
		for k in range(len(d)):
			c[d[k]] +=1

print(c.count(0))

### FIXED CODE ###

n, k = map(int,input().split())
c = [0]*n

for i in range(k):
	d = int(input())
	a = list(map(int, input().split()))
	for k in range(len(a)):
		c[a[k]-1] +=1

print(c.count(0))
s = input()
t = input()

x = len(s)

if s == t:
  print('Yes')

for z in range(x):
  u[0] = s[x-1]
  
  for y in range(x-2):
    u[y+1] = s[y]
  
  if t == u;
  print('Yes')

  s = u
  
print('No')

### FIXED CODE ###

print('Yes' if (input() * 2).find(input()) != -1 else 'No')
result = 0;
for i in range(1,N+1):
    result += i
        
print(result)

### FIXED CODE ###

N=int(input())
result = 0;
for i in range(1,N+1):
    result += i
        
print(result)
n,m=map(int,input().split())
edge=[[] for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    edge[a].append(b)
    edge[b].append(a)
depth=[-1 for i in range(n)]
def check(i,h):
    depth[i]=h
    for j in edge[i]:
        if depth[j]==-1:
            check(j,h+1)
        elif depth[j]%2==depth[i]%2:
            return False
    return True
if check(0,0):
    blk=0
    whi=0
    for i in range(n):
        if depth[i]%2==0:
            blk+=1
        else:
            whi+=1
    ret=0
    for i in range(n):
        if depth[i]%2==0:
            ret+=blk-len(edge[i])
        else:
            ret+=whi-len(edge[i])
    print(ret//2)
else:
    print(n*(n-1)//2-m)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)
n, m = map(int, input().split())
edge = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edge[a].append(b)
    edge[b].append(a)
# -1 → 0,1に塗っていきます
color=[-1 for i in range(n)]
def dfs(pos):
    ret = True
    for i in range(len(edge[pos])):
        to = edge[pos][i]
        if color[to] == -1:
            color[to] = 1 ^ color[pos]
            ret &= dfs(to)
        else:
            ret &= not (color[to]==color[pos])
    return ret

color[0]=0
if dfs(0):
    black, white = 0, 0
    for i in range(n):
        if color[i]==0:
            black += 1
        else:
            white += 1
    print(black*white-m)
else:
    print(n*(n-1)//2-m)