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

from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools
import queue
from collections import deque
from fractions import Fraction

# 10進数表記でnのk進数を求めてlength分0埋め
def ternary (n, k, length):
    if n == 0:
        nums = ['0' for i in range(length)]
        nums = ''.join(nums)
        return nums
    nums = ''
    while n:
        n, r = divmod(n, k)
        nums += str(r)
    nums = nums[::-1]
    nums = nums.zfill(length)
    return nums


def main():
    num = int(input())
    data = list(map(int, input().split()))
    mod = 10 ** 9 + 7

    max_length = 61
    bit_count = [0 for i in range(max_length)]

    for i in range(num):
        now_bin = ternary(data[i], 2, max_length)
        # print(now_bin)
        for j in range(max_length):
            if now_bin[j] == "1":
                bit_count[j] += 1


    ans = 0
    for i in range(num):
        now_bin = ternary(data[i], 2, max_length)
        for j in range(max_length):
            if now_bin[j] == "1":
                bit_count[j] -= 1
                ans += pow(2, max_length - 1 - j, mod) * (num - i - 1 - bit_count[j])
            else:
                ans += pow(2, max_length - 1 - j, mod) * bit_count[j]
            ans %= mod

    print(ans)




if __name__ == '__main__':
    main()



### FIXED CODE ###

from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools
import queue
from collections import deque
from fractions import Fraction

# 10進数表記でnのk進数を求めてlength分0埋め
def ternary (n, k, length):
    if n == 0:
        nums = ['0' for i in range(length)]
        nums = ''.join(nums)
        return nums
    nums = ''
    while n:
        n, r = divmod(n, k)
        nums += str(r)
    nums = nums[::-1]
    nums = nums.zfill(length)
    return nums


def main():
    num = int(input())
    data = list(map(int, input().split()))
    mod = 10 ** 9 + 7

    max_length = len(bin(max(data))) - 2
    bit_count = [0 for i in range(max_length)]

    for i in range(num):
        now_bin = bin(data[i])[2:]
        now_bin = now_bin.zfill(max_length)
        for j in range(max_length):
            if now_bin[j] == "1":
                bit_count[j] += 1

    flg_data = [0 for i in range(max_length)]


    for i in range(max_length):
        flg_data[i] += bit_count[i] * (num - bit_count[i])

    ans = 0
    for j in range(max_length):
        pow_num = max_length - 1 - j
        bbb = pow(2, pow_num, mod)

        ans += bbb * flg_data[j]
        ans %= mod

    print(ans)




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

from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,M,P = inpl()
lines = defaultdict(set)

for _ in range(M):
    a,b,c = inpl()
    a,b = a-1,b-1
    lines[a].add((b,-c+P))

#ベルマンフォード(始点と終点が決まってる時)
def BellmanFord(Start,Goal):
    Costs=[INF]*N
    Costs[Start] = 0
    upd8s = set(range(N))
    for i in range(2*N): #2N回ループ(負閉路の検出までみる)
        will_upd8s = set()
        for s in upd8s:
            for t,c in lines[s]:
                if c + Costs[s] < Costs[t]:
                    Costs[t] = Costs[s]+c
                    will_upd8s.add(t) #更新した点だけ次に見る
                    if i >= N:
                        Costs[t] = -INF

        if i == N-1: #Nループ目のGoalのCostを記録
            tmp = Costs[Goal]

        upd8s = copy.deepcopy(will_upd8s)

    if tmp != Costs[Goal]:
        return -INF
    else:
        return Costs[Goal]

ans = -BellmanFord(0,N-1)
if ans == INF:
    print(-1)
else:
    print(max(0,ans))


### FIXED CODE ###

from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,M,P = inpl()
lines = defaultdict(set)

for _ in range(M):
    a,b,c = inpl()
    a,b = a-1,b-1
    lines[a].add((b,-c+P))

#ベルマンフォード(始点と終点が決まってる時)
def BellmanFord(Start,Goal):
    Costs=[INF]*N
    Costs[Start] = 0
    upd8s = [True]*N
    for i in range(2*N): #2N回ループ(負閉路の検出までみる)
        will_upd8s = [False]*N
        for s in range(N):
            if not upd8s[s]: continue    #前回更新してないので見ない
            for t,c in lines[s]:
                if c + Costs[s] < Costs[t]:
                    Costs[t] = Costs[s]+c
                    will_upd8s[t] = True #更新した点だけ次に見る
                    if i >= N:
                        Costs[t] = -INF

        if i == N-1: #Nループ目のGoalのCostを記録
            tmp = Costs[Goal]

        upd8s = will_upd8s[:]

    if tmp != Costs[Goal]:
        return -INF
    else:
        return Costs[Goal]

ans = -BellmanFord(0,N-1)
if ans == INF:
    print(-1)
else:
    print(max(0,ans))
### BUGGY CODE ###

K,S = map(int,input().split())
count=0

for x in range(K+1):
    for y in range(K+1):
        for z in range(K+1):
            if x + y + z == S:
                count += 1

print(count)


### FIXED CODE ###

K,S = map(int,input().split())
count=0

for x in range(K+1):
    for y in range(K+1):
        if 0 <= S-x-y <= K:
            count += 1

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

import re
def MAIN():
    T = input()
    P = input()
    pat = re.compile(P)
    t = 0
    ans = []
    while True:
        t = pat.search(T, t)
        if t is None:
            break
        ans.append(t.span()[0])
        t = t.span()[0] + 1
    if ans:
        print(*ans, sep="\n")
MAIN()



### FIXED CODE ###

def kmpTable(w):
    lw = len(w)
    nx = [-1] * (lw + 1)
    j = -1
    for i in range(lw):
        while j >= 0 and w[i] != w[j]:
            j = nx[j]
        j += 1
        nx[i + 1] = j
    return tuple(nx)
def kmpSearch(s, w):
    ls = len(s)
    start = 0
    w_idx = 0
    ret = []
    nx = kmpTable(w)
    while start + w_idx < ls:
        if s[start + w_idx] == w[w_idx]:
            w_idx += 1
            if w_idx == len(w):
                ret.append(start)
                start = start + w_idx - nx[w_idx]
                w_idx = nx[w_idx]
        else:
            if w_idx == 0:
                start += 1
            else:
                start = start + w_idx - nx[w_idx]
                w_idx = nx[w_idx]
    return ret
T = input()
P = input()
ans = kmpSearch(T, P)

if ans:
    print(*ans, sep="\n")
#    print("\n".join(map(str, ans)))
### BUGGY CODE ###

from collections import Counter
class Combination:
    _maxNum = 0
    _divider = 0
    _fact = []
    _inv = []
    _finv = []

    def __init__(self, maxNum, divider):
        self._maxNum = maxNum
        self._divider = divider
        self._fact = [0] * (self._maxNum + 1)
        self._fact[0] = self._fact[1] = 1

        if self._divider != 0:
            self._inv = [0] * (self._maxNum + 1)
            self._finv = [0] * (self._maxNum + 1)
            self._inv[0] = self._inv[1] = self._finv[0] = self._finv[1] = 1

        for i in range(2, self._maxNum + 1):
            self._fact[i] = self._fact[i - 1] * i;
            if self._divider != 0:
                self._fact[i] %= self._divider
                self._inv[i] = self._divider - self._inv[self._divider % i] * (self._divider // i) % self._divider
                self._finv[i] = self._finv[i - 1] * self._inv[i] % self._divider

    def nPk(self, n, k):
        if(k > self._maxNum) or (n > self._maxNum) or (k > n) or (k < 0) or (n < 0):
            return 0
        return(self._fact[n] // self._fact[n - k])

    def nCk(self, n, k):
        ans = 0
        if(k > self._maxNum) or (n > self._maxNum) or (k > n) or (k < 0) or (n < 0):
            ans = 0
        elif self._divider == 0:
            ans = self.nPk(n, k)
            ans //= self._fact[k]
        else:
            ans = self._fact[n] * (self._finv[k] * self._finv[n - k] % self._divider) % self._divider

        return ans

def ABC137C_GreenBin():
    N = int(input().strip())
    S = [input().strip() for i in range(N)]

    di = Counter()
    for s in S:
        s = ''.join(sorted(list(s)))
        di[s] += 1
    
    cmb = Combination(N, 0)
    ans = 0
    for num in di.values():
        ans += cmb.nCk(num, 2)

    print(ans)


def main():
    ABC137C_GreenBin()

if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import Counter

def ABC137C_GreenBin():
    N = int(input().strip())
    S = [input().strip() for i in range(N)]

    ans = 0
    di = Counter()
    for s in S:
        s = ''.join(sorted(list(s)))
        
        if s in di:
            ans += di[s]

        di[s] += 1
    
    print(ans)


def main():
    ABC137C_GreenBin()

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

a = input().split()
k = int(a[0])
s = int(a[1])

count = 0

for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            if x + y + z == s:
                count = count + 1

print(count)

### FIXED CODE ###

a = input().split()
k = int(a[0])
s = int(a[1])

count = 0

for x in range(k + 1):
    if x > s:
        break
    for y in range(k + 1):
        if x + y > s:
            break
        else:
            if (k + 1) > (s - x - y):
                # print(x, y, (s - x - y))
                count = count + 1

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

# -*- coding: utf-8 -*-

N,M = list(map(int, input().rstrip().split()))
#-----

delta = [(-1,-1) , (0,-1), (1,-1),
         (-1, 0) , (0, 0), (1, 0),
         (-1, 1) , (0, 1), (1, 1)]


ans=0
for y in range(N):
    for x in range(M):
        
        check_cnt=0
        for d in delta:
            check_x = x + d[0]
            check_y = y + d[1]
            
            if 0 <= check_x <= (M-1) and 0 <= check_y <= (N-1):
                check_cnt += 1
        
        if check_cnt % 2 == 1:
            ans += 1

print(ans)


### FIXED CODE ###

# -*- coding: utf-8 -*-

N,M = list(map(int, input().rstrip().split()))
#-----

ans = abs(N-2) * abs(M-2)
print(ans)
### BUGGY CODE ###

class UF():
  def __init__(self, N):
    self._parent=[n for n in range(0, N)]
    self._size=[1] * N

  def find_root(self, x):
    if self._parent[x]==x:return x
    self._parent[x]=self.find_root(self._parent[x])
    return self._parent[x]

  def unite(self, x, y):
    gx=self.find_root(x)
    gy=self.find_root(y)
    if gx==gy:return

    if self._size[gx]<self._size[gy]:
      self._parent[gx]=gy
      self._size[gy]+=self._size[gx]
    else:
      self._parent[gy]=gx
      self._size[gx]+=self._size[gy]

  def size(self, x):
    return self._size[self.find_root(x)]

  def samegroup(self, x, y):
    return self.find_root(x)==self.find_root(y)

  def groupnum(self):
    N=len(self._parent)
    ans=0
    for i in range(N):
      if self.find_root(i)==i:
        ans+=1
    return ans

  def reset(self):
    self._parent=[n for n in range(0, n)]

n=int(input())
UF=UF(n)
l=[list(map(int,input().split())) for i in range(n)]
if n==1:
  print(1)
else:
  ans=[]
  for i in range(n):
    x1=l[i][0]
    y1=l[i][1]
    for j in range(n):
      if i!=j:
        x2=l[j][0]
        y2=l[j][1]
        p=x1-x2
        q=y1-y2
        for k1 in range(n):
          for k2 in range(n):
            if k1!=k2:
              if (l[k1][0]-p==l[k2][0] and l[k1][1]-q==l[k2][1]) or (l[k1][0]+p==l[k2][0] and l[k1][1]+q==l[k2][1]):
                UF.unite(k1,k2)
        ans.append(UF.groupnum())
        UF.reset()
  print(min(ans))

### FIXED CODE ###

class UF():
  def __init__(self, N):
    self._parent=[n for n in range(0, N)]
    self._size=[1] * N

  def find_root(self, x):
    if self._parent[x]==x:return x
    self._parent[x]=self.find_root(self._parent[x])
    return self._parent[x]

  def unite(self, x, y):
    gx=self.find_root(x)
    gy=self.find_root(y)
    if gx==gy:return

    if self._size[gx]<self._size[gy]:
      self._parent[gx]=gy
      self._size[gy]+=self._size[gx]
    else:
      self._parent[gy]=gx
      self._size[gx]+=self._size[gy]

  def size(self, x):
    return self._size[self.find_root(x)]

  def samegroup(self, x, y):
    return self.find_root(x)==self.find_root(y)

  def groupnum(self):
    N=len(self._parent)
    ans=0
    for i in range(N):
      if self.find_root(i)==i:
        ans+=1
    return ans

  def reset(self):
    self._parent=[n for n in range(0, n)]

n=int(input())
UF=UF(n)
l=[list(map(int,input().split())) for i in range(n)]
if n==1:
  print(1)
else:
  ans=[]
  for i in range(n):
    x1=l[i][0]
    y1=l[i][1]
    for j in range(n):
      if i!=j:
        x2=l[j][0]
        y2=l[j][1]
        p=x1-x2
        q=y1-y2
        for k1 in range(n):
          for k2 in range(n):
            if k1!=k2:
              if (l[k1][0]-p==l[k2][0] and l[k1][1]-q==l[k2][1]) or (l[k1][0]+p==l[k2][0] and l[k1][1]+q==l[k2][1]):
                UF.unite(k1,k2)
        ans.append(UF.groupnum())
        UF.reset()
  print(min(ans))
### BUGGY CODE ###

n,*a=map(int,open(0).read().split());print(*[-~a.index(-~i)for i in range(n)])

### FIXED CODE ###

n,*a=map(int,open(0).read().split())
s=[[j,i] for i,j in zip(range(1,n+1),a)]
s.sort()
print(*[i[1] for i in s])
### BUGGY CODE ###

n, k = map(int, input().split())
v = []
for i in range(n):
    abc = [x for x in input().split()]
    a = int(abc[0])
    b = int(abc[1])
    c = abc[2]
    if c == 'W':
        b += k
    v.append((a % (2*k), b % (2*k)))

s = [[0 for _ in range(6*k+1)] for _ in range(6*k+1)]
s2 = [[0 for _ in range(k+1)] for _ in range(k+1)]
s3 = [[0 for _ in range(k+1)] for _ in range(k+1)]

for i in range(n):
    s[v[i][1]][v[i][0]] += 1
    s[v[i][1]+k][v[i][0]+k] += 1
    s[v[i][1]+k][v[i][0]] -= 1
    s[v[i][1]][v[i][0]+k] -= 1

for i in range(3*k):
    for j in range(3*k):
        s[i+1][j] += s[i][j]
for i in range(3*k):
    for j in range(3*k):
        s[i][j+1] += s[i][j]

for i in range(3*k):
    for j in range(3*k):
        c = (i//k+j//k) % 2
        if c == 0:
            s2[i % k][j % k] += s[i][j]
        else:
            s3[i % k][j % k] += s[i][j]
res = 0

for i in range(k):
    for j in range(k):
        res = max(res, s2[i][j])
        res = max(res, s3[i][j])
print(res)


### FIXED CODE ###

n, k = map(int, input().split())
v = []
for i in range(n):
    abc = [x for x in input().split()]
    a = int(abc[0])
    b = int(abc[1])
    c = abc[2]
    if c == 'W':
        b += k
    v.append((a % (2*k), b % (2*k)))

s = [[0 for _ in range(3*k+1)] for _ in range(3*k+1)]
s2 = [[0 for _ in range(k+1)] for _ in range(k+1)]
s3 = [[0 for _ in range(k+1)] for _ in range(k+1)]

for i in range(n):
    s[v[i][1]][v[i][0]] += 1
    s[v[i][1]+k][v[i][0]+k] += 1
    s[v[i][1]+k][v[i][0]] -= 1
    s[v[i][1]][v[i][0]+k] -= 1

for i in range(3*k):
    for j in range(3*k):
        s[i+1][j] += s[i][j]
for i in range(3*k):
    for j in range(3*k):
        s[i][j+1] += s[i][j]

for i in range(3*k):
    for j in range(3*k):
        c = (i//k+j//k) % 2
        if c == 0:
            s2[i % k][j % k] += s[i][j]
        else:
            s3[i % k][j % k] += s[i][j]
res = 0

for i in range(k):
    for j in range(k):
        res = max(res, s2[i][j])
        res = max(res, s3[i][j])

print(res)
### BUGGY CODE ###

from collections import defaultdict

S = input()
B = defaultdict(int)
B[0]=1
ans=0

for i in range(len(S)):
    m=int(S[-i-1:])%2019
    ans+=B[m]
    B[m]+=1

print(int(ans))

### FIXED CODE ###

from collections import defaultdict

S = input()
B = defaultdict(int)
B[0]=1
ans=0
prev=0

for i in range(len(S)):
    m=(prev+int(S[-i-1])*pow(10,i,2019))%2019
    ans+=B[m]
    B[m]+=1
    prev=m

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

n = int(input())
list_A = list(map(int, input().split()))
list_B = list(set(list_A))
an = 0
for i in range(len(list_B)):
    c = list_A.count(list_B[i])
    an += (c*(c-1))//2


for i in range(n):
    c = list_A.count(list_A[i])
    if c != 2:
        ans = an - c + 1
    else:
        ans = an - 1
    print(ans)

### FIXED CODE ###

n = int(input())
list_A = list(map(int, input().split()))
list_B = list(set(list_A))
list_M = [0 for _ in range(n+1)]

for s in list_A:
    list_M[s] += 1
total = 0

for i in range(n+1):
    total += list_M[i]*(list_M[i]-1)//2

for s in list_A:
    ans = total - list_M[s] + 1
    print(ans)
### BUGGY CODE ###

import sys

N, M = map(int, input().split())
p = list(map(int, input().split()))
pairs = [[int(c) for  c in l.strip().split()] for l in sys.stdin]

d1 = [set(pairs[0])]

for i in range(1,M):
  flag = -1
  flag2 = 0
  for j in range(len(d1)):
    if len(d1[j] & set(pairs[i])) != 0:
      if flag != -1:
        d1[j] |= d1[flag]
        del d1[flag]
        break
      else:
        d1[j] |= set(pairs[i])
        flag = j
  if flag == -1:
    d1.append(set(pairs[i]))

ans = 0
for i in range(N):
  if i+1 == p[i]:
    ans += 1
  else:
    for sub in d1:
      if p[i] in sub and i+1 in sub:
        ans += 1
        break

print(ans)


### FIXED CODE ###

import sys

N, M = map(int, input().split())
p = list(map(int, input().split()))
p.insert(0,0)
pairs = [[int(c) for  c in l.strip().split()] for l in sys.stdin]

link = [[] for _ in  range(N+1)]
for i in range(M):
  x = pairs[i][0]
  y = pairs[i][1]
  link[x].append(y)
  link[y].append(x)


ans = 0
visited = set()
#数列の１つ１つの数字について
for i in range(1, N+1):

  #既に1度見た数字は飛ばす
  if i in visited:
    continue
  
  #linkedに交換可能なひとまとまりの数字をセットとして格納
  #ここでlinkedをリセット
  linked = set()

  #todoにはリンク先を調べないといけない数字のリストを格納
  todo = [i]
  while todo:

    #todoから1つずつ
    cur = todo.pop()
    for dest in link[cur]:

      #既にグループに入っている数字は飛ばす
      if dest not in linked:
        linked.add(dest)
        todo.append(dest)

  #「位置」を表すグループと「数字」を表すグループのオーバーラップ部分を数える
  ans += len(linked & set(p[n] for n in linked))
  #一度見た数字は再訪しない
  visited |= linked

#最後にまだ一度も見ていない数字のなかで、i = p[i]であるものを探す
for i in set(range(1,N+1)) - visited:
  ans += i == p[i]

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

def f(n):
    aa = list(map(int, input().split()))
    bb = list(map(int, input().split()))
    dp = [0] * (n + 1)
    for i in range(1, n + 1):
        mx = i
        for a, b in zip(aa, bb):
            if i >= a:
                tmp = dp[i - a] + b
                if tmp > mx:
                    mx = tmp
            dp[i] = mx
    n = dp[-1]
    dp = [0] * (n + 1)
    for i in range(1, n + 1):
        mx = i
        for a, b in zip(aa, bb):
            if i >= b:
                tmp = dp[i - b] + a
                if tmp > mx:
                    mx = tmp
            dp[i] = mx
    print(dp[-1])

n = int(input())
f(n)


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 6)

def don(dk, rate, amin):
    if not rate:
        return dk
    if len(rate)==1:
        a,b=rate[0]
        p,m=divmod(dk,a)
        return p*b+m
    if len(rate)==2:
        a0,b0=rate[0]
        a1,b1=rate[1]
        if b0/a0<b1/a1:
            a0,b0,a1,b1=a1,b1,a0,b0
        p0,m=divmod(dk,a0)
        re=b0*p0
        p1,m=divmod(m,a1)
        re+=b1*p1+m
        while p0>0 and m>0:
            p0-=1
            m+=a0
            p2,m=divmod(m,a1)
            p1+=p2
            tmp=p0*b0+p1*b1+m
            if tmp>re:
                re=tmp
        return re
    if dk < amin:
        return dk
    if dp[dk] != -1:
        return dp[dk]
    mx = 0
    for a, b in rate:
        if a > dk: continue
        tmp = don(dk - a, rate, amin) + b
        if tmp > mx:
            mx = tmp
    dp[dk] = mx
    return mx

n = int(input())
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))
atob = []
btoa = []
amin = 10 ** 7
bmin = 10 ** 7
for a, b in zip(aa, bb):
    if a < b:
        atob.append([a, b])
        if a < amin:
            amin = a
    elif a > b:
        btoa.append([b, a])
        if b < bmin:
            bmin = b
dp = [-1] * (n + 1)
n = don(n, atob, amin)
dp = [-1] * (n + 1)
print(don(n, btoa, bmin))
### BUGGY CODE ###

n = int(input())
a_list = list(map(int, input().split()))
first = a_list[0]

mem = {}
for i in range(1, n + 1):
    mem[i] = {}

counter = 0

for i in range(first + 1):
    curr = i
    arr = [0] * (n + 1)
    arr[0] = curr * 2

    valid = True
    for j in range(0, n):
        curr = arr[j]
        nxt = 0
        if curr not in mem[j + 1]:
            nxt = int(( a_list[j] - curr / 2) * 2)
            mem[j + 1][curr] = nxt
            counter += 1
        else:
            nxt = mem[j + 1][curr]

        if nxt < 0:
            valid = False
            break
        arr[j + 1] = nxt

    if not valid:
        continue

    if arr[0] == arr[n]:
        print(*arr[:n])
        break

### FIXED CODE ###

n = int(input())
a_list = list(map(int, input().split()))
first = a_list[0]

def check(m0):
    arr = [0] * (n + 1)
    arr[0] = m0
    for j in range(0, n):
        curr = arr[j]
        nxt = int((a_list[j] - curr / 2) * 2)
        arr[j + 1] = nxt
    return arr

r = (0, first)
while r[0] <= r[1]:
    mid = (r[0] + r[-1]) // 2
    m0 = mid * 2
    arr = check(m0)
    mn = arr[n]
    if m0 == mn:
        print(*arr[:n])
        break
    elif mn > m0:
        r = (mid + 1, r[1])
    else:
        r = (r[0], mid - 1)
### BUGGY CODE ###

#-*-coding:utf-8-*-

def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    b_list = list(map(int, input().split()))
    c_list = list(map(int, input().split()))

    a_list.sort()
    b_list.sort()
    c_list.sort()

    cnt = 0

    for i in range(n):
        for j in range(n):
            if a_list[i] < b_list[j]:
                for k in range(n):
                    if b_list[j] < c_list[k]:
                        cnt += n - k
                        break
    
    print(cnt)


if __name__ == '__main__':
    main()

### FIXED CODE ###

#-*-coding:utf-8-*-
import bisect

def main():

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

    a_list.sort()
    b_list.sort()
    c_list.sort()

    cnt = 0
    
    for b in b_list:
        i = bisect.bisect_left(a_list, b)
        j = n - bisect.bisect_right(c_list, b)
        cnt += i * j
    
    print(cnt)
    
if __name__ == '__main__':
    main()
### BUGGY CODE ###

n, q = map(int, input().split())
s = list(input())
ac = {i+1 for i in range(n-1) if s[i] + s[i+1] == "AC"}
for _ in range(q):
    l, r = map(int, input().split())
    lr = set(range(l, r))
    print(len(ac & lr))


### FIXED CODE ###

n, q = map(int, input().split())
s = input()

ac = [0] * n
for i in range(1, n):
    ac[i] = ac[i-1] + int(s[i-1:i+1] == "AC")

for _ in range(q):
    l, r = map(int, input().split())
    print(ac[r-1] - ac[l-1])
### BUGGY CODE ###

def main():
    X = int(input())
    if 2000 <= X:
        return print(1)
    if X < 100:
        return print(0)
    from itertools import product
    for c in product(range(20), repeat=6):
        if c[0]*100 + c[1]*101 + c[2]*102 + c[3]*103 + c[4]*104 + c[5]*105 \
                == X:
            return print(1)
    else:
        return print(0)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n = 6
    A = (100, 101, 102, 103, 104, 105)
    M = [10**6]*6
    K = int(input())
    dp = [[-1]*(K+1) for _ in range(n+1)]
    dp[0][0] = 0
    for i in range(n):
        for j in range(K+1):
            if dp[i][j] >= 0:
                dp[i+1][j] = M[i]
            elif j < A[i] or dp[i+1][j-A[i]] <= 0:
                dp[i+1][j] = -1
            else:
                dp[i+1][j] = dp[i+1][j-A[i]] - 1
    if dp[n][K] >= 0:
        print(1)
    else:
        print(0)


if __name__ == '__main__':
    main()