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

x = int(input())


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


p = factorization(x)
# print(p)
Bas = 0
Aas = 0
for i in range(1):
    _p = p[i][0]
    # print(_p)
    B = 0
    while True:

        xnew = (B + _p)**5 - B ** 5
        # print(xnew)
        if xnew == x:
            Bas = B
            Aas = B + _p
            break
        if xnew > x:
            B -= 1
        else:
            B += 1

print(f'{Aas} {Bas}')


### FIXED CODE ###

x = int(input())


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


p = factorization(x)
p = make_divisors(x)
# print(p)
Bas = 0
Aas = 0

flg = False
# p.append([1, 1])
# print(p)
for i in range(len(p)):
    if flg:
        break
    _p = p[i]
    # print(_p)
    B = int(-_p/2)

    while True:

        xnew = (B + _p)**5 - B ** 5
        # print(B, xnew)
        if xnew == x:
            Bas = B
            Aas = B + _p
            flg = True
            break

        if xnew > x:
            break

        B += 1


print(f'{Aas} {Bas}')
### BUGGY CODE ###

import bisect
from collections import Counter
from itertools import combinations
from math import factorial
n, a = list(map(int, input().split()))
xs = list(map(lambda x: int(x) - a, input().split()))

xs.sort()
l, r = bisect.bisect_left(xs, 0), bisect.bisect_right(xs, 0)
low, n0, high = xs[:l], r - l, xs[r:]
if len(low) > len(high):
    low, high = high, low

factor = 2 ** n0
lsums = sum((Counter(map(sum, combinations(low, 1 + i))) for i in range(len(low))), Counter())
hsums = sum((Counter(map(sum, combinations(high, 1 + i))) for i in range(len(high))), Counter())

ans = 0
for lsum, cnt in lsums.items():
    ans += cnt * hsums[-lsum]
ans *= factor
if n0:
    ans += (2 ** n0 - 1)

print(ans)

### FIXED CODE ###

import bisect
from collections import Counter, deque
from itertools import combinations, accumulate
from math import factorial
from operator import neg
n, a = list(map(int, input().split()))
xs = list(map(lambda x: int(x) - a, input().split()))

xs.sort()
l, r = bisect.bisect_left(xs, 0), bisect.bisect_right(xs, 0)
low, n0, high = list(map(neg, xs[:l][::-1])), r - l, xs[r:]

def sums(arr):
    cntr = Counter([0])
    for v in arr:
        tmps = tuple(cntr.items())
        for u, cnt in tmps:
            cntr[u + v] += cnt
    del cntr[0]
    return cntr

lsums = sums(low)
hsums = sums(high)

ans = sum(hsums[a] * b for a, b in lsums.items())

ans *= 2 ** n0
ans += 2 ** n0 - 1

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

import functools
# import collections
import fractions
N = int(input())
A = [int(i) for i in input().split()]
S = set(A)


mod = 10**9 + 7


def multiple(a, b):
    return a*b // fractions.gcd(a, b)


def lcm(nums):
    return functools.reduce(multiple, nums)


lcm = lcm(S)

ans = 0
for a in A:
    ans += lcm//a
    ans %= mod
print(ans)


### FIXED CODE ###

import functools
import fractions
N = int(input())
A = [int(i) for i in input().split()]
S = set(A)


mod = 10**9 + 7


def multiple(a, b):
    return a*b // fractions.gcd(a, b)


def lcm(nums):
    return functools.reduce(multiple, nums)


lcm = lcm(S)

ans = 0
for a in A:
    ans += lcm//a
    # ans %= mod
print(ans % mod)
### BUGGY CODE ###

n, q = map(int, input().split())
s = input()
for i in range(q):
    l, r = map(int, input().split())
    c = s[l-1:r]
    print((len(c)-len(c.replace("AC", "")))//2)

### FIXED CODE ###

n, q = map(int, input().split())
s = input()
m = [0]
c = 0
for i in range(1, n):
    if (s[i-1] == "A") & (s[i] == "C"):
        c += 1
    m.append(c)

for j in range(q):
    l, r = map(int, input().split())
    print(m[r-1] - m[l-1])
### BUGGY CODE ###

n=int(input())
l=[]
c=0
for i in range (n):
  a=input()
  if not a in l:
    l.append(a)
    c+=1
    
print(c)

### FIXED CODE ###

n = int(input())
s = [str(input()) for i in range(n)]
print(len(set(s)))
### BUGGY CODE ###

a, b, k = [int(i) for i in input().split()]
print(*[i for i in range(a, b + 1) if i < a + k or b - k < i], sep="\n")

### FIXED CODE ###

a, b, k = [int(i) for i in input().split()]
print(*([i for i in range(a, min(a + k, b + 1))] + [i for i in range(max(a + k, b - k + 1), b + 1)]), sep="\n")
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 9)

n,k = map(int,input().split())
s = []
for i in range(k):
  l,r = map(int,input().split())
  s.append((l,r))
s.sort(key=lambda x:x[1], reverse=True)
MOD = 998244353

memo = [-1 for _ in range(n+1)]

def f(x):
  if x < 1:
    return 0
  if x == 1:
    return 1
  if memo[x] != -1:
    return memo[x]
  res = 0
  for l,r in s:
    for i in range(r,l-1,-1):
      res += f(x-i)
      res %= MOD
  memo[x] = res
  return res

print(f(n))


### FIXED CODE ###

# D - Leaping Tak
n,k = map(int,input().split())
lr = [tuple(map(int,input().split())) for _ in range(k)]
MOD = 998244353

# 累積和を使ってもらうdpを効率よく実現する。

dp = [0 for _ in range(n+1)]
dpsum = [0 for _ in range(n+1)]
dp[1] = 1
dpsum[1] = 1
for i in range(2,n+1):
  for li,ri in lr:
    r = i-li
    if r < 1:
      continue
    l = max(i-ri-1,0)
    dp[i] += dpsum[r]-dpsum[l]
    dp[i] %= MOD
  dpsum[i] += dpsum[i-1]+dp[i]
  dpsum[i] %= MOD
print(dp[n])
### BUGGY CODE ###

N,S =map(int,input().split())
A=list(map(int,input().split()))
mod=998244353
ans=0
q=[0]*(S+1)
for i in range(N):
    q[0]+=1
    q2=[0]*(S+1)
    for j in range(S+1):
        q[j]%=mod
        q2[j]+=q[j]
        if (j + A[i]) <= S:
            q2[j+A[i]]+=q[j]
    q = q2
    ans+=q[S]
    ans%=mod
print(ans)


### FIXED CODE ###

N,S =map(int,input().split())
A=list(map(int,input().split()))
mod=998244353
ans=0
q=[0]*(S+1)
for i in range(N):
    q2=q.copy()
    if A[i]<=S:
        for j in range(A[i],S+1):
            q[j]+=q2[j-A[i]]
        q[A[i]]+=i+1
    ans+=q[S]
    ans%=mod
print(ans)
### BUGGY CODE ###

N = int(input())
H = list(map(int,input().split()))
H.append(10**10)
tmp = 0
for i in range(0,N-2):
    new_tmp = 0
    j = i
    while H[j] >= H[j+1]:
        new_tmp += 1
        j += 1
    if new_tmp > tmp:tmp = new_tmp
print(tmp)

### FIXED CODE ###

N = int(input())
H = list(map(int,input().split()))
tmp = 0
new_tmp = 0
i = N-1
while i >= 1:
    if H[i] <= H[i-1]:
        new_tmp += 1
        i -= 1
        if new_tmp > tmp:
            tmp = new_tmp
    else:
        if new_tmp > tmp:
            tmp = new_tmp
        new_tmp = 0
        i -= 1
print(tmp)
### BUGGY CODE ###

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

while len(HP_list)>1:
    HP_list.sort()
    #attacked_list = [HP_list[-1]%i for i in HP_list[:-1]]
    HP_list[-1] = min([HP_list[-1]%i for i in HP_list[:-1]])
    HP_list.sort()
    if HP_list[0] == 0:
        HP_list=HP_list[1:]
print(HP_list[0])

### FIXED CODE ###

import numpy as np
N = int(input())
HPs = np.array([int(i) for i in input().split()])
np.sort(HPs)
while len(HPs) > 1:
    HPs[1:] %= HPs[0]
    HPs[HPs==0] = HPs[0]
    HPs=np.unique(HPs)
print(HPs[0])
### BUGGY CODE ###

S=input()
T=input()


def search():
    pos=0
    now=""
    for i,t in enumerate(T):
        if t in S:
            if not t in now:
                now+=S
            ind=now.index(t)+1
            now=now[ind:]

            pos+=ind
        else:
            return -1
    return pos

print(search())

### FIXED CODE ###

import collections
import bisect
S = input()
T = input()
N = len(S)

d = collections.defaultdict(list)
for i, s in enumerate(S):
    d[s].append(i + 1)

ans = 0
end = 0
isOK = True
i = 0

for t in T:
    if len(d[t]) == 0:
        isOK = False
        break
    dic = d[t]
    idx = bisect.bisect_right(dic, i)
    if len(dic) == idx:
        i = dic[0]
        end += 1
    else:
        i = dic[idx]

if isOK:
    ans = N * end + i
else:
    ans = -1

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

n,k,q = map(int, input().split())
a = []
for i in range(q):
  a.append(int(input()))
for i in range(n):
  temp = k-q+a.count(i+1)
  if temp>0:
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

n,k,q = map(int, input().split())
point = [k-q for i in range(n)]
for i in range(q):
  a = int(input())
  point[a-1] += 1
for i in range(n):
  if point[i]>0:
    print("Yes")
  else:
    print("No")
### BUGGY CODE ###

n = int(input())

ans = 0
for a in range(1, n):
    for b in range(1, n):
        if a * b < n:
            ans += 1
        else:
            break
print(ans)

### FIXED CODE ###

n = int(input())

ans = 0
for a in range(1, n):
    ans += (n - 1) // a
print(ans)
### BUGGY CODE ###

n=int(input())
a=list(input())
a.sort()
for i in range(n):
  print(a.count(str(i+1)))




### FIXED CODE ###

n=int(input())
a=list(map(int,input().split(" ")))
t=[0 for i in range(n)]
for i in range(n-1):
  b=a[i]
  t[b-1]=t[b-1]+1
for j in range(n):
  print(t[j])
### BUGGY CODE ###

import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = list(map(int,input().split()))
    A.sort(reverse = True)
    M = max(A)
    ex = [0 for _ in range(M+1)]
    for i in range(N):
        ex[A[i]] += 1
        
    
    def exp(x):
        l = len(str(bin(x))[2:])
        return 2**l

    ans = 0
    for i in range(N):
        use = A[i]
        if ex[use] == 0:
            continue
        ex[use] -= 1
        pare = exp(use)-use
        if ex[pare] != 0:
            ex[pare] -= 1
            ans += 1
    
    print(ans)
    
if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import defaultdict
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = list(map(int,input().split()))
    d = defaultdict(int)
    for x in A:
        d[x] += 1
    A = list(set(A))
    A.sort(reverse = True)
    l = len(A)
    
    def exp(x):
        l = len(str(bin(x))[2:])
        return 2**l

    ans = 0
    for i in range(l):
        a = A[i]
        if exp(a)//2 == a:
            ans += int(d[a]//2)
        else:
            m = min(d[a],d[exp(a)-a])
            ans += m
            d[a] -= m
            d[exp(a)-a] -= m
            
    print(ans)
    
if __name__ == "__main__":
    main()
### BUGGY CODE ###

N = int(input())

q = int(1e9+7)

comb = [1]

for i in range(0, N):
    comb.append((comb[-1] * (N - i) * pow(i+1, q-2, q)) % q)

base = [pow(8, N-2, q)]
for i in range(2, N+1):
    base.append((base[-1] * pow(8, q-2, q)) % q)

ans = 0
for i in range(2, N + 1):
    ans = (ans + (base[i-2] * comb[i] * (pow(2, i, q) - 2)) % q) % q
print(ans)

### FIXED CODE ###

N = int(input())

q = int(1e9+7)

print((pow(10, N, q) - 2 * pow(9, N, q) + pow(8, N, q)) % q)
### BUGGY CODE ###

h,w=map(int,input().split())
a,s=[],[["x"for i in range(w+2)]]
for i in range(h):
  t,tt=input(),[]
  for j in range(w):
    if t[j]=="#":a.append([i+1,j+1])
    tt.append(t[j])
  s.append(["x"]+tt+["x"])
s.append(["x"for i in range(w+2)])
f=1
while 1:
  b=[]
  for k in a:
    i,j=k[0],k[1]
    if s[i-1][j]==".":s[i-1][j]=f;b.append([i-1,j])
    if s[i+1][j]==".":s[i+1][j]=f;b.append([i+1,j])
    if s[i][j-1]==".":s[i][j-1]=f;b.append([i,j-1])
    if s[i][j+1]==".":s[i][j+1]=f;b.append([i,j+1])
  a=b[:]
  f+=1
  if len(a)==0:break
print(f-2)

### FIXED CODE ###

from collections import deque
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
d=deque()
dc=0
b=[]
for i in range(h):
  t=[]
  s=input()
  for j in range(w):
    if s[j]=="#":d.append((i,j));dc+=1;t.append(1)
    else:t.append(0)
  b.append(t)
count=0
while dc!=0:
  ld=dc
  dc=0
  for i in range(ld):
    x=d.popleft()
    if x[0]<h-1:
      if b[x[0]+1][x[1]]==0:b[x[0]+1][x[1]]=1;d.append((x[0]+1,x[1]));dc+=1
    if 0<x[0]:
      if b[x[0]-1][x[1]]==0:b[x[0]-1][x[1]]=1;d.append((x[0]-1,x[1]));dc+=1
    if x[1]<w-1:
      if b[x[0]][x[1]+1]==0:b[x[0]][x[1]+1]=1;d.append((x[0],x[1]+1));dc+=1
    if 0<x[1]:
      if b[x[0]][x[1]-1]==0:b[x[0]][x[1]-1]=1;d.append((x[0],x[1]-1));dc+=1
  count+=1
print(count-1)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
input = sys.stdin.readline
 
# bisect_left(lists, 3)
# bisect_right(lists, 3)
 
def main():
	N, M = map(int, input().split(" "))
	#N = int(input())
	#S = input()

	A = input().split(" ")
	A = list(A)
	#A = A[:-1]
	A = [int(s) for s in A]

	BC = []
	for i in range(M):
		b, c = map(int, input().split(" "))
		BC.append((b, c))

	for i in BC:
		A.sort()
		b, c = i
		for j in range(b):
			#print("sss")
			if c > A[j]:
				A[j] = c
			else:
				break
		#print(A)

	ans = 0
	for i in A:
		ans += i
	print(ans)


if __name__ == "__main__":
	main()

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
input = sys.stdin.readline
 
# bisect_left(lists, 3)
# bisect_right(lists, 3)

# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

def main():
	N, M = map(int, input().split(" "))
	#N = int(input())
	#S = input()

	A = input().split(" ")
	A = list(A)
	#A = A[:-1]
	A = [(int(s) * (-1), 1) for s in A]
	heapq.heapify(A)

	for i in range(M):
		b, c = map(int, input().split(" "))
		heapq.heappush(A, (c * (-1), b))
	
	ans = []
	for i in range(N):
		t, con = heapq.heappop(A)
		for _ in range(con):
			if len(ans) == N:
				print(sum(ans))
				sys.exit()
			ans.append(t * (-1))
	print(sum(ans))


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

N, K = map(int, input().split())
A = tuple(map(int, input().split()))
F = tuple(map(int, input().split()))

if sum(A) <= K:
    print(0)
else:
    def solve(N, K, A, F):
        A = sorted(A)
        F = sorted(F, reverse=True)
        l = -1
        r = 10**12
        while (r - l) > 1:
            mid = (r + l) // 2
            # 成績がmidだったとして、修行しなければならない回数を算出
            fmid = sum([max(0, a - (mid // f)) for a, f in zip(A, F)])
            if fmid <= K:
                r = mid
            else:
                l = mid
        return(r)
    print(solve(N, K, A, F))

### FIXED CODE ###

import numpy as np
N, K = map(int, input().split())
A = np.array(tuple(map(int, input().split())))
F = np.array(tuple(map(int, input().split())))

if sum(A) <= K:
    print(0)
else:
    def solve(N, K, A, F):
        A = np.sort(A)
        F = np.sort(F)[::-1]
        l = -1
        r = 10**12
        while (r - l) > 1:
            mid = (r + l) // 2
            # 成績がmidだったとして、修行しなければならない回数を算出
            fmid = (np.fmax([0]*N, A - (mid // F))).sum()
            if fmid <= K:
                r = mid
            else:
                l = mid
        return(r)
    print(solve(N, K, A, F))
### BUGGY CODE ###

i = int(input())
S = [input() for _ in range(i)]
d = {}
l = []
max = 1
for s in list(set(S)):
  if S.count(s) == max:
    max = S.count(s) 
    l.append(s)
  elif S.count(s) > max:
    max = S.count(s) 
    l = []
    l.append(s)    
#keys = sorted([k for k, v in d.items() if v == max])
for key in sorted(l):
  print(key)

### FIXED CODE ###

import collections
i = int(input())
S = collections.Counter([input() for _ in range(i)])
max_v = max(S.values())
[print(s) for s in sorted([s for s in S if S[s] == max_v])]
### BUGGY CODE ###

import numpy as np

N=int(input())
A=np.array(list(map(int,input().split())))
Q=int(input())

for step in range(Q):
    b,c=map(int,input().split())
    A[A==b]=c
    print(sum(A))

### FIXED CODE ###

N=int(input())
A=[int(x) for x in input().split()]
Q=int(input())
somme=sum(A)

from collections import Counter
D=Counter()

for l in A:
    D[l]+=1
    
for step in range(Q):
    b,c=map(int,input().split())

    if b not in D:
        print(somme)
        continue

    somme=somme+(c-b)*D[b]

    D[c]=D[c]+D[b]
    del D[b]    
    print(somme)
### BUGGY CODE ###

# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
S = str(input())

cnt = 0
cnt += S.count("R") * S.count("G") * S.count("B")

for i in range(1, N + 1):
    for j in range(i + 1, N + 1):
        k = 2 * j - i
        if k > N:
            continue
        if S[i - 1] != S[j - 1] and S[j-1] != S[k-1] and S[i -1] != S[k-1]:
            cnt -= 1

print(cnt)


### FIXED CODE ###

# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
S = str(input())

cnt = 0
cnt += S.count("R") * S.count("G") * S.count("B")

# for i in range(1, N - 1):
#     for j in range(i + 1, N):
#         k = 2 * j - i
#         if k > N :
#             continue
#         if S[i - 1] != S[j - 1] and S[j-1] != S[k-1] and S[i -1] != S[k-1]:
#             cnt -= 1

for k in range(N):
    for j in range(k):
        i = 2 * j - k
        if i < 0:
            continue
        if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
            cnt -= 1 

print(cnt)
### BUGGY CODE ###

n = int(input())

for i in range(1,n+1):
    cnt = 0
    for j in range(1, 10^2+5): #x
        for k in range(1, 10^2+5): #y
            for l in range(1, 10^2+5): #z
                if j*j+k*k+l*l+j*k+k*l+l*j == i:
                      cnt += 1
    print(cnt)

### FIXED CODE ###

n = int(input())
ans = [0 for _ in range(10**4+1)]
for x in range(1, 101): #x
    for y in range(1, 101): #y
        for z in range(1,101): #z
            if (m:=x*x+y*y+z*z+x*y+y*z+z*x) <= n:
                # print(m)
                ans[m] += 1

for i in range(n):
    print(ans[i+1])
### BUGGY CODE ###

N, M = map(int,input().split())
A = [int(i) for i in input().split()]
sumA = [0 for i in range(N + 1)]
for i in range(N):
    sumA[i + 1] = (A[i] + sumA[i]) % M
ans = 0

for j in range(N):
    ans += sumA[j:].count(sumA[j]) - 1

print(ans)

### FIXED CODE ###

from collections import defaultdict as dict
d = dict(int)
N, M = map(int,input().split())
A = [int(i) for i in input().split()]
sumA = [0 for i in range(N + 1)]
for i in range(N):
    sumA[i + 1] = (A[i] + sumA[i]) % M
ans = 0

for j in range(len(sumA)):
    ans += d[sumA[j]]
    d[sumA[j]] += 1

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

# coding: utf-8
from collections import deque
def bfs(maze, visited, sy, sx, gy, gx):
    queue = deque([[sy, sx]])
    count = 0
    while queue:
        #ここでforループを回している
        for _ in range(len(queue)):
            coord = queue.popleft()
            visited[coord[0]][coord[1]] = 1
            if coord == [gy, gx]:
                return count
            for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
                next_coord = [coord[0]+j, coord[1]+k]
                if next_coord[0] < 0 or next_coord[0] > H-1 or next_coord[1] < 0 or next_coord[1] > W-1:
                    continue
                if maze[next_coord[0]][next_coord[1]] == "." and \
                   visited[next_coord[0]][next_coord[1]] != 1:
                    queue.append(next_coord)
        count += 1

H, W = map(int, input().split())
maze = []
for i in range(H):
    tmp = list(input())
    # tmp = input()
    maze.append(tmp[:])
# print(*maze, sep="\n")
# exit()
ans = -1
for sx in range(H):
    for sy in range(W):
        for ex in range(H):
            for ey in range(W):
                if maze[sx][sy] == "#" or maze[ex][ey] == "#":
                    continue
                if sx == ex and sy == ey:
                    continue
                # maze[ex][ey] = "g"
                top = [-1]
                visited = [[-1 for _ in range(W)] for _ in range(H)]
                # dfs(sx, sy, 0)
                tmp = bfs(maze, visited, sx, sy, ex, ey)
                ans = max(ans, tmp)
print(ans)

### FIXED CODE ###

# coding: utf-8
from collections import deque
H, W = map(int, input().split())
INF = -1
maze = []
for i in range(H):
    tmp = list(input())
    maze.append(tmp[:])

def bfs(sx, sy):
    visited = [[INF for _ in range(W)] for _ in range(H)]
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    q = deque()
    q.append([sx, sy])
    visited[sx][sy] = 0
    while q:
        p = q.popleft()
        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]
            if 0 <= nx < H and 0 <= ny < W:
                if maze[nx][ny] != "#" and visited[nx][ny] == INF:
                    q.append([nx, ny])
                    visited[nx][ny] = visited[p[0]][p[1]] + 1
        dist = -1
        for i in range(H):
            dist = max(dist, max(visited[i]))
    return dist
ans = -1
for i in range(H):
    for j in range(W):
        x, y = i, j
        if maze[x][y] == "#":
            continue
        ans = max(ans, bfs(x, y))
print(ans)
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
Q=int(input())
for i in range(Q):
  B,C=map(int,input().split())
  A = [C if i==B else i for i in A]
  print(sum(A))


### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
ans=sum(A)
check=[0]*(10**5+1)
for key in A:
  check[key]+=1
Q=int(input())
for i in range(Q):
  B,C=map(int,input().split())
  if check[B]==0:
    print(ans)
  else:
    x=C-B
    ans+=check[B]*x
    print(ans)
    check[C]+=check[B]
    check[B]=0
### BUGGY CODE ###

from bisect import bisect_left, bisect_right

N, K = map(int, input().split())
As = sorted(map(int, input().split()))

def check(t):
    "if the number of the pairs (i, j) that satisfies Ai * Aj <= t is < K, return True"
    count = 0
    for i, A in enumerate(As):
        if A > 0:
            index = bisect_right(As, t//A, lo = i+1) - (i+1)
        elif A < 0:
            r_index = bisect_left(As, -((-t)//A), lo = i+1) - (i+1)
            index = (N - i - 1) - r_index
        else:
            if t < 0:
                index = 0
            else:
                index = N - i - 1
        count += index
    if count < K:
        return True
    else:
        return False


l = - (10 ** 18 + 10)
r = 10 ** 18 + 10
while r - l > 1:
    mid = (l + r) // 2
    if check(mid):
        l = mid
    else:
        r = mid

print(r)

### FIXED CODE ###

from bisect import bisect_left, bisect_right

N, K = map(int, input().split())
As = sorted(map(int, input().split()))
        
l = - (10 ** 18 + 10)
r = 10 ** 18 + 10
while True:
    mid = (l + r) // 2
    count = 0
    for i, A in enumerate(As):
        if A > 0:
            count += bisect_right(As, mid//A, lo = i+1) - (i+1)
        elif A < 0:
            count += N - bisect_left(As, -((-mid)//A), lo = i+1)
        else:
            if mid >= 0:
                count += N - i - 1
    if count < K:
        l = mid
    else:
        r = mid
    if r - l == 1:
        break

print(r)
### BUGGY CODE ###

x = input()

while x.find("ST") != -1:
    index = x.find("ST")
    x = x[:index] + x[index+2:]

print(len(x))


### FIXED CODE ###

x = input()

counter = 0
stack = []

for i in range(len(x)):
    if x[i] == "S":
        stack.append("S")
    elif stack:
        stack.pop()
        counter += 1

print(len(x) - 2 * counter)