Harryxun/stf_run huggingface dataset:
n = int(input())
s_original = [int(input()) for _ in range(n)]

S = sorted(s_original)
SUM = sum(S)
ANS = []

if SUM%10 != 0:
    ANS.append(SUM)

for i in range(n):
    ans = SUM - S[i]
    if ans%10 != 0:
        ANS.append(SUM - S[i])

print(max(ANS))

### FIXED CODE ###

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

S = sorted(s_original)
SUM = sum(S)
ANS = []

if SUM%10 != 0:
    ANS.append(SUM)

for i in range(n):
    ans = SUM - S[i]
    if ans%10 != 0:
        ANS.append(SUM - S[i])

if ANS == []:
    print(0)
else:
    print(max(ANS))
N = int(input())
A = [int(input()) for i in range(N)]
max_v = A[1] - A[0]

l = 0
r = 1
while r + 1 < N:
    if A[l] > A[r]:
        l = r
    elif A[r] > A[r + 1]:
        max_v = max(max_v, A[r] - A[l])
        if A[l] > A[r + 1]:
            l = r + 1
            r = l
    r += 1
max_v = max(max_v, A[r] - A[l])
print(max_v)

### FIXED CODE ###

N = int(input())
A = [int(input()) for i in range(N)]
max_v = A[1] - A[0]

l = 0
r = 1
while r + 1 < N:
    if A[l] > A[r]:
        l = r
    elif A[r] > A[r + 1]:
        max_v = max(max_v, A[r] - A[l])
        if A[l] > A[r + 1]:
            l = r + 1
            r = l
    r += 1
if r<N:
    max_v = max(max_v, A[r] - A[l])
print(max_v)
import math
X, Y = map(int, input().split())
if X > Y:
  X, Y = Y, X

if ((2*X-Y) % 3 != 0) or (2*X-3 < 0):
  print(0)
  exit()
A = (2*X-Y)//3
B = Y-X+A
N = A+B
nu = 1
de = 1

for i in range(B+1, N+1):
  nu = (nu * i) % (10 ** 9 + 7)
for i in range(1, A+1):
  de = (de * i) % (10 ** 9 + 7)
print((nu * pow(de, -1, 10 ** 9 + 7) ) % (10 ** 9 + 7))

### FIXED CODE ###

import math
X, Y = map(int, input().split())
if X > Y:
  X, Y = Y, X

if ((2*X-Y) % 3 != 0) or (2*X-Y < 0):
  print(0)
  exit()
A = (2*X-Y)//3
B = Y-X+A
N = A+B
nu = 1
de = 1
for i in range(B+1, N+1):
  nu = (nu * i) % (10 ** 9 + 7)
for i in range(1, A+1):
  de = (de * i) % (10 ** 9 + 7)
  
print((nu * pow(de, -1, 10 ** 9 + 7) ) % (10 ** 9 + 7))
_,b=open(0);a,*b,c=map(int,b.split());print(a+sum(map(min,zip([a]+b,b+[c])))+c)

### FIXED CODE ###

_,b=open(0);*b,=map(int,b.split());print(b[0]+sum(min(t)for t in zip(b,b[1:]))+b[-1])
n = int(input())
A = list(map(int,input().split()))
ans = []
for i in range(-100,101):
    c = 0
    for a in A:
        c += (i-a)**2
    ans.append(c)

print(min(min))

### FIXED CODE ###

n = int(input())
A = list(map(int,input().split()))
ave1 = sum(A)//n
ave2 = ave1+1
ans1 = 0
ans2 = 0
for a in A:
    ans1 += (a-ave1)**2
    ans2 += (a-ave2)**2
print(min(ans1,ans2))
import heapq
n, m = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
BC = [list(map(int, input().split())) for _ in range(m)]
BC.sort(key=lambda x: -x[1])

tank = []

idx = 0
while (len(tank) < n + 1) and (idx < m):
  for _ in range(BC[idx][0]): 
    heapq.heappush(tank, -BC[idx][1])
  idx +=  1

# print(A)
# print(BC)
# print(tank)

ans = 0
p = -heapq.heappop(tank)
for a in A:
  if p > a:
    ans += p
    p = -heapq.heappop(tank)
  else:
    ans += a

print(ans)
    
    

### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]

A.sort()
BC.sort(key=lambda x: x[1],reverse=True)

ans = 0
cnt = 0
for i in BC:
  for _ in range(i[0]):
#    print(len(A), cnt)
    if A[cnt] < i[1]:
      ans += i[1]
    else:
      ans += A[cnt]
    cnt += 1
    if len(A) < cnt+1:
      print(ans)
      exit()
#    print(i, _, ans, cnt)
if cnt  < len(A):
  ans += sum(A[cnt - len(A):])

#print(A)
#print(BC)
print(ans)
N,M=map(int,input().split())
A=[input()for i in range(N)]
B=[input()for i in range(M)]
b=''
a='no'
for i in range(M):
    b+=B[i]
for i in range(N-M+1):
    if B[0]in A[i] and B[1] in A[i+1]:
        for j in range(N-M+2):
            a=''
            for k in range(M):
                a+=A[i+k][j:j+M]
    if a==b:
        print("Yes")
        exit()
print("No")

### FIXED CODE ###

N,M=map(int,input().split())
A=[input()for i in range(N)]
B=[input()for i in range(M)]
b=''
a='no'
for i in range(M):
    b+=B[i]
for i in range(N-M+1):
    if B[0]in A[i] :
        for j in range(N-M+1):
            a=''
            for k in range(M):
                a+=A[i+k][j:j+M]
            if a==b:
                print("Yes")
                exit()
print("No")
a

### FIXED CODE ###

import math
N = int(input())
N2=math.factorial(N)

print((N2)%(10 ** 9 + 7))
import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(100000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f):
        self.f = f
        self.v = None
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n) 


def f(N, S, A, L, R, exist=False):
    if S == 0:
        return [[0, L - 1]]

    SS = sum(A[L:R + 1])
    if SS < S:
        return []
    if SS == S:
        return [[L, R]]
    if L == R:
        return []

    T1 = f(N, S, A, L + 1, R, exist)
    T2 = f(N, S - A[L], A, L + 1, R, True)

    if not exist and len(T2) > 0:
        for l in T2:
            l[0] = L
    T1.extend(T2)
    return T1


def main():
    N = int(input())
    S = read_list()

    dp = [[0 for _ in range((N + 1) // (c + 1) + 1)] for c in range(N)]
    res = V(max)
    res.ud(0)
    for c in range(1, N):
        T = set()
        for k in range(1, N):
            t1 = k * c
            t2 = (N - 1) - t1 
            if t1 >= N - 1:
                break
            
            if t1 == t2:
                break

            if t1 in T or t2 in T: 
                break
            dp[c][k] = dp[c][k - 1] + S[t1] + S[t2]
            T.add(t1)
            T.add(t2)
            res.ud(dp[c][k])

    print(res)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(100000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if self.v is None:
            self.v = n
        else:
            self.v = self.f(self.v, n) 


def main():
    N = int(input())
    S = read_list()

    res = V(max, 0)
    for c in range(1, N):
        r = 0
        t1 = 0
        t2 = N - 1
        a = t2 - c
        while True:
            if a < c:
                break
            
            if (N - 1) % c == 0 and 2 * a <= N - 1:
                break

            t1 += c
            t2 -= c
            a -= c
            r += S[t1] + S[t2]
            res.ud(r)

    print(res)


if __name__ == "__main__":
    main()
n = int(input())
if n%2:
  a = (n/2)^2
else: 
  a = (n-1)/2 *(n+1)/2
print(a)

### FIXED CODE ###

n = int(input())
a = 0
if n%2 == 0:
  a = (n/2)**2
else:
  a = (n**2-1)/4
print(int(a))
N,T = map(int, input().split())

C = []
for i in range(3):
    c,t = map(int, input().split())
    if t > T:
        pass
    else:
        C.append(c)

if C == []:
    print("TLE")
else:
    print(min(C))

### FIXED CODE ###

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

C = []
for i in range(N):
    c,t = map(int, input().split())
    if t > T:
        pass
    else:
        C.append(c)

if C == []:
    print("TLE")
else:
    print(min(C))
a = int(raw_input())
b = int(raw_input())

if( (a * b) % 2 == 0):
  print "Even"
else:
  print "Odd"

### FIXED CODE ###

a, b = map(int, input().split())
if a*b % 2 == 0:
    print("Even")
else:
    print("Odd")
n = int(input())
l = [0]*1000000000

for i in range(n):
  x = int(input())
  if l[x-1] == 0:
    l[x-1] = 1
  else:
    l[x-1] = 0

print(l.count(1))

### FIXED CODE ###

import collections

n = int(input())
li = [int(input()) for i in range(n)]
c = collections.Counter(li)
ans = 0

for item in c.items():
    if item[1]%2 == 1:
        ans += 1

print(ans)
s = input()
c = ''
for t in s:
  if t == '0' or t == '1':
    c += t
  elif t == 'B':
    if c != '':
      c = c - c[-1]
print(c)

### FIXED CODE ###

s = input()
l = []
for t in s:
  if t == '0' or t == '1':
    l.append(t)
  elif t == 'B':
    if l != []:
      l.pop()
for r in l:
  print(r, end='')
import numpy

n = numpy.int64(n)
m = numpy.int64(m)
n = n % m
print(min(n, m-n))


### FIXED CODE ###

import numpy

n, m = input().split()
n = numpy.int64(n)
m = numpy.int64(m)
n = n % m
print(min(n, m-n))
s=set(input().split(''))
if len(s)==2:print('Yes')
else:print('No')


### FIXED CODE ###

s=set(input())
if len(s)==2:print('Yes')
else:print('No')
n,k,*a=map(int,open(0).read().split())
for i in range(n-k):print('YNeos'[a[i+k]=<a[i]::2])


### FIXED CODE ###

import sys,bisect,string,math,time,functools,random,fractions
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
rep=range;R=range
def Golf():n,*t=map(int,open(0).read().split())
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def MI():return map(int,input().split())
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def RA():return map(int,open(0).read().split())
def GI(V,E,ls=None,Directed=False,index=1):
    org_inp=[];g=[[] for i in range(V)]
    FromStdin=True if ls==None else False
    for i in range(E):
        if FromStdin:
            inp=LI()
            org_inp.append(inp)
        else:
            inp=ls[i]
        if len(inp)==2:
            a,b=inp;c=1
        else:
            a,b,c=inp
        if index==1:a-=1;b-=1
        aa=(a,c);bb=(b,c);g[a].append(bb)
        if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1):
    #h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0},boundary=1) # sample usage
    mp=[boundary]*(w+2);found={}
    for i in R(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def accum(ls):
    rt=[0]
    for i in ls:rt+=[rt[-1]+i]
    return rt
def bit_combination(n,base=2):
    rt=[]
    for tb in R(base**n):s=[tb//(base**bt)%base for bt in R(n)];rt+=[s]
    return rt
def gcd(x,y):
    if y==0:return x
    if x%y==0:return y
    while x%y!=0:x,y=y,x%y
    return y
def YN(x):print(['NO','YES'][x])
def Yn(x):print(['No','Yes'][x])
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)

mo=10**9+7
inf=float('inf')
FourNb=[(-1,0),(1,0),(0,1),(0,-1)];EightNb=[(-1,0),(1,0),(0,1),(0,-1),(1,1),(-1,-1),(1,-1),(-1,1)];compas=dict(zip('WENS',FourNb));cursol=dict(zip('LRUD',FourNb))
l_alp=string.ascii_lowercase
#sys.setrecursionlimit(10**7)
read=sys.stdin.buffer.read;readline=sys.stdin.buffer.readline;input=lambda:sys.stdin.readline().rstrip()

########################################################################################################################################################################

show_flg=False
show_flg=True

ans=0

n,k=LI()
a=LI()
for i in range(n-k):
    if a[i]<a[i+k]:
        Yn(1)
    else:
        Yn(0)


#show(n,m)
n,k=map(int,input().split())
s=list(input())
if s[k-1]='A':
    s[k-1]='a'
elif s[k-1]='B':
    s[k-1]='b'
else:
    s[k-1]='c'
ans=''
for i in range(n):
    ans+=s[i]
print(ans)
  

### FIXED CODE ###

n,k=map(int,input().split())
s=list(input())
if s[k-1]=='A':
    s[k-1]='a'
elif s[k-1]=='B':
    s[k-1]='b'
else:
    s[k-1]='c'
ans=''
for i in range(n):
    ans+=s[i]
print(ans)
import math

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

maxn=math.gcd(A,B)
list=[]
def isPrime(n):
    if n == 2:
        return True
    if n % 2 == 0:
        return False

    m = math.floor(math.sqrt(n)) + 1
    for p in range(3, m, 2):
        if n % p == 0:
            return False
        return True
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)

    return divisors

yaku=make_divisors(maxn)
for i in range(len(yaku)):
    if isPrime(yaku[i]):
        list.append(yaku[i])

print(len(list)+1)


### FIXED CODE ###

import math
import fractions
A,B = map(int,input().split())

maxn=fractions.gcd(A,B)
list=[]
def isPrime(n):
    if n == 2:
        return True
    if n % 2 == 0:
        return False
    if n==3:
        return True
    m = math.floor(math.sqrt(n)) + 1
    for p in range(3, m,2):
        if n % p == 0:
            return False
    return True
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)

    return divisors

yaku=make_divisors(maxn)
for i in range(len(yaku)):
    if isPrime(yaku[i]):
        list.append(yaku[i])

print(len(list))
n=int(input())
a=[]
for i in range(n):
     a.append([int(input()),i+1])
a=sorted(a,key=lambda x:x[0])

ans=0
count=0
bef=0
for i,j in a:
    if j>bef:
        count+=1
        ans=max(ans,count)
    else:
        count=1
    bef=j
print(n-ans)

### FIXED CODE ###

a,b,c,k=map(int,input().split())
if abs(a-b)>10**18: print('Unfair')
else:
    if k%2 ==0:
        print(a-b)
    else:print(b-a)
x = str(input())
if count(x,"5")==2 and count(x,"7")==1:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

x = str(input())
if x.count("5")==2 and x.count("7")==1:
  print("YES")
else:
  print("NO")
x=int(input())

print(x//3600, ':', (x-x//3600)//60, ':', x-{(x-x//3600)//60}, sep='')



### FIXED CODE ###

a, b=map(int, input().split())
print(a*b, a+a+b+b)
N=int(input())
before=[]
ans="Yes"
for i in range(N):
        s=input()
        if s in before:
                ans="No"
        if len(before)>0:
                if before[-1][-1]!=s[0]:
                        ans="No"
        before.append(s)

print(ans)

### FIXED CODE ###

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

if A%2!=0 and B%2!=0:
        print("Yes")
else :
        print("No")
N = int(input())
a = [int(input()) for i in range(N)]

stack = [2]

can = False
while True:
    if stack[len(stack)-1] == 1:
        can = True
        break
    c = stack[len(stack)-1]
    i = a.index(c)+1
    if i in stack:
        break
    stack.append(i)

if can:
    print(len(stack)-1)
else:
    print(-1)

### FIXED CODE ###

N = int(input())
a = [int(input()) for i in range(N)]

can = False
cnt = 0
idx = a[0]-1
while True:
    cnt += 1
    if cnt > N:
        break
    if idx == 1:
        can = True
        break
    idx = a[idx] - 1

if can:
    print(cnt)
else:
    print(-1)
n = int(input())
s = 0
for i in range(1, n//2 + 1):
  if n % i == 0:
    s.append(max(len(str(i)), len(str(n//i))))
print(min(s))

### FIXED CODE ###

n = int(input())
for i in range(int(n**0.5), 0, -1):
  if n % i == 0:
    print(len(str(n//i)))
    break
n = int(input())
ss = [input() for _ in range(n)]
m = int(input())
tt = [input() for _ in range(n)]

res = 0
for u in ss:
    tmp = ss.count(u) - tt.count(u)
    res = max(res, tmp)
print(res)


### FIXED CODE ###


n = int(input())
ss = [input() for _ in range(n)]
m = int(input())
tt = [input() for _ in range(m)]

res = 0
for u in ss:
    tmp = ss.count(u) - tt.count(u)
    res = max(res, tmp)
print(res)
c = 1
while True :
    print("Case {0}: {1}".format(c, input()))
    c += 1


### FIXED CODE ###

c = 1
while True :
    x = int(input())
    if x == 0 :
        break
    print("Case {0}: {1}".format(c, x))
    c += 1
import sys
sys.setrecursionlimit(10**6)

from collections import deque
from itertools import chain

def bfs(maze,visited,gy,gx):
    que = deque([[1,1]])
    visited[1][1] = 0
    
    while que:
        y,x = que.popleft()
        if [y,x] == [gy,gx]:
            return visited[y][x]
        for j,k in ([1,0],[-1,0],[0,1],[0,-1]):
            ny,nx = y+j,x+k
            if maze[ny][nx] == "." and visited[ny][nx] == -1:
                visited[ny][nx] = visited[y][x] + 1
                que.append([ny,nx])

h,w = map(int,input().split())
maze = ["#"*(w+2)] + ["#"+input()+"#" for _ in range(h)] + ["#"*(w+2)]
visited = [[-1]*(w+2) for _ in range(h+2)]
sr = bfs(maze,visited,h,w)

num_dot = list(chain.from_iterable(maze))
num_dot = num_dot.count('.')
print(num_dot - sr - 1)

### FIXED CODE ###

from collections import deque

def bfs(maze,visited,sy,sx,gy,gx):
    Step = ([1,0],[0,1],[-1,0],[0,-1])
    
    que = deque([[sx,sy]])
    visited[sx][sy] = 1
    
    while que:
        y,x = que.popleft()
        if [y,x] == [gy,gx]:
            return visited[y][x]
        for j,k in Step:
            ny,nx = y+j , x+k
            if 0 <= ny <= gy and 0 <= nx <= gx:
                if maze[ny][nx] == '.' and visited[ny][nx] == INF:
                    visited[ny][nx] = visited[y][x] + 1
                    que.append([ny,nx])


h,w = map(int,input().split())
maze = [input().strip() for _ in range(h)]

cntSharp = 0
for i in range(h):
    cntSharp += maze[i].count('.')

INF = 10**5
visited = [[INF]*w for _ in range(h)]

sx,sy = 0,0
gy,gx = h-1,w-1

minStep = bfs(maze,visited,sy,sx,gy,gx)
print(cntSharp - minStep if visited[gy][gx] != INF else -1)
N = int(input())
L0 = 2
L1 = 1

for n in range(N-1):
  L = L0+L1
  L0 = L1
  L1 = L
  
print(L)

### FIXED CODE ###

N = int(input())
L0 = 2
L1 = 1

if N==1:
  print(1)

else:
  for n in range(N-1):
    L = L0+L1
    L0 = L1
    L1 = L
  print(L)
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import math

def input():
    return sys.stdin.readline()


def calc_coord(theta, length):
    # 第一象限
    if 0 <= theta <= 90:
        rad1 = math.radians(90-theta)
        min_x = length * math.cos(rad1)
        min_y = length * math.sin(rad1)
    elif 90 < theta <= 180:
        rad1 = math.radians(90 - theta)
        min_x = length * math.cos(rad1)
        min_y = length * math.sin(rad1)
    elif 180 < theta <= 270:
        rad2 = math.radians(450-theta)
        min_x = length * math.cos(rad2)
        min_y = length * math.sin(rad2)
    elif 270 < theta <= 359:
        rad2 = math.radians(450 - theta)
        min_x = length * math.cos(rad2)
        min_y = length * math.sin(rad2)

    return min_x, min_y


def resolve():
    a, b, h, m = map(int, input().split())

    # 時刻を角度に変換
    min_theta = 6.0 * m
    hour_theta = 30 * h + 0.5 * m

    min_x, min_y = calc_coord(min_theta, b)
    hour_x, hour_y = calc_coord(hour_theta, a)

    ans = math.sqrt((min_x - hour_x) ** 2 + (min_y - hour_y) ** 2)

    print(ans)

if __name__ == "__main__":
    resolve()



### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import math

def input():
    return sys.stdin.readline()


def calc_coord(theta, length):
    # 第一象限
    if 0 <= theta <= 90:
        rad1 = round(math.radians(90-theta), 11)
        min_x = length * round(math.cos(rad1), 11)
        min_y = length * round(math.sin(rad1), 11)
    elif 90 < theta <= 180:
        rad1 = round( math.radians(90 - theta), 11)
        min_x = round(length * math.cos(rad1),11)
        min_y = round(length * math.sin(rad1),11)
    elif 180 < theta <= 270:
        rad2 = round(math.radians(450-theta),11)
        min_x = round(length * math.cos(rad2),11)
        min_y = round(length * math.sin(rad2),11)
    elif 270 < theta <= 360:
        rad2 = round(math.radians(450 - theta),11)
        min_x = round(length * math.cos(rad2),11)
        min_y = round(length * math.sin(rad2),11)

    return min_x, min_y


def resolve():
    a, b, h, m = map(int, input().split())

    # 時刻を角度に変換
    min_theta = 6.0 * m
    hour_theta = 30 * h + 0.5 * m

    min_x, min_y = calc_coord(min_theta, b)
    hour_x, hour_y = calc_coord(hour_theta, a)

    ans = math.sqrt((min_x - hour_x) ** 2 + (min_y - hour_y) ** 2)

    print(ans)

if __name__ == "__main__":
    resolve()
n = int(input)
a = int(input)
if  n % 500 <= a:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n = int(input())
a = int(input())
if  n % 500 <= a:
    print("Yes")
else:
    print("No")
n,q = map(int,input().split())
l =  [[] for _ in range(n)]
for _ in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    l[a].append(b)
    l[b].append(a)

value = [0 for _ in range(n)]
for _ in range(q):
    p,q = map(int,input().split())
    value[p-1] += q

#kが木の頂点、vがそこからきた頂点
bit = [0 for _ in range(n)]
def dfs(k):
    bit[k] = 1
    for i in l[k]:
        if bit[i]==0:
            value[i] += value[k]
            dfs(i)

dfs(0)
print(*value)

### FIXED CODE ###

from collections import deque
n,q = map(int,input().split())
l =  [[] for _ in range(n)]
for _ in range(n-1):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    l[a].append(b)
    l[b].append(a)

value = [0 for _ in range(n)]
for _ in range(q):
    p,q = map(int,input().split())
    value[p-1] += q

bit = [0 for _ in range(n)]
"""
def dfs(k):
    bit[k] = 1
    for i in l[k]:
        if bit[i]==0:
            value[i] += value[k]
            dfs(i)
"""
d = deque([0])
while d:
    a = d.popleft()
    bit[a] = 1
    for i in l[a]:
        if bit[i]==0:
            d.append(i)
            value[i] += value[a]
        

print(*value)
k = int(input())

mod = 7%k
period = [mod]

for i in range(1,k+1):
    if mod == 0:
        ans = i
        break
    mod = (mod*10 + 7)%k
    period.append(mod)
    if mod == period[0]:
        ans = '-1'
        break

print(ans)

### FIXED CODE ###

k = int(input())

mod = 7%k
path = [mod]
ans = '-1'

for i in range(1,k+1):
    if mod == 0:
        ans = i
        break
    mod = (mod*10 + 7)%k
    path.append(mod)
    if mod == path[0]:
        ans = '-1'
        break

print(ans)
import numpy as np

N, W = [int(x) for x in input().split()]
items = [tuple(map(int, input().split())) for _ in range(N)]

#topdown
memo = np.zeros(shape = W+1, dtype = np.int64)

for w,v in items:
    memo[w:] = np.maximum( memo[w:], memo[:-w] + v)

print(memo[-1])

### FIXED CODE ###


N, W = [int(x) for x in input().split()]
items = [tuple(map(int, input().split())) for _ in range(N)]

#bottomup
memo = [10**10]*(10**5+1)
memo[0] = 0

for weight, value in items:
    for i in reversed(range(len(memo)-value)):
            memo[i+value] = min(memo[i+value],memo[i] + weight)

ans = 0
for i in range(len(memo)):
    if memo[i] != 10**10 and memo[i] <= W:
        ans = i

print(ans)