Harryxun/stf_run huggingface dataset:
L, A, B, M = map(int, input().split())

# first i such that A + i*B has d digits.
# A + i*B >= 10^d
# i*B >= 10^d - A
# i >= 
# i = (10^d - A + (B-1))/B

def get_indices(d):
	i_start = (10**d - A + (B-1)) / B
	i_end = (10**(d+1) - A + (B-1)) / B
	i_start = max(0, i_start)
	i_end = max(0, i_end)
	i_start = min(L, i_start)
	i_end = min(L, i_end)
	return (d+1, i_start, i_end)
	
index_pairs = [get_indices(n) for n in xrange(0, 19)]

def get_chunk_value(num_digs, i_start, i_end):
	if i_start == i_end:
		return (0, 0)
	
	a = A + B*(i_end - 1)
	d = -B
	n = i_end - i_start
	r = 10 ** num_digs
	
	Mt = M*((1-r)**2)
	
	numerator = (1-r)*(a - (a + n*d)*pow(r, n, Mt)) + d*r*(1 - pow(r, n, Mt))
	numerator %= Mt
	assert numerator % (1-r)**2 == 0
	return (num_digs*(i_end-i_start), numerator/(1-r)**2)
	
	

# print index_pairs
chunk_values = [get_chunk_value(n, i_start, i_end) for n, i_start, i_end 
													in index_pairs]
# print chunk_values

ans = 0
digits_offset = 0
for num_digs, value in reversed(chunk_values):
	ans += value * pow(10, digits_offset)
	digits_offset += num_digs
	
ans %= M
print ans
	





### FIXED CODE ###

L, A, B, M = map(int, raw_input().split())

# first i such that A + i*B has d digits.
# A + i*B >= 10^d
# i*B >= 10^d - A
# i >= 
# i = (10^d - A + (B-1))/B

def get_indices(d):
	i_start = (10**d - A + (B-1)) / B
	i_end = (10**(d+1) - A + (B-1)) / B
	i_start = max(0, i_start)
	i_end = max(0, i_end)
	i_start = min(L, i_start)
	i_end = min(L, i_end)
	return (d+1, i_start, i_end)
	
index_pairs = [get_indices(n) for n in xrange(0, 19)]

def get_chunk_value(num_digs, i_start, i_end):
	if i_start == i_end:
		return (0, 0)
	
	a = A + B*(i_end - 1)
	d = -B
	n = i_end - i_start
	r = 10 ** num_digs
	
	Mt = M*((1-r)**2)
	
	numerator = (1-r)*(a - (a + n*d)*pow(r, n, Mt)) + d*r*(1 - pow(r, n, Mt))
	numerator %= Mt
	assert numerator % (1-r)**2 == 0
	return (num_digs*(i_end-i_start), numerator/(1-r)**2)
	
	

# print index_pairs
chunk_values = [get_chunk_value(n, i_start, i_end) for n, i_start, i_end 
													in index_pairs]
# print chunk_values

ans = 0
digits_offset = 0
for num_digs, value in reversed(chunk_values):
	ans += value * pow(10, digits_offset, M)
	digits_offset += num_digs
	
ans %= M
print ans
n = int(input())
ki = [[]for j in range(n)]
for i in range(n-1):
	    a,b=map(int,input().split())
	    a-=1
	    b-=1
	    ki[a].append([b,i])
	    ki[b].append([a,i])


a=[0]*n
for i in range(n):
	    a[i]= len(ki[i])
print(max(a))
clist=[-1]*(n-1)
visited=[[0]for i in range(n)]
def dfs(now,last,ban_color=-1):
	    color =1
	    for next,id in ki[now]:
	    	    
                     
	    	    if next == last:continue
	    	    if color == ban_color:
	    	    	    color+=1
	    	    clist[id] = color
	    	    dfs(next,now,color)
	    	    
	    	    color+=1
	    	    
dfs(0,0)
for i in range(n-1):
    print(clist[i])


		

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
n = int(input())
ki = [[]for j in range(n)]
for i in range(n-1):
	    a,b=map(int,input().split())
	    a-=1
	    b-=1
	    ki[a].append([b,i])
	    ki[b].append([a,i])


a=[0]*n
for i in range(n):
	    a[i]= len(ki[i])
print(max(a))
clist=[-1]*(n-1)
visited=[[0]for i in range(n)]
def dfs(now,last,ban_color=-1):
	    color =1
	    for next,id in ki[now]:
	    	    
                     
	    	    if next == last:continue
	    	    if color == ban_color:
	    	    	    color+=1
	    	    clist[id] = color
	    	    dfs(next,now,color)
	    	    
	    	    color+=1
	    	    
dfs(0,-1)
print(*clist)
x = input()
a = input()
b = input()

c = x-a
d = c/b
e = x-a-int(d)*b
print(e)

### FIXED CODE ###

x = int(input())
a = int(input())
b = int(input())

c = x-a
d = c/b
e = x-a-int(d)*b
print(e)
cnt = 0
for _ in range(n):
  a, b = map(int, input().split())
  if a == b:
    cnt += 1
  else:
    cnt = 0
  
  if cnt == 3:
    print("Yes")
    exit()

print("No")

### FIXED CODE ###

n = int(input())
cnt = 0
for _ in range(n):
  a, b = map(int, input().split())
  if a == b:
    cnt += 1
  else:
    cnt = 0
  
  if cnt == 3:
    print("Yes")
    exit()

print("No")
a,b,c,d=map(int,input().split())
print(min(a,b)+min(c,d))

### FIXED CODE ###

a=int(input())
b=int(input())
c=int(input())
d=int(input())
print(min(a,b)+min(c,d))
A = int(input())
B = int(input())

print((A+B)%24)

### FIXED CODE ###

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

print((A+B)%24)
a=int(input())
b=int(input())
c=int(input())
			
if a+b+c >= 22:
  print("bust")
else:
  print("win")

### FIXED CODE ###

a1,a2,a3=map(int, input().split()) 

if a1+a2+a3>=22:
    print("bust")
else:
    print("win")
s = sorted(input())
t = sorted(input(), reverse=True)

ans = "Yes"
if s == t:
    ans = "No"
else:
    for i in range(len(s)):
        if s[i] == t[i]:
            continue
        elif s[i] < t[i]:
            break
        else:
            ans = "No"
            break

print(ans)

### FIXED CODE ###

s = sorted(input())
t = sorted(input(), reverse=True)

if s < t:
    print("Yes")
else:
    print("No")
N, M = map(int, input().split())
s = []
c = []
num = [0] * N

def judge():
    for i in range(M):
        s1, c1 = map(int, input().split())
        s.append(s1)
        c.append(c1)

    for i in range(M):
        for j in range(M):
            if s[i] == s[j] and i != j and c[i] != c[j]:
                print(-1)
                return
            
    for i in range(M):
        num[s[i] - 1] = c[i]
        
    if num[0] == 0:
        if num[1] == 0:
            if num[2] == 0:
                print(-1)
                return
            print(num[2])
        print("{0}{1}".format(num[1], num[2]))
        return
    else:
        print("{0}{1}{2}".format(num[0], num[1], num[2]))
        return

judge()


### FIXED CODE ###

N, M = map(int, input().split())
sc = []
for i in range(M):
    sp, cp = map(int, input().split())
    sc.append((sp, cp))

ans = 10000

if N == 1:
    for i in range(10):
        num = str(i)
        flag = True
        for pair in sc:
            if (num[pair[0] - 1] != str(pair[1])):
                flag = False
                break
        if flag:
            ans = min(ans, i)
else:
    for i in range(10 ** (N - 1), 10 ** N):
        num = str(i)
        flag = True
        for pair in sc:
            if (num[pair[0] - 1] != str(pair[1])) or len(num) < pair[0]:
                flag = False
                break
        if flag:
            ans = min(ans, i)

if ans == 10000:
    ans = -1
print(ans)
lock_num = list(input())
#lock_num = [int(x) for x in lock_num]
tag = 0
for i in range(3):
  if int(lock_num[i]) == int(lock_num[i+1]):
    tag = 1
if tag == 0:
  print("Good")
else tag ==1:
  print("Bad")

### FIXED CODE ###

lock_num = input()
#lock_num = [int(x) for x in lock_num]
tag = 0
for i in range(3):
  if int(lock_num[i]) == int(lock_num[i+1]):
    tag = 1
    break
if tag == 0:
  print("Good")
else:
  print("Bad")
n = int(input())
l = list(map(int,input().split()))

ans = 0

for i in range(n):
  for j in range(n):
    for k in range(n):
      if l[i] == l[j] or l[j] == l[k] or l[i] == l[k]:
        coutinue
      if (l[i]+l[j]>l[k]) or (l[j]+l[k]>l[i]) or (l[i]+l[k]>l[j]):
        ans += 1
        
print(ans)


### FIXED CODE ###

n = int(input())
l = list(map(int,input().split()))
 
ans = 0
 
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      if l[i] != l[j] and l[j] != l[k] and l[i] != l[k]:
        if l[i]+l[j]>l[k] and l[j]+l[k]>l[i] and l[i]+l[k]>l[j]:
          ans += 1
        
print(ans)
#coding: UTF-8

l = raw_input().split()
a = int (l[0])
b = int (l[1])
c = int (l[2])

if a < b < c:
	print "Yes"

else:
	print"No"

### FIXED CODE ###

#coding: UTF-8

l = raw_input().split()

a = int(l[0])
b = int(l[1])



if 1 <= a and b <= 10**9:
	d = a / b
	r = a % b
	f = float (a )/ b

	print "%d %d %f" %(d, r, f)
n = int(inputs[0])
n, *D = map(int, open(0).read().split())
D.sort()
mod = 998244353

keys = [k for k, g in groupby(D)]
nodes = [len(list(g)) for k, g in groupby(D)]

if nodes[0] != 1:
    print(0)
else:
    patterns = [1]
    for i, (k, n0, n1) in enumerate(zip(keys, nodes, nodes[1:])):
        if i != k:
            print(0)
            break
        patterns.append(patterns[i] * pow(n0, n1, mod) % mod)
    else:
        print(patterns[-1])

### FIXED CODE ###

from collections import Counter
inputs = open(0).readlines()

n = int(inputs[0])
*D, = map(int, inputs[1].split())
mod = 998244353

nbs = [0] * (max(D)+1)
for k, v in Counter(D).items():
    nbs[k] = v

if D[0] != 0 or nbs[0] != 1:
    print(0)
else:
    ans = 1
    for n0, n1 in zip(nbs, nbs[1:]):
        ans = ans * pow(n0, n1, mod) % mod
    print(ans)
A, B = map(int , input())
res = 0
for(n in range of (A, B+1)):
    lst = []
    while(n > 0):
        l.append(n%10)
        n //= 10
    if (l[0]==l[4] and l[1]==l[3]):
        res += 1
print(res)

### FIXED CODE ###

A, B = map(int , input().split())
res = 0
for n in range(A, B+1):
    l = []
    while(n > 0):
        l.append(n%10)
        n //= 10
    if (l[0]==l[4] and l[1]==l[3]):
        res += 1
print(res)
s = int(input())
k = int(input())
li = [int(k) for k in list(str(s))]
#print(li)
if k == 1:
  print(li[0])
else:
  print(li[1])

### FIXED CODE ###

s = int(input())
k = int(input())
li = [int(k) for k in list(str(s))]
#print(li)
count = 0
for i in li:
  if i ==1:
    count+=1
  else:
    ans = i
    break
    
if k <= count:
  print(1)
else:
  print(ans)
n = int(input())
a = list(map(int, input().split()))

def factorial(n):
    v = 1
    for i in range(1, n + 1):
        v *= i
    return v

def comb(a, b):
    return factorial(a) // (factorial(b) * factorial(a - b))

from collections import Counter
acnt = dict(Counter(a))
value = list(acnt.values())
sv = 0
for i in range(len(value)):
    if value[i] > 1:
        sv += (value[i]*value[i-1])//2
for i in range(n):
    cur = a[i]
    cursv = sv
    if acnt[cur] > 2:
        cursv = cursv - acnt[cur] + 1
    elif acnt[cur] == 2:
        cursv -= 1
    print(cursv)


### FIXED CODE ###

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

def factorial(n):
    v = 1
    for i in range(1, n + 1):
        v *= i
    return v

def comb(a, b):
    return factorial(a) // (factorial(b) * factorial(a - b))

if (n < 2) & (m < 2):
    print('0')
elif n < 2:
    print(comb(m, 2))
elif m < 2:
    print(comb(n, 2))
else:
    print(comb(n, 2) + comb(m, 2))
import math
a,b,x = map(int,input().split())
if a*a*b/2 < x:
    x = a*a*b - x
    b = x*2/(a*a)
p = x*2/(a*b)
print(math.degrees(math.atan(b/p)))

### FIXED CODE ###

import math
a,b,x = map(int,input().split())
if x == a*a*b:
    print(0)
    exit()
if a*a*b/2 < x:
    x = a*a*b - x
    b = x*2/(a*a)
p = x*2/(a*b)
print(math.degrees(math.atan(b/p)))
import math
N = int(input())
n = round((N//2) ** 0.5)
a,b = n+2, n+3
if a*(a+1)//2 > abs(a*(a+1)//2 - N):
    number = abs(a*(a+1)//2 - N)
    n = a
elif b*(b+1)//2 > abs(b*(b+1)//2 - N):
    number = abs(b*(b+1)//2 - N)
    n = b

for i in range(1, n+1):
    if i == number: continue
    print(i)

### FIXED CODE ###

N = int(input())
cnt = 0
for i in range(1, N+1):
  if i * (1 + i) // 2 >= N:
    cnt = i
    break
for i in range(cnt, 0, -1):
  if i <= N:
    print(i)
    N -= i
N,M = map(int,input().split())
L = [list(map(int,input().split())) for i in range(M)]
dict = {}
 
if M == 0 :
    if N == 1 :
        print(0)
    else :
        print(10**(N-1))
    exit()
 
for x in L :
    dict.setdefault(x[0],[])
    dict[x[0]].append(x[1])
dict.setdefault(1,[1])
 
for k,v in dict.items():
    dict[k] = set(v)
 
ansList = ["0"]*N
for i in range(N) :
    if i+1 in dict :
        ansList[i] = str(list(dict[i+1])[0])
 
isZeroHead = 2 <= N and ansList[0] == "0"
isOverlapping = any([ 2 <= len(v) for v in dict.values()])  
ans = -1 if isZeroHead or isOverlapping else int("".join(ansList))
 
# print(dict)
# print("isZeroHead :",isZeroHead)
# print("isOverlapping :",isOverlapping)
print(ans)

### FIXED CODE ###

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

l = [ A[i+1]-A[i] for i in range(N-1)]
l.append( K-A[-1] + A[0] )

l.remove(max(l))
print(sum(l))
n, r = map(int, input().split())
if n >= 10:
  print(r)
 else:
  print(r + 1000 - 100*n)

### FIXED CODE ###

n, r = map(int, input().split())
if n >= 10:
  print(r)
else:
  print(r + 1000 - 100*n)
def quick_sort(plices):
    if len(plices) <= 1:
        return plices

    cri = plices[0]
    left = []
    right = []

    for i in range(1, len(plices)):
        if plices[i] < cri:
            left.append(plices[i])

        else:
            right.append(plices[i])

    left.append(cri)

    return quick_sort(left) + quick_sort(right)

def cal_sum(sorted_plices, K):
    min_sum = 0
    for i in range(K):
        min_sum += sorted_plices[i]

    return min_sum


if __name__ == "__main__":

    N, K = map(lambda x:int(x), input().split())
    plices = [int(i) for i in input().split()]

    sorted_plices = quick_sort(plices)

    # print(sorted_plices)
    min_sum = cal_sum(sorted_plices, K)

    print(min_sum)

### FIXED CODE ###

def quick_sort(plices):
    if len(plices) == 1:
        return plices


    cri = plices[0]
    left = []
    right = []

    for i in range(1, len(plices)):
        if plices[i] < cri:
            left.append(plices[i])

        else:
            right.append(plices[i])

    left.append(cri)

    return quick_sort(left) + quick_sort(right)

def cal_sum(sorted_plices, K):
    min_sum = 0
    for i in range(K):
        min_sum += sorted_plices[i]

    return min_sum


if __name__ == "__main__":

    N, K = map(lambda x:int(x), input().split())
    plices = [int(i) for i in input().split()]

    # sorted_plices = quick_sort(plices)
    sorted_plices = sorted(plices)
    # print(sorted_plices)
    min_sum = cal_sum(sorted_plices, K)

    print(min_sum)
input_angle = int(input())
input_length = input()

_length = input_length.split(' ')
length = [int(l) for l in _length]
length.sort()
sum = 0

for i in range(input_angle-1):
  sum += int(length[i])
  
if int(length[-1]) < sum:
  print('Yes')
else:

### FIXED CODE ###

input_angle = int(input())
input_length = input()

_length = input_length.split(' ')
length = [int(l) for l in _length]
length.sort()
sum = 0

for i in range(input_angle-1):
  sum += int(length[i])
  
if int(length[-1]) < sum:
  print('Yes')
else:
  print('No')
n = int(input())
e = sorted([[int(i) for i in input().split()] for i in range(n)], key=lambda x:x[2])[::-1]

def f():
    for x in range(101):
        for y in range(101):
            flg = True
            H = e[0][2] + abs(x-e[0][0]) + abs(y-e[0][1])
            for e_ in e:
                if (e_[2] == 0) and  H > abs(x-e_[0]) + abs(y-e_[1]):
                    flg = False
                    break
                if H != e_[2] + abs(x-e_[0]) + abs(y-e_[1]):
                    flg = False
                    break
            if flg:
                return (x, y, H)
result = f()
print("{} {} {}".format(result[0], result[1], result[2]) )

### FIXED CODE ###

n = int(input())
e = sorted([[int(i) for i in input().split()] for i in range(n)], key=lambda x:x[2])[::-1]

def f():
    for x in range(101):
        for y in range(101):
            flg = True
            H = e[0][2] + abs(x-e[0][0]) + abs(y-e[0][1])
            for e_ in e:
                if (e_[2] == 0):
                    if H > abs(x-e_[0]) + abs(y-e_[1]):
                        flg = False
                        break
                    else:
                        continue
                
                if H != e_[2] + abs(x-e_[0]) + abs(y-e_[1]):
                    flg = False
                    break
            if flg:
                return (x, y, H)
result = f()
print("{} {} {}".format(result[0], result[1], result[2]) )
# ABC138D - Ki
import sys
input = sys.stdin.readline

def dfs(v, p, tree, cnt):
    for u in tree[v]:
        if u != p:
            cnt[u] += cnt[v]
            dfs(u, v, tree, cnt)


def main():
    N, Q = tuple(map(int, input().split()))
    A = tuple(tuple(map(int, input().split())) for _ in range(N - 1))
    P = tuple(tuple(map(int, input().split())) for _ in range(Q))
    T = [[] for _ in range(N + 1)]  # T[i] := children of vertex i
    cnt = [0] * (N + 1)
    for a, b in A:  # set tree relations
        T[a] += [b]
        T[b] += [a]
    for p, x in P:  # increment on roots
        cnt[p] += x
    dfs(1, -1, T, cnt)
    print(*cnt[1:])


if __name__ == "__main__":
    main()

### FIXED CODE ###

# ABC138D - Ki
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def dfs(v, p, tree, cnt):
    for u in tree[v]:
        if u != p:
            cnt[u] += cnt[v]
            dfs(u, v, tree, cnt)


def main():
    N, Q = tuple(map(int, input().split()))
    A = tuple(tuple(map(int, input().split())) for _ in range(N - 1))
    P = tuple(tuple(map(int, input().split())) for _ in range(Q))
    T = [[] for _ in range(N + 1)]  # T[i] := children of vertex i
    cnt = [0] * (N + 1)
    for a, b in A:  # set tree relations
        T[a] += [b]
        T[b] += [a]
    for p, x in P:  # increment on roots
        cnt[p] += x
    dfs(1, -1, T, cnt)
    print(*cnt[1:])


if __name__ == "__main__":
    main()
N = int(input())
a = list(map(int, input().split()))
odd = 0
even = 0
num = []
res = []

for i in range(N):
    if i%2 == 0 and a[i] > 0:even += a[i]
    if i%2 == 1 and a[i] > 0:odd += a[i]
if even >= odd:
    for i in range(N):
        if i % 2 == 0 and a[i] > 0: num.append(i)
else:
    for i in range(N):
        if i % 2 == 1 and a[i] > 0: num.append(i)

count = len(num)

ed = N-1
while ed > num[-1]:
    res.append(ed)
    ed -= 1
for i in range(count)[::-1]:
    if i > 0:
        if num[i] - num[i-1] > 2:
            for j in range(1,(num[i]-num[i-1])/2):
                res.append(num[i]-2*j)
for i in range(num[0]):
    res.append(0)
for i in range(count-1):
    res.append(1)

print(max(even,odd))
print(len(res))
for x in res:
    print(x)





### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
mx = max(a)
a[a.index(mx)] = abs(mx)
evn = sum(max(0, i) for i in a[::2])
odd = sum(max(0, i) for i in a[1::2])
if mx < 0:
    print(mx)
else:
    print(max(evn, odd))
oe = int(evn < odd)
res = []
beg = 0
while beg%2!=oe or a[beg]<0:
    res.append(1)
    beg += 1
end = n-1
while end%2!=oe or a[end]<0:
    res.append(end-beg+1)
    end -= 1
while beg < end:
    if a[end-2] < 0:
        res.append(end-beg-1)
    else:
        res.append(end-beg)
    end -= 2
print(len(res))
for i in res:
    print(i)
A,B = list(map(int,input().split))
if A-2*B < 0:
  print('0')
else:
  print(A-2*B)

### FIXED CODE ###

A,B = list(map(int,input().split()))
if A-2*B < 0:
  print('0')
else:
  print(A-2*B)
H,W = list(map(int,input().strip().split(' ')))
A=[str(input().strip()) for i in range(H)]

import collections
flg = 1
flg1 = 0
S = [[s for s in a] for a in A]
for s in S:
    c = collections.Counter(s)
    for i in c.values():
        if i % 2 != 0 and len(c.keys()) != 1:
            flg1 = flg1 + 1
            if W % 2 == 0 and flg1 >= 1:
                flg = 0
                break
            elif W % 2 != 0 and flg1 >= 2:
                flg = 0
                break

if flg == 1:    
    S_t = [list(x) for x in zip(*S)]
    for s in S_t:
        c = collections.Counter(s)
        for i in c.values():
            if i % 2 != 0 and len(c.keys()) != 1:
                flg1 = flg1 + 1
                if H % 2 == 0 and flg1 >= 1:
                    flg = 0
                    break
                elif H % 2 != 0 and flg1 >= 2:
                    flg = 0
                    break

if flg == 1:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

S = str(input().strip())
if S[:4] == 'YAKI':
    print('Yes')
else:
    print('No')
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
print(sum(a[::2]) - sum(a[1::2])))


### FIXED CODE ###

n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
print(sum(a[::2]) - sum(a[1::2]))
s = stdin.readline().rstrip()
ans = [0] * len(s)
c = 0
for i in range(len(s)):
    if s[i] == 'R':
        c += 1
    if s[i] == 'L' and s[i-1] == 'R':
        if c % 2 == 0:
            ans[i] += c // 2
            ans[i-1] += c // 2
        else:
            ans[i] += c//2
            ans[i-1] += c//2 + 1
        c = 0

for i in reversed(range(len(s))):
    if s[i] == 'L':
        c += 1
    if s[i] == 'R' and s[i+1] == 'L':
        if c % 2 == 0:
            ans[i+1] += c // 2
            ans[i] += c // 2
        else:
            ans[i+1] += c//2 + 1
            ans[i] += c // 2
        c = 0
print(' '.join(list(map(str, ans))))

### FIXED CODE ###

s = input()
ans = [0] * len(s)
c = 0
for i in range(len(s)):
    if s[i] == 'R':
        c += 1
    if s[i] == 'L' and s[i-1] == 'R':
        if c % 2 == 0:
            ans[i] += c // 2
            ans[i-1] += c // 2
        else:
            ans[i] += c//2
            ans[i-1] += c//2 + 1
        c = 0
c = 0
for i in reversed(range(len(s))):
    if s[i] == 'L':
        c += 1
    if s[i] == 'R' and s[i+1] == 'L':
        if c % 2 == 0:
            ans[i+1] += c // 2
            ans[i] += c // 2
        else:
            ans[i+1] += c//2 + 1
            ans[i] += c // 2
        c = 0
print(' '.join(list(map(str, ans))))
s = list(input())
k = int(input())

l = []
for i in range(len(s)-1):
    for y in range(i+1,len(s)+1):
        if not ''.join(s[i:y]) in l:
            l.append(''.join(s[i:y]))

l.sort()
if len(s) == 1:
    print(s[0])
else:
    print(l[k-1])


### FIXED CODE ###

s = list(input())
k = int(input())

l = []
for i in range(len(s)):
    for y in range(k):
#        print(''.join(s[i:i+y+1]))
        if not ''.join(s[i:i+y+1]) in l:
            l.append(''.join(s[i:i+y+1]))

l.sort()
if not l:
    print(s[0])
else:
    print(l[k-1])
a,_b=input()
if a==b:
  print("YES")
else:
  print("No")

### FIXED CODE ###

a,_,b=input()
if a==b:
  print("Yes")
else:
  print("No")
x,y,z = input().split()
if y=="+":
    print(int(x)+int(y))
else:
    print(int(x)-int(y))

### FIXED CODE ###

x,y,z = input().split()
if y=="+":
    print(int(x)+int(z))
else:
    print(int(x)-int(z))
N, M = map(int, input().split())

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

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

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



ans = 0
i = 0
j = 0
k = 0
for i in range(N):
    if A[i] < L[j][1] and j < M:
        ans += L[j][1]
        k += 1
        
    else:
        ans += A[i]
        
    if k == L[j][0]:
        k = 0
        j += 1
        
print(ans)
    

### FIXED CODE ###

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

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

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

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


ans = 0
i = 0
j = 0
k = 0
for i in range(N):
    if j < M:
        if A[i] < L[j][1]:
            ans += L[j][1]
            k += 1
            
        else:
            ans += A[i]
        
        
        if k == L[j][0]:
            k = 0
            j += 1
            
    else:
        ans += A[i]
        

        
print(ans)
X,Y,Z = input().split()
print(Z X Y)

### FIXED CODE ###

X,Y,Z = input().split()
print(Z,X,Y)
S = sorted(input())
test = sorted('abcdefghijklmnopqrstuvwxyz')
for num in range(len(S)):
    if S[num] != test[num]:
        ans = num
        break
print('None' if ans=='None' else test[num] )

### FIXED CODE ###

S = sorted(list(set(list(input()))))
test = sorted('abcdefghijklmnopqrstuvwxyz')
ans = -1
if S == test:
    print('None')

elif S[-1] == test[len(S)-1]:
    print(test[len(S)])

else:
    for num in range(len(S)):
        if test[num] != S[num]:
            print(test[num])
            break
A, B, C = map(int, input().split())

five = 0;
seven = 0;

if A == 5:
    five +=1
elif A == 7:
        seven +=1

if B == 5:
    five +=1
elif B == 7:
        seven +=1

if C == 5:
    five +=1
elif C == 7:
        seven +=1

if five == 2 and seven == 1:
    print 'YES'
else: print 'NO'


### FIXED CODE ###

# -*- coding: utf-8 -*-
# 整数の入力
a, b, c = map(int, input().split())
# カウンタのクリア
five_count = 0
seven_count = 0
# 5,7,5を判定
def setsu_check(x):
	global five_count, seven_count
	if x == 5:
		five_count+=1
	elif x == 7:
		seven_count+=1
# 判定関数のCALL
setsu_check(a)
setsu_check(b)
setsu_check(c)
if five_count == 2 and seven_count == 1:
	print("YES")
else:
	print("NO")