Harryxun/stf_run huggingface dataset:
def update(i, x):
    i += 1
    while i < m + 1:
        bit[i] += x
        i += i & -i

def get_sum(i):
    i += 1
    s = 0
    while i > 0:
        s += bit[i]
        i -= i & -i
    return s

n, m = map(int, input().split())
bit = [0] * (m + 1)
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort(key=lambda x: (-x[1], -x[0]))
cnt = 0
ans = 0
for a, b in ab:
    if a <= m:
        a = m - a
        if get_sum(a) < a + 1:
            update(a, 1)
            cnt += 1
            ans += b
    print(a,b,bit,get_sum(a))
    if cnt == m: break
print(ans)


### FIXED CODE ###

# pdf
from heapq import *

n, m = map(int, input().split())
hp = []
for _ in range(n):
    a, b = map(int, input().split())
    heappush(hp, [a, b])
ans = 0
mx = b
ch = []
a, b = heappop(hp)
flag = 1
for i in range(1, m + 1):
    while a <= i:
        if flag:
            heappush(ch, -b)
            flag = 0
        if not hp:break
        a, b = heappop(hp)
        flag = 1
    if ch:
        ans -= heappop(ch)
print(ans)
a = int(input())
b = int(input())

if a * b % 2 == 0:
    print('Even')
else:
    print('Odd')


### FIXED CODE ###

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

if (a * b) % 2 == 0:
    print('Even')
else:
    print('Odd')
s = input()
n = int(input())

t = []
a = []
for i in s:
    ord_i = ord(i)
    t.append((123 - ord_i, ord_i))

for i in t:
    if n >= i[0]:
        a.append(chr(97))
        n -= i[0]
    else:
        a.append(chr(i[1]))
    
temp = ord(a[-1]) + n
a[-1] = chr(temp)
print(''.join(a))

### FIXED CODE ###

def main():
    s = input()
    n = int(input())
    
    t = []
    a = []
    for i in s:
        ord_i = ord(i)
        t.append(((123 - ord_i)%26, ord_i))
    
    for i in t:
        if n >= i[0]:
            a.append('a')
            n -= i[0]
        else:
            a.append(chr(i[1]))
            
    a[-1] = chr(ord(a[-1]) + n%26)
    print(''.join(a))
    
if __name__ == '__main__':
    main()
X, Y, Z, K = map(int, input().split())
candy = [[],[],[]]
for i in range(3):
    temp = list(map(int, input().split()))
    candy[i] = temp

for i in range(3):
    candy[i] = sorted(candy[i], reverse=True)
i, j, k = 0, 0, 0
heap = [(-(candy[0][i] + candy[1][j] + candy[2][k]), i, j, k)]
cnt = 0
visit = {(i, j, k)}
while cnt < K:
    print(heap)
    s, ii, jj, kk = heapq.heappop(heap)
    print(-s)
    cnt += 1
    if ii < len(candy[0]) - 1 and (ii+1, jj, kk) not in visit:
        heapq.heappush(heap, (-(candy[0][ii + 1] + candy[1][jj] + candy[2][kk]), ii + 1, jj, kk))
        visit.add((ii+1, jj, kk))
    if jj < len(candy[1]) - 1 and (ii, jj+1, kk) not in visit:
        heapq.heappush(heap, (-(candy[0][ii] + candy[1][jj + 1] + candy[2][kk]), ii, jj + 1, kk))
        visit.add((ii, jj+1, kk))
    if kk < len(candy[2]) - 1 and (ii, jj, kk+1) not in visit:
        heapq.heappush(heap, (-(candy[0][ii] + candy[1][jj] + candy[2][kk + 1]), ii, jj, kk + 1))
        visit.add((ii, jj, kk+1))

### FIXED CODE ###

import heapq
X, Y, Z, K = map(int, input().split())
candy = [[],[],[]]
for i in range(3):
    temp = list(map(int, input().split()))
    candy[i] = temp

for i in range(3):
    candy[i] = sorted(candy[i], reverse=True)
i, j, k = 0, 0, 0
heap = [(-(candy[0][i] + candy[1][j] + candy[2][k]), i, j, k)]
cnt = 0
visit = {(i, j, k)}
while cnt < K:
    s, ii, jj, kk = heapq.heappop(heap)
    print(-s)
    cnt += 1
    if ii < len(candy[0]) - 1 and (ii+1, jj, kk) not in visit:
        heapq.heappush(heap, (-(candy[0][ii + 1] + candy[1][jj] + candy[2][kk]), ii + 1, jj, kk))
        visit.add((ii+1, jj, kk))
    if jj < len(candy[1]) - 1 and (ii, jj+1, kk) not in visit:
        heapq.heappush(heap, (-(candy[0][ii] + candy[1][jj + 1] + candy[2][kk]), ii, jj + 1, kk))
        visit.add((ii, jj+1, kk))
    if kk < len(candy[2]) - 1 and (ii, jj, kk+1) not in visit:
        heapq.heappush(heap, (-(candy[0][ii] + candy[1][jj] + candy[2][kk + 1]), ii, jj, kk + 1))
        visit.add((ii, jj, kk+1))
def knapsack(V,n):
    if n == -1:
        return V
    if (V,n) in OS_dict.keys():
        return OS_dict[(V,n)]
    elif V < cost[n]:
        r = knapsack(V,n-1)
        OS_dict[(V, n)] = r
        return r
    else:
        r = min(knapsack(V,n-1),knapsack(V-cost[n],n)+value[n]) #完全背包问题只需将第二个选项改为knapsack(V-cost[n],n)+value[n]
        OS_dict[(V,n)] = r
        return r



N = int(input())
now = 9
cost = []
value = []
while now <= N:
    cost.append(now)
    now *= 9
now = 6
while now <= N:
    cost.append(now)
    now *= 6
for x in range(len(cost)):
    value.append(1)
OS_dict = {}
V = N
best = knapsack(V,len(cost)-1)
print(best)

### FIXED CODE ###

def knapsack(V,n):
    if n == -1:
        return V
    if (V,n) in OS_dict.keys():
        return OS_dict[(V,n)]
    elif V < cost[n]:
        r = knapsack(V,n-1)
        OS_dict[(V, n)] = r
        return r
    else:
        r = min(knapsack(V-cost[n],n)+value[n],knapsack(V,n-1)) 
        OS_dict[(V,n)] = r
        return r



N = int(input())
now = 9
cost = []
value = []
while now <= N:
    cost.append(now)
    now *= 9
now = 6
while now <= N:
    cost.append(now)
    now *= 6
for x in range(len(cost)):
    value.append(1)
OS_dict = {}
V = N
best = knapsack(V,len(cost)-1)
print(best)
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    N,M=map(int,input().split())
    A=[list(map(int,input().split())) for i in range(N)]
    B=[list(map(int,input().split())) for i in range(M)]

    for i in A:
        valmin=10**5
        cnt=0
        for j in B:
            if abs(i[0]-j[0])+abs(i[1]-j[1])<valmin:
                valmin=abs(i[0]-j[0])+abs(i[1]-j[1])
                ans=cnt+1
            cnt+=1
        print(ans)





resolve()

### FIXED CODE ###

A,B=map(int,input().split())
#print(sorted(B)[0])
print((A+B)%24)
a, b = input().split(' ')
print('{} {}'.format(a*b, 2(a+b)))

### FIXED CODE ###

a, b = map(int, input().split(' '))
print('{} {}'.format(a*b, 2*(a+b)))
N = int(input())
p = []
for i in range(N):
    X1, Y1, H1 = map(int, input().split())
    if H1 != 0:
        p.append([X1, Y1, H1])

if len(p) == 1:
    print(p[0][0], p[0][1], p[0][2])
    exit()


for i in range(101):
    for j in range(101):
        h = -1
        fg = True
        for t in p:
            if h == -1:
                h = t[2] + abs(i - t[0]) + abs(j - t[1])

            else:
                ht = t[2] + abs(i - t[0]) + abs(j - t[1])
                if h == ht:
                    h = ht
                else:
                    fg = False
                    break
        if fg:
            print(i, j, h)
      


### FIXED CODE ###

N = int(input())

if N == 1:
    a = "Hello World"
    print(a)

if N == 2:
    A = int(input())
    B = int(input())
    C = A+B
    print(C)
from sys import stdin
import sys
N=int(stdin.readline().rstrip())
data=[]
for i in range(N):
    data.append([int(x) for x in stdin.readline().rstrip().split()])
 
cnt=1
for X in range(0,101):
    for Y in range(0,101):
        for data_ in data:
            if data_[2] == 0:
                cnt+=1
                continue
            H = data_[2] + abs(X-data_[0]) + abs(Y-data_[1])
            if H == h_log:
                cnt+=1
            h_log = H
            
        if cnt == N:
            break
        
        cnt=1
    else:
        continue
    break
    
print(X,Y,H) 

### FIXED CODE ###

from sys import stdin
import sys
N=int(stdin.readline().rstrip())
data=[]
for i in range(N):
    data.append([int(x) for x in stdin.readline().rstrip().split()])
for X in range(0,101):
    for Y in range(0,101):
        for data_ in data:
            H = data_[2] + abs(X-data_[0]) + abs(Y-data_[1])
            flag = True
            for data__ in data:
                if max(H-abs(X-data__[0])-abs(Y-data__[1]),0) != data__[2]:
                    flag = False
            if flag:
                break
        else:
            continue
        break
    else:
        continue
    break
    
print(X,Y,H)
n = int(input())
As = list(map(int, input().split()))

number_counter = {}
for i in As:
    if str(i) in number_counter:
        number_counter[str(i)] += 1
    else:
        number_counter[str(i)] = 1
# 自分の数字以外の方法の合計は一緒。

howmanyways_in_number_by_default = {}
for k, v in number_counter.items():
    if v == 1:
        howmanyways_in_number_by_default[k] = 0
    else:
        howmanyways_in_number_by_default[k] = (v*(v-1))/2

for i in range(n):
    ways = 0
    # 自分以外の通りから自分のとこを引く
    for k, v in howmanyways_in_number_by_default.items():
        if int(k) == As[i]:
            ways += ((number_counter[str(As[i])]-1)*(number_counter[str(As[i])]-2))/2
        else:
            ways += v

    print(int(ways))

### FIXED CODE ###

import sys

s = str(input())
n = len(s)
left = s[0:int((n-1)/2)]
right = s[int(((n+3)/2)-1):n]
l = len(left)

for i in range(int((n-1)/2)):
    if s[i] == s[n-1-i]:
        continue
    else:
        print("No")
        sys.exit()

for i in range(int((n-1)/4)):
    if left[i] == left[l-1-i] and right[i] == right[l-1-i]:
        continue
    else:
        print("No")
        sys.exit()

print("Yes")
t=int(input())
import heapq
for _ in range(t):
    n=int(input())
    L=[];R=[]
    ans=0
    for _ in range(n):
        ki,li,ri = map(int, input().split())
        dif=li-ri
        if dif>=0:
            L.append((ki-1,-dif))
            ans+=ri
        else:
            R.append((n-ki-1,dif))
            ans+=li
    L.sort();R.sort()
    hL=[]
    hR=[]
    for i in range(len(L)):
        if L[i][0]>len(hL):
            heapq.heappush(hL,L[i][1])
        elif L[i][0]==len(hL):
            heapq.heappushpop(hL,L[i][1])
    for i in range(len(R)):
        if R[i][0]>len(hR):
            heapq.heappush(hR,R[i][1])
        elif L[i][0]==len(hR):
            heapq.heappushpop(hR,R[i][1])
    print(ans-sum(hL)-sum(hR))        
    
    

### FIXED CODE ###

t=int(input())
import heapq
for _ in range(t):
    n=int(input())
    L=[];R=[]
    ans=0
    for _ in range(n):
        ki,li,ri = map(int, input().split())
        dif=li-ri
        if dif>=0:
            L.append((ki-1,dif))
            ans+=ri
        else:
            R.append((n-ki-1,-dif))
            ans+=li
    L.sort();R.sort()
    hL=[]
    hR=[]
    for i in range(len(L)):
        if L[i][0]>=len(hL):
            heapq.heappush(hL,L[i][1])
        elif L[i][0]==len(hL)-1:
            heapq.heappushpop(hL,L[i][1])
    for i in range(len(R)):
        if R[i][0]>=len(hR):
            heapq.heappush(hR,R[i][1])
        elif R[i][0]==len(hR)-1:
            heapq.heappushpop(hR,R[i][1])
    print(ans+sum(hL)+sum(hR))
from fractions import gcd  # python<=3.4

MOD=1000000007

n = int(input().rstrip())
a = [int(x) for x in input().rstrip().split()]

el = 1
for ai in a:
  g = gcd(a,b)
  el = el // g * b

sum = 0
for ai in a:
    sum = (sum + el // ai) % MOD

print(sum)


### FIXED CODE ###

from fractions import gcd  # python<=3.4

MOD=1000000007

def ADD(x, y):
  return (x + y) % MOD

def SUB(x, y):
  return (x - y + MOD) % MOD

def MUL(x, y):
  return x * y % MOD

def POW(x, e):
  v = 1
  while e:
    if e & 1:
      v = MUL(v, x)
    x = MUL(x, x)
    e >>= 1
  return v

def INV(x):
  return POW(x, MOD-2)

def DIV(x, y):
  return MUL(x, INV(y))


n = int(input().rstrip())
a = [int(x) for x in input().rstrip().split()]

el = 1
for ai in a:
  g = gcd(el,ai)
  el = el // g * ai

el %= MOD

sum = 0
for ai in a:
  sum += DIV(el, ai)

sum %= MOD
print(sum)
import math
N = int(input())
sheet = []
for i in range(N):
  line = input().split()
  sheet += [(int(line[0]), int(line[1]))]
 
dic = {}
for i in range(N):
  start = sheet[i]
  for j in range(i+1, N):
    vec = [(sheet[j][0]-start[0]), (sheet[j][1]-start[1])]
    size = math.gcd(vec[0],vec[1])
    vec[0] = vec[0]//size
    vec[1] = vec[1]//size
    vec = tuple(vec)
    if vec not in dic.keys():
      dic[vec] = set([j])
    else:
      dic[vec].add(j)
m = 0
for s in dic.values():
  if len(s)>m:
    m = len(s)
print(N-m)

### FIXED CODE ###

N,*L = map(int, open(0).read().split())
ls = [0]*N
for i,c in enumerate(zip(*[iter(L)]*2)):
  ls[i] = c
ls.sort()
pls = []
for i in range(N):
  for j in range(i+1,N):
    a,b = ls[i]
    x,y = ls[j]
    pls += [(x-a,y-b)]
ans = 10**10
for X,Y in pls:
  s = set()
  m = 0
  for x,y in ls:
    if (x-X, y-Y) not in s:
      m += 1
    s.add((x,y))
  ans = min(m,ans)
if N==1:
  ans = 1
print(ans)
a = int(input())
ans = a + a**2 + a***3
print(ans)

### FIXED CODE ###

a = int(input())
ans = a + a**2 + a**3
print(ans)
n = int(input())

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

n = max(a)

highest = 0
last = 0
for i in range(n):
    if a[i] >= highest:
        highest = a[i]
        last = i

shortest = highest
for j in range(0, i):
    if a[j] <= shortest:
        shortest = a[j]
        #print(shortest)

print(highest - shortest)

### FIXED CODE ###

n = int(input())

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


highest = 0
ans = 0

for i in a:
    if i > highest:
        highest = i
    ans += highest - i

print(ans)
H,W = map(int,input('H W=').split())
S = [list(map(int,input().split())) for i in range(H)]
for i in range(0,H):
    for j in range(0,W):
        if (S[i][j] == '.'):
            count = 0
            for a in range(-1,2):
                for b in range(-1,2):
                    if(0<=i+a<=H-1 and 0<=j+b<=W-1):
                        if(S[i+a][j+b] == '#'):
                            count += 1
            S[i][j] = count
    print(S[i])

### FIXED CODE ###

H,W = map(int,input().split())
S = [[0 for j in range(W)] for i in range(H)]
for i in range(H):
    S[i] = list(input())
for i in range(H):
    for j in range(W):
        if (S[i][j] == '.'):
            count = 0
            for a in range(-1,2):
                for b in range(-1,2):
                    if(0<=i+a<=H-1 and 0<=j+b<=W-1):
                        if(S[i+a][j+b] == '#'):
                            count += 1
            S[i][j] = count
    print(*S[i], sep='')
N = int(input())
INF = 10**6
dp = [INF] * (N+1)
for i in range(9):
  if i < 6:
    dp[i] = i
  elif i < 9:
    dp[i] = i%6+1

for i in range(N):
  n = m = 1
  while i+9*n <= N:
    dp[i+9*n] = min(dp[i+9*n], dp[i] + 1)
    n += 1
  while i+6*m <= N:
    dp[i+6*m] = min(dp[i+6*m], dp[i] + 1)
    m += 1
print(dp[N])
    


### FIXED CODE ###

N = int(input())
INF = 10**6
dp = [INF] * (max(9, N)+1)
dp[0] = 0
for i in range(N):
  n = m = 0
  while i+9**n <= N:
    dp[i+9**n] = min(dp[i+9**n], dp[i] + 1)
    n += 1
  while i+6**m <= N:
    dp[i+6**m] = min(dp[i+6**m], dp[i] + 1)
    m += 1
print(dp[N])
s=input().replace(" ","+")
l,r=eval(s[:3]),eval(s[4:])
print("RLiegfhtt"[l>r::2] if l!=r else "Balanced")

### FIXED CODE ###

a, b, c, d = map(int,input().split())
print(["RLiegfhtt"[a+b > c+d::2], "Balanced"][a+b == c+d])
import math
A, B, N = map(int, input().split())

x = list(range(1, N+1))

ans = -10**20
for i in x:
  y = math.floor(A*i/B) - A * math.floor(i/B)
  if y > ans:
    ans = y
  elif y < ans:
    break
print(y)

### FIXED CODE ###

import math
A, B, N = map(int, input().split())

x = min(B-1, N)
y = math.floor(A*x/B) - A * math.floor(x/B)
print(y)
n = int(input())
a = [int(x) for x in input().split()]
counter=0
while True:
    z=2**(counter+1)
    for i in range(n):
        if a[i]%z==0:
        else :
            print(counter)
            break
    counter+=1

### FIXED CODE ###

N = int(input())
a = [int(x) for x in input().split()]
cnt=0
Flag=True
while(Flag):
    for i in range(N):
        if a[i]%2!=0:
            Flag=False
            break
        a[i]/=2
    cnt+=1
print(cnt-1)
s=list(input())+['']
n=0
for i in range(4):
    if s[i]==s[i+1]:
        n+=1
    else:
        n+=0
if n>0
    print('Bad')
else:
    print('Good')

### FIXED CODE ###

s=input()
n=0
for i in range(3):
    if s[i]==s[i+1]:
        n+=1
    else:
        n+=0
if n>=1:
    print('Bad')
else:
    print('Good')
import re
s=input()

def hoge(str):
	if(str == ""):
		return "YES"
	if(str.startswith("maerd")):
		return hoge(re.sub('^maerd', '', str))
	if(str.startswith("remaerd")):
		return hoge(re.sub('^remaerd', '', str))
	if(str.startswith("esare")):
		return hoge(re.sub('^esare', '', str))
	if(str.startswith("resare")):
		return hoge(re.sub('^resare', '', str))
	return "NO"

if(s == ""):
  print("NO")
else:
	print(hoge(s[::-1]))

### FIXED CODE ###

def main():
    S = input()

    while len(S) >= 5:
        if len(S) >= 7 and S[-7:] == "dreamer":
            S = S[:-7]
            continue

        if len(S) >= 6 and S[-6:] == "eraser":
            S = S[:-6]
            continue

        elif S[-5:] == "dream" or S[-5:] == "erase":
            S = S[:-5]
            continue

        else:
            break

    if len(S) == 0:
        print("YES")
    else:
        print("NO")

main()
s = input()
n = len(s)

if n < 4:
    print('0')
else:
    cnt = 0
    for j in range(n-3):
        i = 0
        while i < n-3-j:
            step = int(s[n-4-i-j:n-j])
            if step % 2019 == 0:
                cnt += 1
                i += 3
            i += 1

print(cnt)

### FIXED CODE ###

import collections
s = input()
n = len(s)
mod_list = [0]

T = 0
for i in range(n):
    T += int(s[-1-i])*pow(10, i, 2019)%2019
    T = T%2019
    mod_list.append(T)

res = collections.Counter(mod_list)
cnt = 0
for d in res.values():
    cnt += int(d*(d-1)/2)
print(cnt)
n = int(input())
#値の初期化
path = [None]*(n + 1)
adjacent_list = [[] for i in range(n+1)]

for i in range(n - 1):
    a, b, c = list(map(int,input().split()))
    adjacent_list[a].append([b,c])
    adjacent_list[b].append([a,c])
#ノード番号、そこまでの距離,検索済みの要素を受け取る。
def dfs(node_n ,distance,finished):
    #検索済みに追加
    finished.add(node_n)
    #そこまでの距離を代入。値の更新などは特にない（はず）
    path[node_n] = distance
    #対象ノードに対する隣接リストをforで回す
    for i in adjacent_list[node_n]:
        next = i[0]
        if next not in finished:
            #検索済みでなかった場合、そこまでのコストを追加し再帰
            dfs(next, distance + i[1],finished)

q,k = list(map(int, input().split()))
dfs(k, 0, set())
#各クエリへの返答
for i in range(q):
    s, g = list(map(int, input().split()))
    is path[s] is not None and path[g] is not None:
        print(path[s] + path[g])



### FIXED CODE ###

import sys

sys.setrecursionlimit(200000)

n = int(input())
# 値の初期化
path = [None]*(n + 1)
adjacent_list = [[] for i in range(n+1)]

for i in range(n - 1):
    a, b, c = list(map(int, input().split()))
    adjacent_list[a].append([b, c])
    adjacent_list[b].append([a, c])
# ノード番号、そこまでの距離,検索済みの要素を受け取る。


def dfs(node_n, distance, finished):
    # 検索済みに追加
    finished.add(node_n)
    # そこまでの距離を代入。値の更新などは特にない（はず）
    path[node_n] = distance
    # 対象ノードに対する隣接リストをforで回す
    for i in adjacent_list[node_n]:
        next = i[0]
        if next not in finished:
            # 検索済みでなかった場合、そこまでのコストを追加し再帰
            dfs(next, distance + i[1], finished)


q, k = list(map(int, input().split()))
dfs(k, 0, set())
# 各クエリへの返答
for i in range(q):
    s, g = list(map(int, input().split()))
    print(path[s] + path[g])
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=q
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def binary_search(li,item):#二分探索
	left,right = 0, len(li)
	while left<=right:
		mid = (left+right)//2
		if li[mid]==item:
			return mid
		elif li[mid]<item:
			left = mid+1
		else:
			right = mid-1
	return -1

N = readInt()
S = readChar()
rgb = {"R":[],"G":[],"B":[]}
for i in range(N):
	rgb[S[i]].append(i)

c=s=0
c=len(rgb["R"])*len(rgb["G"])*len(rgb["B"])
for i in range(1,N):
	for j in range(i+1,N):
		k = 2*j-i
		if k<=N-1:
			continue
		if S[i]==S[j] and S[i]==S[k]:
			s+=1

ans=c-s
print(ans)


### FIXED CODE ###

import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=q
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
def binary_search(li,item):#二分探索
	left,right = 0, len(li)
	while left<=right:
		mid = (left+right)//2
		if li[mid]==item:
			return mid
		elif li[mid]<item:
			left = mid+1
		else:
			right = mid-1
	return -1

N = readInt()
S = readChar()
rgb = {"R":[],"G":[],"B":[]}
for i in range(N):
	rgb[S[i]].append(i)

c=s=0
c=len(rgb["R"])*len(rgb["G"])*len(rgb["B"])
for i in range(N):
	for j in range(i+1,N):
		k = 2*j-i
		if k>=N:
			continue
		if S[i]!=S[j] and S[i]!=S[k] and S[k]!=S[j]:
			s+=1

ans=c-s
print(ans)
s = input()
q_number = int(input())
reverse_flag = 1
for i in range(q_number):
  temp = input().split()
  if temp[0] == "1": 
    reverse_flag = reverse_flag * -1
  else:
    if int(temp[1])*reverse_flag == 1 or int(temp[1])*reverse_flag == -2:
      s = temp[2] + s
    else:
      s = s + temp[2]      
      
if reverse_flag == -1:
  s = s[::-1]
print(s)

### FIXED CODE ###

a = input()
if "A" in a and "B" in a:
  print("Yes")
else:
  print("No")
A,B = map(int, input().split())

if A//K < B//K or K==1:
  print('OK')
else:
  print('NG')

### FIXED CODE ###

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

if a <= b//k*k:
  print('OK')
else:
  print('NG')
n = int(input())
a = [int(i) for i in input().split()] 

print(max(a) - min(a))

### FIXED CODE ###

n = int(input())

if n % 2 == 0:
  print(n)
else:
  print(n * 2)
s = input().strip()

DIV = 10**9 + 7
new = list(range(13))
old = None

if s[-1] == '?':
    old = [int(t < 10) for t in range(13)]
else:
    old = [int(t == int(c)) for t in range(13)]

digit = 10
for i, c in enumerate(reversed(s[:-1])):
    for j in range(13):
        new[j] = 0
    if c == '?':
        for m in range(10):
            for mod, cnt in enumerate(old):
                shifted = (mod + m * digit) % 13
                new[shifted] += cnt
    else:
        c = int(c)
        for mod, cnt in enumerate(old):
            shifted = (mod + c * digit) % 13
            new[shifted] += cnt
    for j in range(13):
        new[j] %= DIV
    new, old = old, new
    digit = (digit * 10) % 13

print(old[5])

### FIXED CODE ###

s = input().strip()

DIV = 10**9 + 7
new = list(range(13))
old = None

c = s[-1]
if c == '?':
    old = [int(t < 10) for t in range(13)]
else:
    c = int(c)
    old = [int(t == c) for t in range(13)]

digit = 10
for i, c in enumerate(reversed(s[:-1])):
    for j in range(13):
        new[j] = 0
    if c == '?':
        for m in range(10):
            for mod, cnt in enumerate(old):
                shifted = (mod + m * digit) % 13
                new[shifted] += cnt
    else:
        c = int(c)
        for mod, cnt in enumerate(old):
            shifted = (mod + c * digit) % 13
            new[shifted] += cnt
    for j in range(13):
        new[j] %= DIV
    new, old = old, new
    digit = (digit * 10) % 13

print(old[5])