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

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

cnt = 0

for i in range(N-1):
    for j in range(i+1,N):
        if j-i == A[i]+A[j]:
            cnt += 1

print(cnt)


### FIXED CODE ###

from collections import defaultdict

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

cnt = 0
L = defaultdict(lambda: 0)
R = defaultdict(lambda: 0)

for i in range(N):
    L[i+A[i]] += 1
    R[i-A[i]] += 1

for key in L:
    cnt += L[key] * R[key]


print(cnt)
### BUGGY CODE ###

H, W = map(int, input().split())
A = [list(map(int, input().split())) for i in range(H)]
B = [list(map(int, input().split())) for i in range(H)]


X = [[0] * W for i in range(H)]
for h in range(H):
    for w in range(W):
        X[h][w] = abs(A[h][w] - B[h][w])


# dp[h][w][x] := (h, w)の時点で差をxにできるか？
M = 3200
dp = [[[False] * (M + 1) for j in range(W)] for i in range(H)]
dp[0][0][X[0][0]] = True


for h in range(H):
    for w in range(W):
        for m in range(M):
            x = X[h][w]
            if (0 <= h - 1) and abs(m + X[h][w] <= M):
                dp[h][w][m] = dp[h][w][m] or dp[h - 1][w][abs(m + x)]

            if (0 <= h - 1) and abs(m - X[h][w] <= M):
                dp[h][w][m] = dp[h][w][m] or dp[h - 1][w][abs(m - x)]

            if (0 <= w - 1) and abs(m + X[h][w] <= M):
                dp[h][w][m] = dp[h][w][m] or dp[h][w - 1][abs(m + x)]

            if (0 <= w - 1) and abs(m + X[h][w] <= M):
                dp[h][w][m] = dp[h][w][m] or dp[h][w - 1][abs(m - x)]


ans = float('inf')
for x in range(M + 1):
    if dp[H - 1][W - 1][x]:
        ans = min(ans, x)

print(ans)


### FIXED CODE ###

def main():
    import sys

    H, W = map(int, sys.stdin.readline().split())
    A = [list(map(int, sys.stdin.readline().split())) for i in range(H)]
    B = [list(map(int, sys.stdin.readline().split())) for i in range(H)]
    X = [[0] * W for i in range(H)]
    for h in range(H):
        for w in range(W):
            X[h][w] = abs(A[h][w] - B[h][w])

    dp = [[set() for j in range(W)] for i in range(H)]
    dp[0][0].add(X[0][0])
    dp[0][0].add(-X[0][0])

    for h in range(H):
        for w in range(W):
            if h == 0 and w == 0:
                continue
            x = X[h][w]
            s = set()

            if h > 0:
                for d in dp[h - 1][w]:
                    s.add(d + x)
                    s.add(abs(d - x))

            if w > 0:
                for d in dp[h][w - 1]:
                    s.add(d + x)
                    s.add(abs(d - x))

            dp[h][w] = s

    ans = min([abs(s) for s in dp[H - 1][W - 1]])
    print(ans)


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

from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


n, m = Is()
A = LI()
tmp = 0
for i in range(m):
    b, c = Is()
    A += [c]*b
    tmp += b
heapify(A)

for i in range(tmp):
    heappop(A)

print(sum(A))


### FIXED CODE ###

from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


n, m = Is()
A = LI()
BC = TIR(m)
A.sort()
BC.sort(key=itemgetter(1), reverse=True)
D = []
for b, c in BC:
    D += [c]*b
    if len(D) > n:
        break

for i in range(min(n, len(D))):
    if A[i] < D[i]:
        A[i] = D[i]
    else:
        break

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

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

A,B,N = map(int, input().split())
z = 0

for x in range(1,B+1):
    if x > N:
        break
    ans = (x % B) / B * A
    if ans > z:
        z = ans
print(int(z))

### FIXED CODE ###

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

A,B,N = map(int, input().split())

if N >= B:
    x  = B - 1
    z = (A * x) // B - A * (x // B)
else:
    x = N
    z = (A * x) // B - A * (x // B)

print(int(z))
### BUGGY CODE ###

from functools import reduce

words = lambda t : list(map(t, input().split()))
n = int(input())
xs = words(int)

ys = []
n = 0
for x in xs:
    y = list(reversed(bin(x)))[:-2]
    ys.append(y)
    n = max(n, len(y))
#print(ys, n)

def calc (x,y):
    if i < len(y) and y[i] == "1":
        return x+1
    else:
        return x

ans = 0
for i in range(n):
    x1 = 0
    x1 = reduce(calc,ys,0)
    #print(x1,x0)
    ans += x1 * (len(ys)-x1) * (2**(i))
    ans %= 10**9 + 7
print(ans)


### FIXED CODE ###

words = lambda t : list(map(t, input().split()))
n = int(input())
xs = words(int)

ys = [0]*60
for x in xs:
    for i in range(60):
        if x == 0:
            continue
        ys[i] += x & 1
        x = x >> 1

ans = 0

for i,yi in enumerate(ys):
    ans += 2**(i) * yi * (n-yi)
    ans %= 10**9 + 7
print(ans)
### BUGGY CODE ###

import sys
from io import StringIO
import unittest


class UnionFind:
    def __init__(self, N):
        self.roots = list(range(N + 1))
        self.counter = [1] * (N + 1)

    def get_root(self, n):
        if self.roots[n] != n:
            self.roots[n] = self.get_root(self.roots[n])
        return self.roots[n]

    def union(self, a, b):
        a, b = sorted([self.get_root(a), self.get_root(b)])
        if a != b:
            self.roots[b] = a
            self.counter[a] += self.counter[b]
            self.counter[b] = 0

    def find(self, a, b):
        return self.get_root(a) == self.get_root(b)

    def count(self, x):
        return (self.counter[self.get_root(x)])

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

    uf = UnionFind(N)

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

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

    for i in range(N):
        ans = uf.count(i) - len(list[i]) - 1
        for j in block[i]:
            if uf.find(i ,j):
                ans -= 1

        print(ans, end=" ")
resolve()

### FIXED CODE ###

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

import numpy as np
input()
x=np.array(input().split(),dtype=np.int32)
ans=0
while (x%2==0).all():
  x//2
  ans +=1
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
result = float('inf') 
for i in a:
    result = min(result,len(bin(i))-bin(i).rfind('1')-1)
print(result)
### BUGGY CODE ###

import sys

def solve():
    n = int(raw_input())
    R = []

    for i in xrange(n):
        R.append(int(raw_input()))

    #for i in xrange(n):
    #    print R[i]

    max_profit = -sys.maxint
    for i in xrange(n):
        for j in xrange(i + 1, n):
            if R[j] - R[i] > max_profit:
                max_profit = R[j] - R[i]


    print max_profit


if __name__ == "__main__":
    solve()

### FIXED CODE ###

import sys

def solve():
    n = int(raw_input())
    R = []

    for i in xrange(n):
        R.append(int(raw_input()))

    #for i in xrange(n):
    #    print R[i]

    max_profit = -sys.maxint
    min_R = R[0]

    for i in xrange(1, n):
        if R[i] - min_R > max_profit:
            max_profit = R[i] - min_R
        if min_R > R[i]:
            min_R = R[i]

    print max_profit


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

# O(NM), absolutely TLE
n, m = map(int, input().split())
ab = []
for _ in range(n):
    ab.append(list(map(int, input().split())))

ab.sort(key=lambda x:x[1], reverse=True)

ans = 0
for i in range(1, m+1):
    if len(ab)==0:
        break
    for j in range(len(ab)):
        if ab[j][0]<=i:
            _, tmp = ab.pop(j)
            ans += tmp
            break
print(ans)

### FIXED CODE ###

import heapq
n, m = map(int, input().split())
ab = []
for _ in range(n):
    ab.append(list(map(int, input().split())))

ab.sort(key=lambda x:x[0])

heap = []
ind = 0
ans = 0
for i in range(1, m+1):
    while ind<len(ab):
        if ab[ind][0]==i:
            heapq.heappush(heap, -ab[ind][1])
            ind += 1
        else:
            break
    if len(heap)>0:
        ans += heapq.heappop(heap)
    elif ind==len(ab)-1:
        break
print(-ans)
### BUGGY CODE ###

S=input()
Q=int(input())
reverse=0
for q in range(Q):
    Query=list(input().split())
    T=Query[0]
    if T=="1":
        reverse+=1
    if T=="2":
        F,C=Query[1],Query[2]
        if F=="1" and reverse%2==0 or F=="2" and reverse%2==1:
            S=C+S
        else:
            S=S+C
print(S if reverse%2==0 else S[::-1])

### FIXED CODE ###

from collections import deque
S=deque(input())
Q=int(input())
reverse=0
for q in range(Q):
    Query=list(input().split())
    T=Query[0]
    if T=="1":
        reverse+=1
    if T=="2":
        F,C=Query[1],Query[2]
        if F=="1" and reverse%2==0 or F=="2" and reverse%2==1:
            S.appendleft(C)
        else:
            S.append(C)
S="".join(S)
print(S if reverse%2==0 else S[::-1])
### BUGGY CODE ###

def lcs(x, y):
    m = len(x)
    n = len(y)
    c = [[0] * 1001 for i in range(1002)]
    x = " " + x
    y = " " + y
    for i in range(1, m + 1):
        for j in range(1, n + 1):
            if x[i] == y[j]:
                c[i][j] = c[i - 1][j - 1] + 1
            else:
                c[i][j] = max(c[i - 1][j], c[i][j - 1])
    return max([e for l1 in c for e in l1])

if __name__ == '__main__':
    n = int(input().rstrip())
    for i in range(n):
        s1 = input().rstrip()
        s2 = input().rstrip()
        print(lcs(s1, s2))

### FIXED CODE ###

def lcs(x, y):
    a = len(x)
    b = len(y)
    c1 = [0] * (b + 1)
    for i in range(a):
        e1 = x[i]
        c2 = c1[:]
        for j in range(b):
            if e1 == y[j]:
                c1[j+1] = c2[j] + 1
            elif c1[j+1] < c1[j]:
                c1[j+1] = c1[j]
    return c1[-1]
   
n = int(input().rstrip())
ret = []
for i in range(n):
    s1 = input().rstrip()
    s2 = input().rstrip()
    ret.append(lcs(s1, s2))
print(*ret, sep="\n")
### BUGGY CODE ###

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

MOD = 10**9+7

N = int(input())
S = list(input())

if S[0] == "W" or S[-2] == "W":
    print(0)
    sys.exit()

LR = [0 for i in range(2*N)]
count0 = 1
ans = 1
for i in range(1, 2*N):
    if LR[i-1] == 0:
        if S[i] == S[i-1]:
            LR[i] = 1
        else:
            LR[i] = 0
    else:
        if S[i] == S[i-1]:
            LR[i] = 0
        else:
            LR[i] = 1

    if LR[i] == 0:
        count0 += 1
    else:
        ans *= count0 % MOD
        count0 -= 1

if LR.count(0) != N:
    print(0)
    sys.exit()

def factorial(N, mod):
    if N == 0 or N == 1:
        return 1
    else:
        return N * factorial(N-1, mod) % mod

print(ans*factorial(N,MOD)%MOD)

### FIXED CODE ###

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

MOD = 10**9+7

N = int(input())
S = list(input().rstrip())

if S[0] == "W" or S[-1] == "W":
    print(0)
    sys.exit()

LR = [0 for i in range(2*N)]
count0 = 1
count0_raw = 1
ans = 1
for i in range(1, 2*N):
    if LR[i-1] == 0:
        if S[i] == S[i-1]:
            LR[i] = 1
        else:
            LR[i] = 0
    else:
        if S[i] == S[i-1]:
            LR[i] = 0
        else:
            LR[i] = 1

    if LR[i] == 0:
        count0 += 1
        count0_raw += 1
    else:
        ans *= count0
        ans %= MOD
        count0 -= 1

if count0_raw != N:
    print(0)
    sys.exit()

N_k = 1
for i in range(N):
    N_k *= i+1
    N_k %= MOD

print(ans*N_k%MOD)
### BUGGY CODE ###

n = int(input())
lis = list(map(int, input().split()))
cnt = 0

for i in range(n):
    for j in range(i):
        if lis[i] > lis[j]:
            cnt += 1
            break
print(n - cnt)

### FIXED CODE ###

n = int(input())
lis = list(map(int, input().split()))
inf = 10 ** 15
ans = 0
for i in lis:
    if i < inf:
        ans += 1
        inf = i
print(ans)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *


def solve(H: int, W: int, A: "List[str]"):
    queue = deque()

    for i in range(H):
        for j in range(W):
            if A[i][j] == '#':
                queue.append((i, j, 0))
    
    ret = 0
    visited = [[False] * W for _ in range(H)]
    while 0 < len(queue):
        i, j, n = queue.popleft()
        if visited[i][j]:
            continue
        visited[i][j] = True
        ret = max(ret, n)

        if 0 < j:
            queue.append((i, j - 1, n + 1))
        if j < W - 1:
            queue.append((i, j + 1, n + 1))
        if 0 < i:
            queue.append((i - 1, j, n + 1))
        if i < H - 1:
            queue.append((i + 1, j, n + 1))
    return ret


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    A = [ next(tokens) for _ in range(H) ]  # type: "List[str]"
    result = solve(H, W, A)
    print(result)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *


def solve(H: int, W: int, A: "List[str]"):
    queue = deque()

    rem = H * W
    visited = [True] * ((W+2) * (H+2))
    for i in range(W+2):
        visited[i] = False
        visited[(W + 2) * (H + 1) + i] = False
    for i in range(H+2):
        visited[(W + 2) * i] = False
        visited[(W + 2) * i + (W + 1)] = False

    for i in range(H):
        l = A[i]
        for j in range(W):
            if l[j] == '#':
                queue.append((i+1, j+1, 0))
                k = i * (W + 2) + j
                visited[k] = False

    ret = 0
    while queue:
        i, j, n = queue.popleft()
        k = i * (W + 2) + j
        if not visited[k] and 0 < n:
            continue
        visited[k] = False
        ret = n
        rem -= 1

        if rem == 0:
            break

        if visited[k - 1]:
            queue.append((i, j - 1, n + 1))
        if visited[k + 1]:
            queue.append((i, j + 1, n + 1))

        if visited[k - (W + 2)]:
            queue.append((i - 1, j, n + 1))
        if visited[k + (W + 2)]:
            queue.append((i + 1, j, n + 1))
    return ret


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    A = [ next(tokens) for _ in range(H) ]  # type: "List[str]"
    result = solve(H, W, A)
    print(result)

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

N,M=map(int, input().split())
AB=[]
for i in range(N):
  AB.append(list(map(int,input().split())))
AB.sort()
count=0
summary=0
for i in range(N):
  for j in range(AB[i][1]):
    summary+=AB[i][0]
    count+=1
    if count==M:
      print(summary)
      break

### FIXED CODE ###

N,M=map(int, input().split())
AB=[]
for i in range(N):
  AB.append(list(map(int,input().split())))
AB.sort()
count=0
summary=0
for i in range(N):
  for j in range(AB[i][1]):
    summary+=AB[i][0]
    count+=1
    if count==M:
      print(summary)
      break
  else:
    continue
  break
### BUGGY CODE ###

N, M = map(int, input().split())
AC = []
WA = []
for i in range(M):
  p, S = input().split()
  p = int(p)
  if S == 'AC':
    AC.append(p)
  else:
    if p in set(AC):
      continue
    else:
      WA.append(p)
AC = list(set(AC))
c = len(AC)
wa = 0
for w in WA:
  if w in set(AC):
    wa += 1
print(c, wa, sep=' ')

### FIXED CODE ###

N, M = map(int, input().split())
AC = [0 for i in range(N)]
WA = [0 for i in range(N)]
a = [0 for i in range(N)]
for i in range(M):
  p, S = input().split()
  p = int(p)
  if S == 'AC':
    AC[p-1] = 1
    a[p-1] = 0
  else:
    if AC[p-1] == 0:
      WA[p-1] += 1
      a[p-1] += 1
c = sum(AC)
wa = sum(WA) - sum(a)
print(c, wa, sep=' ')
### BUGGY CODE ###

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

MOD = 998244353

fact = [1]*4000
t = 1
for i in range(1,4000):
    t = (t*i)%MOD
    fact[i] = t

def ncr(n,r):
    return (fact[n] * pow(fact[r],MOD-2,MOD) % MOD) * pow(fact[n-r],MOD-2,MOD) % MOD

for i in range(2,2*K+1):
    t1,t2 = 0,0
    Ans = 0
    # p : 足して i になる整数の組の数
    np = i//2 - max(i-1-K,0)
    # p組からq組, 片方を使用する場合の数を足し合わせる
    # 偶奇で場合分け
    if i%2==0:
        # 偶数の場合 : 1組だけ同じ数の組があるため特別扱いする
        np -= 1
        for nq in range(np+1):
            # 同じ数の組の数字を全く含まない場合
            t1 = ncr(np,nq)*(2**nq)
            t1 %= MOD
            nr = K - np*2 - 1
            t2 = ncr(N+nr-1,N-nq) if N+nr-1>=N-nq else 0
            t2 %= MOD
            Ans += t1*t2
            # 同じ数の組の数字を1つ含む場合
            t2 = ncr(N-1+nr-1,N-1-nq) if N-1+nr-1>=N-1-nq else 0
            t2 %= MOD
            Ans += t1*t2
    else:
        # 奇数の場合 : p組全て互いに異なる数
        for nq in range(np+1):
            t1 = ncr(np,nq)*(2**nq)
            t1 %= MOD
            nr = K - np*2
            t2 = ncr(N+nr-1,N-nq) if N-1+nr-1>=N-1-nq else 0
            t2 %= MOD
            Ans += t1*t2
    print(Ans%MOD)


### FIXED CODE ###

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

MOD = 998244353

fact = [1]*4000
t = 1
for i in range(1,4000):
    t = (t*i)%MOD
    fact[i] = t

factinv = [1]*4000
for i in range(1,4000):
    factinv[i] = pow(fact[i], MOD-2, MOD)

def ncr(n,r):
    if n < 0 or r < 0 or n-r < 0:
        return 0
    return (fact[n] * factinv[r] * factinv[n-r]) % MOD

def nhr(n,r):
    if n == 0 and r == 0:
        return 1
    return ncr(n+r-1, r)

for i in range(2,2*K+1):
    t1,t2 = 0,0
    Ans = 0
    # p : 足して i になる整数の組の数
    np = i//2 - max(i-1-K,0)
    # p組からq組, 片方を使用する場合の数を足し合わせる
    # 偶奇で場合分け
    if i%2==0:
        # 偶数の場合 : 1組だけ同じ数の組があるため特別扱いする
        np -= 1
        for nq in range(np+1):
            # 同じ数の組の数字を全く含まない場合
            t1 = ncr(np,nq)*pow(2, nq, MOD)
            t1 %= MOD
            t2 = nhr(K-np*2+nq-1,N-nq)
            t2 %= MOD
            Ans = (Ans + t1*t2) % MOD
            # 同じ数の組の数字を1つ含む場合
            t2 = nhr(K-np*2+nq-1,N-nq-1)
            t2 %= MOD
            Ans = (Ans + t1*t2) % MOD
    else:
        # 奇数の場合 : p組全て互いに異なる数
        for nq in range(np+1):
            t1 = ncr(np,nq)*pow(2, nq, MOD)
            t1 %= MOD
            t2 = nhr(K-np*2+nq,N-nq)
            t2 %= MOD
            Ans = (Ans + t1*t2) % MOD
    print(Ans%MOD)
### BUGGY CODE ###

import re
N, Q = map(int, input().split())
S = input()
iter = re.finditer("AC", S)
indices_A = [m.start(0) for m in iter]
indices_C = [a+1 for a in indices_A]
total = S.count("AC")

dec_l_list = []
dec_l = 0
for i in range(N):
    if i in indices_C:
        dec_l-= 1
    dec_l_list.append(dec_l)

dec_r_list = []
dec_r = 0
for i in reversed(range(N)):
    if i in indices_A:
        dec_r-= 1
    dec_r_list.append(dec_r)
dec_r_list.reverse()

#print(dec_l_list)
#print(dec_r_list)

for i in range(Q):
    l, r = map(int, input().split())
    print(total + dec_l_list[l-1] + dec_r_list[r-1])

### FIXED CODE ###

#import re
N, Q = map(int, input().split())
S = input()
#iter = re.finditer("AC", S)
#indices_C = [m.start(0)+1 for m in iter]
#total = len(indices_C)
#
#dec_l_list = []
#dec_l = 0
#dec_r_list = []
#dec_r = total
#for i in range(N):
#    if i in indices_C:
#        dec_l += 1
#        dec_r -= 1
#    dec_l_list.append(dec_l)
#    dec_r_list.append(dec_r)

flag = False
dec_l_list = []
total = 0
for i in range(N):
    if flag and S[i] == "C":
        total += 1
    dec_l_list.append(total)
    flag = True if S[i] == "A" else False
dec_r_list = [total - x for x in dec_l_list]

for i in range(Q):
    l, r = map(int, input().split())
    print(total - dec_l_list[l-1] - dec_r_list[r-1])
### BUGGY CODE ###

n = int(input())
ans = 0
a = 1
repeat_count = 0
while a <= n:
    b = 1
    while b <= a and a*b < n:
        ans += 1
        if b < a:
            repeat_count += 1
        b += 1
    a += 1
print(ans + repeat_count)

### FIXED CODE ###

import math as mt
from collections import defaultdict
  
MAXN = 10**6
  
spf = [0 for i in range(MAXN)] 
  
def sieve(): 
    spf[1] = 1
    for i in range(2, MAXN): 
        spf[i] = i 
    for i in range(4, MAXN, 2): 
        spf[i] = 2
  
    for i in range(3, mt.ceil(mt.sqrt(MAXN))): 
        if (spf[i] == i): 
            for j in range(i * i, MAXN, i):  
                if (spf[j] == j): 
                    spf[j] = i 
  
# A O(log n) function returning prime  
# factorization by dividing by smallest  
# prime factor at every step 
def getFactorization(x): 
    d = defaultdict(int)
    while (x != 1): 
        #ret.append(spf[x])
        d[spf[x]] += 1 
        x = x // spf[x] 
    #return Counter(ret)
    ans = 1
    for i in d:
        ans *= (d[i]+1)
    return ans
sieve()

n = int(input())
ans = 0
for i in range(1, n):
    ans += getFactorization(i)
print(ans)
### BUGGY CODE ###

s=input()
orig = len(s)
while True:
    s = list(s)
    for i in range(1, len(s)):
        if s[i] == '0' and s[i-1] == '1':
            s[i] = 'x'
            s[i-1] = 'x'
        elif s[i-1] == '0' and s[i] == '1':
            s[i] = 'x'
            s[i-1] = 'x'
    s = ''.join(s)
    if s == s.replace('x', ''):
        break
    s=s.replace('x', '')
print(orig-len(s))

### FIXED CODE ###

s=input()
orig = len(s)
ones = sum([1 for x in s if x == '1'])
zeros = sum([1 for x in s if x == '0'])
print(2*min(ones, zeros))