Harryxun/stf_run huggingface dataset:
import math

def Eratos(n):
	primes = [2]
	num = [2*i+1 for i in range(1,n//2)]
	tmp = []

	top = 1
	while top < math.sqrt(n):
		top = num[0]
		for i in range(1,len(num)):
			if num[i] % top != 0:
				tmp.append(num[i])
		num = tmp
		tmp = []
		primes.append(top)
	for i in range(len(num)):
		primes.append(num[i])
	return primes

n = int(input())
cont = 0
nums = []
for i in range(n):
	a = int(input())
	nums.append(a)
nums.sort()
primes = Eratos(nums[n-1])
for i in range(n):
	if primes.count(num[i])!=0:
		cont += 1
print(cont)


### FIXED CODE ###

import math

def Eratos(n):
	primes = [2]
	num = [2*i+1 for i in range(1,n//2)]
	tmp = []

	top = 1
	while top < math.sqrt(n):
		top = num[0]
		for i in range(1,len(num)):
			if num[i] % top != 0:
				tmp.append(num[i])
		num = tmp
		tmp = []
		primes.append(top)
	for i in range(len(num)):
		primes.append(num[i])
	return primes

n = int(input())
cont = 0
primes = Eratos(10010)
for i in range(n):
	a = int(input())
	if a<10000:
		if primes.count(a)!=0:
			cont += 1
	else:
		for j in range(len(primes)):
			if a%primes[j]==0:
				break
			else:
				if math.sqrt(a)<primes[j]:
					cont += 1
					break
print(cont)
a = int(input())
blue = []
count = []
for i in range(a)
    x = input()
    if x in blue:
        count[blue.index(x)] += 1
    else:
        blue.append(x)
        count.append(1)
b = int(input())
for i in range(b)
    x = input()
    if x in blue:
        count[blue.index(x)] -= 1
    else:
        blue.append(x)
        count.append(-1)

count.sorted()
if count[0] < 0:
    print("0")
else:
    print (count[0])

### FIXED CODE ###

a = int(input())
blue = []
count = []
for i in range(a):
    x = input()
    if x in blue:
        count[blue.index(x)] += 1
    else:
        blue.append(x)
        count.append(1)
b = int(input())
for i in range(b):
    x = input()
    if x in blue:
        count[blue.index(x)] -= 1
    else:
        blue.append(x)
        count.append(-1)

count.sort()
count.reverse()
if count[0] < 0:
    print("0")
else:
    print (count[0])
import functools
print("Even" if functools.reduce(lamda x,y:x*y,map(int,input().split())) %2==0 else "Odd")


### FIXED CODE ###

a,b = map(int, input().split())
if a%2!=0 and b%2!=0:
  print("Odd")
else:
  print("Even")
import numpy as np

n, w = list(map(int, input().split()))
wv = np.array([list(map(int, input().split())) for i in range(n)])

dp = np.zeros((w + 1, n))
dp[w[0, 0]:, 0] = wv[0, 1]
for i in range(1, n):
    dp[:, i] = dp[:, i - 1]
    wNew, vNew = wv[i, 0], wv[i, 1]
    dp[wNew:, :] = np.fmax(dp[wNew:, :], vNew + dp[:-wNew, :])

print(dp[w, n - 1])


### FIXED CODE ###

import numpy as np


def main():
    N, W = list(map(int, input().split(' ')))
    items = np.array([list(map(int, input().split(' '))) for _ in range(N)])
    dp = np.zeros((N, W + 1))
    dp[0, items[0, 0]:] = items[0, 1]
    for n in range(1, N):
        weight, value = items[n, 0], items[n, 1]
        dp[n, :] = dp[n - 1, :]
        dp[n, weight:] = np.fmax(
            dp[n, weight:],
            value + dp[n - 1, :(- weight)]
        )
    print(int(dp[N - 1, W]))


if __name__ == '__main__':
    main()
n = int(input())
*P, = map(int, input().split())
memo = {(n-1, i): i for i in range(P[-1]+1)}
def dfs(pos, t):
    if (pos, t) in memo:
        return memo[pos, t]
    res = memo[pos, t] = dfs(pos+1, max(0, P[pos+1]-t)) + t*2
    return res
print(min(dfs(0, P[0]-i)+i for i in range(P[0]+1)))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
n = int(input())
*P, = map(int, input().split())
memo = {(n-1, i): i for i in range(P[-1]+1)}
def dfs(pos, t):
    if (pos, t) in memo:
        return memo[pos, t]
    res = memo[pos, t] = dfs(pos+1, max(0, P[pos+1]-t)) + t*2
    return res
print(min(dfs(0, P[0]-i)+i for i in range(P[0]+1)))
from fractions import gcd

n, x = map(int, input().split())
x_lis = [abs(int(i)-x) for i in input().split()]

ans = x[0]
for i in range(n):
	ans = gcd(ans, x[i])
	if ans == 1:
		break
print(ans)

### FIXED CODE ###

from fractions import gcd

n, x = map(int, input().split())
x_lis = [abs(int(i)-x) for i in input().split()]

ans = x_lis[0]
for i in range(n):
	ans = gcd(ans, x_lis[i])
	if ans == 1:
		break
print(ans)
a,b = input().split()
number_list =list(range(1,1000))
squared_list =[]
for i in number_list:
        D = i * i
        D = str(D)
        squared_list.append(D)
if C in squared_list:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

a,b = input().split()
C = a + b
number_list =list(range(1,1000))
squared_list =[]
for i in number_list:
        D = i * i
        D2 = str(D)
        squared_list.append(D2)
if C in squared_list:
    print("Yes")
else:
    print("No")
n = int(input())
x = input()

original_pop_count = x.count('1')
one_pop_count = original_pop_count - 1
zero_pop_count = original_pop_count + 1

one_mod = 0
zero_mod = 0
for b in x:
    if one_pop_count != 0:
        one_mod = (one_mod *2 + int(b))%one_pop_count
        zero_mod = (zero_mod *2 + int(b))%zero_pop_count

f = [0]*220001
pop_count = [0]*220000
for i in range(1, 220000):
    pop_count[i] = pop_count[i//2] + i%2
    f[i] = f[i%pop_count[i]] + 1

one_pow2 = [1]*220000
zero_pow2 = [1]*220000
for i in range(1, 220001):
    if one_pop_count != 0:
        one_pow2[i] = one_pow2[i-1] *2 % one_pop_count
        zero_pow2[i] = zero_pow2[i-1] *2 % zero_pop_count

for i in range(n-1, -1, -1):
    if x[n-1-i] == '1':
        if one_pop_count != 0:
            nxt = one_mod
            nxt -= one_pow2[i]
            nxt %= one_pop_count
            print(f[nxt]+1)
        else:
            print(0)

    if x[n-1-i] == '0':
        nxt = zero_mod
        nxt += zero_pow2[i]
        nxt %= zero_pop_count
        print(f[nxt]+1)

### FIXED CODE ###

n = int(input())
x = input()

original_pop_count = x.count('1')
one_pop_count = original_pop_count - 1
zero_pop_count = original_pop_count + 1

one_mod = 0
zero_mod = 0
for b in x:
    if one_pop_count != 0:
        one_mod = (one_mod *2 + int(b))%one_pop_count
    zero_mod = (zero_mod *2 + int(b))%zero_pop_count

f = [0]*220001
pop_count = [0]*220001
for i in range(1, 220001):
    pop_count[i] = pop_count[i//2] + i%2
    f[i] = f[i%pop_count[i]] + 1

one_pow2 = [1]*220001
zero_pow2 = [1]*220001
for i in range(1, 220001):
    if one_pop_count != 0:
        one_pow2[i] = one_pow2[i-1] *2 % one_pop_count
    zero_pow2[i] = zero_pow2[i-1] *2 % zero_pop_count

for i in range(n-1, -1, -1):
    if x[n-1-i] == '1':
        if one_pop_count != 0:
            nxt = one_mod
            nxt -= one_pow2[i]
            nxt %= one_pop_count
            print(f[nxt]+1)
        else:
            print(0)

    if x[n-1-i] == '0':
        nxt = zero_mod
        nxt += zero_pow2[i]
        nxt %= zero_pop_count
        print(f[nxt]+1)
N = int(input())
M = list(map(int,input().split()))

a = N/2

if a%2 == 1:
    a += 0.5
    a = int(a)

for i in range(1,a):
  print(M.count(i))
  
for i in range(a,N+1):
    print(M.count(i))

### FIXED CODE ###

N = int(input())
a = list(map(int,input().split()))
b = [0]*N

for i in range(N-1):
  b[a[i]-1]+=1
  #print(a[i]-1)

for i in range(N):
  print(b[i])
n=int(input())
a=list(map(int, input().split()))

len=sum(a)
len_l=0
for i in range(n):
    if len/2>len_l:
        len_l+=a[i]
    else:
        center=i-1
        break
len_r=len-len_l
len_l-=a[center]

#半分との差
d=len/2-max(len_r,len_l)

print(int(d*2))

### FIXED CODE ###

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

len=sum(a)
len_l=0
for i in range(n):
    if len/2>len_l:
        len_l+=a[i]
    else:
        center=i-1
        break
else:
    center=n-1
    
len_r=len-len_l
len_l-=a[center]
#半分との差
d=len/2-max(len_r,len_l)

print(int(d*2))
s = list(input())
t = list(input())

s.sort()
s=''.join(s)

s.sort()
t.reverse()
t=''.join(t)

if s < t:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

import math
a,b = map(int, input().split())
x = (a + b) / 2
print(math.ceil(x))
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**7)
mod=10**9+7
n=int(input())
edges=[[] for _ in range(n)]
for _ in range(n-1):
    x,y=map(int,input().split())
    edges[x-1].append(y-1)
    edges[y-1].append(x-1)
C=[[] for _ in range(n)]

def fill_C(v,par):
    for c in edges[v]:
        if c==par:
            continue
        C[v].append(c)
        fill_C(c,v)
fill_C(root,-1)

DP=[[-1,-1] for _ in range(n)]

def white(v):
    if DP[v][0]!=-1:
        return DP[v][0]
    res=1
    for c in C[v]:
        res*=white(c)+black(c)
        res%=mod
    DP[v][0]=res
    return res
def black(v):
    if DP[v][1]!=-1:
        return DP[v][1]
    res=1
    for c in C[v]:
        res*=white(c)
        res%=mod
    DP[v][1]=res
    return res

print((black(0)+white(0))%mod)

### FIXED CODE ###

import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**7)
mod=10**9+7
n=int(input())
edges=[[] for _ in range(n)]
for _ in range(n-1):
    x,y=map(int,input().split())
    edges[x-1].append(y-1)
    edges[y-1].append(x-1)
root=-1
l=-1
for i in range(n):
    if len(edges[i])>l:
        root=i
        l=len(edges[i])
C=[[] for _ in range(n)]

def fill_C(v,par):
    for c in edges[v]:
        if c==par:
            continue
        C[v].append(c)
        fill_C(c,v)
fill_C(root,-1)

DP=[[-1,-1] for _ in range(n)]

def white(v):
    if DP[v][0]!=-1:
        return DP[v][0]
    res=1
    for c in C[v]:
        res*=white(c)+black(c)
        res%=mod
    DP[v][0]=res
    return res
def black(v):
    if DP[v][1]!=-1:
        return DP[v][1]
    res=1
    for c in C[v]:
        res*=white(c)
        res%=mod
    DP[v][1]=res
    return res

print((black(root)+white(root))%mod)
mod=[]
answer = 2018
count = 0
sub=0
mod = [int(i) for i in input().split()]
if(i+1==mod[1]):
    answer = (mod[0]*mod[1])%2019

for i in range(mod[0],mod[1]+1):
    for j in range(i+1,mod[1]+1):
        sub = (i*j)%2019
        if sub<answer:
            answer = sub
            print(answer)
    if count == 2018:
        break
    count = count + 1
print(answer)

### FIXED CODE ###

mod=[]
answer = 2018
count = 0
sub=0
mod = [int(i) for i in input().split()]
if(mod[0]==mod[1]):
    answer = (mod[0]*mod[1])%2019

for i in range(mod[0],mod[1]+1):
    if 2019<=mod[1]-mod[0]:
        answer = 0
        break
    for j in range(i+1,mod[1]+1):
        sub = (i*j)%2019
        if sub<answer:
            answer = sub
    if count == 2018:
        break
    count = count + 1
print(answer)
from scipy.special import comb
N,M = (int(x) for x in input().split())
a = int(comb(N, 2)) + int(comb(M, 2))
print(a)

### FIXED CODE ###

from scipy.misc import comb
N,M = (int(x) for x in input().split())
a = comb(N, 2, exact=True) + comb(M, 2, exact=True)
print(a)
n, k = [x for x in input()]
s = input()

s[k-1] = s[k-1].lower()
print(s)

### FIXED CODE ###

n, k = [int(x) for x in input().split()]
s = list(input())

s[k-1] = s[k-1].lower()
s = "".join(s)
print(s)
def H(h, x, y, cx, cy):
    return h + abs(x-cx) + abs(y-cy)
def Hr(h, x, y, cx, cy):
    return max(h-abs(x-cx)-abs(y-cy),0)


N = int(input())
x = [list(map(int, input().split())) for i in range(N)]
for cx in range(0, 101):
    for cy in range(0, 101):
        judge = True
        m = [l for l in range(N) if x[l][2]!=0][0]
        H0 = H(x[m][2], x[m][0], x[m][1], cx, cy)
        for n in range(len(x)):
            Hn = H(x[n][2], x[n][0], x[n][1], cx, cy)
            #print(Hn)
            if(x[n][2] != 0):
                if(Hn == H0):
                    judge = judge and True
                else:
                    judge = judge and False
        if(judge):
            for n in range(len(x)):
                if(x[n][2] == 0):
                    Hr = Hr(H0, x[n][0], x[n][1], cx, cy)
                    if(Hr == 0):
                        judge = judge and True
                    else:
                        judge = judge and False
                
            if(judge):
                print(cx, cy, H0)


### FIXED CODE ###

def H(h, x, y, cx, cy):
    return h + abs(x-cx) + abs(y-cy)
def Hr(h, x, y, cx, cy):
    return max(h-abs(x-cx)-abs(y-cy),0)


N = int(input())
x = [list(map(int, input().split())) for i in range(N)]
for cx in range(0, 101):
    for cy in range(0, 101):
        judge = True
        m = [l for l in range(N) if x[l][2]!=0][0]
        H0 = H(x[m][2], x[m][0], x[m][1], cx, cy)
        for n in range(len(x)):
            Hn = H(x[n][2], x[n][0], x[n][1], cx, cy)
            #print(Hn)
            if(x[n][2] != 0):
                if(Hn == H0):
                    judge = judge and True
                else:
                    judge = judge and False
        if(judge):
            for n in range(len(x)):
                if(x[n][2] == 0):
                    Hm = Hr(H0, x[n][0], x[n][1], cx, cy)
                    if(Hm == 0):
                        judge = judge and True
                    else:
                        judge = judge and False
                
            if(judge):
                print(cx, cy, H0)
N = int(input())
S, T = input().split()
A = ''
 
for i in range(N):
    A += S[i] + T[i]
    
print(A)

### FIXED CODE ###

A = int(input())
B = int(input())
 
print(6-A-B)	#和から誤答を引けば正答
print(D)

### FIXED CODE ###

print('Christmas' + ' Eve' * (25 - int(input())))
from itertools import accumulate
N,W = map(int,input().split())
w = [[] for i in range(4)]
w1,v1 = map(int,input().split())
w[0].append(v1)
for i in range(N-1):
    wi,vi = map(int,input().split())
    w[wi-w1].append(vi)
num = []
for i in range(4):
    w[i].sort(reverse= 1)
    w[i] = [0]+list(accumulate(w[i]))
    num.append(len(w[i]))
ans = 0
for n1 in range(num[0]+1):
    for n2 in range(num[1]+1):
        for n3 in range(num[2]+1):
            for n4 in range(num[3]+1):
                wc = w1*(n1+n2+n3+n4) + n2 + 2*n3 + 3*n4
                if wc <= W:
                    vc = w[0][n1]+w[1][n2]+w[2][n3]+w[3][n4]
                    ans = max(ans,vc)
print(ans)

### FIXED CODE ###

N,W = map(int,input().split())
w = [[] for i in range(4)]
w1,v1 = map(int,input().split())
w[0].append(v1)
for i in range(N-1):
    wi,vi = map(int,input().split())
    w[wi-w1].append(vi)
num = []
for i in range(4):
    w[i].sort(reverse= 1)
    num.append(len(w[i]))
ans = 0
for n1 in range(num[0]+1):
    for n2 in range(num[1]+1):
        for n3 in range(num[2]+1):
            for n4 in range(num[3]+1):
                wc = w1*(n1+n2+n3+n4) + n2 + 2*n3 + 3*n4
                if wc <= W:
                    vc = sum(w[0][:n1])+sum(w[1][:n2])+sum(w[2][:n3])+sum(w[3][:n4])
                    ans = max(ans,vc)
print(ans)
a,b,c=map(int,input().split())
if a<b<c: print("Yes")
elif: print("No")

### FIXED CODE ###

a,b,c=map(int,input().split())
print(('No','Yes')[a<b<c])
n = int(input())
a = list(map(int, input().split()))

ave = round(sum(a)/n)
ans = 0

for _a in a:
    ans += (_a - ave)**2

print(ans1)

### FIXED CODE ###

"""
1 2 3 4 5
1 1 1 1 9   4 4 4 4 36=53 | 1 1 1 1 49
"""
import math
n = int(input())
a = list(map(int, input().split()))

ave1 = math.ceil(sum(a)/n)
ave2 = math.floor(sum(a)/n)
ans1 = 0
ans2 = 0

for _a in a:
    ans1 += (_a - ave1)**2

for _a in a:
    ans2 += (_a - ave2)**2

print(min(ans1, ans2))
W,H,N = map(int,input().split())
bo = [[0]*W]*H
li = [list(map(int,input().split())) for i in range(N)]
for i in range(N):
    if li[i][2] == 1:
        for j in range(li[i][0]):
            bo[i][j] = 1
    elif li[i][2] == 2:
        for j in range(li[i][0],W,1):
            bo[i][j] = 1
    elif li[i][2] == 3:
        for j in range(li[i][1]):
            bo[j] = [1]*W
    else:
        for j in range(H-1,li[i][1]-1,-1):
            bo[j] = [1]*W

sum = 0

for i in range(H):
    sum += bo[i][:].count(1)
print((W*H)-sum)

### FIXED CODE ###

W,H,N = map(int,input().split())
bo = [[0]*W]*H
for i in range(N):
    x,y,z = map(int,input().split())
    if z == 1:
        for j in range(H):
            for k in range(x):
                bo[j][k] = 1
    elif z == 2:
        for j in range(H):
            for k in range(x,W,1):
                bo[j][k] = 1
    elif z == 3:
        for j in range(y):
            bo[j] = [1]*W
    else:
        for j in range(H-1,y-1,-1):
            bo[j] = [1]*W

sum = 0

for i in range(H-1,-1,-1):
    sum += bo[i][:].count(1)
print((W*H)-sum)
n = int(input())

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

s = 1
for i in a:
    s = s*i
if s > 10**18:
    print('-1')
else:
    print(s)

### FIXED CODE ###

n = int(input())

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

s = 1
for i in a:
    s = s*i
    s = min(s,10**18+1)
if s == 10**18+1:
    print('-1')
else:
    print(s)
a,b=map(int,input().split())
s=input()
if s[a]=="-" and (not "-"in s[:a]+s[a+1:])
    print("Yes")
else:
    print("No")

### FIXED CODE ###

a,b=map(int,input().split())
s=input()
if s[a]=="-" and (not "-"in s[:a]+s[a+1:]):
    print("Yes")
else:
    print("No")
#D問題
NM=40
ABM=10
MM=400

N,M1,M2=map(int,input().split())
A=[]
B=[]
C=[]
for i in range(N):
    a,b,c=map(int,input().split())
    A.append(a)
    B.append(b)
    C.append(c)
cmax=max(C)
CM=N*max(C)+1
dp=[[[CM for broop in range(401)] for aroop in range(401)] for nroop in range(NM)]
dp[0][0][0]=0
for i in range(N-1):
    for cb in range(401):
        for ca in range(401):
            if dp[i][ca][cb]==CM:
                continue
            dp[i+1][ca][cb]=min(dp[i+1][ca][cb],dp[i][ca][cb])
            if ca+A[i]<401 and cb+B[i]<401: 
                dp[i+1][ca+A[i]][cb+B[i]]=min(dp[i+1][ca+A[i]][cb+B[i]],dp[i][ca][cb]+C[i])

ans=CM
for cb in range(400):
    CB=cb+1
    for ca in range(400):
        CA=ca+1
        if ca*M2 == cb*M1:
            ans=min(ans,dp[N][CA][CB])

if ans == CM:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

#D問題
NM=40
ABM=10
MM=400

N,M1,M2=map(int,input().split())
A=[]
B=[]
C=[]
for i in range(N):
    a,b,c=map(int,input().split())
    A.append(a)
    B.append(b)
    C.append(c)
cmax=max(C)
CM=N*cmax+10
dp=[[[CM for broop in range(401)] for aroop in range(401)] for nroop in range(N+1)]
dp[0][0][0]=0
for i in range(N):
    for cb in range(401):
        for ca in range(401):
            if dp[i][ca][cb]==CM:
                continue
            dp[i+1][ca][cb]=min(dp[i+1][ca][cb],dp[i][ca][cb])
            if ca+A[i]<401 and cb+B[i]<401:
                dp[i+1][ca+A[i]][cb+B[i]]=min(dp[i+1][ca+A[i]][cb+B[i]],dp[i][ca][cb]+C[i])

ans=CM
for cb in range(400):
    for ca in range(400):
        CB=cb+1
        CA=ca+1
        if CA*M2 == CB*M1:
            ans=min(ans,dp[N][CA][CB])

if ans == CM:
    print(-1)
else:
    print(ans)
import sys
input=sys.stdin.readline
N=int(input())

def dfs(u,par):
  col=1
  for v in graph[u]:
    if col==par:
      col+=1
    color_dic[(u,v)]=col
    dfs(v,col)
    col+=1

elist=[]
graph=[[] for _ in range(N+1)]
for _ in range(N-1):
  a,b=map(int,input().split())
  graph[a].append(b)
  elist.append((a,b))
#print(graph)

color_dic={}
dfs(1,-1)
#print(color_dic)

K=len(set(color_dic.values()))
print(K)
for e in elist:
  print(color_dic[e])

### FIXED CODE ###

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

def dfs(u,par):
  col=1
  for v in graph[u]:
    if col==par:
      col+=1
    color_dic[(u,v)]=col
    dfs(v,col)
    col+=1

elist=[]
graph=[[] for _ in range(N+1)]
for _ in range(N-1):
  a,b=map(int,input().split())
  graph[a].append(b)
  elist.append((a,b))
#print(graph)

color_dic={}
dfs(1,-1)
#print(color_dic)

K=len(set(color_dic.values()))
print(K)
for e in elist:
  print(color_dic[e])
n = int(input())
A = list(map(int, input().split()))
maxA = max(A)
abs_min = 100000
for a in A:
  if abs_min > abs(maxA/2 - a):
    abs_min = abs(maxA/2 - a)
    r = a
print(maxA, r)

### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
maxA = max(A)
abs_min = 10**9
A.remove(maxA)
for a in A:
  if abs_min > abs(maxA/2 - a):
    abs_min = abs(maxA/2 - a)
    r = a
print(maxA, r)
x,y = [int(x) for x in input().split()]
def c(m):
      if (m>=2):
            return m*(m-1)//2
      else:
            return 0
if (x<2 and y<2):
      print(s)
else:
      print(c(x)+c(y))


### FIXED CODE ###

x,y = [int(x) for x in input().split()]
def c(m):
      if (m>=2):
            return m*(m-1)//2
      else:
            return 0
if (x<2 and y<2):
      print(0)
else:
      print(c(x)+c(y))
N,L=map(int,input().split())
S=[]
S_list=[]
for i in range(N):
    S.append(input())
S.sort()
print("".join(S))

### FIXED CODE ###

A,B,C=map(int,input().split())
a=str(A)
b=str(B)
c=str(C) 
s=a+b+c
if s.count("5")==2 and s.count("7")==1:
    print("YES")
else:
    print("NO")
n = int(input())
_s = input()
q = int(input())
query = [input() for _ in range(q)]

def bitsum(_bit, i):
    s = 0
    while i > 0:
        s += _bit[i]
        i -= i & (-i)
    return s

def bitadd(_bit, i, x):
    while i <= n:
        _bit[i] += x
        i += i & (-i)
    return _bit

al = [chr(ord('a') + i) for i in range(26)]
al_to_idx = dict()
for i in range(26):
    al_to_idx[al[i]] = i

s = list(_s).copy()

# init
import math
n_ = int(math.log2(n)) + 1
bit = [[0] * (2 ** n_ + 1) for _ in range(26)]
for i in range(n):
    idx = al_to_idx[s[i]]
    bit[idx] = bitadd(bit[idx], i + 1, 1)
# print(bit)

for i in range(q):
    _query = query[i].split(' ')
    if _query[0] == '1':
        # decrement old
        idx = al_to_idx[s[int(_query[1]) - 1]]
        bit[idx] = bitadd(bit[idx], int(_query[1]), -1)

        s[int(_query[1]) - 1] = _query[2]
        # print(s)

        # increment
        idx = al_to_idx[_query[2]]
        bit[idx] = bitadd(bit[idx], int(_query[1]), 1)

    else:
        _ans = 0
        for idx in range(26):
            _bit = bit[idx]
            c = bitsum(_bit, int(_query[2])) - bitsum(_bit, int(_query[1]) - 1)
            if c != 0:
                _ans += 1
        print(_ans)


### FIXED CODE ###

n = int(input())
_s = input()
q = int(input())
query = [input() for _ in range(q)]

def bitsum(_bit, i):
    s = 0
    while i > 0:
        s += _bit[i]
        i -= i & (-i)
    return s

def bitadd(_bit, i, x):
    while i <= n:
        _bit[i] += x
        i += i & (-i)
    return _bit

al = [chr(ord('a') + i) for i in range(26)]
al_to_idx = dict()
for i in range(26):
    al_to_idx[al[i]] = i

s = list(_s)

# init
import math
n_ = int(math.log(n) / math.log(2)) + 1
bit = [[0] * (2 ** n_ + 1) for _ in range(26)]
for i in range(n):
    idx = al_to_idx[s[i]]
    bit[idx] = bitadd(bit[idx], i + 1, 1)
# print(bit)

for i in range(q):
    _query = query[i].split(' ')
    if _query[0] == '1':
        # decrement old
        idx = al_to_idx[s[int(_query[1]) - 1]]
        bit[idx] = bitadd(bit[idx], int(_query[1]), -1)

        s[int(_query[1]) - 1] = _query[2]
        # print(s)

        # increment
        idx = al_to_idx[_query[2]]
        bit[idx] = bitadd(bit[idx], int(_query[1]), 1)

    else:
        _ans = 0
        for idx in range(26):
            _bit = bit[idx]
            c = bitsum(_bit, int(_query[2])) - bitsum(_bit, int(_query[1]) - 1)
            if c != 0:
                _ans += 1
        print(_ans)
n = int(input())
arr = list(map(int, input().split()))
s = 0
for i in range(0, n, 2):
  if arr[i]%2:ans+=1
print(ans)

### FIXED CODE ###

n = int(input())
arr = list(map(int, input().split()))
ans = 0
for i in range(0, n, 2):
  if arr[i]%2:ans+=1
print(ans)
a,b,c,d=map(int,input().split())
print(max(a*c, a*d, b*c, b*d))

### FIXED CODE ###

x = int(input())

if x == 0:
  print(1)
elif x == 1:
  print(0)
S = int(input())
list=[]
for i in range(N):
    list.append(int(input()))
print(len(set(list)))

### FIXED CODE ###

N=int(input())
list=[int(input()) for i in range(N)]
print(len(set(list)))