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

# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc084/tasks/abc084_c

"""
import sys
from sys import stdin
from collections import namedtuple
from math import ceil
input = stdin.readline


def solve(trains, N):
    arrives = []

    for i in range(N-1):
        arrives.append(0)
        for j in range(len(arrives)):
            dt = trains[i].S
            while dt < arrives[j]:
                dt += trains[i].F
            arrives[j] = dt + trains[i].C

    arrives.append(0)
    return arrives


T = namedtuple('T', ['C', 'S', 'F'])
def main(args):
    trains = []
    N = int(input())
    for _ in range(N-1):
        c, s, f = map(int, input().split())
        trains.append(T(c, s, f))
    ans = solve(trains, N)
    print(*ans, sep='\n')


if __name__ == '__main__':
    main(sys.argv[1:])


### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
https://beta.atcoder.jp/contests/abc084/tasks/abc084_c

"""
import sys
from sys import stdin
from collections import namedtuple
from math import ceil
input = stdin.readline


def solve(trains, N):
    arrives = []

    for i in range(N-1):
        arrives.append(0)
        for j in range(len(arrives)):
            t = arrives[j] - trains[i].S
            dt = max(trains[i].S, (trains[i].S + ceil(t/trains[i].F)*trains[i].F ))
            arrives[j] = dt + trains[i].C

    arrives.append(0)
    return arrives


T = namedtuple('T', ['C', 'S', 'F'])
def main(args):
    trains = []
    N = int(input())
    for _ in range(N-1):
        c, s, f = map(int, input().split())
        trains.append(T(c, s, f))
    ans = solve(trains, N)
    print(*ans, sep='\n')


if __name__ == '__main__':
    main(sys.argv[1:])
### BUGGY CODE ###

#import time
#t = []

N = int(input())

#st = time.time()

sums = [1]  # pair number sum until index
#cpos = [-1] * (2 * 10 ** 5 + 1)    # positions of each color
cpos = {}
lastc = -1  # last color of input
C = []      # color stone list

#print("prepare time [ms] = {}".format(1000 * (time.time() - st)))

for i in range(N):
    c = int(input())

#    sti = time.time()
#    st = time.time()

    if(lastc != c):
        lastc = c
        C.append(c)
        cnt = len(C)
#        print("lastc = {}, cnt = {}, C = {}".format(lastc, cnt, C))

#        print("prepare time in loop [ms] = {}".format(1000 * (time.time() - st)))
#        st = time.time()

        if(c in cpos):
            s = sums[-1]
            for pos in cpos[c]:
                s += sums[pos - 1]
            sums.append(s)
            cpos[c].append(cnt)
        else:
            sums.append(sums[-1])
            cpos[c] = [cnt]

#        print("calc time [ms] = {}".format(1000 * (time.time() - st)))
#        print("cpos = " + str(cpos))

#    print("iteration time [ms] = {}".format(1000 * (time.time() - sti)))

#print("C = " + str(C))
#print("cpos = " + str(cpos))
#print("sums = " + str(sums))

print(sums[-1] % (10 ** 9 + 7))


### FIXED CODE ###

sums = [1]  # pair number sum until index
csums = {}  # pair number sum of each color

N = int(input())
C = []      # color stone list
lastc = -1  # last color of input
for i in range(N):
    c = int(input())
    if(lastc == c):
        continue
    lastc = c
    C.append(c)

#print("C = " + str(C))

for i, c in enumerate(C, 1):
    if(c in csums):
        sums.append(sums[-1] + csums[c])
        csums[c] += sums[i - 1]
    else:
        sums.append(sums[-1])
        csums[c] = sums[i - 1]

#    print("i = {}, c = {}".format(i, c))
#    print("csums = " + str(csums))
#    print("sums = " + str(sums))

print(sums[-1] % (10 ** 9 + 7))
### BUGGY CODE ###

x = int(input())
t = 0
i = 0
while t < x:
    t = int(t*(1.01))
    i += 1
 
print(i)

### FIXED CODE ###

x = int(input())
t = 100
i = 0
while t < x:
    t = int(t*(1.01))
    i += 1
 
print(i)
### BUGGY CODE ###

from sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) for x in stdin.readline().rstrip().split()]

score = 1
for i in range(0,K):
    score*=A[i]

for i in range(K,N):
    tmp = score
    score *= A[i]
    score //= A[i-K]
    if score > tmp:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

from sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) for x in stdin.readline().rstrip().split()]

for i in range(K,N):
    if A[i] > A[i-K]:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

N,w = [int(x) for x in input().split()]
ll = []
for i in range(N):
    abc = [int(x) for x in input().split()]
    ll.append(abc)
DP = [[0]*(w+1) for i in range(N+1)]
for i in range(1,N+1):
    for j in range(1,w+1):
        if ll[i-1][0] <= j:
            DP[i][j] = max(DP[i-1][j-ll[i-1][0]]+ll[i-1][1],DP[i-1][j])
        else:
            DP[i][j] = DP[i-1][j]
print(DP[N][w])

### FIXED CODE ###

N,w = [int(x) for x in input().split()]
ll = []
for i in range(N):
    abc = [int(x) for x in input().split()]
    ll.append(abc)
DP = [[0]*(w+1) for i in range(N+1)]
for i in range(1,N+1):
    for j in range(1,w+1):
        if ll[i-1][0] <= j:
            DP[i][j] = max(DP[i-1][j-ll[i-1][0]]+ll[i-1][1],DP[i-1][j])
        else:
            DP[i][j] = DP[i-1][j]
print(DP[N][w])
### BUGGY CODE ###

n, p = map(int, input().split())
S = list(map(int, list(input())))

if p == 2 or p == 5:
  ans = 0
  for i, x in enumerate(S[::-1]):
    if x % p == 0:
      ans += n - i
else:
  mods = [0 for _ in range(p)]
  mods[0] = 1

  num = 0
  digit = 1
  for s in S[::-1]:
    num = (s * digit + num) % p
    mods[num] += 1
    digit = digit * 10
  
  ans = 0
  for m in mods:
    ans += m * (m - 1) // 2

print(ans)


### FIXED CODE ###

n, p = map(int, input().split())
S = list(map(int, list(input())))

if p == 2 or p == 5:
  ans = 0
  for i, x in enumerate(S[::-1]):
    if x % p == 0:
      ans += n - i
else:
  mods = [0 for _ in range(p)]
  mods[0] = 1

  num = 0
  digit = 1
  for s in S[::-1]:
    num = (s * digit + num) % p
    mods[num] += 1
    digit = (digit * 10) % p
  
  ans = 0
  for m in mods:
    ans += m * (m - 1) // 2

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

N = int(input())

res = 0
for i in range(N):
    res += i

print(res)


### FIXED CODE ###

N = int(input())

res = (N - 1) * N // 2

print(res)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
A_set = list(set(A))

Ad = {a_set:A.count(a_set) for a_set in A_set}

score_sum = sum([x*(x-1)/2 for x in list(Ad.values())])

for a in A:
    print(int(score_sum - (Ad[a] - 1)))


### FIXED CODE ###

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

# A_set = list(set(A))
# Ad = {a_set:A.count(a_set) for a_set in A_set}
Ad = {}
for i in A:
  if not i in Ad:
    Ad[i]=0
  Ad[i] += 1

score_sum = sum([x*(x-1)/2 for x in list(Ad.values())])

for a in A:
    print(int(score_sum - (Ad[a] - 1)))
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)

N,Q = map(int,input().split())
to = [[] for _ in range(N+1)]
ans = [0 for _ in range(N+1)]

for _ in range(N-1):
    a,b=map(int,input().split())
    to[a].append(b)
    to[b].append(a)
for _ in range(Q):
    px = list(map(int,input().split()))
    ans[px[0]] += px[1]

def dfs(v, p):
    for u in to[v]:
        if u == p:
            continue
        ans[u] += ans[v]
        dfs(u, v)
dfs(1, -1)
print(*ans[1:])


### FIXED CODE ###

from collections import deque
n,q=map(int, input().split())
l=[[] for i in range(n+1)]
ans=[0]*(n+1)

for i in range(n-1):
    a,b=[int(j) for j in input().split()]
    l[a].append(b)
    l[b].append(a)
for i in range(q):
    p,x=[int(j) for j in input().split()]
    ans[p]+=x

que=deque()
que.append(1)
ll=[0]*(n+1)
while que:
    y=que.popleft()
    ll[y]=1
    for i in l[y]:
        if ll[i]==1:
            continue
        ans[i]+=ans[y]
        que.append(i)
print(*ans[1:])
### BUGGY CODE ###

from collections import Counter
N = int(input())
S = Counter([input() for _ in range(N)])
if len(S) == 1:
    print(list(S)[0])
    exit()
for k, val in sorted(S.most_common()):
    if val == max(S.values()):
        print(k)

### FIXED CODE ###

from collections import Counter
N = int(input())
S = Counter([input() for _ in range(N)])
v = max(S.values())
s = sorted(S.most_common())
if len(S) == 1:
    print(list(S)[0])
    exit()
for k, val in s:
    if val == v:
        print(k)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

n, k, q = map(int, input().split(' '))
t = [int(input()) for i in range(q)] 
 
ans = [k] * n
 
for i in range(max(t)):
    score = i + 1
    ans[i] += t.count(score)
    
for i in ans:
  if i  - q > 0:
    print('Yes')
  else:
    print('No')

### FIXED CODE ###

import sys
input = sys.stdin.readline
import collections

n, k, q = map(int, input().split(' '))
t = [int(input()) for i in range(q)] 
 
ans = [k - q] * n

t_cnt = collections.Counter(t)
for i, j in t_cnt.items():
  ans[i-1] += j

for i in ans:
  if i > 0:
    print('Yes')
  else:
    print('No')
### BUGGY CODE ###

N = int(input())
T = list(map(int, input().split()))
A = list(map(int, input().split()))
h = []
for i in range(N):
    if i == 0:
        h.append(1)
    elif i == N - 1:
        h.append(1)
    else:
        if T[i] > T[i - 1]:
            h.append(1)
            if T[i] > A[i]:
                h[i] = 0
                break
        elif A[i] > A[i + 1]:
            h.append(1)
            if A[i] > T[i]:
                h[i] = 0
                break
        else:
            h.append(min([A[i], T[i]]) % 1000000007)

if max(T) != max(A):
    h.append(0)
    
cnt = 1
for i in range(len(h)):
    cnt *= h[i]
                     
print(cnt % 1000000007)

### FIXED CODE ###

N = int(input())
T = list(map(int, input().split()))
A = list(map(int, input().split()))
h = []
for i in range(N):
    if i == 0:
        h.append(1)
    elif i == N - 1:
        h.append(1)
    else:
        if T[i] > T[i - 1]:
            h.append(1)
            if T[i] > A[i]:
                h[i] = 0
                break
        elif A[i] > A[i + 1]:
            h.append(1)
            if A[i] > T[i]:
                h[i] = 0
                break
        else:
            h.append(min([A[i], T[i]]))

if max(T) != max(A):
    h.append(0)
    
cnt = 1
for i in range(len(h)):
    cnt *= h[i]
    cnt %= 1000000007
                     
print(cnt % 1000000007)
### BUGGY CODE ###

#!/usr/bin/python
# -*- coding: UTF-8 -*-

import sys


def get_ints():
    return map(int, sys.stdin.readline().strip().split())


def std_in():
    return sys.stdin.readline().strip()


def calc_score(a, f, e):
    score = 1

    for i in range(f, e):
        score *= a[i]
    return score


def main():
    n, k = get_ints()
    a = list(get_ints())

    score = calc_score(a, 0, k)

    for i in range(k, n):
        if a[i-k] == 0:
            n_score = calc_score(a, i-k+1, i+1)
        else:
            n_score = int(score / a[i-k] * a[i])

        if n_score > score:
            print("Yes")
        else:
            print("No")
        score = n_score


if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/python
# -*- coding: UTF-8 -*-

import sys


def get_ints():
    return map(int, sys.stdin.readline().strip().split())


def main():
    n, k = get_ints()
    a = list(get_ints())

    for i in range(k, n):
        if a[i] > a[i-k]:
            print("Yes")
        else:
            print("No")


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

def lucas(n):
    if n == 0:
        return 2
    elif n == 1:
        return 1
    return lucas(n - 1) + lucas(n - 2)
    
n = int(input())
print(lucas(n))

### FIXED CODE ###

def lucas(n):
    if n == 0:
        return 2
    elif n == 1:
        return 1
    return lucas(n - 1) + lucas(n - 2)
    
n = int(input())
lucas = [0 for i in range(87)]
lucas[0] = 2
lucas[1] = 1
for i in range(2, n + 1):
    lucas[i] = lucas[i - 1] + lucas[i - 2]
print(lucas[n])
### BUGGY CODE ###

import sys

input = sys.stdin.readline
import fractions



def main():
    N = int(input())
    A = tuple([int(x) for x in input().split()])
    MOD = 10 ** 9 + 7

    x = 1
    for a in A:
        x = (a * x) // fractions.gcd(a, x)

    ans = 0
    for a in A:
        ans %= MOD
        ans += x // a

    print(ans % MOD)



    
    

if __name__ == '__main__':
    main()



### FIXED CODE ###

import sys

input = sys.stdin.readline
import fractions



def main():
    N = int(input())
    A = tuple([int(x) for x in input().split()])
    MOD = 10 ** 9 + 7

    x = 1
    for a in A:
        x = (a * x) // fractions.gcd(a, x)

    ans = 0
    for a in A:
        ans += x // a

    print(ans % MOD)



    
    

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

import numpy as np
n = int(input())
s = input()
q = int(input())
al = "abcdefghijklmnopqrstuvwxyz"
al = {al[i]:i for i in range(26)}

def get(i):
    return np.identity(26)[al[i]]


bit = [np.zeros(26) for _ in range(n+1)]


def ko(i, j):
    global bit
    while i <= n:
        bit[i] += j
        i += i & (-i)


def su(i):
    s = np.zeros(26)
    while i != 0:
        s += bit[i]
        i -= i & (-i)
    return s


a = []
for i in range(n):
    ko(i + 1, get(s[i]))
    a.append(get(s[i]))
for _ in range(q):
    kind, i, j = [k for k in input().split()]
    i = int(i)
    if int(kind) == 1:
        ko(i, get(j)-a[i-1])
        a[i-1] = get(j)
    else:
        j = int(j)
        b = su(j) - su(i-1)
        k = 0
        for i in b:
            if i != 0:
                k += 1
        print(k)


### FIXED CODE ###

n = int(input())
s = input()
q = int(input())


class SegmentTree:
    def __init__(self, a, func=max, one=-10 ** 18):
        self.logn = (len(a) - 1).bit_length()
        self.n = 1 << self.logn
        self.func = func
        self.one = one

        self.b = [self.one] * (2 * self.n - 1)
        for i, j in enumerate(a):
            self.b[i + self.n - 1] = j
        for i in reversed(range(self.n - 1)):
            self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2])

    def get_item(self, i):
        return self.b[i + self.n - 1]

    def update(self, index, x):
        i = index + self.n - 1
        self.b[i] = x
        while i != 0:
            i = (i - 1) // 2
            self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2])

    def update_func(self, index, x):
        i = index + self.n - 1
        self.b[i] = self.func(self.b[i], x)
        while i != 0:
            i = (i - 1) // 2
            self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2])

    def get_segment(self, l, r, i=0):
        j = i - (1 << ((i + 1).bit_length() - 1))+1
        length = 1 << (self.logn - (i + 1).bit_length() + 1)
        ll = j * length
        rr = (j + 1) * length
        if l <= ll and rr <= r:
            return self.b[i]
        elif rr <= l or r <= ll:
            return self.one
        else:
            return self.func(self.get_segment(l, r, i * 2 + 1),
                             self.get_segment(l, r, i * 2 + 2))


def get_int(s):
    abc = "abcdefghijklmnopqrstuvwxyz"
    return 1<<abc.index(s)


seg = SegmentTree([get_int(i) for i in s], int.__or__, 0)

for _ in range(q):
    q, i, j = input().split()
    if q == "1":
        seg.update(int(i) - 1, get_int(j))
    else:
        aa = seg.get_segment(int(i) - 1, int(j))
        ans = 0
        for i in range(26):
            if (aa >> i) & 1 == 1:
                ans += 1
        print(ans)
### BUGGY CODE ###

import sys, math, itertools, bisect, copy, re
from collections import Counter, deque, defaultdict

# from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
# from functools import reduce
# from math import ceil, floor, log10, log2, factorial
# from pprint import pprint


INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -7
sys.setrecursionlimit(1000000)

# N = int(input())
# N,M = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]
# DP = [[0] * 100 for _ in range(100)]
# DP = defaultdict(lambda: float('inf'))

H, W = [int(x) for x in input().split()]
A = []
BQ = deque()
for _ in range(H):
    L = list(input())
    A.append(L)

for x in range(W):
    for y in range(H):
        if A[y][x] == '#':
            BQ.append((x, y))


def check(a):
    a2 = sum(a, [])
    cnt = a2.count('.')
    return cnt == 0


def ok(x, y, W, H):
    if x >= 0 and x < W and y >= 0 and y < H:
        return True
    return False


# X,Y座標
DX = [1, -1, 0, 0]
DY = [0, 0, 1, -1]

cnt = 0
while check(A) == False:
    newBQ = deque()
    for (x, y) in BQ:
        for (dx, dy) in zip(DX, DY):
            X = x + dx
            Y = y + dy
            if ok(X, Y, W, H) and A[Y][X] == '.':
                A[Y][X] = '#'
                newBQ.append((X, Y))
    cnt += 1

    # print("len:{}".format(len(newBQ)))
    # for a in A:
    #     print(a)
    # print("---")

    BQ = newBQ

print(cnt)


### FIXED CODE ###

import sys, math, itertools, bisect, copy, re
from collections import Counter, deque, defaultdict

# from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
# from functools import reduce
# from math import ceil, floor, log10, log2, factorial
# from pprint import pprint


INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -7
sys.setrecursionlimit(1000000)

# N = int(input())
# N,M = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]
# DP = [[0] * 100 for _ in range(100)]
# DP = defaultdict(lambda: float('inf'))

H, W = [int(x) for x in input().split()]
A = []
BQ = deque()
for _ in range(H):
    L = list(input())
    A.append(L)

bCnt = 0
for x in range(W):
    for y in range(H):
        if A[y][x] == '#':
            BQ.append((x, y))
            bCnt += 1


def check(a):
    a2 = sum(a, [])
    cnt = a2.count('.')
    return cnt == 0


def ok(x, y, W, H):
    if x >= 0 and x < W and y >= 0 and y < H:
        return True
    return False


# X,Y座標
DX = [1, -1, 0, 0]
DY = [0, 0, 1, -1]

cnt = 0

while bCnt != H * W:
    newBQ = deque()
    for (x, y) in BQ:
        for (dx, dy) in zip(DX, DY):
            X = x + dx
            Y = y + dy
            if ok(X, Y, W, H) and A[Y][X] == '.':
                A[Y][X] = '#'
                newBQ.append((X, Y))
                bCnt += 1

    cnt += 1

    # print("len:{}".format(len(newBQ)))
    # for a in A:
    #     print(a)
    # print("---")

    BQ = newBQ

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

from sys import stdin
readline = stdin.readline
def i_input(): return int(readline().rstrip())
def i_map(): return map(int, readline().rstrip().split())
def i_list(): return list(i_map())


def main():
    N = i_input()
    A = i_list()
    ans = 0
    for i, a in enumerate(A):
        for ii, aa in enumerate(A):
            if i == ii:
                continue
            if a % aa == 0:
                break
        else:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()


### FIXED CODE ###

from sys import stdin
readline = stdin.readline
def i_input(): return int(readline().rstrip())
def i_map(): return map(int, readline().rstrip().split())
def i_list(): return list(i_map())

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

def main():
    N = i_input()
    A = i_list()
    ans = 0
    max_a = max(A)
    p = [0] * (max_a + 1)
    for i in A:
        for j in range(i , max_a + 1, i):
            p[j] += 1
    for i in A:
        if p[i] < 2:
            ans += 1
    print(ans)

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

import sys
input = sys.stdin.readline

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

SUM=[0]*(N+2)
end=[[] for i in range(N+2)]

for l,r,a in SCORE:
    end[r+1].append((l,a))
    SUM[l]+=a
    SUM[r+1]-=a

import itertools
SUM=list(itertools.accumulate(SUM))

#遅延Segment tree
seg_el=1<<(N+1).bit_length()#Segment treeの台の要素数
seg_el2=seg_el-1#Segment treeの最下段の最初の要素
seg_el3=seg_el2//2#下から二段目の最初の要素

SEG=[0]*(2*seg_el-1)#Segment tree.色々考えると0で初期化してOKそう
LAZY=[0]*seg_el2#伝搬用Segment tree

def propagation(k):#子ノードへ伝搬
    
    if k<seg_el3 and LAZY[k]!=0:
        
        SEG[k*2+1]+=LAZY[k]
        SEG[k*2+2]+=LAZY[k]
        LAZY[k*2+1]+=LAZY[k]
        LAZY[k*2+2]+=LAZY[k]
        LAZY[k]=0

        return

    if k<seg_el2 and LAZY[k]!=0:
        
        SEG[k*2+1]+=LAZY[k]
        SEG[k*2+2]+=LAZY[k]
        LAZY[k]=0

def updates(a,b,x,k,l,r):#区間[a,b)にxを加算
    
    if r<=a or b<=l:#区間[a,b)が対象区間の外にあれば終了
        return
    
    if a<=l and r<=b:
        SEG[k]+=x#そのノードを更新
        if k<seg_el2:
            LAZY[k]+=x#後でアクセスされたときに子ノードを更新
        return

    propagation(k)#アクセスした箇所にデータが入っていたときは,評価を伝搬させる
    
    updates(a,b,x,k*2+1,l,(l+r)//2)#それ以外のときは,SEG[k*2+1]とSEG[k*2+2]で場合分け
    updates(a,b,x,k*2+2,(l+r)//2,r)

    if SEG[k*2+1]>SEG[k*2+2]:#そのノードを更新（再帰的に値が求まる）
        SEG[k]=SEG[k*2+1]
    else:
        SEG[k]=SEG[k*2+2]

def update_solo(n,x,seg_el):#A[n]=xに更新（反映）
    i=n+seg_el-1
    SEG[i]=x
    i=(i-1)//2
    
    while i>=0:
        if SEG[i*2+1]>SEG[i*2+2]:
            SEG[i]=SEG[i*2+1]
        else:
            SEG[i]=SEG[i*2+2]
        i=(i-1)//2

for i in range(1,N+2):

    for j in end[i]:
        updates(j[0],i,j[1],0,0,seg_el)

    update_solo(i,SEG[0],seg_el)#[0,i)の最大値はSEG[0]と一致するはず

print(SEG[0])

### FIXED CODE ###

import sys
input = sys.stdin.readline

N,M=map(int,input().split())

end=[[] for i in range(N+2)]

for i in [0]*M:
    l,r,a=map(int,input().split())
    end[r+1].append((l,a))

#Starry Sky tree
seg_el=1<<18#Segment treeの台の要素数

SEG=[0]*(2*seg_el-1)#Segment tree.色々考えると0で初期化してOKそう
ADD=[0]*(2*seg_el-1)#加算用Segment tree,SEG[k]+ADD[k]がkにおける本当の最大値
seg_el_list=[524286, 262142, 131070, 65534, 32766, 16382, 8190, 4094, 2046, 1022, 510, 254, 126, 62, 30, 14, 6, 2, 0]

def update(k):#SEGのkより上のノードを更新（反映）
    while k>=0:
        k=(k-1)//2
        if SEG[k]==max(SEG[k*2+1]+ADD[k*2+1],SEG[k*2+2]+ADD[k*2+2]):
            break
        SEG[k]=max(SEG[k*2+1]+ADD[k*2+1],SEG[k*2+2]+ADD[k*2+2])

def to_seg(a):#aが終点となる区間をSegment treeの座標へ変換  
    b=(a&(-a)).bit_length()
    return seg_el_list[b]+a//(1<<(b-1))

def add(a,b,x):#区間(a,b]にxを加算
    #print(a,b,x)
    while b!=0:
        ADD[to_seg(b)]+=x
        update(to_seg(b))
        b-=(b&(-b))

    while a!=0:
        ADD[to_seg(a)]+=-x
        update(to_seg(a))
        a-=(a&(-a))
    
for i in range(N+2):
    for b,k in end[i]:
        add(b,i,k)#点数がもらえる区間から出たときにその分を加算

    SEG[i+seg_el-1]=SEG[0]
    update(i+seg_el-1)

print(SEG[0])
### BUGGY CODE ###

N, K = list(map(int, input().split()))
p = list(map(int, input().split()))

expected_value = []
for i in range(len(p)):
    value = 0
    for j in range(1, p[i] + 1):
        value += j / p[i]
    expected_value.append(value)

### K個合算した数値の配列
cumsum = []
cumsum_temp = 0
for i in range(len(p) - K + 1):
    if i == 0:
        cumsum_temp = sum(expected_value[:K])
    else:
        cumsum_temp = cumsum_temp - expected_value[i - 1] + expected_value[i + K - 1]
    cumsum.append(cumsum_temp)
# print(f"N:{N} K:{K} expected_value:{expected_value} cumsum:{cumsum}")

print(max(cumsum))



### FIXED CODE ###

N, K = list(map(int, input().split()))
p = list(map(int, input().split()))

expected_value = []
for i in range(len(p)):
    expected_value.append((p[i] + 1)/ 2)

### K個合算した数値の配列
cumsum = []
cumsum_temp = 0
for i in range(len(p) - K + 1):
    if i == 0:
        cumsum_temp = sum(expected_value[:K])
    else:
        cumsum_temp = cumsum_temp - expected_value[i - 1] + expected_value[i + K - 1]
    cumsum.append(cumsum_temp)
# print(f"N:{N} K:{K} expected_value:{expected_value} cumsum:{cumsum}")

print(max(cumsum))
### BUGGY CODE ###

X = str(input())
X = X.replace("ST","")
lx = len(X)
st = []

for i in range(lx):
  if X[i] == "S":
    st.append("S")
  else:
    if "S" in st:
      st.pop()
    else:
      st = ["T"] + st
   
print(len(st))

### FIXED CODE ###

X = str(input())
X = X.replace("ST","")
lx = len(X)
s_count = 0
t_count = 0
for i in range(lx):
  if X[i] == "S":
    s_count += 1
  else:
    if s_count:
      s_count -= 1
    else:
      t_count += 1
   
print(s_count + t_count)