Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

#!/usr/bin/env python3


def argmax(scores):
    index = 0
    mx = 0
    for i, s in enumerate(scores):
        if mx < s[0]:
            mx = s[0]
            index = i
    return index


def main():
    N, K = input_line(int, int)
    A = input_line([int])
    F = input_line([int])
    A.sort()
    F.sort(reverse=True)
    scores = [[a*f, a, f] for a, f in zip(A, F)]
    index = argmax(scores)
    while K > 0 and scores[index][1] > 0:
        scores[index][1] -= 1
        scores[index][0] = scores[index][1] * scores[index][2]
        K -= 1
        index = argmax(scores)
    print(scores[index][0])


def input_line(*types):
    if isinstance(types[0], list):
        return list(map(types[0][0], input().split()))
    elif len(types) == 1:
        return types[0](input())
    else:
        return [t(x) for t, x in zip(types, input().split())]


if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import numpy as np


def is_ok(mid, K, A, F):
    return np.maximum(A - mid // F, 0).sum() <= K


def main():
    N, K = input_line(int, int)
    A = input_line([int])
    F = input_line([int])
    A = np.array(sorted(A))
    F = np.array(sorted(F, reverse=True))

    ng = -1
    ok = int(1e12)
    while ok - ng > 1:
        mid = (ng + ok) // 2
        if is_ok(mid, K, A, F):
            ok = mid
        else:
            ng = mid
    print(ok)


def input_line(*types):
    if isinstance(types[0], list):
        return [types[0][0](x) for x in input().split()]
    elif len(types) == 1:
        return types[0](input())
    else:
        return [t(x) for t, x in zip(types, input().split())]


if __name__ == "__main__":
    main()
### BUGGY CODE ###

#from collections import Counter

#import numpy as np

#input = raw_input
n = int(input())
#nums = np.zeros(2001, dtype=int)
nums = [0] * 2001
#nums = np.zeros(2001, dtype=int)

ls = map(int, input().split(" "))
#ls = Counter(map(int, ls))
#vals = ls.keys()
ls = sorted(ls)
for l in ls:
    #print(l)
    nums[l] += 1

set_vals = [val for val in range(2001) if nums[val] >= 1]
#print(vals)

#cumsum = np.cumsum(nums)

#print(set_vals)
len_set = len(set_vals)
out = 0
for i in range(len_set):
    val1 = set_vals[i]
    num_i = nums[val1]
    if num_i >= 3:
        out += (num_i * (num_i-1) * (num_i-2) // 6)
    
    if num_i >= 2:
        val2 = set_vals[i]
        for j in range(i+1, len_set):
            val3 = set_vals[j]
            num_h = nums[val3]
            if 2 * val1 <= val3:
                break

            out += ((num_i * (num_i-1)) // 2) * num_h

    for j in range(i+1, len_set):
        val2 = set_vals[j]
        num_j = nums[val2]

        if num_j >= 2:
            out += (num_i *  num_j * (num_j - 1) // 2 )

        for h in range(j+1, len_set):
            val3 = set_vals[h]
            #print(val1, val2, val3)
            num_h = nums[val3]
            if val1 + val2 <= val3:
                break

            #print("num", num_i, num_j, num_h)
            out += (num_i * num_j * num_h)

print(out)

### FIXED CODE ###

#from collections import Counter

#import numpy as np

input = raw_input
n = int(input())
#nums = np.zeros(2001, dtype=int)
nums = [0] * 2001
#nums = np.zeros(2001, dtype=int)

ls = map(int, input().split(" "))
#ls = Counter(map(int, ls))
#vals = ls.keys()
ls = sorted(ls)
for l in ls:
    #print(l)
    nums[l] += 1

set_vals = [val for val in range(2001) if nums[val] >= 1]
#print(vals)

#cumsum = np.cumsum(nums)

#print(set_vals)
len_set = len(set_vals)
out = 0
for i in range(len_set):
    val1 = set_vals[i]
    num_i = nums[val1]
    if num_i >= 3:
        out += (num_i * (num_i-1) * (num_i-2) // 6)
    
    if num_i >= 2:
        val2 = set_vals[i]
        for j in range(i+1, len_set):
            val3 = set_vals[j]
            num_h = nums[val3]
            if 2 * val1 <= val3:
                break

            out += ((num_i * (num_i-1)) // 2) * num_h

    for j in range(i+1, len_set):
        val2 = set_vals[j]
        num_j = nums[val2]

        if num_j >= 2:
            out += (num_i *  num_j * (num_j - 1) // 2 )

        for h in range(j+1, len_set):
            val3 = set_vals[h]
            #print(val1, val2, val3)
            num_h = nums[val3]
            if val1 + val2 <= val3:
                break

            #print("num", num_i, num_j, num_h)
            out += (num_i * num_j * num_h)

print(out)
### BUGGY CODE ###

n=int(input())
a=[]
for i in range(n):
    a.append(int(input())-1)

#TLEチーンコ
i=0
j=0
b=[]
while True:
    j+=1
    if a[i]==1:
        print(j)
        break
    elif a[i] in b:
        print(-1)
        break
    else:
        i=a[i]


### FIXED CODE ###

n=int(input())
a=[]
for i in range(n):
    a.append(int(input())-1)
'''
#TLEチーンコ
i=0
j=0
b=[]
while True:
    j+=1
    if a[i]==1:
        print(j)
        break
    elif a[i] in b:
        print(-1)
        break
    else:
        b.append(a[i])
        i=a[i]
'''
i=0
j=0
while True:
    j+=1
    if a[i]==1:
        print(j)
        break
    elif j==n:
        print(-1)
        break
    else:
        i=a[i]
### BUGGY CODE ###

N = input()
A = list(input().split())
num = 1
for i in A:
  num = num*int(i)
if num > 1000000000000000000:
  print(-1)
else:
  print(num)

### FIXED CODE ###

N = input()
A = list(map(int, input().split()))
newA = sorted(A,reverse=True)
num = 1
if 0 in A:
  num = 0
else:
  for i in newA:
    if num > 1000000000000000000:
      break
    num = num*int(i)
if num > 1000000000000000000:
  print(-1)
else:
  print(num)
### BUGGY CODE ###

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

jinjya = []
otera = []

for i in range(a):
    jinjya.append(int(input()))
for i in range(b):
    otera.append(int(input()))
def find(arr,tar,start,end):
    if start >= end:
        return start
    bar = (start+end)//2
    if arr[bar]<tar:
        return find(arr,tar,bar+1,end)
    elif arr[bar]>tar:
        return find(arr,tar,start,bar-1)
    else:
        return bar
for i in range(q):
    jinjyaEast = 0
    jinjyaWest = 0
    oteraEast = 0
    oteraWest = 0
    pos = int(input())
    idx = find(jinjya,pos,0,len(jinjya)-1)
    if(jinjya[idx] < pos):
        jinjyaWest = jinjya[idx]
        if idx<len(jinjya)-1:
            jinjyaEast = jinjya[idx+1]
    else:
        jinjyaEast = jinjya[idx]
        if idx>0:
            jinjyaWest = jinjya[idx-1]
    idx = find(otera,pos,0,len(otera)-1)
    if(otera[idx] < pos):
        oteraWest = otera[idx]
        if idx<len(otera)-1:
            oteraEast = otera[idx+1]
    else:
        oteraEast = otera[idx]
        if idx>0:
            oteraWest = otera[idx-1]
    res = []
    j = []
    o = []
    if jinjyaWest != 0:
        j.append(jinjyaWest)
    if jinjyaEast != 0:
        j.append(jinjyaEast)
    if oteraWest != 0:
        o.append(oteraWest)
    if oteraEast != 0:
        o.append(oteraEast)
    for a in j:
        for b in o:
            res.append(min(abs(pos-a)+abs(b-a),abs(pos-b)+abs(a-b)))
    print(min(res))


### FIXED CODE ###

import bisect
a,b,q = map(int,input().split())

jinjya = []
otera = []

for i in range(a):
    jinjya.append(int(input()))
for i in range(b):
    otera.append(int(input()))

INF = 10**18
jinjya = [-INF] + jinjya + [INF]
otera = [-INF] + otera + [INF]


for i in range(q):
    res = INF
    pos = int(input())
    j,o = bisect.bisect_right(jinjya,pos),bisect.bisect_right(otera,pos)
    for a in [jinjya[j-1],jinjya[j]]:
        for b in [otera[o-1],otera[o]]:
            res = min(res,abs(pos-a)+abs(a-b),abs(pos-b)+abs(a-b))
    print(res)
### BUGGY CODE ###

import sys

def Not_Divisible(n,p):
    k=0
    for i,a in enumerate(p):
        for j,b in enumerate(p):
            if  i != j and a % b == 0:
                k-=1
                break
        k+=1
    return k

if __name__ == '__main__':
    input = sys.stdin.readline
    
    inp1 = input().rstrip()
    n = int(inp1)

    inp2 = input().rstrip().split()
    p = list(map(int,inp2))
    print(Not_Divisible(n,p))

### FIXED CODE ###

import sys

def Not_Divisible(n,p):
    maxp = max(p)
    dp = [[True,0] for _ in range(maxp+1)]
    for a in p:
        dp[a][1]+=1
        t =2
        while a*t <= maxp:
            if dp[a*t][0] == True :
                dp[a*t][0] = False
            t+=1
    k=0
    for d in p:
        if dp[d][1] == 1 and dp[d][0] == True:
            k+=1
    return k


def main():
    input = sys.stdin.readline
    
    inp1 = input().rstrip().split()
    n = int(inp1[0])

    inp2 = input().rstrip().split()
    p = tuple(map(int,inp2))
    print(Not_Divisible(n,p))


if __name__ == '__main__':
    main()
### BUGGY CODE ###

def main():
    mod = 10**9+7
    k = int(input())
    n = len(input())
    fact = [1, 1]
    for i in range(2, n+k+1):
        fact.append(fact[-1]*i % mod)
    nk = fact[n+k]
    print(sum([pow(fact[n+k-i]*fact[i] % mod, mod-2, mod)
               * nk*pow(25, i, mod) % mod for i in range(k+1)]) % mod)


main()


### FIXED CODE ###

def main():
    mod = 10**9+7
    k = int(input())
    s = input()
    n = len(s)
    fact = [1, 1]
    for i in range(2, 2*(10**6)+1):
        fact.append(fact[-1]*i % mod)

    def nCr(n, r, mod=10**9+7):
        return pow(fact[n-r]*fact[r] % mod, mod-2, mod)*fact[n] % mod

    ans = 0
    for i in range(k+1):
        ans = (ans+nCr(n+k, i)*pow(25, i, mod)) % mod
    print(ans)


main()
### BUGGY CODE ###

import numpy as np

def main(H, W, s_list):
    row_count = np.zeros((H, W))
    for i_row in range(H):
        i_col = 0
        j_col = 0
        while(i_col < W):
            char = s_list[i_row][i_col]
            j_col = i_col
            
            if char == '.':
                while(True):
                    j_col += 1
                    if j_col == W:
                        break
                    c = s_list[i_row][j_col]
                    if c == '#':
                        break

                row_count[i_row, i_col:j_col] = j_col - i_col
            i_col = j_col + 1


    col_count = np.zeros((H, W))
    for i_col in range(W):
        i_row = 0
        j_row = 0 
        while(i_row < H):
            char = s_list[i_row][i_col]
            j_row = i_row
            if char == '.':
                while(True):
                    j_row += 1
                    if j_row == H:
                        break
                    c = s_list[j_row][i_col]
                    if c == '#':
                        break
                
                col_count[i_row:j_row, i_col] = j_row - i_row
            i_row = j_row + 1
    print(int(np.max(row_count + col_count)) - 1)



if __name__ == "__main__":
    H, W = [int(x) for x in input().split()]
    s_list = []
    for _ in range(H):
        s_list.append(input())

    main(H, W, s_list)


### FIXED CODE ###


def main(H, W, s_list):
    row_count = [[0]*W for _ in range(H)]
    for i_row in range(H):
        i_col = 0
        j_col = 0
        s = s_list[i_row]
        while(i_col < W):
            char = s[i_col]
            j_col = i_col
            
            if char == '.':
                while(True):
                    j_col += 1
                    if j_col == W:
                        break
                    c = s[j_col]
                    if c == '#':
                        break
                
                for k in range(i_col, j_col):
                    row_count[i_row][k] = j_col - i_col
            i_col = j_col + 1


    col_count = [[0]*W for _ in range(H)]
    for i_col in range(W):
        i_row = 0
        j_row = 0
        s_col = [s[i_col] for s in s_list]
        while(i_row < H):
            char = s_col[i_row]
            j_row = i_row
            if char == '.':
                while(True):
                    j_row += 1
                    if j_row == H:
                        break
                    c = s_col[j_row]
                    if c == '#':
                        break
                for k in range(i_row, j_row):
                    col_count[k][i_col] = j_row - i_row
            i_row = j_row + 1

    m = 0
    for i_row in range(H):
        for i_col in range(W):
            sumation = row_count[i_row][i_col] + col_count[i_row][i_col]
            if sumation > m:
                m = sumation
    print(int(m) - 1)



if __name__ == "__main__":
    H, W = [int(x) for x in input().split()]
    s_list = []
    for _ in range(H):
        s_list.append(input())

    main(H, W, s_list)
### BUGGY CODE ###

M = int(input())
A = list(map(int, input().split()))
num = 1

while num <= M:
    print(A.count(num))
    num += 1


### FIXED CODE ###

import collections
M = int(input())
A = list(map(int, input().split()))
B = collections.Counter(A)
num = 1

while num <= M:
    print(B[num])
    num += 1
### BUGGY CODE ###

n = int(input())
a_list = list(map(int, input().split()))
nums = list(set(a_list))
r_list = []
for n in nums:
	count = a_list.count(n) + a_list.count(n-1) + a_list.count(n+1)
	r_list.append(count)
print(max(r_list))

### FIXED CODE ###

n = int(input())
a_list = list(map(int, input().split()))
r_list = [0]*(10**5+2)
for n in a_list:
	r_list[n] += 1
	r_list[n+1] += 1
	if n > 0:
		r_list[n-1] += 1
print(max(r_list))
### BUGGY CODE ###

N, M = map(int,input().split())
A = [1]*N
for i in range(M):
    L, R = map(int,input().split())
    for j in range(0,L-1):
        A[j] = 0
    for j in range(R,N):
        A[j] =0
print(sum(A))

### FIXED CODE ###

N, M = map(int,input().split())
L =[]
R =[]
for i in range(M):
    L1, R1 = map(int,input().split())
    L.append(L1-1)
    R.append(R1+1)
if min(R) - max(L) -1<0:
    print("0")
else:
    print(min(R)-max(L)-1)
### BUGGY CODE ###

#import pysnooper
#import os,re,sys,operator,math,heapq,string
#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline

s=input().rstrip()
dp=[[0]*13 for _ in range(10**5+5)]
n=len(s)
dp[0][0]=1
mod=10**9+7
for i in range(n):
    c=-1 if s[i]=="?" else int(s[i])
    for j in range(10):
        if c!=-1 and c!=j:
            continue
        for k in range(13):
            dp[i+1][(k*10+j)%13]+=dp[i][k]
    for j in range(13):
        dp[i+1][j]%=mod
print(dp[n][5])

### FIXED CODE ###

#import pysnooper
#import os,re,sys,operator,math,heapq,string
#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline

s=input().rstrip()
dp=[[0]*13 for _ in range(10**5+5)]
n=len(s)
dp[0][0]=1
mod=10**9+7
for i in range(n):
    c=-1 if s[i]=="?" else int(s[i])
    for j in range(10):
        if c!=-1 and c!=j:
            continue
        for k in range(13):
            dp[i+1][(k*10+j)%13]+=dp[i][k]
    for j in range(13):
        dp[i+1][j]%=mod
print(dp[n][5])
### BUGGY CODE ###

from collections import Counter
n = int(input())
l = [int(i) for i in input().split()]

c = Counter(l)

for i in l:
    ans = sum([v * (v-1) // 2 for v in c.values()])
    print(ans - c[i] + 1)



### FIXED CODE ###

from collections import Counter
n = int(input())
l = [int(i) for i in input().split()]

c = Counter(l)

total = sum([v * (v-1) // 2 for v in c.values()])
for i in l:
    print(total - c[i] + 1)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
pos = [0, 0, 0]
for a in A:
  if a == 1:
    pos[0] += 1
  elif a == 2:
    pos[1] += 1
  elif a == 3:
    pos[2] += 1


dp = [[[0]*(N+1) for y in range(N+1)] for x in range(N+1)]
transition = [[1, 0, 0, 0], [-1, 1, 0, 1], [0, -1, 1, 2]]

def get_expectation(pos):
  global dp
  px, py, pz = pos
  if px == py == pz == 0:
    return 0
  elif px<0 or px>N or py<0 or py>N or pz<0 or pz>N:
    return 0
  else:
    if dp[px][py][pz] > 0:
      return dp[px][py][pz]
    else:
      for dx, dy, dz, idx in transition:
        s = px + py + pz
        dp[px][py][pz] += (get_expectation([px-dx, py-dy, pz-dz]) + N/s)*[px, py, pz][idx]/s
      
      return dp[px][py][pz]


print(get_expectation(pos))

### FIXED CODE ###

N = int(input())
A = input().split()
px = py = pz = 0
for a in A:
  if a == '1':
    px += 1
  elif a == '2':
    py += 1
  elif a == '3':
    pz += 1

nx = px + py + pz
ny = py + pz
nz = pz

dp = [[[0]*(nx+1) for y in range(ny+1)] for z in range(nz+1)]

for z in range(nz+1):
  for y in range(ny+1-z):
    for x in range(nx+1-z-y):
      if x == y == z == 0:
        continue
      
      else:
        s = x + y + z
        t = N/s
        if x > 0:
          t += dp[z][y][x-1]*x/s
        if y > 0:
          t += dp[z][y-1][x+1]*y/s
        if z > 0:
          t += dp[z-1][y+1][x]*z/s
        
        dp[z][y][x] += t


print(dp[pz][py][px])
### BUGGY CODE ###

N = int(input())
a = list(map(int,input().split()))
if N == 2:
    print(abs(a[1]-a[0]))
    exit()
S = sum(a)
m = float('inf')
for i in range(N-2):
    m = min(abs(S - sum(a[:i+1])*2),m)
    if m == 0:
        break
print(m)

### FIXED CODE ###

N = int(input())
a = list(map(int,input().split()))
if N == 2:
    print(abs(a[1]-a[0]))
    exit()
S = sum(a)
m = float('inf')
memo = [0]*(N-1)
memo[0] = a[0]
for i in range(1,N-1):
    memo[i] = memo[i-1] + a[i]
for i in range(N-1):
    m = min(abs(S-memo[i]*2),m)

print(m)
### BUGGY CODE ###

n,m,*T=map(int,open(0).read().split());*S,=zip(T[::2],T[1::2]);s=lambda e:set(sum([s for s in S if e in s],()));print("IM"*(len(s(1)&s(n))<1)+"POSSIBLE")

### FIXED CODE ###

n,m,*T=map(int,open(0).read().split());*S,=zip(T[::2],T[1::2]);s=lambda e:set(s[e<2]for s in S if e in s);print("IM"*(len(s(1)&s(n))<1)+"POSSIBLE")
### BUGGY CODE ###

def bSort(a):
    for i in range(len(a)):
        for j in range(len(a)-1, i, -1):
            if a[j] > a[j-1]:
                a[j], a[j-1] = a[j-1], a[j]

    return a


n = int(input())

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

d = int(n / 2)

p = bSort(p)


print(p[d-1]-p[d])

### FIXED CODE ###

n = int(input())
p = list(map(int,input().split()))
d = int(n / 2)
p.sort(reverse=True)
print(p[d-1]-p[d])
### BUGGY CODE ###

n = int(input())
list=[0,'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
word = []
i = 12
while i>=0:
  x = n//(26**i)
  word.append(x)
  n = n-x*26**i

while True:
  word = int(''.join(word)).split()
  if 0 in word:
    p = word.index(0)
    word[p-1] = word[p-1]-1 
    word[p] = 26
  else:
    break

h=''
for i in range(len(word)):
  h += list[word[i]]
print(h)

### FIXED CODE ###

list = [0,'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
num_list =[0]
for i in range(1,15):
    num_list.append(26**i+num_list[i-1])

n = int(input())
i = 0
while True:
    if num_list[i] >= n:
        break
    else:
        i +=1


word = []
for j in range(i,0,-1):
    x = n//26**(j-1)
    if x==27:
        word.append(26)
        n = n -26**(j-1)*(n//26**(j-1))+26**(j-1)
    else:
        word.append(x)
        n = n -26**(j-1)*(n//26**(j-1))
while True:
    if 0 in word:
        p = word.index(0)
        word[p-1] = word[p-1]-1
        word[p] = 26
    else:
        break
h =''
for k in range(len(word)):
    h+=str(list[word[k]])
print(h)
### BUGGY CODE ###

import heapq
import bisect
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
s=[0]*(n+1)

for i in range(n):
    s[i+1]=s[i]+a[i]
def test(x):
    count=0
    for i in range(n):
        idx=bisect.bisect_left(a,x-a[i])
        if i>=idx:
            count+=(i-idx)*2+1
    return count


def search():
    mn=-1
    mx=m*max(a)*2
    buf=0
    while mx-mn>1:
        buf=(mx+mn)//2
        count=test(buf)
        if count>=m:
            mn=buf
        else:
            mx=buf
    return mn
x=search()
y=test(x)
#print(x,y)
count=0
for i in range(n):
    idx=bisect.bisect_left(a,x-a[i])
    if i>=idx:
        count+=(2*i-2*idx)*a[i]+(s[i+1]-s[idx])*2
        #print(count,i-idx+1)
print(count-(y-m)*x)


### FIXED CODE ###

import heapq
import bisect
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
s=[0]*(n+1)
dp=[0]*(10**5+1)
h=0
for i in range(10**5+1):
    if h==n:
        dp[i]=h
        continue
    if i<=a[h]:
        dp[i]=h
    else:
        while h<n and i>a[h]:
            h+=1
        dp[i]=h



for i in range(n):
    s[i+1]=s[i]+a[i]
def test(x):
    count=0
    for i in range(n):
        buf=x-a[i]
        #idx=bisect.bisect_left(a,x-a[i])
        if buf<0:
            idx=0
        elif buf>=10**5+1:
            idx=n
        else:
            idx=dp[buf]
        if i>=idx:
            count+=(i-idx)*2+1
    return count


def search():
    mn=-1
    mx=m*max(a)*2
    buf=0
    while mx-mn>1:
        buf=(mx+mn)//2
        count=test(buf)
        if count>=m:
            mn=buf
        else:
            mx=buf
    return mn
x=search()
y=test(x)
#print(x,y)
count=0
for i in range(n):
    idx=bisect.bisect_left(a,x-a[i])
    if i>=idx:
        count+=(2*i-2*idx)*a[i]+(s[i+1]-s[idx])*2
        #print(count,i-idx+1)
print(count-(y-m)*x)
### BUGGY CODE ###

s=input()[::-1]
l=len(s)
dp=[[0]*2 for _ in range(l+1)]
for i in range(l):
  dp[i+1][0]=min(dp[i][0]+int(s[i]),dp[i][1]+int(s[i])+1)
  if i!=0:
    dp[i+1][1]=min(dp[i][0]+10-int(s[i]),dp[i][1]+10-(int(s[i])+1))
  else:
    dp[i+1][1]=dp[i][0]+10-int(s[i])
print(min(dp[l][0],dp[l][1]+1))

### FIXED CODE ###

s=input()[::-1]
l=len(s)
dp=[[0]*2 for _ in range(l+1)]
for i in range(l):
  dp[i+1][0]=min(dp[i][0]+int(s[i]),dp[i][1]+int(s[i])+1)
  if i!=0:
    dp[i+1][1]=min(dp[i][0]+10-int(s[i]),dp[i][1]+10-(int(s[i])+1))
  else:
    dp[i+1][1]=dp[i][0]+10-int(s[i])
print(min(dp[l][0],dp[l][1]+1))
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10**7)

def dfs(x):
    if seen[x-1]==0:
        uni[cnt].add(x)
        seen[x-1]=1
        for i in fri[x-1]:
            dfs(i)
    

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

fri=[[] for i in range(n)]
blk=[set() for i in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    fri[a-1].append(b)
    fri[b-1].append(a)

for i in range(k):
    c,d=map(int,input().split())
    blk[c-1].add(d)
    blk[d-1].add(c)


seen=[0 for i in range(n)]

uni=[]
cnt=0
for i in range(1,n+1):
    if seen[i-1]==0:
        uni.append(set())
        dfs(i)
        cnt+=1

seq=[0 for i in range(n)]

for unii in uni:
    for j in unii:
        cj=len(unii)-len(fri[j-1])-len(unii&blk[j-1])-1
        seq[j-1]=cj

print(*seq)

### FIXED CODE ###

import sys

sys.setrecursionlimit(10**7)

def dfs(x):
    if seen[x-1]==0:
        uni[cnt].add(x)
        seen[x-1]=1
        for i in fri[x-1]:
            dfs(i)
    

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

fri=[[] for i in range(n)]
blk=[[] for i in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    fri[a-1].append(b)
    fri[b-1].append(a)

for i in range(k):
    c,d=map(int,input().split())
    blk[c-1].append(d)
    blk[d-1].append(c)


seen=[0 for i in range(n)]

uni=[]
cnt=0
for i in range(1,n+1):
    if seen[i-1]==0:
        uni.append(set())
        dfs(i)
        cnt+=1

seq=[0 for i in range(n)]

for unii in uni:
    for j in unii:
        cj=len(unii)-len(fri[j-1])-len(unii&set(blk[j-1]))-1
        seq[j-1]=cj

print(*seq)
### BUGGY CODE ###

s = input()
ans = 0
num = 4
for i in range(len(s)-3):
    for j in range(num,len(s)):
        if  (int(s[i:j+1]) % 2019 == 0):
            ans += 1
            num = j
print(ans)

### FIXED CODE ###

s = input()
ans = 0
mod = [0]*2019
t = s[len(s)-1]
n = 1
for i in range(len(s)-1,-1,-1):
#     mod.append(int(s[i:])%2019)
    mod[int(t)%2019] += 1
#     t = int(t) + (10**(len(s)-i-1))*int(s[i])
    t = int(t) + n*10*int(s[i-1])
    n = n*10%2019
for i in range(0,2019):
    ans += mod[i]*(mod[i]-1)/2
ans += mod[0]
print(int(ans))