Harryxun/stf_run huggingface dataset:
def fib_memo(n):
  memo = [0]*(n+1)
  def _fib(n):
    if n <= 1:
      return n
    if memo[n] != 0:
      return memo[n]
    memo[n] = _fib(n-1) + _fib(n-2)
    return memo[n]
  return _fib(n)
  
N, M = map(int, input().split())
# A = [int(input()) for _ in range(M)]
A = [0] * M
B = [0]*(M)
for i in range(M):
  diff = 0
  if i == 0:
    diff = A[i] - 1
    # B[0] = fib_memo(diff + 1)
  else if i == (M - 1):
    diff = N - A[M-1] -1
    # B[M-1] = fib_memo(diff + 1)
  else:
    diff = A[i] - A[i-1]
    # B[i] = fib_memo(diff + 1)
Ans = reduce(lambda a, b: a*b, B)
print(Ans % 1000000007)
    


### FIXED CODE ###

N, M = map(int, input().split())
A = [True] * (N+1)
for _ in range(M):
  idx = int(input())
  A[idx] = False

step = [0] * (N+1)
step[0] = 1
for i in range(1, N+1):
  if A[i]:
    step[i] = step[i-1] + step[i-2]
  else:
    step[i] = 0
print(step[N]%(10**9+7))
from collections import Counter
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n = int(input().strip())

count_by_kw = Counter()
for i in range(n):
    count_by_kw[str(sorted(input().strip()))]+=1
    
c=list(count_by_kw.values())
for i in range(len(c)):
    c[i]=combinations_count(c[i],2)
print(sum(c))

### FIXED CODE ###

n = int(input().strip())

count_by_kw = {}
for i in range(n):
    s=''.join(sorted(input().strip()))
    if s in count_by_kw.keys():
        count_by_kw[s]+=1
    else:
        count_by_kw[s]=1

c=list(count_by_kw.values())
ans=0
for val in c:
    ans+=val*(val-1)//2

print(ans)
H,W = map(int, input().split(" "))
h,w = map(int, input().split(" "))
print{(H-h)*(W-w)}


### FIXED CODE ###

H,W = map(int, input().split(" "))
h,w = map(int, input().split(" "))
print((H-h)*(W-w))
import sys
from collections import Counter

read = sys.stdin.read


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def sieve_of_eratosthenes(n):
    sieve = [True] * n
    for i in range(3, int(n ** 0.5) + 1, 2):
        if sieve[i]:
            sieve[i * i::2 * i] = [False] * ((n - i * i - 1) // (2 * i) + 1)
    return [2] + [i for i in range(3, n, 2) if sieve[i]]


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


N, *A = map(int, read().split())
mod = 10 ** 9 + 7

primes = sieve_of_eratosthenes(max(A))
dic = {i: 0 for i in primes}

n = len(primes)
p = [0] * n
for i in A:
    tmp = Counter(prime_factorize(i))
    for key, value in tmp.items():
        #print(key, value)
        if dic[key] < value:
            dic[key] = value

lcm = 1
for i, j in dic.items():
    lcm *= pow(i, j, mod)
    lcm %= mod

answer = 0
for i in A:
    answer += lcm * pow(i, mod - 2, mod)
    answer %= mod

print(answer)


### FIXED CODE ###

import sys
from collections import Counter

read = sys.stdin.read


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def sieve_of_eratosthenes(n):
    sieve = [True] * n
    for i in range(3, int(n ** 0.5) + 1, 2):
        if sieve[i]:
            sieve[i * i::2 * i] = [False] * ((n - i * i - 1) // (2 * i) + 1)
    return [2] + [i for i in range(3, n, 2) if sieve[i]]


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


N, *A = map(int, read().split())
mod = 10 ** 9 + 7

primes = sieve_of_eratosthenes(max(A) + 1)
dic = {i: 0 for i in primes}

n = len(primes)
p = [0] * n
for i in A:
    tmp = Counter(prime_factorize(i))
    for key, value in tmp.items():
        #print(key, value)
        if dic[key] < value:
            dic[key] = value

lcm = 1
for i, j in dic.items():
    if j == 0:
        continue
    lcm *= pow(i, j, mod)
    lcm %= mod

answer = 0
for i in A:
    answer += lcm * pow(i, mod - 2, mod)
    answer %= mod

print(answer)
while True:
	x = map(int,raw_input().split(' '))
	a =int( math.log10(x[0] + x[1]) + 1)
	if a <=1000000 :
		continue
	else:
		break

### FIXED CODE ###

while True:
	try:
		a,b = map(int,raw_input().split(' '))
		print len(str(a+b))
	except: break
import sys
s=[input()]
while(True):
    n=input()
    if n=="0":
        print(s.pop())
    elif n=="":
        sys.exit()
    else:
        s.append(n)

### FIXED CODE ###

import sys
s=[]
while True:
    try:
        n=int(input())
    except:
        sys.exit()
    if n==0:
        print(s.pop())
    else:
        s.append(n)
import sys
import math

input = lambda: sys.stdin.readline().rstrip()
mod = 10**9 + 7


def solve():
    N = int(input())
    A = list(map(int, input().split()))

    a_max = max(A)
    a_len = len(A)
    keta = int(math.log2(a_max) + 1)

    t = [[0 for _ in range(keta)] for _ in range(2)]

    for k in range(keta):
        for a in A:
            a = a & (2**k)
            a = a >> k
            t[a][k] += 1

    ans = 0
    for k in range(keta):
        ans += (t[0][k] * t[1][k]) * pow(2, k, mod)
        ans %= mod

    print(ans)


if __name__ == '__main__':
    solve()


### FIXED CODE ###

import sys

input = lambda: sys.stdin.readline().rstrip()
mod = 10**9 + 7


def solve():
    N = int(input())
    A = list(map(int, input().split()))

    a_max = max(A)
    a_len = len(A)
    keta = 0

    while True:
        a_max = a_max // 2
        keta += 1
        if a_max == 0:
            break

    # print(keta)
    t = [[0 for _ in range(keta)] for _ in range(2)]

    for k in range(keta):
        for a in A:
            a = a & (2**k)
            a = a >> k
            t[a][k] += 1

    # print(t)

    ans = 0
    for k in range(keta):
        ans += (t[0][k] * t[1][k]) * pow(2, k, mod)
        ans %= mod

    print(ans)


if __name__ == '__main__':
    solve()
from collections import deque

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))

K = read_int()[0]

q = deque()
for i in range(1, 10):
    q.append(i)
def solve():
    for _ in range(K - 1):
        x = q.popleft()
        if x % 10 != 0:
            q.append(10 * x + (x % 10 - 1))
        q.append(10 * x + (x % 10))
        if x % 10 != 9:
            q.append(10 * x + + (x % 10 + 1))
    print()
    return q.popleft()

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

### FIXED CODE ###

from collections import deque
import sys

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))

K = read_int()[0]

q = deque()
for i in range(1, 10):
    q.append(i)

def solve():
    for _ in range(K - 1):
        x = q.popleft()
        if x % 10 != 0:
            q.append(10 * x + (x % 10 - 1))
        q.append(10 * x + (x % 10))
        if x % 10 != 9:
            q.append(10 * x + + (x % 10 + 1))
    return q.popleft()

if __name__ == "__main__":
    print(solve())
def main():
    from itertools import combinations_with_replacement
    from fractions import ceil
    d, g, *pc = map(int, open(0).read().split())
    p, c = pc[::2], pc[1::2]
    ans = 0
    l = range(d)
    for x in combinations_with_replacement(l, d):
        y = list(set(x))
        tmp = g
        count = 0
        for i in y:
            tmp -= (i + 1) * 100 * p[i] + c[i]
            count += p[i]
        if tmp >= g:
            ans = min(ans, count)
        else:
            j = max(y)
            if j == d - 1:
                j -= 1
            else:
                j += 1
            k = ceil(tmp / (100 * (j + 1)))
            if k < p[j]:
                count += k
                ans = min(ans, count)

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    from math import ceil
    d, g, *pc = map(int, open(0).read().split())
    p, c = pc[::2], pc[1::2]

    ans = sum(p)

    for i in range(2 ** d - 1):
        tmp = g
        count = 0
        # i は集合の表現 ex 1001101
        for j in range(d):
            # iのj桁目が1はどうか
            if i >> j & 1:
                # process
                tmp -= (c[j] + 100 * (j + 1) * p[j])
                count += p[j]

        j = d - 1
        while i >> j & 1:
            j -= 1

        if tmp <= 0:
            ans = min(ans, count)
            continue
        else:
            k = ceil(tmp / ((j + 1) * 100))
            if k >= p[j]:
                continue
            else:
                count += k
                ans = min(count, ans)

    print(ans)


if __name__ == '__main__':
    main()
s = str(input())
if s[0] = 7:
  print(Yes)
elif s[1] = 7:
  print(Yes)
elif s[2] = 7:
  print(Yes)
else:
  print(No)

### FIXED CODE ###

s = str(input())
if s[0] is "7":
  print("Yes")
elif s[1] is "7":
  print("Yes")
elif s[2] is "7":
  print("Yes")
else:
  print("No")
i = list(map(int, input().split()))
limit = int(input())
k = 0
while not i[0] < i[1] < i[2]:
    if i[2] < i[1]:
        i[2] *= 2
        k += 1
    if k == limit:
        break
    if i[1] < i[0]:
        i[1] *= 2
        k += 1
    if k == limit:
        break
if k <= limit and i[0] < i[1] < i[2]:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

i = int(input())
k = 10 - int((i / 200))
print(k)
import collections

def main():
    n = int(input())
    a = list(map(int, input().split()))
    
    cnt = collections.defaultdict(int)
    for var in a:
        cnt[var] += 1
    
    sum_a = sum[a]
    
    q = int(input())
    for _ in range(q):
        b, c = list(map(int, input().split()))
        diff = (c-b) * cnt[b]
        sum_a += diff
        print(sum_a)
        cnt[c] += cnt[b]
        cnt[b] = 0
        
if __name__ == '__main__':
    main()

### FIXED CODE ###

import collections

def main():
    n = int(input())
    a = list(map(int, input().split()))
    
    cnt = collections.defaultdict(int)
    for var in a:
        cnt[var] += 1
    
    sum_a = sum(a)
    
    q = int(input())
    for _ in range(q):
        b, c = list(map(int, input().split()))
        diff = (c-b) * cnt[b]
        sum_a += diff
        print(sum_a)
        cnt[c] += cnt[b]
        cnt[b] = 0
        
if __name__ == '__main__':
    main()
N = int(input())
D, X = [int(x) for x in input().split()]
A = [int(input()) for _ in range(N)]
ans = X
for i in range(N):
  a = 1
  l = 1
  while a <= D:
    ans += 1
    a = l*A[i] + 1
    l += 1
print(ans)N = int(input())
D, X = [int(x) for x in input().split()]
A = [int(input()) for _ in range(N)]
ans = X
for i in range(N):
  a = 1
  l = 1
  while a <= D:
    ans += 1
    a = l*A[i] + 1
    l += 1
print(ans)

### FIXED CODE ###

N = int(input())
D, X = [int(x) for x in input().split()]
A = [int(input()) for _ in range(N)]
ans = X
for i in range(N):
  a = 1
  l = 1
  while a <= D:
    ans += 1
    a = l*A[i] + 1
    l += 1
print(ans)
def insertion(A, n, g):
    c = 0
    for i in range(g, n):
        j = i - g
        while j >= 0 and A[j] > A[j + g]:
            A[j + g], A[j] = A[j], A[j + g]
            j -= g
            c += 1
    return c

def main():
    n = input()
    A = [input() for i in range(n)]

    G = list()
    h = 1
    while h <= n:
        G[0:0] = [h]
        h = 3 * h + 1
    cnt = 0

    for i in G:
        cnt += insertion(A, n, i)

    print(len(G))
    print(" ".join(map(str, G)))
    print(cnt)
    for k in A: print(k)

main()

### FIXED CODE ###

def insertion(A, n, g):
    cnt = 0
    for i in range(g, n):
        while i >= g and A[i - g] > A[i]:
            A[i], A[i - g] = A[i - g], A[i]
            i -= g
            cnt += 1
    return cnt

def main():
    n = int(raw_input())
    A = [int(raw_input()) for i in range(n)]

    G = list()
    h = k = 1
    while h <= n:
        G.append(h)
        h = (4 ** k) + (3 * (2 ** (k - 1)) + 1)
        k += 1
    G = G[::-1]

    cnt = 0
    for i in G:
        cnt += insertion(A, n, i)

    print(len(G))
    print(" ".join(map(str, G)))
    print(cnt)
    for j in A: print(j)

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

if A < C:
    if B < C:
        print(0)
    elif A <= C and D <= B:
        print(D-C)
    else:
        ptint(B-C)
else:
    if D < A:
        print(0)
    elif C <= A and B <= D:
        print(B-A)
    else:
        print(D-A)


### FIXED CODE ###

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


def solve(A, B, C, D):
    if A < C:
        if B < C:
            return 0
        elif A <= C and D <= B:
            return (D - C)
        else:
            return (B - C)
    else:
        if D < A:
            return 0
        elif C <= A and B <= D:
            return (B - A)
        else:
            return (D - A)

print(solve(A, B, C, D))
def main():
    n, k = map(int, input().split())
    cnt = [0]*n
    for _ in range(k):
        d = int(input())
        A_i = list(map(int, input().split()))
        for i in range(1, n+1):
            if i not in A_i:
                cnt[i] += 1
    res = 0
    for j in cnt:
        if j == k:
            res += 1
    print(res)

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    n, k = map(int, input().split())
    cnt = [0]*101
    for _ in range(k):
        d = int(input())
        A_i = list(map(int, input().split()))
        for i in range(1, n+1):
            if i not in A_i:
                cnt[i] += 1
    res = 0
    for j in cnt:
        if j == k:
            res += 1
    print(res)

if __name__ == "__main__":
    main()
k,s=map(int,raw_input())
ans=0
for i in range(k+1):
  for j in range(k+1):
    if 0 <= s-i-j<=k:ans+=1
print ans

### FIXED CODE ###

k,s=map(int,raw_input().split())
ans=0
for i in range(k+1):
 for j in range(k+1):
  if 0 <= s-i-j<=k:ans+=1
print ans
N = int(input())
T, A = map(int, input().split())
H = []
for i in range(N):
  H.append(input())

l = []
for i in range(N):
    l.append(abs(A - (T - 0.006 * H[i])))
print(l.index(min(l))+1)

### FIXED CODE ###

N = int(input())
T, A = map(int, input().split())
H = []
H = list(map(int,input().split()))

l = []
for i in range(N):
    l.append(abs(A - (T - 0.006 * H[i])))
print(l.index(min(l))+1)
from collections import Counter

N = int(input())
s = [0]*(N-1)
for i in range(N-1):
    #s[i] = ''.join(sorted(list(input())))
    s[i] = int(input())

ct = Counter(s)

for i in range(N):
    print(ct[i+1])


### FIXED CODE ###

import collections

N = int(input())
s = list(map(int, input().split()))

ct = collections.Counter(s)

for i in range(N):
    print(ct[i+1])
S = input()

if S = 'SUN':
  print(7)
elif S = 'MON':
  print(6)
elif S = 'TUE':
  print(5)
elif S = 'WED':
  print(4)
elif S = 'THU':
  print(3)
elif S = 'FRI':
  print(2)
elif S = 'SAT':
  print(1)

### FIXED CODE ###

S = input()

if S == 'SUN':
  print(7)
elif S == 'MON':
  print(6)
elif S == 'TUE':
  print(5)
elif S == 'WED':
  print(4)
elif S == 'THU':
  print(3)
elif S == 'FRI':
  print(2)
elif S == 'SAT':
  print(1)
N = input()
print(-((-N)//2))

### FIXED CODE ###

N = int(input())
print(-((-N)//2))
# numpyとか使って高速化お遊び
import sys
import numpy as np

def main():
    inf = 10 ** 7
    s = sys.stdin.readline()[:-1]
    n = len(s)
    s += "".join(chr(i + 97) for i in range(26))
    # print(s)
    # 次をその文字にした時の「長さ、位置」
    size = np.zeros(26, "i8")
    pos = [n + i for i in range(26)]
    # 解答復元のための移動先
    nxt = [-1] * n
    # 後ろの文字から順に見る
    for i in range(n - 1, -1, -1):
        # 次をどの文字にすれば短くなるか調べる
        # 同じ長さの時は辞書順優先
        # codeはaを0として番号化したもの
        min_size_code = size.argmin()[0]
        now_code = ord(s[i]) - 97
        size[now_code] = size[min_size_code] + 1
        pos[now_code] = i
        nxt[i] = pos[min_size_code]
        # print(size)
        # print(pos)
        # print(nxt)
        # print()
    # 最短になる最初の文字を調べて、nxtの順にたどる
    min_size_code = size.argmin()[0]
    i = pos[min_size_code]
    ans = s[i]
    while i < n:
        i = nxt[i]
        ans += s[i]
    print(ans)

main()


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    inf = 10 ** 7
    s = input()
    n = len(s)
    s += "".join(chr(i + 97) for i in range(26))
    # print(s)
    # 次をその文字にした時の「長さ、位置」
    size = [0] * 26
    pos = [n + i for i in range(26)]
    # 解答復元のための移動先
    nxt = [-1] * n
    # 後ろの文字から順に見る
    for i in range(n - 1, -1, -1):
        min_size = inf
        min_pos = -1
        # 次をどの文字にすれば短くなるか調べる
        # 同じ長さの時は辞書順優先
        for sz, p in zip(size, pos):
            if sz < min_size:
                min_size = sz
                min_pos = p
        code = ord(s[i]) - 97
        size[code] = min_size + 1
        pos[code] = i
        nxt[i] = min_pos
        # print(size)
        # print(pos)
        # print(nxt)
        # print()
    # 最短になる最初の文字を調べて、nxtの順にたどる
    min_size = inf
    min_pos = -1
    for sz, p in zip(size, pos):
        if sz < min_size:
            min_size = sz
            min_pos = p
    i = min_pos
    ans = s[i]
    while i < n:
        i = nxt[i]
        ans += s[i]
    print(ans)

main()
a,b=map(int,imput().split())
if (a+b)%2==1:
  print("IMPOSSIBLE")
else:
  print((a+b)/2)

### FIXED CODE ###

a,b=map(int,input().split())
if a%2==b%2:
  print (int((a+b)/2))
else:
  print("IMPOSSIBLE")
n = int(input())
l = [int(input()) for _ in [0]*n]

print(sum(l)-max(l)//2)


### FIXED CODE ###

d = int(input())
if d == 25:
  print('Christmas')
elif d == 24:
  print('Christmas Eve')
elif d == 23:
  print('Christmas Eve Eve')
else:
  print('Christmas Eve Eve Eve')
n=int(input())
a=n%100
for i in range(a):
  for j in range(a-i):
    for k in range(a-i-j):
      for l in range(a-i-j-k):
        for m in range(a-i-j-k-l):
          if i+2*j+3*k+4*l+5*m == a:
            print(1)
            return
print(0)


### FIXED CODE ###

import sys
import math

n=int(input())
a=n%100
b=math.floor(n/100)+1
f=True
while b != 0:
  for i in range(b):
    for j in range(b-i):
      for k in range(b-i-j):
        for l in range(b-i-j-k):
          for m in range(b-i-j-k-l):
            if i+2*j+3*k+4*l+5*m == a:
              print(1)
              sys.exit()
  a+=100
  b-=1
print(0)
# from scipy.special import comb

from math import factorial

MOD = 10 ** 9 + 7
x, y = map(int, input().split())

if (x + y) % 3 != 0:
    print(0)
else:
    # (+1, +2) n
    # (+2, +1) m
    # n + 2m = x
    # 2n + m = y
    m = (2 * x - y) // 3
    n = (2 * y - x) // 3
    score = factorial(n + m) // factorial(n) // factorial(m)
    # score = comb(n + m, n, exact=True)
    print(score % MOD)

### FIXED CODE ###

# from scipy.special import comb
# from math import factorial
# from operator import mul
# from functools import reduce

# def combination(n, r):
#     r = min(n - r, r)
#     if r == 0:
#         return 1
#     over = reduce(mul, range(n, n - r, -1))
#     under = reduce(mul, range(1, r + 1))
#     return over // under


def combination(n, r, mod=10 ** 9 + 7):
    n1, r = n + 1, min(r, n - r)
    numerator = denominator = 1
    for i in range(1, r + 1):
        numerator = numerator * (n1 - i) % mod
        denominator = denominator * i % mod

    return numerator * pow(denominator, mod - 2, mod) % mod


x, y = map(int, input().split())

if (x + y) % 3 != 0 or (x > 2 * y or y > 2 * x):
    print(0)
else:
    # (+1, +2) n
    # (+2, +1) m
    # n + 2m = x
    # 2n + m = y
    m = (2 * x - y) // 3
    n = (2 * y - x) // 3
    # score = factorial(n + m) // factorial(n) // factorial(m)
    # score = comb(n + m, n, exact=True)
    score = combination(n + m, n)
    print(score)
l=[]
n,W=list(map(int,input().split()))
for i in range(n):
	item=list(map(int,input().split))
	l.append([item[1],item[0]])

# n=4
# l=[[2,3],[1,2],[3,4],[2,2]] #w,v
# W=5

print(l)
def solve(i,w):
	if i==n or w<0:
		return(0)
	elif w-l[i][0]<0:
		return(0)
	else:
		return(max(solve(i+1,w),l[i][1]+solve(i+1,w-l[i][0])))

print(solve(0,W))

### FIXED CODE ###

value=[0]
weight=[0]
n,W=input().split()
n=int(n)
W=int(W)
for i in range(n):
	item=list(map(int,input().split()))
	value.append(item[0])
	weight.append(item[1])

dp=[[0 for j in range(W+1)] for i in range(n+1)]
for i in range(n+1):
	for j in range(W+1):
		if i==0:
			res=0
		elif j-weight[i]<0:
			res=dp[i-1][j]
		else:
			res=max(dp[i-1][j-weight[i]]+value[i],dp[i-1][j])
		dp[i][j]=res
print(dp[n][W])
data = [int(i) for i in input().split()]

data,sort()
print("{0}{1}{2}".format(data[0],data[1],data[2]))

### FIXED CODE ###

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

data.sort()
print("{0} {1} {2}".format(data[0],data[1],data[2]))
n = int(input())
s = [int(i) for i in input().split()]
print("Yes" if max(s) < (sum(s) -max(s)) else "No")

### FIXED CODE ###

t,x = map(int,input().split())
print(t/x)
N = int(input())
for i in range(N):
        a,b,c = map(int,input().split())
        if i == 0:
                preA = a
                preB = b
                preC = c
        else:
                A = max(preB + a, preC + a)
                B = max(preA + b, preC + b)
                C = max(preA + c, preB + c)
                preA = A
                preB = B
                preC = C
print(max(A, B, C))

### FIXED CODE ###

abc = []
n = int(input())
for i in range(n):
  abc.append([int(s) for s in input().split()])

dp = [[0, 0, 0]for i in range(n)]
dp[0][0] = abc[0][0]
dp[0][1] = abc[0][1]
dp[0][2] = abc[0][2]
for i in range(1, n):
  dp[i][0] = max(dp[i-1][1]+abc[i][0], dp[i-1][2]+abc[i][0])
  dp[i][1] = max(dp[i-1][0]+abc[i][1], dp[i-1][2]+abc[i][1])
  dp[i][2] = max(dp[i-1][0]+abc[i][2], dp[i-1][1]+abc[i][2])
print(max(dp[n-1]))
N=int(input())
P=list(map(int,input().split()))
import math
min_num = math.inf
count=0
for p in P:
    if p <= min_num:
        min_num = p
        count += 1
print(count)



### FIXED CODE ###

N=int(input())
P=list(map(int,input().split()))
count=0
for i,p in enumerate(P):
    if i ==0:
        min_num=p
        count += 1
        continue
    if p <= min_num:
        min_num = p
        count += 1
print(count)
S = input()
T = input()
n = len(S)
m = len(T)

ans = 'UNRESTORABLE'
for i in range(n - m + 1):
    for j in range(m):
        if S[i + j] != '?' and S[i + j] != T[j]:
            break
    else:
        S2 = S[: i] + T + S[i + m :]
ans = S2.replace('?', 'a')
        
print(ans)

### FIXED CODE ###

S = input()
T = input()

ans = 'UNRESTORABLE'
for i in range(len(S) - len(T) + 1):
    flag = 1
    for j in range(len(T)):
        if S[i+j] == T[j] or S[i+j] == '?':
            continue
        else:
            flag = 0
    if flag:
        ans = S[0:i] + T + S[i+len(T):]
        ans = ans.replace('?', 'a')
    
print(ans)
import bisect
import numpy as np

def main():
    N = int(input())
    P = list(map(int, input().split()))

    P = np.array(P)

    ans = 0
    i = N
    while i != 0:
        ans += 1
        i = np.argmin(P)
        P = P[0:i]
    print(ans)

    return 0


if __name__ == '__main__':
    main()

### FIXED CODE ###

import bisect
import numpy as np

def main():
    N = int(input())
    P = list(map(int, input().split()))


    ans = 1
    f = P[0]

    for i in range(1, N):
        f_o = P[i]
        if f >= f_o:
            ans+=1
            f = f_o
    print(ans)
    return 0


if __name__ == '__main__':
    main()
while(1):
    word = input()
    if (word = "0"):
        break
    result = 0
    for i in word:
        result += int(i)
    print(result)
        

### FIXED CODE ###

while(1):
    word = input()
    if (word == "0"):
        break
    result = 0
    for i in word:
        result += int(i)
    print(result)
N,A=int(input().strip())
if A >= (N%500):
  print('Yes')
else:
  print('no')


### FIXED CODE ###

N=int(input())
A=int(input())
if A >= (N%500):
  print('Yes')
else:
  print('No')