Harryxun/stf_run huggingface dataset:
from heapq import*
n,k=map(int,input().split())
*v,=map(int,input().split())
motimono=[]
ans=[]
if k>=n:
    k-=n
    heapify(v)
    for i in range(k):
        if len(v)>0:
            heappop(v)
        ans.append(sum(v))
    print(max(ans))
else:
    v*=2
    for j in range(1,k+1):
        for i in range(n-j,n+1):
            motimono=v[i:i+j]
            ans.append(sum(motimono))
            heapify(motimono)
            for i in range(k-j):
                if len(motimono)>0:
                    heappop(motimono)
                ans.append(sum(motimono))
    print(max(ans))

### FIXED CODE ###

from heapq import*
n,k=map(int,input().split())
*v,=map(int,input().split())
motimono=[]
ans=[]
if k>=n:
    k-=n
    heapify(v)
    ans.append(sum(v))
    for i in range(k):
        if len(v)>0:
            heappop(v)
        ans.append(sum(v))
    print(max(ans))
else:
    v*=2
    for j in range(1,k+1):
        for i in range(n-j,n+1):
            motimono=v[i:i+j]
            ans.append(sum(motimono))
            heapify(motimono)
            for i in range(k-j):
                if len(motimono)>0:
                    heappop(motimono)
                ans.append(sum(motimono))
    print(max(ans))
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
count = 0
ans = 0
for i in range(n):
    A = list(map(int,input().split()))
    for j in range(m):
        ans += A[j]*b[j]
    ans = ans + c
    if ans > 0:
        tmp += 1
print(tmp)

### FIXED CODE ###

n,m,c = map(int,input().split())
b = list(map(int,input().split()))
count = 0
for i in range(n):
    A = list(map(int,input().split()))
    ans = 0
    for j in range(m):
        ans += A[j]*b[j]
    ans = ans + c
    if ans > 0:
        count+= 1
print(count)
s = list(input())
s = set(s)
s = sorted(s)
m = 'abcdefghijklmnopqrstuvwxyz'

for i in range(26):
    if s[i] != m[i]:
        print(m[i])
        exit(0)

print('None')

### FIXED CODE ###

s = list(input())
s = set(s)
s = sorted(s)
m = 'abcdefghijklmnopqrstuvwxyz'

for i in range(len(m)):
    if s[i] != m[i]:
        print(m[i])
        exit(0)

    if i + 1 != len(m) and i + 1 == len(s):
        print(m[i + 1])
        exit(0)

print('None')
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

def diff(i, j, k):
	return (j // k) - ( i // k)

a,b,c,d = map(int, input().split())

zedd = diff(a, b+1, c) + diff(a, b+1, d) - diff(a, b+1, lcm(c,d))
ans = (b-a+1) -zedd

print(ans)

### FIXED CODE ###

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

def diff(i, j, k):
	return i - (i//j) - (i//k) + (i//lcm(j,k))

a,b,c,d = map(int, input().split())

print( diff(b, c, d) - diff(a-1, c, d) )
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
n,x=map(int,input().split())
l=[int(i) for i in input().split()]
print(reduce(gcd,[abs(i-x) for i in l]))

### FIXED CODE ###

import fractions
from functools import reduce
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
n,x=map(int,input().split())
l=[int(i) for i in input().split()]
print(gcd_list([abs(i-x) for i in l]))
A, B, C = int(input())

int D = max(A, B, C)

if A == D :
  print(A * 10 + B + c)
  
elif B == D:
  print(B * 10 + A + C)
  
elif C == D
  print(C * 10 + A + B)

### FIXED CODE ###

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


ans = max(A*10 + B + C, B*10 + A + C, C*10 + A + B)
print(ans)
s = intput()

print(s[0] + str((len(s)-2)) + s[-1])


### FIXED CODE ###

s = input()
print(s[0]+str(len(s)-2)+s[-1])
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]


def fib(n):
    a, b = 0, 1
    for i in range(n):
        a, b = b, a + b
    return b


if n == 0:
    print(0)
elif n == 1:
    print(1)

total = 1
i = 0
for x in a:
    if x == i:
        print(0)
        exit()
    total *= fib(x - i - 1)
    i = x + 1
total *= fib(n - (a[-1] + 1))

print(total % 1000000007)

### FIXED CODE ###

def fib(n):
    a, b = 0, 1
    for i in range(n):
        a, b = b, a + b
    return b


n, m = map(int, input().split())
if m == 0:
    print(fib(n) % 1000000007)
    exit()
a = [int(input()) for _ in range(m)]

total = 1
i = 0
for x in a:
    if x == i:
        print(0)
        exit()
    total *= fib(x - i - 1)
    i = x + 1
if a[-1] != n:
    total *= fib(n - (a[-1] + 1))

print(total % 1000000007)
from collections import defaultdict

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N, M = ZZ()
    edge = [ZZ() for _ in range(M)]
    E = defaultdict(list)
    for a, b in edge:
        E[a].append(b)
        E[b].append(a)

    color = [0] * (N+1)

    def is_bi(v, c):
        color[v] = c
        for to in E[v]:
            if color[to] == c: return False
            if color[to] == 0 and not is_bi(to, -c): return False
        return True

    if is_bi(1, 1):
        x = color.count(1)
        output = x * (N - x) - M
    else: output = N * (N - 1) // 2 - M
    print(output)

    return

if __name__ == '__main__':
    main()


### FIXED CODE ###

from collections import defaultdict
import sys
sys.setrecursionlimit(1000000)

def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
    N, M = ZZ()
    edge = [ZZ() for _ in range(M)]
    E = defaultdict(list)
    for a, b in edge:
        E[a].append(b)
        E[b].append(a)

    color = [0] * (N+1)

    def is_bi(v, c):
        color[v] = c
        for to in E[v]:
            if color[to] == c: return False
            if color[to] == 0 and not is_bi(to, -c): return False
        return True

    if is_bi(1, 1):
        x = color.count(1)
        output = x * (N - x) - M
    else: output = N * (N - 1) // 2 - M
    print(output)

    return

if __name__ == '__main__':
    main()
N, A, B = map(int, input().split())
s = ''
while len(s) < N:
    s += (A * 'b' + B * 'r') 

print(s[:N].count('b'))

### FIXED CODE ###

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

blue = N // (A + B) * A
rem = N % (A + B)
blue = blue + min(rem, A)

print(blue)
import math
from functools import reduce

n = int(input())
enemies = list(map(int,input().split()))
print(reduce(math.gcd, enemies))

### FIXED CODE ###

from functools import reduce

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

n = int(input())
enemies = list(map(int,input().split()))
print(reduce(gcd, enemies))
N = ini(input())

if N == 3 or N == 5 or N == 7:
	print("YES")
else:
	print("NO")

### FIXED CODE ###

N = int(input())

if N == 3 or N == 5 or N == 7:
	print("YES")
else:
	print("NO")
import math
x=int(input())
primemode = True
while primemode:
  sos = True
  for n in range(math.floor(math.sqrt(x))):
    if n+1 != 1:
      if x%(n+1) == 0:
        sos = False
  if sos:
    primemode = False
  else:
    x = x+1
print(x)

### FIXED CODE ###

s,t=input().split()
print(t+s)
n = int(input())
while True:
    if i % 2 == 0 and i % n == 0:
      	print(i)
        break
    i += 1


### FIXED CODE ###

n = int(input())
if n % 2 == 0:
    print(n)
else:
    print(n * 2)
S = list(input())
X, A = [], []
NX = ""

for i in range(len(S)):
    if S[i] == "x": X.append(i)
    else: 
        NX += S[i]
        A.append(i)
    
for i in range(len(NX)//2):
    if NX[i] != NX[-1-i]:
        print(-1)
        break
else:
    if NX == "": print(0)
    else:
        l, r = 0, len(S)-1
        midl = A[len(NX)//2]
        midr = (A[len(NX)//2] if len(NX)%2==1 else A[len(NX)//2 + 1])
        Add = 0
        while l < midl or r > midr:
            if S[l] == S[r] == "x":
                l += 1
                r -= 1
            elif S[l] == "x":
                l += 1
                Add += 1
            elif S[r] == "x":
                r -= 1
                Add += 1
            else:
                l += 1
                r -= 1
        print(Add)

### FIXED CODE ###

S = list(input())
X, A = [], []
NX = ""

for i in range(len(S)):
    if S[i] == "x": X.append(i)
    else: 
        NX += S[i]
        A.append(i)
    
for i in range(len(NX)//2):
    if NX[i] != NX[-1-i]:
        print(-1)
        break
else:
    if NX == "": print(0)
    else:
        l, r = 0, len(S)-1
        midl = A[(len(NX)-1)//2]
        midr = (A[(len(NX)-1)//2] if len(NX)%2==1 else A[(len(NX)-1)//2 + 1])
        Add = 0
        while l < midl or r > midr:
            if S[l] == S[r] == "x":
                l += 1
                r -= 1
            elif S[l] == "x":
                l += 1
                Add += 1
            elif S[r] == "x":
                r -= 1
                Add += 1
            else:
                l += 1
                r -= 1
        print(Add)
g

### FIXED CODE ###

n=int(input())
res=int((n%100)/5)
n -= 105*res
if n == 0 or n >= 100:
    print(1)
else:
    print(0)
a,b,c,d=map(int,input().split())
if c-a > 2d:
  print("No")
else:
  print("Yes")

### FIXED CODE ###

a,b,c,d=map(int,input().split())
if abs(c-a)>d:
  if abs(a-b)>d or abs(b-c)>d:
    print("No")
  else:
    print("Yes")
else:
  print("Yes")
inf = int(input())
i = 0
table = []
buil = [[[0]*10 for i in range(3)]for i in range(4)]

while(i < inf):
    b,f,r,v = map(int,input().split())
    b -=1
    f -=1
    r -=1
    buil[b][f][r] += c
    if buil[b][f][r] > 9: buil[b][f][r] = 9
    elif buil[b][f][r] < 0: buil[b][f][r] = 0
    i += 1

for i in range(4):
        if i != 0: print("#"*20)
        for j in range(3):
                for k in range(10):
                    print(" %d" %(buil[i][j][k]),end ="")
                print()

    


### FIXED CODE ###

inf = int(input())
i = 0
table = []
buil = [[[0]*10 for i in range(3)]for i in range(4)]

while(i < inf):
    b,f,r,v = map(int,input().split())
    b -=1
    f -=1
    r -=1
    buil[b][f][r] += v
    if buil[b][f][r] > 9: buil[b][f][r] = 9
    elif buil[b][f][r] < 0: buil[b][f][r] = 0
    i += 1

for i in range(4):
        if i != 0: print("#"*20)
        for j in range(3):
                for k in range(10):
                    print(" %d" %(buil[i][j][k]),end ="")
                print()
#ABC157.B
A = list(input().split()for l in range(3))
N = int(input())
b = [int(input())for _ in range(N)]
for i in b:
    if i in A:
        A[A.index(i)]=0
if A[0]==0 and A[1]==0 and A[2]==0:
    print('Yes')
elif A[3]==0 and A[4]==0 and A[5]==0:
    print('Yes')
elif A[6]==0 and A[7]==0 and A[8]==0:
    print('Yes')

elif A[0]==0 and A[3]==0 and A[6]==0:
    print('Yes')
elif A[1]==0 and A[4]==0 and A[7]==0:
    print('Yes')
elif A[2]==0 and A[5]==0 and A[8]==0:
    print('Yes')

elif A[0]==0 and A[4]==0 and A[8]==0:
    print('Yes')
elif A[2]==0 and A[4]==0 and A[6]==0:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

#ABC157.B
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
A3 = list(map(int,input().split()))
N = int(input())
b = [int(input())for _ in range(N)]
if (A1[0] in b)and (A1[1]in b)and (A1[2] in b):
    print('Yes')
elif (A2[0]in b)and(A2[1] in b)and(A2[2]in b):
    print('Yes')
elif (A3[0]in b)and(A3[1]in b)and (A3[2]in b):
    print('Yes')
elif (A1[0]in b)and(A2[0]in b)and(A3[0]in b):
    print('Yes')
elif (A1[1]in b)and (A2[1]in b)and(A3[1]in b):
    print('Yes')
elif (A1[2] in b)and (A2[2]in b)and(A3[2]in b):
    print('Yes')
elif (A1[0]in b)and (A2[1]in b)and(A3[2]in b):
    print('Yes')
elif (A1[2]in b)and (A2[1]in b)and(A3[0]in b):
    print('Yes')
else:
    print('No')
#include<iostream>
using namespace std;

int main(){
    long long n, k;
    cin >> n >> k;
    long long ans = 0;

    for (int i = k; i <= n+1; ++i){
        ans += i * (n - i + 1) + 1;
        ans %= 1000000007;
    }
    cout << ans << endl;
}

### FIXED CODE ###

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

ans = 0
for i in range(k, n+2):
    ans += i * (n - i + 1) + 1
    ans %= 1000000007

print(ans)
n=int(input())
ans=0
for _ in range(n):
  x,u=input().split()
  if u==JPY:
    ans+=int(x)
  else:
    ans+=380000*float(x)
print(ans)

### FIXED CODE ###

n=int(input())
ans=0
for _ in range(n):
  x,u=input().split()
  if u=='JPY':
    ans+=int(x)
  else:
    ans+=380000*float(x)
print(ans)
n = list(map(int,input().split()))
ans = 0
if n[1] % 2 == 0 and n[2] % 2 == 0:
  ans = n[2] - n[1]
  print(ans//2)
else:
  if n[0] - n[2] < n[1] - 1:
    ans = n - n[1]
  else:
    ans = n[2] - 1
  print(ans)

### FIXED CODE ###

n = list(map(int,input().split()))
ans = 0
if (n[2] - n[1]) % 2 == 0:
  ans = (n[2] - n[1]) // 2
else:
  ans = min(n[0] - n[2] + 1, n[1] - 1 + 1)
  ans += abs(n[2] - n[1] - 1) // 2

print(ans)
n,T=map(int,input().split())
ck=[]
times=[]
l=[]
t=0
s=0
count=0
for i in range(n):
    ck=list(map(str,input().split()))

nck=sorted(ck,reverse=True)
for i in range(n):
    for i in range(n):
        t+=1
        s=t*int(nck[i-1][0])+int(nck[i-1][1])
        t+=s
        count+=1
        if t>T:
            t-=s
            n-=1
            times.append(count)
            nck.remove(nck[0])
            break
print(max(times))


### FIXED CODE ###

s=input()
a=[str(c) for c in s]
if len(a)%2!=0:
    print("No")
    exit()
for i in range(len(a)):
    if i%2==1:
        if a[i]!="i":
            print("No")
            exit()
    else:
        if a[i]!="h":
            print("No")
            exit()
print("Yes")
from itertools import accumulate
N, C = map( int, input().split())
timetable = [ [0]*(10**5+2) for _ in range(C+1)]
for _ in range(N):
    s, t, c = map( int, input().split())
    timetable[c][s-1] += 1
    timetable[c][t] -= 1
for c in range(1,C+1):
    timetable[c] = list( accumulate(timetable[c]))
ans = 0
for i in range(1,10*5+1):
    now = 0
    for c in range(1,C+1):
        if timetable[c][i] > 0:
            now += 1
    ans = max( now, ans)
print(ans)

### FIXED CODE ###

N, A, B = map( int, input().split())
print( min(A*N,B))
*l = map(int, input().split())
if len(set(l)) == 2:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

l = list(map(int, input().split()))
if len(set(l)) == 2:
    print('Yes')
else:
    print('No')
n,k = map(int,input().split())
a = list(map(int,input().split()))
li = [1,]
ans = [0] * n 
tmp = 1
ind = []
count = 0
for i in range(10**5):
    li.append(a[tmp-1])
    ans[tmp-1] += 1
    tmp = a[tmp-1]
    for j in range(len(ans)):
        if ans[j] == 2:
            count = sum(ans) -1
            ind.append(j)
            ans[j] = 3
    if any(item > 3 for item in ans):
        break
s = count-2*len(ind)-1

if k <= s:
    print(a[k])
else:
    print(a[ind[(k-s+1) % (s+1) -2]])

### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
 
visited = []
tf_visited = [0] * n
pos = 0
count = 0
 
while tf_visited[pos] == 0:
	visited.append(pos)
	tf_visited[pos] = 1
	pos = a[pos]-1
	count += 1
	if count >= k:
		print(pos+1)
		exit()
 
loop_start = visited.index(pos)
loop_length = len(visited)-loop_start
pos_t = (k-loop_start) % loop_length + loop_start
print(visited[pos_t]+1)
print(7-'SUN,MON,TUE,WED,THU,FRI,SAT'.split().index(input()))

### FIXED CODE ###

print(7-'SUN,MON,TUE,WED,THU,FRI,SAT'.split(',').index(input()))
n = int(input())

for i in range(0, n):
    a = int(input())
    b = int(input())
    if len(str(a + b)) > 80
        print("overflow")
    elif len(str(a)) > 80:
        print("overflow")
    elif len(str(b)) > 80
        print("overflow")
    else :
        print(a + b)

### FIXED CODE ###

n = int(input())

for i in range(0, n):
    a = int(input())
    b = int(input())
    if len(str(a + b)) > 80:
        print("overflow")
    elif len(str(a)) > 80:
        print("overflow")
    elif len(str(b)) > 80:
        print("overflow")
    else :
        print(a + b)
N = int(input())
xylist = [[0, 0]]*N
for i in range(N):
  xy = list(map(int, input().split()))
  xylist[i] = xy

dl = {}
for i in range(N):
  for j in range(i+1, N):
    dx = str(xylist[j][0] - xylist[i][0])
    dy = str(xylist[j][1] - xylist[i][1])
    l = dx + "|" + dy
    if l in dl:
      dl[l] = dl[l] + 1
    else:
      dl[l] = 1

print(N - max(dl.values()))

### FIXED CODE ###

N = int(input())
xylist = [[0, 0]]*N
for i in range(N):
  xy = list(map(int, input().split()))
  xylist[i] = xy

dl = {}
for i in range(N):
  for j in range(N):
    dx = str(xylist[j][0] - xylist[i][0])
    dy = str(xylist[j][1] - xylist[i][1])
    l = dx + "|" + dy
    if dx == "0" and dy == "0":
      continue
    if l in dl:
      dl[l] = dl[l] + 1
    else:
      dl[l] = 1

cnt = 0
if len(dl) != 0:
  cnt = N - max(dl.values())

print(cnt if cnt > 1 else "1")
def abc053_b():
    s = str(input())

    start = int(s.index('a'))
    
    for i in range(len(s), 0, -1):
        if s[i] == "z":
            return i - start


if __name__ == '__main__':
    print(abc053_b())

### FIXED CODE ###

def abc053_b():
    s = str(input())

    start = s.index('A')
    end = 0
    for i in range(len(s) - 1, 0, -1):
        if s[i] == "Z":
            return i - start + 1


if __name__ == '__main__':
    print(abc053_b())
n, q = map(int, input().split())

road = [[] for _ in range(n)]
cnt = [0 for _ in range(n)]

for i in range(n - 1):
    a, b = map(int, input().split())
    road[a - 1].append(b - 1)
    road[b - 1].append(a - 1)

for i in range(q):
    idx, v = map(int, input().split())
    cnt[idx - 1] += v

dist = [-1] * n
que = deque()
dist[0] = 0
que.append(0)

while(len(que) != 0):
    # BFS/DFS
    v = que.pop()
    for r in road[v]:
        if dist[r] != -1:
            continue
        # print(r, v)
        dist[r] = dist[v] + 1
        print(cnt)
        cnt[r] += cnt[v]
        que.append(r)
print(*cnt)


### FIXED CODE ###

from collections import deque
n, q = map(int, input().split())

road = [[] for _ in range(n)]
cnt = [0 for _ in range(n)]

for i in range(n - 1):
    a, b = map(int, input().split())
    road[a - 1].append(b - 1)
    road[b - 1].append(a - 1)

for i in range(q):
    idx, v = map(int, input().split())
    cnt[idx - 1] += v

dist = [-1] * n
que = deque()
dist[0] = 0
que.append(0)

while(len(que) != 0):
    # BFS/DFS
    v = que.pop()
    for r in road[v]:
        if dist[r] != -1:
            continue
        # print(r, v)
        dist[r] = dist[v] + 1
        cnt[r] += cnt[v]
        que.append(r)
print(*cnt)
#coding:utf-8
import numpy as np
c = []
c.append (list(map(int, input().split())))
c.append (list(map(int, input().split())))
c.append (list(map(int, input().split())))
c = np.array(c)
if np.sum(c)/3 == c[0]+c[4]+c[8]:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

#coding:utf-8
n = int(input())
a = int(input())
if n%500 <= a:
    print("Yes")
else:
    print("No")
arr, =map(int, input().split())
print(max(arr) - min(arr))

### FIXED CODE ###

arr = list(map(int, input().split()))
print(max(arr) - min(arr))
import sys

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
past_city = [1]
n = 0

for i in range(K):
    if len(past_city) == len(A) or i == K:
        print(past_city[-1])
        sys.exit()
    if A[past_city[i] - 1] in past_city:
        n = i + 1
        break
    past_city.append(A[past_city[i] - 1])
rem = K % n
print(past_city[rem])

### FIXED CODE ###

import sys

N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
A = [0] + A
town = 1
visited = [0]*(N+1)

for i in range(1, K+1):
    town = A[town]
    if visited[town] == 0:
        visited[town] = i
    else:
        loop = i - visited[town]
        place = (K - visited[town]) % loop + visited[town]
        print(visited.index(place))
        sys.exit()
print(town)
k = int(input())

from functools import reduce
def gcd_list(numbers):
  return reduce(math.gcd, numbers)

total = 0
for i in range(1, k+1):
  for j in range(i, k+1):
    for k in range(j, k+1):
      if i == j and j == k and i == k:
        x = 1
      elif i != j and i != k and j != k:
        x = 6
      else:
        x = 3
        
      total += x * gcd_list([i, j, k])
print(total)

### FIXED CODE ###

from itertools import combinations
import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

n = int(input())

total = 0
for i in range(1, n+1):
    for j in range(i, n+1):
        for k in range(j, n+1):
            if  i == j and j == k and i == k:
                x = 1
            elif i != j and j != k and i != k:
                x = 6
            else:
                x = 3
            
            total += x * gcd_list([i, j, k])
        
print(total)
from math import factorial
X, Y = map(int,input().split())
if (X+Y)%3!=0:
    print(0)
else:
    itr=(X+Y)//3
    x_mx=itr*2
    flag=0
    ir=-1
    for i in range(itr,x_mx+1,1):
        ir+=1
        if X==i and Y==x_mx-ir:
            flag=1
            break
    print(flag)
    if flag==1:
        g=factorial(itr)/factorial(ir) / factorial(itr-ir)
        print(int(g%(10**9+7)))
    elif flag==0:
        print(0)

### FIXED CODE ###

X, Y = map(int,input().split())
# https://qiita.com/derodero24/items/
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

if (X+Y)%3!=0:
    print(0)
else:
    itr=(X+Y)//3
    x_mx=itr*2
    if itr<=X and X<=x_mx and itr<=Y and Y<=x_mx and X+Y==itr+x_mx:
        c=X-itr
        f=cmb(itr, c)
        f=f%(10**9+7)
        print(f)
    else:
        print(0)
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())
S = np.array(read().split(),np.int64)

def F(d):
    # 公差を固定
    L = S[::d].cumsum()
    R = S[::-d].cumsum()
    if (N-1)%d == 0:
        n = (N-1)//d
        x = np.arange(1,n+2)
        bl = (x+x <= n+1)
        L = L[bl]; R = R[bl]
    return (L+R).max()

def G(n):
    # 項数n+1を固定
    D = (N-1)//n
    L = np.zeros(D+1,np.int64)
    R = np.zeros(D+1,np.int64)
    for i in range(1,n+1):
        L += S[:i*(D+1):i]
        R += S[::-1][:i*(D+1):i]
    ok = np.ones(D+1,np.bool)
    overlap = (np.arange(D+1) * (n+n) >= N-1)
    overlap[1:] &= ((N-1)%np.arange(1,D+1) == 0)
    x = L+R
    x[overlap] = 0
    return x.max()

L = (N-1)**.5 + 10
L = min(N-1,L)

x = max(F(n) for n in range(1,L+1))
y = max(F(n) for n in range(1,L+1))
answer = max(x,y)
print(answer)

### FIXED CODE ###

import numpy as np

N = int(input())
S = np.array([int(x) for x in input().split()],dtype=np.int64)

# 右移動着地点：等差数列、ゴール含む
# 左移動着地点：等差数列、スタート含む

answer = 0
for d in range(1,N):
  # d = A-B
  cum_left = np.cumsum(S[::d])
  cum_right = np.cumsum(S[::-1][::d])
  score = cum_left + cum_right # 等差数列の長さ-1 -> 得点
  # あとは、その経路がルール内で実現できるかどうか
  for L,s in enumerate(score):
    if answer >= s:
      continue
    # 右左に進んでいることの確認
    A = N-1-L*d
    B = A-d
    if A <= 0:
      continue
    if A<=B:
      continue
    if B<=0:
      continue
    # 同じ場所を取っていないかの確認
    # kd = N-1-ldとなるとまずい
    # 約数のとき、Ld >= N-Ldだとまずい
    if (N-1)%d == 0 and 2*L*d >= N-1:
      continue
    answer = s

print(answer)
import itertools
import numpy as np

X = int(input())
L = list(range(X))
L = list(itertools.accumulate(L))

def getNearestValue(list, num):
    idx = np.abs(np.asarray(list) - num).argmin()
    return list[idx]

tmp = getNearestValue(L, X)
tmp1 = abs(X-tmp)
print(L.index(tmp)+tmp1)

### FIXED CODE ###

X=int(input())
res=0
for i in range(X+1):
  if i*(i+1)//2>=X:
    res=i
    break
print(res)