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

def solve():
    BASE = 10**9 + 7
    MOD = 2**61 - 1  # メルセンヌ素数

    # [Ssの先頭lenRH文字]のハッシュ値を求める
    def getHash(Ss, lenRH):
        hashS = 0
        for S in Ss[:lenRH]:
            hashS *= BASE
            hashS += ord(S)
            hashS %= MOD
        return hashS

    ss = input()
    ts = input()

    cs = set(ss)
    ct = set(ts)
    if len(cs) == 1 and len(ct) == 1 and cs == ct:
        print(-1)
        return
    elif ss.replace(ts, '') == '':
        print(-1)
        return

    Ss = ss + ss
    lenS, lenT = len(Ss), len(ts)
    lenRH = lenT

    powB_P = pow(BASE, lenRH)

    hashS = getHash(Ss, lenRH)
    hashT = getHash(ts, lenRH)

    isFounds = [False] * lenS

    Ss += '$' # ダミー
    for i in range(lenS - lenRH + 1):
        # ハッシュ値が一致
        if hashS == hashT:
            isFounds[i] = True
        hashS *= BASE
        hashS += ord(Ss[i+lenRH]) - ord(Ss[i])*powB_P
        hashS %= MOD
#    print(isFounds)

    ans = 0
    for i in range(lenS):
        if not isFounds[i]: continue
        num = 0
        for j in range(i, lenS, lenT):
            if isFounds[j]:
                num += 1
                isFounds[j] = False
            else:
                break
        ans = max(ans, num)

    print(ans)


solve()


### FIXED CODE ###

def getTableKMP(Ss):
    Ss += '$'
    lenS = len(Ss)
    table = [-1] * lenS
    j = -1
    for i in range(lenS-1):
        while j >= 0 and Ss[i] != Ss[j]:
            j = table[j]
        j += 1
        if Ss[i+1] == Ss[j]:
            table[i+1] = table[j]
        else:
            table[i+1] = j
    return table

def getPosPtnsKMP(Ss, ptn, table):
    anss = []
    lenS, lenP = len(Ss), len(ptn)
    iS, iP = 0, 0
    while iS < lenS:
        if Ss[iS] == ptn[iP]:
            iS += 1
            iP += 1
            if iP == lenP:
                anss.append(iS-lenP)
                iP = table[iP]
        else:
            iP = table[iP]
            if iP == -1:
                iS += 1
                iP = 0
    return anss


Ss = input()
Ts = input()

lenS, lenT = len(Ss), len(Ts)
num = (lenT+lenS-1+lenS-1) // lenS
S2s = Ss * num

tableKMP = getTableKMP(Ts)
posPtns = getPosPtnsKMP(S2s, Ts, tableKMP)

isFounds = [False] * lenS
for pos in posPtns:
    if pos >= lenS:
        break
    isFounds[pos] = True

ans = 0
numDone = 0
for i in range(lenS):
    if not isFounds[i]:
        i = (i+lenT) % lenS
        for num in range(lenS+1):
            if not isFounds[i]:
                ans = max(ans, num)
                numDone += num+1
                break
            i = (i+lenT) % lenS
        else:
            ans = -1
            break

if numDone < lenS:
    ans = -1
print(ans)
### BUGGY CODE ###

def max_ten(s):
    if memo[s]!="e":
        return memo[s]
    ten = 0
    # 分けない場合の点数
    for ai, ar in enumerate(a[:-1]):
        if s >> ai & 1:
            ten += sum(ar[j] * (s >> j & 1) for j in range(1 + ai, n))
    # 分ける場合の点数
    bubun = (s - 1) & s
    while bubun > 0:
        kari = max_ten(bubun) + max_ten(bubun ^ s)
        if kari > ten:
            ten = kari
        bubun = (bubun - 1) & s
    memo[s] = ten
    return ten


n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
s = (1 << n) - 1
memo = ["e"] * (1 << n)
print(max_ten(s))


### FIXED CODE ###

def max_ten(s):
    if memo[s]!="e":
        return memo[s]
    ten = 0
    # 分けない場合の点数
    for ai, ar in enumerate(a[:-1]):
        if s >> ai & 1:
            ten += sum(ar[j] * (s >> j & 1) for j in range(1 + ai, n))
    # 分ける場合の点数
    bubun = (s - 1) & s
    while bubun > 0:
        kari = max_ten(bubun) + max_ten(bubun ^ s)
        if kari > ten:
            ten = kari
        bubun = (bubun - 1) & s
    memo[s] = ten
    return ten


n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
s = (1 << n) - 1
memo = ["e"] * (1 << n)
print(max_ten(s))
### BUGGY CODE ###

X=int(input())
l=[2]
t=3
while 1:
    for i in l:
        if t%i==0:
            break
    else:
        if t>=X:
            break
        l.append(t)
    t+=1
if X==2:
    t=2
print(t)


### FIXED CODE ###

X=int(input())
l=[2]
t=3
while 1:
    for i in l:
        if t%i==0:
            break
    else:
        if t>=X:
            break
        l.append(t)
    t+=1
if X==2:
    t=2
print(t)
### BUGGY CODE ###

n=int(input())
import math
count=0
a=1
b=1
c=1
for i in range(n):
    for j in range(n):
        for m in range(n):
            k=math.gcd(a,b)
            l=math.gcd(k,c)
            count+=l
            c+=1
        c=1
        b+=1
    b=1
    a+=1
print(count)

### FIXED CODE ###

n=int(input())
import math
count=0
a=1
b=1
c=1
for i in range(n):
    for j in range(n):
        for m in range(n):
            k=math.gcd(a,b)
            l=math.gcd(k,c)
            count+=l
            c+=1
        c=1
        b+=1
    b=1
    a+=1
print(count)
### BUGGY CODE ###

n = int(input())
l = list(map(int, input().split()))
l.sort()

ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if l[i] + l[j] > l[k]:
                ans += 1
            else:
                break
print(ans)

### FIXED CODE ###

import bisect
n = int(input())
l = list(map(int, input().split()))
l.sort()

ans = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        a = bisect.bisect(l, l[i]+l[j]-1)
        ans += (a-j-1)
print(ans)
### BUGGY CODE ###

from bisect import*
import sys;input=sys.stdin.readline

n,q=map(int,input().split())
event=[]
stop=set([-1])

def doevent(lis):
    global stop
    a,b=lis
    if b>=0:
        if stop=={-1}:
            stop=set()
        stop.add(b)
    else:
        if -b in stop:
            stop.remove(-b)
        if stop==set():
            stop={-1}
    return min(stop)

for i in range(n):
    s,t,x=map(int,input().split())
    event.append((s-x,x))
    event.append((t-x,-x))
event.sort(key=lambda x:x[0])

minlist=[doevent(i)for i in event] #時間をindexとしたminlist

for i in range(q):
    print(minlist[bisect_right(event,(int(input()),float("inf")))-1])

### FIXED CODE ###

import sys;input=sys.stdin.readline

n,q=map(int, input().split())
event=[]
for _ in range(n):
    s,t,x=map(int,input().split())
    event.append((s-x-0.5,1,x))
    event.append((t-x-0.5,-1,x))
for i in range(q):
    event.append((int(input()),0,i))
    
event.sort()
is_stop=False
stop=set()
minstop=float('inf')
ans=[-1]*q
for t,e,x in event:
    if e > 0:
        stop.add(x)
        if x<minstop:
            minstop=x
            is_stop=True
    elif e<0:
        stop.remove(x)
        if minstop==x:
            is_stop=False
    elif len(stop)>0:
        if not is_stop:
             minstop=min(stop)
             is_stop=True
        ans[x]=minstop
        
print('\n'.join(map(str, ans)))
### BUGGY CODE ###

alphabet_small = [chr(i) for i in range(97, 97+26)]
s = input()
k = int(input())
ans = ""
for num,character in enumerate(s):
    for i in range(26):
        if character == alphabet_small[i]:
            if i != 0 and k >= 26-i:
                k -= 26-i
                ans += "a"
            else:
                ans += character
            break

if k > 0:
    k %= 26
    for i in range(26):
        if ans[-1] == alphabet_small[i]:
            ans = ans[:-1] + alphabet_small[(i+k)%26]
            break

print(ans)

### FIXED CODE ###

alphabet_small = {chr(i):i-97 for i in range(97, 97+26)}
s = input()
k = int(input())
ans =""
for character in s:
    i = alphabet_small[character]
    #print(i,character)
    if i != 0 and k >= 26 - i:
        k -= 26 - i
        ans += "a"
    else:
        ans += character


if k > 0:
    k %= 26
    ans = ans[:-1] + chr((alphabet_small[ans[-1]]+k)%26+97)

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

(_, M) = map(int, input().split())
A = list(map(int, input().split()))
for _ in range(M):
  i = A.index(max(A))
  A[i] = A[i]//2
print(sum(A))

### FIXED CODE ###

from heapq import heappush, heappop
def main():
	(N, M) = map(int, input().split())
	hq =  list(map(lambda x:-x, map(int, input().split())))
	hq.sort()
	for i in range(M):
		b = - heappop(hq) // 2
		heappush(hq, -b)
	print(-sum(hq))
main()
### BUGGY CODE ###

n=int(input())
arr=[int(x) for x in input().split()]
for i in range(n):
    a = arr[:i] + arr[i+1:]
    a.sort()
    index = int((n-1)/2)
    print(a[index])


### FIXED CODE ###

n=int(input())
arr=[int(x) for x in input().split()]
sorted_arr = sorted(arr)
l = sorted_arr[n//2 -1]
r = sorted_arr[n//2]
for x in arr:
    if x >= r:
        print(l)
    else:
        print(r)
### BUGGY CODE ###

import sys
readline = sys.stdin.readline
def maxHeapify(A, i):
    l = i * 2 + 1
    r = i * 2 + 2
    if l < n:
        largest = l
        if r < n and A[r] > A[l]:
            largest = r
        if A[largest] > A[i]:
            A[i], A[largest] = A[largest], A[i]
            maxHeapify(A, largest)
def insert(S, k):
    S.append(k)
    i = n - 1
    p = (i - 1) // 2
    while i > 0 and S[i] > S[p]:
        S[i], S[p] = S[p], S[i]
        i = p
        p = (i - 1) // 2
def extractMax(S):
    global n
    if n == 1:
        n -= 1
        return S.pop()
    ans = S[0]
    S[0] = S.pop()
    n -= 1
    maxHeapify(S, 0)
    return ans
A = []
n = 0
while True:
    s = readline()
    if s[2] == "d":
        break
    elif s[2] == "t":
        print(extractMax(A))
    else:
        n += 1
        insert(A, int(s[7:]))



### FIXED CODE ###

import sys
from heapq import heapify, heappush, heappop
hq = []
S = []
for s in sys.stdin:
    if s[2] == "s":
        heappush(hq, -int(s[7:]))
    elif s[2] == "t":
        S.append(-heappop(hq))
    else:
        break
print("\n".join(map(str, S)))
### BUGGY CODE ###




aa=int(input())
N=[0 for i in range(aa)]
for i in range(aa):
  bb=input()
  #print(b)
  N[i]=bb.split()


def so(p,q):
  while p!=q:
    if p>q:
      p-=q
    else:
      q-=p
  return p


#print(so(11,5))

def aaa(n):

  a=int(N[n][0])
  b=int(N[n][1])
  c=int(N[n][2])
  d=int(N[n][3])

  e=a-a//b*b
  f=d-d//b*b
  
  if e*f>0 :
    s=so(e,f)
  else :
    s=f


  if a<b or d<b :
    return "No"
  
  elif b<=c :
    return "Yes"
  else:
  
    if f!=0 :
      ss=b//s*s
      if ss==b:
        ss-=s

      if ss>c:
        return "No"
          
    

        #print(e)
        #print(f)
  #print("while")
    else:
      if e>c :
        return "No"

  return "Yes"

for i in range(aa):
  print(aaa(i))


### FIXED CODE ###

import sys
input = sys.stdin.readline

n = int(input())
C = [list(map(int,input().split())) for i in range(n)]

from fractions import gcd

for i in range(n):
    a = C[i][0]
    b = C[i][1]
    c = C[i][2]
    d = C[i][3]
    ng = 0

    e = 0  # 最初に補充が発生する直前の本数
    e0 = a - b
    e1 = ((c - a%b) // b) * b + a%b
    e = min(e0, e1)

    if e < 0 or b > d:
        ng = 1
    else:
        g = gcd(b, d)
        # print(c+1, b-1, g)
        if c+1 <= b-1 and (c - e) // g < (b-1 - e) // g:
            ng = 1

    if ng == 1:
        print("No")
    else:
        print("Yes")
### BUGGY CODE ###

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


def solve():
    H, W, K = map(int, input().split())
    y1, x1, y2, x2 = map(int, input().split())
    l = [[1 if s=="@" else 0 for s in input()] for _ in range(H)]
    INF = 10**12

    x1 -= 1
    y1 -= 1
    x2 -= 1
    y2 -= 1

    ddy = [0, 0, -1, 1]
    ddx = [-1, 1, 0, 0]

    dist = defaultdict(lambda :INF)
    dist[(y1, x1)] = 0
    q = deque([(y1, x1)])

    while q:
        y, x = q.popleft()
        for i in range(4):
            dx = ddx[i]
            dy = ddy[i]
            for j in range(1, K+1):
                if not (0<=y+dy*j<H and 0<=x+dx*j<W):
                    break
                if l[y+dy*j][x+dx*j]:
                    break

                if dist[(y+dy*j, x+dx*j)] > dist[(y, x)] + 1:
                    dist[(y+dy*j, x+dx*j)] = dist[(y, x)] + 1
                    q.append((y+dy*j, x+dx*j))


    ans = dist[(y2, x2)]
    print(ans if ans!=INF else -1)


if __name__ == "__main__":
    solve()


### FIXED CODE ###

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


def solve():
    H, W, K = map(int, input().split())
    y1, x1, y2, x2 = map(int, input().split())
    l = [[1 if s=="@" else 0 for s in input()] for _ in range(H)]
    INF = 10**12

    x1 -= 1
    y1 -= 1
    x2 -= 1
    y2 -= 1

    ddy = [0, 0, -1, 1]
    ddx = [-1, 1, 0, 0]

    dist = defaultdict(lambda :INF)
    dist[(y1, x1)] = 0
    q = deque([(y1, x1)])

    while q:
        y, x = q.popleft()
        for dy, dx in zip(ddy, ddx):
            for j in range(1, K+1):
                if not (0<=y+dy*j<H and 0<=x+dx*j<W):
                    break
                if l[y+dy*j][x+dx*j]:
                    break

                if dist[(y+dy*j, x+dx*j)] > dist[(y, x)] + 1:
                    dist[(y+dy*j, x+dx*j)] = dist[(y, x)] + 1
                    q.append((y+dy*j, x+dx*j))
                elif dist[(y+dy*j, x+dx*j)] == dist[(y, x)] + 1:
                    continue
                else:
                    break


    ans = dist[(y2, x2)]
    print(ans if ans!=INF else -1)


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

A,B,C,K = map(int,input().split())
li = [1 for a in range(A)]+ [ 0 for b in range(B)]+ [ -1 for c in range(C)]
print(sum(li[:K]))


### FIXED CODE ###

A,B,C,K = map(int,input().split())

if K<=A:
    print(K)
elif A<K<=B:
    print(A)
else:
    print(A - (K-A-B))
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
a.sort()
b=[a.count(a[0])+a.count(a[0]+1)]
for x in range(a[0]+1,a[-1]):
    b.append(a.count(x-1)+a.count(x)+a.count(x+1))
b.append(a.count(a[-1]-1)+a.count(a[-1]))
print(max(b))

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
cnt=[0]*10**6
for i in a:
    cnt[i-1]+=1
    cnt[i]+=1
    cnt[i+1]+=1
print(max(cnt))
### BUGGY CODE ###

import sys
from collections import defaultdict, deque
sys.setrecursionlimit(10**6)

def main():
    input = sys.stdin.readline
    MOD = 10**9 + 7
    N, K = map(int, input().split())
    G = defaultdict(list)
    for _ in range(N-1):
        a, b = map(int, input().split())
        a, b = a-1, b-1

        G[a].append(b)
        G[b].append(a)

    visited = [False] * N
    def dfs(n, p, ans):
        cnt = 1
        for p0 in G[p]:
            if visited[p0]:
                cnt += 1
        if n == p:
            cnt -= 1

        ans = (ans * (K - cnt)) % MOD
        visited[n] = True
        for n1 in G[n]:
            if visited[n1]:
                continue

            ans = dfs(n1, n, ans)

        return ans

    return dfs(0, 0, 1)


if __name__ == '__main__':
    print(main())


### FIXED CODE ###

import sys
from collections import defaultdict
sys.setrecursionlimit(10**6)

def main():
    input = sys.stdin.readline
    MOD = 10**9 + 7
    N, K = map(int, input().split())
    G = defaultdict(list)
    for _ in range(N-1):
        a, b = map(int, input().split())
        a, b = a-1, b-1

        G[a].append(b)
        G[b].append(a)

    visited = [False] * N
    def dfs(n, ans):
        child = 1
        if n == 0:
            child = 0

        visited[n] = True
        for c in G[n]:
            if visited[c]:
                continue
            ans = (ans * (K - 1 - child)) % MOD
            ans = dfs(c, ans)
            child += 1

        return ans

    return dfs(0, K)


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

import sys
from bisect import bisect_left, bisect_right
sys.setrecursionlimit(10**6)
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    repn = [[] for _ in range(N)]
    for _ in range(N - 1):
        u, v = map(int, input().split())
        repn[u - 1].append(v - 1)
        repn[v - 1].append(u - 1)
    
    length = [0] * (N + 1)
    dp = [-1]

    """
    やはり各頂点でLIS配列を取ると配列コピーの時間がかかってTLEするので、
    配列は唯一つを扱って、DFSからバックするときに配列も元に戻す操作を行いたい
    （ここの実装の仕方がわからなかった）

    これはdfsを再帰で書いた後に復元操作を追記すれば異常に楽に書ける。。。
    """

    def dfs(v, p=N):
        if A[v] > dp[-1]:
            dp.append(A[v])
            length[v] = length[p] + 1
            for u in repn[v]:
                if u == p: continue
                dfs(u, v)
            dp.pop()
        else:
            length[v] = length[p]
            idx = bisect_left(dp[:length[p]], A[v]) # bisect_rightだとdpに重複する値を書き込んでしまうのでダメ
            old = dp[idx]
            dp[idx] = A[v]
            for u in repn[v]:
                if u == p: continue
                dfs(u, v)
            dp[idx] = old
        #print("v={}, len={}, dp={}".format(v, length[v], dp))

    dfs(0)
    length.pop()
    for ans in length:
        print(ans)
    


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
from bisect import bisect_left, bisect_right
sys.setrecursionlimit(2*10**5)
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    repn = [[] for _ in range(N)]
    for _ in range(N - 1):
        u, v = map(int, input().split())
        repn[u - 1].append(v - 1)
        repn[v - 1].append(u - 1)
    
    length = [0] * (N + 1)
    dp = [-1]

    """
    やはり各頂点でLIS配列を取ると配列コピーの時間がかかってTLEするので、
    配列は唯一つを扱って、DFSからバックするときに配列も元に戻す操作を行いたい
    （ここの実装の仕方がわからなかった）

    これはdfsを再帰で書いた後に復元操作を追記すれば異常に楽に書ける。。。
    """

    def dfs(v, p=N):
        if A[v] > dp[-1]:
            dp.append(A[v])
            length[v] = length[p] + 1
            for u in repn[v]:
                if u == p: continue
                dfs(u, v)
            dp.pop()
        else:
            length[v] = length[p]
            idx = bisect_left(dp, A[v]) # bisect_rightだとdpに重複する値を書き込んでしまうのでダメ
            old = dp[idx]
            dp[idx] = A[v]
            for u in repn[v]:
                if u == p: continue
                dfs(u, v)
            dp[idx] = old
        #print("v={}, len={}, dp={}".format(v, length[v], dp))

    dfs(0)
    length.pop()
    for ans in length:
        print(ans)
    


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

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


def main():
    n, m = map(int, input().split())

    nexts = [[] for i in range(n)]
    
    for _ in range(m):
        ai, bi = map(int, input().split())
        ai -= 1
        bi -= 1
        nexts[ai].append(bi)
        nexts[bi].append(ai)

    blues = [1] * n # 1 is in blues
    blues[0] = 0 # 0 is not in blues

    red_deque = deque([0])

    arrows = [0] * n

    while 1 in blues:
        rd = red_deque[0]
        red_deque.popleft()

        for nxt in nexts[rd]:
            if blues[nxt] == 1:
                blues[nxt] = 0
                if nxt not in red_deque:
                    red_deque.append(nxt)
                arrows[nxt] = rd

    print("Yes")
    for arrow in arrows[1:]:
        print(arrow + 1)
    

if __name__ == "__main__":
    main()

### FIXED CODE ###

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


def main():
    n, m = map(int, input().split())

    nexts = [[] for i in range(n)]
    
    for _ in range(m):
        ai, bi = map(int, input().split())
        ai -= 1
        bi -= 1
        nexts[ai].append(bi)
        nexts[bi].append(ai)

    blues = [-1] * n # 1 is in blues
    blues[0] = 0 # 0 is not in blues
    checked = [0] * n

    red_deque = deque([0])

    while len(red_deque) > 0:
        rd = red_deque[0]
        red_deque.popleft()
        if checked[rd] == 0:
            checked[rd] = 1
            for nxt in nexts[rd]:
                if blues[nxt] == -1:
                    blues[nxt] = rd
                    red_deque.append(nxt)

    print("Yes")
    for blue in blues[1:]:
        print(blue + 1)
    

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

def more_num_len(num, r_sorted_list, n):
    for i, m in enumerate(r_sorted_list):
        if m <= num:
            return i
    return n


n = int(input())
a, b, c = [list(map(int, input().split(" "))) for i in range(3)]

a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

count = 0
for a_i in a:
    x = more_num_len(a_i, b, n)
    for b_i in b[:x]:
        y = more_num_len(b_i, c, n)
        count += y
print(count)

### FIXED CODE ###

import bisect

n = int(input())
abc = [tuple(map(int, input().split(" "))) for i in range(3)]
# n = 100000
# abc = [tuple(range(n)) for i in range(3)]

a, b, c = [sorted(abc_i) for abc_i in abc]

print(sum(bisect.bisect_left(a, b_i) * (n-bisect.bisect(c, b_i)) for b_i in b))
### BUGGY CODE ###

n, m = map(int, input().split())

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

ans = []

ways = []

for i in range(m):
    a, b = map(int, input().split())
    if (a not in ways) or (b not in ways):
        if h[a-1] < h[b-1]:
            if a not in ans:
                ans.append(a)
                ways.append(a)
        elif h[a-1] > h[b-1]:
            if b not in ans:
                ans.append(b)
                ways.append(b)
        elif h[a-1] == h[b-1]:
            if a not in ans:
                ans.append(a)
                ways.append(a)
                if b not in ans:
                    ans.append(b)
                    ways.append(b)
            elif b not in ans:
                ans.append(b)
                ways.append(b)

print(n-len(ans))


### FIXED CODE ###

N, M = map(int, input().split())
H = list(map(int, input().split()))
LIST = [ 1 for _ in range(N)]
for _ in range(M):
    A, B = map(int, input().split())
    if H[A-1] >= H[B-1]: LIST[B-1] = 0
    if H[A-1] <= H[B-1]: LIST[A-1] = 0
print(sum(LIST))
### BUGGY CODE ###

from collections import defaultdict

n, m = map(int, input().split())
ac = 0
wa = 0
a = []
b = defaultdict(int)
for _ in range(m):
    q, j = input().split()
    if q not in a and j == 'AC':
        ac += 1
        a.append(q)
        if q in b:
            wa += b[q]
    else:
        b[q] += 1
print(ac, wa)


### FIXED CODE ###

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

def main():
    n, m = map(int, input().split())
    ac = 0
    wa = 0
    b = defaultdict(lambda: 0)
    for _ in range(m):
        q, j = input().split()
        if b[q] != -1 and j == 'AC':
            ac += 1
            if q in b:
                wa += b[q]
                b[q] = -1
        else:
            if b[q] != -1:
                b[q] += 1
    print(ac, wa)

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

N = int(input())
S = input()
R = 0
G = 0
B = 0
notToAllow = 0


for i in range(0,N):
    if S[i] == "R":
        R = R + 1
    elif S[i] == "G":
        G = G + 1
    else:
        B = B + 1

total = R*G*B

for i in range(0,N-2):
    for j in range(0,(N//2)+1):
        if(j+j+i < N) and (j+j < N) and (i+j < N):
            if ((S[i] != S[i+j]) and (S[i] != S[i+j+j]) and (S[i+j] != S[i+j+j])):
                notToAllow = notToAllow + 1

print(R*G*B - notToAllow)


### FIXED CODE ###

N = int(input())
S = input()
R = 0
G = 0
B = 0
notToAllow = 0


for i in range(0,N):
    if S[i] == "R":
        R = R + 1
    elif S[i] == "G":
        G = G + 1
    else:
        B = B + 1

total = R*G*B

for i in range(0,N):
    for j in range(0,(N//2)+1):
        if(j+j+i < N):
            if ((S[i] != S[i+j])):
                if(S[i] != S[i+j+j]):
                    if(S[i+j] != S[i+j+j]):
                        notToAllow = notToAllow + 1

print(R*G*B - notToAllow)
### BUGGY CODE ###

K = int(input())
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
sum=0
for i in range(1, K+1):
    for j in range(1, K+1):
        value = gcd(i,j)
        for k in range(1, K+1):
            sum += gcd(value,k)

print(sum)
# print(gcd(2,6))


### FIXED CODE ###

K = int(input())
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)
sum=0
for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            sum += gcd(gcd(i,j),k)

print(sum)
# print(gcd(2,6))