peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
b = sum(a)
ans = 0
for i in range(n-1):
    ans += a[i] *(b-a[i])
    b = b - a[i]
print(ans % (10**9 + 7))
# Judge status: Accepted
n=int(input())
ans=0
for i in range(n,n+200):
    N=str(i)
    if N[0]==N[1]==N[2]:
        ans=i
        break
print(ans)
# Judge status: Accepted
n,m = map(int,input().split())

# 余ってる c の数
dif = m - 2 * n

# すでにある s に対して、 c の数が足りない時
if dif < 0:
    ans = m // 2

else:
    ans = n + dif // 4

print(ans)
# Judge status: Accepted
s = input()
cnt1 = 0
cnt0 = 0
for i in range(len(s)):
    if s[i] == "0":
        cnt0 +=1
    else:
        cnt1+=1
print(min(cnt0,cnt1)*2)
# Judge status: Accepted
import time
import itertools
import collections

N = int(input())
start = time.time()
def function(x,y,z):
    return pow(x,2) + pow(y,2) + pow(z,2) + (x * y) + (x * z ) + (y * z)

p = list(itertools.product(range(1,100),repeat=3))
a = []

for p_in in p:
    a.append(function(p_in[0],p_in[1],p_in[2]))

dict = collections.Counter(a)

for n in range(1,N + 1):
    print(dict[n])
# Judge status: Accepted
n = int(input())

s = list(input())

mx = 0
x = 0
for i in range(n):
  if s[i]=='I':
    x+=1
  else:
    x-=1
  if x>mx:
    mx = x
    
print(mx)
# Judge status: Accepted
N, P = map(int, input().split())
A = [int(i)&1 for i in input().split()]
o = A.count(1)
e = N-o
on = en = 0
def ncr(n, r):
    r = min(r,n-r)
    res=1
    d=1
    for i in range(r):
        res*=n-i
        d *= i + 1
    return res//d

for r in range(e+1):
    en+=ncr(e,r)
for r in range(P, o+1, 2):
    on+=ncr(o,r)

print(on*en)
# Judge status: Wrong Answer
x = input()
if x == 0:
  print(1)
else:
  print(0)
# Judge status: Accepted
import collections
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]

sc = collections.Counter(s)
tc = collections.Counter(t)
ans = 0
for x in sc.keys():
  ans = max(ans,sc[x]-tc[x])
print(ans)
# Judge status: Accepted
a,b,c,d=map(int,input().split())

index=0
for i in range(1000):
	if index==0:
		c=c-b
		if c<=0:
			print("Yes")
			break
		else:
			index=1
	else:
		a=a-d
		if a<=0:
			print("No")
			break
		else:
			index=0
# Judge status: Accepted
k = int(input())
a, b = [int(x) for x in input().split()]

ans = "NG"
for i in range(a, b + 1):
    if i % k == 0:
        ans = "OK"
        break
print(ans)
# Judge status: Accepted
n,m=map(int,input().split())
if n>8 or m>8:
    print(":(")
else:
    print("Yay!")
# Judge status: Wrong Answer
n, l = map(int, input().split())

apple = [i + l for i in range(n)]
aji = sum(apple)

if 0 in apple:
    print(0)
elif apple[0] > 0:
    print(aji - min(apple))
else:
    print(aji - max(apple))
# Judge status: Wrong Answer
h=int(input())
w=int(input())
n=int(input())

if h>w:
  if (int(n/h))<=w:
    print(int(n/h))
else:
  if (int(n/w))<=h:
    print(int(n/w))
# Judge status: Wrong Answer
s = input()
res = 1
flg = 0
i = 1
while i < len(s)-2:
  if s[i] == s[i-1]:
    i += 3
    res += 2
  else:
    res += 1
    i += 1
if i == len(s):
  print(res)
elif i == len(s)-1:
  if s[-1] == s[-2]:
    print(res)
  else:
    print(res+1)
elif i == len(s)-2:
  if s[-1] == s[-2]:
    print(res+1)
  else:
    print(res+2)
# Judge status: Accepted
X = int(input())

if X == 3 or X == 5 or X == 7 :
    print("YES")
else :
    print("NO")
# Judge status: Wrong Answer
import sys
S = list(input())
s = list(set(S))
s.sort()
alfa = list('abcdefghijklmnopqrstuvwxyg')
ans = 0
if(len(s)==len(alfa)):
  print('None')
  sys.exit()
else:
  for i in range(len(s)):
    if(s[i]!=alfa[i]):
      print(alfa[i])
      sys.exit()
  print(alfa[len(s)])
# Judge status: Accepted
h, n = map(int, input().split())
M = [list(map(int, input().split())) for _ in range(n)]

INF = 10**9
dp = [[INF] * (h+1) for _ in range(n+1)]
dp[0][h] = 0
for i in range(n):
    for j in reversed(range(h+1)):
        a, b = M[i]
        if j > h - a:
            dp[i+1][j] = min(dp[i][j], b)
        else:
            dp[i+1][j] = min(dp[i][j], dp[i+1][j+a] + b)
print(dp[n][0])
# Judge status: Accepted
s = input()
print("ABC") if s == "ARC" else print("ARC")
# Judge status: Accepted
from sys import stdin

a = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()

if a >= 3200:
    print(s)
else:
    print("red")
# Judge status: Accepted
S,W=map(int,input().split())
if W>=S:
    print("unsafe")
else:
    print("safe")
# Judge status: Accepted
k, s = map(int, input().split())

ans = 0
for x in range(k+1):
  for y in range(k+1):
    z = s - x - y
    if x+y+z != s:
      continue
    if z >= 0 and z <= k:
      ans += 1
      
      
print(ans)
# Judge status: Accepted
N = int(input())
S = list(input())
list_ans = []

for i in S:
    tmp = ord(i)
    tmp += N
    if tmp > 90:
        tmp -= 90 - 64
    list_ans.append(chr(tmp))

ans = "".join(list_ans)
print(ans)
# Judge status: Wrong Answer
import fractions
import numpy as np
A, B = map(int, input().split())

gcd = []
for i in range(1, fractions.gcd(A, B)+1):
    if A % i == 0 and B % i == 0:
        gcd.append(i)

max_gcd = gcd[-1]
prime = np.array([i for i in range(0, max_gcd+1)])
prime[0], prime[1] = 0, 0
for i in range(2, max_gcd+1):
    if i != prime[i]:
        continue
    for j in range(i*2, max_gcd, i):
        prime[j] = 0
prime = sorted(list(set(prime)))

ans = 0
for i in gcd:
    if i in prime:
        ans += 1
print(ans)
# Judge status: Wrong Answer
N,K=map(int,input().split())
a=list(map(int,input().split()))
if K>=N:
	print(0)
b=sorted(a)
c=0
for i in range(N-K):
	c+=b[i]
print(c)
# Judge status: Accepted
mod = 10 ** 9 + 7
#### 逆元リストいらない
fact = [1]
for i in range(10**5+5):
    new_fact = fact[-1]*(i+1)%mod
    fact.append(new_fact)
N,M = map(int,input().split())
if abs(N-M) > 1:
    ans = 0
elif abs(N-M) == 1:
    ans = fact[N] * fact[M] % mod
elif abs(N-M) == 0:
    ans = fact[N] * fact[M] * 2 % mod
print(ans)
# Judge status: Accepted
n = int(input())
l = list(map(int, input().split()))

for i in range(n):
    if l[i] % 4 == 0:
        l[i] = 2
    elif l[i] % 4 == 2:
        l[i] = 1
    else:
        l[i] = 0

if n - (l.count(2)*2 + 1) <= 0:
    print("Yes")
elif n - (l.count(2)*2 + 1) < l.count(1):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
from math import log2

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

r = 0
for i in range(1,N+1):
    if i >= K:
        r += 1.0 / N
        continue
    count = int(log2(K / i)) + 1

    r += (1.0 / N) * (1.0 / (2 ** count))

print(r)
# Judge status: Wrong Answer
def main():
    import sys
    
    s = sys.stdin.readline()
    
    delete = False
    for i in reversed(range(len(s))):
        if s[i] == "B":
            s = s[:i] + s[i+1:]
            delete = True
        elif delete:
            s = s[:i] + s[i+1:]
            delete = False
    print(s)
        
if __name__ == "__main__":
    main()
# Judge status: Accepted
N,M = map(int,input().split())
R,A = [0]*N,[1]*N
R[0] = 1
for i in range(M):
    x,y = map(int,input().split())
    x,y = x-1,y-1
    if A[x] > 1 and R[x] == 1:
        R[y] = 1
    elif A[x] ==  R[x] == 1:
        R[x] = 0
        R[y] = 1
    A[x] -= 1
    A[y] += 1
print(sum(R))
# Judge status: Wrong Answer
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0

for i in range(n):
    s = input()
    print(s)
    if s == 'AC':
        ac += 1
    elif s == 'WA':
        wa += 1
    elif s == 'TLE':
        tle += 1
    else:
        re += 1

print('AC x ' + str(ac))
print('WA x ' + str(wa))
print('TLE x ' + str(tle))
print('RE x ' + str(re))
# Judge status: Accepted
h = int(input())
w = int(input())
n = int(input())
def paint(num):
    if num >= n:
        print(1)
    else:
        k = 0
        c = 0
        while k < n:
            k +=num
            c+=1
        print(c)

if h <= w:
    paint(w)
else:
    paint(h)
# Judge status: Accepted
INT_MAX= 100000000
n=int(input())
dp  = [INT_MAX]*(100001)
h=[int(X) for X in input().split()]
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):

    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i-2]-h[i]))

print(dp[n-1])
# Judge status: Accepted
import math
N = int(input())
print(math.factorial(N) % (10**9+7))
# Judge status: Accepted
import math

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

if math.ceil(a/d)>=math.ceil(c/b):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
from math import ceil
N = int(input())
A = list(map(int,input().split()))
ans_1 = max(A)
A.remove(ans_1)
ans_2 = 1000000
d = 10000000000
half = ceil(ans_1/2)
for e in A:
    if d > abs(half-e):
        d = abs(half-e)
        ans_2 = e
print(ans_1,ans_2)
# Judge status: Wrong Answer
n = int(input())
flg = False
tmp = 0
ans = 0
for i in range(n):
	a, b = map(int, input().split())
	if not flg and a == b:
		tmp = 1
		flg = True
	elif flg and a == b:
		tmp += 1
	ans = max(ans, tmp)
print("Yes" if ans >= 3 else "No")
# Judge status: Wrong Answer
n,a,b = map(int, input().split())
if a > b or n < b-a+1:
    print(0)
    exit()
Max = a + b * (n-1)
Min = a * (n-1) + b
print(Max - Min + 1)
# Judge status: Accepted
n = int(input())
ans = [0]*4
for i in range(n):
    s = input()
    if s=='AC':
        ans[0]+=1
    elif s=='WA':
        ans[1]+=1
    elif s=='TLE':
        ans[2]+=1
    else:
        ans[3]+=1
print('AC x {0}'.format(ans[0]))
print('WA x {0}'.format(ans[1]))
print('TLE x {0}'.format(ans[2]))
print('RE x {0}'.format(ans[3]))
# Judge status: Accepted
n = int(input())
a= list(map(int, input().split()))
from collections import deque
d=deque()
if n%2==0:
    flag=1
else:
    flag=-1
for i in a:
    if flag==1:
        d.append(i)
        flag*=-1
    else:
        d.appendleft(i)
        flag*=-1
for i in d:
    print(i,end=" ")
print()
# Judge status: Wrong Answer
s = list(input())
t = list(input())
s.sort()
t.reverse()
S = str()
T = str()
for i in s:
    S += i
for k in t:
    T += k
print('Yes' if S<T else 'No')
# Judge status: Accepted
from itertools import accumulate

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
SA = list(accumulate(A))
SB = list(accumulate(B))
ans = 0
for i in range(n):
    if i >= 1:
        ans = max(SA[i] + SB[n - 1] - SB[i - 1], ans)
    else:
        ans = max(SA[i] + SB[n - 1], ans)
print(ans)
# Judge status: Wrong Answer
n = int(input())
sum = 0
for i in range(n):
    if i %3 != 0 and i %5 != 0:
        sum += i

print(sum)
# Judge status: Accepted
N = int(input())
Inf = [[0,0,0]]

for i in range(N):
    Inf += [list(map(int,input().split()))]

for i in range(N):
    dist = abs(Inf[i][1]-Inf[i+1][1]) + abs(Inf[i][2]-Inf[i+1][2])
    dt = Inf[i+1][0] - Inf[i][0]
    if dt < dist:
        print("No")
        break
    else:
        if (dt % 2) == (dist % 2):
            continue
        else:
            print("No")
            break
else:
    print("Yes")
# Judge status: Accepted
import sys
input = sys.stdin.readline

def main():
    n, a, b = map(int, input().split())
    ans = 0

    for i in range(1, n + 1):
        sum = 0
        for num in str(i):
            sum += int(num)
        if a <= sum <= b:
            ans += i
    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N,K = map(int,input().split())
li = [int(i) for i in input().split()]

min_index = li.index(1)
left = min_index
right = len(li) - left - 1

count = 0

if (left > 0) :
    count += left // (K-1)
    if (left % (K-1) == 1) :
        count += 1

if (right > 0) :
    count += right // (K-1)
    if (right % (K-1) == 1) :
        count += 1

print(count)
# Judge status: Accepted
n,m=map(int,input().split())
l=list(map(int,input().split()))
s=sum(l)
a=[]
for i in l:
    if i>=(s/(4*m)):

        a.append(1)
print('Yes' if len(a) >=m else 'No')
# Judge status: Accepted
import math
def distance(x1,x2,y1,y2):
  d=math.sqrt((x1-x2)**2+(y1-y2)**2)
  return d
count=int(input())
zahyou=[]
for i in range(count):
  a=input().split(" ")
  zahyou.append(a)

lenth=0
for i in zahyou:
  for j in zahyou:
    lenth=lenth+distance(int(i[0]),int(j[0]),int(i[1]),int(j[1]))
print(lenth/count)
# Judge status: Accepted
def main():
    N, M = map(int, input().split())

    cnt = 0
    cnt = min(N, M//2)
    M -= 2*cnt
    if M > 0:
        cnt += M//4
    print(cnt)
        
if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

a,b,c,d,k = inpl()
sa = c*60+d - (a*60-b)
print(sa-k)
# Judge status: Accepted
import sys
input = sys.stdin.readline
N, H = map(int, input().split())
a = [tuple(map(int, input().split())) for _ in range(N)]
a.sort(key = lambda x: -x[1])
cs = [0] * (N + 1)
mx = 0
for i in range(N):
  cs[i + 1] = cs[i] + a[i][1]
  mx = max(mx, a[i][0])
res = H + 1
for i in range(N + 1): res = min(res, -(-max(0, H - cs[i]) // mx) + i)
print(res)
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
if a<=b and b<=c:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
N,M=map(int,input().split())
arr=[int(x) for x in input().split()]
s=[list(map(int,input().split())) for y in range(M)]
s.sort(key=lambda z: z[1], reverse=True)

sum_a=0
for a,b in s:
    arr+=[b]*a
    sum_a+=a
    if sum_a>=N:
        break

lst=sorted(arr)
ans=sum(lst[-N:])
print(ans)
# Judge status: Accepted
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

ans = 0

for i in range(n):
    if a[i] < b[i]:
        ans += a[i]
        if a[i+1] < b[i]-a[i]:
            ans += a[i+1]
            a[i+1] = 0
        else:
            ans += b[i]-a[i]
            a[i+1] -= b[i]-a[i]
    else:
        ans += b[i]

print(ans)
# Judge status: Wrong Answer
n = int(input())
s = input()
if n%2==1:
    print("NO") 
else:
    s1 = ""
    s2 = ""
    for i in range(0, n//2):
        s1+=s[i]
        s2+=s[n//2 + i]
    if(s1 == s2):
        print("YES")
    else:
        print("NO")
# Judge status: Wrong Answer
n = input()
cnt = len(n) -1
for i in range(2 ** cnt):
    op = ["-"] * cnt
    for j in range(cnt):
        if ((i >> j) & 1):
            op[cnt - 1 - j] = "+"

    formula = ""
    for p_n,p_o in zip(n,op+[""]):
        formula += (p_n + p_o)
        print(formula)
    if eval(formula) == 7:
        print(formula + "=7")
        break
# Judge status: Wrong Answer
n,m=map(int,input().split())
cnt=0
i=1
d=0
non = []
while cnt<m:
    a,b=i,n-(i+d)+1
    if a==b:
        print(a,non)
        break
    if b-a != n-b+a:
        print(a,b)
        i += 1
        cnt += 1
    else:
        print(a,b-1)
        non = b
        d += 1
        i += 1
        cnt += 1
# Judge status: Accepted
N = int(input())
a = list(map(int, input().split()))

max_len = len(bin(max(a))[2:])
l = [0] * max_len

ans = 0
mod = 10**9 + 7

for i in range(max_len):
    for x in a:
        l[i] += x >> i & 1
    ans += pow(2, i, mod) * l[i] * (N-l[i])

print(ans % mod)
# Judge status: Accepted
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**5)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    N = gete(int)

    if N & 1 == 1:
        print(0)
        return

    base = 5
    n = N // 2
    ans = 0
    while base <= n:
        ans += n // base
        base *= 5

    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
N, K, S = map(int, input().split())

if S != 10 ** 9:
    ans = [S] * K + [S + 1] * (N - K)
else:
    ans = [S] * K + [1] * (N - K)

print (*ans)
# Judge status: Wrong Answer
n,m = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse = True)
if n == 1:
    print(a[0]//(2**m))
else:
    for i in range(m):
        a.sort(reverse = True)
        while a[0]>a[1]:
            a[0] //= 2
    print(sum(a))
# Judge status: Accepted
n = int(input())
a = [int(input()) for _ in range(n)]

a_set = set()
for a_i in a:
    a_set ^= {a_i}

print(len(a_set))
# Judge status: Wrong Answer
S = str(input())
N = len(S)


def solve(S):
    # S: 文字列
    r = N % 2
    for i in range(N//2):
        s = S[:N-(2*i+r)]
        n = len(s)
        #print(s,i,n,s[:(n//2)],s[(n//2):])
        if s[:(n//2)] == s[(n//2):]:
            ans = N - (2 * i + r)
    return ans


print(solve(S))
# Judge status: Accepted
a,b = map(int,input().split())
if a<=b:
    print(a)
    exit()
print(a-1)
# Judge status: Accepted
n, m = map(int, input().split())

if 2 * n >= m:
    print(min(n, m//2))
else:
    print((2 * n + m) // 4)
# Judge status: Accepted
N=int(input())
BU=[int(input())-1 for i in range(N)]
ans=-1
onid=0
for i in range(1,N+1):
  onid=BU[onid]
  if onid==1:
    ans=i
    break
print(ans)
# Judge status: Accepted
n = int(input())
d = [int(i) for i in input().split()]
d2 = sorted(d)
p = n // 2
print(d2[p] - d2[p-1])
# Judge status: Accepted
n,k=(int(i) for i in input().split())

a=list(map(int, input().split()))
a.sort()
sum=0
for i in range(k):
  sum+=a[i]
print(sum)
# Judge status: Wrong Answer
def combination(m, n):
    a = 1
    b = 1

    for i in range(m-n+1, m+1):
        a *= i

    for j in range(1, n+1):
        b *= j

    return a/b


mod = 10**9 + 7

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

if ((x + y) % 3) != 0:
    print(0)
    exit()
n = (x + y) / 3

print(combination(n, (n - (x-y)) / 2) % mod)
# Judge status: Accepted
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    w, h, x, y = map(int, readline().split())
    ans = '{:.10f}'.format(w*h/2) 
    print(ans, end=' ')
    if (2*x == w) and (2*y == h):
        print(1)
    else:
        print(0)
if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())
D = list(map(int, input().split()))
D.sort()
print(D[N//2]-D[N//2 - 1])
# Judge status: Wrong Answer
x, y = map(int,input().split())

a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]

if (x in a) and (y in a):
  print("YES")
elif (x in b) and (y in b):
  print("YES")
elif (x in c) and (y in c):
  print("YES")
else:
  print("NO")
# Judge status: Wrong Answer
import math

A,B,H,M  = map(int,input().split())
hd = 30*H + int(30/60*M)
md = 6*M
dif = min(abs(hd - md), 360-abs(hd-md))
yo = A**2 + B**2 - 2*A*B*math.cos(math.radians(dif))
print(yo**0.5)
# Judge status: Wrong Answer
N = int(input())

def base(x, n):
  ret = []
  while x != 0:
    ret.append( x % abs(n))
    if n < 0:
      x = - ( (-x)//n )
    else:
      x //= n
  return ret

print("".join(map(str, reversed(base(N, -2)))))
# Judge status: Wrong Answer
def solve():
    n,t = map(int,input().split())
    mn = 10**9
    for _ in range(n):
        a,b = map(int,input().split())
        if b<=t:
            mn = min(mn,a)
    if mn<=t:
        print(mn)
    else:
        print('TLE')
if __name__=='__main__':
    solve()
# Judge status: Accepted
n=int(input())
A=list(map(int,input().split()))

B=[0 for i in range(n)]
B[n//2:]=A[n//2:]

for i in range(n//2,0,-1):
    B[i-1]= (sum(B[i*2-1::i])%2 != A[i-1])

print(sum(B))
for i,j in enumerate(B):
    if j==1:
        print(i+1)
# Judge status: Accepted
x,y=map(int,input().split())
r=0
for i in range(0,x+1):
    c=i
    t=x-c
    if c*2+t*4==y:
        r=r+1
if r!=0:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import sys
input = sys.stdin.readline
sys.setrecursionlimit(200000)
import numpy as np


def read():
    x = np.fromstring(input().strip(), dtype=np.int32, sep=" ")
    return x,


def solve(x):
    return np.argmin(x) + 1


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))
# Judge status: Wrong Answer
def main():
    A, B, T = map(int, input().split(" "))
    result = 0
    if T > A:
        while T > 0:
            result += B
            T //= A
    print(result)


if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())
nn = []
mm = []
ll = []
ans = 0
for i in range(N):
  k = input()
  nn.append(k)
  ll.append(k)
M = int(input())
l_s = set(ll)
for i in range(M):
  k = input()
  mm.append(k)
for i in l_s:
  count = 0
  for j in nn:
    if i == j:
      count += 1
  for j in mm:
    if i == j:
      count -= 1
  if count > ans:
    ans = count
print(ans)
# Judge status: Accepted
X = int(input())
flag = 0
for A in range(-300,301):
    for B in range(-300,301):
        if A**5 - B**5 == X:
            print(A,B)
            flag = 1
        if flag==1:
            break
    if flag==1:
        break
# Judge status: Accepted
# -*- coding: utf-8 -*-

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

if a > b:
    a,b = b,a

print(max(b-(a+w), 0))
# Judge status: Wrong Answer
n = int(input())
b = [int(i) for i in input().split()]
prev = b[0]
cnt = 0
for i in b:
    if i >= prev:
        cnt += prev
        prev = i
    else:
        cnt += i
        prev = i
cnt += max(b[0], b[-1])
print(cnt)
# Judge status: Accepted
S=input()
T=input()
n=len(S)
s,t=[],[]
for i in range(n):
  s.append(S[i])
  t.append(T[i])
for i in range(n):
  p=s[0]
  for j in range(1,n):
    s[j-1]=s[j]
  s[n-1]=p
  if s==t:
    print('Yes')
    exit()
print('No')
# Judge status: Accepted
s1 = input()
s2 = input()

if s1 == s2[::-1]:
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
N = int(input())
S = [int(input()) for _ in range(N)]

S.sort()
ans = sum(S)
if ans%10 != 0:
    print(ans)
    exit()
for x in S:
    ans -= x
    if ans%10 != 0:
        print(ans)
        exit()
print(ans)
# Judge status: Accepted
import bisect

N, K = map(int, input().split())
Xs = list(map(int, input().split()))

rlt = float('inf')
i = bisect.bisect_left(Xs, 0)
if i-K >= 0:
  rlt = abs(Xs[i-K])

for j in range(i, i+K-1):
  if j >= N:
    break
  if j - K + 1 < 0:
    continue
  rlt = min(rlt, 2*abs(Xs[j-K+1])+Xs[j], abs(Xs[j-K+1])+2*Xs[j])
  
if i + K - 1 < N:
  rlt = min(rlt, Xs[i+K-1])
  
print(rlt)
# Judge status: Wrong Answer
n=int(input())
ans=1
for i in range(1,n+1):
  ans=ans*i
print(ans%1000000007)
# Judge status: Accepted
n,k=list(map(int,input().split(" ")))
l=list(map(int,input().split(" ")))
f=[0]*n
f[1]=abs(l[1]-l[0])

for i in range(2,n):

	x1=f[i-1]+abs(l[i-1]-l[i])
	z=min(k,i)
	for j in range(z):
		# print(i,i-j-1)
		x1=min(x1,(f[i-j-1]+abs(l[i]-l[i-j-1])))

	# x2=f[i-2]+abs(l[i-2]-l[i])
	f[i]=x1
print(f[-1])
# Judge status: Accepted
from math import sqrt
from collections import defaultdict

N = int(input())

f = defaultdict(int)
for p in [2] + list(range(3, int(sqrt(N)) + 1, 2)):
    while N % p == 0:
        N //= p
        f[p] += 1
    if N == 1:
        break
if N != 1:
    f[N] += 1

ans = 0
for e in f.values():
    ans += int((sqrt(1 + 8 * e) - 1) / 2)
print(ans)
# Judge status: Accepted
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,*A = map(int, read().split())

    if 0 in A:
        print(0)
        exit()

    INF = 10**18
    ans = 1
    for a in A:
        ans *= a
        if ans > INF:
            print(-1)
            exit()
    
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
import math
N = int(input())
N_ori = N
cnt = 0
for p in range(2,int(math.sqrt(N_ori))+10):
    waru = p
    while(N%waru==0):
        N //= waru
        cnt += 1
        waru *= p

if(N == N_ori and N != 1):
    cnt += 1
print(cnt)
# Judge status: Accepted
x, y = map(int, input().split())
ans = 0
while x <= y:
  x *= 2
  ans += 1
print(ans)
# Judge status: Accepted
N, K = (int(i) for i in input().split())

flag = [True]*N
for k in range(K):
  tmp = input()
  for i in list(map(int,input().split())):
        flag[i-1] = False
 
print(sum(1 for x in flag if x==True))
# Judge status: Accepted
n,k=map(int,input().split())
B=[0]*n
for _ in range(k):
    d=int(input())
    a=list(map(int,input().split()))
    for i in range(d):
        B[a[i]-1]+=1
print(B.count(0))
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
ans=10**20
p=sum(a)
q=0
for i in range(n-1):
	q+=a[i]
	ans=min(ans,abs(p-q-q))
print(ans)