Harryxun/stf_run huggingface dataset:
def main():
    n =int(input())
    al = list(map(int,input().split()))

    res = 0
    bits = [[0]*2 for _ in range(60)]
    for a in al:
        i = 0
        while a > 0:
            bits[i][a&1] += 1
            a = a >> 1
            d += 1

    res = 0

    for i in range(60):
        res += bits[i][0] * bits[i][1]  * (2 ** i)

    print(res % (10 ** 9 + 7))

if __name__ == "__main__":
    main()

### FIXED CODE ###


n = int(input())
al = list(map(int,input().split()))

res = 0
bits = [0]*60
for a in al:
    i = 0
    b = a
    while b:
        bits[i] += b&1
        b = b >> 1
        i += 1

res = 0

for j in range(60):
    res += bits[j] * (n - bits[j])  * (2 ** j)

print(res % (10 ** 9 + 7))
num_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(num_list[input()])

### FIXED CODE ###

num_list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input()) - 1
print(num_list[K])
N,M = map(int,input().split())

line = [[] for _ in range(M)]
for _ in range(M):
    a,b = map(int,input().split())
    line[a-1].append(b-1)
    line[b-1].append(a-1)

check = [False] * N

def dfs(now):
    global cnt
    global ans
    if cnt == N:
        ans += 1
    else:
        for i in line[now]:
            if check[i] == False:
                check[i] = True
                cnt += 1
                dfs(i)
                check[i] = False
                cnt -= 1

check[0] = True
cnt = 1
ans = 0
dfs(0)
print(ans)

### FIXED CODE ###

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

line = [[] for _ in range(N)]
for _ in range(M):
    a,b = map(int,input().split())
    line[a-1].append(b-1)
    line[b-1].append(a-1)

check = [False] * N

def dfs(now):
    global cnt
    global ans
    if cnt == N:
        ans += 1
    else:
        for i in line[now]:
            if check[i] == False:
                check[i] = True
                cnt += 1
                dfs(i)
                check[i] = False
                cnt -= 1

check[0] = True
cnt = 1
ans = 0
dfs(0)
print(ans)
from collections import deque
N = int(input())
lis = []

A = []
B = []
for i in range(N):
    Ain,Bin = map(int,input().split())
    A.append(Ain)
    B.append(Bin)
    lis.append((Ain+Bin,i))
lis.sort()
lis.reverse()
lis = deque(taka)

takacnt = 0
aocnt = 0
st = set()

# print(taka)
# print(ao)

for i in range(N):
    if i % 2 == 0:
        while True:
            val = lis.popleft()
            if not val[1] in st:
                break
        st.add(val[1])
        takacnt += A[val[1]]
    else:
        while True:
            val = lis.popleft()
            if not val[1] in st:
                break
        st.add(val[1])
        aocnt += B[val[1]]
print(takacnt-aocnt)


### FIXED CODE ###

from collections import deque
N = int(input())
taka = []
ao = []
A = []
B = []
for i in range(N):
    Ain,Bin = map(int,input().split())
    A.append(Ain)
    B.append(Bin)
    taka.append((Bin+Ain,i))
    ao.append((Ain+Bin,i))
taka.sort()
taka.reverse()
ao.sort()
ao.reverse()
taka = deque(taka)
ao = deque(ao)
takacnt = 0
aocnt = 0
st = set()

# print(taka)
# print(ao)

for i in range(N):
    if i % 2 == 0:
        while True:
            val = taka.popleft()
            if not val[1] in st:
                break
        st.add(val[1])
        takacnt += A[val[1]]
    else:
        while True:
            val = ao.popleft()
            if not val[1] in st:
                break
        st.add(val[1])
        aocnt += B[val[1]]
print(takacnt-aocnt)
X, Y = map(int, input().split())
if X <= 3 and Y <= 3:
    ans = (4-X) * 100000 + (4-Y) * 100000
    if X == 1 and Y == 1:
        ans += 400000
elif X <= 3:
    ans = (4-X) * 100000
elif Y <= 3:
    ans = (4-Y) * 100000
    
print(ans)

### FIXED CODE ###

X, Y = map(int, input().split())
if X <= 3 and Y <= 3:
    ans = (4-X) * 100000 + (4-Y) * 100000
    if X == 1 and Y == 1:
        ans += 400000
elif X <= 3:
    ans = (4-X) * 100000
elif Y <= 3:
    ans = (4-Y) * 100000
else:
    ans = 0
    
print(ans)
n = int(input())
s = input()

if n % 2 == 0 and s[:n / 2] == s[n / 2:]:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n = int(input())
s = input()

if n % 2 == 0 and s[:n // 2] == s[n // 2:]:
  print("Yes")
else:
  print("No")
def fact(i):
    a = 1
    for i in range(2,i+1):
        a *= i
    return a
def comb(i,j):
    return int(fact(i)/(fact(j)*fact(i-j)))

n = int(input())
l = list(map(int,input().split()))
l.sort()
a = []
b = []
d = []
for i in range(1,n):
    c = l[i]
    if l[0] >= int((c+1)/2):
        a.append(comb(c,l[0]))
        b.append(c)
        d.append(l[0])
    else:
        j = 1
        while l[j] < int((c+1)/2):
            j += 1
        else:
            if l[j] == int((c+1)/2):
                a.append(comb(c,int((c+1)/2)))
                b.append(c)
                d.append(int((c+1)/2))
            else:
                if l[j] - int((c+1)/2) < int((c+1)/2) -l[j-1]:
                    a.append(comb(c,l[j]))
                    b.append(c)
                    d.append(l[j])
                else:
                    a.append(comb(c,l[j-1]))
                    b.append(c)
                    d.append(l[j-1])
I = a.index(max(a))
print("{} {}".format(b[I],d[I]))


### FIXED CODE ###

n = int(input())
l = list(map(int,input().split()))
l.sort()
a = l[-1]
j = 0
while l[j] < int((a+1)/2):
    j += 1
else:
    if l[j] - int((a+1)/2) < int((a+1)/2) - l[j-1]:
        b = l[j]
    else:
        b = l[j-1]
print("{} {}".format(a,b))
N,K = map(int,input().split())
h_s = list(map(int,input().split()))
INF = 10000000000
dp = [INF]*N
dp[0] = 0
K = min(K,N-1)
for i in range(1,N):
    for j_j in range(min(K,i)):
        j = j_j + 1
        dp[i] = min((dp[i-j] + abs(h_s[i] - h_s[i-j])),dp[i])
print(dp)


### FIXED CODE ###

N = int(input())
h_s = list(map(int,input().split()))
INF = 10^3
dp = [INF]*N

dp[0] = 0
dp[1] = abs(h_s[1] - h_s[0]) + dp[0]
for i in range(2,len(h_s)):
    dp[i] = min((dp[i-1] + abs(h_s[i] - h_s[i-1])),(dp[i-2] + abs(h_s[i] - h_s[i-2])))
print(dp[N-1])
D T S = map(int, input().split(" "))

A = S * T
if A >= D:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

D, T, S = map(int, input().split(" "))

A = S * T
if A >= D:
    print("Yes")
else:
    print("No")
from collections import Counter

class UnionFind:
    def __init__(self, N: int) -> None:
        self.par = [i for i in range(N)]
    
    def root(self, x: int) -> bool:
        if self.par[x] == x: #親が自分自身なら頂点
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def unite(self, x: int, y: int) -> None:
        rx = self.root(x)
        ry = self.root(y)
        if rx == ry:
            return
        else:
            self.par[rx] = ry
    
    def same(self, x: int, y: int) -> bool:
        return self.root(x) == self.root(y)


def main():
    N, M = map(int, input().split())
    uf = UnionFind(N)
    for _ in range(M):
        a, b = map(int, input().split())
        uf.unite(a-1, b-1)
    
    g = Counter(uf.root(x) for x in range(N))
    ans = g.most_common(1)[0][1]
    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

from collections import Counter
import sys
sys.setrecursionlimit(10000000)

class UnionFind:
    def __init__(self, N: int) -> None:
        #自身が親なら、その集合に属する頂点数に-1をかけたもの
        #自身が親でないなら、自身の親
        self.par = [-1 for i in range(N)]
    
    def root(self, x: int) -> bool:
        if self.par[x] < 0: #親が自分自身なら頂点
            return x
        else:
            #経路圧縮してから返す
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def unite(self, x: int, y: int) -> None:
        rx = self.root(x)
        ry = self.root(y)
        if rx == ry:
            return
        else:
            if rx > ry:
                rx, ry = ry, rx
            self.par[rx] += self.par[ry]
            self.par[ry] = rx
    
    def same(self, x: int, y: int) -> bool:
        return self.root(x) == self.root(y)
    
    def size(self, x: int) -> int:
        root = self.root(x)
        return -self.par[root]


def main():
    N, M = map(int, input().split())
    uf = UnionFind(N)
    for _ in range(M):
        a, b = map(int, input().split())
        uf.unite(a-1, b-1)
    
    ans = 0
    for i in range(N):
        ans = max(ans, uf.size(i))
    print(ans)

if __name__ == '__main__':
    main()
n = int(input())
ans = 1
for i in range(0, n):
  b = int(input())
  ans *= b
if a > 10**18:
   print(-1)
else:
  print(ans)
  



### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))

if 0 in a:
  print(0)
  
else:
  ans = 1
  for val in a:
    ans *= val
    if ans > 10**18:
      print(-1)
      exit()
      
  print(ans)
h, w = map(int, input().split())
grid = []
for _ in range(h):
    grid.append(list(map(int, input().split())))
for i in range(h):
    l = list(map(int, input().split()))
    for j in range(w):
        grid[i][j] = grid[i][j] - l[j]

biggest = max([max(i) for i in grid])
m = (h + w) * biggest

unba = [[[0 for _ in range(2*m)] for _ in range(w)] for _ in range(h)]

# 0行目
unba[0][0][grid[0][0]] = 1
unba[0][0][-grid[0][0]] = 1
for i in range(1, w):
    for j in range(-m, m):
        if unba[0][i-1][j] == 1:
            unba[0][i][grid[0][i] + j] = 1
            unba[0][i][grid[0][i] - j] = 1

# 1~h-1行目
for i in range(1, h):

    # i行0列
    for j in range(-m, m):
        if unba[i-1][0][j] == 1:
            unba[i][0][grid[i][0] + j] = 1
            unba[i][0][grid[i][0] - j] = 1

    # i行j列
    for j in range(1, w):
        for k in range(-m, m):
            if unba[i-1][j][k] == 1 or unba[i][j-1][k]:
                unba[i][j][grid[i][j] + k] = 1
                unba[i][j][grid[i][j] - k] = 1

ans = [abs(i) for i in range(-m, m) if unba[h-1][w-1][i] == 1]
print(min(ans))

### FIXED CODE ###

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

    h, w = map(int, input().split())
    g = []
    for _ in range(h):
        g.append(list(map(int, input().split())))
    for i in range(h):
        k = list(map(int, input().split()))
        for j in range(w):
            g[i][j] = abs(g[i][j] - k[j])

    m = (h + w) * 80

    if m == 0:
        print(0)
        exit()

    dp = [[False] * m for _ in range(w)]
    dp[0][g[0][0]] = True
    for j in range(1, w):
        for k in range(m):
            if dp[j-1][k]:
                dp[j][abs(k - g[0][j])] = True
                dp[j][k + g[0][j]] = True
    
    for i in range(1, h):
        new_dp = [[False] * m for _ in range(w)]
        for k in range(m):
            if dp[0][k]:
                new_dp[0][abs(k - g[i][0])] = True
                new_dp[0][k + g[i][0]] = True
        
        for j in range(1, w):
            for k in range(m):
                if new_dp[j-1][k] or dp[j][k]:
                    new_dp[j][abs(k - g[i][j])] = True
                    new_dp[j][k + g[i][j]] = True
        dp = new_dp

    for j in range(m):
        if dp[w-1][j]:
            print(j)
            break

main()
import math
l, r = map(int, input().split())

flag = False
if l % 2019 == 0 or r // 2019 - l // 2019 != 0:
    flag = True

if flag:
    print(0)
else:
    lmod = l % 2019
    rmod = r % 2019
    root = math.sqrt(2019)

    n1, n2 = math.inf, math.inf
    p = lmod // 45
    q = rmod // 44
    for m in range(p, q+1):
        for i in range(lmod, rmod+1):
            if i - m * root > 0 and i - m * root < n1:
                tmp = n1
                n1 = i
                n2 = tmp
            elif i - m * root > 0 and i - m * root < n2:
                n2 = i

    print((n1 * n2) % 2019)

    # lmod = l % 2019
    # print((lmod * (lmod + 1)) % 2019)

### FIXED CODE ###

l, r = map(int, input().split())

flag = False
if l % 2019 == 0 or r // 2019 - l // 2019 != 0:
    flag = True

if flag:
    print(0)
else:
    lmod = l % 2019
    rmod = r % 2019

    ans = 10**5
    for i in range(lmod, rmod):
        for j in range(i+1, rmod+1):
            ans = min((i * j) % 2019, ans)
    print(ans)
def test():
  x=input()
  x=x.split()
  if x =['5','5','7']:
    print("YES")
  elif x =['5','7','5']:
    print("YES")
  elif x =['7','5','5']:
    print("YES")
  else:
    print("NO")

### FIXED CODE ###

def test():
  x=input()
  x=x.split()
  if x == ['5','5','7']:
    print("YES")
  elif x == ['5','7','5']:
    print("YES")
  elif x == ['7','5','5']:
    print("YES")
  else:
    print("NO")
    
test()
s=input()
t=input()
f=0
e=5
flg=0
while e<=len(s):
  tmp=s[f:e]
  for i in range(len(t)):
    if tmp[i]!=t[i] and tmp[i]!='?':
      break
    if i==len(t)-1:
      s=s[:f]+t+s[e:]
      flg=1
      print(s.replace('?','a'))
  f+=1
  e+=1
if flg==0:
  print('UNRESTORABLE')

### FIXED CODE ###

s=input()
t=input()
f=0
e=len(t)
flg=0
while e<=len(s):
  tmp=s[f:e]
  for i in range(len(t)):
    if tmp[i]!=t[i] and tmp[i]!='?':
      break
    if i==len(t)-1:
      ans=s[:f]+t+s[e:]
      flg=1
  f+=1
  e+=1
if flg==0:
  print('UNRESTORABLE')
else:
  print(ans.replace('?','a'))
from copy import deepcopy

def gcd(a, b):
	while b:
		a, b = b, a % b
	return(a)

def gcd_mul(numbers):
    s = gcd(numbers[0], numbers[1])
    for i in range(2, len(numbers)) :
        s = gcd(s, numbers[i])
    return(s)

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

ans = 0
A2 = deepcopy(A)
for i in range(N) :
    del A[i]
    g = gcd_mul(A)
    if g > ans :
        ans = g
    A = deepcopy(A2)
print(ans)

### FIXED CODE ###

import fractions # for python 3.4.3

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

gcd_l = [0]
gcd_r = [0]
for i in range(N):
    gcd_l.append(fractions.gcd(gcd_l[i], A[i]))
    gcd_r.append(fractions.gcd(gcd_r[i], A[-(i+1)]))
    #print(gcd_l)
    #print(gcd_r)
gcd_r = gcd_r[::-1]

ans = []
for i in range(N):
    ans.append(fractions.gcd(gcd_l[i], gcd_r[i+1]))

print(max(ans))
n, m = map(int, input().split())

s = []
for i in range(m):
    s.append(list(map(int, input().split())))

if n == 1:
    a = [str(i) for i in range(10)]
elif n == 2:
    a = [str(i) for i in range(10:100)]
elif n == 3:
    a = [str(i) for i in range(100:1000)]

ans = []

for i in a:
    b = True
    for j in s:
        if int(i[j[0]-1]) != j[1]:
            b = False
            break
    if b:
        ans.append(i)

if len(ans) == 0:
    print(-1)
else:
    print(min(ans))



### FIXED CODE ###

n, m = map(int, input().split())

s = []
for i in range(m):
    s.append(list(map(int, input().split())))

if n == 1:
    a = [str(i) for i in range(10)]
elif n == 2:
    a = [str(i) for i in range(10,100)]
elif n == 3:
    a = [str(i) for i in range(100,1000)]

ans = []

for i in a:
    b = True
    for j in s:
        if int(i[j[0]-1]) != j[1]:
            b = False
            break
    if b:
        ans.append(i)

if len(ans) == 0:
    print(-1)
else:
    print(min(ans))
a,b,c=map(int,input().split())
k=int(input())

print(sum(a,b,c)-max(a,b,c)+max(a,b,c)*(2**k))

### FIXED CODE ###

a=list(map(int,input().split()))
k=int(input())

print(sum(a)-max(a)+max(a)*(2**k))
N = int(input())
 
ans = -1
for i in range(N):
	if round(i*1.08) == N:
    	ans = i
      
if ans == -1:
  print(':(')
  
else:
  print(ans)

### FIXED CODE ###

import math

N = int(input())
ans = -1
for i in range(N+1):
	if math.floor(i*1.08) == N:
		ans = i
if ans == -1:
	print(':(')
else:
	print(ans)
N, M = map(int, input().split())
L, R = 1, N

import math

def merge_list(list):
    return (list[-1][0], min(map(lambda x: x[1], list)))

data = []
for i in range(0, M):
    l, r = input().split()
    data.append((int(l), int(r)))
data = sorted(data, key=lambda x: x[0])

def saiki(totyuu):
    mid = int(math.floor(len(totyuu)/2))
    if len(totyuu) < 10000000:
        m1 = merge_list(totyuu[:mid])
        m2 = merge_list(totyuu[mid:])
        return merge_list(totyuu)
    else:
        return merge_list([saiki(totyuu[:mid]), saiki(totyuu[mid:])])

data = saiki(data)

print(max(0, data[1]-data[0]+1))

### FIXED CODE ###

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

Ls = []
Rs = []
for i in range(0, M):
    l, r = input().split()
    Ls.append(int(l))
    Rs.append(int(r))

maxL = max(Ls)
minR = min(Rs)
result = max(0, minR-maxL+1)

print(result)
N,A,B=map(int,input().split())
List=""
while len(List) < N:
    List+="b"*A+"r"*B
if len(List) >= N:
  ans=List[:N]
  print(ans.count("b"))


### FIXED CODE ###

N,A,B=map(int,input().split())
print(N//(A+B)*A+min(A,N%(A+B)))
from heapq import heappush, heappop, heapify, heapreplace
from collections import defaultdict


class Solution:
    def main(self):
        N, M =map(int, input().split())
        self.memo = {}
        for _ in range(M):
            a = int(input())
            self.memo[a] = 0
        res = self.rec(N)
        print(res)

    def rec(self, n):
        if n < 0:
            return 0
        elif n == 0:
            return 1
        elif n in self.memo:
            return self.memo[n]
        else:
            val = (self.rec(n-1) + self.rec(n-2)) %1000000007
            self.memo[n] = val
            return val


if __name__ == '__main__':
    Solution().main()

### FIXED CODE ###

from heapq import heappush, heappop, heapify, heapreplace
from collections import defaultdict


class Solution:
    def main_old(self):
        N, M = map(int, input().split())
        self.memo = {}
        for _ in range(M):
            a = int(input())
            self.memo[a] = 0
        res = self.rec(N)
        print(res)

    def main(self):
        N, M = map(int, input().split())
        A = set()
        for _ in range(M):
            A.add(int(input()))
        dp = [0] * (N+1)
        dp[0] = 1
        for i in range(0, N+1):
            # print(dp)
            if i+1 <= N and i+1 not in A:
                dp[i+1] += dp[i]
                dp[i + 1] %= 1000000007
            if i+2 <= N and i+2 not in A:
                dp[i+2] += dp[i]
                dp[i + 2] %= 1000000007
        print(dp[N])

    def rec(self, n):
        if n < 0:
            return 0
        elif n == 0:
            return 1
        elif n in self.memo:
            return self.memo[n]
        else:
            val = (self.rec(n-1) + self.rec(n-2)) %1000000007
            self.memo[n] = val
            return val


if __name__ == '__main__':
    Solution().main()
input=(S)
if S[-1]!="s":
  	print(S+"s")
elif S[-1]=="s":
  	print(S+"es")

### FIXED CODE ###

S=input()
if S[-1]=="s":
  	print(S+"es")
else:
  	print(S+"s")
import bisect

def dfs(v,l,tr):
  ans[v]=l
  for u in g[v]:
    if checked[u]==0:
      checked[u]=1
      pos=bisect.bisect_left(tr,arr[u])
      if pos==l:
        dfs(u,l+1,tr+[arr[u]])
      elif tr[pos]==arr[u]:
        dfs(u,l,tr)
      else:
        dfs(u,l,tr[:pos]+[arr[u]]+tr[pos+1:])

n=int(input())
arr=[0]+list(map(int,input().split()))
g=[[] for _ in range(n+1)]
for _ in range(n-1):
  a,b=map(int,input().split())
  g[a].append(b)
  g[b].append(a)
ans=[0]*(n+1)
checked=[0]*(n+1)
checked[1]=1
dfs(1,1,[arr[1]])
for i in range(1,n+1):
  print(ans[i])

### FIXED CODE ###

import bisect
import sys
sys.setrecursionlimit(10**7)

def dfs(v):
  pos=bisect.bisect_left(dp,arr[v])
  changes.append((pos,dp[pos]))
  dp[pos]=arr[v]
  ans[v]=bisect.bisect_left(dp,10**18)
  for u in g[v]:
    if checked[u]==0:
      checked[u]=1
      dfs(u)
  pos,val=changes.pop()
  dp[pos]=val

n=int(input())
arr=[0]+list(map(int,input().split()))
g=[[] for _ in range(n+1)]
for _ in range(n-1):
  a,b=map(int,input().split())
  g[a].append(b)
  g[b].append(a)
ans=[0]*(n+1)
checked=[0]*(n+1)
checked[1]=1
dp=[10**18 for _ in range(n+1)]
changes=[]
dfs(1)
for i in range(1,n+1):
  print(ans[i])
def op_print(data,a,b):
    for i in range(a,b+1):
        print(data[i])
def op_reverse(data,a,b):
    return data[:a] + data[::-1][-b:-a] + data[:b]
def op_replace(data,a,b,q):
    return data.replace(data[a:b],q) 

data = input()
q = int(input())
for _ in range(q):
    op = list(map(str,input().split()))
    if(op[0] == "print"):
        op_print(data,int(op[1]),int(op[2]))
    elif(op[0] == "reverse"):
        data = op_reverse(data,int(op[1]),int(op[2]))
    elif(op[0] == "replace"):
        data = op_replace(data,int(op[1]),int(op[2]),op[3])


### FIXED CODE ###

s=input()
for _ in range(int(input())):
    o=input().split()
    a,b=map(int,o[1:3]);b+=1
    c=o[0][2]
    if c=='p':s=s[:a]+o[3]+s[b:]
    elif c=='i':print(s[a:b])
    elif c=='v':s=s[:a]+s[a:b][::-1]+s[b:]
k, x = map(int, input().split())
ans = []
for i in range(N):
    ans.append(k-i)
for j in range(1, N, 1):
    ans.append(k+i)
ans = sorted(ans)
 
for k in ans:
    print(ans[k])

### FIXED CODE ###

k, x = map(int, input().split())
l = []
for i in range(k):
    l.append(x+i)
    if i > 0:
        l.append(x-i)
l = sorted(l)
for j in range(2*k-1):
    print(l[j], end=" ")
from collections import Counter
from collections import defaultdict
s =input()
lenth=len(s)
ss=s*2
t =input()
place=defaultdict(set)
guide=Counter()
flag=0
for k,l in enumerate(s):
	for word in range(97, 97+26):
		word=chr(word)
		if word==l:
			place[word].add(k)
			place[word].add(k+lenth)
			flag=1

now=0
ans=0
for i in t:
	if not place[i]:
		print(-1)
		exit()
	mt=min((j for j in place[i] if j>now))
	if mt>lenth:
		mt-=lenth
		ans+=lenth
	now=mt
print(ans+now+1)



			

	





	

### FIXED CODE ###

import sys
from bisect import bisect_right
input = lambda: sys.stdin.readline()[:-1]
from collections import defaultdict
s =input()
lenth=len(s)
ss=s*2
t =input()
place=defaultdict(list)

for k,l in enumerate(s):
	place[l].append(k+1)
	place[l].append(k+1+lenth)
for i in place.values():
	i.sort()
now=0
ans=0

for i in t:
	if not place[i]:
		print(-1)
		exit()
	mt=place[i][bisect_right(place[i],now)]
	if mt>lenth:
		mt-=lenth
		ans+=lenth
	now=mt
print(ans+now)
N = int(input())
H = list(map(int, input().split()))

ans = 1 
for i in range(1,N):
    if H[i] >= max(H[:i]):
        ans += 1
print(ans)

### FIXED CODE ###

a,b = (int(_) for _ in input().split())
ans = 0
for i in range(2):
    c = max(a,b)
    ans += c
    if c == a:
        a = a - 1
    else:
        b = b - 1
print(ans)
import math


n = int(input())
a = list(map(int, input().split()))

left_gcd_list = [a[0]]
right_gcd_list = [a[n - 1]]

for i in range(1, n):
    left_gcd_list.append(math.gcd(a[i], left_gcd_list[i - 1]))
    right_gcd_list.insert(0, math.gcd(a[n - 1 - i], right_gcd_list[0]))

print(max([left_gcd_list[n - 2]] +
          [math.gcd(left_gcd_list[i], right_gcd_list[i + 2]) for i in range(0, n - 2)] +
          [right_gcd_list[n - 2]]))


if __name__ == '__main__':
    pass


### FIXED CODE ###

import fractions
import numpy as np


n = int(input())
a = list(map(int, input().split()))

left_gcd_array = np.array([0] * n)
left_gcd_array[0] = a[0]

right_gcd_array = np.array([0] * n)
right_gcd_array[n - 1] = a[n - 1]

for i in range(1, n):
    left_gcd_array[i] = fractions.gcd(a[i], left_gcd_array[i - 1])
    right_gcd_array[n - 1 - i] = fractions.gcd(a[n - 1 - i], right_gcd_array[n - i])

print(max([left_gcd_array[n - 2]] +
          [fractions.gcd(left_gcd_array[i], right_gcd_array[i + 2]) for i in range(0, n - 2)] +
          [right_gcd_array[1]]))


if __name__ == '__main__':
    pass
k,x = map(int,input().split())

for i in range(x-k-1,x+k-1)
	print(i)

### FIXED CODE ###

import numpy as np
k,x = map(int,input().split())

result = np.arange(x-k+1,x+k,1,dtype = 'int')

for i in range(len(result)):
    print(result[i],end = " ")
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
MOD = 10**9 + 7

dp = [0] * (N+1)
dp[0] = 1
dp[1] = 1 if 1 not in a else 0

a = list(set(range(2, N+2)) - set(a))
for i in a:
    dp[i] = (dp[i-1] + dp[i-2]) % MOD
print(dp[N] % MOD)

### FIXED CODE ###

N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
MOD = 10**9 + 7
 
dp = [0] * (N+1)
dp[0] = 1
dp[1] = 1 if 1 not in a else 0
 
a = set(list(range(2,N+1))) - set(a)
for i in a:
    dp[i] = (dp[i-1] + dp[i-2]) % MOD
print(dp[N] % MOD)
n =input()
a= 500
b = 5
sum = 0
if(n%a==0):
  sum = n*2
print(sum)

### FIXED CODE ###

n =int(input())
a= 500
b = 5
sum = 0
if(n%a==0):
  sum = n*2
else:
  sum = (1000*(n//a)) + 5*((n%a)//b)
  
print(sum)