Harryxun/stf_run huggingface dataset:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
input = sys.stdin.readline 
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_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def mod_cmb(n: int, k: int, p: int) -> int:
    if n < 0 or k < 0 or n < k: return 0
    if n == 0 or k == 0: return 1
    if (k > n - k):
        return mod_cmb(n, n - k, p)
    c = d = 1
    for i in range(k):
        c *= (n - i)
        d *= (k - i)
        c %= p
        d %= p
    return c * pow(d, p - 2, p) % p

def main():
    x, y = i_map()

    if (x+y)%3 != 0:
        print(0)
        exit()

    a = int((2*x-y) / 3)
    b = int((-x+2*y) / 3)

    if a < 0 or b < 0:
        print(0)
        exit()

    print(mod_cmb(a+b,a,MOD))

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys, re
from math import ceil, floor, sqrt, pi, factorial#, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
input = sys.stdin.readline 
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_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def mod_cmb(n: int, k: int, p: int) -> int:
    if n < 0 or k < 0 or n < k: return 0
    if n == 0 or k == 0: return 1
    if (k > n - k):
        return mod_cmb(n, n - k, p)
    c = d = 1
    for i in range(k):
        c *= (n - i)
        d *= (k - i)
        c %= p
        d %= p
    return c * pow(d, p - 2, p) % p

def main():
    x, y = i_map()

    if (x+y)%3 != 0:
        print(0)
        exit()

    a = int((2*x-y) / 3)
    b = int((-x+2*y) / 3)

    if a < 0 or b < 0:
        print(0)
        exit()

    print(mod_cmb(a+b,a,MOD))

if __name__ == '__main__':
    main()
# 各秒数を取得
X,t = map(int,input().split())
 
#残りの砂を計算し出力
Remain = X - t
if remain > 0:
    print(Remain)
else:
    print("0")

### FIXED CODE ###

# 各秒数を取得
X,t = map(int,input().split())
 
#残りの砂を計算し出力
Remain = X - t
if Remain > 0:
    print(Remain)
else:
    print("0")
while True:
    a = [int(i) for i in input().split(" ")]
    num1 = a[0]
    num2 = a[1]
    if num1 <= num2:
        print(num1,num2)
    elif num1 > num2:
        print(num2,num1)
    elif num1 == 0 and num2 == 0:
        break    
    

### FIXED CODE ###

while True:
    a = [int(i) for i in input().split(" ")]
    num1 = a[0]
    num2 = a[1]
    if num1 == 0 and num2 == 0:
        break
    elif num1 <= num2:
        print(num1,num2)
    elif num1 > num2:
        print(num2,num1)
#129d
H,W = map(int, input().split()) #H,W<=2000≒2*10^3
#∴最大で4*10^6…シンプルな処理でないと死ぬ。

input_2d = [[None] * W for _ in range(H)]

processed_input_2d_w = [[None] * W for _ in range(H)]
processed_input_2d_h = [[None] * H for _ in range(W)]

ans = 0

def cont_quantificate(seq_list):
    stored_char = seq_list[0]
    stored_index = 0
    stored_count = 1
    
    ans = []
    
    if len(seq_list)!=1:
        for i in range(1,len(seq_list)):
            
            if seq_list[i] == stored_char:
                stored_count += 1
                
            else:
                if stored_char != "#":
                    ans.extend([stored_count for _ in range(stored_count)])
                    stored_count = 1
                    stored_char = seq_list[i]
                else:
                    ans.extend([0 for _ in range(stored_count)])
                    stored_count = 1
                    stored_char = seq_list[i]
                    
        if stored_char != "#":
            ans.extend([stored_count for _ in range(stored_count)])
        else:
            ans.extend([0 for _ in range(stored_count)]) 
            
        return ans
    else:
        if stored_char != "#":
            ans = [1]
        else:
            ans = [0]
        return ans

#読み込みつつ、横方向の処理
for i in range(H):
    #読み込み
    input_row = str(input())
    input_2d[i] = [input_row[i] for i in range(len(input_row))]
    #横方向で連続している数を求める
    processed_input_2d_w[i] = cont_quantificate(input_row)

print("input")
print(input_2d)
print("横方向")
print(processed_input_2d_w)
    
#縦方向に処理する
for i in range(W):
    #縦方向で連続している数を求める
    processed_input_2d_h[i] = cont_quantificate([row[i] for row in input_2d])
    
print("縦方向")
print(processed_input_2d_h)

#回答を求める
for i in range(H):
    for j in range(W):
        ans[i][j] = processed_input_2d_w[i][j] + processed_input_2d_h[j][i]
        
print(ans)

### FIXED CODE ###

H,W = map(int, input().split())

S_array = [["#" for _ in range(W+2)]] + [["#"] + list(input()) + ["#"] for i in range(H)] + [["#" for _ in range(W+2)]]

def connection_check(target_list):
    connection = 0
    connection_list = list()
    
    for i in range(len(target_list)):
        if target_list[i]=="#":
            connection_list += [connection for _ in range(connection)]
            connection_list += [0]
            connection = 0
        elif target_list[i]==".":
            connection += 1
    
    return connection_list

W_connection_array = [[0 for _ in range(W+2)]] + [connection_check(S_array[i]) for i in range(1,H+1)] + [[0 for _ in range(W+2)]]
H_connection_array = [[0 for _ in range(H+2)]] + [connection_check([row[i] for row in S_array]) for i in range(1,W+1)] + [[0 for _ in range(H+2)]]

#print(W_connection_array)
#print(H_connection_array)

ans = 0

for i in range(1,H+1):
    for j in range(1,W+1):
        temp_ans = W_connection_array[i][j] + H_connection_array[j][i]
        if ans < temp_ans:
            ans = temp_ans

print(ans - 1) #自分自身の分の重複加算を引く
X, Y = map(int, input().split())
A = x
B = 0
if Y % 2 != 0:
  print("NO")
  quit()
else:
  while A >= 0:
    C = A*2 + B*4
    if C == Y:
      print("YES")
      quit()
     A -=1
     B +=1
print("NO")

### FIXED CODE ###

x, y = map(int, input().split())
b = 0
if y % 2 != 0:
  print("No")
  quit()
else:
  while x >= 0:
    c = x * 2 + b * 4
    if c == y:
      print("Yes")
      quit()
    x -=1
    b +=1
print("No")
mod = 10**9+7
n, k = map(int, input().split())
ans = n-k+1
print(ans)
for i in range(1, k):
    ans = int(ans*(k-i)*(n-k-i+1)/(i*(i+1)))
    print(ans % mod)


### FIXED CODE ###

# k-1Ci-1 * n-k+1Ci
mod = 10**9+7
n, k = map(int, input().split())
ans = n-k+1
print(ans)
for i in range(1, k):
    ans = ans*(k-i)*(n-k-i+1)//(i*(i+1))
    print(ans % mod)
import heapq
n,m = map(int,input().split())
j = []
for i in range(n):
    j1 = list(map(int,input().split()))
    j.append(j1)
j.sort(key=lambda x:x[1],reverse=True)
j.sort(key=lambda x:x[0])
day = 1
i = 0
q = []
ans = 0
count = 0
while day <= m and i < n:
    if day == j[i][0]:
        heapq.heappush(q,-(j[i][1]))
        ans = ans + heapq.heappop(q)*(-1)
        day = day + 1
        i = i + 1
    elif day > j[i][0]:
        heapq.heappush(q,-(j[i][1]))
        i = i + 1
        count = count + 1
    else:
        day = day + 1
        if count > 0:
            ans = ans + heapq.heappop(q)*(-1)
while day <= m and count > 0:
        ans = ans + heapq.heappop(q)*(-1)
        day = day + 1
        count = count - 1
print(ans)

### FIXED CODE ###

import heapq
n,m = map(int,input().split())
j = []
for i in range(n):
    j1 = list(map(int,input().split()))
    j.append(j1)
j.sort(key=lambda x:x[1],reverse=True)
j.sort(key=lambda x:x[0])
day = 1
i = 0
q = []
ans = 0
count = 0
while day <= m and i < n:
    if day == j[i][0]:
        heapq.heappush(q,-(j[i][1]))
        ans = ans + heapq.heappop(q)*(-1)
        day = day + 1
        i = i + 1
    elif day > j[i][0]:
        heapq.heappush(q,-(j[i][1]))
        i = i + 1
        count = count + 1
    else:
        day = day + 1
        if count > 0:
            ans = ans + heapq.heappop(q)*(-1)
            count = count - 1
while day <= m and count > 0:
        ans = ans + heapq.heappop(q)*(-1)
        day = day + 1
        count = count - 1
print(ans)
n,k = map(int,input().split())
h = list(map(input().split())
h.sort()
ans = int(0)
if k >= n:
    print(ans)
else:
    for i in range(n - k):
        ans += int(h[i])
    print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
h = list(map(int, input().split()))
h = sorted(h, reverse=True)
ans = 0
for i in range(k, n):
  ans+=h[i]
  
print(ans)
N,M = map(int,input().split())
a = []
tmp = []
for i in range(M):
    tmp = list(map(str,input().split()))
    a.append(list(tmp))

siCheck = [0 for i in range(N)]
inCheck = [0 for i in range(N)]

for i in range(M):
    if a[i][0] == '1':
        siCheck[int(a[i][1])-1] = True
    else:
        siCheck[int(a[i][1])-1] = False
    if int(a[i][1]) == N:
        inCheck[int(a[i][0])-1] = True
    else:
        inCheck[int(a[i][0])-1] = False

for i in range(M):
    if siCheck[i] and inCheck[i]:
        print('POSSIBLE')
        exit()

print('IMPOSSIBLE')

### FIXED CODE ###

from collections import deque

N, M = map(int, input().split())
route = []
for i in range(M):
    route.append(list(map(int,input().split())))

island_map = {}
for a,b in route:
    if a not in island_map:
        island_map[a] = [b]
    else:
        island_map[a].append(b)

first_island = deque()
first_island += island_map[1]
second_island = deque()

for i in first_island:
    if i in island_map:
        second_island += island_map[i]
    else:
        pass
    for j in second_island:
        if j == N:
            print('POSSIBLE')
            exit()

print('IMPOSSIBLE')
import fractions
import collections
N, K = map(int, input().split())
G = [set() for i in range(N)]

for i in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    G[a].add(b)
    G[b].add(a)

q = collections.deque()
q.append((0))
ans = K
mod = 10**9+7
r = [True]*N
r[0] = False
while(q):
    x = q.popleft()
    tmp = K - 1
    if x > 0:
        tmp -= 1
    for y in G[x]:
        if r[y]:
            r[y] = False
            q.append(y)
            ans *= tmp
            tmp -= 1
    		ans %= mod
print(ans)


### FIXED CODE ###

import collections
N,K=map(int,input().split())
G=[set() for i in range(N)]
for i in range(N-1):
  a,b=map(int,input().split())
  a-=1
  b-=1
  G[a].add(b)
  G[b].add(a)
m=0
id=9
for i in range(N):
  if len(G[i])>m:
    id=i
    m = len(G[i])
q=collections.deque()
q.append(0)
colored=[False]*N
colored[0]=True
from math import factorial
mod = 10**9 + 7
ans = K
while(q):
  x= q.popleft()
  count=0
  for y in G[x]:
    if colored[y]:
      continue
    else:
      q.append(y)
      colored[y]=True
      count+=1
      
  for i in range(count):
    ans *= K-1-(len(G[x])-count)-i
    ans %= mod
  #print(ans,count,factorial(K-1-(len(G[x])-count)),factorial(count))
print(ans)
n = list(map(int, input().split()))
s = [int(input()) for i in range(n[1])]
s.append(n[0]+1)

def stairs(x):
    if x > 2:
        return stairs(x-1) + stairs(x-2)
    elif x == 2:
        return 2
    elif x == 1 or x == 0:
        return 1

sa = [s[0]-1]
for i in range(n[1]):
    sa.append((s[i+1]-1) - (s[i]+1))
ans = 1
for k in range(len(sa)):
    ans *= stairs(sa[k])

print(ans%1000000007)


### FIXED CODE ###

n = list(map(int, input().split()))
s = [int(input()) for i in range(n[1])]
s.append(n[0]+1)
memo = [0] * 100001
def stairs(x):
    memo[0] = 1
    memo[1] = 1
    for i in range(2, x+1):
        memo[i] = memo[i-2] + memo[i-1]

salst = [s[0]-1]
for i in range(n[1]):
    sa = (s[i+1]-1) - (s[i]+1)
    salst.append(sa)
    if sa < 0:
        break
if salst[-1] < 0:
    print(0)
else:
    ans = 1
    maxnum = max(salst)
    stairs(maxnum)
    for l in salst:
        ans *= memo[l]
    print(ans%1000000007)
N = int(input())
H = list(map(int,input().split()))
ans = 0
x = 0
for i in range(N-1):
  if x[i] > x[i+1]:
    x += 1
    ans = max(ans,x)
  else:
    x = 0
print(ans)

### FIXED CODE ###

N = int(input())
H = list(map(int,input().split()))
ans = 0
x = 0
for i in range(N-1):
  if H[i] >= H[i+1]:
    x += 1
    ans = max(ans,x)
  else:
    x = 0
print(ans)
S = input()
print('ARC' if S != 'ABC else 'ABC')

### FIXED CODE ###

S = input()
print('ARC' if S == 'ABC' else 'ABC')
import itertools

n,m=map(int, input().split()) 
ab=[list(map(int, input().split())) for _ in range(m)]
#ab=Input.split()
#d：隣接行列
print(ab)
print(type(ab))
d = [[] for i in range(n)]
for i in range(m):
    a = ab[i][0]
    b = ab[i][1]
    d[a-1].append(b-1)
    d[b-1].append(a-1)
    
#per：順列列挙
per= list(itertools.permutations(range(1,n)))
cnt=0
for i in range(len(graph)):
    x = [0]+graph[i]
    for j in range(n):
        #隣接していなければ終了
        if not x[j+1] in d[x[j]]:
            break
        cnt+=1
print(cnt)
        

### FIXED CODE ###

import itertools

n,m=map(int, input().split()) 
ab=[list(map(int, input().split())) for _ in range(m)]
#ab=Input.split()
#d：隣接行列

d = [[] for i in range(n)]
for i in range(m):
    a = ab[i][0]
    b = ab[i][1]
    d[a-1].append(b-1)
    d[b-1].append(a-1)
    
#per：順列列挙
per= itertools.permutations(range(1,n))
ans=0
for i in per:
    cnt=1
    x = [0]+list(i)
    for j in range(1,n):
        #隣接していなければ終了
        if not x[j] in d[x[j-1]]:
            break
        else:
            cnt+=1
    if(cnt==n):
        ans+=1
print(ans)
#!/usr/bin/env python3
import sys


input = sys.stdin.readline
def IS(cb): return cb(input().strip())
def IL(cb): return [cb(s) for s in input().strip().split()]
def IR(cb, rows): return [IS(cb) for _ in range(rows)]
def ILL(cb, rows): return [IL(cb) for _ in range(rows)]


def solve():
    N, K = IL(int)
    A = IL(lambda x: int(x) - 1)
    memo = []
    i = 0
    while(i < N and A[i] != 0):
        memo.append(A[i])
        i += 1
    print(memo[K % len(memo)] + 1)


solve()


### FIXED CODE ###

#!/usr/bin/env python3
import sys


input = sys.stdin.readline
def IS(cb): return cb(input().strip())
def IL(cb): return [cb(s) for s in input().strip().split()]
def IR(cb, rows): return [IS(cb) for _ in range(rows)]
def ILL(cb, rows): return [IL(cb) for _ in range(rows)]


def solve():
    N, K = IL(int)
    A = IL(lambda x: int(x) - 1)
    memo = [0]
    visited = [False] * N
    i = 0
    while(not visited[A[i]]):
        memo.append(A[i])
        visited[A[i]] = True
        i = A[i]
    if K < len(memo):
        print(memo[K] + 1)
    else:
        loop = memo[memo.index(A[i]):]
        print(loop[(K - (len(memo) - len(loop))) % len(loop)] + 1)


solve()
from collections import deque
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(a[tmp-1])
            ans[j] = 3
    if any(item > 3 for item in ans):
        break
q = deque(ind)
q.rotate(-1)
s = count-2*len(ind)-1
if s >= k:
    print(li[k])
else:
    print(q[k%len(q)-s])

### 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)
n=int(input())
a=(int(i) for i input().split())
b=0
for i in a:b^=i
print(*(i^b for i in a))

### FIXED CODE ###

input()
a=[int(i) for i in input().split()]
b=0
for i in a:b^=i
print(*[i^b for i in a])
from collection import counter

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

c = counter(a)

for _ in c:
  print(_)

### FIXED CODE ###

from collections import Counter
 
n = int(input())
a = list(map(int, input().split()))
 
c = Counter(a)
 
for _ in range(1, n+1):
  print(c[_])
if n < 10:
    print(n)
elif n < 100:
    print(9)
elif n < 1000:
    print(9 + (n-99))
elif n < 10000:
    print(9 + 900)
elif n < 100000:
    print(9 + 900 + (n-9999))
elif n == 100000:
    print(9 + 900 + 90000)

### FIXED CODE ###

n = int(input())

if n < 10:
    print(n)
elif n < 100:
    print(9)
elif n < 1000:
    print(n-90)
elif n < 10000:
    print(909)
elif n < 100000:
    print(n-9090)
elif n == 100000:
    print(90909)
x = input()
print(x*x*x)

### FIXED CODE ###

n = int(input())
print(n * n * n)
import sys
import bisect
import itertools


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, readline().split()))
    a = list(map(int, readline().split()))
    a.sort()
    cor_v = a[0] * 2
    inc_v = a[-1] * 2 + 1
    while - cor_v + inc_v > 1:
        bin_v = (cor_v + inc_v) // 2
        cost = 0
        #条件を満たすcostを全検索
        for i in range(n-1, -1, -1):
            cost += n - bisect.bisect_left(a, bin_v - a[i])
            if cost >= m:
              	cost += 10 ** 100
              	cost -= 10 ** 100
                break
        #costが制約を満たすか
        if cost >= m:
            cor_v = bin_v
        else:
            inc_v = bin_v
    acm = list(itertools.accumulate([0] + a))
    t = 0
    c = 0
    for i in range(n):
        p = bisect.bisect_left(a, cor_v - a[i])
        t += acm[-1] - acm[p] + a[i] * (n - p)
        c += n - p
    print(t - (c - m) * cor_v)


if __name__ == '__main__':
    solve()


### FIXED CODE ###

import sys
import bisect
import itertools


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, readline().split()))
    a = list(map(int, readline().split()))
    a.sort()
    cor_v = a[0] * 2
    inc_v = a[-1] * 2 + 1
    while - cor_v + inc_v > 1:
        bin_v = (cor_v + inc_v) // 2
        cost = 0
        #条件を満たすcostを全検索
        for i in range(n-1, -1, -1):
            cost += n - bisect.bisect_left(a, bin_v - a[i])
        #costが制約を満たすか
        if cost >= m:
            cor_v = bin_v
        else:
            inc_v = bin_v
    acm = list(itertools.accumulate([0] + a))
    t = 0
    c = 0
    for i in range(n):
        p = bisect.bisect_left(a, cor_v - a[i])
        t += acm[-1] - acm[p] + a[i] * (n - p)
        c += n - p
    print(t - (c - m) * cor_v)


if __name__ == '__main__':
    solve()
#!/usr/bin/env pypy3
# -*- coding: utf-8 -*-

from math import log2, floor

L = int(input())

N = floor(log2(L)) + 1
edge = []

# 長さ0の辺
for i in range(1, N):
    edge.append((i, i+1, 0))

# 長さ2**(i-1)の辺
for i in range(1, N):
    edge.append((i, i+1, 2**(i-1)))

# ここまでで長さ0,...,X-1のパスが完成
X = 2 ** (N-1)

# 残りの辺
while L > X:
    r = floor(log2(L - X))
    edge.append((r + 1, N, X))
    X += 2 ** r

# 出力
M = len(edge)
print(N, M)
for e in edge:
    print(' '.join(map(str, e)))

### FIXED CODE ###

L = int(input())

def decompose(L):
    if L < 3:
        return [L]
    r = L % 3
    return [r] + decompose((L - r) // 3)

dec = decompose(L)

N = len(dec) + 1
edge = []

for w in range(dec[-1]):
    edge.append((N-1, N, w))

base = dec[-1]
for i in range(len(dec) - 2, -1, -1):
    for w in range(3):
        edge.append((i+1, i+2, w * base))
    base = 3 * base
    for w in range(dec[i]):
        edge.append((i+1, N, base + w))
    base += dec[i]

M = len(edge)
print(N, M)
for e in edge:
    print(' '.join(map(str, e)))
a, b, c = input().split()
a = int(a)
b = int(b)
c = int(c)

k = input()
k = int(k)

ans = 0

if max(a,b,c) = a:
  ans = ans + b + c
elif max(a, b, c) == b:
  ans = ans + a + c
elif max(a, b, c) == c:
  ans = ans + a + b

print(ans + max(a, b, c) * 2 * k)

### FIXED CODE ###

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

k = input()
k = int(k)

print(max(a * 2 ** k + b + c, a + b * 2 ** k + c, a + b + c * 2 ** k))
s = list(input())
if len(set(a)) != 2:
  print("No")
else:
  print("Yes")


### FIXED CODE ###

s = input()
if len(set(s)) != 2:
  print("No")
else:
  print("Yes")
from fractions import gcd

N = int(input())
T = list(map(int, input().split()))
ans = 1

for i in range(0,N):
    ans = ans * T[i] / gcd(ans, T[i])
    
print(int(ans))

### FIXED CODE ###

import fractions
 
def lcm(a,b):
  return (a*b)//fractions.gcd(a,b)
 
N=int(input())
T=1
for i in range(N):
  T=lcm(T,int(input()))
print(T)
n = input
R = 2*3.1415926535*n
print(R)

### FIXED CODE ###

n = float(input())
R = 2*3.1415926535*n
print(R)
n = int(input())
e = list(map(int, input().split))
if max(e) < sum(e) - max(e):
  print('Yes')
else:
  print('No')


### FIXED CODE ###

n = int(input())
e = list(map(int, input().split()))
if max(e) < sum(e) - max(e):
  print('Yes')
else:
  print('No')
# dp[i] := i番目の人が選ばれたときの踏み台

def main():
    # INF = 10 ** 9
    N = int(input())
    A = list(map(int, input().split()))

    # initialize
    dp = [0] * (N + 10)
    dp[0] = A[0]

    res = 0
    for i in range(1, N):
        for j in range(10**9):
            if dp[i-1] <= (tmp := A[i] + j):
                dp[i] = tmp
                res += j
                break
    print(res)

if __name__ == "__main__":
    main()

### FIXED CODE ###

# maをi-1番目までにでてる最大値としてi番目との差分を足していく

def main():
    # INF = 10 ** 9
    N = int(input())
    A = list(map(int, input().split()))

    # initialize
    ma = A[0]

    res = 0
    for i in range(1, N):
        if A[i] <= ma:
            res += ma - A[i]
        else:
            ma = A[i]
    print(res)

if __name__ == "__main__":
    main()
import math

N = [int(input()) for i in range(100)]
min_page = math.ceil(N/2)
print(min_page)


### FIXED CODE ###

import math
N = int(input())
min_page = math.ceil(N/2)
print(min_page)
A,B,C,D,E,F=map(int,input().split())

water=[0]*3001
water[100*A]=100*A
water[100*B]=100*B
for i in range(3001):
  if water[i]>0:
    if i+100*A<3001: water[i+100*A]=i+100*A
    if i+100*B<3001: water[i+100*B]=i+100*B
for i in range(1,3001):
  if water[i]==0:
    water[i]=water[i-1]
#print(water)

suger=[0]*3001
suger[C]=C
suger[D]=D
for i in range(3001):
  if suger[i]>0:
    if i+C<3001: suger[i+C]=i+C
    if i+D<3001: suger[i+D]=i+D
for i in range(1,3001):
  if suger[i]==0:
    suger[i]=suger[i-1]
#print(suger)

tmp=0
for i in water:
  w=i
  s=suger[w//100*E]
  if w+s<=F and w+s>0:
    if s/(w+s)*100>tmp:
      tmp=s/(w+s)*100
      mw=w
      ms=s
print(mw+ms,ms)

### FIXED CODE ###

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

water = [0] * (F//100 + 1)
water[0] = 1
for i in range(F//100 + 1):
  if water[i]:
    if i + A < F//100 + 1: water[i+A] = 1
    if i + B < F//100 + 1: water[i+B] = 1
water[0] = 0
#print(water)

suger = [0] * (F + 1)
suger[0] = 1
for i in range(F + 1):
  if suger[i]:
    if i + C < F + 1: suger[i+C] = 1
    if i + D < F + 1: suger[i+D] = 1
#print(suger)

max_sol = -1
answer = [0, 0]
for i in range(len(water)):
  if water[i] == 0:
    continue
  #print(i)
  for j in range(len(suger)):
    if suger[j] and i*100 + j <= F and j / (i*100 + j) <= E / (100 + E):
        if max_sol < 100 * j / (i*100 + j):
          max_sol = 100 * j / (i*100 + j)
          answer = [i*100 + j, j]
print(*answer)