Harryxun/stf_run huggingface dataset:
from sys import stdin
from itertools import repeat
def main():
    n, m = map(int, stdin.readline().split())
    w = map(int, stdin.readline().split())
    dat = map(int, stdin.read().split(), repeat(10, 3 * m))
    e = [(dat[i*3+2], dat[i*3] - 1, dat[i*3+1] - 1) for i in xrange(m)]
    e.sort()
    p = range(n)
    ok = [0] * n
    h = [None] * n
    g = [None] * m
    st = []
    pu = st.append
    for i, z in enumerate(e):
        c, u, v = z
        x = u
        while x != p[x]:
            pu(x)
            x = p[x]
        pu(x)
        t = x
        x = v
        while x != p[x]:
            pu(x)
            x = p[x]
        for y in st:
            p[y] = x
        del st[:]
        if x != t:
            w[x] += w[t]
            if w[x] >= c:
                ok[i] = 1
            g[i] = (h[x], h[t])
            h[x] = i
        elif w[x] >= c:
            ok[i] = 1
            g[i] = (h[x],)
            h[x] = i
    d = [0] * m
    po = st.pop
    for i in xrange(m - 1, -1, -1):
        if d[i]:
            continue
        pu(i)
        while st:
            x = po()
            d[x] = 1
            if g[x] is None:
                continue
            for y in g[x]:
                if y is not None:
                    ok[y] |= ok[x]
                    pu(y)
    print m - sum(ok)
main()


### FIXED CODE ###

from sys import stdin
from itertools import repeat
def main():
    n, m = map(int, stdin.readline().split())
    w = map(int, stdin.readline().split())
    dat = map(int, stdin.read().split(), repeat(10, 3 * m))
    e = [(dat[i*3+2], dat[i*3] - 1, dat[i*3+1] - 1) for i in xrange(m)]
    e.sort()
    p = range(n)
    ok = [0] * m
    h = [None] * n
    g = [tuple() for i in xrange(m)]
    st = []
    pu = st.append
    for i, z in enumerate(e):
        c, u, v = z
        x = u
        while x != p[x]:
            pu(x)
            x = p[x]
        pu(x)
        t = x
        x = v
        while x != p[x]:
            pu(x)
            x = p[x]
        for y in st:
            p[y] = x
        del st[:]
        if x != t:
            w[x] += w[t]
            if w[x] >= c:
                ok[i] = 1
            g[i] = (h[x], h[t])
            h[x] = i
        else:
            if w[x] >= c:
                ok[i] = 1
            g[i] = (h[x],)
            h[x] = i
    d = [0] * m
    po = st.pop
    for i in xrange(m - 1, -1, -1):
        if d[i]:
            continue
        pu(i)
        while st:
            x = po()
            d[x] = 1
            for y in g[x]:
                if y is not None:
                    ok[y] |= ok[x]
                    pu(y)
    print m - sum(ok)
main()
a,b = input().split
c,d = map(int,input().split())
e = input()

if a == e:
  print("{} {}".format(c-1,d))
else:
  print("{} {}".format(c,d-1))

### FIXED CODE ###

a,b = input().split()
c,d = map(int,input().split())
e = input()

if a == e:
  print("{} {}".format(c-1,d))
else:
  print("{} {}".format(c,d-1))
n = int(input())
tree = [[] for _ in range(n)]
color = [0]*n
for _ in range(n-1):
  a,b,c = map(int,input().split())
  a -= 1
  b -= 1
  tree[a].append((b,c))
  tree[b].append((a,c))
  
  
def dfs(i,before,cost):
  if cost%2 == 1:
    color[i] = 1
  for j in tree[i]:
    if j[0] == before:
      continue
    dfs(j[0],i,cost + j[1])
    
dfs(0,-1,0)

for i in range(n):
  print(color[i])
  



### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

n = int(input())
tree = [[] for _ in range(n)]
color = [0]*n
for _ in range(n-1):
  a,b,c = map(int,input().split())
  a -= 1
  b -= 1
  tree[a].append((b,c))
  tree[b].append((a,c))
  
  
def dfs(i,before,cost):
  if cost == 1:
    color[i] = 1
  for j in tree[i]:
    if j[0] == before:
      continue
    dfs(j[0],i,(cost + j[1])%2 )
    
dfs(0,-1,0)

for i in range(n):
  print(color[i])
def f(a):q=a[:n];heapify(q);return sum(q)+cumsum([e-heappushpop(q,e)for e in a[n:n-~n]]);from heapq import*;from numpy import*;n,*a=map(int,open(0).read().split());print(max(map(sum,zip(f(a),f([-e for e in a[::-1]])[::-1]))))

### FIXED CODE ###

from heapq import*
n,*a=map(int,open(0).read().split())
b=a[:n]
c=[-i for i in a[n:][::-1]]
d=c[:n]
e=c[n:]
heapify(b)
heapify(d)
s=sum(b)
t=sum(d)
red=[s]
blue=[t]
for i in range(n,n*2):
    s+=a[i]-heappushpop(b,a[i])
    t+=c[i]-heappushpop(d,c[i])
    red+=[s]
    blue+=[t]
print(max(map(sum,zip(red,blue[::-1]))))

#あｈｊｆｋぁｄｓｈｆｌｋじゃｇはｌｋｊｄｊｇｌｋ；あｊｄｇｌｋ；あｄｓｊｇｌ；あｊｓｄｇｌｋ；あｊｓｄｇｌ；かｓ
o = input()
e = input()
ans = ""
for i in o:
  ans += o[i]
	if len(e) > i:
  		ans += e[i]
print(ans)

### FIXED CODE ###

o = input()
e = input()
ans = ""
for i in range(len(o)):
  ans += o[i]
  if len(e) > i:
    ans += e[i]
print(ans)
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

N = int(input())

n = []
n = make_divisors(N)

cnt = 999999999999999
if len(n) >= 2:
    for i in range(0,len(n),2):
        t = int(n[i])-1 + int(n[i+1])-1
        if cnt > t:
            cnt = t
print(cnt)



### FIXED CODE ###

def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    #table = list(set(table))
    table = list(table)
    table.sort()
    return table

N = int(input())

#for N in range(1000000000000):
n = []
n = divisor(N)
#print(n)

cnt = 999999999999999
for i in range(0,len(n)//2,1):
    t = int(n[i])-1 + int(n[len(n)-i-1])-1
    if cnt > t:
        cnt = t
print(cnt)
n, m, q = map(int, input().split())
 T = []
 for i in range(q):
     a, b, c, d = map(int, input().split())
     T.append((a-1, b-1, c, d))
 
 L = []
 def f(l):
     if len(l) == n+1:
         L.append(l[1:])
         return
     for i in range(l[-1], m + 1):
         f(l + [i])
	f([1])
 
 print(max(sum(d for a, b, c, d in T if l[b] - l[a] == c)) for l in L)

### FIXED CODE ###

n, m, q = map(int, input().split())
A, B, C, D = [], [], [], []
for i in range(q):
    a, b, c, d = map(int, input().split())
    A.append(a - 1)
    B.append(b - 1)
    C.append(c)
    D.append(d)

L = []

def f(l):
    if len(l) == n:
        L.append(l)
        return
    for i in range(l[-1], m + 1):
        f(l + [i])

for i in range(1, m + 1):
    f([i])

ans = 0

for l in L:
    ans = max(ans, sum(d for a, b, c, d in zip(A, B, C, D) if l[b] - l[a] == c))

print(ans)
while True:
  n, x = map(int, raw_input().split())
  if n + x == 0: break
  ans = 0
  for i in range(n):
    tmp_ans = []
    tmp_ans.append(i+1)
    for j in range(n):
      if j not in tmp_ans and i <= j: 
        tmp_ans.append(j+1)
      for h in range(n):
        if h not in tmp_ans and j <= h: 
          tmp_ans.append(h+1)
        if sum(tmp_ans) == x: ans+= 1
  
    print len(ans)

### FIXED CODE ###

while True:
  n, x = map(int, raw_input().split())
  if n + x == 0: break
  ans = 0
  for i in range(1, n+1):
    tmp_ans = []
    tmp_ans.append(i)
    for j in range(1, n+1):
      if j not in tmp_ans and i < j: 
        tmp_ans.append(j)
        for h in range(1, n+1):
          if h not in tmp_ans and j < h: 
            tmp_ans.append(h)
            if sum(tmp_ans) == x: ans+= 1
            tmp_ans.remove(h)
        tmp_ans.remove(j)
    tmp_ans.remove(i)
  
  print ans
n=int(input())
lists=[list(input().split()) for x in range(n)]
for y in range(n):
  lists[y].append(y+1)
lists.sort(key=lambda t:t[1] reverse=True)
lists.sort(key=lambda t:t[0])
for z in range(n):
  print(lists[z][2])

### FIXED CODE ###

n=int(input())
lists=[]
for x in range(n):
  a,b=input().split()
  lists.append([a,int(b),x+1])
lists.sort(key=lambda t:t[1],reverse=True)
lists.sort(key=lambda t:t[0])
for x in range(n):
  print(lists[x][2])
N = input()
 
res = {i+1: 0 for i in range(N)}
 
for i in range(int(sqrt(N))):
  for j in range(int(sqrt(N))):
    for k in range(int(sqrt(N))):
      n = i**2 + j**2 + k**2 + i*j + j*k + k*i
      if n in res:
        res[n] += 1
for r in res.values():
  print(r)

### FIXED CODE ###

N = int(input())
 
res = {i+1: 0 for i in range(N)}
 
for i in range(1, int(N**0.5)):
  for j in range(1, int(N**0.5)):
    for k in range(1, int(N**0.5)):
      n = i**2 + j**2 + k**2 + i*j + j*k + k*i
      if n in res:
        res[n] += 1
for r in res.values():
  print(r)
from bisect import bisect_left
n = int(input())
ans = [int(input())]
for i in range(n-1):
    now = int(input())
    j = bisect_left(ans,now)
    if j == 0:
        ans.insert(0,now)
    else:
        ans[j-1] = now

print(len(ans))

### FIXED CODE ###

n = int(input())


def divisor(n):  # 約数全列挙
    ans = [1, n]
    i = 2
    while i ** 2 <= n:
        if n % i == 0:
            ans.append(i)
            if i ** 2 < n:
                ans.append(n // i)
        i += 1
    ans.sort()
    return ans
a = list(map(int,input().split()))
ans = []
for num in range(n-1,-1,-1):
    if a[num] %2== 1:
        ans.append(num+1)
        q = divisor(num+1)
        for j in q:
            a[j-1] += 1

print(len(ans))
for i in ans:
    print(i,end=' ')

print()
import sys
input = sys.stdin.readline

MOD = 10**9 + 7
def main():
    S = input()
    N = len(S)-1

    if S[0] == '?':
            dp = [1,1,1,1,1,1,1,1,1,1,0,0,0]
        else:
            dp = [0,0,0,0,0,0,0,0,0,0,0,0,0]
            dp[int(S[i])] = 1

    for i in range(1,N):
        dppre = dp
        dp = [0] * 13

        if S[i] == '?':
            R = range(10)
        else:
            R = [int(S[i])]
        
        for j in range(13):
            for k in R:
                dp[(j * 10 + k) % 13 ] += dppre[j]
        for j in range(13):
            dp[j] %= MOD

    print(dp[5])
if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
sys.setrecursionlimit(2**31-1)
input = sys.stdin.readline
write = sys.stdout.write
LMIIS = lambda : list(map(int,input().split()))
II = lambda : int(input())
dbg = lambda *something : print(*something) if DEBUG is True else 0
DEBUG = True



MOD = 10**9 + 7
class ModInt:

    def __init__(self, x):
        self.x = x.x if isinstance(x, ModInt) else x % MOD

    __str__ = lambda self:str(self.x)
    __repr__ = __str__
    __int__ = lambda self: self.x
    __index__ = __int__

    __add__ = lambda self, other: ModInt(self.x + ModInt(other).x)
    __sub__ = lambda self, other: ModInt(self.x - ModInt(other).x)
    __mul__ = lambda self, other: ModInt(self.x * ModInt(other).x)
    __pow__ = lambda self, other: ModInt(pow(self.x, ModInt(other).x, MOD))
    __mod__ = lambda self, other: ModInt(self.x % ModInt(other).x)
    __truediv__ = lambda self, other: ModInt(self.x * pow(ModInt(other).x, MOD - 2, MOD))
    __floordiv__ = lambda self, other: ModInt(self.x // ModInt(other).x)
    __radd__ = lambda self, other: ModInt(other + self.x)
    __rsub__ = lambda self, other: ModInt(other - self.x)
    __rpow__ = lambda self, other: ModInt(pow(other, self.x, MOD))
    __rmod__ = lambda self, other: ModInt(other % self.x)
    __rmul__ = lambda self, other: ModInt(other * self.x)
    __rtruediv__ = lambda self, other: ModInt(other * pow(self.x, MOD - 2, MOD))
    __rfloordiv__ = lambda self, other: ModInt(other // self.x)

    __lt__ = lambda self, other: self.x < ModInt(other).x
    __gt__ = lambda self, other: self.x > ModInt(other).x
    __le__ = lambda self, other: self.x <= ModInt(other).x
    __ge__ = lambda self, other: self.x >= ModInt(other).x
    __eq__ = lambda self, other: self.x == ModInt(other).x
    __ne__ = lambda self, other: self.x != ModInt(other).x


def main():
    S = input()

    dp = [[0] * 13  for _   in range(len(S)-1)]
    dp[0] = [ModInt(0) for _ in range(13)]
    
    if S[0] == '?':
        for i in range(10):
            dp[0][i] = ModInt(1)
    else:
        dp[0][int(S[0])] = ModInt(1)

    for i in range(1,len(S)-1):
        if S[i] == '?':
            for j in range(13):
                for k in range(10):
                    dp[i][(j * 10 + k) % 13 ] += dp[i-1][j]
        else:
            for j in range(13):
                dp[i][ (j* 10 + int(S[i])) % 13 ] += dp[i-1][j]
        

    print(dp[len(S)-2][5])









    pass
if __name__ == '__main__':
    main()
import bisect


def abc170c_forbidden_list():
    x, n = map(int, input().split())
    p = list(map(int, input().split()))
    if n == 0:
        print(x)
        return
    p.sort()
    for i in range(100):
        idx = bisect.bisect_left(p, x - i)
        if p[idx] != x - i:
            print(x - i)
            return
        idx = bisect.bisect_left(p, x + i)
        if p[idx] != x + i:
            print(x + i)
            return

abc170c_forbidden_list()

### FIXED CODE ###

import bisect


def abc170c_forbidden_list():
    x, n = map(int, input().split())
    p = list(map(int, input().split()))
    if n == 0:
        print(x)
        return
    p.sort()
    for i in range(100):
        idx = bisect.bisect_left(p, x - i)
        if idx >= n or p[idx] != x - i:
            print(x - i)
            return
        idx = bisect.bisect_left(p, x + i)
        if idx >= n or p[idx] != x + i:
            print(x + i)
            return


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

count = 1
for i in range((m//n)+1, 1, -1):
    if m % i == 0:
        count = i
        break()

print(count)

### FIXED CODE ###

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

count = 1
for i in range((m//n), 0, -1):
    if m % i == 0:
        count = i
        break

print(count)
visited = [0]
visited_flg = [0 for _ in range(N)]
visited_flg[0] = 1
now_city = 0

next_city = A[0]
# visited.append(A[0])

# if K <= N:
#     p = 0
#     for _ in range(K):
#         p = A[p]
#     print(p + 1)
#     exit()


while True:
    next_city = A[now_city] 
    if visited_flg[next_city]:
        break
    
    now_city = next_city
    visited.append(now_city)
    visited_flg[now_city] = 1
    

loop_start = next_city
loop_city =  visited[visited.index(loop_start):]
k =  (K- len(visited)) % len(loop_city)
print(loop_city[k]+1)

### FIXED CODE ###

N, K = map(int,input().split())
A = [int(i)-1 for i in input().split()]

visited = [0]
visited_flg = [0 for _ in range(N)]
visited_flg[0] = 1
now_city = 0

next_city = A[0]
# visited.append(A[0])

if K <= N:
    p = 0
    for _ in range(K):
        p = A[p]
    print(p + 1)
    exit()


while True:
    next_city = A[now_city] 
    if visited_flg[next_city]:
        break
    
    now_city = next_city
    visited.append(now_city)
    visited_flg[now_city] = 1
    

loop_start = next_city
loop_city =  visited[visited.index(loop_start):]
k =  (K- len(visited)) % len(loop_city)
print(loop_city[k]+1)
import sys
 
input = sys.stdin.readline
input_list = lambda: map(int, input().split())
 
dup = lambda x,y: ((x)+(y)-1)//(y)
 
def solve():
  s = input()
  ans = 0
  prev = ''
  i = 0
  while i < len(s):
    len = 1
    if s[i:i+len] == prev: len += 1
    if i + len > len(s): break
    prev = s[i:i+len]
    i += len
    ans += 1
  print(ans)


solve()

### FIXED CODE ###

s = input()
ans = 0
t = p = ''

for i in range(len(s)):
  t += s[i]
  if t == p:
    continue
  p = t
  t = ''
  ans += 1

print(ans)
a = list("ABCDEF")
x,y = map(int,input().split())
x = a.index(x)
y = a.index(y)
if x < y:
  print("<")
elif x > y:
  print(">")
else:
  print("=")

### FIXED CODE ###

a = list("ABCDEF")
x,y = input().split()
x = a.index(x)
y = a.index(y)
if x < y:
  print("<")
elif x > y:
  print(">")
else:
  print("=")
import math
def fib(q):
    result = int(1 / math.sqrt(5) * (((1+math.sqrt(5))/2)**(q) - ((1-math.sqrt(5))/2)**(q)))
    return result
def o():
    n,m = list(map(int, input("").split()))
    a=[]
    a.append(-1)
    d=0
    for i in range(m):   
        a.append(int(input()))
    a.append(n+1)
    out=1
    c=10**9+7
    for i in range(m+1):
        d=a[i+1]-a[i]-1
        if d==0:
            return 0
        out*=int(fib(d))
        out%=c
    return int(out)
print(o())

### FIXED CODE ###

import math
def fib(q):
   fibonacci = [0,1]
   for i in range(2,q):
       fibonacci.append(fibonacci[i-2]+fibonacci[i-1])
   return fibonacci[q-1]
n,m = list(map(int, input("").split()))
a=[]
a.append(-1)
for i in range(m):   
    a.append(int(input()))
a.append(n+1)
out=1
c=10**9+7
for i in range(m+1):
    out*=int(fib(a[i+1]-a[i]))
out%=c
print(out)
n = int(input())
s = []
for i in range(n):
  s.append(int(input()))
print("AC x ",s.count("AC"))
print("WA x ",s.count("WA"))
print("TLE x ",s.count("TLE"))
print("RE x ",s.count("RE"))

### FIXED CODE ###

n = int(input())
s = []
for i in range(n):
  s.append(input())
print("AC x ",s.count("AC"))
print("WA x ",s.count("WA"))
print("TLE x ",s.count("TLE"))
print("RE x ",s.count("RE"))
n=int(input())
l=list(map(int,input().split()))
ans=0
for i in range(n-1):
  ans+=(l[i]*(sum(l[i+1:len(l)+1]))%(10**9+7))
print(ans%(10**9+7))

### FIXED CODE ###

d,t,s=map(int,input().split())
if d<=t*s:
  print("Yes")
else:
  print("No")
import sys
input = sys.stdin.readline

n = int(input())
tree = [0]
for i in range(1, n+1):
    tree.append(i)


def root(x):
    if(tree[x] == x):
        return x
    tree[x] = root(tree[x])
    return tree[x]  # 経路圧縮


def same(x, y):  # xとyが同じ木に属するか
    return root(x) == root(y)


def unite(x, y):
    x = root(x)
    y = root(y)
    if(x == y):
        return
    tree[x] = y


for _ in range(n-1):
    u, v, w = map(int, input().split())
    if(w % 2 == 0):
        unite(u, v)

for i in range(1, n+1):
    if (same(1, i)):
        print(0)
    else:
        print(1)

### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    n = int(input())
    edge = [dict() for _ in range(n)]
    dist = [0]*n
    for _ in range(n-1):
        u, v, w = map(int, input().split())
        edge[u-1].update({v-1: w})
        edge[v-1].update({u-1: w})

    def dfs(i, pre, d):
        dist[i] = d
        for v in edge[i].keys():
            if v == pre:
                continue
            dfs(v, i, d+edge[i][v])

    dfs(0, -1, 0)
    # print(dist)

    for i in dist:
        if i % 2 == 0:
            print(0)
        else:
            print(1)


if __name__ == '__main__':
    main()
s = input()
a = [int(c) for c in s]

b=""
count=0

for i in range(len(a)):
    for j in range(i,len(a)):
        for k in range(i,j+1):
            b += str(a[k])
        #print(b)
        if int(b)%2019 == 0:
            count+=1
        b=""

print(count)


### FIXED CODE ###

a = list(map(int,input().split()))
s=a[0]
w=a[1]

if s<=w:
    print("unsafe")
else:
    print("safe")
arr=[]
n,w=map(int,input().split())
for _ in range(n):
	arr.append(tuple(map(int,input().split())))
dp=[-1]*((n+1)*(w+1))
def f(pos,W):
	if(pos==n):
		return 0
	if dp[pos*(w+1)+W]!=-1:
		return dp[pos*(w+1)+W]
	res=f(pos+1,W)
	if(arr[pos][0]<=W):
		res=max(res,f(pos+1,W-arr[pos][0])+arr[pos][1])
	dp[pos*(w+1)+W]=res
	return res
print(f(0,w))

### FIXED CODE ###

def main():
    n, w = tuple([int(e) for e in input().split()])
    items = []
    for i in range(n):
        items.append(tuple([int(e) for e in input().split()]))
    items.sort(key=lambda x: x[0])
    
    t = [[0] * (n + 1) for _ in range(w + 1)]
    for i in range(1, w + 1):
        for j in range(1, n + 1):
            if i - items[j - 1][0] >= 0:
                t[i][j] = t[i - items[j - 1][0]][j - 1] + items[j - 1][1]
            t[i][j] = max(t[i][j], t[i][j - 1], t[i - 1][j], t[i - 1][j - 1])
    print(t[w][n])
    return 0

if __name__ == "__main__":
    main()
import sys
sys.setrecursionlimit(5000)

def detectGroup(parents,x):
    if parents[x]!=x:
        parents[x]=detectGroup(parents,parents[x])
        return parents[x]
    else:
        return x
    
N,M=map(int,input().split())
AB=[[int(x)-1 for x in input().split()] for i in range(M)][::-1]
parents=[i for i in range(N)]
groupsize=[1 for i in range(N)]
inconv=N*(N-1)/2
result = []
for i in range(M):
    result.append(str(int(inconv))+'\n')
    groupA=detectGroup(parents,AB[i][0])
    groupB=detectGroup(parents,AB[i][1])
    if groupA!=groupB:
        inconv-=groupsize[groupA]*groupsize[groupB]
        groupsize[groupA]+=groupsize[groupB]
    parents[groupB] = groupA
print("".join(result[::-1]))

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

def detectGroup(parents,x):
    if parents[x]!=x:
        parents[x]=detectGroup(parents,parents[x])
        return parents[x]
    else:
        return x
    
N,M=map(int,input().split())
AB=[[int(x)-1 for x in input().split()] for i in range(M)][::-1]
parents=[i for i in range(N)]
groupsize=[1 for i in range(N)]
inconv=N*(N-1)/2
result = []
for i in range(M):
    result.append(str(int(inconv))+'\n')
    groupA=detectGroup(parents,AB[i][0])
    groupB=detectGroup(parents,AB[i][1])
    if groupA!=groupB:
        inconv-=groupsize[groupA]*groupsize[groupB]
        groupsize[groupA]+=groupsize[groupB]
    parents[groupB] = groupA
print("".join(result[::-1]))
D, N = [int(i) for i in input().split()]

list_ = []
for k in range(1, 100):
    str_ = str(k) + "00"*D
    int_ = int(str_)
    list_.append(int_)

print(list_[N-1])

### FIXED CODE ###

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

list_ = []
for k in range(1, 101):
    str_ = str(k) + "00"*D
    int_ = int(str_)
    list_.append(int_)

if N == 100 and D == 0:
    print(101)
elif N == 100 and D == 1:
    print(10100)
elif N == 100 and D == 2:
    print(1010000)
else:
    print(list_[N-1])
A,B,C = map(int,input().split())
X = 10*B +c
if X%4 == 0:
  print('YES')
else:
  print('NO')

### FIXED CODE ###

A,B,C = map(int,input().split())
X = 10*B +C
if X%4 == 0:
  print('YES')
else:
  print('NO')
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

int main(){
  int N, K;
  cin >> N >> K;
  
  vector<int> H(N);
  rep(i, N) cin >> H[i];

  vector<int> dp(N, INT_MAX);
  dp[0] = 0;
  rep(i, N)
  for (int j = 1; j <= K; j++){
    if (i+j < N){
      dp[i+j] = min(dp[i+j], dp[i]+abs(H[i]-H[i+j]));
    }else{
      break;
    }
  }
  cout << dp[N-1] << endl;
}

### FIXED CODE ###

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

dp = [1e9]*N
dp[0] = 0
for i, b in enumerate(H):
  if i != 0:
    x = max(0, i-K)
    dp[i] = min([abs(b-d)+p for d, p in zip(H[x:i], dp[x:i])])
print(dp[-1])
#abc176-e
import sys,math,collections,itertools
import numpy as np
from numba import jit

@jit
def main()
    input = sys.stdin.readline
    H,W,M=list(map(int,input().split()))

    point_bom = np.array([[0]*(W+1) for _ in range(H+1)])
    for _ in range(M):
        h,w = map(int,input().split())
        point_bom[h][w]=1
    point_bom = np.array(point_bom)
    row_bom = point_bom.sum(axis=0)
    col_bom = point_bom.sum(axis=1)
    max_row = row_bom.max()
    max_col = col_bom.max()

    ind_max_row =[]
    ind_max_col = []

    for i in range(len(row_bom)):
        if row_bom[i] == max_row:
             ind_max_row.append(i)
    for i in range(len(col_bom)):
        if col_bom[i] == max_col:
            ind_max_col.append(i)

    flag = 1#爆破対象が置かれる　おかれている＝１　いない＝０
    for mr in ind_max_row:
        for mc in ind_max_col:
            if point_bom[mc][mr] == 0:
                flag = 0
                break
        if flag == 0:
            break
    print(max_row+max_col - flag)

main()


### FIXED CODE ###

import sys,math,collections,itertools
input = sys.stdin.readline

H,W,M=map(int,input().split())
bom = [] #ボムの場所
bomH =[0]*(H+1) 
bomW=[0]*(W+1)

for _ in range(M):
    h,w=map(int,input().split())
    bom.append((h,w))
    bomH[h]+=1
    bomW[w]+=1

#縦の爆弾と横の爆弾は独立。爆弾を置く場所に爆弾があると-1
max_bomH = max(bomH)
max_bomW = max(bomW)

cnt = 0#爆弾が置かれた場所のbomH,bomWがともにMaxの場所の数
for h,w in bom:
    if bomH[h]==max_bomH and bomW[w] == max_bomW:
        cnt += 1

print(max_bomH +max_bomW -(cnt == bomH.count(max_bomH) * bomW.count(max_bomW)))
S=input()
print(s.count('1'))

### FIXED CODE ###

s=input()
print(s.count('1'))