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

N = int(input())
S = input()
ans = 0
T = {'R', 'G', 'B'}
is_R, is_G, is_B = [], [], []

for i in S:
    is_R.append(i=='R')
    is_G.append(i=='G')
    is_B.append(i=='B')
    
sum_R = [0] + is_R
sum_G = [0] + is_G
sum_B = [0] + is_B

for i in range(1, N+1):
    sum_R[i] = sum_R[i-1] + sum_R[i]
    sum_G[i] = sum_G[i-1] + sum_G[i]
    sum_B[i] = sum_B[i-1] + sum_B[i]
    
dict_RGB = {'R':(is_R, sum_R), 'G':(is_G, sum_G), 'B':(is_B, sum_B)}

for i in range(N-2):
    s_i = S[i]
    for j in range(i+1, N-1):
        s_j = S[j]
        if s_i == s_j:
            continue
        
        s_k = list(T - set((s_i, s_j)))[0]
        
        is_s_k, sum_s_k = dict_RGB[s_k]
        ans = ans + sum_s_k[-1] - sum_s_k[j]
        if (2 * j - i < N) and (is_s_k[2*j - i]):
            ans -= 1
        
    
print(ans)

### FIXED CODE ###

N = int(input())
S = input()
ans = 0
T = {'R', 'G', 'B'}
sum_R, sum_G, sum_B = [0], [0], [0]
 
for i in S:
    sum_R.append(i=='R')
    sum_G.append(i=='G')
    sum_B.append(i=='B')
    
for i in range(1, N+1):
    sum_R[i] = sum_R[i-1] + sum_R[i]
    sum_G[i] = sum_G[i-1] + sum_G[i]
    sum_B[i] = sum_B[i-1] + sum_B[i]
    
dict_RGB = {'R':sum_R, 'G':sum_G, 'B':sum_B}
 
for i in range(N-2):
    s_i = S[i]
    for j in range(i+1, N-1):
        s_j = S[j]
        if s_i == s_j:
            continue
        
        s_k = list(T - set((s_i, s_j)))[0]
        
        sum_s_k = dict_RGB[s_k]
        ans = ans + sum_s_k[-1] - sum_s_k[j]
        if (2 * j - i < N) and (S[2*j - i]==s_k):
            ans -= 1
        
    
print(ans)
### BUGGY CODE ###

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

queue = []
ans = 0
popAt = -1
for i in range(N):
    for j in range(popAt + 1,len(queue)):
        if queue[j][1] & A[i] != 0:
            ans += i - queue[j][0]
            popAt = j
        else:
            queue[j][1] += A[i]
    queue.append([i,A[i]])

popAt += 1
z = ((N - popAt) * (N - popAt + 1)) // 2
print(ans+z)


### FIXED CODE ###

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

cur = A[0]
ans = 0
rp = 1
for lp in range(N):
    while rp < N and cur & A[rp] == 0:
        cur += A[rp]
        rp += 1
    ans += rp - lp
    cur -= A[lp]
    
print(ans)
### BUGGY CODE ###

from math import factorial
mod=10*9+7

def comb(a,r):
  return factorial(a) / factorial(r) / factorial(a - r)%mod

n,a,b=map(int,input().split())
ans=((2**n-1)%(10**9+7)-comb(n,a)-comb(n,b))
print(int(ans))

### FIXED CODE ###

mod=10**9+7
n,a,b=map(int,input().split())
ans=pow(2,n,mod)-1 #n種類の花を使って花束を作る総数は2^n-1通り
comb1=1 #nCaの計算
for i in range(n-a+1,n+1): #n*(n-1)*…*(n-a+1)を計算
 comb1*=i
 comb1%=mod
for i in range(1,a+1): #1/a!=1/(1*2*…*a)=1^(p-2)*2^(p-2)*…*a^(p-2) (p=10**9+7)を計算
 comb1*=pow(i,mod-2,mod)
 comb1%=mod
comb2=1
for i in range(n-b+1,n+1): #n*(n-1)*…*(n-b+1)を計算
 comb2*=i
 comb2%=mod
for i in range(1,b+1): #1/b!=1/(1*2*…*b)=1^(p-2)*2^(p-2)*…*b^(p-2) (p=10**9+7)を計算
 comb2*=pow(i,mod-2,mod)
 comb2%=mod
ans-=(comb1+comb2) #nCa、nCbを総数から引く
ans%=mod
print(ans)
### BUGGY CODE ###

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

### FIXED CODE ###

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

import numpy as np
from collections import deque

@np.vectorize
def trans(s):
    return True if s == "#" else False

def parse(inp):
    H, W = map(int, next(inp).split())
    return np.array([trans([w for w in next(inp).strip()]) for _ in range(H)])

def appender(i, j, H, W, C, S, Q):
    s = S[i, j]
    if i + 1 < H and not C[i+1, j] and np.logical_xor(s, S[i+1, j]):
        Q.append((i + 1, j))
    if i > 0 and not C[i-1, j] and np.logical_xor(s, S[i-1, j]):
        Q.append((i - 1, j))
    if j + 1 < W and not C[i, j+1] and np.logical_xor(s, S[i, j+1]):
        Q.append((i, j + 1))
    if j > 0 and not C[i, j-1] and np.logical_xor(s, S[i, j-1]):
        Q.append((i, j - 1))

def search(S, start, C):
    Q = deque([start])
    H, W = S.shape
    n0 = 0
    n1 = 0
    while Q:
        i, j = Q.popleft()
        if C[i, j]:
            continue
        else:
            C[i, j] = True
            if S[i, j] == 0:
                n0 += 1
            else:
                n1 += 1
            appender(i, j, H, W, C, S, Q)
    return n0, n1


def search_all(S):
    C = np.full_like(S, False).astype(np.bool)
    D = np.full_like(S, 0)
    ret = 0
    for i in range(S.shape[0]):
        for j in range(S.shape[1]):
            if D[i, j] == 0:
                n0, n1 = search(S, (i, j), C)
                D += C
                ret += n1 * n0
                if np.all(D):
                    return ret
                else:
                    C[:, :] = False




import sys
    
print(search_all(parse(sys.stdin)))

### FIXED CODE ###


import numpy as np
from collections import deque
import sys

def parse(inp):
    H, W = map(int, next(inp).split())
    return np.array([list(next(inp).strip()) for _ in range(H)])

dis = [0, 0, 1, -1]
djs = [1, -1, 0, 0]

def search(S, i, j, Q, R):
    H, W = S.shape
    R[i, j] = True
    Q.append((i, j))
    n0 = 0
    n1 = 0
    while Q:
        i, j = Q.popleft()
        if S[i, j] == "#":
            n1 += 1
        else:
            n0 += 1
        gen = ((i + di, j + dj) for di, dj in zip(dis, djs))
        ijs = (g for g in gen if 0 <= g[0] and g[0] < H and 0 <= g[1] and g[1] < W)
        for ni, nj in ijs:
            if not R[ni, nj] and S[ni, nj] != S[i, j]:
                R[ni, nj] = True
                Q.append((ni, nj))
    return n0 * n1


def test(S):
    i, j = 0, 0
    Q = deque()
    R = np.full(S.shape, False)
    H, W = S.shape
    n = 0
    for i in range(H):
        for j in range(W):
            if not R[i, j]:
                n += search(S, i, j, Q, R)
    return n

print(test(parse(sys.stdin)))
### BUGGY CODE ###

from collections import deque
h, w = map(int, input().split())
area = []
h += 2
w += 2
INF = -1

for i in range(h):
    if i == 0 or i == h-1:
        array = ['#'] * w
    else:
        array = list(input())
        array.insert(0, '#')
        array.append('#')
    area.append(array)

line = []
for i in range(h):
    for j in range(w):
        if area[i][j] == '#':
            line.append(INF)
        else:
            line.append(1)


def bfs(start):
    unsearched_points = deque()
    searched_points = deque()
    distance_matrix = [INF for _ in range(h*w)]
    unsearched_points.append(start)
    distance_matrix[start] = 0
    while len(unsearched_points) > 0:
        current_point = unsearched_points.popleft()
        searched_points.append(current_point)
        for move in (-1, 1, -w, w):
            if line[current_point+move] == 1 and current_point+move not in searched_points:
                unsearched_points.append(current_point+move)
                distance_matrix[current_point+move] = distance_matrix[current_point] + 1
    return max(distance_matrix)

max_distance = 0
for i in range(len(line)-w):
    if line[i] == INF:
        continue
    else:
        distance = bfs(i)
        if max_distance < distance:
            max_distance = distance

print(max_distance)

### FIXED CODE ###

from collections import deque

h, w = map(int, input().split())

area = [[] for _ in range(h+2)]

for i in range(h+2):
    if i == 0 or i == h+1:
        area[i] = ['#'] * (w+2)
    else:
        area[i] = list(input())
        area[i].insert(0, '#')
        area[i].append('#')

def bfs(i, j):
    distance_matrix = [[1000 for _ in range(w+2)] for _ in range(h+2)]
    distance_matrix[i][j] = 0
    move = [[-1,0],[1,0],[0,-1],[0,1]]
    d = deque()
    d.append([i, j])
    max_distance = 0
    while len(d) > 0:
        x, y = d.popleft()
        for q, v in move:
            if area[x+q][y+v] =='.' and distance_matrix[x+q][y+v] == 1000:
                d.append([x+q,y+v])
                distance = distance_matrix[x][y] + 1
                distance_matrix[x+q][y+v] = distance
                if distance > max_distance:
                    max_distance = distance
    return max_distance

max_distance = 0
for i in range(1, h+1):
    for j in range(1, w+1):
        if area[i][j] == '#':
            continue
        else:
            distance = bfs(i, j)
            if distance > max_distance:
                max_distance = distance


print(max_distance)
### BUGGY CODE ###

N = int(input())
a = [] 
for i in range(N-1):
    a.append(list(map(int, input().split())))
min_time = []
for i in range(N-1):
    t_min = [0]
    for j in range(N-1-i):
        start_time = a[i+j][1]
        while start_time < t_min[j]:
            start_time = start_time + a[i+j][2]
        goal_time = start_time + a[i+j][0]
        t_min.append(goal_time)
    min_time.append(t_min[-1])
for i in range(N-1):
    print(min_time[i])
print(0)

### FIXED CODE ###

n = int(input())
csf = []
for i in range(n - 1):
    csf.append(list(map(int, input().split())))
for i in range(n):
    t = 0
    for j in range(n - i - 1):
        c, s, f = (csf[i + j][k] for k in range(3))
        t = (max(t - 1, s - 1) // f + 1) * f + c
    print(t)
### BUGGY CODE ###

from decimal import *
getcontext().prec = 40000
a, b, c = map(int, input().split())
if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():
    print("Yes")
else:
    print("No")

### FIXED CODE ###

from decimal import *
getcontext().prec = 30000
a, b, c = map(int, input().split())
# if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():
if a + b + 2 * Decimal(a * b).sqrt() < c: 
    print("Yes")
else:
    print("No")
### BUGGY CODE ###

# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N = int(input())
arrD = list(map(int,input().split()))
M = int(input())
arrT = list(map(int,input().split()))

for dif in arrT:
    if dif in arrD:
        arrD.remove(dif)
    else:
        print("NO")
        exit()

print("YES")
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


### FIXED CODE ###

# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N = int(input())
arrD = list(map(int,input().split()))
M = int(input())
arrT = list(map(int,input().split()))

cntD = Counter(arrD)
cntT = Counter(arrT)

for dif,cnt in cntT.items():
    if dif in cntD:
        if cnt > cntD[dif]:
            print("NO")
            exit()
    else:
        print("NO")
        exit()

print("YES")
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
p =[]
for i in range(n) :
    p.append([i+1,a[i]])

p.sort(key=lambda x: x[1])
r = ''
for i in range(n) :
    r = r + ' ' + str(p[i][0])

print (r)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
p =[]
for i in range(n) :
    p.append([i+1,a[i]])

p.sort(key=lambda x: x[1])
q = list(map(str,[x[0] for x in p]))
r = ' '.join(q)


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

from sys import stdin

def get_result(data):
    N, X, Y = data
    min_dist = []
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            min_dist.append(min([j-i, abs(X-i) + 1 + abs(Y-j), abs(Y-i) + 1 + abs(X-j)]))
    for i in range(1, N):
        print(min_dist.count(i))


if __name__ == '__main__':
    data = list(map(int, stdin.readline().rstrip('\n').split(' ')))
    get_result(data)

### FIXED CODE ###

from sys import stdin


def get_result(data):
    N, X, Y = data
    dist_cnt = [0 for i in range(N)]
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            min_dist = min([j-i, abs(X-i) + 1 + abs(Y-j), abs(Y-i) + 1 + abs(X-j)])
            dist_cnt[min_dist] += 1
    for i in range(1, N):
        print(dist_cnt[i])


if __name__ == '__main__':
    data = list(map(int, stdin.readline().rstrip('\n').split(' ')))
    get_result(data)
### BUGGY CODE ###

N,Q = map(int,input().split())
S = input()
P = []
for i in range(Q):
    P.append((int(_) for _ in input().split()))

for i in range(Q):
    l,r = P[i]
    print(S.count('AC',l-1,r))


### FIXED CODE ###

def countAC(s):
    counter = 0
    index = [0]
    for i in range(1,N):
        if s[i-1] == 'A':
            if s[i] == 'C':
                counter += 1
                index.append(counter)
                continue
        index.append(counter)
    return index

N,Q = (int(_) for _ in input().split())
S = input()
SIndex = countAC(S)
out = 0
for i in range(Q):
    l,r = (int(_) for _ in input().split())
    print(SIndex[r-1] - SIndex[l-1])
### BUGGY CODE ###

from itertools import permutations as perm
import sys


input = sys.stdin.readline


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

dest = (list)(map(lambda x: (int)(x)-1, input().split()))


inf = 10**10
mat = [[inf]*N for _ in range(N)]
for _ in range(M):
    a, b, c = (list)(map(int, input().split()))
    mat[a-1][b-1] = c
    mat[b-1][a-1] = c

for i in range(N):
    mat[i][i] == 0

for i in range(N):
    for j in range(N):
        for k in range(N):
            mat[j][k] = min(mat[j][k], mat[j][i]+mat[i][k])


ans = inf
for l in perm(dest):
    tmp = 0
    for i in range(R-1):
        tmp += mat[l[i]][l[i+1]]
    ans = min(ans, tmp)

print(ans)


### FIXED CODE ###

from itertools import permutations
import sys


input = sys.stdin.readline


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

dest = [x-1 for x in map(int, input().split())]


inf = float('inf')
mat = [[inf]*N for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    mat[a-1][b-1] = mat[b-1][a-1] = c


for i in range(N):
    for j in range(N):
        for k in range(N):
            mat[j][k] = min(mat[j][k], mat[j][i]+mat[i][k])


ans = inf
for l in permutations(dest):
    tmp = 0
    for u, v in zip(l, l[1:]):
        tmp += mat[u][v]
    ans = min(ans, tmp)

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

import sys
from collections import defaultdict

sys.setrecursionlimit(4000)

n = int(input())
arr = map(int, input().split())
arr = tuple(sorted(enumerate(arr), key=lambda tpl: -tpl[1]))

dp = defaultdict(int)

def cal(ln, rn):
  if ln + rn > n:
    return

  p, a = arr[ln + rn - 1]
  val_l = dp[ln - 1, rn] + a * abs(p - (ln - 1)) if ln > 0 else 0
  val_r = dp[ln, rn - 1] + a * abs(p - (n - rn)) if rn > 0 else 0

  dp[ln, rn] = max(val_l, val_r)

  cal(ln + 1, rn)
  cal(ln, rn + 1)

cal(1, 0)
cal(0, 1)

print(max([dp[i, n - i] for i in range(n + 1)]))


### FIXED CODE ###


def main():

  n = int(input())
  arr = map(int, input().split())
  arr = tuple(sorted(enumerate(arr), key=lambda tpl: -tpl[1]))

  dp = [[0] * (n + 1) for _ in range(n + 1)]
  for i, (p, a) in enumerate(arr):
    for l in range(i + 1):
      dp[i + 1][l] = max(dp[i + 1][l], dp[i][l] + a * abs(p - (n - (i - l) - 1)))
      dp[i + 1][l + 1] = max(dp[i + 1][l + 1], dp[i][l] + a * abs(p - l))

  print(max(dp[n]))

main()
### BUGGY CODE ###

import numpy as np
s = input()
effects = [1, 10, 9, 12, 3, 4]
mod = 10**9+7

amari = np.array([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
arrays = [np.eye(13, k=i, dtype=np.int64)+np.eye(13, k=i-13, dtype=np.int64) for i in range(13)]
for i, c in enumerate(reversed(s)) :
    if c != "?" :
        c = int(c)
        array = arrays[c*effects[i%6]%13]
        amari = np.dot(amari, array)
    else :
        array = sum(arrays[c*effects[i%6]%13] for c in range(10))
        amari = np.dot(amari, array)%mod

print(amari[5])

### FIXED CODE ###

import numpy as np
s = input()
effects = [1, 10, 9, 12, 3, 4]
mod = 10**9+7

amari = np.array([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
arrays = [np.eye(13, k=i, dtype=np.int64)+np.eye(13, k=i-13, dtype=np.int64) for i in range(13)]
brrays = [sum(arrays[c*effects[i]%13] for c in range(10)) for i in range(6)]
for i, c in enumerate(reversed(s)) :
    if c != "?" :
        c = int(c)
        array = arrays[c*effects[i%6]%13]
        amari = np.dot(amari, array)
    else :
        array = brrays[i%6]
        amari = np.dot(amari, array)%mod

print(amari[5])
### BUGGY CODE ###

from collections import deque
A = deque(input())
while len(A) >= 2:
    if list(A)[:5] == list("dream"):
        if list(A)[5:7] == list("er") and list(A)[7:8] != list("a"):
            for _ in range(7):
                A.popleft()
        else:
            for _ in range(5):
                A.popleft()
    elif list(A)[:5] == list("erase"):
        if list(A)[5:6] == list("r"):
            for _ in range(6):
                A.popleft()
        else:
            for _ in range(5):
                A.popleft()
    else:
        A = deque([0])
if len(A) == 0:
    print("YES")
else:
    print("NO")


### FIXED CODE ###

s = input().replace("eraser", "").replace("erase", "")
s = s.replace("dreamer", "").replace("dream", "")
if s:
    print("NO")
else:
    print("YES")
### BUGGY CODE ###

from itertools import combinations
MOD = 10**9 + 7
n=int(input())
a=list(map(int,input().split()))
sum=0
for x,y in combinations(a,2):
   sum+= x*y
   ans=sum%MOD
print(ans)

### FIXED CODE ###

mod = 10**9 + 7
n=int(input())
s=list(map(int,input().split()))
s2=sum(map(lambda x: x ** 2,s))
ans=(((sum(s))**2)-(s2))//2%mod
print(ans)
### BUGGY CODE ###

# problem D
s = input()
Q = int(input())

query = []
for i in range(0,Q):
    query.append(input().split())
    
summ = 0
hanten = 0
    
for i in query:
    if int(i[0]) == 1:
        summ += 1
    elif (summ % 2 == 0 and int(i[1]) == 1) or (summ % 2 == 1 and int(i[1]) == 2):
        s = ''.join([str(i[2]),s])
    else:
        s = ''.join([s,str(i[2])])
    
if summ % 2 == 1:
    s = s[::-1]
        
print(s)

### FIXED CODE ###

from collections import deque

s = deque(input())
Q = int(input())
    
t = True
    
for i in range(Q):
    query = input().split()
    if query[0] == '1':
        t = not t
    else:
        if(t and query[1] == '1') or (not t and query[1] == '2'):
            s.appendleft(query[2])
        else:
            s.append(query[2])
            
s = ''.join(s)
    
if not t:
    s = s[::-1]
        
print(s)
### BUGGY CODE ###

K = int(input())
checker = False
for i in range(10 ** 6):
    n = int('7' * (i + 1))
    if n % K == 0:
        checker = True
        break
    
if checker:
    print(len(str(n)))
else:
    print(-1)

### FIXED CODE ###

K = int(input())

cur = 7
flg = False
for i in range(10 ** 6):
    mod = cur % K
    if mod == 0:
        ans = i + 1
        flg = True
        break
    else:
        cur = mod * 10 + 7

if flg:
    print(ans)
else:
    print(-1)
### BUGGY CODE ###

def main():
    from sys import stdin
    input = stdin.readline
    import numpy as np
    import scipy.sparse as sp

    n, m, s, t = map(int, input().split())
    uvab = np.array([list(map(int, input().split())) for _ in [0]*m])

    data = uvab[:, 2]
    row = uvab[:, 0] - 1
    col = uvab[:, 1] - 1

    matrix = sp.csr_matrix(
        (data, (row, col)), shape=(n, n), dtype=np.int64)
    yen = sp.csgraph.dijkstra(matrix, indices=s-1, directed=False)

    data = uvab[:, 3]
    matrix = sp.csr_matrix(
        (data, (row, col)), shape=(n, n), dtype=np.int64)
    snk = sp.csgraph.dijkstra(matrix, indices=t-1, directed=False)

    cost = yen+snk
    m = cost[-1]
    for i in range(n-1, -1, -1):
        m = min(cost[i], m)
        cost[i] = m

    cost = 10**15-cost

    for i in cost:
        print(int(i))


main()


### FIXED CODE ###

n,m,s,t=map(int,input().split())
uvab=[list(map(int,input().split())) for _ in [0]*m]
g_yen=[[] for _ in [0]*n]
[g_yen[u-1].append([v-1,a]) for u,v,a,b in uvab]
[g_yen[v-1].append([u-1,a]) for u,v,a,b in uvab]

g_snk=[[] for _ in [0]*n]
[g_snk[u-1].append([v-1,b]) for u,v,a,b in uvab]
[g_snk[v-1].append([u-1,b]) for u,v,a,b in uvab]

import heapq
def dijkstra(g,start):
    inf=10**15
    dist=[inf for _ in [0]*n]
    h=[(0,start)]
    heapq.heapify(h)
    while h:
        d,i=heapq.heappop(h)
        if dist[i]==inf:
            dist[i]=d
            for x,y in g[i]:
                heapq.heappush(h,(d+y,x))
    return dist

yen=dijkstra(g_yen,s-1)
snk=dijkstra(g_snk,t-1)

cost=[yen[i]+snk[i] for i in range(n)]
m=cost[-1]
for i in range(n-1,-1,-1):
    m=min(m,cost[i])
    cost[i]=m
    
for i in cost:
    print(10**15-i)
### BUGGY CODE ###

import sys
from collections import defaultdict

readline = sys.stdin.buffer.readline


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


sys.setrecursionlimit(10**5)


def main():
    n, d, a = geta(int)
    mon = []
    ans = 0

    for _ in range(n):
        x, h = geta(int)
        mon.append([x, (h + a - 1) // a])

    mon.sort()

    for i in range(n):
        if mon[i][1] <= 0:
            continue

        ans += mon[i][1]
        rb = mon[i][0] + 2 * d

        for j in range(i + 1, n):
            if mon[j][0] > rb:
                break

            mon[j][1] -= mon[i][1]

    print(ans)


if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
from collections import defaultdict
from queue import deque

readline = sys.stdin.buffer.readline


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


sys.setrecursionlimit(10**5)


def main():
    n, d, a = geta(int)
    mon = []
    ans = 0

    for _ in range(n):
        x, h = geta(int)
        mon.append([x, (h + a - 1) // a])

    mon.sort()

    bom = deque()
    cur = 0
    for i, mi in enumerate(mon):

        while len(bom) != 0 and bom[0][0] < mi[0]:
            b = bom.popleft()
            cur -= b[1]

        if mi[1] <= cur:
            continue
        else:
            b1 = mi[1] - cur
            bom.append((mi[0] + 2 * d, b1))
            cur += b1
            ans += b1

    print(ans)


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

n=int(input())
s=input()
ans=0
for i in range(1,n+1):
    if i+1<=n:
        for j in range(i+1,n+1):
            if j+1<=n:
                for k in range(j+1,n+1):
                    if j-i!=k-j and s[i-1]!=s[j-1] and s[j-1]!=s[k-1] and s[k-1]!=s[i-1]:
                        ans+=1
            else:
                break
    else:
        break
print(ans)

### FIXED CODE ###

n=int(input())
s=input()
ans=0
r,g,b=0,0,0
for i in range(n):
    if s[i]=="R":
        r+=1
    elif s[i]=="G":
        g+=1
    else:
        b+=1
for i in range(1,n):
    for j in range(i+1,n):
        if (j-i)+j<=n:
            k=(j-i)+j-1
            if  s[i-1]!=s[j-1] and  s[j-1]!=s[k] and s[k]!=s[i-1]:
                ans-=1
ans+=r*g*b
print(ans)