Harryxun/stf_run huggingface dataset:
import sys
input=sys.stdin.readline
s=input()
n=len(s)
s=s[::-1]
accum=[0]*n
p=2019
d=dict()
for i in range(n):
    accum[i]=int(s[i])*pow(10,i,p)%p
for i in range(n-1):
    accum[i+1]+=accum[i]
    accum[i+1]%=p
accum[-1]%=p
ans=0
#print(accum)
for i in range(n):
    #print(d)
    if accum[i] not in d:
        if accum[i]==0:
            ans+=1
        d[accum[i]]=1
    else:
        if accum[i]==0:
            ans+=1
        ans+=d[accum[i]]
        d[accum[i]]+=1
print(ans)

### FIXED CODE ###

s=input()
n=len(s)
s=s[::-1]
accum=[0]*n
p=2019
d=dict()
for i in range(n):
    accum[i]=int(s[i])*pow(10,i,p)%p
for i in range(n-1):
    accum[i+1]+=accum[i]
    accum[i+1]%=p
accum[-1]%=p
ans=0
#print(accum)
for i in range(n):
    #print(d)
    if accum[i] not in d:
        if accum[i]==0:
            ans+=1
        d[accum[i]]=1
    else:
        if accum[i]==0:
            ans+=1
        ans+=d[accum[i]]
        d[accum[i]]+=1
print(ans)
import sys

number = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
answer = 0

for i in range(number):
    answer += b[a[i]-1]
    
    if i != 0:
        if a[i-1] == a[i]-1:
            answer += c[a[i-1]-1]

print(answer)
            


### FIXED CODE ###

import sys

a = input()
l = True

for i in range(len(a)):
    if i % 2 == 1:
        if a[i] == 'R':
            l = False

    if i % 2 == 0:
        if a[i] == 'L':
            l = False

if l:
    print('Yes')
else:
    print('No')
InputData=[]
while True:
	H,W = map(int,raw_input().split())      # Python3
	if W==0 and H==0 : break
	if (H-3)*(H-100)> 0 : continue
	if (W-3)*(W-100)> 0 : continue
	InputData.append([H,W])
	


for i in range(len(InputData)):
	H,W = InputData[i]
	print("#" * W)
	print(("#"+"#"*(W-2)+"#"+"\n")*(H-2),end="")    # Python3
	print("#" * W)
	print("")

### FIXED CODE ###

a = []
while True:
    l = list(map(int,input().split()))
    if l == [0,0]:
        break
    a.append(l)


for i in range(len(a)):
	H,W = a[i]
	for i in range(H):
		print("#"*W)
	print("")
n = int(input())
T = []
for i in range(n):
    T.append(int(input()))

# def gcd(a, b):
#     if b==0:
#         return(a)
#     return(gcd(b, a%b))
def gcd(a, b):
    while b > 0:
        t = a
        a = b
        b = t%b
    return(a)

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

LCM = T[0]
for i in range(n-1):
    LCM = lcm(LCM, T[i+1])

print(int(LCM))


### FIXED CODE ###

n = int(input())
T = []
for i in range(n):
    T.append(int(input()))

T = sorted(T)
def gcd(a, b):
    while b > 0:
        t = a
        a = b
        b = t%b
    return(a)

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

LCM = T[0]
for i in range(n-1):
    LCM = lcm(LCM, T[i+1])

print(LCM)
input()
nums = [ int(i) for i in input().split()]
??
print( min(nums), max(nums), sum(nums))

### FIXED CODE ###

input()
nums = [ int(i) for i in input().split()]
print( min(nums), max(nums), sum(nums))
from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix
from sys import stdin


def makeConnected(n, connections):
    l = list(zip(*connections))
    d = [1] * len(connections)
    a = csr_matrix((d, (l[0], l[1])), (n, n))
    return connected_components(a, return_labels=0)


def main():
    input = lambda: stdin.readline()[:-1]
    N, M = map(int, input().split())
    AB = [tuple(map(int, input().split())) for _ in [0] * M]

    ans = makeConnected(N, AB) - 1
    print(ans)


main()


### FIXED CODE ###

from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix
from sys import stdin


def makeConnected(n, connections):
    l = list(zip(*connections))
    d = [1] * len(connections)
    a = csr_matrix((d, (l[0], l[1])), (n, n))
    return connected_components(a, return_labels=0)


def main():
    input = lambda: stdin.readline()[:-1]
    N, M = map(int, input().split())
    AB = [tuple(map(int, input().split())) for _ in [0] * M]

    ab = [[a - 1, b - 1] for a, b in AB]
    ans = makeConnected(N, ab) - 1
    print(ans)


main()
number = input(int())
print(number**3)


### FIXED CODE ###

number = int(input())
print(number**3)
n,x = map(int.input().split())
l = list(map(int,input().split()))
sum = 0
ans = 0
for i in l:
  sum += i
  if sum <= x:
    ans += 1
    
  

### FIXED CODE ###

n,x = map(int,input().split())
l = list(map(int,input().split()))
sum = 0
ans = 0
for i in l:
  sum += i
  if sum <= x:
    ans += 1
print(ans+1)
s = input()
k = 'keyence'
i = 0
inds = []
ans = 'NO'
for a,x in enumerate(s):
    if x==k[i]:
        i+=1
        inds.append(a)
    if i==6:
        c = 0
        for z in range(i-1):
            if inds[z+1]-inds[z]>1:
                c+=1
        if c<=1:ans='YES'
print(ans)

### FIXED CODE ###

s = input()
ans = 'NO'
for i in range(len(s)):
    for j in range(i,len(s)+1):
        if s[:i]+s[j:]=='keyence':
            ans = 'YES'
print(ans)
# スペース区切りの整数の入力
p,q,r=map(int, input().split())

# 出力
Print(p+q+r-max(p, q, r))

### FIXED CODE ###

p,q,r=map(int,input().split())
print(p+q+r-max(p,q,r))
_l=input().split()
_s=sum([int(i) for i in _l])
if _s % 2 != 0:
  print('IMPOSSIBLE')
else:
  print(s/2)

### FIXED CODE ###

_l = input().split()
_s = sum([int(i) for i in _l])
if _s % 2 != 0:
    print('IMPOSSIBLE')
else:
    print(int(_s / 2))
n = int(input())
a = map(int, input().split())
while True:
  for i in range(n):
    if a[i] % 2 == 1:
      break
    a[i] //= 2
  else:
    ans += 1
    continue
  break
print(ans)

### FIXED CODE ###

n = int(input())
print(min(bin(int(i))[::-1].find("1") for i in input().split()))
n = int(input())
a = list(map(int,input().split()))
ma = []
pa = []
l =[]
t = 0
for i in a:
  if i < 0:
    ma.append(i)
    l.append(i*-1)
  elif i> 0:
    pa.append(i)
    l.append(i)
  else:
    t = 1
pa.sort()
ma.sort()
s = sum(l)
for i in [pa,ma]:
  if len(i)==0:i.append(0)
print(s  if t == 1 or len(b)%2==0 else s - 2*min(l))

### FIXED CODE ###

s= 0
A,B,T=map(int,input().split())
for i in range(T//A):
  s+=B
print(s)
N=int(input())
P=list(map(int,input().split()))

D=sorted(D)
K=D[N//2]-D[N//2-1]
print(K)

### FIXED CODE ###

N=int(input())
D=list(map(int,input().split()))
 
D=sorted(D)
K=D[N//2]-D[N//2-1]
print(K)
N, A, B = map(int, input().split())
C = input()
D = [C[i:i+1] for i in range(N)]
AA = 0
BB = 0
for i in(D):
  if D[i] == 'c':
    print('No')
  elif D[i] =='a' and A+B > AA+BB:
    print('Yes')
    AA += 1
  elif D[i] =='a' and A+B > AA+BB and BB < B:
    print('Yes')
    BB += 1
  else:
    print('No')

### FIXED CODE ###

N, A, B = map(int, input().split())
C = input()
D = [C[i:i+1] for i in range(N)]
AA = 0
BB = 0
for i in(D):
  if i == 'c':
    print('No')
  elif i =='a' and A+B > AA+BB:
    print('Yes')
    AA += 1
  elif i =='b' and A+B > AA+BB and BB < B:
    print('Yes')
    BB += 1
  else:
    print('No')
dp=[.0]*100001
dp[1]=1.
for i in range(2,100001):
    a,b,j=.5,1,1
    while j<i and b> 1e-5:
        dp[i]+=b*(1-a)*(j+dp[i-j-1])
        b*=al;a/=2;j+=1
    dp[i]+=i*b
while 1:
    n=int(input())
    if n==0:break
    print(dp[n])

### FIXED CODE ###

dp=[.0]*100001
dp[1]=1.
for i in range(2,100001):
    a,b,j=.5,1,1
    while j<i and b>1e-15:
        dp[i]+=b*(1-a)*(j+dp[i-j-1])
        b*=a;a/=2;j+=1
    dp[i]+=i*b
while 1:
    n=int(input())
    if n==0:break
    print(dp[n])
import math
time_list=[]

for _ in range(5):
    time_list.append(int(input()))
# print(1, time_list)

time_list2=[]
for x in time_list:
    m = x % 10
    time_list2.append(x+(10-m))
# print("2", time_list2)
# print(round(102,-1))

mod_list = []
for x in time_list:
    m = x % 10
    if m!=0:
        mod_list.append(10-m)
min_ = max(mod_list)
# print(mod_list)



print(sum(time_list2)-min_)

### FIXED CODE ###

import math
time_list=[]

for _ in range(5):
    time_list.append(int(input()))
# print(1, time_list)

time_list2=[]
for x in time_list:
    m = x % 10
    if m!=0:
        time_list2.append(x+(10-m))
    else:
        time_list2.append(x)
# print("2", time_list2)

mod_list = []
for x in time_list:
    m = x % 10
    if m!=0:
        mod_list.append(m)
    else:
        mod_list.append(10)
min_ = min(mod_list)
# print(mod_list)



print(sum(time_list2)-(10-min_))
n, a, b = map(int, input().split())
count = 0
for i in range(n+1):
	ans = i % 10
	while (i // 10) != 0:
        ans += (i // 10)
		i = (i // 10)
	if ans >= a and ans <= b:
		count += 1
print(count)



### FIXED CODE ###

n, a, b = map(int, input().split())
ans = 0
for i in range(n+1):
    if a <= sum(list(map(int, list(str(i))))) <= b:
        ans += i
print(ans)
a = input()
sig = str(a[-1])

if (sig=="2" or sig=="4" or sig== "5" or sig =="7" or sig=="9"):
  print("hon")
else:
  if (sig=="3"):
    print("pon")
   else:
    print("bon")

### FIXED CODE ###

a = input()
target = a[-1]

hon = [2,4,5,7,9]
pon = [0,1,6,8]
bon = [3]

if int(target) in hon:
    print("hon")
else:
    if int(target) in pon:
        print("pon")
    else:
        print("bon")
N=int(input())
Nk=N
rootN=int(N**0.5)
p=[1]*(rootN+1)
p[0]=0
p[1]=0
for i in range(2,rootN+1):
    for j in range(i*2,rootN,i):
        p[j]=0
ps=[i for i in range(1,rootN+1) if p[i]==1]
pq=[]
for i in ps:
    d=i
    c=0
    for j in range(1,10):
        if (N/i).is_integer():
            c+=1
            N/=(i)
        else:
            break
        d*=i
    if c!=0:
        pq.append(c)

res=0
for j in pq:
    res+=int(((8*j+1)**0.5-1)/2)


if N > rootN:
    res+=1
if N==Nk:
    res+=1
    
print(res)

### FIXED CODE ###

a,b=map(int,input().split())
print(a*b)
def log_2(n):
    t = 0
    while n:
        if n % 2 == 1:
            break
        t += 1
        n //= 2
    return t


def solve(A, B, C)->int:

    s = A+B+C
    odd = log_2(s-C)
    even = log_2(s+A)

    if odd == even:
        return odd
    else:
        return odd+1


A, B, C = map(int, input().split())
A, B, C = sort([A, B, C])

ans = 0
if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
    ans = 0
elif A == B == C:
    ans = -1
else:
    ans = solve(A, B, C)
print(ans)


### FIXED CODE ###

def log_2(n):
    t = 0
    while n:
        if n % 2 == 1:
            break
        t += 1
        n //= 2
    return t


def solve(A, B, C)->int:

    s = A+B+C
    odd = min(log_2(s-A), log_2(s-B), log_2(s-C))
    even = min(log_2(s+A), log_2(s+B), log_2(s+C))

    if odd == even:
        return odd
    else:
        return odd+1


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

ans = 0
if A % 2 == 1 or A % 2 == 1 or A % 2 == 1:
    ans = 0
elif A == B == C:
    ans = -1
else:
    ans = solve(A, B, C)
print(ans)
n=int(input())
x=list(map(lambda x:int(x), input().split()))
mi = n/2
sx=sorted(x)
for item in x:
    if item > sx[mi]:
	print(sx[mi])
    else:
	print(sx[mi+1])


### FIXED CODE ###

n=int(input())
x=list(map(lambda x:int(x), input().split()))
mi = n//2 - 1
sx=sorted(x)
for item in x:
    if item > sx[mi]:
        print(sx[mi])
    else:
        print(sx[mi+1])
n, k = int(input()).split()
print(n%k - 1)

### FIXED CODE ###

n, k = map(int, input().split())
if n % k == 0:
    print(0)
else:
    print(1)
N=int(input())
T=[int(i) for i in input().split()]
A=[int(i) for i in input().split()]
ans=1
mod=10**9+7
for i in range(N):
  if i==0:
    if A[i]!=A[i+1] and T[i]!=A[i]:
      print(0)
      exit()
  elif i==N-1:
    if T[i]!=T[i-1] and T[i]!=A[i]:
      print(0)
      exit()
  else:
    if T[i]==T[i-1] and A[i]==A[i+1]:
      ans=(ans*min(T[i],A[i]))%mod
    elif T[i]!=T[i-1] and A[i]<T[i]:
      print(0)
      exit()
    elif A[i]!=A[i+1] and A[i]>T[i]:
      print(0)
      exit()
print(ans)
    
      

### FIXED CODE ###

N=int(input())
T=[int(i) for i in input().split()]
A=[int(i) for i in input().split()]
if N==1:
  if A[0]==T[0]:
    print(1)
  else:
    print(0)
  exit()
  
ans=1
mod=10**9+7
for i in range(N):
  if i==0:
    if A[i]!=A[i+1] and T[i]!=A[i]:
      print(0)
      exit()
  elif i==N-1:
    if T[i]!=T[i-1] and T[i]!=A[i]:
      print(0)
      exit()
  else:
    if T[i]==T[i-1] and A[i]==A[i+1]:
      ans=(ans*min(T[i],A[i]))%mod
    elif T[i]!=T[i-1] and A[i]<T[i]:
      print(0)
      exit()
    elif A[i]!=A[i+1] and A[i]>T[i]:
      print(0)
      exit()
print(ans)
s = input()
t = input()
for i in range(len(s)):
  if s[i] == t[i]:
  else:
    s = s.translate(str.maketrans(s[i]+t[i],t[i]+s[i]))

if s == t:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

s = input()
t = input()
used_str = []
for i in range(len(s)):
  if s[i] != t[i] and not s[i] in used_str and not t[i] in used_str:
    s = s.translate(str.maketrans(s[i]+t[i],t[i]+s[i]))
    used_str.append(s[i])
    used_str.append(t[i])

if s == t:
  print("Yes")
else:
  print("No")
from math import factorial
 
s = int(input())
 
ans = 0
for i in range(s // 3):
    box = i + 1  # 箱の数
    ball = s - 3 * box # あらかじめ箱に３こずつ入れたあとの残りの玉の数
 
　　# 箱の入れ方が何通りあるか計算。
    # 割り算を // ではなく / とするとfloat型の計算となりオーバーフローする可能性がある。
    # factorial(s_ + i) // (factorial(s_) * factorial(i))ではなくfactorial(s_ + i) // (factorial(s_) // factorial(i))としても同様にオーバーフローする可能性がある。
    ans += factorial(ball + box - 1) // (factorial(ball) * factorial(box - 1)) % (10**9 + 7)
 
print(ans % (10 ** 9 + 7))

### FIXED CODE ###

s = int(input())

x = s // 3

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

ans = 0
for i in range(x):
    Box = i + 1
    Nokori = s - 3 * Box
    ans_ = cmb(Nokori + Box - 1, Box - 1) 
    ans += ans_
print(ans % (10 ** 9 + 7))
from collections import defaultdict


def longest_path(n, edges):
    adj_list = defaultdict(list)
    for x, y in edges:  # x -> y
        adj_list[y].append(x)

    distances = [None] * n

    def dfs(x):
        if distances[x] is None:
            if adj_list[x]:
                for y in adj_list[x]:
                    dfs(y)
                distances[x] = max((distances[y] + 1 for y in adj_list[x]))
            else:
                distances[x] = 0

    for x in range(n):
        dfs(x)

    return max(distances)


def main():
    n, m = [int(x) for x in input().split()]
    edges = [None] * m
    for i in range(m):
        edges[i] = [int(x) - 1 for x in input().split()]

    return longest_path(n, edges)


print(main())


### FIXED CODE ###

from collections import defaultdict, deque


def longest_path(n, edges):
    adj_list = defaultdict(list)
    for x, y in edges:  # x -> y
        adj_list[y].append(x)

    state = [0] * n
    distances = [0] * n
    stack = deque(range(n))

    while stack:
        x = stack.pop()
        if state[x] == 0:
            state[x] = 1
            stack.append(x)
            stack.extend(adj_list[x])
        elif state[x] == 1:
            state[x] = 2
            if adj_list[x]:
                distances[x] = max(distances[y] for y in adj_list[x]) + 1

    return max(distances)


def main():
    n, m = [int(x) for x in input().split()]
    edges = [None] * m
    for i in range(m):
        edges[i] = [int(x) - 1 for x in input().split()]

    return longest_path(n, edges)


print(main())
n = int(input())
a = [int(input()) for l in range(n)]
flag = True
ans = 0
i = a[0]
while flag:
  i = a[i-1]
  ans += 1
  if i == 2:
    print(ans+1)
    flag = False
  else:
    count += 1
    if count >= n:
      print(-1)
      flag = False
    
    

### FIXED CODE ###

n = int(input())
a = [int(input()) for l in range(n)]
count = 0
for i in range(n):
  if a[count] == 2:
    print(i+1)
    exit()
  else:
    count = a[count]-1
print(-1)
H,W,D=map(int,input().split())
data=[]
for i in range(1,H+1):
    tmp=list(map(int,input().split()))
    for j in range(1,W+1):
        data.append([i,j,tmp[j-1]])

data.sort(key=lambda x:x[2])

ruiseki=[]
for i in range(D):
    tmp=[0]
    j=i+D
    while(j<H*W):
        tmp.append( abs(data[j][0]-data[j-D][0]) +abs(data[j][1]-data[j-D][1]) +tmp[-1])
        j+=D
    ruiseki.append(tmp)

Q=int(input())
for _ in range(Q):
    l,r=map(int,input().split())
    ind=l%D-1
    print(ruiseki[ind][r//D] - ruiseki[ind][l//D])

### FIXED CODE ###

H,W,D=map(int,input().split())
data=[]
for i in range(1,H+1):
    tmp=list(map(int,input().split()))
    for j in range(1,W+1):
        data.append([i,j,tmp[j-1]])

data.sort(key=lambda x:x[2])

ruiseki=[]
for i in range(D):
    tmp=[0]
    j=i+D
    while(j<H*W):
        tmp.append( abs(data[j][0]-data[j-D][0]) +abs(data[j][1]-data[j-D][1]) +tmp[-1])
        j+=D
    ruiseki.append(tmp)

Q=int(input())
for _ in range(Q):
    l,r=map(int,input().split())
    ind=l%D-1
    if(ind==-1):
        l-=D
        r-=D
    print(ruiseki[ind][r//D] - ruiseki[ind][l//D])
n, m = map(int,input().split())
li = list(map(int, input().split()))

res = n - li.sum()
if res >= 0:
	print(res)
else:
    print(-1)

### FIXED CODE ###

n, m = map(int,input().split())
li = list(map(int, input().split()))
 
res = n - sum(li)
if res >= 0:
	print(res)
else:
    print(-1)
a=1
while 1:
    x=int(raw_input())
    if x==0:
        break
    print "Case %d: %d" % (a,x)
    cnt+=1;

### FIXED CODE ###

a=1
while 1:
    x=int(raw_input())
    if x==0:
        break
    print "Case %d: %d" % (a,x)
    a+=1;
ABCD=input()
ABCD=ABCD.split()
A=int(ABCD[0])
B=int(ABCD[1])
C=int(ABCD[2])
D=int(ABCD[3])
while(1):
    C=C-B
    if(C<=0):
        print('Yes')
        break
    A=A-D
    if(A<=0):
        print('No')
        break

### FIXED CODE ###

SW=input()
SW=SW.split()
if(int(SW[1])>=int(SW[0])):
    print('unsafe')
else:
    print('safe')
s = raw_input()
aId = s.index("a")
s = s[::-1]
zId = s.index("z")
print len(s) - aId - zId

### FIXED CODE ###

s = raw_input()
aId = s.index("A")
s = s[::-1]
zId = s.index("Z")
print len(s) - aId - zId
N, M = map(int, input().split())
edge = [[] for _ in range(N)]
for i in range(M):
    a,b = map(int, input().split())
    edge[a-1].append(b-1)

def dp(v,dpv,e):
    if dpv[v] != -1:
        return dpv[v]
    if len(e[v])==0:
        dpv[v]=0
        return 0
    res = 0
    for w in e[v]:
        res = max(dp(w,dpv,e),res)
    res += 1
    dpv[v] = res
    return res

def solve(edge):
    dpv = [-1]*N
    for i in range(N):
        dp(i,dpv,edge)
    ans = max(dpv)
    print(dpv)
    return ans
print(solve(edge))

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)
N, M = map(int, input().split())
edge = [[] for _ in range(N)]
for i in range(M):
    a,b = map(int, input().split())
    edge[a-1].append(b-1)

def dp(v,dpv,e):
    if dpv[v] != -1:
        return dpv[v]
    if len(e[v])==0:
        dpv[v]=0
        return 0
    res = 0
    for w in e[v]:
        res = max(dp(w,dpv,e),res)
    res += 1
    dpv[v] = res
    return res

def solve(edge):
    dpv = [-1]*N
    for i in range(N):
        dp(i,dpv,edge)
    ans = max(dpv)
    # print(dpv)
    return ans
print(solve(edge))
N, M = map(int, input().split())  #数字
H = list(map(int, input().split()))#リスト
A = [list(map(int, input().split())) for i in range(M)]  #数字、複数行複数列

good = []
bad = []
for i in range(M):
    left = H[A[i][0] - 1]
    right = H[A[i][1] - 1]
    if left < right:
        good.append(A[i][1])
        bad.append(A[i][0])
    if left > right:
        good.append(A[i][0])
        bad.append(A[i][1])
    if left == right:
        bad.append(A[i][0])
        bad.append(A[i][1])

#print(set(good))
#print(set(bad))

lonely = H - set(good) - set(bad)

#print(len(lonely))
#print(len(good))
print(len(set(good))+ len(lonely))

### FIXED CODE ###

N, M = map(int, input().split())  #数字
H = list(map(int, input().split()))#リスト
A = [list(map(int, input().split())) for i in range(M)]  #数字、複数行複数列

good = [True]*N
for i, j in A:
    i -= 1
    j -= 1
    if H[i] < H[j]:
        good[i] = False
    if H[i] > H[j]:
        good[j] = False
    if H[i] == H[j]:
        good[i] = False
        good[j] = False

print(good.count(True))
a,b,c,d = map(int,input().split())
import math
def num_of_complements(x,c,d):
    lcm = c * d // math.gcd(c, d)
    num = x + x//lcm - x//c - x//d
    return num

ans = num_of_complements(b,c,d) - num_of_complements(a-1,c,d)
print(ans)



### FIXED CODE ###

a,b,c,d = map(int,input().split())
from fractions import gcd
lcm = c * d // gcd(c, d)
def num_of_complements(x,c,d,lcm):
    num = x + x//lcm - x//c - x//d
    return num

ans = num_of_complements(b,c,d,lcm) - num_of_complements(a-1,c,d,lcm)
print(ans)
import math
a,b,c,d=list(map(int, input().split()))
lcm=int(c*d/math.gcd(c,d))
could_divide=(b//c-(a-1)//c) + (b//d-(a-1)//d) - (b//lcm-(a-1)//lcm)
#print("could divide by "+str(c)+" : "+str(b//c-(a-1)//c))
#print("could divide by "+str(d)+" : "+str(b//d-(a-1)//d))
print(b-a+1-could_divide)

### FIXED CODE ###

import fractions
a,b,c,d=list(map(int, input().split()))
lcm=int(c*d/fractions.gcd(c,d))
could_divide=(b//c-(a-1)//c) + (b//d-(a-1)//d) - (b//lcm-(a-1)//lcm)
#print("could divide by "+str(c)+" : "+str(b//c-(a-1)//c))
#print("could divide by "+str(d)+" : "+str(b//d-(a-1)//d))
print(b-a+1-could_divide)
while (n == x != 0) :
    n, x = map(int, input().split())
    if (n == x == 0) :
        break
    count = 0
    for a in range (1, n) :
        for b in range (2, n) :
            for c in range (3, n) :
                Sum = a + b + c
                if (Sum == x) :
                    count += 1
    print(count)

### FIXED CODE ###

while True:
    n, x = map(int, input().split())
    if (n == x == 0):
        break

    count = 0
    for a in range(1, x // 3):
        for b in range(a + 1, x // 2):
            for c in range(b + 1, n + 1):
                Sum = a + b + c
                if (Sum == x):
                    count += 1 
    print(count)
N=int(input())
a=list(map(int, input().split()))
b=a
c=1
if c<=N:
	d=a[c-1]
	b[d-1]='c'
	c+=1
''.join(b)


### FIXED CODE ###

N=int(input())
if N%2==0:
	print(1/2)
else:
	print((N+1)/2/N)
N = int(ipnut())

print(3 // N)

### FIXED CODE ###

N = int(input())

print(N // 3)
n = input()

S = [int(x) for x in raw_input().split]

q = input()

T = [int(x) for x in raw_input().split]

C = 0

for i in S:
 for j in T:
  if i==j:
   C += 1

print C

### FIXED CODE ###

n = input()

S = [int(x) for x in raw_input().split()]

q = input()

T = [int(x) for x in raw_input().split()]

C = 0

for i in T:
 for j in S:
  if i==j:
   C += 1
   break

print C
import sys
m,d = int(input().split())
if m in ('1','3','5','7','8','10','12'):
  if d == '31':
    print('1')
elif m == '2':
  if d == '28':
    print('1')
else:
  print('0')


### FIXED CODE ###

import sys
m,d = input().split()
if m in ('1','3','5','7','8','10','12'):
  if d == '31':
    print('1')
  else:
    print('0')
elif m == '2':
  if d == '28':
    print('1')
  else:
    print('0')
else:
  if d == '30':
    print('1')
  else:
    print('0')
times = int(input())
prices = []

for i in range(times):
  prices.append(int(input())

max_price = max(prices)
prices.delete(max_prices)
prices.append(max_price/2)

print(sum(prices))
  

### FIXED CODE ###

N = int(input())
prices = []
for i in range(N):
    prices.append(int(input()))
max_price = max(prices)
prices.remove(max_price)
print(int(sum(prices)+(max_price/2)))