Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

n = int(input())
c = 1
for i in range(1,n+1):
    for j in range(2,n+1):
        if i**j <= n:
            c = max(c,i**j)
print(c)

### FIXED CODE ###

n = int(input())
c = 1
for i in range(1,n):
    for j in range(2,n):
        if i**j <= n:
            c = max(c,i**j)
        else:
            break
print(c)
### BUGGY CODE ###

s = int(input())
a = b = 0
for i in range(-1000,1000):
  for j in range(-1000,1000):
    if i**5 - j**5 == s:
      print(i,j)
      break

### FIXED CODE ###

import sys
s = int(input())
for i in range(-120,120):
  for j in range(-120,120):
    if i**5 - j**5 == s:
      print(i,j)
      sys.exit()
### BUGGY CODE ###

from collections import deque
def main():
    h,w = map(int,input().split())
    S = [list(input()) for i in range(h)]
    q = [(i,j) for i in range(h) for j in range(w) if S[i][j]=='#']
    q = deque(q)
    ans = 0
    cnt = len(q)
    nxt = [(0,1),(1,0),(-1,0),(0,-1)]
    while cnt < h*w:
        ans += 1
        q_ = deque([])
        while len(q)>0:
            a,b = q.pop()
            for x,y in nxt:
                X,Y = a+x,b+y
                if 0>X or X>h-1 or 0>Y or Y>w-1:
                    continue
                if S[X][Y]=='.':
                    S[X][Y]='#'
                    q_.append((X,Y))
        q = q_
        cnt += len(q)
    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

from collections import deque
def main():
    h,w = map(int,input().split())
    S = [list(input()) for i in range(h)]
    q = [(i,j) for i,a in enumerate(S) for j,b in enumerate(a) if b=='#']
    q = deque(q)
    ans = 0
    s = h*w
    cnt = len(q)
    nxt = [(0,1),(1,0),(-1,0),(0,-1)]
    while cnt < s:
        ans += 1
        q_ = deque([])
        while q:
            a,b = q.pop()
            for x,y in nxt:
                X,Y = a+x,b+y
                if 0>X or X>h-1 or 0>Y or Y>w-1:
                    continue
                if S[X][Y]=='.':
                    S[X][Y]='#'
                    q_.append((X,Y))
        q = q_
        cnt += len(q_)
    print(ans)

if __name__ == "__main__":
    main()
### BUGGY CODE ###

m=input();n=int(m);a=[];i=6
while n%2==0:a+=[2];n//=2
while n%3==0:a+=[3];n//=3
while i<int(m):
 if n%(i-1)==0:a+=[i-1];n//=i-1
 elif n%(i+1)==0:a+=[i+1];n//=i+1
 else:i+=6
if n==int(m):a+=[m]
print(m+':',*a)


### FIXED CODE ###

p=lambda x:print(x,end=' ')
n=input();p(n+':')
m=n=int(n)
while n%2==0 and n>3:p(2);n//=2
d=3
while d*d<m and n>d:
 if n%d>0:d+=2
 else:p(d);n//=d
print(n)
### BUGGY CODE ###

N,M = (int(x) for x in input().split())
Now = range(1,N+1)
for T in range(0,M):
    L,R = (int(x) for x in input().split())
    Now = set(Now)&set(range(L,R+1))
print(len(Now))

### FIXED CODE ###

N,M = (int(x) for x in input().split())
Now = [0]*N
maxL = 1
minR = N
for T in range(0,M):
    L,R = (int(x) for x in input().split())
    if maxL<L:
        maxL = L
    if minR>R:
        minR = R
if maxL>minR:
    print(0)
elif maxL==minR:
    print(1)
elif maxL<minR:
    print(minR-maxL+1)
### BUGGY CODE ###

n = int(input())
s = input()
r, g, b = [], [], []
for i in range(n):
    if s[i] == 'R':
        r.append(i)
    elif s[i] == 'G':
        g.append(i)
    else:
        b.append(i)
lr, lg, lb = len(r), len(g), len(b)
ans = lr * lg * lb

if min([lr, lg, lb]) == lb:
    r, b = b, r

for i in r:
    for j in g:
        a = 2 * j - i
        c = 2 * i - j
        if a in b:
            ans -= 1
        if c in b:
            ans -= 1
        if (i + j) / 2 in b:
            ans -= 1
print(ans)

### FIXED CODE ###

n = int(input())
s = input()
r, g, b = [], [], []
for i in range(n):
    if s[i] == 'R':
        r.append(i)
    elif s[i] == 'G':
        g.append(i)
    else:
        b.append(i)
lr, lg, lb = len(r), len(g), len(b)
ans = lr * lg * lb

for i in r:
    for j in g:
        a = 2 * j - i
        c = 2 * i - j
        if 0 <= a and a <= n-1 and s[a] == 'B':
            ans -= 1
        if 0 <= c and c <= n-1 and s[c] == 'B':
            ans -= 1
        if (i + j) % 2 == 0 and s[int((i + j) / 2)] == 'B':
            ans -= 1
print(ans)
### BUGGY CODE ###

n=int(input())
s=input()
min=300000
for i in range(n):
    left=s[:i:].count("W")
    right=s[i+1:].count("E")
    if min>left+right:
        min=left+right
print(min)


### FIXED CODE ###

n=int(input())
s=input()
w=[0]*n
e=[0]*n
for i in range(n):
    if s[i]=="W":
        if i==0:
           w[i]+=1
        else:
            w[i]+=w[i-1]+1
            e[i]+=e[i-1]
    else:
        if i==0:
            e[i]+=1
        else:
            e[i]+=e[i-1]+1
            w[i]+=w[i-1]
min=9999999
for i in range(n):
    if i==0:
        num=e[n-1]-e[i]

    else:
        num=w[i-1]+e[n-1]-e[i]
    if min>num:
        min=num
print(min)
### BUGGY CODE ###

import math
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


def get_divisors(n):
    """
    n の約数をリストで返す
    :param int n:
    :rtype: list of int
    """
    ret = []
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0:
            ret.append(i)
            if n // i != i:
                ret.append(n // i)
    return ret


def can_make(div):
    mods = []
    for a in A:
        mods.append(a % div)

    mods.sort()
    left = 0
    right = len(mods) - 1
    for k in range(K + 1):
        while left < len(mods) and mods[left] % div == 0:
            left += 1
        while right >= 0 and mods[right] % div == 0:
            right -= 1
        if right < left:
            return True
        mods[left] -= 1
        mods[right] += 1
    return False


N, K = list(map(int, sys.stdin.readline().split()))
A = list(map(int, sys.stdin.readline().split()))

# 答えは絶対 A の合計の約数になる
divs = get_divisors(sum(A))
for div in sorted(divs, reverse=True):
    if can_make(div):
        print(div)
        exit()
assert False


### FIXED CODE ###

import math
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


def get_divisors(n):
    """
    n の約数をリストで返す
    :param int n:
    :rtype: list of int
    """
    ret = []
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0:
            ret.append(i)
            if n // i != i:
                ret.append(n // i)
    return ret


def can_make(div):
    mods = []
    for a in A:
        mods.append(a % div)

    mods.sort()
    left = 0
    right = len(mods) - 1
    k = K
    while left <= right and k >= 0:
        while left < len(mods) and mods[left] % div == 0:
            left += 1
        while right >= 0 and mods[right] % div == 0:
            right -= 1
        if right < left:
            return True

        m = div - mods[right]
        if mods[left] >= m:
            mods[left] -= m
            mods[right] = 0
            right -= 1
            k -= m
        else:
            mods[right] += mods[left]
            k -= mods[left]
            mods[left] = 0
            left += 1
    return k >= 0


N, K = list(map(int, sys.stdin.readline().split()))
A = list(map(int, sys.stdin.readline().split()))

# 答えは絶対 A の合計の約数になる
divs = get_divisors(sum(A))
for div in sorted(divs, reverse=True):
    if can_make(div):
        print(div)
        exit()
assert False
### BUGGY CODE ###

import sys
import math
from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

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

N = II()
l = []
ans=0
for i in range(1, N+1):
    for j in range(1, N+1):
        for k in range(1, N+1):
            l1 = []
            l1.append(i)
            l1.append(j)
            l1.append(k)
            l.append(l1)

for L in l:
    ans += gcd_list(L)
print(ans)







### FIXED CODE ###

import sys
#import fractions
from math import gcd
import itertools

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

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

def euclid(p,q):
    if p%q==0:
        return q
    else:
        return euclid(q,p%q)


N = II()

ans=0

for i in range(1, N+1):
    for j in range(1, N+1):
        x = gcd(i,j)
        for k in range(1, N+1):
            ans+=gcd(x,k)


print(ans)
### BUGGY CODE ###

N = int(input())
Alist = []
Blist = []
sumlist = []

for i in range(N):
    a,b = map(int,input().split())
    Alist.append(a)
    Blist.append(b)
    sumlist.append(a+b)

counter = 0
takahasi = 0
aoki = 0
for i in range(N):
    if counter == 0:
        takahasi += Alist[sumlist.index(max(sumlist))]
        sumlist[sumlist.index(max(sumlist))] = 0
        counter = 1
        continue
    if counter == 1:
        aoki += Blist[sumlist.index(max(sumlist))]
        sumlist[sumlist.index(max(sumlist))] = 0
        counter = 0
        continue

print(takahasi-aoki)




### FIXED CODE ###

import numpy as np

N = int(input())
Alist = []
Blist = []
sumlist = []

for i in range(N):
    a,b = map(int,input().split())
    Alist.append(a)
    Blist.append(b)
    sumlist.append(a+b)

index = np.argsort(sumlist)

sumlist = np.sort(sumlist)




counter = 0
takahasi = 0
aoki = 0

for i in range(N)[::-1]:
    if counter == 0:
        takahasi += Alist[index[i]]
        counter = 1
        continue
    if counter == 1:
        aoki += Blist[index[i]]
        counter = 0
        continue

print(takahasi-aoki)
### BUGGY CODE ###

#from math import factorial
n = int(input())
s = input()
ans = 0
for i in range(1000):
    i=str(i).zfill(3)
    now = 0
    for S in s:
        if S==i[now]:
            now+=1
        if now == 3:
            ans += 1
            break
print(ans)

### FIXED CODE ###


n = int(input())
s = input()
ans = 0
for i in range(1000):
    i=str(i).zfill(3)
    now = 0
    for S in s:
        if S==i[now]:
            now+=1
        if now == 3:
            ans += 1
            break
print(ans)
### BUGGY CODE ###

from collections import deque
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
INF=float("inf")

H,W=map(int,readline().split())
Ch,Cw=map(int,readline().split())
Dh,Dw=map(int,readline().split())
Ch-=1
Cw-=1
Dh-=1
Dw-=1
maze=list(map(str,read().rstrip().decode().split()))

path=[[INF]*W for _ in range(H)]
walk=[(1,0),(0,-1),(-1,0),(0,1)]
warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if not (i, j) in [(0, 0)] + walk]

q = deque()
path[Ch][Cw] = 0
q.append((Ch, Cw, 0))

while q:
    x, y, s = q.popleft()
    for dx, dy in walk:
        nx = x + dx
        ny = y + dy
        if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s:
            path[nx][ny] = s
            q.appendleft((nx, ny, s)) 
    for dx, dy in warp: 
        nx = x + dx
        ny = y + dy
        if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s + 1:
            path[nx][ny] = s + 1
            q.append((nx, ny, s + 1)) 
    
ans = path[Dh][Dw] if path[Dh][Dw] < INF else '-1'
print(ans)

### FIXED CODE ###

from collections import deque
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
INF=float("inf")

H,W=map(int,readline().split())
Ch,Cw=map(lambda x: int(x) - 1, readline().split())
Dh,Dw=map(lambda x: int(x) - 1, readline().split())
maze=list(map(str,read().rstrip().decode().split()))

path=[[INF]*W for _ in range(H)]
walk=[(1,0),(0,-1),(-1,0),(0,1)]
warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if not (i, j) in [(0, 0)] + walk]

q = deque()
path[Ch][Cw] = 0
q.append((Ch, Cw, 0))

while q:
    x, y, s = q.popleft()
    for dx, dy in walk:
        nx = x + dx
        ny = y + dy
        if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s:
            path[nx][ny] = s
            q.appendleft((nx, ny, s)) 
    for dx, dy in warp: 
        nx = x + dx
        ny = y + dy
        if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s + 1:
            path[nx][ny] = s + 1
            q.append((nx, ny, s + 1)) 
    
ans = path[Dh][Dw] if path[Dh][Dw] < INF else '-1'
print(ans)
### BUGGY CODE ###

import bisect

N = int(input())
A = [int(input()) for _ in range(N)]

colors = 0
a = A
while True:
    colors += 1
    p = [a[0]]
    pp = [0]
    for i in range(1,len(a)):
        if p[-1] < a[i]:
            p.append(a[i])
            pp.append(i)
        else:
            pos = bisect.bisect_left(p,a[i])
            p[pos] = a[i]
            pp[pos] = i

    if len(p) == len(a):
        break
    a = [a[x] for x in range(len(a)) if x not in pp]
print (colors)

### FIXED CODE ###

import bisect

N = int(input())
A = [-int(input()) for _ in range(N)]

p = [A[0]]
for i in A[1:]:
    if p[-1] <= i:
        p.append(i)
    else:
        p[bisect.bisect_right(p,i)] = i
print (len(p))
### BUGGY CODE ###

import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda x: [ni() for _ in range(x)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

import numpy as np

n, k = na()
p = na()

ans = 0.0
for i in range(n - k + 1):
    s = 0.0
    for j in range(k):
        a = (p[i + j] * (p[i + j] + 1) // 2) * np.reciprocal(float(p[i + j]))
        s += a
    ans = max(ans, s)

print(ans)

### FIXED CODE ###

import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda x: [ni() for _ in range(x)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

n, k = na()
p = na()
d = [0] * (n + 1)
for i in range(n):
    a = (p[i] * (p[i] + 1) // 2) * (1 / p[i])
    d[i + 1] = d[i] + a

ans = 0.0
for i in range(n - k + 1):
    a = d[i + k] - d[i]
    ans = max(ans, a)

print(ans)
### BUGGY CODE ###

import numpy as np
import sys
input = sys.stdin.readline


def main():
    n, s = map(int, input().split())
    a = [int(i) for i in input().split()]
    MOD = 998244353

    dp = np.zeros(s + 1, dtype="int32")
    dp[0] = 1

    for i in a:
        p = np.zeros(s + 1, dtype="int32")
        dp, p = p, dp
        dp += (p * 2) % MOD
        dp %= MOD
        for j in range(s + 1):
            if (ji := j + i) <= s:
                dp[ji] = (dp[ji] + p[j]) % MOD

    print(dp[s])


if __name__ == '__main__':
    main()

### FIXED CODE ###

import numpy as np
import sys
input = sys.stdin.readline


def main():
    n, s = map(int, input().split())
    A = [int(i) for i in input().split()]

    MOD = 998244353

    dp = np.zeros(s + 1, dtype="int32")
    dp[0] = 1

    for a in A:
        p = (dp * 2) % MOD
        p %= MOD
        p[a:] += dp[:-a]
        dp = p % MOD

    print(dp[s])


if __name__ == '__main__':
    main()
### BUGGY CODE ###

import sys
import functools
import itertools
import math
from collections import deque

def bfs(H, W, S):
    visited = deque()
    unvisited = deque([(1,1)])
    dist = 1
    while unvisited:
        dist += 1
        un = deque()
        for x, y in unvisited:
            visited.append((x,y))
            if S[y-1][x] != '#' and (x, y-1) not in visited:
                un.append((x, y-1))

            if S[y+1][x] != '#' and (x, y+1) not in visited:
                if y+1 == H and x == W:
                    return dist
                un.append((x, y+1))

            if S[y][x-1] != '#' and (x-1, y) not in visited:
                un.append((x-1, y))

            if S[y][x+1] != '#' and (x+1, y) not in visited:
                if y == H and x+1 == W:
                    return dist
                un.append((x+1, y))
        unvisited = un

    return -1

def main():
    H, W = map(int, input().split())
    S = ['#'+input()+'#' for _ in range(H)]
    S.insert(0,'#'*(W+2))
    S.insert(H+1,'#'*(W+2))
    step = bfs(H,W,S)
    white = sum([n.count('.') for n in S])
    if step == -1:
        print(step)
    else:
        print(white - step)

if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import deque

def bfs(H, W, S):
    visited = [[False]*(W+2) for _ in range(H+2)]
    visited[1][1] = True
    unvisited = deque([(1,1)])
    dist = 1
    while unvisited:
        dist += 1
        un = deque()
        for x, y in unvisited:
            for t1, t2 in zip([-1,+1,0,0],[0,0,-1,1]):
                dx = x + t1
                dy = y + t2
                if S[dy][dx] != '#' and not visited[dy][dx]:
                    if dy == H and dx == W:
                        return dist
                    un.append((dx,dy))
                    visited[dy][dx] = True
        unvisited = un

    return -1

def main():
    H, W = map(int, input().split())
    S = ['#'+input()+'#' for _ in range(H)]
    S.insert(0,'#'*(W+2))
    S.append('#'*(W+2))
    step = bfs(H,W,S)
    white = sum([n.count('.') for n in S])
    if step == -1:
        print(step)
    else:
        print(white - step)

if __name__ == "__main__":
    main()
### BUGGY CODE ###

#! /usr/bin/env python
# -*- coding: utf-8 -*-

''' ????????????????????£????????\??? '''


class PQueue(object):
    """ Priority Queue """

    def __init__(self):
        self.pqueue = []

    def insert(self, x):
        self.pqueue.append(x)

    def extractMax(self):
        return self.pqueue.pop(self.pqueue.index(max(self.pqueue)))


if __name__ == '__main__':

    pqueue = PQueue()
    result = []

    while True:
        line = input()
        if line == 'end':
            break

        if line.split()[0] == 'insert':
            pqueue.insert(int(line.split()[1]))
        elif line.split()[0] == 'extract':
            result.append(pqueue.extractMax())

    for i in range(len(result)):
        print(result[i])

### FIXED CODE ###

#! /usr/bin/env python
# -*- coding: utf-8 -*-

''' ????????????????????£????????\??? '''

import heapq


class PQueue(object):
    """ Priority Queue """

    def __init__(self):
        self.pqueue = []

    def insert(self, x):
        # self.pqueue.append(x)
        heapq.heappush(self.pqueue, -x)

    def extractMax(self):
        # return self.pqueue.pop(self.pqueue.index(max(self.pqueue)))
        return -heapq.heappop(self.pqueue)


if __name__ == '__main__':

    pqueue = PQueue()
    result = []

    while True:
        line = input()
        if line == 'end':
            break

        if line.split()[0] == 'insert':
            pqueue.insert(int(line.split()[1]))
        elif line.split()[0] == 'extract':
            result.append(pqueue.extractMax())

    for i in range(len(result)):
        print(result[i])
### BUGGY CODE ###

from scipy.special import comb

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

MOD = 10**9 + 7

base = 2**n - 1
a = comb(n, a, exact=True)
b = comb(n, b, exact=True)

print((base - a - b)%MOD)


### FIXED CODE ###

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

MOD = 10**9 + 7

def comb(n, r, mod):
    if r > n-r:
        r = n - r
    
    res_X = 1
    for i in range(n-r+1, n+1):
        res_X = (res_X * i)%mod
    
    res_Y = 1
    for i in range(1, r+1):
        res_Y = (res_Y * i)%mod
    
    return (res_X * pow(res_Y, mod-2, mod))%mod

base = (pow(2, n, MOD) - 1)%MOD
a = comb(n, a, MOD)
b = comb(n, b, MOD)

print((base - a - b)%MOD)
### BUGGY CODE ###

s = input()
n = len(s)
result = [0 for _ in range(n)]
t = [None for _ in range(n)]
for i in range(n):
  p = i
  if s[p] == 'R':
    p += 1
    prev = 'R'
  else:
    p -= 1
    prev = 'L'
  count = 1
  while True:
    if t[p] is not None:
      fp = t[p][0]
      fcount = count + t[p][1]
      t[i] = (fp, fcount)
      if fcount % 2 == 0:
        result[fp] += 1
      else:
        result[fp - 1] += 1
      break
    if s[p] == 'R':
      p += 1
      prev = 'R'
    else:
      if prev == 'R':
        t[i] = (p, count)
        if count % 2 == 0:
          result[p] += 1
        else:
          result[p - 1] += 1
        break
      p -= 1
      prev = 'L'
    count += 1
print(' '.join(map(str, result)))


### FIXED CODE ###

s = input()
n = len(s)
result = [0 for _ in range(n)]
start = 0
c = 'R'
for i in range(1, n):
  if s[i] != c:
    if c == 'R':
      result[i - 1] += (i - start) // 2 + (i - start) % 2
      result[i] += (i - start) // 2
      c = 'L'
    else:
      result[start] += (i - start) // 2 + (i - start) % 2
      result[start - 1] += (i - start) // 2
      c = 'R'
    start = i
result[start] += (n - start) // 2 + (n - start) % 2
result[start - 1] += (n - start) // 2
print(*result)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
S = sum(A)
x = 0
for i in range(N):
  x += (A[i] * (S - sum(A[:i+1]))) % 1000000007
x = x % 1000000007
print(x)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
S = [A[0]]
for i in range(1, N):
  S.append(S[i-1] + A[i])
x = 0
for i in range(N):
  x += (A[i] * (S[-1] - S[i])) % 1000000007
x = x % 1000000007
print(x)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
ans = 1
if 0 in A:
  	print(0)
  	exit(0)
for i in A:
    ans = ans * i
if ans > pow(10, 18):
    print(-1)
    exit(0)
else:
    print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
    exit(0)
ans = 1
for i in A:
    ans = ans * i
    if ans > pow(10, 18):
        print(-1)
        exit(0)
else:
    print(ans)
### BUGGY CODE ###

n,m = map(int,input().split())
a = []
b = []
l = []
ans = 0
count = 0

for i in range(n):
	a_dash,b_dash = map(int,input().split())
	a.append(a_dash)
	b.append(b_dash)

c = zip(a,b)
c = sorted(c)
a,b = zip(*c)
a = list(a)
b = list(b)

for i in reversed(range(m)):
	for j in range(count,count+a.count(m-i)):
		if a[j] + i == m:
			l.append(b[j])
			count += 1

	if len(l) != 0:
		ans += max(l)
		l.pop(l.index(max(l)))

print(ans)

### FIXED CODE ###

import sys
import heapq

s = sys.stdin.readlines()
n,m = map(int,s[0].split())
a = []
b = []
l = []
ans = 0
count = 0

for i in range(1,n+1):
	a_dash,b_dash = map(int,s[i].split())
	a.append(-a_dash)
	b.append(-b_dash)

c = zip(a,b)
c = sorted(c,reverse=True)
a,b = zip(*c)
a_length = len(a)

for i in reversed(range(m)):
	for j in range(count,a_length):
		if -a[j] + i == m:
			heapq.heappush(l,b[j])
			count += 1
		else:
			break
	if len(l) != 0:
		maximum = heapq.heappop(l)
		ans += maximum

print(-ans)