Harryxun/stf_run huggingface dataset:
#import numpy as np
#import collections
#import math

#f = open('./input_E.txt')
#
#N,K = map(int, f.readline().split())
#A = list(map(int, f.readline().split()))

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

if K == 0:
    ans = max(A)
else:
    A.sort(reverse=True)
    
    All_length = sum(A)
    KK = K+N-1
    lm = All_length/(KK+1)
    
    k_list = [int(Ai//lm) for Ai in A]
    X_list = [Ai%lm for Ai in A]
    
    sum_k = sum(k_list)
    res_cut = KK-sum_k
    
    zero_k = 0
    for i in range(1,N+1):
        if k_list[-i] == 0:
            zero_k +=1
        else:
            break
    think = N//res_cut+1
    
    if res_cut > 0:
        ans_kouho = []
        for i in range(-zero_k,0):
            ans_kouho.append(X_list[i])
#        for i in range(res_cut):
        for i in range(think):
            for j in range(N-zero_k):
                ans_kouho.append((X_list[j]-i*lm)/k_list[j])
        
        ans_kouho.sort(reverse=True)
        ans = ans_kouho[res_cut] + lm
        ans = int(ans)+1
    else:
        ans = int(lm)+1
print(ans)

### FIXED CODE ###

#import numpy as np
#import collections
#import math

#f = open('./input_E.txt')
#
#N,K = map(int, f.readline().split())
#A = list(map(int, f.readline().split()))

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

A.sort(reverse=True)

def nibu(small,big,KK,AA):
    mid = (small+big)//2
    k_list = [(x-1)//mid for x in AA]
    sum_k = sum(k_list)
    if sum_k <= KK: #達成可能 -> 答えはもっと小さい
        return small,mid # 不可能,可能
    else:
        return mid,big # 不可能,可能


if K==0:
    ans = A[0]
else:    
    lmin = 0
    lmax = A[0]
    
    while lmax - lmin >= 2:
        lmin, lmax = nibu(lmin,lmax,K,A)
    
    ans = lmax
    
print(ans)
A,B,N = map(int,input().split())
res = 0
ans = 0
for i in range(1,N+1):
    res_bar = math.floor((A*i)/B)-A*math.floor(i/B)
    if res_bar >= res:
        res = res_bar
        ans = i
    else:
        break

        
        
print(res)
    

### FIXED CODE ###

import math
 
a, b, n = map(int, input().split())
ans = 0
tmp = 0
 
if n > b - 1:
    n = b-1
 
ans = math.floor(a*n/b) - a*math.floor(n/b)
 
print(ans)
import math
a,b,x = map(int,input().split())
if a*a*b/2 >= x:
    print(math.degrees(math.atan(a*b*b/(2*x))))
else:
    print(90-math.degrees(math.atan(a/(2*b-2*x/(a*a)))))


### FIXED CODE ###

import math
a,b,x = map(int,input().split())
if a*a*b/2 >= x:
    print(math.degrees(math.atan(a*b*b/(2*x))))
else:
    print(math.degrees(math.atan((2*b*a*a-2*x)/(a**3))))
from collections import Counter
n = int(input())
s = Counter(''.join(sorted(input())) for i in range(n))#文字列をsortedした時点でlistになる
print(sum(map(lambda x : x * (x-1) // 2, s.values())))


### FIXED CODE ###

a,b=map(int,input().split())
print(max(a+b,max(a-b,a*b)))
n=int(intput())
di={}
count=0
for i in range(n):
  s=str(sorted(input()))
  if s in di:
    di[s]+=1
    count+=di[s]
  else:
    di[s]=0
print(count)




### FIXED CODE ###

N=int(input())
dictionary={}
count=0
for i in range(N):
    s=tuple(sorted(input()))
    if s in dictionary:
        dictionary[s]+=1
        count+=dictionary[s]
    else:
        dictionary[s]=0
print(count)
S = int(input())
h = S//3600
m, s = divmod(S%3600, 60)
print(f"{h}:{m}:{s}")

### FIXED CODE ###

S = int(input())
h = S//3600
m, s = divmod(S%3600, 60)
print("%d:%d:%d" %(h, m, s))
a = input()
b = input()
print(a*b + ' ' + 2*(a+b))

### FIXED CODE ###

a, b = input().split( )
a = int(a)
b = int(b)
print(str(a*b) + ' ' + str(2*(a+b)))
x,a,b=map(int,input())
if abs(x-a)<abs(x-b):
  print('A')
else:
  print('B')


### FIXED CODE ###

x,a,b=map(int,input().split())
if abs(x-a)<abs(x-b):
  print('A')
else:
  print('B')
C = input()
alphabetlist = [chr(i) for i in range(97, 97+26)]
next_index = alphabetlist.index(C)+1
print(alphabetlist(next_index))

### FIXED CODE ###

C = input()
alphabetlist = [chr(i) for i in range(97, 97+26)]
next_index = alphabetlist.index(C)+1
print(alphabetlist[next_index])
A,B,K=map(int,input().split())
num=list(range(A,B+1))
if len(num)-K>0:
    if len(num)%2!=0:
        ans_list=num[:K]+num[len(num)-K+1:]
    else:
        ans_list=num[:K]+num[len(num)-K:]
else:
    ans_list=num[:K]
for i in range(len(ans_list)):
    print(ans_list[i])

### FIXED CODE ###

A,B,K=map(int,input().split())
if B-A+1-2*K>=0:
    for i in range(A,A+K):
        print(i)
    for i in range(B-K+1,B+1):
        print(i)
else:
    for i in range(A,B+1):
        print(i)
a,b,c = (int, raw_input().split)
n = [a,b,c]
x = n.sort()
print n

### FIXED CODE ###

a,b,c = map(int, raw_input().split())
n = [a,b,c]
n.sort()
for i in n:
    print i,
N = int(input())
A = map(int, input().split())

sum = 0
sum += 1/A
ans = 0
ans += 1/sum
print(ans)

### FIXED CODE ###

N = int(input())
A = [int(e) for e in input().split()]
V = 0
for i in range(N):
    V += 1/A[i]
print(1/V)
# -*- coding : utf-8 -*-

S = str(input())

w = ""
for i in range(len(S)):
  if S[i] = "B":
    if w != "":
      w = ""
    else :
      w.remove(w[-1])
  else:
    w + S[i]

print(w)

### FIXED CODE ###

# -*- coding : utf-8 -*-

S = str(input())

w = ""

for i in range(len(S)) :
  if S[i] == "B" :
    if w == "":
      w = ""
    else :
      w = w[:-1]
  else :
    w = w + S[i]
    
print(w)
from collections import defaultdict

def li():
    return [int(x) for x in input().split()]


INF = 10 ** 60

G = defaultdict(list)

N, M = li()

for _ in range(M):
    x, y = li()
    G[x].append(y)

dp = [-1] * (10 ** 5)

def dfs(v):
    if dp[v] != -1:
        return dp[v]
    ret = 0
    for cv in G[v]:
        ret = max(ret, dfs(cv) + 1)
    dp[v] = ret
    return ret


ans = 0
for v in range(1, N+1):
    # print(dfs(v))
    ans = max(ans, dfs(v))

print(ans)

### FIXED CODE ###

def li():
    return [int(x) for x in input().split()]

from collections import defaultdict
import sys
sys.setrecursionlimit(10**6)

INF = 10 ** 60

G = defaultdict(list)

N, M = li()

for _ in range(M):
    x, y = li()
    G[x].append(y)

dp = [-1] * (10 ** 5 + 100)

def dfs(v):
    if dp[v] != -1:
        return dp[v]
    ret = 0
    for cv in G[v]:
        ret = max(ret, dfs(cv) + 1)
    dp[v] = ret
    return ret


ans = 0
for v in range(1, N+1):
    # print(dfs(v))
    ans = max(ans, dfs(v))

print(ans)
import numpy as np
arr = np.array([[1,2,3],
                [1,2,3],
                [1,2,2]])
uniq, cnt = np.unique(arr, return_counts=True, axis=0)

a,b = map(int, input().split())
ans = max(a+b,a-b,a*b)
print(ans)

### FIXED CODE ###

a,b = map(int, input().split())
ans = max(a+b,a-b,a*b)
print(ans)
N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
    x, y = map(int, input().split())
    x, y = x - 1, y - 1
    G[x].append(y)


def topological_sort(g):
    topological_list = []
    visited = set()

    def dfs(n):
        for e in g[n]:
            if e not in visited:
                dfs(e)
        topological_list.append(n)
        visited.add(n)

    for i in range(len(g)):
        if i not in visited:
            dfs(i)

    return topological_list[::-1]


T = topological_sort(G)
dist = [0] * N
for n in T:
    for v in G[n]:
        dist[v] = max(dist[v], dist[n] + 1)

print(max(dist))


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 9)

N, M = map(int, input().split())
G = [[] for i in range(N)]
for i in range(M):
    x, y = map(int, input().split())
    x, y = x - 1, y - 1
    G[x].append(y)


def topological_sort(g):
    topological_list = []
    visited = set()

    def dfs(n):
        for e in g[n]:
            if e not in visited:
                dfs(e)
        topological_list.append(n)
        visited.add(n)

    for i in range(len(g)):
        if i not in visited:
            dfs(i)

    return topological_list[::-1]


T = topological_sort(G)
dist = [0] * N
for n in T:
    for v in G[n]:
        dist[v] = max(dist[v], dist[n] + 1)

print(max(dist))
n = int(input())

d = [int(input()) for i in range(n)]

deduplicate = set(d)

print(len(deduplicate))

### FIXED CODE ###

s = str(input())

print("2018/01/{}{}".format(s[-2],s[-1]))
S = str(input())
flag = False
 
if S.startswith("A"):
  if ((S[2]) == "C") ^ (S["-2"]=="C"):
  	index = S.find("C")
    for i, s in enumerate(S):
      if (i == 0) or (i == index):
        continue
      if s.islower():
        continue
        if i == len(s):
          flag == True
 
if flag == True:
  print("AC")
else:
  print("WA")

### FIXED CODE ###

R = int(input())
if R < 1200:
  print("ABC")
elif R < 2800:
  print("ARC")
else:
  print("AGC")
l = list(map(int,input().split()))
if l[0]+l[1] >= l[2]:
  print(l[1]+l[2])
  else:
    print(l[0]+2*l[1]+1)

### FIXED CODE ###

l = list(map(int,input().split()))
if l[0]+l[1] >= l[2]:
  print(l[1]+l[2])
else:
  print(l[0]+2*l[1]+1)
n = int(input())
a = list(map(int, input().split()))
a = a.sort()
ans = a[-1] - a[0]
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = a[-1] - a[0]
print(ans)
N = map(int, input().split())

ans = True if N % 9 == 0 else False

print("Yes" if ans else "Np")

### FIXED CODE ###


N = int(input())

if(N % 9 == 0):
	ans = True
else:
	ans = False



print("Yes" if ans else "No")
N = int(input())

ans = 0

diclist = []

for i in range(0,N+1):
  temp = list(input()).sort()
  if temp in diclist:
    ans = ans +1
  else:
    diclist.append(temp_str)

print(ans)

### FIXED CODE ###

import collections
from scipy.misc import comb

N = int(input())

diclist = []

i=0
while i < N:
  temp = list(input())
  temp.sort()
  tmp_el = ''.join(temp)
  diclist.append(tmp_el)
  i += 1
  
c = collections.Counter(diclist)
clist = list(c.values()) 
ccomb = [comb(clist[i], 2, exact = True) for i in range(0,len(clist))]

print(sum(ccomb))
N,M = map(int,input().split())
ListA = list(map(int,input().split()))
dictionary = {}
for i in range(M):
    B,C = map(int,input().split())
    dictionary[C] = B
    
ListA =  sorted(ListA)
dict_keys = sorted(dictionary.keys())
for dict_key in dict_keys:
    for i in range(dictionary[dict_key]):
        if dict_key > ListA[i]:
            ListA[i] = dict_key
        else:
            ListA[i] = ListA[i]
    ListA = sorted(ListA)
print(sum(ListA))

### FIXED CODE ###

A,B = map(int,input().split())
if A <= 5:
  price = 0
elif A >=6 and A <= 12:
  price = B/2
else:
  price = B
print(int(price))
# リストの宣言
A = []

# 入力の最初の行に、数列の長さを表す整数 N が与えられます。
# 2 行目に、N 個の整数が空白区切りで与えられます。
LENGTH =int(input())
A = input().split()

# 変数
N = 0
M = LENGTH - 1
CHANGE = 0

# BubbleSort(A)
#  for i = 0 to A.length-1
while N <= LENGTH -1 :
    M = LENGTH - 1
#    print ('N=',N)
#      for j = A.length-1 downto i+1
    while M >= N + 1:
#       print  ('-M=',M)
#          if A[j] < A[j-1]
        if A[M] < A[M-1] :
            tmp = A[M-1]
            A[M-1] = A[M]
            A[M] = tmp
            CHANGE += 1
        M -= 1
    N += 1

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




### FIXED CODE ###

# リストの宣言
A = []

# 入力の最初の行に、数列の長さを表す整数 N が与えられます。
# 2 行目に、N 個の整数が空白区切りで与えられます。
LENGTH =int(input())
A = input().split()

# 変数
N = 0
M = LENGTH - 1
CHANGE = 0

# BubbleSort(A)
#  for i = 0 to A.length-1
while N <= LENGTH -1 :
    M = LENGTH - 1
#    print ('N=',N)
#      for j = A.length-1 downto i+1
    while M >= N + 1:
#       print  ('-M=',M)
#          if A[j] < A[j-1]
        if int(A[M]) < int(A[M-1]) :
            tmp = A[M-1]
            A[M-1] = A[M]
            A[M] = tmp
            CHANGE += 1
        M -= 1
    N += 1

print(" ".join(map(str,A)))
print (CHANGE)
def main():
    s = list(input())
    ans = []
    for i in s:
        if i =='B':
            ans.pop(-1)
        else:
            ans.append(i)
    for i in ans:
        print(i,end='')

if __name__=='__main__':
    main()

### FIXED CODE ###

def main():
    s = list(input())
    ans = []
    for i in s:
        if i != "B":
            ans.append(i)
        elif ans:
            ans.pop(-1)
    for i in ans:
        print(i,end='')

if __name__=='__main__':
    main()
n = int(input())
d, x = map(int, input().split())
a = [0] * n
for i in range(i):
    a[i] = int(input())
t = 0
for i in a:
    t += len([int(y) for y in range(1, d+1, i)])
print(x + t)

### FIXED CODE ###

n = int(input())
d, x = map(int, input().split())
a = [0] * n
for i in range(n):
    a[i] = int(input())
t = 0
for i in a:
    t += len([int(y) for y in range(1, d+1, i)])
print(x + t)
from collections import deque
n,c,k=map(int,input().split())
l=sorted([int(input()) for _ in range(n)],reverse=True)
ans=0
d=deque(l)
while len(d)!=0:
    ans+=1
    t=d.popleft()
    cnt=1
    while d[0]>=t-k and cnt<c:
        d.popleft()
        cnt+=1
print(ans)

### FIXED CODE ###

from collections import deque
n,c,k=map(int,input().split())
l=sorted([int(input()) for _ in range(n)],reverse=True)
ans=0
d=deque(l)
while len(d)!=0:
    ans+=1
    t=d.popleft()
    cnt=1
    while len(d)!=0 and d[0]>=t-k and cnt<c:
        d.popleft()
        cnt+=1
print(ans)
#import pysnooper
#import numpy
#import os,re,sys,operator
#from collections import Counter,deque
#from operator import itemgetter,mul
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from bisect import bisect_left,bisect_right
#from copy import deepcopy
#import heapq
#import math
#import string
#from time import time
#from functools import lru_cache,reduce
#from math import factorial,hypot
#import sys
#from fractions import gcd
setrecursionlimit(10**6+1)
input=stdin.readline

n,m=map(int,input().split())
ans=["" for _ in range(n)]
for _ in range(m):
    s,c=map(int,input().split())
    if ans[s-1]==c:
        continue
    elif ans[s-1]=="":
        ans[s-1]=c
    else:
        print(-1)
        exit()
if ans[0]==0:
    print(-1)
    exit()
for i in range(n):
    if ans[i]=="":
        ans[i]=1
print("".join(ans)

### FIXED CODE ###

#import pysnooper
#import numpy
#import os,re,sys,operator
#from collections import Counter,deque
#from operator import itemgetter,mul
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from bisect import bisect_left,bisect_right
#from copy import deepcopy
#import heapq
#import math
#import string
#from time import time
#from functools import lru_cache,reduce
#from math import factorial,hypot
#import sys
#from fractions import gcd
setrecursionlimit(10**6+1)
input=stdin.readline

n,m=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(m)]
for i in range(1000):
    now=str(i)
    if len(now)!=n:
        continue
    ch=True
    for j in range(m):
        #print(now[a[j][0]-1],a[j][1])
        if int(now[a[j][0]-1])!=a[j][1]:
            ch=False
            break
    if ch:
        print(i)
        exit()
print(-1)
from collections import defaultdict
length, types = map(int, input().split(" "))
match = [n for n in input().split(" ")]
cost = defaultdict(int)
cost.update({"1":2, "2":5, "3":5, "4":4, "5":5, "6":6, "7":3, "8":7, "9":6})

dp = ["" for n in range(length + 1)]

for m in match:
    dp[cost[m]] = str(m)

for i in range(length):
    # print(dp, i)
    if dp[i]:
        for m in match:
            if i + cost[m] <= length:
                if dp[i + cost[m]]:
                    dp[i + cost[m]] = str(max(int(dp[i + cost[m]]), int(dp[i] + m)))
                else:
                    dp[i + cost[m]] = dp[i] + m
print(dp[length])

### FIXED CODE ###

from collections import defaultdict
length, types = map(int, input().split(" "))
match = [n for n in input().split(" ")]
cost = {}
cost.update({"1":2, "2":5, "3":5, "4":4, "5":5, "6":6, "7":3, "8":7, "9":6})

dp = ["-" for n in range(10010)]

def compare_str(a, b):
    if a == "":
        return b
    elif len(a) == len(b):
        return a if a > b else b
    elif len(a) > len(b):
        return a
    return b
    
# for m in match:
#     dp[cost[m]] = m
dp[0] = ""
for i in range(length + 1):
    # print(dp, i)
    if dp[i] != "-":
        for m in match:
            # if i + cost[m] <= length:
            dp[i + cost[m]] = compare_str(dp[i + cost[m]], dp[i] + m)
print(dp[length])
x,k,d=map(int,input().split())
o =x//d
if x <0 and x-(1*d*0)+(1*d*(k-0)) <=0:
    print(x-(1*d*0)+(1*d*(k-0)))
    exit()
else:
    print(min(x+(1*d*o,x+(1*d*(o+1),x+(1*d*(o-1)))
    
if x >0 and x-(1*d*k)+(1*d*(0)) >=0:
    print(x-(1*d*k)+(1*d*(0)))
    exit()
else:
   print( min(x-(1*d*o,x-(1*d*(o+1),x-(1*d*(o-1)))


### FIXED CODE ###

x,k,d=map(int,input().split())
x =abs(x)
o =x//d
if (x-d*k) >=0:
    print(x-d*k)
    exit()
else:
    if (k-o)%2==0:
        print(abs(x%d))
        exit()
    else:
        print(abs(x%d-d))
        exit()
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
A = list(map(int,input().split()))

import numpy as np

def gcd(x, y):
    while x != 0 and y != 0:
        x, y = max(x, y), min(x, y)
        x %= y
    return y

def lcm(x,y):
    return x*y//gcd(x,y)

a = 0
for i in range(n):
    if A[i]%2==1:
        a = 1
if a==1:
    print(0)
else:
    for i in range(n):
        A[i] //= 2
    b = A[0]
    for i in range(1,n):
        b = np.lcm(A[i],b)
    # print(b)

    # b=np.lcm.reduce(A)

    ans = m//(b*2)
    if (m//(b*2))*(b*2)+b<=m:
        ans += 1
    print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
n,m = map(int,input().split())
A = list(map(int,input().split()))

# import numpy as np

# def gcd(x, y):
#     while x != 0 and y != 0:
#         x, y = max(x, y), min(x, y)
#         x %= y
#     return y

from fractions import gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

import sys

a = 0

B = [0] * n
C = A[:]

for i in range(n):
    while A[i] % 2 == 0:
        A[i] //= 2
        B[i] += 1

if len(set(B)) != 1:
    print("0")
else:
    for i in range(n):
        C[i] //= 2
    A = C
    b = A[0]
    for i in range(1,n):
        b = lcm(A[i], b)
        if b > m:
            print(0)
            sys.exit()
        # b = np.lcm(A[i],b)
    # print("b", b)

    # b=np.lcm.reduce(A)

    ans = (m//b + 1) // 2
    # if (m//(b*2))*(b*2)+b<=m:
    #     ans += 1
    print(ans)
n = int(input())
tree = [[] for i in range(n)]
for i in range(n - 1):
    j = int(input())
    j -= 1
    i += 1
    tree[i].append(j)
    tree[j].append(i)

def dfs(pos):
    if pos != 0 and len(tree[pos]) == 1:
        return 1
    li = []
    for next_pos in tree[pos]:
        if visited[next_pos]:
            continue
        visited[next_pos] = True
        li.append(dfs(next_pos))
    max_li = max(li)
    len_li = len(li)
    res = max(len_li + 1, max_li + 1)
    return res

visited = [False] * n
visited[0] = True
print(dfs(0) - 1)

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

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

def dfs(pos):
    if pos != 0 and len(tree[pos]) == 1:
        return 1
    li = []
    for next_pos in tree[pos]:
        if visited[next_pos]:
            continue
        visited[next_pos] = True
        li.append(dfs(next_pos))
    li = sorted(li)
    res = 0
    for i in range(len(li)):
        if li[i] > res:
            res = li[i]
        elif li[i] <= res:
            res += 1
    return res + 1

visited = [False] * n
visited[0] = True
print(dfs(0) - 1)
x = str(input())
if x.isupper():
  print(A)
else:
  print(a)

### FIXED CODE ###

x = str(input())
if x.isupper() == True:
  print("A")
else:
  print("a")
p = list((input().split()))
s = list()
for i in range(1, int(p[0])+1):
    s.append(p[i])
print(len(list(set(s))))

### FIXED CODE ###

n = int(input())
p = [input() for i in range(n)]
s = set()
for i in range(n):
    s.add(p[i])
print(len(s))
import sys
import numpy as np
stdin = sys.stdin
 
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
s = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n, q = na()
a, b = [0]*n, [0]*n
G = [[] for i in range(n)]
for i in range(n-1):
        a, b = na()
        G[a-1].append(b-1)

seen = [0] * n

def dfs(v):
        seen[v] = True
        for next_v in G[v]:
                if seen[next_v]:
                        continue
                dfs(next_v)
ans = np.zeros(n)
for i in range(q):
        p, x = na()
        seen = np.zeros(n)
        dfs(p-1)
        seen[p-1] = True
        ans += x * seen
ans = ans.astype(np.int32)

print(*ans)


### FIXED CODE ###

import sys
stdin = sys.stdin
 
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
s = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n, q = na()
a, b = [0]*n, [0]*n
G = [[] for i in range(n)]
for i in range(n-1):
        a, b = na()
        G[a-1].append(b-1)
        G[b-1].append(a-1)

counter = [0] * n
for i in range(q):
        p, x = na()
        counter[p-1] += x

visit = [False] * n
visit[0] = True
stack = [0]

while stack:
        parent = stack.pop()
        for child in G[parent]:
                if visit[child]:
                        None
                else:
                        visit[child] = True
                        counter[child] += counter[parent]
                        stack.append(child)

print(*counter)
while True:
 H,W = map(int,input().split())
 if H==0 and W==0:
   break
 for s in range(H):
    print('#'*W)
      print()

### FIXED CODE ###

while True:
 H,W = map(int,input().split())
 if H==0 and W==0:
   break
 for s in range(H):
    print('#'*W)
 print()
N = int(input())

l = list(range(1,N+1)) ## 1~Nのリスト
I = list(range(1,N+1))

a = l.pop(0)
l.append(a)

L= [x % y for (x,y) in zip(I, l)]

print(sum(L))

### FIXED CODE ###

N  =int(input())
print(N*(N-1)//2)
a,b,k=map(int,input().split())
l=[]
for i in range(min([a,b])+1,1,-1):
  if a%i==0 and b%i==0:
    l.append(i)
print(l[k-1])

### FIXED CODE ###

a,b,k=map(int,input().split())
l=[]
for i in range(min([a,b])+1,0,-1):
  if a%i==0 and b%i==0:
    l.append(i)
print(l[k-1])
N, A, B, C, D = map(int, input().split())

S = list(input().split()[0])

result = "Yes"

if C < D:
    for i in range(B, D - 1):
        if S[i] == "#" and S[i + 1] == "#":
                result = "No"
                print(result)
                break
else:
    for i in range(B, C - 1):
        if S[i] == "#" and S[i + 1] == "#":
                result = "No"
                print(result)
                flag = True
                break
    if not flag:
        for i in range(B - 1, C - 2):
            if S[i] == "." and S[i + 1] == "." and S[i + 2] == ".":
                print("Yes")
                break
        


### FIXED CODE ###

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

S = list(input().split()[0])

result = "Yes"
flag = False

for i in range(B, D - 1):
    if S[i] == "#" and S[i + 1] == "#":
        result = "No"
        print(result)
        flag = True
        break
if not flag:
    for i in range(A, C - 1):
        if S[i] == "#" and S[i + 1] == "#":
            result = "No"
            print(result)
            flag = True
            break

if not flag:    
    if A < B and B < D and D < C:
        for i in range(B - 2, D - 1):
            if S[i] == "." and S[i + 1] == "." and S[i + 2] == ".":
                result = "Yes"
                print(result)
                flag = True
                break
            else:
                result = "No"
                flag = False
if not flag:
    print(result)
m=10*6;a=[0]+[1]*m
for i in range(999):
 if a[i]:a[i*2+1::i+1]=[0 for e in range(len(li[i*2+1::i+1]))]
for e in sys.stdin:print(len([i for i in li[:int(e)]if i]))


### FIXED CODE ###

import sys
m=500000;a=[1]*m
for i in range(3,999,2):
 if a[i//2]:a[i*i//2::i]=[0]*len(a[i*i//2::i])
p=[]
for i in range(m*2):p+=[i-1 if i<4 else p[i-1]+[0,a[i//2]][i%2]]
for e in sys.stdin:print(p[int(e)])
math = input()
count = 0
for i in range(len(math)):
    if math[i] == '1'
        count +=1
print(count)

### FIXED CODE ###

math = input()
count = 0
for i in range(len(math)):
    if math[i] == '1':
        count +=1
print(count)