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

import sys
from io import StringIO
import unittest

def resolve():
    N, M, K = [int(x) for x in input().split()]
    global list, block, seen, osusume
    list = [[] for _ in range(N)]
    block = [[] for _ in range(N)]
    seen = [[False] * N for _ in range(N)]
    osusume = [[] for _ in range(N)]

    for _ in range(M):
        A, B = [int(x)-1 for x in input().split()]
        list[A].append(B)
        list[B].append(A)

    for _ in range(K):
        C, D = [int(x)-1 for x in input().split()]
        block[C].append(D)
        block[D].append(C)

    for i in range(N):
        dfs(i, i)
        print(len(osusume[i]), end=" ")

def dfs(v, origin):
    stacka = list[v]
    seen[origin][v] = True

    if not v in list[origin] and not v in block[origin] and v != origin:
        osusume[origin].append(v)

    for i in stacka:
        if(seen[origin][i] == False):
            dfs(i, origin)
resolve()

### FIXED CODE ###

class UnionFind:
    def __init__(self, N, l):
        self.roots = list(range(N+1))
        self.counter = [1]*(N+1)
        for a, b in l:
            self.union(a, b)
 
    def get_root(self, n):
        if self.roots[n] != n:
            self.roots[n] = self.get_root(self.roots[n])
        return self.roots[n]
 
    def union(self, a, b):
        a, b = sorted([self.get_root(a), self.get_root(b)])
        if a != b:
            self.roots[b] = a
            self.counter[a] += self.counter[b]
            self.counter[b] = 0
 
    def find(self, a, b):
        return self.get_root(a) == self.get_root(b)
 
    def count(self, x):
        return(self.counter[self.get_root(x)])
 
 
N, M, K = [int(i) for i in input().split()]
ab = [[int(i) for i in input().split()] for _ in range(M)]
cd = [[int(i) for i in input().split()] for _ in range(K)]
friend = [[] for _ in range(N+1)]
uf = UnionFind(N, ab)
 
for a, b in ab:
    friend[a].append(b)
    friend[b].append(a)
 
ans = [uf.count(i)-1-len(friend[i]) for i in range(N+1)]
 
for c, d in cd:
    if uf.find(c, d):
        ans[c] -= 1
        ans[d] -= 1
 
print(*ans[1:])
### BUGGY CODE ###

inp = input().split()

i = 1
x = 0

while i <= pow(10,18):
	if i % int(inp[0])  == 0 and i % int(inp[1]) != 0:
		print(i)
		x = 1
		break
	i *= int(inp[0])


if x == 0:
	print(-1)

### FIXED CODE ###

inp = input().split()

i = 1
x = 0

while i <= pow(10,18):
	if inp[0] == "1" and inp[1] == "1":
		print(-1)
		x = 1
		break
	if i % int(inp[0])  == 0 and i % int(inp[1]) != 0:
		print(i)
		x = 1
		break
	i *= int(inp[0])

if x == 0:
	print(-1)
### BUGGY CODE ###

import math

N = int(input())
sum = 0

for i in range(N):
    for j in range(N):
        for k in range(N):
            g = math.gcd(i+1,j+1)
            sum += math.gcd(g,k+1)

print(sum)


### FIXED CODE ###

import math

N = int(input())
sum = 0

for i in range(N):
    for j in range(N):
        g = math.gcd(i+1,j+1)
        for k in range(N):
            sum += math.gcd(g,k+1)

print(sum)
### BUGGY CODE ###

n = int(input())
a = list(int(input()) for i in range(n))
b = list(set(a))
p = 0

for i in range(len(b)):
    if a.count(b[i]) % 2 != 0:
        p += 1

print(p)

### FIXED CODE ###

import collections
n = int(input())
l = list(input() for i in range(n))
a = collections.Counter(l)
a = list(a.values())
p = 0
for i in range(len(a)):
    if a[i] % 2 != 0:
        p += 1
print(p)
### BUGGY CODE ###

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

def my_index(arr, x, default = -1):
    if x in arr:
        return arr.index(x)
    else:
        return default

idx = my_index(arr, 1)

if idx == -1:
    print(-1)
else:
    search = 2
    while idx < n:
        s_arr = arr[idx:]
        n_idx = my_index(s_arr, search)
        if n_idx == -1:
            break
        idx += n_idx
        search += 1
    
    print(n - search + 1)

### FIXED CODE ###

n = int(input())
a_list = list(map(int, input().split()))

ans = 0
current = 1
flag = False

for a in a_list:
    if a != current:
        ans += 1
    else:
        current += 1
        flag = True

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

#! -*- coding: UTF-8 -*-

import itertools

k, s = map(int, input().strip().split())
result = [i for i in itertools.product(range(k+1), repeat=3) if sum(i) == s]
print(len(result))


### FIXED CODE ###

k, s = list(map(int, input().split()))
result = 0
for x in range(k+1):
  for y in range(k+1):
    if 0 <= s-x-y <= k:
      result += 1
print(result)
### BUGGY CODE ###

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

N = int(input().strip())
from itertools import combinations
nodes = list(combinations(range(N), 2))
graph = {i:set() for i in nodes}
for x in range(N):
  l = list(map(int,input().split()))
  y = l[0]-1
  prev = (min(x,y),max(x,y))
  for y in l[1:]:
    y -= 1
    now = (min(x,y),max(x,y))
    graph[prev].add(now)
    prev = now

d = {k:1 for k in nodes}
f = {k:0 for k in nodes}
in_cnt = {k:0 for k in nodes}
for x in nodes:
  for y in graph[x]:
    in_cnt[y] += 1
ret = []
q = deque([i for i in nodes if not in_cnt[i]])
if not q:
  print(-1)
  exit()
ans = 0
while q:
  x = q.popleft()
  ret.append(x)
  f[x] = 1
  for y in graph[x]:
    if f[y]:
      print(-1)
      exit()
    d[y] = max(d[y],d[x]+1)
    ans = max(ans,d[y])
    in_cnt[y] -= 1
    if not in_cnt[y]:
      q.append(y)
if [i for i in nodes if in_cnt[i]]:
  print(-1)
  exit()

print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

N = int(input().strip())
M = N*(N-1)//2

graph = [[] for i in range(M)]
in_cnt = [0 for i in range(M)]
for x in range(1,N+1):
  l = list(map(int,input().split()))
  y = l[0]
  b,s = max(x,y),min(x,y)
  prev = (b-1)*(b-2)//2+s-1
  for y in l[1:]:
    b,s = max(x,y),min(x,y)
    now = (b-1)*(b-2)//2+s-1
    graph[prev].append(now)
    in_cnt[now] += 1 
    prev = now

d = [1 for k in range(M)]
q = [i for i in range(M) if not in_cnt[i]]

if not q:
  print(-1)
  exit()
ans = 0
while q:
  x = q.pop()
  for y in graph[x]:
    d[y] = max(d[y],d[x]+1)
    ans = max(ans,d[y])
    in_cnt[y] -= 1
    if not in_cnt[y]:
      q.append(y)
if [i for i in range(M) if in_cnt[i]]:
  print(-1)
  exit()

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

import math

H,N = map(int,input().split())
ab = [list(map(int,input().split()))for _ in range(N)]

dp=[[[float('INF'),0] for _ in range(H+1)]for i in range(N+1)]
dp[0]=[[0,0]for _ in range(H+1)]
for i in range(1,N+1):
  a = ab[i-1][0]
  b = ab[i-1][1]
  for j in range(1,H+1):
    limit = math.floor(j/a)+2
    for k in range(limit):
      if j>=a*k:
        mana = dp[i-1][j-(a*k)][0]+b*k
        damage = dp[i-1][j-(a*k)][1]+(a*k)
        if damage >= j:
          if dp[i][j][0] > mana:
            dp[i][j]=[mana,damage]
      else:
        mana = b*k
        damage = a*k
        if dp[i][j][0] > mana:
          dp[i][j]=[mana,damage]

print(dp[N][H][0])

### FIXED CODE ###

#モンスターの体力は H
#トキはN種類の魔法が使え、
#i番目の魔法を使うと、モンスターの体力を Ai減らすことができますが、
#トキの魔力を Bi消耗します。

#dp[i] = モンスターの体力を i 減らすため消耗する魔力の最小値
#dp[i+1] = min(dp[i-Ai]+Bi,dp[i])
#dp[0]=0

import numpy as np
 
h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
ab = np.array(ab)
 
a = ab[:, 0]
b = ab[:, 1]
 
dp = np.zeros(100001, dtype=np.int)
for i in range(1, h+1):
    dp[i] = (dp[i-a]+b).min()
print(dp[h])
### BUGGY CODE ###

N = int(input())

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

ans = 0

for i in range(N):
  if i == 0:
    ans += 1
    continue
  
  if P[i] < min(P[:i]):
    ans += 1

print(ans)

### FIXED CODE ###

N = int(input())

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

ans = 1
minj = 0

for i in range(1, N):
  
  if P[i] < P[minj]:
    ans += 1
    minj = i

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

# https://atcoder.jp/contests/abc138/tasks/abc138_d

from collections import deque

def bfs(graph, start, query):
    queue = deque([])
    acc = query[start] if start in query else 0
    queue.append([start, acc])
    ans = {start:acc}

    while queue:
        idx, acc = queue.popleft()
        for child in graph[idx].keys():
            ans[child] = acc
            if child in query:
                ans[child] += query[child]
            queue.append([child, ans[child]])
            del graph[child][idx]
    [print(ans[i], end=' ') for i in range(1, n+1)]

n,q = map(int, input().split())
tree = {}
start = 1
for i in range(n-1):
    a,b = map(int, input().split())
    if a not in tree:
        tree[a] = {}
    tree[a][b] = 1
    if b not in tree:
        tree[b] = {}
    tree[b][a] = 1

query = {}
for _ in range(q):
    p, x = map(int,input().split())
    if p not in query:
        query[p] = x
    else:
        query[p] += x
bfs(tree, start, query)


### FIXED CODE ###

# https://atcoder.jp/contests/abc138/tasks/abc138_d

from collections import deque

def bfs(graph, start, query, n):
    queue = deque([])
    acc = query[start] if start in query else 0
    queue.append([start, acc])
    ans = [-1] * n
    ans[start] = acc

    while queue:
        idx, acc = queue.popleft()
        for child in graph[idx].keys():
            if ans[child] >= 0:
                continue
            ans[child] = acc
            if child in query:
                ans[child] += query[child]
            queue.append([child, ans[child]])
    
    print(' '.join(map(str, ans)))

n,q = map(int, input().split())
tree = {}
start = 0
for i in range(n-1):
    a,b = map(int, input().split())
    a -= 1
    b -= 1
    if a not in tree:
        tree[a] = {}
    tree[a][b] = 1
    if b not in tree:
        tree[b] = {}
    tree[b][a] = 1

query = {}
for _ in range(q):
    p, x = map(int,input().split())
    p -= 1
    if p not in query:
        query[p] = x
    else:
        query[p] += x
bfs(tree, start, query, n)
### BUGGY CODE ###

A, B, Q = map(int, input().split())
s = [int(input()) for i in range(A)]
t = [int(input()) for i in range(B)]
x = [int(input()) for i in range(Q)]


def binary_search(list, a):
    r = 0
    l = len(list)-1
    while l - r > 1:
        if list[(r+l)//2] > a:
            l = (r+l)//2
        else:
            r = (r+l)//2
    return r, l


def cost(start, s, t):
    if s == t:
        return abs(start - s)

    min_o = min(s, t)
    max_o = max(s, t)
    if start <= min_o:
        return max_o - start
    elif start <= max_o:
        return min(abs(start-min_o), abs(start-max_o)) + (max_o-min_o)
    else:
        return start - min_o


for start in x:
    s_r, s_l = binary_search(s, start)
    s_r_t_r, s_r_t_l = binary_search(t, s[s_r])
    s_l_t_r, s_l_t_l = binary_search(t, s[s_l])

    res0 = cost(start, s[s_r], t[s_r_t_r])
    res1 = cost(start, s[s_r], t[s_r_t_l])
    res2 = cost(start, s[s_l], t[s_l_t_r])
    res3 = cost(start, s[s_l], t[s_l_t_l])
    print(min(res0, res1, res2, res3))

### FIXED CODE ###

import bisect
A, B, Q = map(int, input().split())
INF = 10**18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
x = [int(input()) for i in range(Q)]



def cost(start, s, t):
    if s == t:
        return abs(start - s)

    min_o = min(s, t)
    max_o = max(s, t)
    if start <= min_o:
        return max_o - start
    elif start <= max_o:
        return min(abs(start-min_o), abs(start-max_o)) + (max_o-min_o)
    else:
        return start - min_o


for start in x:
    s_r = bisect.bisect_right(s, start)
    s_l = s_r - 1
    t_r = bisect.bisect_right(t, start)
    t_l = t_r - 1


    res0 = cost(start, s[s_r], t[t_r])
    res1 = cost(start, s[s_r], t[t_l])
    res2 = cost(start, s[s_l], t[t_r])
    res3 = cost(start, s[s_l], t[t_l])
    print(min(res0, res1, res2, res3))
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = ''
for i in range(1,n+1):
    ans+=(str(a.index(i)+1)+' ')
print(ans)

### FIXED CODE ###

n = int(input())
a = [int(i) for i in input().split()]
b = [0 for i in range(n)]
for i in range(n):
    b[a[i]-1] = i+1
print(*b)
### BUGGY CODE ###

from math import floor
A, B, N = map(int, input().split())
ans = max([floor(A*x/B)-A*floor(x/B) for x in range(1, min(B, N)+1)])
print(ans)

### FIXED CODE ###

from math import floor
A, B, N = map(int, input().split())
print(floor(A*min(B-1, N)/B))
### BUGGY CODE ###

from queue import Queue
def bfs(target, graph, ans):
    visited = [False]*len(graph)
    que = Queue()
    que.put(target)
    visited[target] = True
    distance = [0]*len(graph)
    while not que.empty():
        root = que.get()
        for dst in graph[root]:
            if visited[dst] is False:
                visited[dst] = True
                que.put(dst)
                dist = distance[root] + 1
                distance[dst] = dist
                ans[dist-1] += 1 

n, x, y = map(int, input().split())
graph = {i:[] for i in range(n)}
for i in range(n-1):
    graph[i].append(i+1)
    graph[i+1].append(i)
graph[x-1].append(y-1)
graph[y-1].append(x-1)
ans = [0]*(n-1)
for target in range(n):
    bfs(target, graph, ans)

for a in ans:
    print(a//2)

### FIXED CODE ###

n, x, y = map(int, input().split())
x -= 1
y -= 1
dist = [0]*(n-1)
for start in range(n):
    for end in range(start+1, n):
        dst = min(end-start, abs(x-start) + abs(end-y) + 1)
        dist[dst-1] += 1

for d in dist:
    print(d)
### BUGGY CODE ###


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

field=[]
m=[]
INF=10**6

for i in range(h):
    row=list(input())
    field.append(row)
    m.append([INF for i in range(w)])

dx=[1,0,-1,0]
dy=[0,1,0,-1]

queue=[]
for i in range(h):
    for j in range(w):
        if field[i][j]=="#":
            m[i][j]=0
            queue.append([i,j])

while len(queue)>0:
    y,x=queue.pop(0)
    field[y][x]="#"
    for k in range(4):
        nx=x+dx[k]
        ny=y+dy[k]
        if 0<=ny<h and 0<=nx<w:
            if m[ny][nx]>m[y][x]+1 and field[ny][nx]==".":
                m[ny][nx]=m[y][x]+1
                queue.append([ny,nx])

ans=0

for i in range(h):
    ans=max(ans,max(m[i]))

print(ans)

### FIXED CODE ###

h,w=map(int,input().split())
INF=10**10
a=[[INF for i in range(w)] for j in range(h)]
ans=0
for i in range(h):
    s=input()
    for j in range(w):
        if s[j]=="#":
            a[i][j]=0
            
for i in range(h):
    for j in range(w):
        k=a[i][j]+1

        if i!=h-1:
            if k<a[i+1][j]:
                a[i+1][j]=k
        if j!=w-1:
            if k<a[i][j+1]:
                a[i][j+1]=k

for i in range(h):
    for j in range(w):
        k=a[-1-i][-1-j]+1
        if i!=h-1:
            if k<a[-i-2][-j-1]:
                a[-i-2][-j-1]=k

        if j!=w-1:        
            if k<a[-i-1][-j-2]:
                a[-i-1][-j-2]=k

for i in range(h):
    ans=max(ans,max(a[i]))
print(ans)
### BUGGY CODE ###

from collections import deque
import numpy as np
h, w = map(int, input().split())
mass = [[ord(i) for i in input()] for _ in range(h)]
wall = ord("#")

dr = np.array([[0, 1], [0, -1], [1, 0], [-1, 0]])


def bfs(s, t):
    if mass[s][t] == wall:
        return 0
    visited = [[False] * w for _ in range(h)]
    depth = np.zeros((h, w))
    q1 = deque([s])
    q2 = deque([t])
    visited[s][t] = True
    while q1:
        x = q1.popleft()
        y = q2.popleft()
        visited[x][y] = True
        for nx, ny in dr + [x, y]:
            if nx < 0 or h - 1 < nx:
                continue
            if ny < 0 or w - 1 < ny:
                continue

            if mass[nx][ny] == wall:
                continue
            if visited[nx][ny]:
                continue

            q1.append(nx)
            q2.append(ny)
            depth[nx][ny] = depth[x][y] + 1

    return np.max(depth)


ans = 0
for i in range(h):
    for j in range(w):
        ans = max(ans, bfs(i, j))
print(int(ans))


### FIXED CODE ###

import numpy as np
from collections import deque
h, w = map(int, input().split())
r = [list(input()) for i in range(h)]


def dist(s, t):
    if r[s][t] == "#":
        return 0
    else:
        visited = np.zeros((h, w))
        visited[s][t] += 1
        distance = np.zeros((h, w))
        q = deque([[s, t]])
        while len(q) > 0:
            i, j = q.popleft()
            d = distance[i][j] + 1
            if j != w-1:
                if r[i][j+1] == "." and not visited[i][j+1]:
                    q.append([i, j + 1])
                    visited[i][j+1] += 1
                    distance[i][j+1] += d
            if j != 0:
                if r[i][j-1] == "." and not visited[i][j-1]:
                    q.append([i, j - 1])
                    visited[i][j - 1] += 1
                    distance[i][j - 1] += d
            if i != 0:
                if r[i-1][j] == "." and not visited[i-1][j]:
                    q.append([i - 1, j])
                    visited[i-1][j] += 1
                    distance[i-1][j] += d
            if i != h-1:
                if r[i+1][j] == "." and not visited[i+1][j]:
                    q.append([i + 1, j])
                    visited[i+1][j] += 1
                    distance[i+1][j] += d
        return np.max(distance)


ans = 0
for s in range(h):
    for t in range(w):
        ans = max(ans, dist(s, t))

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

def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    ans = a[0]
    for i in range(1, n):
        ans *= a[i]        

    if ans > 10 ** 18:
        ans = -1

    print(f'{ans}')


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    # a = list(map(int, input().split()))
    
    ans = a[0]
    if 0 in a:
        ans = 0
    else:    
        for i in range(1, n):
            ans *= a[i]
            if ans > 10 ** 18:
                ans = -1
                break

    print(f'{ans}')


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

n = int(input())
A = []
for _ in range(n):
    A.append(int(input()))

for a in A:
    for i in range(2, a//2+1):
        if a%i == 0:
            n -= 1
            break

print(n)

### FIXED CODE ###

import sys
import math

def isprime(n):
    if n == 2:
        return 1
    if n < 2 or n % 2 == 0:
        return 0

    i = 3
    while i <= math.sqrt(n):
        if n % i == 0:
            return 0
        i += 2
    return 1

n = int(input())
p = 0
for i in map(int, sys.stdin.readlines()):
    p += isprime(i)

print(p)
### BUGGY CODE ###

A,B,C,D=map(int,input().split())
a=[i for i in range(A,B+1) if i%C==0 or i%D==0]
print(B-A+1-len(a))

### FIXED CODE ###

import fractions
A,B,C,D=map(int,input().split())
c=B//C-(A-1)//C
d=B//D-(A-1)//D
lm=C*D//fractions.gcd(C,D)
cd=B//lm-(A-1)//lm

print(B-A+1-c-d+cd)
### BUGGY CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
for i in range(M):
  list.sort(A, reverse=True)
  A[0] = A[0] // 2
print(sum(A))

### FIXED CODE ###

import heapq
import math

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

hq = []
for a in A:
  heapq.heappush(hq, a * -1)

for i in range(M):
  n = math.ceil(heapq.heappop(hq) / 2)
  heapq.heappush(hq, n)

b = []
for hqi in hq:
  b.append(hqi * -1)
  
print(sum(b))
### BUGGY CODE ###

S = str(input())
li = []
dic = {}
ans = 0

s = 0
for i in range(len(S)):
  s += int(S[len(S)-1-i]) * (10**i)
  s = s % 2019
  if s == 0:
    ans += 1
  elif s not in li:
    li.append(s)
  elif s not in dic:
    dic[s] = 2
  else:
    dic[s] += 1
  
li = list(dic.values())
for l in li:
  ans += l * (l-1) // 2

print(ans)

### FIXED CODE ###

S = str(input())
li = [0] * 2019
ans = 0
li[0] = 1

d = 1
s = 0
for i in S[::-1]:
  s += int(i) * d
  s = s % 2019
  li[s] += 1
  d *= 10
  d = d % 2019
  
for l in li:
  ans += l * (l-1) // 2

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

#幅
k = int(input())
ans = []
queue = [i for i in range(1,10)]

while queue:
    if len(ans)==k:
        print(ans[k-1])
        break
    now = queue.pop(0)
    ans.append(now)
    if int(str(now)[-1]) -1 >= 0:
        queue.append(int(str(now) +str(int(str(now)[-1])-1)))

    queue.append(int(str(now) +str(now)[-1]))

    if int(str(now)[-1]) +1 <= 9:
        queue.append(int(str(now) +str(int(str(now)[-1])+1)))

### FIXED CODE ###

k = int(input())
ans = [str(i) for i in range(1,10)]
c = 0

while len(ans) < k:
    now = ans[c]
    t = int(now[-1])
    if t != 0:
        ans.append(str(now) +str(t-1))

    ans.append(str(now) +str(now)[-1])

    if t != 9:
        ans.append(str(now) +str(t+1))

    c += 1
print(ans[k-1])
### BUGGY CODE ###

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

ans = N
a = N - X
b = X
while a != b:
    if a >= b:
        a, b = b, a
    if b%a != 0:
        ans += 2 * a * (b//a)
        b = b%a
    else:
        ans += 2 * a
        b = b - a
print (ans + a)


    

### FIXED CODE ###

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

ans = N
a = N - X
b = X
while a != b:
    if a >= b:
        a, b = b, a
    if b%a != 0:
        ans += 2 * a * (b//a)
        b = b%a
    else:
        ans += 2 * a * (b//a - 1)
        b = a
print (ans + a)
### BUGGY CODE ###

from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
t=1
for i in a:
  t=t/gcd(t,i)*i
ans=0
MOD=1000000007
for i in a:
  ans+=t//i
  ans%=MOD
print(int(ans+0.0000001))


### FIXED CODE ###

from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
b=1
for i in a:
  b=b//gcd(b,i)*i
ans=0
for i in a:
  ans+=(b//i)
print(ans%(10**9+7))
### BUGGY CODE ###

S = input()
g = 10 ** 9 + 7
x = 1
DP = [[0] * 13 for _ in range(2)]
DP[0][0] = 1
for i in range(len(S)):
    for j in range(13):
        DP[1][j] = DP[0][j] % g
        DP[0][j] = 0
    for j in range(13):
        if S[i] == "?":
            for k in range(10):
               DP[0][(j*10+k)%13] += DP[1][j]
        else:
            DP[0][(j*10+int(S[i]))%13] += DP[1][j]

print(DP[0][5] % g)


### FIXED CODE ###

S = input()
g = 10 ** 9 + 7
x = 1
DP = [[0] * 13 for _ in range(2)]
DP[0][0] = 1
for i in range(len(S)):
    for j in range(13):
        DP[1][j] = DP[0][j] % g
        DP[0][j] = 0
    for j in range(13):
        if S[i] == "?":
            for k in range(10):
               DP[0][(j*10+k)%13] += DP[1][j]
        else:
            DP[0][(j*10+int(S[i]))%13] += DP[1][j]

print(DP[0][5] % g)
### BUGGY CODE ###

n = int(input())
x = 1
res = n
while x * x <= n:
  if n % x == 0:
    res = min(res, x + n // x)
print(res)

### FIXED CODE ###

n = int(input())
i = 1
res = n
while i * i <= n:
  if n % i == 0:
    res = min(res, i + n//i - 2)
  i += 1
print(res)
### BUGGY CODE ###

#coding:utf-8
N=int(input())
S=input()
comb=0
if N<3:
	comb=0
else:
	for i in range(N-2):
		for j in range(i+1,N-1):
			for k in range(j+1,N):
				if S[i]!=S[j] and S[i]!=S[k] and S[j]!=S[k] and (j-i)!=(k-j):
					comb+=1
print(comb)

### FIXED CODE ###

#coding:utf-8
N=int(input())
S=input()
r=S.count("R")
g=S.count("G")
b=S.count("B")
ans=r*b*g

for i in range(N-2):
	for d in range(N):
		j=i+d
		k=j+d
		if k>N-1:
			break
		elif S[i]!=S[j] and S[i]!=S[k] and S[j]!=S[k]:
			ans-=1
print(ans)