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


k = int(input())
q = list(map(str, range(1, 10)))
i = 0

while i < k:
    i += 1

    org = q.pop(0)
    x = int(org[-1])

    if x != 0:
        q.append(org + str(x- 1))

    q.append(org + str(x))

    if x != 9:
        q.append(org + str(x + 1))
print(org)

### FIXED CODE ###

import collections

k = int(input())
q = collections.deque(list(range(1, 10)))
i = 0

while i < k:
    i += 1

    org = q.popleft()
    x = org % 10

    if x != 0:
        q.append(10 * org + x - 1)

    q.append( 10 * org + x)

    if x != 9:
        q.append(10 * org + x + 1)
print(org)
### BUGGY CODE ###

def solve(array, k):
    ans = 0
    length = len(array)
    i = 0
    while i < length - 1:
        if array[i] == array[i + 1]:
            i += 1
        elif i + k >= length:
            ans += 1
            break
        else:
            ans += 1
            i += k - 1
            array[i] = min(array[:i + 1])
    return ans
    
if __name__ == "__main__":
    n, k = map(int, input().split())
    array = [int(s) for s in input().split()]
    print(solve(array, k))

### FIXED CODE ###

def solve(n, k):
    div, mod = divmod(n - 1, k - 1)
    return div + (0 if mod == 0 else 1)

if __name__ == "__main__":
    n, k = map(int, input().split())
    array = [int(s) for s in input().split()]
    print(solve(n, k))
### BUGGY CODE ###

import collections

N = int(input())
S = [input() for _ in range(N)]
# print(S)

c = collections.Counter(S)
# print(c.most_common())

outputs = []
for i, (key, value) in enumerate(c.most_common()):
    outputs.append(key)
    if i == len(c.most_common())-1 or c.most_common()[i+1][1] != value:
        break
outputs.sort()
for x in outputs:
    print(x)
    

### FIXED CODE ###

N = int(input())
S = [input() for _ in range(N)]
S.sort()

ans = []
counter = 1
memo = 0

for i in range(1, N):
    if S[i] == S[i-1]:
        counter += 1
    else:
        if counter == memo:
            ans.append(S[i-1])
        elif counter > memo:
            ans.clear()
            ans.append(S[i-1])
            memo = counter
        counter = 1
if counter == memo:
    ans.append(S[N-1])
elif counter > memo:
    ans.clear()
    ans.append(S[N-1])
    memo = counter
for a in ans:
    print(a)
### BUGGY CODE ###





data = input().split()

N, k = int(data[0]), int(data[1])

tab = []

data = input().split()
for i in range(N):
    tab.append(int(data[i]) - 1)


parcour = []

position = 0

while (not (position in parcour)):
    parcour.append(position)
    position = tab[position]
i = 0
while parcour[i] != position:
    i+= 1

sizeCycle = len(parcour) - i 

#print (parcour)
if (k < len(parcour)):
    print(parcour[k] + 1)
else:
    print(parcour[i + ((k - i) % sizeCycle)] + 1)
    


### FIXED CODE ###





data = input().split()

N, k = int(data[0]), int(data[1])

tab = []

data = input().split()
for i in range(N):
    tab.append(int(data[i]) - 1)


parcour = []
tmp = [0] * N

position = 0

while (tmp[position] == 0):
    parcour.append(position)
    tmp[position] = 1
    position = tab[position]
i = 0
while parcour[i] != position:
    i+= 1

sizeCycle = len(parcour) - i 

#print (parcour)
if (k < len(parcour)):
    print(parcour[k] + 1)
else:
    print(parcour[i + ((k - i) % sizeCycle)] + 1)
### BUGGY CODE ###

# D
from collections import deque

# create graph
G = dict()
N, M = map(int, input().split())
for n in range(1, N+1):
    G[n] = dict()

for _ in range(M):
    a, b, c = map(int, input().split())
    G[a][b] = c

# value
values = [-1000000000*2000]*(N+1)
values[1] = 0
# BFS
inc_cnt = 0
d = deque([1])
while len(d) > 0:
    a = d.popleft()
    for b in G[a].keys():
        if values[b] < values[a] + G[a][b]:
            values[b] = values[a] + G[a][b]
            if b == N:
                inc_cnt += 1
            d.append(b)
    if inc_cnt > 100:
        break
if inc_cnt > 100:
    print('inf')
else:
    print(values[N])

### FIXED CODE ###

# D
from collections import deque

# create graph
G = dict()
G_inv = dict()
N, M = map(int, input().split())
for n in range(1, N+1):
    G[n] = dict()
    G_inv[n] = dict()

for _ in range(M):
    a, b, c = map(int, input().split())
    G[a][b] = c
    G_inv[b][a] = c

# value
values = [-1000000000*2000]*(N+1)
values[1] = 0

reachable = [0]*(N+1)
reachable[N] = 1
# find reachble points
dr = deque([N])
while len(dr) > 0:
    b = dr.popleft()
    for a in G_inv[b].keys():
        if reachable[a] == 0:
            reachable[a] = 1
            dr.append(a)

# BFS
inc_cnt = 0
d = deque([1])
while len(d) > 0:
    a = d.popleft()
    for b in G[a].keys():
        if values[b] < values[a] + G[a][b] and reachable[b] == 1:
            values[b] = values[a] + G[a][b]
            inc_cnt += 1
            d.append(b)
    if inc_cnt > 2000:
        break
if inc_cnt > 1000:
    print('inf')
else:
    print(values[N])
### BUGGY CODE ###

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

S = M / N
S = int(S)
#print(S)
import math
if N == 1:
    ans = M
else:
    not_sosu = -1
    for i in range(2, int(math.sqrt(M)) + 1):
        if M % i == 0:
            not_sosu = 1
            break
    if not_sosu == 1:
        for i in range(S, -1, -1):
            if M / i >= N:
                if M % i == 0:
                    ans = i
                    break
    else:
        ans = 1

if N == 1:
    ans = M

print(ans)


### FIXED CODE ###

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

S = M / N
S = int(S)
#print(S)
import math
if N == 1:
    ans = M
else:
    not_sosu = -1
    for i in range(2, int(math.sqrt(M)) + 1):
        if M % i == 0:
            not_sosu = 1
            if M / i >= N and M % i == 0:
                ans = max(ans, i)
            j = M // i
            if M / j >= N and M % j == 0:
                ans = max(ans, j)
            #print(i)
    if not_sosu == -1:
        ans = 1


if N == 1:
    ans = M

print(ans)
### BUGGY CODE ###

def input_int():
    return(int(input()))

def input_int_list():
    return(list(map(int,input().split())))

def input_int_map():
    return(map(int,input().split()))

def run():
    num_count = input_int()
    nums = []
    for _ in range(num_count):
        nums.append(input_int())

    num_history = [1]

    current_num = 1
    while True:
        current_num = nums[current_num - 1]

        if current_num == 1:
            print(-1)
            return

        if current_num == 2:
            print(len(num_history))
            return

        num_history.append(current_num)

run()


### FIXED CODE ###

def input_int():
    return(int(input()))

def input_int_list():
    return(list(map(int,input().split())))

def input_int_map():
    return(map(int,input().split()))

def run():
    num_count = input_int()
    nums = []
    for _ in range(num_count):
        nums.append(input_int())

    num_count = 1

    current_num = 1
    while True:
        current_num = nums[current_num - 1]

        if num_count >= len(nums):
            print(-1)
            return

        if current_num == 2:
            print(num_count)
            return
        num_count += 1

run()
### BUGGY CODE ###

N, K = map(int, input().split())
A = list(int(a) for a in input().split())

B = []
tmp = 1
for i in range(N):
    tmp *= A[i]
    if i < K-1:
        continue
    if i > K-1:
        tmp //= A[i-K]
    B.append(tmp)

for i in range(N-K):
    if B[i] < B[i+1]:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

N, K = map(int, input().split())
A = list(int(a) for a in input().split())

for i in range(N-K):
    if A[i] < A[i+K]:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

#各丸太を何回切るか、どこで切るか
#丸太iをKi回切る場合、その丸太の最小はL//Kiとなる
#あとは、どの丸太を何回切るかを求めればよい。
"""
長い丸太ほど多く切るべき
丸太が2本、1本が10**9でもう一本が1。10**9回切れるのであれば1本目に全振りするのがベスト。

結論、元の長さの比に基づいて割り当てればよい。
一番短い丸太の長さを1として各丸太の
"""
from math import ceil
import heapq
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
pivot = A[0]
hiritu = [a/pivot for a in A]
hirituSum = sum(hiritu)
kaisu = []
for i in range(N):
    h = hiritu[i]
    k = int(K*h/hirituSum)
    kaisu.append(k)
    K -= k

leng = []
for i in range(N):
    a = A[i]
    k = kaisu[i]
    leng.append(((-a/(k+1)),k,a))
heapq.heapify(leng)
for _ in range(K):
    l,k,a = heapq.heappop(leng)
    l = -a/(k+2)
    heapq.heappush(leng,(l,k+1,a))
l,k,a = heapq.heappop(leng)
l *= -1
print(ceil(l))

### FIXED CODE ###

from math import ceil
N,K = map(int,input().split())
A = list(map(int,input().split()))

def is_ok(X):
    #最大値をX以下にできるか
    cnt = 0
    for a in A:
        cnt += ceil(a/X)-1
    return cnt <= K

def bisearch(high,low):
    while high - low > 1:
        mid = (high+low)//2
        if is_ok(mid):
            high = mid
        else:
            low = mid
    return high

print(bisearch(10**9+1,0))
### BUGGY CODE ###

from collections import deque
h, w = map(int, input().split())
maze = [list(input()) for i in range(h)]
ans = 0

# (px, py)にライトを置いた時照らされるマスを返す関数
def lightdot(px, py):
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    # それぞれ上、下、左、右に移動していく
    pos = deque([[px, py, 0, 0], [px, py, 1, 0], [px, py, 2, 0], [px, py, 3, 0]])
    res = 0

    while len(pos) > 0:
        x, y, direct, depth = pos.popleft()
        nx = x + dx[direct]
        ny = y + dy[direct]
        if 0 <= nx < w and 0 <= ny < h and maze[ny][nx] == '.':
            # 方向は引き継ぐ
            pos.append([nx, ny, direct, depth + 1])
        else:
            res += depth
    # 現在地点の'.'も含める
    return res + 1

for i in range(w):
    for j in range(h):
        if maze[j][i] == '.':
            ans = max(ans, lightdot(i, j))
print(ans)

### FIXED CODE ###

def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

h,w = [int(i) for i in input().split()]
b = [input() for i in range(h)]

ans = [[0]*w for i in range(h)]

for i in range(h):
    res = 0
    for j in range(w):
        if b[i][j] == ".":
            ans[i][j] += res
        if b[i][j] == ".":
            res += 1
        else:
            res = 0

for i in range(h):
    res = 0
    for j in range(w-1,-1,-1):
        if b[i][j] == ".":
            ans[i][j] += res
        if b[i][j] == ".":
            res += 1
        else:
            res = 0

for j in range(w):
    res = 0
    for i in range(h):
        if b[i][j] == ".":
            ans[i][j] += res
        if b[i][j] == ".":
            res += 1
        else:
            res = 0

for j in range(w):
    res = 0
    for i in range(h-1,-1,-1):
        if b[i][j] == ".":
            ans[i][j] += res
        if b[i][j] == ".":
            res += 1
        else:
            res = 0

print(max(max(row) for row in ans) + 1)
### BUGGY CODE ###

def lcs(x,y):
    x = " " + x
    y = " " + y
    c = [[0 for i in xrange(len(x))] for j in xrange(len(y))]
    for i in xrange (1,len(y)):
        for j in xrange (1,len(x)):
            if x[j] == y[i]:
                c[i][j] = c[i-1][j-1] + 1
            elif c[i-1][j] >= c[i][j-1]:
                c[i][j] = c[i-1][j]
            else:
                c[i][j] = c[i][j-1]
    return max(max(c))
n = input() 
for i in xrange (n): 
    x = raw_input()
    y = raw_input() 
    print lcs(x,y)

### FIXED CODE ###

def lcs():
    x, y = raw_input(), raw_input()
    b1 = [0 for k in range(len(y)+1)]
    for i in xrange(len(x)):
        a = x[i]
        b2 = b1 + []
        for j in xrange(len(y)):
            if a == y[j]:
                b1[j+1] = b2[j] + 1
            elif b1[j+1] < b1[j]:
                b1[j+1] = b1[j]
    print max(b1)
 
n = input()
for i in xrange(n):
    lcs()
### BUGGY CODE ###

#B問題
N = int(input())
S = [list(str(input())) for i in range(N)]

A = 0
B = 0
T = [[0 for i in range(N)] for j in range(N)]
ans = 0
for i in range(N):
    A+=1
    A%=N
    for j in range(N):
        for k in range(N):
            s = S[j][k]
            T[(j+A)%N][k] = s
            
    flag = 0
    for j in range(N):
        for k in range(N):
            if T[j][k] != T[k][j]:
                flag = 1
    if flag == 0:
        ans+=1
        
print(ans*N)


### FIXED CODE ###

#B問題
N = int(input())
S = [list(str(input())) for i in range(N)]

A = 0
B = 0

ans = 0
for i in range(N):
    A = i
    flag = 0
    for j in range(N):
        for k in range(N):
            if S[(j+A)%N][k] != S[(k+A)%N][j]:
                flag = 1
    
    if flag == 0:
        ans+=1
        
print(ans*N)
### BUGGY CODE ###

K, S = map(int, input().split())
import itertools
count = 0
for pattern in list(itertools.product(range(K+1), repeat=3)):
    #print(pattern)
    if sum(pattern) == S:
        
        count += 1

print(count)

### FIXED CODE ###

K, S = map(int, input().split())
import itertools
count = 0
for pattern in itertools.product(range(K+1), repeat=2):
    #print(pattern)
    if S-K <= sum(pattern) <= S:
        
        count += 1

print(count)
### BUGGY CODE ###

n = int(input())
li = list(map(int,input().split()))
li2 = sorted(li,reverse=True)
cnt = 0

for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if li2[i] < li2[j]+li2[k]:
                cnt += 1
            else:
                break
print(cnt)

### FIXED CODE ###

import bisect

n = int(input())
li = list(map(int,input().split()))
li2 = sorted(li)
cnt = 0

for i in range(n-2):
    for j in range(i+1,n-1):
        cnt += bisect.bisect_left(li2,li2[i]+li2[j]) - (j+1) 
print(cnt)
### BUGGY CODE ###

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

dp = [0]
for i in range(1, N):
    min_v = 1050000000
    for j in range(1, K+1):
        if i - j >= 0:
            min_v = min(min_v, dp[i - j] + abs(H[i] - H[i - j]))
    dp.append(min_v)
print(dp[N-1])

### FIXED CODE ###

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

dp = [0 for _ in range(N)]
for i, hi in enumerate(H):
    if i == 0:
        continue
    r = max(0, i - K)
    dp[i] = min(d + abs(hi - h) for d, h in zip(dp[r:i], H[r:i]))
print(dp[N-1])
### BUGGY CODE ###

k, s = map(int, input().split())
x = 0
for i in range(k+1):
    for j in range(k+1):
        for l in range(k+1):
            if i + j + l == s:
                x += 1
print(x)

### FIXED CODE ###

k, s = map(int, input().split())
x = 0
for i in range(k+1):
    for j in range(k+1):
        z = s - i - j
        if 0 <= z and  z <= k:
            x += 1
print(x)
### BUGGY CODE ###

N, K = map(int, input().split())
p = list(map(int, input().split()))
def expected_value(li):
    def _expect(i):
        return (i+1) * (i / 2) / i
    return sum(map(_expect, li))

ans = 0

for x in range(N - K + 1):
    r = expected_value(p[x:x+K])
    if r > ans:
        ans = r
        
print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
p = list(map(int, input().split()))
def expect(i):
    return (i+1) / 2


S=[0]

for i, x in enumerate(p, start=1):
    S.append(S[i-1] + expect(x))
    
ans = 0    

for i in range(N - K + 1):
    r = S[i+K] - S[i]
    if r > ans:
        ans = r
print(ans)
### BUGGY CODE ###

H, N = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]

AB.append((0, 1))

dp = [float("inf")] * (10 ** 4 * 2 + 1)
dp[0] = 0
for i in range(1, len(dp)):
    for a, b in AB:
        if i - a >= 0:
            dp[i] = min(dp[i], dp[i - a] + b)

ans = min(dp[H:])
print(ans)


### FIXED CODE ###

from functools import lru_cache
import sys

sys.setrecursionlimit(10 ** 8)

H, N = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]
# 効率順にソート
# 効率が同じなら、小規模な魔法を優先
AB.sort(key=lambda ab: (ab[1] / ab[0], ab[0]))


@lru_cache(maxsize=None)
def dp(h):
    if h <= 0:
        return 0
    else:
        best = float("inf")
        for a, b in AB:
            val = b + dp(h - a)
            if val < best:
                best = val
            else:
                # 更新されなかった場合は、以降の魔法で更新されることはない
                break
        return best


print(dp(H))
### BUGGY CODE ###

def main():
    N, K = map(int, input().split())
    A = sorted(map(int, input().split()))
    F = sorted(map(int, input().split()), reverse=True)

    l = 0
    r = A[-1] * F[0]
    while r != l:
        t = l + (r - l) // 2
        if K >= sum(a - t // f for a, f in zip(A, F) if a * f > t):
            r = t
        else:
            l = t + 1
    print(r)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    N, K = map(int, input().split())
    A = sorted(map(int, input().split()))
    F = sorted(map(int, input().split()), reverse=True)
    def helper(t):
        k = K
        for a, f in zip(A, F):
            if a * f <= t:
                continue
            m = t // f
            k -= (a - m)
            if k < 0:
                return False
        return True

    l = 0
    r = A[-1] * F[0]
    while r != l:
        m = l + (r - l) // 2
        if helper(m):
            r = m
        else:
            l = m + 1
    print(r)


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

N,Q=[int(x) for x in input().split()]
S=list(input())
Check_list=['A','T','G','C']

for i in range(Q):
  l,r=[int(x) for x in input().split()]
  S_temp=S[l-1:r]
  
  ac_num=0
  
  for l in range(len(S_temp)-1):
    if (S_temp[l]=='A') & (S_temp[l+1]=='C'):
      ac_num+=1
    
  print(ac_num)

### FIXED CODE ###

N,Q=[int(x) for x in input().split()]
S=list(input())

t=[0]

for i in range(1,N):
  if (S[i-1]=='A')&(S[i]=='C'):
    t.append(t[i-1]+1)
  else:
    t.append(t[i-1])

for i in range(Q):
  r,l = map(int, input().split(" "))
  print(abs(t[r-1]-t[l-1]))
### BUGGY CODE ###

n = int(input())
lst1 = list(map(int,input().split()))
mod = 10**9+7
 
def GCD(a,b):
    if b == 0:
        return a
    else:
        return GCD(b,a%b)
def LCM(a,b):
    return (a//GCD(a,b)*b)

l = 1
for i in lst1:
    l = LCM(l,i)

ans = 0
for i in range(n):
    ans += l//lst1[i]
 
print(ans%mod)

### FIXED CODE ###

n = int(input())
lst1 = list(map(int,input().split()))
mod = 10**9+7
 
def GCD(a,b):
    if b == 0:
        return a
    else:
        return GCD(b,a%b)
def LCM(a,b):
    return (a//GCD(a,b)*b)

l = 1
for i in lst1:
    l = LCM(l,i)

ans = 0
for i in range(n):
    ans += l//lst1[i]
 
print(ans%mod)
### BUGGY CODE ###

cnt = int(input())
lst = [int(input()) for i in range(cnt)]

for i, j in enumerate(lst):
    lst[i] = 0
    print(max(lst))
    lst[i] = j

### FIXED CODE ###

cnt = int(input())
lst = [int(input()) for i in range(cnt)]
lst2 = sorted(lst)
for i in lst:
  if i == lst2[-1]:
    print(lst2[-2])
  else:
    print(lst2[-1])
### BUGGY CODE ###

import math

x = int(input())

a = 0
b = 0
while True:
    b = -(x - a ** 5)

    f = False
    if b < 0:
        b = -b
        f = True
        
    for i in range(5):
        b = math.sqrt(b)

    if f == True:
        b = -b
    
    if b - int(b) == 0.0:
        break
    a += 1

print(a, int(b))

### FIXED CODE ###

import math

x = int(input())

f = False
for a in range(-200,200):
    for b in range(-200, 200):
        if a ** 5 - b ** 5 == x:
            print(a, b)
            f = True
            break
    if f == True:
        break
### BUGGY CODE ###

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

c = [True for i in range(n)]
for i in range(1,n):
  for j in range(i):
    if p[i]>p[j]:
      c[i] = False
      break
print(sum(c))

### FIXED CODE ###

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

c = [True for i in range(n)]
target = p[0]
for i in range(1,n):
  if p[i]>target:
      c[i] = False
  else:
    target = p[i]
print(sum(c))
### BUGGY CODE ###

rows,cols = list(map(int,input().split()))
grid=[]
up=[]
# down=[]
# left=[]
# right=[]
for i in range(rows):
	grid.append(input())
	up.append([0 for j in range(cols)])
	# down.append([-1 for j in range(cols)])
	# left.append([-1 for j in range(cols)])
	# right.append([-1 for j in range(cols)])
#up
for c in range(cols):
	count = 1
	for r in range(rows-1,-1,-1):
		if(grid[r][c]=='#'):
			count=1
		else:
			up[r][c]+=count
			count+=1

#down

for c in range(cols):
	count = 1
	for r in range(rows):
		if(grid[r][c]=='#'):
			count=1
		else:
			up[r][c]+=count
			count+=1

#left

for c in range(rows):
	count = 1
	for r in range(cols-1,-1,-1):
		if(grid[c][r]=='#'):
			count=1
		else:
			up[c][r]+=count
			count+=1

#right

for c in range(rows):
	count = 1
	for r in range(cols):
		if(grid[c][r]=='#'):
			count=1
		else:
			up[c][r]+=count
			count+=1
ans = 1
for x in range(rows):
	for y in range(cols):
		if(grid[x][y]=='.'):
			ans=max(ans,(up[x][y]-3))
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
rows,cols = list(map(int,raw_input().split()))
grid=[]
up=[]
# down=[]
# left=[]
# right=[]
for i in range(rows):
	grid.append(raw_input())
	up.append([0 for j in range(cols)])
	# down.append([-1 for j in range(cols)])
	# left.append([-1 for j in range(cols)])
	# right.append([-1 for j in range(cols)])
#up
for c in range(cols):
	count = 1
	for r in range(rows-1,-1,-1):
		if(grid[r][c]=='#'):
			count=1
		else:
			up[r][c]+=count
			count+=1

#down

for c in range(cols):
	count = 1
	for r in range(rows):
		if(grid[r][c]=='#'):
			count=1
		else:
			up[r][c]+=count
			count+=1

#left

for c in range(rows):
	count = 1
	for r in range(cols-1,-1,-1):
		if(grid[c][r]=='#'):
			count=1
		else:
			up[c][r]+=count
			count+=1

#right

for c in range(rows):
	count = 1
	for r in range(cols):
		if(grid[c][r]=='#'):
			count=1
		else:
			up[c][r]+=count
			count+=1
ans = 1
for x in range(rows):
	for y in range(cols):
		if(grid[x][y]=='.'):
			ans=max(ans,(up[x][y]-3))
print(ans)
### BUGGY CODE ###

import re
S = input()
ans = 0
a = len(S)
while True:
    S = re.sub('01|10|1001|0110', '', S)
    if ans - len(S) == 0:
        print(a-ans)
        break
    else:
        ans = len(S)



### FIXED CODE ###

import re
S = input()
print(2*min(S.count('0'), S.count('1')))
### BUGGY CODE ###

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

if N <= K:
  print(0)
  
else:
  H = list(map(int, input().split()))
  H.sort()
  H.reverse()
  for i in range(K):
    del(H[0])
 
  c = 0
  for j in range(len(H)):
    c += H[j]
  print(c)

### FIXED CODE ###

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

if N <= K:
  print(0)
  
else:
  H = list(map(int, input().split()))
  H.sort()
  H.reverse()
  
  c = 0
  for i in range(K, N):
    c += H[i]
  print(c)
### BUGGY CODE ###

N = int(input())
print(sum([i for i in range(1, N)]))


### FIXED CODE ###

N = int(input())
print(N*(N-1)//2)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
U = 5000 * 5000 + 10

inf = 10 ** 18
dp1 = [-inf] * U
dp1[0] = N
for a, b in zip(A, B):
    for i in range(N - a + 1):
        dp1[i + a] = max(dp1[i + a], dp1[i] + b - a)

for i in range(N + 1):
    N = max(N, dp1[i])

dp2 = [-inf] * U
dp2[0] = N
for a, b in zip(A, B):
    for i in range(N - b + 1):
        dp2[i + b] = max(dp2[i + b], dp2[i] + a - b)

for i in range(N + 1):
    N = max(N, dp2[i])

print(N)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
U = 5000 * 5000 + 10

inf = 10 ** 18
dp1 = [-inf] * U
dp1[0] = N
for a, b in zip(A, B):
    for i in range(N - a + 1):
        dp1[i + a] = max(dp1[i + a], dp1[i] + b - a)

for i in range(N + 1):
    N = max(N, dp1[i])

dp2 = [-inf] * U
dp2[0] = N
for a, b in zip(A, B):
    for i in range(N - b + 1):
        dp2[i + b] = max(dp2[i + b], dp2[i] + a - b)

for i in range(N + 1):
    N = max(N, dp2[i])

print(N)
### BUGGY CODE ###

arr = [0 for i in range(2019)]
arr[0] = 1

s = input()
n = len(s)

num = 0
for i,ele in enumerate(s[::-1]):
    num += int(ele) * 10**i
    arr[num%2019] += 1


ans = 0
for m in arr:
    if m==0: continue
    ans += m*(m-1)//2

print(ans)



### FIXED CODE ###

arr = [0 for i in range(2019)]
arr[0] = 1

s = input()
n = len(s)

num = 0
for i,ele in enumerate(s[::-1]):
    num += int(ele) * pow(10, i, 2019)
    arr[num%2019] += 1


ans = 0
for m in arr:
    if m==0: continue
    ans += m*(m-1)//2

print(ans)