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

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
xtoy = {}
ytox = {}
for x, y in xy:
    if x not in xtoy:
        xtoy[x] = []
    xtoy[x].append(y)
    if y not in ytox:
        ytox[y] = []
    ytox[y].append(x)
ret = 0
while len(xtoy) > 0:
    q = [(next(iter(xtoy)), None)]
    xs = set()
    ys = set()
    while len(q) > 0:
        (x, y) = q.pop(0)
        if x is not None and x not in xs:
            xs.add(x)
            for y in xtoy.pop(x):
                q.append((None, y))
        if y is not None and y not in ys:
            ys.add(y)
            for x in ytox.pop(y):
                q.append((x, None))
    ret += len(xs) * len(ys)
print(ret - n)


### FIXED CODE ###

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
xtoy = {}
ytox = {}
for x, y in xy:
    if x not in xtoy:
        xtoy[x] = []
    xtoy[x].append(y)
    if y not in ytox:
        ytox[y] = []
    ytox[y].append(x)
ret = 0
while len(xtoy) > 0:
    x = next(iter(xtoy))
    xs = set()
    ys = set()
    xs.add(x)
    q = [(x, None)]
    while len(q) > 0:
        (xx, yy) = q.pop(0)
        if xx is not None:
            for y in xtoy.pop(xx):
                if y not in ys:
                    ys.add(y)
                    q.append((None, y))
        if yy is not None:
            for x in ytox.pop(yy):
                if x not in xs:
                    xs.add(x)
                    q.append((x, None))
    ret += len(xs) * len(ys)
print(ret - n)
### BUGGY CODE ###

import math 

mysum = 0
K = int(input())
for i in range(1,K+1):
	for j in range(1,K+1):
		for k in range(1,K+1):
			mysum += math.gcd(math.gcd(i,j),k)

print(mysum)

### FIXED CODE ###

from math import gcd 

mysum = 0
K = int(input())
for i in range(1,K+1):
	for j in range(1,K+1):
		for k in range(1,K+1):
			mysum += gcd(gcd(i,j),k)

print(mysum)
### BUGGY CODE ###

def main():
    import sys
    input = sys.stdin.buffer.readline
    sys.setrecursionlimit(1000000)
    N = int(input())
    edge = [[] for _ in range(N)]
    for i in range(N-1):
        a, b, c = (int(i) for i in input().split())
        edge[a-1].append((c, b-1))
        edge[b-1].append((c, a-1))

    dist = [-1]*N
    color = [-1]*N

    def dfs(v, G):
        todo = []
        dist[v] = 0
        color[v] = 0
        todo.append(v)
        while todo:
            u = todo[-1]
            for c, next_v in G[u]:
                if dist[next_v] != -1:
                    continue
                dist[next_v] = dist[u] + c
                if dist[next_v] % 2 == 1:
                    color[next_v] = 1
                else:
                    color[next_v] = 0
                todo.append(next_v)
                break
            else:
                todo.pop()

    dfs(0, edge)
    print(*color, sep="\n")
    # print("\n", *dist, sep="\n")


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    import sys
    from collections import deque
    input = sys.stdin.buffer.readline
    N = int(input())
    edge = [[] for _ in range(N)]
    for i in range(N-1):
        a, b, c = (int(i) for i in input().split())
        edge[a-1].append((c, b-1))
        edge[b-1].append((c, a-1))

    dist = [-1]*N
    color = [-1]*N

    def dfs(v, G):
        todo = deque()
        dist[v] = 0
        color[v] = 0
        todo.append(v)
        while todo:
            u = todo.pop()
            for c, next_v in G[u]:
                if dist[next_v] != -1:
                    continue
                dist[next_v] = dist[u] + c
                if dist[next_v] % 2 == 1:
                    color[next_v] = 1
                else:
                    color[next_v] = 0
                todo.append(next_v)

    dfs(0, edge)
    print(*color, sep="\n")
    # print("\n", *dist, sep="\n")


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

N, M = map(int, input().split())
adjL = [[] for v in range(N)]
indegs = [0] * N
for _ in range(N+M-1):
    u, v = map(int, input().split())
    adjL[u-1].append(v-1)
    indegs[v-1] += 1

parents = [-1] * N
vRoot = [v for v in range(N) if indegs[v] == 0][0]
vNows = set([vRoot])
for _ in range(N+M):
    vNexts = set()
    for vNow in vNows:
        for v2 in adjL[vNow]:
            parents[v2] = vNow
            vNexts.add(v2)
    vNows = vNexts

for v in range(N):
    print(parents[v] + 1)


### FIXED CODE ###

from collections import deque

N, M = map(int, input().split())
adjL = [[] for v in range(N)]
indegs = [0] * N
for _ in range(N+M-1):
    u, v = map(int, input().split())
    adjL[u-1].append(v-1)
    indegs[v-1] += 1

parents = [-1] * N
Q = deque([v for v in range(N) if indegs[v] == 0])
while Q:
    vNow = Q.popleft()
    for v2 in adjL[vNow]:
        parents[v2] = vNow
        indegs[v2] -= 1
        if indegs[v2] == 0:
            Q.append(v2)

for v in range(N):
    print(parents[v] + 1)
### BUGGY CODE ###

N=int(input())
P=list(map(int,input().split()))
A=[]
ans=0
for i in P:
    A.append(i)
    if min(A)==i:
        ans+=1
print(ans)

### FIXED CODE ###

N=int(input())
P=list(map(int,input().split()))
A=10**100
ans=0
for i in P:
    A=min(A,i)
    if A==i:
        ans+=1
print(ans)
### BUGGY CODE ###

import fractions
def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
gcd=lcm(a)
res = 0
for i in range(n):
    res += gcd//a[i]
    res%=mod
print(res)



### FIXED CODE ###


from fractions import gcd


n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
x = a[0]
for i in range(1, len(a)):
    x = (x * a[i]) // gcd(x, a[i])
gcd=x
res = 0
for i in a:
    res += gcd//i
    #res%=mod
print(res%mod)
### BUGGY CODE ###

from collections import deque

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

# まずスタートの点数
p_pre = 1
for item in a[:k]:
    p_pre *= item

# n-k回やる
for i in range(n-k):
    # iこ目をなくしてk+iこめをふやす
    p_next = ((p_pre / a[i]) * a[k+i])
    if p_next > p_pre:
        print("Yes")
    else:
        print("No")

    p_pre = p_next


### FIXED CODE ###

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

# n-k回やる
for i in range(n-k):
    # iこ目をなくしてk+iこめをふやす
    if a[k+i] > a[i]:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

N = int(input())
H = [int(x) for x in input().split()]

ans = 0
for i in range(N):
    current = 0
    if(N-i < ans):
        break
    
    while(True):
        if(i==N-1):
            break
        elif(H[i] >= H[i+1]):
                current += 1
                i += 1
        else:
            break

    if(current > ans):
        ans = current

print(ans)



### FIXED CODE ###

N = int(input())
H = [int(x) for x in input().split()]
 
ans = 0
current = 0
for i in range(N):
    if(i == N-1):
        if(current > ans):
            ans = current
        break
    if(H[i] >= H[i+1]):
        current += 1
    else:
        if(ans < current):
            ans = current
        current = 0
 
print(ans)
### BUGGY CODE ###

from collections import deque

S = deque(list(str(input())))
Q = int(input())
flag = False

for i in range(Q):
    Query =  [str(p) for p in input().split()]
    if(int(Query[0]) == 1):
        flag = not(flag)
    else:
        if(int(Query[1]) == 1):
            if(flag):
                S.reverse()
                flag = not(flag)
            S.appendleft(Query[2])
        else:
            if(flag):
                S.reverse()
                flag = not(flag)
            S.append(Query[2])

if(flag):
    S.reverse()

print("".join(list(S)))

### FIXED CODE ###

from collections import deque

S = deque(list(str(input())))
Q = int(input())
flag = False

for i in range(Q):
    Query =  [str(p) for p in input().split()]
    if(int(Query[0]) == 1):
        flag = not(flag)
    else:
        if(int(Query[1]) == 1):
            if(flag):
                S.append(Query[2])
            else:
                S.appendleft(Query[2])
        else:
            if(flag):
                S.appendleft(Query[2])
            else:
                S.append(Query[2])

if(flag):
    S.reverse()

print("".join(list(S)))
### BUGGY CODE ###


N = int(input())

L = list(map(int, input().split()))
L.sort()

L_count = [0] * (max(L)+1)

ans = 0

for i in range(N):
    L_count[L[i]] += 1

for i in range(N-1):
    for j in reversed(range(i + 2, N)):
        for k in range(i + 1, j):
            if L[j] - L[i] < L[k] and L[k] < L[j] + L[i]:
                ans += 1
        # print(i, j)

print(ans)

### FIXED CODE ###

from bisect import bisect_left

N = int(input())

L = list(map(int, input().split()))
L.sort()

ans = 0


for i in range(N):
    for j in range(i + 1, N):
        c = L[i] + L[j]
        # a+bが入る場所を返す
        idx = bisect_left(L, c)
        ans += max(0, idx - (j + 1))

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

from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
s = input()

r = s.count('R')
g = s.count('G')
b = n - r - g
ans = comb(n, 3) - ( comb(r, 2) + comb(g, 2) + comb(b, 2) ) * (n-2) + ( comb(r, 3) + comb(g, 3) + comb(b, 3) ) * 2
for i in range(n):
    d = 1
    j = i + d
    k = j + d
    while k < n:
        t = s[i] + s[j] + s[k]
        if t.count('R') == t.count('G') == 1:
            ans -= 1
        d += 1
        j = i + d
        k = j + d
print(ans)

### FIXED CODE ###

from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
s = input()

r = s.count('R')
g = s.count('G')
b = n - r - g
ans = comb(n, 3) - ( comb(r, 2) + comb(g, 2) + comb(b, 2) ) * (n-2) + ( comb(r, 3) + comb(g, 3) + comb(b, 3) ) * 2
for i in range(n):
    d = 1
    j = i + d
    k = j + d
    while k < n:
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            ans -= 1
        d += 1
        j += 1
        k += 2
print(ans)
### BUGGY CODE ###

n = int(input())
T = []
for _ in range(n):
    a, b = list(map(int, input().split()))
    T.append((a, b))
T = sorted(T, key=lambda x: x[1])[::-1]
d = [0] * n
d[0] = T[-1][0]
for i in range(n-1):
    d[i + 1] = d[i] + T[::-1][i + 1][0]
d = d[::-1]

f = 0
for i, (a, b) in enumerate(T):
    if b < d[i]:
        f = 1
        break
if f == 0:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

n = int(input())
T = []
s = 0
for _ in range(n):
    a, b = list(map(int, input().split()))
    T.append((a, b))
    s += a
T = sorted(T, key=lambda x: x[1])[::-1]
f = 0
for i, (a, b) in enumerate(T):
    if b < s:
        f = 1
        break
    s -= a
if f == 0:
    print('Yes')
else:
    print('No')
### BUGGY CODE ###

n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort(reverse=True)
hi = -1
lo = n
while lo-hi>1:
  mid = (lo+hi)//2
  if a[mid] >= k:
    hi = mid
  else:
    lo = mid
ng = hi
ok = n
while ok-ng > 1:
  mid = (ok+ng)//2
  dp = [False]*(k+1)
  dp[0] = True
  for j in range(n):
    if j == mid:
      continue
    w = a[j]
    for i in range(k,w-1,-1):
      dp[i] |= dp[i-w]
  if any(dp[k-a[mid]:k]):
    ng = mid
  else:
    ok = mid
print(n-ok)


### FIXED CODE ###

n, k = map(int,input().split())
a = [k+1 if x > k else x for x in map(int,input().split())]
a.sort()
lef = [1]*n
rig = [1]*n
mask = (1 << (k+1)) - 1
for i in range(n-1):
  lef[i+1] = lef[i] | (lef[i] << a[i]) & mask
  rig[-i-2] = rig[-i-1] | (rig[-i-1] << a[-i-1]) & mask
ok = -1
ng = n
while ng - ok > 1:
  mid = (ng + ok) // 2
  if a[mid] >= k:
      ng = mid
      continue
  lc = lef[mid]
  rc = rig[mid]
  cov = ((1 << k) - 1) ^ ((1 << (k - a[mid])) - 1)
  for i in range(k):
    if lc & 1 and rc & cov:
      ng = mid
      break
    lc >>= 1
    cov >>= 1
  else:
    ok = mid
print(ok + 1)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

H,W = map(int,input().split())
INF = 10**18
q = []

visited = [[True]*(W+2)]
visited += [[True] + [x == '#' for x in input().rstrip()] + [True] for _ in range(H)]
visited.append([True]*(W+2))
for i in range(1,H+1):
  for j in range(1,W+1):
    if visited[i][j]:
      q.append((i,j))

ans = -1
while q:
  qq = []
  ans += 1
  for x,y in q:
    if not visited[x-1][y]:
      visited[x-1][y] = True
      qq.append((x-1,y))
    if not visited[x+1][y]:
      visited[x+1][y] = True
      qq.append((x+1,y))
    if not visited[x][y-1]:
      visited[x][y-1] = True
      qq.append((x,y-1))
    if not visited[x][y+1]:
      visited[x][y+1] = True
      qq.append((x,y+1))
  q = qq
  
print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

H,W = map(int,input().split())
INF = 10**18
q = []

visited = [[True]*(W+2)]
visited += [[True] + [x == '#' for x in input().rstrip()] + [True] for _ in range(H)]
visited.append([True]*(W+2))
for i in range(1,H+1):
  for j in range(1,W+1):
    if visited[i][j]:
      q.append((i,j))

moves = [(0,1),(0,-1),(1,0),(-1,0)] #全方向調べる

ans = -1
while q:
  qq = []
  ans += 1
  for x,y in q:
    if not visited[x-1][y]:
      visited[x-1][y] = True
      qq.append((x-1,y))
    if not visited[x+1][y]:
      visited[x+1][y] = True
      qq.append((x+1,y))
    if not visited[x][y-1]:
      visited[x][y-1] = True
      qq.append((x,y-1))
    if not visited[x][y+1]:
      visited[x][y+1] = True
      qq.append((x,y+1))
  q = qq
  
print(ans)
### BUGGY CODE ###

N,A = map(int,input().split())
X = list(map(int,input().split()))
ans = 0
for i in range(1,2**N):
    state = format(i,'0%ib'%(N))
    value = 0
    count = 0
    for j,s in enumerate(state):
        if s == '1':
            value += X[j]
            count += 1
    if value == A*count:
        ans += 1
print(ans)

### FIXED CODE ###

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

def make_array(dims,fill):
    if len(dims) == 1:
        return [fill]*dims[0]
    ret = []
    nxt = dims[1:]
    for i in range(dims[0]):
        ret.append(make_array(nxt,fill))
    return ret
S = sum(X)+1
dp = make_array([N+2,N+2,S],0)
dp[0][0][0] = 1
for i in range(N):
    for j in range(N):
        for s in range(S-X[i]):
            dp[i+1][j+1][s+X[i]] += dp[i][j][s]
            dp[i+1][j][s] += dp[i][j][s]
ans = 0
for j in range(1,N+1):
    for s in range(1,S+1):
        if j*A == s:
            ans += dp[-2][j][s]
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import numpy as np

n, k = map(int, input().split())
p = list(map(int, input().split()))
np_p = np.array(p)

#sumを呼び出す
def my_sum(i, k):
    return ((np_p[i:i+k]+1)/2).sum()

def main3():
    ans = 0
    for i in range(n-k+1):
        ans = max(ans, my_sum(i, k))
    print(ans)

main3()

### FIXED CODE ###

# -*- coding: utf-8 -*-
 
n, k = map(int, input().split())
p = list(map(int, input().split()))

summation = 0
exp_val = []
for i in range(n):
    summation += (p[i]+1)/2
    exp_val.append(summation)
exp_val.insert(0, 0)
#print(exp_val)

ans = 0
for i in range(n-k+1):
    m = exp_val[k+i] - exp_val[i]
    ans = max(ans, m)

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

N = int(input())
output_list = []

def gcd(a, b, c):
  ret_gcd = 0
  mini = min([a,b,c])
  for i in range(mini, 0, -1):
    if a % i == 0 and b % i == 0 and c % i == 0:
      ret_gcd = i
      break
  return ret_gcd

for a in range(1, N+1):
  for b in range(1, N+1):
    for c in range(1, N+1):
      output_list.append(gcd(a, b, c))

print(sum(output_list))
  

### FIXED CODE ###

K = int(input())

def gcp(a, b):
  while b % a != 0:
    mod = b % a
    b = a
    a = mod
  return a

ans = 0

for a in range(1, K+1):
  for b in range(1, K+1):
    r = gcp(a, b)
    for c in range(1, K+1):
      ans += gcp(r, c)
      
print(ans)
### BUGGY CODE ###

n = int(input())
C = []
S = []
F = []

for _ in range(n-1):
    c,s,f = map(int,input().split())
    C.append(c)
    S.append(s)
    F.append(f)

for i in range(n-1):
    time = 0
    while i != n-1:
        if i == 0:
            time += S[i]
        else:
            train = S[i]
            while time > train:
                train += F[i]
            time = train
        time += C[i]
        i += 1        
    print(time)

print(0)


### FIXED CODE ###

n = int(input())
C = []
S = []
F = []

for _ in range(n-1):
    c,s,f = map(int,input().split())
    C.append(c)
    S.append(s)
    F.append(f)

for i in range(n-1):
    time = 0
    while i != n-1:
        if i == 0:
            time += S[i]
        elif S[i] <= time and time%F[i] == 0:
            time += 0
        else:
            if time > S[i]:
                r = (time-S[i])//F[i]
                time = S[i] + F[i]*(r + 1)
            else:
                time = S[i]
        time += C[i]
        i += 1        
    print(time)

print(0)
### BUGGY CODE ###

#計算間に合わなかった泣

n = int(input())
l = list(str(input()) for _ in range(n))
d = [{} for _ in range(n)]

for m, a in enumerate(l):
    for p in range(10):
        d[m][a[p]] = a.count(a[p])
cnt = 0
dellist = lambda items, indexes: [item for index, item in enumerate(items) if index not in indexes]

for i in d:
    pp=[i==k for k in d]
    kk = [x for x, _ in enumerate(pp) if _]
    d = dellist(d, kk)
    cnt += (len(kk)-1)*len(kk)/2

print(int(cnt))


### FIXED CODE ###

N = int(input())
s = [input() for i in [0]*N]
words = {}
cnt = 0
for i in s:
    i = "".join(sorted(i))
    time = words.get(i,0)
    cnt += time
    words[i] = time + 1
print(cnt)
### BUGGY CODE ###

import heapq

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


def change(A, B, C):
    for i in range(B):
        tmp = heapq.heappop(A)
        if tmp < C:
            heapq.heappush(A, C)
        else:
            heapq.heappush(A, tmp)
            break


for i in range(M):
    B, C = map(int,input().split())
    change(A, B, C)

print(sum(A))

### FIXED CODE ###

import heapq

N, M = map(int,input().split())
A = list(map(int,input().split()))
heapq.heapify(A)
B = []
C = []
for i in range(M):
    tmp_B, tmp_C = map(int,input().split())
    B.append(tmp_B)
    C.append(tmp_C)

def change(A, B, C):
    for i in range(B):
        tmp = heapq.heappop(A)
        if tmp < C:
            heapq.heappush(A, C)
        else:
            heapq.heappush(A, tmp)
            break

ZIP = zip(C, B)

ZIP = reversed(sorted(ZIP))

C, B = zip(*ZIP)

for i in range(M):
    change(A, B[i], C[i])

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

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
n,k = map(int,input().split())
lis = list(map(int,input().split()))
lis.sort()
ans = 0
for i in range(n):
    if i >= k-1:
        ans += lis[i] * cmb(i,k-1)
    if n-i-1 >= k-1:
        ans -= lis[i] * cmb(n-i-1,k-1)
    ans %= 10 ** 9+7
print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル


n,k = map(int,input().split())
lis = list(map(int,input().split()))
lis.sort()
ans = 0
for i in range( 2, n + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
for i in range(n):
    if i >= k-1:
        ans += lis[i] * cmb(i,k-1,mod)
    if n-i-1 >= k-1:
        ans -= lis[i] * cmb(n-i-1,k-1,mod)
    ans %= 10 ** 9+7
print(ans)
### BUGGY CODE ###

s = list(input())
q = int(input())
c = 0
for _ in range(q):
    t = input()
    if t != "1":
        t = t.split()
        if t[1] == "1":
            if c % 2 == 0:
                s.insert(0, t[2])
            else:
                s.append(t[2])
        else:
            if c % 2 == 0:
                s.append(t[2])
            else:
                s.insert(0, t[2])
    else:
        c += 1

if c % 2 == 1:
    s.reverse()
print("".join(s))

### FIXED CODE ###

s = list(input())
q = int(input())
c = 0
s1 = []
s2 = []
for _ in range(q):
    t = input()
    if t != "1":
        t = t.split()
        if t[1] == "1":
            if c % 2 == 0:
                s1.append(t[2])
            else:
                s2.append(t[2])
        else:
            if c % 2 == 0:
                s2.append(t[2])
            else:
                s1.append(t[2])
    else:
        c += 1

if c % 2 == 0:
    s1.reverse()
    s = s1 + s + s2
else:
    s2.reverse()
    s3 = s
    s3.reverse()
    s = s2 + s3 + s1
print("".join(s))
### BUGGY CODE ###

k, s = list(map(int, input().split()))

count = 0

for i in range(k + 1):
  for j in range(k + 1):
    for l in range(k + 1):
      if i + j + l > s:
        break

      if i + j + l == s:
        count+= 1

print(count)


### FIXED CODE ###

k, s = list(map(int, input().split()))

count = 0

for i in range(k + 1):
  for j in range(k + 1):
    if i + j > s:
      break

    if s - (i + j) > k:
      continue

    count+=1

print(count)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
count_dict = {}
total_sum = 0
for i in a:
    if i not in count_dict:
        count_dict[i] = a.count(i)
        total_sum += (a.count(i))*(a.count(i)-1)//2
for i in a:
    print(total_sum - (a.count(i)*(a.count(i)-1)//2) + (a.count(i)-1)*(a.count(i)-2)//2)

### FIXED CODE ###

import collections
n = int(input())
a = list(map(int, input().split()))
cnt = collections.Counter(a)
total = 0
for key in cnt.keys():
    total += cnt[key]*(cnt[key]-1) // 2
for i in a:
    ans = total
    ans -= cnt[i] * (cnt[i]-1) / 2
    ans += (cnt[i]-1) * (cnt[i]-2) / 2
    print(int(ans))
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n = int(input())
import collections
chk = collections.deque([])
for i in range(n):
  s = input()
  s = sorted(s)
  chk.append(''.join(s))
#chk = list(chk)
c = collections.Counter(chk)
ans = 0
for i in range(len(c)):
  if c.most_common()[i][1] == 1:
    break
  else:
    ans += c.most_common()[i][1]*(c.most_common()[i][1]-1)//2
print(ans)

### FIXED CODE ###

n = int(input())
import collections
chk = collections.deque([])
for i in range(n):
  s = input()
  s = sorted(s)
  chk.append(''.join(s))
#chk = list(chk)
c = collections.Counter(chk)
c = dict(c)
ans = 0
for i in c.values():
  ans += i*(i-1)//2
print(ans)
### BUGGY CODE ###

a,b,x=map(int,input().split())
c=0
for i in range(a,b+1):
    if i%x==0:
        c+=1
print(c)

### FIXED CODE ###

a,b,x=map(int,input().split())
print(b//x-(a-1)//x)