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

S = input()
total = 0
while True:
    count_10 = S.count("10")
    total += count_10 * 2
    S = S.replace("10", "")
    count_01 = S.count("01")
    total += count_01 * 2
    S = S.replace("01", "")
    if count_01 == 0 and count_10 == 0:
        break
print(total)

### FIXED CODE ###

S = input()
total = 0
count_0 = S.count("0")
count_1 = S.count("1")
ans = min(count_0, count_1) * 2
print(ans)
### BUGGY CODE ###

import math
A = []
N = int(input())
maxdiff = 0
for n in range(N):
    A.append(int(input()))
S = tuple(A)
Smax = ((S[i]-min(S[:i])) for i in range(1, N))
print(max(Smax))

### FIXED CODE ###

import math
A = []
N = int(input())
maxdiff = 0
for n in range(N):
    A.append(int(input()))
R = tuple(A)

Dmax = R[1] -R[0]
Rmin = R[0]

for i in range(1, N):
    if R[i] >= R[i-1]:
        if R[i] - Rmin > Dmax:
            Dmax = R[i] -Rmin
    if R[i] < Rmin:
        Rmin = R[i]
#    print(R[i], Dmax, Rmin)

print(Dmax)
### BUGGY CODE ###

import math


def inputIntList():
    return [int(s) for s in input().split()]


def inputInt():
    return int(input())


def main():
    N, K = inputIntList()
    h = inputIntList()
    h.extend([0] * K)
    dp = [float("inf") for _ in range(N + K)]
    dp[0] = 0
    for i in range(N):
        for k in range(1, K + 1):
            if abs(h[i] - h[i + k]) + dp[i] < dp[i + k]:
                dp[i + k] = abs(h[i] - h[i + k]) + dp[i]
        # print(dp)
    return dp[N - 1]


if __name__ == "__main__":
    print(main())


### FIXED CODE ###

import math


def inputIntList():
    return [int(s) for s in input().split()]


def inputInt():
    return int(input())


def main():
    N, K = inputIntList()
    h = inputIntList()
    h.extend([0] * K)
    dp = [float("inf") for _ in range(N + K)]
    dp[0] = 0
    for i in range(N):
        for k in range(1, K + 1):
            if abs(h[i] - h[i + k]) + dp[i] < dp[i + k]:
                dp[i + k] = abs(h[i] - h[i + k]) + dp[i]
        # print(dp)
    return dp[N - 1]


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

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,k = inpl()
g = [[] for i in range(n)]
sg = [set() for i in range(n)]
lsg = [0]*n
seen = [-1]*n
fin = set()
for i in range(n-1):
    a,b = inpl()
    g[a-1].append(b-1)
    g[b-1].append(a-1)
    sg[a-1].add(b-1)
    sg[b-1].add(a-1)
for i in range(n):
    lsg[i] = len(g[i])

def dfs(node,parent):
    cnt = len(g[parent]) - len(set(g[parent]) - fin) +1
    # print(cnt)
    seen[node] = k-cnt
    fin.add(node)
    for v in g[node]:
        if seen[v] == -1:
            dfs(v,node)
fin.add(0)
seen[0] = k
for i in g[0]:
    dfs(i,0)
res = 1
for x in seen:
    res *= x
    res %= mod
print(res)

### FIXED CODE ###

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

# class Combination:
#     """
#     comb = Combination(1000000)
#     print(comb(5, 3))  # 10
#     """
#     def __init__(self, n_max, mod=10**9+7):
#         self.mod = mod
#         self.modinv = self.make_modinv_list(n_max)
#         self.fac, self.facinv = self.make_factorial_list(n_max)

#     def __call__(self, n, r):
#         return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

#     def make_factorial_list(self, n):
#         # 階乗のリストと階乗のmod逆元のリストを返す O(n)
#         # self.make_modinv_list()が先に実行されている必要がある
#         fac = [1]
#         facinv = [1]
#         for i in range(1, n+1):
#             fac.append(fac[i-1] * i % self.mod)
#             facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
#         return fac, facinv

#     def make_modinv_list(self, n):
#         # 0からnまでのmod逆元のリストを返す O(n)
#         modinv = [0] * (n+1)
#         modinv[1] = 1
#         for i in range(2, n+1):
#             modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
#         return modinv


n,k = inpl()
g = [[] for i in range(n)]
seen = [-1]*n
for i in range(n-1):
    a,b = inpl()
    g[a-1].append(b-1)
    g[b-1].append(a-1)
def p(n,i):
    count = 1
    for _ in range(i):
        count = count * n % mod
        n -= 1
    return count
def dfs(cur,par=-1):
    res = 1
    c = 0 if par == -1 else 1
    cnt = 0
    for v in g[cur]:
        if v == par:
            continue
        cnt += 1
        res *= dfs(v,cur)
        res %= mod
    return res*p(k-c-1,cnt)
print(dfs(0,-1)*k%mod)
### BUGGY CODE ###

import copy

def op(children, S, stacks):
    ret = [0]*len(S)
    while any(stacks):
        # print(stacks)
        new_stack = [[] for _ in stacks]
        for i in range(len(S)):
            if stacks[i]:
                stacks[i].pop()
                ret[i] += 1
                if S[i] == 'R':
                    new_stack[i+1] += copy.copy(stacks[i])
                else:
                    new_stack[i-1] += copy.copy(stacks[i])
            
        stacks = new_stack
    return ret

def solve():
    S = input()
    children = [0] * len(S)
    stacks = [[] for _ in S]
    R_stack = []
    L_stack = []
    R_i = 0
    L_i = 1
    for idx,s in enumerate(S):
        if s == 'R':
            if L_stack:
                stacks[R_i] = copy.copy(L_stack)
                L_stack = []
            R_stack.append('R')
                    
        elif s == 'L':
            if R_stack and not L_stack:
                L_i = idx-1
                R_i = idx
                stacks[L_i] = copy.copy(R_stack)
                R_stack = []
            L_stack.append('L')
    if L_stack:
        stacks[R_i] = copy.copy(L_stack)
        L_stack = []
    children = op(children, S, stacks)
    print(' '.join(map(str, children)))

solve()

### FIXED CODE ###

def solve():
    S = input()
    result = [0] * len(S)
    children_position = []
    even_odd_sum = []
    even_sum = 0
    odd_sum = 0
    R_i = 0
    L_i = -2
    
    for idx, s in enumerate(S):
        
        if s == 'R':
            R_i = idx
            if L_i+1 == R_i:
                even_odd_sum.append((even_sum, odd_sum))
                even_sum = 0
                odd_sum = 0
        elif s == 'L':
            L_i = idx
            if R_i+1 == idx:
                children_position.append((R_i, L_i))
                
        even_sum += idx % 2 == 0
        odd_sum += idx % 2 == 1
                
    even_odd_sum.append((even_sum, odd_sum))
    # print(children_position, even_odd_sum)
    for idx in range(len(children_position)):
        t = children_position[idx]
        even_odd_R = t[0] % 2
        even_odd_L = t[1] % 2
        
        result[t[0]] = even_odd_sum[idx][0] if even_odd_R == 0 else even_odd_sum[idx][1]
        result[t[1]] = even_odd_sum[idx][0] if even_odd_L == 0 else even_odd_sum[idx][1]
        
    
    print(' '.join(map(str, result)))
solve()
### BUGGY CODE ###

N = int(input())
A = [int(i) for i in input().split()]


def gcd(a: int, b: int) -> int:
    while a % b != 0:
        r = a % b
        a = b
        b = r
    return b


L = [A[0]]
R = [A[-1]]
for i in range(1, N):
    L.append(gcd(L[i-1], A[i]))
    R.insert(0, gcd(R[0], A[N-1-i]))


for i in range(N):
    if i == 0:
        ans = R[i+1]
    elif i == N-1:
        ans = max(ans, L[i-1])
    else:
        ans = max(ans, gcd(L[i-1], R[i+1]))

print(ans)


### FIXED CODE ###

N = int(input())
A = [int(i) for i in input().split()]


def gcd(a: int, b: int) -> int:
    while a % b != 0:
        r = a % b
        a = b
        b = r
    return b


L = [0] * N
R = [0] * N
for i in range(1, N):
    L[i] = gcd(L[i-1], A[i-1])
    R[N-i-1] = gcd(R[N-i], A[N-i])

for i in range(N):
    if i == 0:
        ans = R[i]
    elif i == N-1:
        ans = max(ans, L[i])
    else:
        ans = max(ans, gcd(L[i], R[i]))

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

n = int(input())
s = [int(input()) for _ in range(n)]

sum = [0]
for i in range(n):
    temp = []
    for x in sum:
        temp.append(x)
        temp.append(x+s[i])
        sum = temp[::]

dp = [i for i in sum if i % 10 != 0]
print(max(dp) if dp != [] else '0')

### FIXED CODE ###

n = int(input())
s = sorted([int(input()) for _ in range(n)])
if sum(s) % 10 != 0:
    print(sum(s))
    quit()
else:
    for i in s:
        if i % 10 != 0:
            s.remove(i)
            print(sum(s))
            quit()
print('0')
### BUGGY CODE ###

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

for i in range(K):
    tmpA = B + C
    tmpB = A + C
    tmpC = A + B
    A = tmpA
    B = tmpB
    C = tmpC

    if A == B and B == C:
        break

if (A - B) >= 10**18:
    print("Unfair")
else:
    print(A - B)

### FIXED CODE ###

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

if K % 2 == 0:
    print(A - B)
else:
    print(B - A)
### BUGGY CODE ###

n = input().split()
a = list(map(int, input().split()))
b = 0
c = []
count = 0


while(True):
    T = False
    for i in range(len(a)):
        b = a[i] / 2
        c.append(b)
        if a[i]%2 != 0:
            T=True

    if T:
        break

    a = c
    count+=1


print(count)


### FIXED CODE ###

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

while(True):
    T = False
    for i in range(len(a)):
        if a[i]%2 != 0:
            T=True
        else:
            a[i] = a[i] / 2

    if T:
        break

    count+=1

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

import numpy as np

def dp(v, d, c):
    if memo[v-1][d]:
        return

    memo[v-1][d] = True
    if d == 0:
        res[v-1] = str(c)
        return
    dp(v, d-1, c)
    [dp(e, d-1, c) for e in dic[v-1]]


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

dic = [[] for _ in range(N)]
memo = [[False]*11 for _ in range(N)]

for m in range(M):
    a, b = tuple(map(int, input().split(' ')))
    dic[a-1].append(b)
    dic[b-1].append(a)

Q = int(input())


vdc = [tuple(map(int, input().split(' '))) for _ in range(Q)]

res = ['0']*N

[dp(v, d, c) for v, d, c in vdc[::-1]]


print('\n'.join(res))


### FIXED CODE ###

import numpy as np

def dp(v, d, c):
    if memo[v-1][d]:
        return

    memo[v-1][d] = True
    if d == 0:
        res[v-1] = str(c)
        return

    dp(v, d-1, c)
    for e in dic[v-1]:
        dp(e, d-1, c)


N, M = [int(e) for e in input().split(' ')]

dic = [[] for _ in range(N)]
memo = [[False]*11 for _ in range(N)]

for m in range(M):
    a, b = [int(e) for e in input().split(' ')]
    dic[a-1].append(b)
    dic[b-1].append(a)

Q = int(input())


vdc = [[int(e) for e in input().split(' ')] for _ in range(Q)]

res = ['0']*N

[dp(v, d, c) for v, d, c in vdc[::-1]]


print('\n'.join(res))
### BUGGY CODE ###

n=int(input())
table=[0]*60
for i,v  in enumerate(map(int,input().split())):
    for j in range(60):
        table[j]+=v%2
        v//=2
        if v==0:break
#print(*table,sep='\n')
ans=0
mod1,mod2=10**9+7,998244353
mod=mod1
a=1
for o in table:
    z=n-o
    ans=(ans+o*z*a)%mod
    a=a*2%mod
print(ans)

### FIXED CODE ###

n=int(input())
l=[int(c) for c in input().split()]
ans=0
mod=10**9+7
for i in range(60):
  s=sum(a>>i&1 for a in l)
  ans+=s*(n-s)<<i%mod
  ans%=mod
print(ans)
### BUGGY CODE ###

x,y,z,k = map(int,input().split())
a = sorted(list(map(int,input().split())), reverse = True)
b = sorted(list(map(int,input().split())), reverse = True)
c = sorted(list(map(int,input().split())), reverse = True)

ab = []
for i in range(min(3000,x)):
    for j in range(min(3000,y)):
        ab.append(a[i] + b[j])
ab.sort(reverse = True)

abc = []
for i in range(min(3000, len(ab))):
    for j in range(min(3000,z)):
        abc.append(ab[i] + c[j])
abc.sort(reverse = True)

for i in range(k):
    print(abc[i])


### FIXED CODE ###

x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

ab = []
for i in range(x):
    for j in range(y):
        ab.append(a[i] + b[j])
ab.sort(reverse = True)

abc = []
for i in range(min(k,len(ab))):
    for j in range(z):
        abc.append(ab[i] + c[j])

abc.sort(reverse = True)

for i in range(k):
    print(abc[i])
### BUGGY CODE ###

from bisect import bisect_left

n, m, q = map(int, input().split())
LR = [0]*m
for i in range(m):
    LR[i] = list(map(int, input().split()))
P = [0]*q
Q = [0]*q
for i in range(q):
    P[i], Q[i] = map(int, input().split())

LR.sort(key=lambda x: (x[0], x[1]))
L = list(map(lambda x: x[0], LR))
#print(LR)

C = [[0]*(n+1) for _ in range(n+1)]
for i in range(1,n+1):
    l = bisect_left(L, i)
    r = bisect_left(L, i+1)-1
    R2 = list(map(lambda x: x[1], LR[l:r+1]))
    #print(l, r, R2)
    for j in range(i,n+1):
        C[i][j] = bisect_left(R2, j+1)
    #print(i, C[i])

for i in range(q):
    ans = 0
    for j in range(P[i], Q[i]+1):
        ans += C[j][Q[i]]
    print(ans)


### FIXED CODE ###

from bisect import bisect_left
 
n, m, q = map(int, input().split())
LR = [0]*m
for i in range(m):
    LR[i] = list(map(int, input().split()))
P = [0]*q
Q = [0]*q
for i in range(q):
    P[i], Q[i] = map(int, input().split())
 
LR.sort(key=lambda x: (x[0], x[1]))
L = list(map(lambda x: x[0], LR))
#print(LR)
 
C = [[0]*(n+1) for _ in range(n+1)]
for i in range(1,n+1):
    l = bisect_left(L, i)
    r = bisect_left(L, i+1)-1
    R2 = list(map(lambda x: x[1], LR[l:r+1]))
    #print(l, r, R2)
    for j in range(i,n+1):
        C[i][j] = bisect_left(R2, j+1)
    #print(i, C[i])
 
for i in range(q):
    ans = 0
    for j in range(P[i], Q[i]+1):
        ans += C[j][Q[i]]
    print(ans)
### BUGGY CODE ###

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

m = 10 ** 9 + 7
def main():
    r = 0
    for i in range(n - 1):
        for j in range(i + 1, n):
            r += (a[i] % m) * (a[j] % m)

    print(r % m)
    return

main()


### FIXED CODE ###

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


m = 10 ** 9 + 7
def main():
    s = sum(a)
    ss = 0
    r = 0
    for nn in range(n):
        ss += a[nn]
        r += a[nn] * (s - ss)
    print(r % m)
    return

main()
### BUGGY CODE ###

import sys
s = input()
t = input()
for c in set(t):
  if s.find(c) == -1:
    print(-1)
    sys.exit()
p = 0
slen = len(s)
for i in range(1, 10 ** 5 + 1):
  for j in range(slen):
    if s[j] == t[p]:
      p += 1
      if p == len(t):
        print((i - 1) * slen + j + 1)
        sys.exit()

### FIXED CODE ###

import sys
s = input()
t = input()
tset = set(t)
slen = len(s)
if len(tset - set(s)) != 0:
    print(-1)
    sys.exit()
s2t = [i - ord('a') for i in (s + s).encode('ascii')]
lut = [[-1 for _ in range(slen)] for _ in range(26)]
for c in tset:
  b = ord(c) - ord('a')
  j = 0
  for i in range(slen * 2 - 1, -1, -1):
    if s2t[i] == b:
      j = 0
    else:
      j += 1
    if i < slen:
      lut[b][i] = j
p = 0
for c in t:
  b = ord(c) - ord('a')
  p += lut[b][p % slen] + 1
print(p)
### BUGGY CODE ###

def main():
    import heapq
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    h = []
    h2 = []
    heapq.heapify(h)
    for i in range(n):
        heapq.heappush(h, [-b[i], i])
    cnt = 0
    while h:
        i, j = heapq.heappop(h)
        temp = i+b[j-1]+b[(j+1) % n]
        if -temp < a[j]:
            heapq.heappush(h2, [i, j])
            continue
        cnt += 1
        b[j] = -temp
        heapq.heappush(h, [temp, j])
    h2.sort(key=lambda x: x[1])
    for i in range(n):
        if a[i] != -h2[i][0]:
            print(-1)
            return 0
    print(cnt)


main()

### FIXED CODE ###

def main():
    from heapq import heappop as hpop
    from heapq import heappush as hpush
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    h = []
    for i in range(n):
        hpush(h, (-b[i], i))
    cnt = 0
    while h:
        i, j = hpop(h)
        i = -i
        jj = (j+1) % n
        temp = i-a[j]
        temp2 = b[j-1]+b[jj]
        sho = temp//temp2
        if sho == 0:
            if temp:
                print(-1)
                return 0
            continue
        cnt += sho
        b[j] -= temp2*sho
        hpush(h, (-b[j], j))
    print(cnt)
main()
### BUGGY CODE ###

n = int(input())

class Hash:
    def __init__(self):
        self.m = 1000003
        self.T = [None] * self.m
    def insert(self, key):
        i = 0
        while True:
            j = self.h(key, i)
            if self.T[j] == None:
                self.T[j] = key
                break
            else:
                i = i + 1
    def search(self, key):
        i = 0
        while True:
            j = self.h(key, i)
            if self.T[j] == key:
                return j
            elif self.T[j] == None:
                return None
            else:
                i += 1
        return self.T[self.h(key)]
    def h(self, key, i):
        ki = self.key2int(key)
        h1 = ki % self.m
        h2 = i * (1 + (ki % (self.m - 1)))
        return (h1 + h2) % self.m
    def key2int(self, key):
        return sum([['A', 'C', 'G', 'T'].index(s) + 1 for s in key])

h = Hash()
for i in range(n):
    op, st = input().split()
    if op == 'insert':
        h.insert(st)
    else:
        if h.search(st):
            print('yes')
        else:
            print('no')

### FIXED CODE ###

n = int(input())
h = {}

for i in range(n):
    op, st = input().split()
    if op == 'insert':
        h[st] = 'yes'
    else:
        print (h.get(st, 'no'))
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
res = 1
for i in range(n):
  res = res * a[i]
if(res > pow(10,18)):
  res = -1
print(res)

### FIXED CODE ###

import sys
n = int(input())
a = list(map(int,input().split()))
if 0 in a:
  res = 0
  print(res)
  sys.exit()
  
res = 1
for i in range(n):
  if(res > pow(10,18)):
    break
  else:
    res = res * a[i]
if(res > pow(10,18)):
   res = -1
print(res)
### BUGGY CODE ###

import numpy as np


def read_input(trans=int):
    return list(map(trans, input().split()))


N, K = read_input()
A = np.array(read_input(), dtype="int")

K = np.minimum(K, 41)

for _ in range(K):
    B = np.zeros(N, dtype="int")
    for i in range(N):
        start = np.maximum(i-A[i], 0)
        end = np.minimum(i+A[i], N-1)

        B[start] += 1
        if end+1 < N:
            B[end+1] -= 1
    B = np.cumsum(B)
    A = B


print(" ".join(map(str, A.tolist())))


### FIXED CODE ###

def read_input(trans=int):
    return list(map(trans, input().split()))


N, K = read_input()
A = read_input()
K = min(K, 41)

for _ in range(K):
    B = [0]*N
    for i in range(N):
        start = max(i-A[i], 0)
        end = min(i+A[i], N-1)

        B[start] += 1
        if end+1 < N:
            B[end+1] -= 1
    for i in range(1, N):
        B[i] += B[i-1]
    A = B.copy()


print(" ".join(map(str, A)))
### BUGGY CODE ###

import sys
if sys.version[0] == '2':
    range, input = xrange, raw_input
N = int(input())

A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

AB = [(a, b) for a, b in zip(A, B) if a < b]
dp = [[N] * (N + 1) for _ in range(len(AB)+1)]
for i, (a, b) in enumerate(AB):
    for w in range(N+1):
        if w >= a:
            dp[i+1][w] = max(dp[i][w], dp[i+1][w-a] + b-a)
        else:
            dp[i+1][w] = dp[i][w]

M = max(dp[-1])

BA = [(a, b) for a, b in zip(A, B) if a > b]
dp = [[M] * (M + 1) for _ in range(len(BA)+1)]
for i, (a, b) in enumerate(BA):
    for w in range(M+1):
        if w >= b:
            dp[i+1][w] = max(dp[i][w], dp[i+1][w-b] + a-b)
        else:
            dp[i+1][w] = dp[i][w]
print(max(dp[-1]))


### FIXED CODE ###

import sys
if sys.version[0] == '2':
    range, input = xrange, raw_input
N = int(input())

A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

dp = [0] * (N+1)
for a, b in ((a, b) for a, b in zip(A, B) if a < b):
    for w in range(a, N+1):
        dp[w] = max(dp[w], dp[w-a] + b-a)

M = max(dp) + N
dp = [0] * (M+1)
for a, b in ((a, b) for a, b in zip(A, B) if a > b):
    for w in range(b, M+1):
        dp[w] = max(dp[w], dp[w-b] + a-b)

print(max(dp) + M)
### BUGGY CODE ###

S = input()
news = ''
t = False
for i in range(len(S)-1):
    if t:
        t = False
        continue
    if S[i] == 'B' and S[i+1] == 'C':
        news += 'D'
        t = True
        continue
    news += S[i]

ans = 0
cnt = 0
for s in news:
    if s == 'A':
        cnt += 1
    elif s == 'D':
        ans += cnt
    else:
        cnt = 0

print(ans)

### FIXED CODE ###

S = input()
news = S.replace('BC', 'D')

ans, cnt = 0, 0
for s in news:
    if s == 'A':
        cnt += 1
    elif s == 'D':
        ans += cnt
    else:
        cnt = 0

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

S = input()
mod = 10**9 + 7
dp = [[0] * 13 for i in range(len(S)+1)]  # the number of ways to make a number with remainder j using the first i digit
dp[0][0] = 1
mod13 = [i*10 % 13 for i in range(13)]
for i in range(1, len(S) + 1):
    temp = [0] * 13
    for j, k in enumerate(mod13):
        temp[k] = dp[i-1][j]

    if S[i-1] == '?':
        for d in range(10):
            for j in range(13):
                dp[i][j] += temp[(j-d) % 13]
                dp[i][j] %= mod
    else:
        d = int(S[i-1])
        for j in range(13):
            dp[i][j] += temp[(j-d) % 13]
print(dp[len(S)][5])


### FIXED CODE ###

import numpy as np
 
s = input()
p = np.array([0]*13)
p[0] = 1
 
amari = [[0]*13 for _ in range(13)]
for j in range(10):
  for i in range(13):
    amari[i][(i*10+j)%13] += 1
M = np.array(amari)
 
for si in range(len(s)):
  a = np.array([0]*13)
  if s[si] == '?':
    a = np.dot(p,M)
  else:
    c = int(s[si])
    for i in range(13):
      a[(i*10+c)%13] += p[i]
  p = np.mod(a,1000000007)
print(p[5])
### BUGGY CODE ###

n,k = map(int,input().split())
h = []
for i in range(n):
  h.append(int(input()))
h.sort()
g = float('inf')
for i in range(n-k+1):
  if g > max(h[i:i+k]) - min(h[i:i+k]):
    g = max(h[i:i+k]) - min(h[i:i+k])
print(g)

### FIXED CODE ###

n,k = map(int,input().split())
h = []
for i in range(n):
  h.append(int(input()))
h.sort()
g = float('inf')
for i in range(n-k+1):
  g = min(g, h[i+k-1] - h[i])
print(g)
### BUGGY CODE ###

import sys
from heapq import heappush, heapify

def solve():
    file_input = sys.stdin
    N, R, L = map(int, file_input.readline().split())
    
    hq = []
    m = {}
    for i in range(1, N + 1):
        team = [0, i, 0]
        heappush(hq, team)
        m[i] = team
    
    time = 0
    for line in file_input:
        d, t, x = map(int, line.split())
        m[d][0] -= x
        hq[0][2] += t - time
        time = t
        heapify(hq)
    hq[0][2] += L - time
    ans_team = max(hq, key = lambda x: (x[2], -x[1]))
    print(ans_team[1])

solve()


### FIXED CODE ###

import sys
from heapq import heappush, heappop, heapreplace
 
def solve():
    file_input = sys.stdin
    N, R, L = map(int, file_input.readline().split())
     
    pq = [[0, i] for i in range(1, N + 1)]
    m = dict(zip(range(1, N + 1), pq))
    time = [0] * (N + 1)
    INVALID = -1
     
    pre_t = 0
    for line in file_input:
        d, t, x = map(int, line.split())
        top_team = pq[0]
        time[top_team[1]] += t - pre_t
        pre_t = t
         
        if top_team[1] == d:
            top_team[0] -= x
            if x < 0:
                heapreplace(pq, top_team)
        else:
            scored_team = m[d][:]
            scored_team[0] -= x
            heappush(pq, scored_team)
            m[d][1] = INVALID
            m[d] = scored_team
         
        while pq[0][1] == INVALID:
            heappop(pq)
    time[pq[0][1]] += L - pre_t
    print(time.index(max(time)))
 
solve()