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

def solve(n, s):
    rlist, glist, blist = [0 for _ in range(n)], [0 for _ in range(n)], [0 for _ in range(n)]
    rcount, gcount, bcount = 0, 0, 0
    for i in range(n-1):
        if s[n-1-i] == 'R':
            rcount += 1
        if s[n-1-i] == 'G':
            gcount += 1
        if s[n-1-i] == 'B':
            bcount += 1
        rlist[n-2-i], glist[n-2-i], blist[n-2-i] = rcount, gcount, bcount
        
    ans = 0

    for i in range(n-2):
        for j in range(i+1,n-1):
            if s[i] != s[j]:
                if s[i] == 'R':
                    if s[j] == 'G':
                        ans += blist[j] - ( 1 if 2*j-i < n and s[2*j-i] == 'B' else 0)
                    else:
                        ans += glist[j] - (1 if 2*j-i < n and s[2*j-i] == 'G' else 0)
                elif s[i] == 'G':
                    if s[j] == 'R':
                        ans += blist[j] - (1 if 2*j-i < n and s[2*j-i] == 'B' else 0)
                    else:
                        ans += rlist[j] - (1 if 2*j-i < n and s[2*j-i] == 'R' else 0)
                else:
                    if s[j] == 'G':
                        ans += rlist[j] - (1 if 2*j-i < n and s[2*j-i] == 'R' else 0)
                    else:
                        ans += glist[j] - (1 if 2*j-i < n and s[2*j-i] == 'G' else 0)
    
    return ans

def main():
    n = int(input())
    s = input()
    print(solve(n, s))

if __name__ == '__main__':
    main()

### FIXED CODE ###

def solve(n, s):
    rlist, glist, blist = [0 for _ in range(n)], [0 for _ in range(n)], [0 for _ in range(n)]
    rcount, gcount, bcount = 0, 0, 0
    for i in range(n-1):
        if s[n-1-i] == 'R':
            rcount += 1
        if s[n-1-i] == 'G':
            gcount += 1
        if s[n-1-i] == 'B':
            bcount += 1
        rlist[n-2-i], glist[n-2-i], blist[n-2-i] = rcount, gcount, bcount
        
    ans = 0

    for i in range(n-2):
        for j in range(i+1,n-1):
            if s[i] != s[j]:
                if s[i] == 'R':
                    if s[j] == 'G':
                        ans += blist[j] - ( 1 if 2*j-i < n and s[2*j-i] == 'B' else 0)
                    else:
                        ans += glist[j] - (1 if 2*j-i < n and s[2*j-i] == 'G' else 0)
                elif s[i] == 'G':
                    if s[j] == 'R':
                        ans += blist[j] - (1 if 2*j-i < n and s[2*j-i] == 'B' else 0)
                    else:
                        ans += rlist[j] - (1 if 2*j-i < n and s[2*j-i] == 'R' else 0)
                else:
                    if s[j] == 'G':
                        ans += rlist[j] - (1 if 2*j-i < n and s[2*j-i] == 'R' else 0)
                    else:
                        ans += glist[j] - (1 if 2*j-i < n and s[2*j-i] == 'G' else 0)
    
    return ans

def main():
    n = int(input())
    s = input()
    print(solve(n, s))

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

def search(X, Y):
    dp = [[0] * (len(Y)+1) for x in range(len(X)+1)]
    for x in range(1, len(X) + 1):
        for y in range(1, len(Y) + 1):
            if X[x-1] == Y[y-1]:
                dp[x][y] = dp[x-1][y-1] + 1
            elif dp[x-1][y] > dp[x][y-1]:
                dp[x][y] = dp[x-1][y]
            else:
                dp[x][y] = dp[x][y-1]
    return dp[-1][-1]

for _ in range(int(input())):
    X = input()
    Y = input()
    print(search(X, Y))


### FIXED CODE ###

def ser(X, Y):
    dp = [[0] * (len(Y)+1) for x in range(len(X)+1)]
    for i, x in enumerate(X, 1):
        tmp = dp[i]
        pre = dp[i-1]
        for j, y in enumerate(Y, 1):
            if x == y:
                tmp[j] = pre[j-1] + 1
            elif pre[j] < tmp[j-1]:
                tmp[j] = tmp[j-1]
            else:
                tmp[j] = pre[j]
    return(dp[-1][-1])

for _ in range(int(input())):
    X, Y = input(), input()
    print(ser(X, Y))
### BUGGY CODE ###

N, M = map(int, input().split())
task = []
for i in range(N):
    a, b = map(int, input().split())
    task.append((a, b))

task.sort()

wa = [0] * (10**5+10)
ans = 0
j = 0
for i in range(M):
    while j < N and task[j][0] == i + 1:
        wa[task[j][1]] += 1
        j += 1
    if sum(wa):
        ls = [i for i, e in enumerate(wa) if e != 0][-1]
        ans += ls
        wa[ls] -= 1

print(ans)


### FIXED CODE ###

import bisect
import heapq

N, M = map(int, input().split())
task = []
for i in range(N):
    a, b = map(int, input().split())
    task.append((a, b))

task.sort()

wa = []
ans = 0
j = 0
for i in range(M):
    while j < N and task[j][0] == i + 1:
        heapq.heappush(wa,-task[j][1])
        j += 1
    if wa:
        ans -= heapq.heappop(wa)

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

N = int(input())
A = list(map(int, input().split()))
mod = (10 ** 9) + 7
answer = 0

for i in range(N-1):
    for j in range(i+1, N):
        answer += A[i] * A[j] % mod
print(answer % mod)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
mod = (10 ** 9) + 7
answer = 0
sum_A = sum(A)

for i in range(N):
    sum_A -= A[i]
    answer += A[i] * sum_A % mod
print(answer % mod)
### BUGGY CODE ###

def main():
    h,*s=open(0)
    h,w=map(int,h.split())
    a=tuple([0]*w for _ in range(h))
    b=tuple([0]*w for _ in range(h))
    c=tuple([0]*w for _ in range(h))
    d=tuple([0]*w for _ in range(h))
    for i in range(h*w):
        i,j=divmod(i,w)
        a[i][j]=a[i][j-1]+1if s[i][j]=='.'else 0
        b[i][~j]=b[i][-j]+1if s[i][-j-2]=='.'else 0
        c[i][j]=c[i-1][j]+1if s[i][j]=='.'else 0
        d[~i][j]=d[-i][j]+1if s[~i][j]=='.'else 0
    print(max(sum(u)-3for t in zip(a,b,c,d)for u in zip(*t)))
main()

### FIXED CODE ###

def main():
    h,*s=open(0)
    h,w=map(int,h.split())
    a=tuple([0]*w for _ in range(h))
    b=tuple([0]*w for _ in range(h))
    c=tuple([0]*w for _ in range(h))
    d=tuple([0]*w for _ in range(h))
    for i in range(h*w):
        i,j=divmod(i,w)
        a[i][j]=a[i][j-1]+1if s[i][j]=='.'else 0
        b[i][~j]=b[i][-j]+1if s[i][-j-2]=='.'else 0
        c[i][j]=c[i-1][j]+1if s[i][j]=='.'else 0
        d[~i][j]=d[-i][j]+1if s[~i][j]=='.'else 0
    print(max(a[i][j]+b[i][j]+c[i][j]+d[i][j]-3for i in range(h)for j in range(w)))
main()
### BUGGY CODE ###

"""
セグメント木：蟻本P153
できること：a[i]の更新(O(log n))、a[L],...,a[R-1]の最小値など(O(log n))
入力：n,a(配列)
     'ide_ele' : 単位元(min:∞, 和:0, 積:1, gcd:0)
     'segfunc' : return min(x,y) とかにする
出力:'init(a)': 配列aで初期化。O(N)
     'update(k,x)': a[k]をxに変更 O(logN)
     'query(p,q)': [p,q)について "segfunc" したものを返す O(logN)
"""
n=int(input())
a=[int(input()) for i in range(n)]
#####segfunc######
def segfunc(x,y):
    return max(x,y)


def init(init_val):
    #set_val
    for i in range(n):
        seg[i+num-1]=init_val[i]    
    #built
    for i in range(num-2,-1,-1) :
        seg[i]=segfunc(seg[2*i+1],seg[2*i+2]) 
    
def update(k,x):
    k += num-1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
    
def query(p,q):
    if q<=p:
        return ide_ele
    p += num-1
    q += num-2
    res=ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res,seg[p])
        if q&1 == 1:
            res = segfunc(res,seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res,seg[p])
    else:
        res = segfunc(segfunc(res,seg[p]),seg[q])
    return res

#####単位元######
ide_ele = 0
num =2**(n-1).bit_length()
seg=[ide_ele]*2*num
init(a)
print(query(1,n))
for i in range(1,n):
    print(max(query(0,i),query(i+1,n)))

### FIXED CODE ###

N= int(input())
A=[]
for x in range(0,N):
    A.append(int(input()))
B=sorted(A)
for x in range(0,N):
    if A[x]==B[N-1]:
        print(B[N-2])
    else:
        print(B[N-1])
### BUGGY CODE ###

#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

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

B = [0]*(N-K+1)
val = 1
for a in A[:K]:
    val *= a
B[0] = val
for i in range(1, N-K+1):
    B[i] = B[i-1]
    B[i] //= A[i-1]
    B[i] *= A[i+K-1]

for bi, bip in zip(B[:-1], B[1:]):
    if bi < bip:
        print('Yes')
    else:
        print('No')



### FIXED CODE ###

#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left, bisect_right #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

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

for i in range(N-K):
    if A[i] < A[i+K]:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

x=int(input())
a=0
b=0
for i in range(-x,x):
  for j in range(-x,x):
    if i**5-j**5==x:
      a=i
      b=j
      break
  else:
    continue
  break
print(a,b)

### FIXED CODE ###

x=int(input())
a=0
b=0
for i in range(-500,500):
  for j in range(-500,500):
    if i**5-j**5==x:
      a=i
      b=j
      break
  else:
    continue
  break
print(a,b)
### BUGGY CODE ###

def search_by_find(s1, s2):
    idx = s1.find(s2)
    while idx >= 0:
        yield idx 
        idx = s1.find(s2, idx+1)

def run():
    s1 = input()
    s2 = input()
    for idx in search_by_find(s1, s2):
        print(idx)


if __name__ == '__main__':
    run()



### FIXED CODE ###

class RKSearch:
    shift = 40
    size = 33554393

    def __init__(self, s1, s2):
        self.haystack = self._encode(s1)
        self.needle = self._encode(s2)

    def find(self):
        m, n = len(self.haystack), len(self.needle)
        if m < n:
            return

        h1 = self._hash(self.haystack, n)
        h2 = self._hash(self.needle, n)
        dm = self.shift**(n-1) % self.size

        for i in range(m-n+1):
            if h1 == h2:
                yield i
            if i+n < m:
                h1 = ((h1 - self.haystack[i]*dm) * self.shift
                      + self.haystack[i+n]) % self.size

    def _hash(self, s, length):
        h = 0
        for i in range(length):
            h = (h * self.shift + s[i]) % self.size

        return h

    def _encode(cls, s):
        basea = int.from_bytes(b'a', 'little')
        based = int.from_bytes(b'0', 'little')
        bs = []
        for c in s:
            if c.isdigit():
                bs.append(int.from_bytes(c.encode('utf8'), 'little')-based+27)
            else:
                bs.append(int.from_bytes(c.encode('utf8'), 'little')-basea)

        return bs


def run():
    s1 = input()
    s2 = input()
    rk = RKSearch(s1, s2)
    for i in rk.find():
        print(i)


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

s=str(input())
n=len(s)

a=0
b=0
for i in range(n):
        if i%2==0:
                a+=2**i
        elif i%2==1:
                b+=2**i
a=format(a,'b').zfill(n)
b=format(b,'b').zfill(n)

c=0
d=0
for j in range(n):
        if s[j]==a[j]:
                c+=1
        else:
                d+=1
print(min(c,d))

### FIXED CODE ###

s=str(input())
n=len(s)

a=''
for i in range(n):
        if i%2==0:
                a+='1'
        else:
                a+='0'
c=0
d=0
for j in range(n):
        if s[j]==a[j]:
                c+=1
        else:
                d+=1
print(min(c,d))
### BUGGY CODE ###

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

babies=[(a,i) for i ,a in enumerate(a)]

babies.sort(reverse=True)

dp=[[0]*(n+1) for i in range(n+1)]

ans=0

for l in range(n):
    for r in range(n):
        if l+r==n:
            ans=max(ans,dp[l][r])
            break
        activeness,ind=babies[l+r]
        dp[l+1][r]=max(dp[l+1][r],dp[l][r]+abs(ind-l)*activeness)
        dp[l][r+1]=max(dp[l][r+1],dp[l][r]+abs(ind-(n-1-r))*activeness)

print(ans)

### FIXED CODE ###

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

babies=[(a,i) for i ,a in enumerate(a)]

babies.sort(reverse=True)

dp=[[0]*(n+1) for i in range(n+1)]

ans=0

for l in range(n):
    for r in range(n):
        if l+r==n:
            ans=max(ans,dp[l][r])
            break
        activeness,ind=babies[l+r]
        dp[l+1][r]=max(dp[l+1][r],dp[l][r]+abs(ind-l)*activeness)
        dp[l][r+1]=max(dp[l][r+1],dp[l][r]+abs(ind-(n-1-r))*activeness)

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

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

N = int(input().strip())
A_list = list(map(int, input().rstrip().split()))
B_list = list(map(int, input().rstrip().split()))
C_list = list(map(int, input().rstrip().split()))
#-----

A_list.sort()
B_list.sort()
C_list.sort()


AB_dic={}
for i in A_list:
    AB_dic[i]=[]
    for j in B_list:
        if j > i:
            AB_dic[i].append(j)

BC_dic={}
for i in B_list:
    BC_dic[i]=[]
    for j in C_list:
        if j > i:
            BC_dic[i].append(j)


cnt=0
for v_A in A_list:
    for v_B in AB_dic[v_A]:
        for v_C in BC_dic[v_B]:
            cnt += 1

print(cnt)


### FIXED CODE ###

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

N = int(input().strip())
A_list = list(map(int, input().rstrip().split()))
B_list = list(map(int, input().rstrip().split()))
C_list = list(map(int, input().rstrip().split()))
#-----

A_list.sort()
B_list.sort()
C_list.sort()

cnt=0
for i in B_list:
    ind_A = bisect.bisect_left(A_list, i)
    ind_C = bisect.bisect_right(C_list, i)
    cnt +=  ind_A * (N - ind_C)

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

n = int(input())
a = list(map(int, input().split()))
list1 = []
for i in range(n) :
    list1.append({a[i],i+1})
length1 = len(list1)
list2 = []
for num in list1 :
    if not num in list2 :
        list2.append(num)
length2 = len(list2)
print(length1-length2)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n) :
    if a[a[i]-1] == i + 1 :
        ans += 1
print(ans//2)
### BUGGY CODE ###

n, m  = map(int,input().split())
a = [int(input()) for _ in range(m)]


MOD = 10**9+7
dp = [0]*(n+1)
dp[0] = 1
if not 1 in a:
    dp[1] = 1
for i in range(2, n+1):
    if i in a:
        dp[i] = 0
    else:
        dp[i] = (dp[i-1] + dp[i-2]) % MOD
print(dp[n])

### FIXED CODE ###

n, m  = map(int,input().split())
a = [int(input()) for _ in range(m)]

MOD = 10**9+7

dp = [0]*(n+1)
ng = [False]*(n+1)
for i in a:
    ng[i] = True
    
dp[0] = 1
if not ng[1]:
    dp[1] = 1
for i in range(2, n+1):
    if ng[i]:
        continue
    else:
        dp[i] = (dp[i-1] + dp[i-2]) % MOD
print(dp[n])
### BUGGY CODE ###

# https://atcoder.jp/contests/abc122/tasks/abc122_c
# C - GeT AC

n, q = list(map(int, input().split()))
s = input().split()[0]
lr_list = []

for _ in range(q):
    l, r = list(map(int, input().split()))
    lr_list.append((l, r))

count_ac_list = []
for i in range(n):
    count_ac_list.append(s[:i+1].count('AC'))

# print(count_ac_list)
count_list = []

for l, r in lr_list:
    if l > 1:
        count = count_ac_list[r-1] - count_ac_list[l-1]
    else:
        count = count_ac_list[r-1]
    count_list.append(str(count))

print('\n'.join(count_list))


### FIXED CODE ###

n, q = list(map(int, input().split()))
s = input().split()[0]
lr_list = [list(map(int, input().split())) for _ in range(q)]

count_ac_list = [0] * n
for i in range(n-1):
    # print('{}: {}'.format(i, s[i:i+2]))
    if s[i:i+2] == 'AC':
        count_ac_list[i+1] = count_ac_list[i] + 1
    else:
        count_ac_list[i+1] = count_ac_list[i]

count_list = [str(count_ac_list[r-1] - count_ac_list[l-1]) for l, r in lr_list]

print('\n'.join(count_list))
### BUGGY CODE ###

def resolve():
    N = int(input())
    A = [int(i) for i in input().split()]
    for i in range(N):
        if i > 0:
            print(" ", end="")
        print(A.index(i + 1) + 1, end="")
    print()


resolve()


### FIXED CODE ###

def resolve():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = [0] * N
    for i in range(N):
        ans[A[i] - 1] = i + 1
    print(*ans)


resolve()
### BUGGY CODE ###

k, s = map(int, input().split())
ans = 0
for x in range(k + 1):
    for y in range(k + 1):
        for z in range(k + 1):
            if x + y + z == s:
                ans += 1
print(ans)

### FIXED CODE ###

k, s = map(int, input().split())
ans = 0
for x in range(k + 1):
    for y in range(k + 1):
            if 0 <= s - x - y <=k:
                ans += 1
print(ans)
### BUGGY CODE ###

import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))
n, m, q = map(int, input().split())
vec = [0]
a = []
b = []
c = []
d = []
for _ in range(q):
    i, j, k, l = map(int, input().split())
    a.append(i - 1)
    b.append(j - 1)
    c.append(k)
    d.append(l)
it = a + b
it = list(set(it))
for i in range(m):
    for j in range(len(it) - 1): vec.append(i)
na = []
nb = []
for i in range(q):
    for j in range(len(it)):
        if a[i] == it[j]: na.append(j)
        if b[i] == it[j]: nb.append(j)
ans = 0
for x in combinations(vec, len(it)):
    cnt = 0
    for i in range(q):
        if x[nb[i]] - x[na[i]] == c[i]: cnt += d[i]
    if ans < cnt: ans = cnt
print(ans)

### FIXED CODE ###

from itertools import combinations_with_replacement

n, m, q = map(int, input().split())
a = []
b = []
c = []
d = []
for _ in range(q):
    i, j, k, l = map(int, input().split())
    a.append(i - 1)
    b.append(j - 1)
    c.append(k)
    d.append(l)
it = a + b
it = list(set(it))
na = []
nb = []
for i in range(q):
    for j in range(len(it)):
        if a[i] == it[j]:
            na.append(j)
        if b[i] == it[j]:
            nb.append(j)
ans = 0
for x in combinations_with_replacement(range(1, m+1), len(it)):
    cnt = 0
    for i in range(q):
        if x[nb[i]] - x[na[i]] == c[i]:
            cnt += d[i]
    if ans < cnt:
        ans = cnt
print(ans)
### BUGGY CODE ###

n,q = map(int,input().split())
s = input()
for i in range(q):
    x,y=map(int,input().split())
    ans = 0
    for l in range(x,y):
        if s[l-1]=="A" and s[l]=="C": ans+=1
    print(ans)

### FIXED CODE ###

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

from heapq import heappush, heappop
from collections import defaultdict

N, M = map(int, input().split())
INF = 10**18

edges = defaultdict(set)
C = set()
for _ in range(M):
    fr, to, c = map(int, input().split())
    edges[(fr, c)].add((to, c, 0))
    edges[(to, c)].add((fr, c, 0))

    edges[(fr, c)].add((fr, -1, 0))
    edges[(to, c)].add((to, -1, 0))

    edges[(fr, -1)].add((fr, c, 1))
    edges[(to, -1)].add((to, c, 1))
    C.add(c)

minDist = defaultdict(lambda: INF)
minDist[(1, -1)] = 0
que = [(0, 1, -1)]

while que:
    dist, now, c = heappop(que)

    for to, c, d in edges[(now, c)]:
        if minDist[(to, c)] > dist + d:
            minDist[(to, c)] = dist + d
            heappush(que, (dist + d, to, c))

ans = INF
for c in C:
    ans = min(ans, minDist[(N, c)])
print(ans if ans < INF else -1)


### FIXED CODE ###

from heapq import heappush, heappop, heapify
import sys
input = sys.stdin.buffer.readline

N, M = map(int, input().split())
C = set()

edges = [[] for _ in range(N)]
for _ in range(M):
    fr, to, c = map(int, input().split())
    fr -= 1
    to -= 1
    edges[fr].append((to, c))
    edges[to].append((fr, c))
    C.add(c)

minDist = [10**18] * (N + 1)
minDistList = [set() for _ in range(N)]
minDistList[0] = C

que = [(1, 0, 0)]
while que:
    dist, f, now = heappop(que)

    for to, c in edges[now]:
        d = dist
        if not c in minDistList[now]:
            d += 1
        if minDist[to] > d:
            minDist[to] = d
            minDistList[to] = set()
            heappush(que, (d, f + 1, to))
        if minDist[to] == d:
            minDistList[to].add(c)

for _ in range(2):
    que = [(minDist[i], 0, i) for i in range(N)]
    heapify(que)
    while que:
        dist, f, now = heappop(que)

        for to, c in edges[now]:
            d = dist
            if not c in minDistList[now]:
                d += 1
            if minDist[to] > d:
                minDist[to] = d
                minDistList[to] = set()
                heappush(que, (d, f + 1, to))
            if minDist[to] == d:
                minDistList[to].add(c)

ans = minDist[N - 1]
print(ans if ans < 10**18 else -1)
### BUGGY CODE ###

K, S = [int(v) for v in input().split()]

cnt = 0
for x in range(K + 1):
    for y in range(K + 1):
        for z in range(K + 1):
            if x + y + z == S:
                cnt += 1
print(cnt)
    

### FIXED CODE ###

K, S = [int(v) for v in input().split()]

cnt = 0
for x in range(K + 1):
    for y in range(K + 1):
        if S - (x + y) >= 0 and S - (x + y) <= K:
            cnt += 1
print(cnt)
### BUGGY CODE ###

#!/usr/bin/env python3
a,b,k = map(int,input().split())
for i in range(a,b+1):
    if a <= i <= a+k-1 or b-k+1 <= i <= b: print(i)

### FIXED CODE ###

#!/usr/bin/env python3
a,b,k = map(int,input().split())
for i in range(a,min(b+1,a+k)):
    if a <= i <= a+k-1: print(i)
for i in range(b-k+1,b+1):
    if a+k-1 < i:print(i)
### BUGGY CODE ###

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

def su(n):
  return n*(n+1)/2

maxx = 0
for i in range(n-k+1):
  m = 0
  for j in range(k):
    m += p[i+j]
  if m > maxx:
    maxx = m
    idx = i
s = 0
for i in range(k):
  s += su(p[idx+i])/p[idx+i]
print(s)

### FIXED CODE ###

def main():
    n,k = map(int,input().split())
    p = list(map(int,input().split()))

    for i in range(n):
        p[i]=(p[i]+1)/2
    s = [0]
    for i in range(n):
        s.append(s[i]+p[i])
    m = 0
    for i in range(n-k+1):
        if m<s[i+k]-s[i]:
            m = s[i+k]-s[i]
    print(m)

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

N=int(input())
S=list(input())
ans=0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if k-j==j-i:
                continue
            if not (S[i]==S[j] or S[j]==S[k] or S[i]==S[k]):
                ans+=1
print(ans)

### FIXED CODE ###

N=int(input())
S=input()
totalPattern = S.count("R")*S.count("G")*S.count("B")
for i in range(N-1):
    for j in range(i+1,N):
        k=j+(j-i)
        if k>N-1:
            continue
        if not S[i] == S[j] and not S[i] == S[k] and not S[j] == S[k]:
            totalPattern-=1
print(totalPattern)
### BUGGY CODE ###

def resolve():
    N = int(input())
    A = sorted(list(map(int, input().split())))
    import collections
    counter = collections.Counter(A)
    dp = [True for _ in range(max(A)+1)]
    for a in A:
        if counter[a] > 1:
            dp[a] = False
        for j in range(a+a, max(A)+1, a):
            dp[j] = False
    #print(dp)
    print(sum(1 for a in A if dp[a]))

if '__main__' == __name__:
    resolve()


### FIXED CODE ###

def resolve():
    N = int(input())
    A = sorted(list(map(int, input().split())))
    import collections
    counter = collections.Counter(A)
    maxA = max(A)
    dp = [True for _ in range(max(A)+1)]
    for a in A:
        if counter[a] > 1:
            dp[a] = False
        for j in range(a+a, maxA+1, a):
            dp[j] = False
    #print(dp)
    print(sum(1 for a in A if dp[a]))

if '__main__' == __name__:
    resolve()