Harryxun/stf_run huggingface dataset:
import sys
N = int(input())
array = [ I for I in range(1,10) ]

if not ( 1 <= N <= 100 ): sys.exit()

for J in range(1,10):
    for K in range(1,10):
        if n == J*K:
            print('Yes')
            sys.exit()
print('No')

### FIXED CODE ###

import sys
N = int(input())
array = [ I for I in range(1,10) ]

if not ( 1 <= N <= 100 ): sys.exit()

if N >= 82:
    print('No'); sys.exit()
else:
    for J in array:
        if (N % J) == 0 and (N // J) <= 9 : print('Yes'); sys.exit()
print('No')
input = __import__('sys').stdin.readline
MIS = lambda: map(int,input().split())

# f(a) = z                 a <= x1
#        a+z-x1      x1 <= a <= x2
#        x2+z-x1     x2 <= a
class Sandgraph:
    def __init__(_, X):
        _.z = _.x1 = 0
        _.x2 = X
    
    def __repr__(_):
        return f"<{_.z} {_.x1} {_.x2}>"
    
    def add(_, dt):
        # Go towards the ceiling
        d1 = min(dt, X-(_.x2+_.z-_.x1))
        _.z+= d1
        dt-= d1
        # Reduce the diagonal
        d1 = min(dt, _.x2-_.x1)
        _.z+= d1
        _.x2-= d1
    
    def sub(_, dt):
        # Go towards the floor
        d1 = min(dt, _.z)
        _.z-= d1
        dt-= d1
        # Reduce the diagonal
        d1 = min(dt, _.x2-_.x1)
        _.x1+= d1
    
    def __call__(_, a):
        if a <= _.x1: return _.z
        elif a <= _.x2: return a + _.z - _.x1
        else: return _.x2 + _.z - _.x1

X = int(input())
k = int(input())
rev = list(MIS())
Q = int(input())
sand = Sandgraph(X)

last_t = 0
i = 0 # even -, odd +
for QUERY in range(Q):
    t, a = MIS()
    while i<k and rev[i] <= t:
        dt = rev[i] - last_t
        if i%2 == 0: sand.sub(dt)
        else: sand.add(dt)
        last_t = rev[i]
        i+= 1
    dt = t - last_t
    if i%2 == 0: sand.sub(dt)
    else: sand.add(dt)
    print(sand(a))
    last_t = t

### FIXED CODE ###

input = __import__('sys').stdin.readline
MIS = lambda: map(int,input().split())
 
# f(a) = z                 a <= x1
#        a+z-x1      x1 <= a <= x2
#        x2+z-x1     x2 <= a
class Sandgraph:
    def __init__(_, X):
        _.z = _.x1 = 0
        _.x2 = X
    
    def add(_, dt):
        # Go towards the ceiling
        d1 = min(dt, X-(_.x2+_.z-_.x1))
        _.z+= d1
        dt-= d1
        # Reduce the diagonal
        d1 = min(dt, _.x2-_.x1)
        _.z+= d1
        _.x2-= d1
    
    def sub(_, dt):
        # Go towards the floor
        d1 = min(dt, _.z)
        _.z-= d1
        dt-= d1
        # Reduce the diagonal
        d1 = min(dt, _.x2-_.x1)
        _.x1+= d1
    
    def __call__(_, a):
        if a <= _.x1: return _.z
        elif a <= _.x2: return a + _.z - _.x1
        else: return _.x2 + _.z - _.x1
 
X = int(input())
k = int(input())
rev = list(MIS())
Q = int(input())
sand = Sandgraph(X)
 
last_t = 0
i = 0 # even -, odd +
for QUERY in range(Q):
    t, a = MIS()
    while i<k and rev[i] <= t:
        dt = rev[i] - last_t
        if i%2 == 0: sand.sub(dt)
        else: sand.add(dt)
        last_t = rev[i]
        i+= 1
    dt = t - last_t
    if i%2 == 0: sand.sub(dt)
    else: sand.add(dt)
    print(sand(a))
    last_t = t
n, m, l = [int(i) for i in input().split()]

A = [[int(i) for i in input().split()]]
B = [[int(i) for i in input().split()]]
C = []


for ni in range(n):
    A.append([int(i) for i in input().split()])
    C[n][m] = sum([A[n][m] * B[m][l] for m in range(m)])


for mi in range(m):
    B.append([int(i) for i in input().split()])

print(" ".join([str(v) for v in C]))

### FIXED CODE ###

n, m, l = [int(i) for i in input().split()]

A = []
B = []
C = []

for ni in range(n):
    A.append([int(i) for i in input().split()])

for mi in range(m):
    B.append([int(i) for i in input().split()])

for i in range(n):
    C.append([])
    for j in range(l):
        C[i].append(0)
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]

for li in range(n):
    print(" ".join([str(s) for s in C[li]]))
N,M=map(int,input().split())

div=10**9+7
tmp=1
K=min(N,M)
diff=abs(N-M)
for i in range(K):
    tmp*=(i+1)%div

if diff>3:
    ans=0
elif diff==0:
    ans=2*tmp*tmp%div
elif diff==1:
    ans=tmp*(tmp+K+1+1)%div
print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
MOD = 10 ** 9 + 7
nn = 1
mm = 1
for i in range(1, N + 1):
  nn = (nn * i) % MOD
for j in range(1, M + 1):
  mm = (mm * j) % MOD
if abs(N - M) >= 2:
  ans = 0
elif abs(N - M) == 1:
  ans = (nn * mm) % MOD
else:
  ans = (2 * nn * mm) % MOD
print(ans)
n, m = map(int, input().split())
a = [(1, int(i)) for i in input().split()]
for _ in range(m):
    b, c = map(int, input().split())
    a.append((b, c))
a = sorted(a, key=lambda x: x[1])
res = 0
idx = 0
while idx < n:
    b, c = a.pop()
    p = min(b, n-t)
    res += p * c
    idx += p
print(res)


### FIXED CODE ###

n, m = map(int, input().split())
a = [(1, int(i)) for i in input().split()]
for _ in range(m):
    b, c = map(int, input().split())
    a.append((b, c))
a = sorted(a, key=lambda x: x[1])
res = 0
idx = 0
while idx < n:
    b, c = a.pop()
    p = min(b, n-idx)
    res += p * c
    idx += p
print(res)
n = int(input())
a = list(map(int, input().split()))
sa = sorted(a)
 
for i in range(sa[1], 0, -1):
  cnt = 0
  for j in range(n):
    if a[j] % i != 0:
      cnt += 1
    if cnt >= 2:
      break  
  if cnt <= 1:
    print(i)
    break

### FIXED CODE ###

a, b, t = map(int, input().split())
print((t // a) * b)
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
score = {"r":P, "s":R, "p":S} 
m = {"r":"p", "s":"r", "p":"s"}
command= []
mm = []
ans = 0
print(score)
#添字は0から始まることに注意
#r : 0 s : 1 p : 2


for i in range(N):
    if i <= K-1:
        ans += score[T[i]]
        mm.append(m[T[i]])
        print(mm)
    else:
        if m[T[i]] != mm[i-2]:
            ans += score[T[i]]
            mm.append(m[T[i]])
        else:
            mm.append("")
                 
print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())


ans = 0
commands = [''] * N
for i, t in enumerate(T):
    if t == 'r':
        command = 'p'
        point = P

    elif t == 's':
        command = 'r'
        point = R

    elif t == 'p':
        command = 's'
        point = S

    if (i - K >= 0) and (commands[i -  K] == command):
        command = ''
        point = 0

    ans += point
    commands[i] = command

print(ans)
a,b,c=map(int,input().split())
if a + b >= c + 1:
  print(b+c)
elif a==b==c==0:
  print(0)
elif a+b=c:
  print(b+c)
else:
  print(a+2*b+1)


### FIXED CODE ###

a,b,c=map(int,input().split())
if a + b >= c :
  print(b+c)
elif a==b==c==0:
  print(0)
else:
  print(a+2*b+1)
A=int(input())
B=int(input())
C=int(input())
D=int(input())
print(min(A+C,A+D,B+c,B+D))

### FIXED CODE ###

A=int(input())
B=int(input())
C=int(input())
D=int(input())
print(min(A+C,A+D,B+C,B+D))
S = input().strip()
s = str.lower(S)
target = 'hi'
if target = 'hi':
    print('Yes')
elif target = 'hihi':
    print('Yes')
elif target = 'hihihi':
    print('Yes')    
elif target = 'hihihihi':
    print('Yes')
elif target = 'hihihihihi':
    print('Yes')
else
    print('No')

### FIXED CODE ###

S = input().strip()
target = S
if target == 'hi':
    print('Yes')
elif target == 'hihi':
    print('Yes')
elif target == 'hihihi':
    print('Yes')    
elif target == 'hihihihi':
    print('Yes')
elif target == 'hihihihihi':
    print('Yes')
else:
    print('No')
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

n, m = map(int, input().split())
a = [int(i) for i in input().split()]
l = [0 for i in range(n+1)]

for i in range(1, m+1):
    for j in range(n):
        if a[j]<=i and l[i-a[j]] == 0:
            l[i] = 1
            
if l[k] ==1:
    print("First")
else:
    print("Second")

### FIXED CODE ###

import sys
input = sys.stdin.readline
 
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
 
dp = [0 for i in range(K+1)]
for i in range(K+1):
    if not dp[i]:
        for j in range(N):
            if i + A[j] < K + 1:
                dp[i+A[j]] = 1
 
if dp[K]: print("First")
else: print("Second")
s = map(int,input().split())
m = 10000000
for p in s:
  t = 0
  for x in s:
    t+=(x-p)**2
   m = min(t,m)
print(m)
    
  

### FIXED CODE ###

n = input()
s = list(map(int,input().split()))
m = 10000000
for p in range(0,101):
  t = 0
  for x in s:
    t+=(x-p)**2
  m = min(t,m)
print(m)
import math
def eratosthenes(n):
    prime_list = []
    num_list=[i for i in range(2, n+1)]
    limit = math.sqrt(n)
    while True:
        if limit <= num_list[0]:
            return prime_list + num_list
        prime_list.append(num_list[0])
        num_list = [e for e in num_list if e % num_list[0] != 0]

ls = eratosthenes(100000)
ls2 = []
count = 0
for i in ls:
    ls2.append(count)
    if (i+1)//2 in ls:
        count += 1
Q = int(input())
for i in range(Q):
    l, r = map(int, input().split())
    print(ls2[r-1]-ls2[l-1])

### FIXED CODE ###

q = int(input())
    
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

ls = [0]

for i in range(1,100000):
    if is_prime(i) and is_prime((i+1)//2):
        ls.append(ls[i-1]+1)
    else:
        ls.append(ls[i-1])
        
for i in range(q):
    l,r = map(int,input().split())
    if l == r:
        if is_prime(l) and is_prime((l+1)//2):
            print(1)
        else:
          print(ls[r]-ls[l-1])  
    else:
        print(ls[r]-ls[l-1])
"""

Wは100で固定する。
1行目でできるかぎり連結成分の数が多くなるようにする。


W=100で固定し、白黒格子上になるように列を組む。
白と黒どちらかが規定数をオーバーしたら次の行で調整を入れて数を減らす。
ここでは、白が規定数に達したと仮定しよう。
白色の数に調整を入れたら、次の行では
"""
A,B = map(int,input().split())
N = 10
n = N//2
grid = [["#"]*N for _ in range(N)]
for i in range(N//2,N):
    for j in range(N):
        grid[i][j] = "."

A -= 1
B -= 1

for i in range(0,A//n*2,2):
    for j in range(0,N,2):
        grid[i][j] = "."

for j in range(0,A%n*2,2):
    grid[A//n*2][j] = "."

grid = grid[::-1]
for i in range(0,B//n*2,2):
    for j in range(0,N,2):
        grid[i][j] = "#"

for j in range(0,B%n*2,2):
    grid[B//n*2][j] = "#"

print(grid)

### FIXED CODE ###

"""

Wは100で固定する。
1行目でできるかぎり連結成分の数が多くなるようにする。


W=100で固定し、白黒格子上になるように列を組む。
白と黒どちらかが規定数をオーバーしたら次の行で調整を入れて数を減らす。
ここでは、白が規定数に達したと仮定しよう。
白色の数に調整を入れたら、次の行では
"""
A,B = map(int,input().split())
N = 100
n = N//2
grid = [["#"]*N for _ in range(N)]
for i in range(n,N):
    for j in range(N):
        grid[i][j] = "."

A -= 1
B -= 1

for i in range(0,A//n*2,2):
    for j in range(0,N,2):
        grid[i][j] = "."

for j in range(0,A%n*2,2):
    grid[A//n*2][j] = "."

grid = grid[::-1]
for i in range(0,B//n*2,2):
    for j in range(0,N,2):
        grid[i][j] = "#"

for j in range(0,B%n*2,2):
    grid[B//n*2][j] = "#"

print(" ".join([str(N),str(N)]))
for i in range(N):
    print("".join(grid[i]))
n = int(input())
m = list(input(n))
if n % sum(m)==0:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n = input()
m = sum(map(int,n))
if int(n) % m==0:
  print("Yes")
else:
  print("No")
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M, P = lr()
# 終了時、T*P枚支払う
graph = [tuplr(lr()) for _ in range(M)]

def bellmanford(start, N):
    INF = 10 ** 12
    dist = [-INF] * (N+1) # 1-indexed
    dist[start] = 0
    for i in range(N+N+5):
        for pre, ne, weight in graph:
            if dist[pre] != -INF and dist[pre] + weight - P > dist[ne]:
                dist[ne] = dist[pre] + weight - P
                # n回繰り返してもスコアが更新された場合
                if i > N-1:
                    dist[ne] = INF
    if dist[N] == INF:
        return -1
    else:
        return max(0, dist[N])

answer = bellmanford(1, N)
print(answer)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 9)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, M, P = lr()
graph = [lr() for _ in range(M)]


def bellmanford(s, g):
    dist = [float("inf")] * (N+1)
    dist[s] = 0
    for i in range(2 * N):
        for a, b, c in graph:
            cost = -(c - P)
            if dist[b] > dist[a] + cost:
                dist[b] = dist[a] + cost
                if i >= N:
                    dist[b] = -float("inf")
 
    if dist[g] == -float("inf"):
        return -1
    else:
        return max(-dist[g], 0)

answer = bellmanford(1, N)
print(answer)
#
import math
from math import gcd,pi,sqrt,factorial
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n,k = i_map()

    p = n - k + 1
    b = k - 1

    for i in range(1,k+1):
        pci = factorial(p)//factorial(p-i)//factorial(i)
        bci1 = factorial(b)//factorial(b-(i-1))//factorial(i-1)
        print(pci*bci1%MOD)



if __name__=="__main__":
    main()


### FIXED CODE ###

import math
from math import gcd,pi,sqrt,factorial
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n,k = i_map()

    p = n - k + 1
    b = k - 1

    def comb(n, r):
      if n-r>=0:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
      else:
        return 0

    for i in range(1,k+1):
        pci = comb(p,i)
        bci1 = comb(b,i-1)
        print((pci*bci1)%MOD)

if __name__=="__main__":
    main()
N,K=map(int, input().split())
A=list(map(int, input().split()))
import sys
sys.setrecursionlimit(10**6)
import numpy as np
done=np.array([0]*N)
X=[0]*2
L=[]
F=[True]
def dfs(start, steps):
    done[start-1]+=1
    L.append(start)
    if done[start-1]==3:
        X[1]=steps
        return
    elif done[start-1]==2 and F[0]:
        X[0]=steps
        F[0]=False
    nex=A[start-1]
    dfs(nex, steps+1)
dfs(1,0)
#print(done)
#print(X)
#print(L)
first=L[:X[0]-(X[1]-X[0])]
sec=L[X[0]-(X[1]-X[0]):X[0]-(X[1]-X[0])+(X[1]-X[0])]
#print(first, sec)
if len(first)==0:
    first=sec
if K-1<=len(first):
    print(first[K])
else:
    K=K-len(first)
    print(sec[(K%len(sec))])


### FIXED CODE ###

N,K=map(int, input().split())
A=list(map(int, input().split()))
import sys
sys.setrecursionlimit(10**8)
import numpy as np
done=np.array([0]*N)
X=[0]*2
L=[]
F=[True]
def dfs(start, steps):
    done[start-1]+=1
    L.append(start)
    if done[start-1]==3:
        X[1]=steps
        return
    elif done[start-1]==2 and F[0]:
        X[0]=steps
        F[0]=False
    nex=A[start-1]
    dfs(nex, steps+1)
dfs(1,0)
#print(done)
#print(X)
#print(L)
first=L[:X[0]-(X[1]-X[0])]
sec=L[X[0]-(X[1]-X[0]):X[0]-(X[1]-X[0])+(X[1]-X[0])]
#print(first, sec)
if len(first)==0:
    first=sec
if K+1<=len(first):
    print(first[K])
else:
    K=K-len(first)
    print(sec[(K%len(sec))])
s=input()
t=input()
n=len(s)

dic={}
ans='Yes'
for i in range(n):
    if s[i]==t[i] and s[i] in dic:
        ans='No'
        break
    
    if t[i] not in dic:
        dic[t[i]]=s[i]
    else:
        if dic[s[i]]==t[i]:
            continue
        else:
            ans='No'
            break

print(ans)

### FIXED CODE ###

s=input()
t=input()
n=len(s)

dic={}
ans='Yes'
for i in range(n):
    if t[i] not in dic:
        dic[t[i]]=s[i]
    
    else:
        if dic[t[i]]==s[i]:
            continue
        else :
            ans='No'
            break
    
if len(dic)!=len(set(dic.values())):
    ans='No'
print(ans)
# Ai>=Bi 出来るならそのままにする
# Ai < Bi 仕方ないので溢れたぶんを使う
# 「変更したAi」の最小値が欲しいので、使うのは余ってるやつが多い順に使ったほうがいい

n = int(input())
arr = list(map(int, input().split()))
brr = list(map(int, input().split()))

lack, lack_i = 0, []
extra, extra_i = 0, []
for i in range(n):
    if arr[i] < brr[i]:
        lack += brr[i] - arr[i]
        lack_i.append([i, brr[i] - arr[i], False])
    else:
        extra += arr[i] - brr[i]
        extra_i.append([i, arr[i] - brr[i], False])

if lack > extra:
    print(-1)
    exit()

# 大量に余っているやつから優先的に使う
extra_i = list(sorted(extra_i, key=lambda x: x[1], reverse=True))
ans = 0

l_i = 0
e_i = 0

while True:
    if l_i >= len(lack_i):
        break
    while True:
        if e_i >= len(extra_i):
            print(-1)
            exit()
        if lack_i[l_i][1] <= extra_i[e_i][1]:
            extra_i[e_i][2] = True  # 一回でも使用した
            ans += 1  # 少ないやつを潰したぶん
            extra_i[e_i][1] -= lack_i[l_i][1]
            break
        else:
            extra_i[e_i][2] = True  # 一回でも使用した
            e_i += 1
            lack_i[l_i][1] -= extra_i[e_i][1]
            extra_i[e_i][1] = 0
    l_i += 1

bonus = len(list(filter(lambda x: x[2] == True, extra_i)))
print(ans + bonus)


### FIXED CODE ###

# にぶたんが失敗したので両端からしゃくとりするような感じでやってみる
# 差分でソートして大きく足りないものは大きく余ってるやつをぶつける

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
if sum(A) < sum(B):
    print(-1)
    exit()
D = []
pre_ans = 0  # 確実に変えなくてはいけないやつ
for i in range(N):
    if A[i] != B[i]:
        D.append(A[i] - B[i])
        if A[i] < B[i]:
            pre_ans += 1
D = sorted(D)

used = 0
tmp = 0
# print(D)
l, r = 0, len(D)
while r - l > 1:
    # print("now tmp: {}".format(tmp))
    if tmp + D[l] < 0:
        # 新たに借りる
        r -= 1
        used += 1
        tmp += D[r]
    tmp += D[l]
    l += 1
print(used + pre_ans)
S=input()
T=input()

for i in range(0,len(S)-len(T)+1):
  score=0
  for j in range(0,len(T)):
    if(S[i] != T[i+j]):
      score += 1
  score = min(score, len(T))
print(score)

### FIXED CODE ###

S = input()
T = input()
 
Nmax = len(T)
for i in range(len(S)-len(T)+1):
    diff = 0
    for j in range(len(T)):
        if(S[i+j] != T[j]):
            diff += 1
 
    Nmax = min(diff, Nmax)
 
print(Nmax)
from flactions import gcd
def lcm(x,y):
    return (x*y)//gcd(x,y)
n,m=map(int,input().split())
s=input()
t=input()
w=min(m,n)
l=w//gcd(m,n)
d=lcm(m,n)
p=d//n
q=d//m
h=lcm(p,q)
for i in range(0,l-1):
    g=i*h
    if s[g//p]!=t[g//q]:
        print(-1)
        break
else:
    print(d)

### FIXED CODE ###

from fractions import gcd
def lcm(x,y):
    return (x*y)//gcd(x,y)
n,m=map(int,input().split())
s=input()
t=input()
d=lcm(n,m)
p=d//n
q=d//m
h=lcm(p,q)
l=d//h
for i in range(0,l):
    g=i*h
    if s[g//p]!=t[g//q]:
        print(-1)
        break
else:
    print(d)
n = int(input())

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

l = [1]

for i in range(1, n):
    b_max1 = 2 * (l[i - 1] - a[i - 1])
    b_max2 = sum(a[i:])

    if b_max1 <= 0:
        l = -1

    print(a[i + 1:])

    print(i, b_max1, b_max2)

    l.append(min(b_max1, b_max2))

l.append(a[-1])

print(sum(l))

### FIXED CODE ###

n = int(input())

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

cumsum_a = a.copy()

for i in range(n-1, -1, -1):
    cumsum_a[i] += cumsum_a[i+1]

ans = 0
childable_node = 1

for i in range(n + 1):
    if a[i] > childable_node:
        ans = -1
        break

    ans += childable_node

    if i < n:
        b_max1 = 2 * (childable_node - a[i])
        b_max2 = cumsum_a[i + 1]
        childable_node = min(b_max1, b_max2)

print(ans)
def main():
    _len = int(input())
    _str = input()

    if _len % 2: 
        print("No")
        return

    print(_len/2)
    a, b = _str[:_len/2], _str[_len/2:]

    print("Yes" if a == b else "No")


if __name__ == '__main__':
    main()

### FIXED CODE ###


def main():
    _len = int(input())
    _str = input()

    if _len < 0 or _len > 100 or _len % 2 : 
        print("No")
        return
    idx = int(_len/2)
    a, b = _str[:idx], _str[idx:]

    print("Yes" if a == b else "No")


if __name__ == '__main__':
    main()
n = int(input())
for i in range(1,n+1):
    if i%3 != 0 and i%5 != 0:
        ans += i
print(ans)

### FIXED CODE ###

n = int(input())
ans = 0
for i in range(1,n+1):
    if i%3 != 0 and i%5 != 0:
        ans += i
print(ans)
a = input()

if str.isupper(a) == ture :
  print("A")
else :
  ptint("a")

### FIXED CODE ###

a = input()
 
if str.isupper(a):
  print('A')
else :
  print('a')
if __name__ == '__main__':
    n = int(input())
    print(sum(list(range(1, n + 1))) - n)

### FIXED CODE ###

if __name__ == '__main__':
    n = int(input())
    t = (1 + n) * n // 2
    print(t - n)
from functools import cmp_to_key
n, m = map(int, input().split())
a = [int(e) for e in input().split()]
bc = [[int(e) for e in input().split()] for _ in range(m)]
bc.sort(key = cmp_to_key(lambda x, y: x[1] - y[1]))
t = 0
for bc in range(m):
  b, c = bc
  t += b
  a.extend([c] * b)
  if t > n:
    break
a.sort(reverse = True)
print(sum(a[:n]))


### FIXED CODE ###

from functools import cmp_to_key
n, m = map(int, input().split())
a = [int(e) for e in input().split()]
bc = [[int(e) for e in input().split()] for _ in range(m)]
bc.sort(key = cmp_to_key(lambda x, y: y[1] - x[1]))
t = 0
for v in bc:
  b, c = v
  t += b
  a.extend([c] * b)
  if t > n:
    break
a.sort(reverse = True)
print(sum(a[:n]))
N,L=map(int,input().split())
s=[]
for i in range(1,N+1):
  s.append(L+i-1)
s.remove(min(abs(j for j in s)))
print(sum(s))

### FIXED CODE ###

N,L=map(int,input().split())
s=[]
for i in range(1,N+1):
  s.append(L+i-1)
s.sort(key=lambda x: abs(x))
del s[0]
print(sum(s))
n = int(input())
a = map(int, input().split())
occur = [0 for i in range(n + 1)]
x = 0
cnt = 1
for i in a:
    cnt += 1
    if (occur[i] > 0):
        x = n + 1 - cnt + occur[i]
    else:
        occur[i] = cnt
print(n)
res1 = n + 1
res2 = 1
for i in range(1, n + 1):
    res1 = res1 * (n + 1 - i) / (i + 1)
    res2 = res2 * (x - i) / i
    print(int((res1 - res2 + 1000000007) % 1000000007))
    


### FIXED CODE ###

n = int(input())
a = tuple(map(int, input().split()))
occur = [0 for i in range(n + 1)]
MOD = 1000000007
for i in range(n + 1):
    if occur[a[i]] > 0: val = n - 1 - i + occur[a[i]]
    else: occur[a[i]] = i + 1
inv = [0 if i > 2 else 1 for i in range(n + 2)]
pinv = [0 if i > 2 else 1 for i in range(n + 2)]
perm = [0 if i > 2 else 1 for i in range(n + 2)]
for i in range(2, n + 2):
    inv[i] = -int(MOD / i) * inv[MOD % i] + MOD
    pinv[i] = pinv[i - 1] * inv[i] % MOD
    perm[i] = perm[i - 1] * i % MOD
def C(n, m):
    return (perm[m] * pinv[n] % MOD) * pinv[m - n] % MOD if n <= m else 0
for i in range(1, n + 2):
    temp = C(i, n + 1) - C(i - 1, val)
    if temp < 0: temp += MOD
    print(temp)