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

n = int(input())
s = input()
res = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            current = 0
            require = [str(i), str(j), str(k)]
            for v in s:
                if v == require[current]:
                    current += 1
                    if current == 3:
                        res += 1
                        break
print(res)


### FIXED CODE ###

n = int(input())
s = input()
res = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            current = 0
            require = [str(i), str(j), str(k)]
            for v in s:
                if v == require[current]:
                    current += 1
                    if current == 3:
                        res += 1
                        break
print(res)
### BUGGY CODE ###

# ABC C - Go to school

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

for i in range(1,N+1):
    _list.append(A.index(i) +1 )

for j in range(len(_list)):
    print(_list[j], end = ' ')

print()

### FIXED CODE ###

# ABC C - Go to school


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

for i in range(N):
    Q.append(1)

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

for i in range(N):
    print(Q[i], end = ' ')

print()
### BUGGY CODE ###

n, k, q = map(int, input().split())
a = [int(input()) for _ in range(q)]
for i in range(n):
    print("Yes" if k + a.count(i + 1) - q > 0 else "No")


### FIXED CODE ###

n, k, q = map(int, input().split())
nList = [0] * n
for _ in range(q):
    nList[int(input()) - 1] += 1
for j in range(n):
    print("Yes" if k + nList[j] - q > 0 else "No")
### BUGGY CODE ###

n = int(input())
an = list(map(int, input().split()))
bn = list(set(an))
allcount = 0
for i in bn:
    a = an.count(i)
    allcount += a*(a-1)//2

for i in an:
    print(allcount - (an.count(i)-1))


### FIXED CODE ###

n = int(input())
an = list(map(int, input().split()))
import collections

c = collections.Counter(an)
allcount = 0

for i in c.values():
    allcount += i*(i-1)//2

for i in an:
    print(allcount - (c[i]-1))
### BUGGY CODE ###

x,y,a,b,c=[int(j) for j in input().split()]
p=[int(j) for j in input().split()]
q=[int(j) for j in input().split()]
r=[int(j) for j in input().split()]

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
l=p[:x]+q[:y]
l.sort()
ans=sum(l)
for i in l:
    if r!=[]:
        if i<r[0]:
            ans+=r[0]-i
            del r[0]
        else:
            break
    else:
        break
print(ans)







### FIXED CODE ###

x,y,a,b,c=[int(j) for j in input().split()]
p=[int(j) for j in input().split()]
q=[int(j) for j in input().split()]
r=[int(j) for j in input().split()]
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

p=p[:x]
q=q[:y]
l=p+q
l.sort()
ans=sum(l)
for i in l:
    if i<r[0]:
        ans+=r[0]-i
        del r[0]
        if r==[]:
            break
print(ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
    if i % 2 == n % 2:
        b.append(a[i])
    else:
        b.insert(0, a[i])
print(' '.join(map(str, b)))   

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b1 = []
b2 = []
for i in range(n):
    if i % 2 == 0:
        b1.append(a[i])
    else:
        b2.append(a[i])
if n % 2 == 0:
    b2.reverse()
    b = b2 + b1
else:
    b1.reverse()
    b = b1 + b2
    
print(' '.join(map(str, b)))
### BUGGY CODE ###

R,G,B,N=map(int,input().split())

ans=0
for r in range(N//R+1):
  for g in range(N//G+1):
    b=(N-r*R-g*G)/B
    if b.is_integer() and b>=0:
      ans+=1
      #print(r,g,b)  
print(ans)

### FIXED CODE ###

R,G,B,N=map(int,input().split())

ans=0
for r in range(N//R+1):
  for g in range((N-r*R)//G+1):
    if (N-r*R-g*G)%B==0:
      ans+=1
print(ans)
### BUGGY CODE ###

H,W = map(int,input().split())
HW = [[st for st in input()] for _ in range(H)]
inf = float('inf')
memo = [[inf]*W for _ in range(H)]

def bfs(HW,memo):
    black = []
    for ii in range(H):
        for jj in range(W):
            if HW[ii][jj] == "#":
                black.append((ii,jj))
                memo[ii][jj] = 0
    ans = 0
    while len(black) > 0:
            next = black.pop(0)
            i,j = next
            if 0 <= i - 1:
                if HW[i-1][j] == ".":
                    black.append((i-1,j))
                    HW[i-1][j] = "#"
                    memo[i-1][j] = min(memo[i-1][j],memo[i][j] + 1)
                    if memo[i-1][j] > ans:
                        ans = memo[i-1][j]
            if 0 <= i + 1 < H:
                if HW[i+1][j] == ".":
                    black.append((i+1,j))
                    HW[i+1][j] = "#"
                    memo[i+1][j] = min(memo[i+1][j],memo[i][j] + 1)
                    if memo[i+1][j] > ans:
                        ans = memo[i+1][j]
            if 0 <= j - 1:
                if HW[i][j-1] == ".":
                    black.append((i,j-1))
                    HW[i][j-1] = "#"
                    memo[i][j-1] = min(memo[i][j-1],memo[i][j] + 1)
                    if memo[i][j-1] > ans:
                        ans = memo[i][j-1]
            if j + 1 < W:
                if HW[i][j+1] == ".":
                    black.append((i,j+1))
                    HW[i][j+1] = "#"
                    memo[i][j+1] = min(memo[i][j+1],memo[i][j] + 1)
                    if memo[i][j+1] > ans:
                        ans = memo[i][j+1]
    return ans
print(bfs(HW,memo))

### FIXED CODE ###

h, w = map(int, input().split())
A = [["#"]*(w+2)] + [["#"] + [s for s in input()] + ["#"]
                     for _ in range(h)] + [["#"]*(w+2)]


def main():
    step = 0
    Q = set([])
    for hh in range(1, h + 1):
        for ww in range(1, w + 1):
            if A[hh][ww] == "#":
                if A[hh - 1][ww] == ".":
                    Q.add((hh - 1, ww))
                if A[hh][ww - 1] == ".":
                    Q.add((hh, ww - 1))
                if A[hh + 1][ww] == ".":
                    Q.add((hh + 1, ww))
                if A[hh][ww + 1] == ".":
                    Q.add((hh, ww + 1))
    while len(Q) > 0:
        step += 1
        new = set([])
        for hh, ww in Q:
            A[hh][ww] = "#"
        while len(Q) > 0:
            hh, ww = Q.pop()
            if A[hh - 1][ww] == ".":
                A[hh-1][ww] = "#"
                new.add((hh - 1, ww))
            if A[hh][ww - 1] == ".":
                A[hh][ww-1] = "#"
                new.add((hh, ww - 1))
            if A[hh + 1][ww] == ".":
                A[hh+1][ww] = "#"
                new.add((hh + 1, ww))
            if A[hh][ww + 1] == ".":
                A[hh][ww + 1] = "#"
                new.add((hh, ww + 1))
        Q = new.copy()
    print(step)
    return


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

s = input()
dp = [[0 for i in range(13)] for j in range(len(s)+1)]
dp[0][0] = 1
mod = 10**9+7
for i in range(len(s)):
    if s[i] == "?":
        for j in range(13):
            for k in range(10):
                dp[i+1][(j*10+k)%13] += dp[i][j]
                dp[i+1][(j*10+k)%13] %= mod
    else:
        for j in range(13):
            k = int(s[i])
            dp[i+1][(j*10+k)%13] += dp[i][j]
            dp[i+1][(j*10+k)%13] %= mod

print(dp[len(s)][5])


### FIXED CODE ###

s = input()
dp = [[0 for i in range(13)] for j in range(len(s)+1)]
dp[0][0] = 1
mod = 10**9+7
for i in range(len(s)):
    if s[i] == "?":
        for j in range(13):
            for k in range(10):
                dp[i+1][(j*10+k)%13] += dp[i][j]
                dp[i+1][(j*10+k)%13] %= mod
    else:
        for j in range(13):
            k = int(s[i])
            dp[i+1][(j*10+k)%13] += dp[i][j]
            dp[i+1][(j*10+k)%13] %= mod

print(dp[len(s)][5])
### BUGGY CODE ###

import math
 
d,g = [int(i) for i in input().split()]
P = []
C = []
for i in range(d):
    p,c = [int(i) for i in input().split()]
    P.append(p)
    C.append(c)

# cnt = 0
# def count():
#     global cnt
#     cnt+=1
#     print(cnt)

def flag(point,P,now):
    if point+100*(now+1)*P >= g: return 1
    else: return 0

m = 10**9
def score(point = 0, n = 0, now=-1, done=[]):
    global m
    if m <= n: return
    elif point >= g: m = n
    elif flag(point,P[now],now):
        n += math.ceil((g-point)/(100*(now+1)))
        if m > n: m = n
    else:
        if now == -1:
            for i in range(d):
                done = done[:]
                score(point, n, i, done)
        elif m <= n+P[now]: return
        else:
            done = done[:]
            done.append(now)
            for i in range(d):
                if not i in done:
                    score(point+P[now]*100*(now+1) + C[now], n + P[now], i, done)

score()
print(m)

### FIXED CODE ###

import math
 
d,g = [int(i) for i in input().split()]
P = []
C = []
for i in range(d):
    p,c = [int(i) for i in input().split()]
    P.append(p)
    C.append(c)

# cnt = 0
# def count():
#     global cnt
#     cnt+=1
#     print(cnt)

def flag(point,P,now):
    if point+100*(now+1)*(P-1) >= g: return 1
    elif point+100*(now+1)*P + C[now] >= g: return 2
    else: return 0

m = 10**9
def score(point = 0, n = 0, now=-1, remain = list(range(d))):
    global m
    if m <= n: return
    elif now == -1:
        for i in remain:
            score(point, n, i, remain)
    elif point >= g: m = n
    elif flag(point,P[now],now) == 1:
        n += math.ceil((g-point)/(100*(now+1)))
        if m > n: m = n
    elif flag(point,P[now],now) == 2:
        n += P[now]
        if m > n: m = n
    else:
        if m <= n+P[now]: return
        else:
            remain = remain[:]
            remain.remove(now)
            nxtp = point + P[now]*100*(now+1) + C[now]
            for i in remain:
                score(nxtp, n + P[now], i, remain)

score()
print(m)
### BUGGY CODE ###

# coding:utf-8

import sys
import fractions

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def gcd(x, y):
    if x % y == 0:
        return y
    else:
        x, y = y, x % y
        return gcd(x, y)


def main():
    n = II()
    A = LI()
    A.sort()
    A.reverse()

    pre = [0] * n
    pre[0] = A[0]
    for i in range(1, n):
        pre[i] = fractions.gcd(pre[i - 1], A[i])
    res = pre[-1]
    for i in range(n):
        t = pre[i]
        for j in range(i + 2, n):
            t = fractions.gcd(t, A[j])
        res = max(res, t)

    return res


print(main())


### FIXED CODE ###

# coding:utf-8

import sys
import fractions

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def gcd(x, y):
    if x % y == 0:
        return y
    else:
        x, y = y, x % y
        return gcd(x, y)


def main():
    n = II()
    A = LI()
    A.sort()
    A.reverse()

    pre = [0] * n
    pre[0] = A[0]
    for i in range(1, n):
        pre[i] = gcd(pre[i - 1], A[i])
    res = pre[-1]
    for i in range(n):
        t = pre[i]
        for j in range(i + 2, n):
            t = gcd(t, A[j])
            if t == pre[j - 1]:
                t = -1
                break
        res = max(res, t)

    t = A[1]
    for a in A[1:]:
        t = gcd(t, a)

    return max(res, t)


print(main())
### BUGGY CODE ###

s=int(input())
if s<=10**9:
    print(0,end=" ")
    print(0,end=" ")
    print(1,end=" ")
    print(0,end=" ")
    print(0,end=" ")
    print(s)
else:
    for i in range(10**18-2):
        if s%(i+2)==0 and s//(i+2)<=10**9:
                print(0,end=" ")
                print(0,end=" ")
                print(i+2,end=" ")
                print(0,end=" ")
                print(0,end=" ")
                print(s//(i+2))
                break

### FIXED CODE ###

s=int(input())
x1=0
y1=0
x2=10**9
y2=1
y3=s//(10**9)
x3=s%(10**9)
if x3!=0:
    y3+=1
    x3=x2-x3
print(x1,y1,x2,y2,x3,y3)
### BUGGY CODE ###

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

for i in range(n):
    l1 += a[i] 
    if l1> sum(a)//2:break
r1 = sum(a) - l1
l2 = l1 -a[i]
r2 = sum(a) - l2
ans = min(abs(r1-l1),abs(r2-l2))
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
s = sum(a)
l1 = 0

for i in range(n):
    l1 += a[i] 
    if l1> s//2:break
r1 = s - l1
l2 = l1 -a[i]
r2 = s - l2
ans = min(abs(r1-l1),abs(r2-l2))
print(ans)
### BUGGY CODE ###

n = int(input())
a = [int(i) for i in input().split()]


l = [0] * (max(a)+1)


# for i in a:

#     c = 1
#     while True:
#         if i*c >= max(a):
#             break
#         l[i*c - 1] += 1
#         c += 1



for i in a:
    for j in range(i,max(a)+1, i):
        l[j] += 1



ans = 0

for i in set(a):
    if l[i] == 1:
        ans += 1

print(ans)


### FIXED CODE ###

n = int(input())
A = list(map(int,input().split()))
 
maxA = max(A)
ans = 0
flag = [0]*(maxA+1)
 
# print(flag)
for a in A:
    for ax in range(a,maxA+1,a):
        flag[ax] +=1
 
# print(flag)
for a in set(A):
    if flag[a] == 1:
        ans += 1
print(ans)
### BUGGY CODE ###

import copy
from operator import itemgetter
N, M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(M)]
mid = []
AB.sort()
CD = copy.deepcopy(AB)
CD = sorted(CD, key=itemgetter(1,0),reverse = True)
for ab in AB:
    if ab[0] == 1:
        for  cd in CD:
            if cd[1] == N:
                if ab[1] == cd[0]:
                    print("POSSIBLE")
                    exit()
            else:
                break
    else:
        break
print("IMPOSSIBLE")

### FIXED CODE ###

N, M = map(int,input().split())
AB = []
for _ in range(M):
    a,b = map(int,input().split())
    if  a == 1 or b== N:
        AB.append((a,b))
set1 = set()
set2 = set()
for ab in AB:
    if ab[0] == 1:
        set1.add(ab[1])
    if ab[1] == N:
        set2.add(ab[0])
if set1 & set2:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
### BUGGY CODE ###

n = int(input())
a = list(input().split())
q = int(input())
for i in range(q):
    b, c = input().split()
    replace_a = [i.replace(b, c) if i == b else i for i in a]
    print(sum(map(int, replace_a)))
    a = [str(j) for j in replace_a]


### FIXED CODE ###

from collections import Counter
n = int(input())
a = list(map(int, input().split()))
sum_a = sum(a)
count_a = Counter(a)
q = int(input())
for i in range(q):
    b, c = map(int, input().split())
    tmp = count_a[b]
    new = {c : tmp}
    count_a.update(new)
    del count_a[b]
    sum_a = sum_a - b * tmp + c * tmp
    print(sum_a)
### BUGGY CODE ###

n = int(input())
nums = sorted(list(map(int,input().split())), reverse=True)

res = 1
for i in range(n):
  res = res * nums[i]
  if res <= 10**18 or 0 in nums:
    continue
  else:
    res = -1
    break
    
print(res)


### FIXED CODE ###

n = int(input())
nums = sorted(list(map(int,input().split())), reverse=True)

res = 1

if 0 in nums:
  print(0)
  exit()
  
for i in range(n):
  res = res * nums[i]
  if res <= 10**18 :
    continue
  else:
    res = -1
    break
print(res)
### BUGGY CODE ###

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

frends = []

for i in range(m):
  a,b = map(int, input().split())
  ainclude = set()
  binclude = set()
  flag = False
  for j in frends:
    if a in j:
      if b in j:
        flag = 'Y'
      ainclude = j
      frends.remove(j)
      flag = True
    elif b in j:
      binclude = j
      frends.remove(j)
      flag = True
  if flag == False:
    frends.append({a,b})
  elif flag == 'Y':
    continue
  else:
    c = {a,b}
    frends.append(ainclude|binclude|c)

cnt = 1

for i in frends:
  num = len(i)
  if cnt < num:
    cnt = num


print(cnt)

### FIXED CODE ###

def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def same(x, y):
    return find(x) == find(y)

def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    if par[x] > par[y]:
        x, y = y, x
    par[x] += par[y]
    par[y] = x


N, M = map(int, input().split())
par = [-1 for i in range(N)]

for i in range(M):
    a, b = map(int, input().split())
    unite(a - 1, b - 1)

print(-min(par))
### BUGGY CODE ###

N,K = map(int, input().strip().split(' '))
A = sorted(list(map(int, input().strip().split(' '))), reverse=True)
F = sorted(list(map(int, input().strip().split(' '))))
if sum(A) <= K:
  print(0)
  exit()

ng = 0
ok = max([a*f for a,f in zip(A,F)])
while True:
  if ok-ng < 2: break
  k = int((ng+ok)/2)
  now_cost = 0
  for a,f in zip(A,F):
    while a*f > k:
      a -= 1
      now_cost += 1
    if now_cost > K: break
  if now_cost > K:
    ng = k
  else:
    ok = k
    
print(ok)


### FIXED CODE ###

N,K = map(int, input().strip().split(' '))
A = sorted(list(map(int, input().strip().split(' '))), reverse=True)
F = sorted(list(map(int, input().strip().split(' '))))
if sum(A) <= K:
  print(0)
  exit()

ng = 0
ok = max([a*f for a,f in zip(A,F)])
while True:
  if ok-ng == 1: break
  m = int((ng+ok)/2)
  now_cost = 0
  for a,f in zip(A,F):
    now_cost += max(a-(m//f), 0)
  if now_cost <= K:
    ok = m
  else:
    ng = m
    
print(ok)
### BUGGY CODE ###

from collections import defaultdict
import sys
input = sys.stdin.readline


def factorization(n, primes):
    arr = []
    temp = n
    for i in primes:
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append(i)

    if temp != 1:
        arr.append(temp)

    return arr


def get_sieve_of_eratosthenes_new(n):
    import math
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        raise ValueError('n is more than 2')
    prime = []
    limit = math.sqrt(n)
    data = [i + 1 for i in range(1, n)]
    while True:
        p = data[0]
        if limit <= p:
            return prime + data
        prime.append(p)
        data = [e for e in data if e % p != 0]


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

    primes = get_sieve_of_eratosthenes_new(10**6)
    fact_dict = defaultdict(int)
    for a in A:
        facts = factorization(a, primes)
        for fact in facts:
            fact_dict[fact] += 1

    if not fact_dict.values():
        count = 1
    else:
        count = max(fact_dict.values())
    if count == 1:
        print("pairwise coprime")
    elif count != n:
        print("setwise coprime")
    else:
        print("not coprime")


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline


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

    counts = [0] * (10**6 + 1)
    for a in A:
        counts[a] += 1

    ans = 1
    for i in range(2, 10**6+1):
        co_primes = 0
        for j in range(i, 10**6+1, i):
            co_primes += counts[j]
        if ans < co_primes:
            ans = co_primes

    if ans == 1:
        print("pairwise coprime")
    elif ans < n:
        print("setwise coprime")
    else:
        print("not coprime")


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

import sys
sys.setrecursionlimit(10000000)
n, k = map(int, input().split())
h = [int(input()) for _ in range(n)]
def score(a):
    return max(a) - min(a)

def dfs(i, a):
    if len(a) == k:
        return score(a)

    s = float('inf')
    for x, y in enumerate(h[i:]):
        a.append(y)
        s = min(s, dfs(i + x + 1, a))
        a.pop()
    return s
print(dfs(0, []))

### FIXED CODE ###

import numpy as np
n, k = map(int, input().split())
h = np.array(sorted([int(input()) for _ in range(n)]))
h_roll = np.roll(h, -k + 1)
x = h_roll - h
print(int(x[:-k + 1].min()))
### BUGGY CODE ###

import sys
import itertools
# import numpy as np
import time
import math

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

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

n = int(readline())
L = list(sorted(map(int, readline().split())))

ans = 0
for i in range(n):
    a = L[i]
    for j in range(i + 1, n):
        b = L[j]
        for k in range(j + 1, n):
            c = L[k]
            if a < b + c and b < c + a and c < a + b:
                ans += 1
            else:
                break
print(ans)

### FIXED CODE ###

import sys
import itertools
# import numpy as np
import time
import math

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

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

n = int(readline())
L = list(sorted(map(int, readline().split())))

ans = 0
import bisect
for i in range(n):
    a = L[i]
    for j in range(i + 1, n):
        b = L[j]
        cs = bisect.bisect_left(L, a + b)
        ans += cs - j - 1
print(ans)
### BUGGY CODE ###

n = int(input())
a = [int(_) for _ in input().split()]
const = 10**9 + 7

ans = 0

zero = [0] * 60
one = [0] * 60

for i in range(n):
    for j in range(60):
        if a[i] >> j & 1:
            one[j] += 1
        else:
            zero[j] += 1

ans = 0

for i in range(n):
    j = 0
    while a[i] != 0:
        if a[i] % 2 == 0:
            ans += one[j] * (2**j)
            zero[j] -= 1
        else:
            ans += zero[j] * (2**j)
            one[j] -= 1
        ans %= const
        a[i] //= 2
        j += 1

print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

n = int(input())
a = tuple(map(int,input().split()))
const = 10**9 + 7

ans = 0

zero = [0] * 60
one = [0] * 60

for i in range(60):
    for j in range(n):
        if a[j] >> i & 1:
            one[i] += 1
        else:
            zero[i] += 1

ans = 0

for i in range(60):
    ans += one[i] * zero[i] * 2**i
    ans %= const

print(ans)