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

#ABC170 D
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
a = list(map(int,readline().split()))
a.sort()

if a[0] == a[-1]: # n=1 やサンプル２のような時
  if n > 1:
    print(0)
  else:
    print(1)
  exit()

if a[0] == 1: #１だけは素因数分解するときにバグるので別で処理
  if a[0] == a[1]:
    print(0)
  else:
    print(1)
  exit()
  
def divisorize(fct): # 約数のリストつくるやつ
    b, e = fct.pop()
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]

def factorize(n): #素因数分解
    fct = []
    b, e = 2, 0
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct
 
 
def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a
    
s = set()
ans = 0
for nm,i in enumerate(a):
  c = set()
  fct = factorize(i)
  for div in divisorize(fct): # 約数の集合を作る
      c.add(num(div))

# 積集合をとり、それが空でかつ同じ数字が並んでない時に答えを加算
  if c&s == set() and ((nm < n-1 and a[nm+1] != i) or nm == n-1): 
    ans += 1
  s.add(i) #今まで見た数の集合を更新

print(ans)

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
a = list(map(int,readline().split()))
a.sort()
if a[0] == a[-1]:
  if n > 1:
    print(0)
  else:
    print(1)
  exit()

if a[0] == 1:
  if a[0] == a[1]:
    print(0)
  else:
    print(1)
  exit()
  
def divisorize(fct):
    b, e = fct.pop()
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]

def factorize(n):
    fct = []
    b, e = 2, 0
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct
 
 
def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a
    
s = set()
if a[0] < a[1]:
  ans = 1
else:
  ans = 0
s.add(a[0])
for nm,i in enumerate(a[1:]):
  c = set()
  fct = factorize(i)
  for div in divisorize(fct):
      c.add(num(div))
  if c&s == set() and ((nm < n-2 and a[nm+2] != i) or nm == n-2):
    ans += 1
  s.add(i)

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

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

import sys
import math
def setwise_coprime(a):
  ans=a[0]
  for i in range(1,n):
    ans=math.gcd(ans,a[i])
  return ans

def erast(n):
  num_set=set()
  prime_set=set()
  for i in range(2,n+1):
    if i not in num_set:
      prime_set.add(i)
      for j in range(i*i,n+1,i):
        num_set.add(j)
  s=list(prime_set)
  return s

def is_prime(n):
  if n==1:
    return False
  if n==2:
    return True
  else:
    for i in range(int(math.sqrt(n))+1):
      if n%i==0:
        return False
    return True
  
check=set()
if setwise_coprime(a)==1:
  s=erast(1000000)
  s.sort()
  for i in range(n):
    if a[i]!=1:
      for j in range(len(s)):
        if a[i]%s[j]==0:
          if s[j] in check:
            print("setwise coprime")
            sys.exit()
          else:
            check.add(s[j])
            
  print("pairwise coprime")    
else:
  print("not coprime")
  
  



      
      
    


### FIXED CODE ###

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

import sys
import math
def setwise_coprime(a):
  ans=a[0]
  for i in range(1,n):
    ans=math.gcd(ans,a[i])
  return ans

#エラストテネスのふるい
def create_sieve(n):
  sieve=[0]*(n+1)
  for i in range(2,n+1):
    if sieve[i]==0:
      for j in range(i*i,n+1,i):
        sieve[j]=i
  return sieve

#高速素因数分解
def fast_factorization(n, sieve):
  prime={}
  while n>1:
    p=sieve[n]
    #nが素数の場合
    if p==0:
      prime[n]=prime.get(n,0)+1
      break
    #nが素数ではない場合
    else:
      prime[p]=prime.get(p,0)+1
      n=n//p
  return prime

check=set()
if setwise_coprime(a)==1:
  #素因数のダブリをcheck
  sieve=create_sieve(10**6)
  for i in range(n):
    if a[i]!=1:
      s=fast_factorization(a[i], sieve)
      for i in s:
        if i in check:
          print("setwise coprime")
          sys.exit()
        else:
          check.add(i)
  print("pairwise coprime")    
else:
  print("not coprime")
### BUGGY CODE ###

def main():
    red_box, green_box, blue_box, target = map(int, input().split())
    answer = 0
    for i in range(target // red_box + 1):
        for j in range(target // green_box + 1):
            now_balls = red_box * i + green_box * j
            if (target - now_balls) % blue_box == 0 and target >= now_balls:
                answer += 1
    print(answer)


if __name__ == '__main__':
    main()



### FIXED CODE ###

def main():
    red_box, green_box, blue_box, target = map(int, input().split())
    answer = 0
    for i in range(target // red_box + 1):
        for j in range(target // green_box + 1):
            now_balls = red_box * i + green_box * j
            if (target - now_balls) % blue_box == 0 and target >= now_balls:
                answer += 1
            elif target < now_balls:
                break
    print(answer)


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

N, W = [int(i) for i in input().split()]
w, v = [0]*N, [0]*N

for i in range(N):
  w[i], v[i] = [int(_) for _ in input().split()]
  
dp = [[0] * (W+1) for _ in range(N+1)]

for i in range(N):
  for j in range(W+1):
    if j - w[i] >= 0:
      dp[i+1][j] = max(dp[i+1][j], dp[i][j - w[i]] + v[i])
    dp[i+1][j] = max(dp[i+1][j], dp[i][j])
      
print(dp[N][W])


### FIXED CODE ###

N, W = [int(i) for i in input().split()]
w, v = [0]*N, [0]*N
 
for i in range(N):
  w[i], v[i] = [int(_) for _ in input().split()]
  
dp = [[0] * (W+1) for _ in range(N+1)]
# dp[i][j] i番目までの荷物で重さがjを超えないように選んだときの価値の最大値
for i in range(N):
  for j in range(W+1):
    dp[i+1][j] = max(dp[i+1][j], dp[i][j])
    if j + w[i] <= W:
      dp[i+1][j+w[i]] = max(dp[i+1][j+w[i]], dp[i][j] + v[i])
      
print(dp[N][W])
### BUGGY CODE ###

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

A, B, C, D = map(int, input().split())

CD = C*D//gcd(C, D)

Cs = A - (A%C)
Ds = A - (A%D)
CDs = A - (A%CD)

count1 = 0
count2 = 0
count3 = 0

while(True):
    if A <= Cs <= B:
        count1 += 1
    elif Cs > B:
        break
    Cs += C

while(True):
    if A <= Ds <= B:
        count2 += 1
    elif Ds > B:
        break
    Ds += D

while(True):
    if A <= CDs <= B:
        count3 += 1
    elif CDs > B:
        break
    CDs += CD

print(B - A + 1 - ((count1 + count2) - count3))

### FIXED CODE ###

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

A, B, C, D = map(int, input().split())

CD = C*D//gcd(C, D)

count1 = (B // C - A // C)
count2 = (B // D - A // D)
count3 = (B // CD - A // CD)

if A % C == 0:
    count1 += 1

if A % D == 0:
    count2 += 1

if A % CD == 0:
    count3 += 1 

print(B - A + 1 - ((count1 + count2) - count3))
### BUGGY CODE ###

n = int(input())
order = list(map(int, input().split()))
result = []
for j in range(n):
  for k in range(n):
    if j+1 == order[k]:
      result.append(k+1)
print(*result)

### FIXED CODE ###

n = int(input())
a = []
for i in sorted(enumerate(list(map(int, input().split())), start=1), key = lambda x :x[1]):
	a.append(i[0])
print(*a)
### BUGGY CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
S = [list(map(int, input().split())) for i in range(M)]
A.sort()
B = []
for i in range(M):
  for j in range(S[i][0]):
    B.append(S[i][1])
B.sort()
for ix in range(min(len(B), N)):
  if A[ix] < B[len(B)-1-ix]:
    A[ix] = B[len(B)-1-ix]
print(sum(A))

### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
D = []
for i in range(M):
  B, C = map(int, input().split())
  D.append([C, B])
D.sort(reverse=True)
E = []
j = 0
for i in range(N):
  if j < M:
    if D[j][1] == 0:
      j += 1
    if j == M:
      E.append(0)
    else:
      E.append(D[j][0])
      D[j][1] -= 1
  else:
    E.append(0)
S = 0
for i in range(N):
  S += max(A[i], E[i])
print(S)
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
s=1
for i in range(n):
  s=s*a[i]
  if s==0:
    break
if s>10**18:
  print(-1)
else:
  print(s)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
s=1
a.sort()
for i in range(n):
  s=s*a[i]
  if s==0:
    break
  if s>10**18:
    break
if s>10**18:
  print(-1)
else:
  print(s)
### BUGGY CODE ###

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

place_of_AC = []
ind = 0

while True:
  ind = s.find("AC", ind)
  # print(ind)
  if ind != -1:
    place_of_AC.append(ind + 1)
    ind += 2
  else:
    break
#print(place_of_AC)
    
for _ in range(q):
  l, r = map(int, input().split(" "))
  out = [x for x in place_of_AC if l <= x < r ]
  print(len(out))

### FIXED CODE ###

import sys

input = sys.stdin.readline

n, q = map(int, input().split(" "))
s = input()
cnt = 0
place_of_AC = [0] * n

for i in range(len(s) - 1):
  place_of_AC[i]=cnt
  if s[i:i+2] == "AC":
    cnt += 1


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

N = int(input())
S = input()
answer = 0


def z_algo(S):
    N = len(S)
    A = [0] * N
    i = 1
    j = 0
    A[0] = l = len(S)
    while i < l:
        while i + j < l and S[j] == S[i + j]:
            j += 1
        if not j:
            i += 1
            continue
        A[i] = j
        k = 1
        while l - i > k < j - A[k]:
            A[i + k] = A[k]
            k += 1
        i += k
        j -= k
    return A


for i in range(1, N - 1):
    cnt = max(z_algo(S[i:])[1:])
    if cnt > answer:
        answer = cnt

print(answer)


### FIXED CODE ###

def z_algorithm(S):
    n = len(S)
    A = [0] * n
    A[0] = n
    L = 0
    R = 0
    # 過去にS[R]まで調べたとする
    for i in range(1, n):
        if R <= i:
            L = R = i
            while R < n and S[R] == S[R - L]:
                R += 1
            A[i] = R - L
        elif A[i - L] < R - i:
            A[i] = A[i - L]
        else:
            L = i
            while R < n and S[R] == S[R - L]:
                R += 1
            A[i] = R - L
    return A


def main():
    N = int(input())
    S = input()
    answer = 0
    for i in range(N):
        a = z_algorithm(S[i:])
        for j in range(1, N - i):
            cnt = min(j, a[j])
            if cnt > answer:
                answer = cnt

    print(answer)


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

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

for i in range(n):
  aa = a[:i]+a[i+1:]
  aa = [0]+aa+[0]
  print(sum([abs(aa[index+1]-aa[index]) for index in range(n)]))

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
aa = [0]+a+[0]
allsum = sum([abs(aa[index+1]-aa[index]) for index in range(n+1)])

for i in range(1,n+1):  
  print(allsum-abs(aa[i]-aa[i-1])-abs(aa[i+1]-aa[i])+abs(aa[i+1]-aa[i-1]))
### BUGGY CODE ###

def add(i,x):
    global BIT
    i+=1
    while i<=n:
        BIT[i] += x
        i += i&(-i)
        
def bitsum(i):
    x = 0
    i+=1
    while i>0:
        x += BIT[i]
        i -= i&(-i)
    return x

def sums(l,r):
    return bitsum(r-1)-bitsum(l-1)

n,q = map(int,input().split())
c = list(map(int,input().split()))
pi = [-1]*(n+1)
ps = [[] for _ in range(n)]
qs = [[] for _ in range(n)]
for i in range(n):
    l = pi[c[i]]
    if l!=-1:
        ps[l].append(i)
    pi[c[i]] = i
for i in range(q):
    l,r = map(int,input().split())
    l,r = l-1,r-1
    qs[l].append((r,i))
BIT = [0]*(n+1)
ans = [None]*q
for x in range(n-1,-1,-1):
    for y in ps[x]:
        add(y,1)
    for r,i in qs[x]:
        ans[i] = r-x+1-bitsum(r)

for i in ans:
    print(i)

### FIXED CODE ###

def add(i,x):
    global BIT
    i+=1
    while i<=n:
        BIT[i] += x
        i += i&(-i)
        
def bitsum(i):
    x = 0
    i+=1
    while i>0:
        x += BIT[i]
        i -= i&(-i)
    return x

def sums(l,r):
    return bitsum(r-1)-bitsum(l-1)

n,q = map(int,input().split())
c = list(map(int,input().split()))
pi = [-1]*(n+1)
ps = [[] for _ in range(n)]
qs = [[] for _ in range(n)]
for i in range(n):
    l = pi[c[i]]
    if l!=-1:
        ps[l].append(i)
    pi[c[i]] = i
for i in range(q):
    l,r = map(int,input().split())
    l,r = l-1,r-1
    qs[l].append((r,i))
BIT = [0]*(n+1)
ans = [None]*q
for x in range(n-1,-1,-1):
    for y in ps[x]:
        add(y,1)
    for r,i in qs[x]:
        ans[i] = r-x+1-bitsum(r)

for i in ans:
    print(i)
### BUGGY CODE ###

import sys
def solve(n,m,a):
    bb = {i+1:[] for i in range(n)}
    for [s1,s2] in a:
        bb[s1].append(s2)
    b = [i for i in bb.values()]
    for i in range(len(b)):
        b[i].sort()
    c = {s2:s1 for [s1,s2] in a}
    d = [s2 for [s1,s2] in a]
    #print(" a=",a,"\n","b=",b,"\n","c=",c,"\n","d=",d)
    ans = ""
    zero = ["00000","0000","000","00","0",""]
    for i in range(m):
        ken = str(c[d[i]])
        ban = str(b[c[d[i]]-1].index(d[i])+1)
        ans += zero[len(ken)-1] + ken
        ans += zero[len(ban)-1] + ban + "\n"
    
    return ans 
def readQuestion():
    ws = sys.stdin.readline().strip().split()
    N = int(ws[0])
    M = int(ws[1])
    ls_PY = [list(map(int, sys.stdin.readline().strip().split())) for j in range(M)]
    return (N, M, ls_PY)

def main():
    N, M, ls_PY = readQuestion()
    answer = solve(N, M, ls_PY)
    print(answer)

if __name__ == '__main__':
    main()

### FIXED CODE ###

N,M=map(int,input().split())
PY=[list(map(int,input().split()))+[i] for i in range(M)] #定義終了
 
PY.sort(key= lambda x:x[1])
num=[0]*N
w=[""]*M
 
for p,y,i in PY:
	num[p-1]+=1
	w[i]=str(p).zfill(6)+str(num[p-1]).zfill(6)

for i in range(M):
  	print(w[i])
### BUGGY CODE ###

#!/usr/bin/env python3
import sys


def solve(N: int, Q: int, S: str, l: "List[int]", r: "List[int]"):
    ans = []
    carray = [0] * N
    for i in range(1,N):
        # print(S[i-1:i+1])
        if(S[i-1:i+1] == 'AC'):
            carray[i:] = map(lambda x:x+1, carray[i:])
    
    # print(carray)
    for i in range(Q):
        # print(carray[l[i]-1:r[i]])
        ans.append(carray[r[i]-1]-carray[l[i]-1])

    for i in range(Q):
        print(ans[i])
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    l = [int()] * (Q)  # type: "List[int]" 
    r = [int()] * (Q)  # type: "List[int]" 
    for i in range(Q):
        l[i] = int(next(tokens))
        r[i] = int(next(tokens))
    solve(N, Q, S, l, r)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys


def solve(N: int, Q: int, S: str, l: "List[int]", r: "List[int]"):
    ans = []
    carray = [0] * N
    for i in range(1,N):
        if(S[i-1:i+1] == 'AC'):
            carray[i] = carray[i-1]+1 
            # carray[i:] = map(lambda x:x+1, carray[i:])
        else:
            carray[i] = carray[i-1]
    # print(carray)
    for i in range(Q):
        # print(carray[l[i]-1:r[i]])
        t = carray[r[i]-1] - carray[l[i]-1]
        ans.append(t)

    for i in range(Q):
        print(ans[i])
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    l = [int()] * (Q)  # type: "List[int]" 
    r = [int()] * (Q)  # type: "List[int]" 
    for i in range(Q):
        l[i] = int(next(tokens))
        r[i] = int(next(tokens))
    solve(N, Q, S, l, r)

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

s = str(input())
num = len(s)
dp = [[0] * 13 for i in range(num+1)]
dp[0][0] = 1
mod = 13
ansmod = 10 ** 9 + 7

for i in range(num):
    if s[i] == "?":
        for j in range(10):
            for k in range(13):
                dp[i+1][(k * 10 +j)%mod] += dp[i][k]
    else:
        for k in range(13):
            dp[i+1][(k * 10 + (int(s[i])))%mod] += dp[i][k]
    for j in range(13):
        dp[i+1][j] %= ansmod
  #    print(dp)
print(dp[num][5])

### FIXED CODE ###

s = str(input())
dp = [[0] * 13 for i in range(len(s)+1)]
dp[0][0] = 1
Naoppy = 1
mod = 13
ansmod = 10 ** 9 + 7
ans = 0
for i in range(len(s)):
    if s[i] == "?":
        for j in range(10):
            for k in range(13):
                dp[i+1][(k * 10 +j)%mod] += dp[i][k]
    else:
        for k in range(13):
            dp[i+1][(k * 10 + (int(s[i])))%mod] += dp[i][k]
    for j in range(13):
        dp[i+1][j] %= ansmod
  #    print(dp)
print(dp[len(s)][5])
### BUGGY CODE ###

def solve2():
    n = int(input())
    s = list(input())
    ans = 0
    for i in range(n):
        if s[i] == "R":
            for j in range(n):
                if s[j] == "G":
                    for k in range(n):
                        if s[k] == "B":
                            if float(k) == (i+j)/2 or float(i) == (j+k)/2 or float(j) == (k+i)/2:
                                pass
                            else:
                                ans += 1
    return ans
print(solve2())

### FIXED CODE ###

n = int(input())
s = list(input())

r = s.count('R')
g = s.count('G')
b = s.count('B')

cnt = 0
for i in range(n):
    for j in range(i+1,n):
        k = j*2-i
        if k >= n:
            break
        elif s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            cnt +=1
print(r*g*b - cnt)
### BUGGY CODE ###

N,M=list(map(int,input().split()))
A=list(map(int,input().split()))
A.sort(reverse=True)

def binary_search(y):
   left_index=-1
   right_index=len(A)

   while(left_index<right_index-1):
      i=(left_index+right_index)//2
      if A[i] >= y:
         left_index=i
      else:
         right_index=i
   return right_index

X=[c for c in range(2*max(A)+1)]
left_index_2=0
right_index_2=len(X)

while left_index_2<right_index_2-1:
   count=0
   j=(left_index_2+right_index_2)//2
   #print("X[j]:",X[j])

   for a in A:
      y=X[j]-a
      #Aの中でy以上の数を数える
      count+=binary_search(y)
   if count > M:
      left_index_2=j
   elif count <= M:
      right_index_2=j

#print(X[left_index_2])
happiness=0
count_2=0
for a in A:
   y=X[left_index_2]-a
   z=binary_search(y)
   #print(z)
   happiness+=sum(A[0:z])+a*z
   count_2+=z

if count_2>M:
   happiness-=X[left_index_2]*(count_2-M)
print(happiness)

### FIXED CODE ###

N, M = map(int, input().split())
a = [10**18] + sorted(map(int, input().split()), reverse=True)


def solve(x):
   count = 0
   j = N
   for i in range(1, N+1):
      while a[i] + a[j] < x:
         j -= 1
      count += j
   
   return count


left, right = 0, 10**18
while left < right - 1:
   mid = (left + right) // 2
   if solve(mid) >= M:
      left = mid
   else:
      right = mid

acc = a[:]
acc[0] = 0
for i in range(N):
   acc[i+1] += acc[i]

ans = 0
j = N
for i in range(1, N+1):
   while a[i] + a[j] < left+1:
      j -= 1
   ans += a[i]*j + acc[j]
   M -= j

if M:
   ans += left * M

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

N = int(input())
A = list(map(int,input().split()))
T = sum(A)
print(T-2*sum(A[1::2]),end=" ")
for i in range(1,N):
    print(T-2*(sum(A[i+1::2])+sum(A[i%2:i-1:2])),end=" ")

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
X = []
X.append(sum(A)-2*sum(A[1::2]))
print(X[0],end=" ")
for i in range(1,N):
    X.append(A[i-1]*2-X[i-1])
    print(X[i],end=" ")
### BUGGY CODE ###

N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
lst = []

for i in range(N):
	if V[i] > C[i]:
		lst.append(V[i] - C[i])
N = len(lst)
  
high_score = 0

if N > 0:

	  
	for i in range(2 ** N):
		a = list(str(bin(i))[2:])
		for k in range(N - len(a)):
			a.insert(0, "0")
		b = list(map(int, a))
		score = 0
		for j in range(len(b)):
			score += lst[j] * b[j]
		if high_score < score:
			high_score = score
		
print(high_score)

### FIXED CODE ###

N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))
lst = []

for i in range(N):
	if V[i] > C[i]:
		lst.append(V[i] - C[i])

print(sum(lst))
### BUGGY CODE ###

from bisect import bisect_left, bisect, insort
def main():
    n = int(input())
    s = list(input())
    q = int(input())
    _is = {chr(i):[] for i in range(ord("a"), ord("a")+27)}
    for i, si in enumerate(s, 1):
        _is[si].append(i)
    for _ in range(q):
        t, i, c = input().split()
        i = int(i)
        if t == "1":
            index = bisect_left(_is[s[i-1]], i)
            _is[s[i-1]].pop(index)
            insort(_is[c], i)
            s[i-1] = c
        else:
            c = int(c)
            cnt = 0
            for _isi in _is.values():
                if _isi:
                    is_in = bisect(_isi, c)-bisect_left(_isi, i)
                    if is_in:
                        cnt += 1
            print(cnt)


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    n = int(input())
    a = ord("a")
    orda = lambda x: ord(x)-a
    s = list(map(orda, list(input())))
    q = int(input())
    bits = [BIT(n) for _ in range(26)]
    for i, si in enumerate(s, 1):
        bits[si].add(i, 1)
    for _ in range(q):
        t, i, c = input().split()
        i = int(i)
        if t == "1":
            bits[s[i-1]].add(i, -1)
            bits[ord(c)-a].add(i, 1)
            s[i-1] = ord(c)-a
        else:
            c = int(c)
            cnt = 0
            for bit in bits:
                is_in = bit.sum_(c) - bit.sum_(i-1)
                if is_in:
                    cnt += 1
            print(cnt)
            
            
class BIT:
    __slots__ = ["length", "data"]
    def __init__(self, length):
        self.data = [0]*(length+1)
        self.length = length
    
    def add(self, i, x):
        while i < self.length+1:
            self.data[i] += x
            i += i&-i
    
    def sum_(self, i):
        x = 0
        while i > 0:
            x += self.data[i]
            i -= i&-i
        return x


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

A,B,K=map(int,input().split())
for i in range(A,B+1):
    if i <A+K or i >B-K:
        print(i)

### FIXED CODE ###

A,B,K=map(int,input().split())
b=min(A+K-1,B)
for i in range(A,b+1):
    print(i)
b2=max(b+1,B-K+1)
for i in range(b2,B+1):
    print(i)
### BUGGY CODE ###

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

b=0

for i in range(n-k+1):
    if b < sum(a[i:i+k]):
        b = sum(a[i:i+k])
    
print((k+b)/2)

### FIXED CODE ###

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

ans = sum(a[:k])
b = ans

for i in range(n-k):
    b = b - a[i] + a[i+k]
    if ans < b:
        ans = b       
    
print((k+ans)/2)
### BUGGY CODE ###

from functools import reduce
from operator import mul
n = int(input())
A = map(int, input().split())
ans = reduce(mul, A)
print(ans if ans <= 10**18 else -1)

### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
if 0 in A:
    print(0)
else:
    bound = 10 ** 18
    ans = 1
    for a in A:
        ans = ans * a
        if ans > bound:
            ans = -1
            break
    print(ans)
### BUGGY CODE ###

n, k = map(int, input().split())
n = abs(n-((n-1)*k))
while True:
    if abs(n - k) > n:
        break
    else:
        n = abs(n - k)
print(n)

### FIXED CODE ###

n, k = map(int, input().split())
ans = 0
while True:
    if n > k:
        i = n // k + 1
        n = abs(n - k*i)
        continue
    elif n == k:
        ans = 0
        break
    elif n < k:
        if abs(n - k) > n:
            ans = n
            break
        else:
            ans = k - n
            break

print(ans)