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

n=int(input())
s_list=[input() for i in range(n)]

#出現するアルファベットをカウントしていく
al_list=[chr(ord('a') + i) for i in range(26)]

num_list = []
for _s in s_list:
    num = ''
    for _al in al_list:
        num += str(_s.count(_al))
    num_list.append(num)

count_list = []
for _num in num_list:
    count = num_list.count(_num)
    if count != 1: #1はカウントしても無駄
        count_list.append(count)

ans = 0
for i in range(1,n+1):
    ans += count_list.count(i) * (i - 1) / 2

print(int(ans))


### FIXED CODE ###

from collections import Counter #ハッシュ法
N = int(input())
s_list = [input() for i in range(N)]

#出現するアルファベットをカウントしていく
al_list = [chr(ord('a') + i) for i in range(26)]

num_list = []
count_by_kw = Counter()
for _s in s_list:
    num = ''
    for _al in al_list:
        num += str(_s.count(_al))
    
    num_list.append(num)

count_list = list(Counter(num_list).values()) 

ans = 0
for i in range(len(count_list)):
    k = count_list[i]
    ans += k * (k - 1) / 2

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

from math import sqrt, sin, cos, pi
import time

def main():
    N,L = map(int, input().split())
    t = [int(input()) for i in range(N)]
    #N,L = 100, 100
    #t = [int(i) for i in range(N)]

    comb = N * (N-1) * (N-2) / 6
    ans_X, ans_Y = 0, 0
    for i in range(N-1):
        for j in range(i+1,N):
            theta = pi * (t[j] + t[i]) / L

            I_X = cos(theta) * ((N-1) - (j-i))
            I_Y = sin(theta) * ((N-1) - (j-i))
            ans_X += I_X / comb
            ans_Y += I_Y / comb

            I_X = -cos(theta) * ((j-i) - 1)
            I_Y = -sin(theta) * ((j-i) - 1)
            ans_X += I_X / comb
            ans_Y += I_Y / comb
            #print(ans_X, ans_Y)
    
    print(ans_X, ans_Y)


if __name__ == "__main__":
    #start = time.time()
    main()
    #elapsed_time = time.time() - start
    #print ("elapsed_time:{0}".format(elapsed_time) + "[sec]")


### FIXED CODE ###

from math import sqrt, sin, cos, pi
import time

def main():
    N,L = map(int, input().split())
    t = [int(input()) for i in range(N)]
    #N,L = 3000, 3000
    #t = [int(i) for i in range(N)]

    comb = N * (N-1) * (N-2) / 6
    ans_X, ans_Y = 0, 0
    for i in range(N-1):
        for j in range(i+1,N):
            theta = pi * (t[j] + t[i]) / L

            I_X = cos(theta) * (N - 2*(j-i))
            I_Y = sin(theta) * (N - 2*(j-i))
            ans_X += I_X / comb
            ans_Y += I_Y / comb
            #print(ans_X, ans_Y)
    
    print(ans_X, ans_Y)


if __name__ == "__main__":
    #start = time.time()
    main()
    #elapsed_time = time.time() - start
    #rint ("elapsed_time:{0}".format(elapsed_time) + "[sec]")
### BUGGY CODE ###

N, M, Q = map(int, input().split(" "))
route = []
question = []
for i in range(M):
    route.append(list(map(int, input().split(" "))))
for i in range(Q):
    question.append(list(map(int, input().split(" "))))

route = sorted(route, key=lambda x: x[1])
# question = sorted(question, key=lambda x: x[1])

ans = [0 for i in range(Q)]
chk = 0
for j in range(Q):
    for i in range(M):
        if (question[j][0] <= route[i][0]) and (route[i][1] <= question[j][1]):
            ans[j] += 1

for a in ans:
    print(a)

### FIXED CODE ###

# coding: utf-8
# Your code here!

N, M, Q = map(int, input().split(" "))
L = []
R = []
p = []
q = []

for i in range(M):
    _L, _R = map(int, input().split(" "))
    L.append(_L)
    R.append(_R)
    
for i in range(Q):
    _p, _q = map(int, input().split(" "))
    p.append(_p)
    q.append(_q)
    
def buildSumTable(N, L, R):
    ret = [[0 for i in range(N+1)] for i in range(N+1)]
    for i in range(M):
        ret[L[i]][R[i]] += 1
    for i in range(1, N+1):
        for j in range(1, N+1):
            ret[i][j] += ret[i-1][j]
            ret[i][j] += ret[i][j-1]
            ret[i][j] -= ret[i-1][j-1]
    return ret

def getSumRange(table, p, q):
    return table[q][q] - table[q][p-1] - table[p-1][q] + table[p-1][p-1] 

sumTable = buildSumTable(N, L, R)

for i in range(Q):
    ans = getSumRange(sumTable, p[i], q[i])
    print(ans)
### BUGGY CODE ###

n=int(input())
c=list(input())
l=[]
for i in range(n+1):
  l.append(max(c[:i].count('W'),c[i:].count('R')))
print(min(l))

### FIXED CODE ###

n = int(input())
c = input()
w = 0
r = c.count('R')
ans = r

for k in range(n):
  if c[k] == 'W':
    w += 1
  elif c[k] == 'R':
    r -= 1
  cnt = max(w, r)
  if ans > cnt:
    ans = cnt
print(ans)
### BUGGY CODE ###

from collections import deque

N,M = map(int,input().split())
edges = []
ad = [[] for _ in range(N)]
for _ in range(M):
    u,v = map(int,input().split())
    u -= 1
    v -= 1
    ad[u].append(v)
    edges.append((u,v))
S,T = map(int,input().split())
S -= 1
T -= 1

dq = deque()
dq.append((S,0))
while dq:
    v,d = dq.popleft()
    nd = d + 1
    for nv in ad[v]:
        if nv == T and nd % 3 == 0:
            print(nd//3)
            exit()
        if d == 3*10**5:
            print(-1)
            exit()
        dq.append((nv,nd))

print(-1)

### FIXED CODE ###

from collections import deque

N,M = map(int,input().split())
ad = [[[] for _ in range(3)] for _ in range(N)]
for _ in range(M):
    u,v = map(int,input().split())
    u -= 1
    v -= 1
    for j in range(3):
        ad[u][j].append((v,(j+1)%3))
S,T = map(int,input().split())
S -= 1
T -= 1

visited = [[False]*3 for _ in range(N)]
dq = deque()
dq.append((S,0,0))
visited[S][0] = True

while dq:
    v,j,d = dq.popleft()
    nd = d + 1
    for nv,nj in ad[v][j]:
        if (nv,nj) == (T,0):
            print(nd//3)
            exit()
        if visited[nv][nj]:
            continue
        visited[nv][nj] = True
        dq.append((nv,nj,nd))
        
print(-1)
### BUGGY CODE ###

import sys

def longestcommonsubsequence():
    seq1 = raw_input()
    seq2 = raw_input()

    a,b = len(seq1), len(seq2)
    x1 = [0 for i in range(b+1)]
    i=0
    for e1 in seq1:
        x2 = x1
        x1 = [0 for i in range(b+1)]
        j=0
        for j in range(b):
            if e1 == seq2[j]:
                x1[j+1]=x2[j] + 1
            else:
                x1[j+1]=max(x2[j+1], x1[j])
        i += 1
    return x1[-1]

n = input()
for i2 in range(n):

    print longestcommonsubsequence()

### FIXED CODE ###

import sys

def longestcommonsubsequence():
    seq1 = raw_input()
    seq2 = raw_input()

    a, b = len(seq1), len(seq2)
    x1 = [0 for i in range(b+1)]
    for i in range(a):
        e1 = seq1[i]
        x2 = x1+[]
        #x1 = [0 for i2 in range(b+1)]
        for j in range(b):
            if e1 == seq2[j]:
                x1[j+1] = x2[j] + 1
            elif x1[j+1]<x1[j]:
                x1[j+1] = x1[j]
    return x1[-1]

n = input()
for i2 in range(n):

    print longestcommonsubsequence()
### BUGGY CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
Alist = []
setA = [x for x in set(a)]
for i in setA:
  Alist.append(a.count(i))
Alist.sort()
ans = 0
for i in range(len(Alist) - k):
  ans += Alist[i]
print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
p =  [0] * (n + 1)
for i in a:
  p[i] += 1
p.sort()
print(sum(p[:n-k+1]))
### BUGGY CODE ###

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

saeki = []

for i in range(len(a)-1):
    hikaku = a[i]
    m = max(a[i+1:])
    s = m - hikaku
    if s > 0:
        saeki.append(s)
    else:
        saeki.append(0)

saidaisaeki = max(saeki)
ans = saeki.count(saidaisaeki)
print(ans)

### FIXED CODE ###

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

ma = a[-1]
m = 1
maxsaeki = 0
ans = 0

for i in range(n-2,-1,-1):
    if a[i] > ma:
        ma = a[i]
        m = 1
    elif a[i] < ma:
        if (ma - a[i]) > maxsaeki:
            maxsaeki = ma-a[i]
            ans = 1
        elif (ma - a[i]) == maxsaeki:
            ans += 1

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

def IN(): return map(int,input().split())
h,n=IN()
A=[]; dp=[pow(2,31)]*(h+10)
for i in range(n):
  x,y=IN()
  A.append((x,y))
dp[0]=0
for a,b in A:
  for i in range(h):
    index=min(h,i+a)
    dp[index]=min(dp[index],dp[i]+b)
print(dp[h])

### FIXED CODE ###

def IN(): return map(int,input().split())
ans = pow(2,31); mod = pow(10,9)+7
h,n=IN()
A=[]; dp=[pow(2,31)]*111111
for i in range(n):
  x,y=IN()
  A.append((x,y))
dp[0]=0
for a,b in A:
  for i in range(h+1111):
    dp[i+a]=min(dp[i+a],dp[i]+b)
for i in range(h,11111):
  ans=min(ans,dp[i])
print(ans)
### BUGGY CODE ###

h,s,q=map(int,input().split())
l=[int(input()) for i in range(q)]
g=[s-q+l.count(i) for i in range(h+1)[1:]]
for d in range(h):
  print("Yes") if g[d]>0 else print("No")

### FIXED CODE ###

from collections import Counter as co
h,s,q=map(int,input().split())
l=co([int(input()) for e in range(q)])
for i in range(h+1)[1:]:
  print("Yes") if s-q+l[i]>0 else print("No")
### BUGGY CODE ###

N = int(input())
str_lis = []
max_str_lis = []
max_num = 1
for i in range(N):
  A = str(input())
  str_lis.append(A)
  times = str_lis.count(A)
  if times > max_num:
    max_str_lis = []
    max_str_lis.append(A)
    max_num = times
  if times == max_num and not A in max_str_lis:
    max_str_lis.append(A)

new_max_str_lis = sorted(max_str_lis)
for i in new_max_str_lis:
  print(i)

### FIXED CODE ###

from collections import Counter

N = int(input())

str_lis = [str(input()) for i in range(N)]
c = Counter(str_lis)
a = c.most_common()
num = a[0][1]
b = []
for i in a:
  if i[1] == num:
    b.append(i[0])
    num = i[1]
  else:
    break
    
new_b = sorted(b)
for i in new_b:
  print(i)
### BUGGY CODE ###

import math
import sys

m=10**9 + 7 
sys.setrecursionlimit(1000010)
S = input()
Q = int(input())
inv = 0
head=''
tail=''
for _ in range(Q):
    q = input()
    if q == '1':
        inv = 1 - inv
    else:
        (T,F,C) = list(q.split())
        #print(T,F,C)
        if inv == 0:
            if F == '1':
                head += C
            else:
                tail += C
        else:
            if F == '1':
                tail +=C
            else:
                head +=C
    # print(head,S,tail)
k = ''.join(list(reversed(head))) + S + tail
if inv == 0:
    print(k)
else:
    print(''.join(list(reversed(k))))
    


### FIXED CODE ###

import math
import sys

m=10**9 + 7 
sys.setrecursionlimit(1000010)
S = input()
Q = int(input())

inv = 0
head=[]
tail=[]
for _ in range(Q):
    q = input()
    if q == '1':
        inv = 1 - inv
    else:
        (T,F,C) = list(q.split())
        #print(T,F,C)
        if inv == 0:
            if F == '1':
                head.append(C)
            else:
                tail.append(C)
        else:
            if F == '1':
                tail.append(C)
            else:
                head.append(C)
    # print(head,S,tail)

if inv == 0:
    print(''.join(list(reversed(head))) + S + ''.join(tail))
else:
    print(''.join(list(reversed(tail))) + ''.join(list(reversed(S))) + ''.join(head))
### BUGGY CODE ###

n,m = map(int,input().split())
ps_lst = [list(map(str,input().split())) for _ in range(m)]
ac_count = 0
wa_count = 0


ps_dic = {}
for i in range(m):
    number = ps_lst[i][0]
    tmp_dic = {number:'WA'}
    ps_dic.update(tmp_dic)

wa_dic = {}
for i in range(m):
    number = ps_lst[i][0]
    tmp_dic = {number:0}
    wa_dic.update(tmp_dic)

for i in range(m):
    number = ps_lst[i][0]
    answer = ps_lst[i][1]

    if answer=='AC' and ps_dic[number]=='WA':
        ac_count += 1
        tmp_dic = {number:'AC'}
        ps_dic.update(tmp_dic)
    elif answer=='WA' and ps_dic[number]=='WA':
        wa_dic[number] += 1

for i in range(len(ps_dic)):
    pslst = list(ps_dic.items())
    walst = list(wa_dic.items())
    if pslst[i][1]=='AC':
        wa_count += walst[i][1]

print('{} {}'.format(ac_count, wa_count))

### FIXED CODE ###

def main():
    n, m = map(int, input().split())
    ps_lst = [list(map(str, input().split())) for _ in range(m)]
    judge_lst = [0] * n
    penalty_lst = [0] * n
    correct = 0
    penalty = 0

    for i in range(m):
        problem = int(ps_lst[i][0]) - 1
        result = ps_lst[i][1]
        
        if judge_lst[problem] == 0:
            if result == 'AC':
                judge_lst[problem] = 1
            else:
                penalty_lst[problem] += 1

    for i in range(n):
        if judge_lst[i] == 1:
            correct += 1
            penalty += penalty_lst[i]
            
    print(correct, penalty)


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

A=int(input())
n_l=list(map(int,input().split()))
n_l.sort()
n_l_s=[]
for i in range(A-1):
   n_l_s.append(n_l[i+1]-n_l[i])
ans=1
for i in range(A-1):
   c=0
   n=0
   for j in range(i,A-1):
      c+=n_l_s[j]
      if c < 3:
         n+=1
      else:
         ans=max(ans,n+1)
         break
print(ans)

### FIXED CODE ###

A=int(input())
n_l=list(map(int,input().split()))
import collections
ans=0
n_l=collections.Counter(n_l)
for i in range(0,100001):
   ans=max(ans,n_l[i]+n_l[i+1]+n_l[i+2])
print(ans)
### BUGGY CODE ###

import bisect
import sys
import math
from heapq import heappush, heappop

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))


def main():
    N,K = isRaw()
    As = isRaw()
    for k in range(K):
        #nAs = [0]*N
        dh = []
        for aidx,a in enumerate(As):
            heappush(dh, (max(0, aidx-a),1))
            heappush(dh, (min(aidx+a+1, N),-1))
        d = 0
        for x in range(N):
            while x ==dh[0][0]:
                c, q = heappop(dh)
                d+=q
            As[x] = d

        
        if sum(As) == N*N:
            break
        
    print(" ".join([str(a) for a in As]))


main()


### FIXED CODE ###

import bisect
import sys
import math
from collections import deque
from heapq import heappush, heappop

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))


INF = 1 << 29

DIV = (10**9) + 7


def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac = fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV

    return CONV()


def cumsum(As):
    s = 0
    for a in As:
        s += a
        yield s


sys.setrecursionlimit(200005)


def dijkstra(G,start=0):
    heap = []
    cost = [INF]*len(G)
    heappush(heap,(0,start))
    while len(heap)!=0:
        c,n = heappop(heap)
        if cost[n] !=INF:
            continue
        cost[n]=c
        for e in G[n]:
            ec,v = e
            if cost[v]!=INF:
                continue
            heappush(heap,(ec+c,v))
    return cost


def main():
    N,K = isRaw()
    As = isRaw()
    for k in range(K):
        nAs = [0]*(N+1)
        for aidx,a in enumerate(As):
            nAs[max(0, aidx-a)]+=1
            nAs[min(aidx+a+1,N)]-=1
        for aidx in range(1,N):
            nAs[aidx] += nAs[aidx-1]
        As = nAs[:N]
        if sum(As) == N*N:
            break
        
    print(" ".join([str(a) for a in As]))




main()
### BUGGY CODE ###

N = int(input())
cnt = []
name = []
ans = []

for i in range(N):
    S = str(input())
    if S not in name:
        name.append(S)
        cnt.append(1)
    else:
        cnt[name.index(S)] += 1

for j in range(len(cnt)):
    if cnt[j] == max(cnt):
        ans.append(name[j])

ans = sorted(ans)
for x in range(len(ans)):
    print(ans[x])


### FIXED CODE ###

n = int(input())
s = [input() for _ in range(n)]
d = {}

for i in s:
    d[i] = d.get(i, 0) + 1

d = sorted(d.items(), key=lambda x: x[1], reverse=True)
maxv = d[0][1]
ans = []
for s in d:
    if s[1] == maxv:
        ans.append(s[0])
    else:
        break

for p in sorted(ans):
    print(p)
### BUGGY CODE ###

X = int(input())
if X==1:
    print(0,-1) 
else:
    d = 2
    while(X%d!=0):
        d+=1
    b = -(10)
    a = b+d
    while(X!=((a**5)-(b**5))):
        b+=1
        a+=1
    print(a,b)

### FIXED CODE ###

X = int(input())

A = range(-118,120)
B = range(-118,120)
flag = 0
for a in A:
  for b in B:
    ans = a**5 - b**5
    if ans == X:
      print("{} {}".format(a,b))
      flag=1
      break
  if flag:
    break
### BUGGY CODE ###

n, k = map(int, input().split())
l = [int(x) for x in input().split()]

x = 1
for i in range(k):
    x *= l[i]

xx = x
for i in range(n-k):
    xx *= l[i+k] / l[i]
    if xx > x:
        print("Yes")
    else:
        print("No")
    x = xx


### FIXED CODE ###

n, k = map(int, input().split())
l = [int(x) for x in input().split()]

for i in range(n-k):
    if l[i] < l[k+i]:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

def fun(f,i,sw):
    ret=[]
    for s in sw:
        ii,ss=min(i,s),max(i,s)
        ret.append( f[:ii]+f[ss]+f[ii+1:ss]+f[ii]+f[ss+1:])
    return ret

swaplist=[[1,4],[0,2,5],[1,3,6],[2,7],[0,5],[4,6,1],[5,7,2],[6,3]]
A={}
A[1234567]=0
ks=[1234567]
F=["01234567"]
n=0
while len(F)!=0:
    NF=[]
    n+=1
    for f in F:
        i=f.index('0')
        sw=swaplist[i]
        for g in fun(f,i,sw):
            if int(g) not in ks:
                A[int(g)]=n
                ks.append(int(g))
                NF.append(g)
    F=NF[:]
while(1):
    try:
        print A[int("".join(raw_input().split()))]
    except:
        break

### FIXED CODE ###

import bisect as bs

def fun(f,i,sw):
    ret=[]
    for s in sw:
        ii,ss=min(i,s),max(i,s)
        ret.append( f[:ii]+f[ss]+f[ii+1:ss]+f[ii]+f[ss+1:])
    return ret

def exist(a, x):
    'Locate the leftmost value exactly equal to x'
    i = bs.bisect_left(a, x)
    try:
        if i != len(a) and a[i] == x:
            return 1
    except:
        return 0

swaplist=[[1,4],[0,2,5],[1,3,6],[2,7],[0,5],[4,6,1],[5,7,2],[6,3]]
A={}
A[1234567]=0
ks=[1234567]
F=["01234567"]
n=0
while len(F)!=0:
    NF=[]
    n+=1
    for f in F:
        i=f.index('0')
        sw=swaplist[i]
        for g in fun(f,i,sw):
            ig=int(g)
            if not exist(ks,ig):
                A[ig]=n
                bs.insort(ks,ig)
                NF.append(g)
    F=NF[:]
while(1):
    try:
        print A[int("".join(raw_input().split()))]
    except:
        break
### BUGGY CODE ###

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)


k=int(input())
c=0

for i in range(1,k+1):
  for j in range(1,k+1):
    for k in range(1,k+1):
#      print(i,j,k,gcd(i,j,k))
      c+=gcd(i,j,k)
print(c)


### FIXED CODE ###

import math
k=int(input())
c=0

for i in range(1,k+1):
  for j in range(1,k+1):
    w=math.gcd(i,j)
    for k in range(1,k+1):
      c+=math.gcd(w,k)
print(c)
### BUGGY CODE ###

N,A = map(int,input().split())
*X, = map(int,input().split())
dp=[[[0]*2510 for _ in [0]*(N+10)] for _ in [0]*(N+10)]
for n in range(0,N+1):dp[n][0][0] = 1
for n in range(1,N+1):
    x = X[n-1]
    for k in range(1,n+1):
        for s in range(2501):
            dp[n][k][s] = dp[n-1][k][s]
            if s>=x:
                dp[n][k][s] += dp[n-1][k-1][s-x]
print(sum(dp[N][k][k*A] for k in range(1,N+1)))

### FIXED CODE ###

N,A = map(int,input().split())
*X, = map(int,input().split())
dp=[[[0]*2510 for _ in [0]*(N+10)] for _ in [0]*(N+10)]
for n in range(0,N+1):dp[n][0][0] = 1
for n in range(1,N+1):
    x = X[n-1]
    for k in range(1,n+1):
        for s in range(2501):
            dp[n][k][s] = dp[n-1][k][s]
            if s>=x:
                dp[n][k][s] += dp[n-1][k-1][s-x]
print(sum(dp[N][k][k*A] for k in range(1,N+1)))
### BUGGY CODE ###


import math
import sys
n,q = list(map(int,input().split()))
s = input()
lll = [0 for _ in range(n)]
for i in range(n-1):
  if s[i] == "A" and s[i+1] == "C":
    lll[(i+1):] = [j+1 for j in lll[(i+1):]]
for i in range(q):
  l,r = list(map(int,input().split()))
  print(lll[r-1] - lll[l-1])

### FIXED CODE ###

n,q = list(map(int,input().split()))
s = input()
lll = [0 for _ in range(n)]
for i in range(n-1):
  if s[i] == "A" and s[i+1] == "C":
    lll[i+1] = lll[i] + 1
  else:
    lll[i+1] = lll[i]
for i in range(q):
  l,r = list(map(int,input().split()))
  print(lll[r-1] - lll[l-1])
### BUGGY CODE ###

s=input()
a=[0]
for i,j,k in zip(s[:-1],s[1:],range(1,len(s))):
  if i=="R" and j=="L":
    a.append(k)
  else:
    a.append(a[-1])

b=[len(s)-1]
for i,j,k in zip(s[-2::-1],s[:0:-1],range(len(s)-2,-1,-1)):
  if i=="R" and j=="L":
    b=[k]+b
  else:
    b=[b[0]]+b
c=[0]*len(s)
for i,j in enumerate(s):
  if j=="R":
    c[(b[i]-i)%2+b[i]]+=1
  else:
    c[a[i]-(i-a[i])%2]+=1
print(" ".join([str(i) for i in c]))

### FIXED CODE ###

s=input()
a=[0]
for i,j,k in zip(s[:-1],s[1:],range(1,len(s))):
  if i=="R" and j=="L":
    a.append(k)
  else:
    a.append(a[-1])

b=[len(s)-1]*len(s)
for i,j,k in zip(s[-2::-1],s[:0:-1],range(len(s)-2,-1,-1)):
  if i=="R" and j=="L":
    b[k]=k
  else:
    b[k]=b[k+1]
c=[0]*len(s)
for i,j in enumerate(s):
  if j=="R":
    c[(b[i]-i)%2+b[i]]+=1
  else:
    c[a[i]-(i-a[i])%2]+=1
print(" ".join([str(i) for i in c]))
### BUGGY CODE ###

import numpy as np
def main():
    A, B, N = map(int, input().split())
    max_value = 0
    max_int = B
    if N < B:
        max_int = N
    for x in range(max_int+1):
        value = np.floor(A*x/B) - A * np.floor(x/B)
        #print(x, value)
        if value > max_value:
            max_value = value
    print(int(max_value))
    
if __name__ == '__main__':
    main()

### FIXED CODE ###

import numpy as np
def main():
    A, B, N = map(int, input().split())
    max_value = 0
    x = np.min([B-1, N])
    max_value = int(np.floor(A*x/B))
    print(max_value)
    
if __name__ == '__main__':
    main()
### BUGGY CODE ###

import itertools
n=int(input())
A=list(map(int,input().split()))
AC=list(itertools.combinations(A,2))
for i in range(len(AC)):
  AC[i]=AC[i][0]*AC[i][1]%(10**9+7)
print(sum(AC)%(10**9+7))

### FIXED CODE ###

n=int(input())
A=list(map(int,input().split()))
sumA=sum(A)
x=0
for i in range(n-1):
  sumA-=A[i]
  x+=A[i]*sumA
print(x%(10**9+7))
### BUGGY CODE ###

i = input()
N = int(i)
A = []
for x in range(N):
    j = input()
    A.append(int(j))

for x in range(N):
    #print(x)
    t = A[:x] + A[x:]
    t.remove(A[x])
    print(max(t))


### FIXED CODE ###

import numpy as np

i = input()
N = int(i)
A = np.array([0]*N)
i = input()
a = int(i)
A[0] = a
i = input()
b = int(i)
A[1] = b
snd = min(a, b)
fst = max(a, b)
for x in range(N - 2):
    j = input()
    y = int(j)
    A[x+2] = y
    if y <= fst:
        snd = max(snd, y)
    fst = max(fst, y)

for x in range(N):
    if A[x] < fst:
        print(fst)
    else:
        print(snd)