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

def main():
    n = int(input())
    count = 0
    for _ in range(n):
        x = int(input())
        if isprime(x) == 1:
            count += 1
    print(count)

def isprime(x: int):    
    if x == 2:
        return 1
    elif x % 2 == 0:
        return 0
    else:        
        for y in range(3, x, 2):
            # 偶数は最初に除外するので、奇数で割れるかだけ見ていく
            if x % y == 0:
                return 0
    return 1

if __name__ == '__main__':
    main()



### FIXED CODE ###

def main():
    A = set()
    n_prime = 0
    while True:
        try:
            x = int(input())
            A.add(x)
        except:
            break

    for x in A:
        n_prime += is_prime(x)

    print(n_prime)


def is_prime(x):  
    if x == 2:
        return 1
    elif x % 2 == 0:
        return 0
    else:
        return pow(2, x - 1, x) == 1   

main()
### BUGGY CODE ###

#ABC 127 C - Prison
from collections import Counter

n, m = map(int, input().split())
gates = []
for i in range(m):
    l, r = map(int, input().split())
    temp_l = range(l-1,r)
    gates.extend(temp_l)

c = Counter(gates)
res = 0
for v in c.values():
    if v == m: res += 1
print(res)

### FIXED CODE ###

n, m = map(int, input().split())
L, R = [], []
for _ in range(m):
    l,r = map(int, input().split())
    L.append(l)
    R.append(r)


res = min(R) - max(L) + 1
if res < 0:
    print(0)
else:
    print(res)
### BUGGY CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N, Q = map(int, input().split())
    S = input()
    for _ in range(Q):
        l, r = map(int, input().split())
        print(S[l - 1:r].count('AC'))


if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N, Q = map(int, input().split())
    S = input()

    ac_count = [0]
    ac = 0
    for i in range(1, N):
        if S[i - 1:i + 1] == "AC":
            ac += 1
        ac_count.append(ac)

    result = []

    for _ in range(Q):
        left, right = map(int, input().split())
        result.append(ac_count[right - 1] - ac_count[left - 1])

    print(*result, sep="\n")


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

import sys
sys.setrecursionlimit(10**5)

def DFS(i):
    if i not in done:
        done.add(i)
        circle.add(i)
        for f in F[i]:
            DFS(f)
    else:
        return

N,M,K=map(int,input().split())
F=[[] for _ in range(N)]
B=[[] for _ in range(N)]

for f in range(M):
    f1,f2=map(int,input().split())
    F[f1-1].append(f2-1)
    F[f2-1].append(f1-1)
for b in range(K):
    b1,b2=map(int,input().split())
    B[b1-1].append(b2-1)
    B[b2-1].append(b1-1)

Group=[]
circle=set()
done=set()
for i in range(N):
    if i not in done:
        DFS(i)
        Group.append(circle)
        circle=set()

ans=[-1 for _ in range(N)]
for i in range(N):
    for j in range(len(Group)):
        if i in Group[j]:
            ans[i]+=len(Group[j])
            break
    for fr in F[i]:
        if fr in Group[j]:
            ans[i]-=1
    for bl in B[i]:
        if bl in Group[j]:
            ans[i]-=1

print(*ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5)

def DFS(i,g):
    if i not in done:
        done.add(i)
        circle.add(i)
        g_list[i]=g
        for f in F[i]:
            DFS(f,g)
    else:
        return

N,M,K=map(int,input().split())
F=[[] for _ in range(N)]
B=[[] for _ in range(N)]

for f in range(M):
    f1,f2=map(int,input().split())
    F[f1-1].append(f2-1)
    F[f2-1].append(f1-1)
for b in range(K):
    b1,b2=map(int,input().split())
    B[b1-1].append(b2-1)
    B[b2-1].append(b1-1)

Group=[]
circle=set()
done=set()
g_list=[0 for _ in range(N)]
g=0
for i in range(N):
    if i not in done:
        DFS(i,g)
        Group.append(circle)
        circle=set()
        g+=1

ans=[-1 for _ in range(N)]
for i in range(N):
    G=g_list[i]
    ans[i]+=len(Group[G])
    for fr in F[i]:
        if fr in Group[G]:
            ans[i]-=1
    for bl in B[i]:
        if bl in Group[G]:
            ans[i]-=1

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

s=input()
l=len(s)

dp = [[0 for i in range(13)] for j in range(l+1)]
dp[0][0] = 1

for i in range(1,l+1):
	num = s[-i]
	keta = pow(10,i-1)
	if num == '?':
		for j in range(10):
			tmp = ( int(j) * keta ) % 13
			for k in range(13):
				index = (tmp + k) % 13
				dp[i][index] += dp[i-1][k]
	else:
		tmp = ( int(num) * keta ) % 13
		for k in range(13):
			index = (tmp + k) % 13
			dp[i][index] += dp[i-1][k]
print(dp[l][5] % (pow(10,9)+7))


### FIXED CODE ###

INF = 10 ** 9 + 7

S = input()
# dp[i][j]はうしろからi桁を13で割った余りがjであるものの個数
dp = [[0] * 13 for _ in range(len(S) + 1)]
dp[0][0] = 1
mul = 1

for i in range(len(S)):
    x = S[-(i + 1)]
    if x == "?":
        for k in range(10):
            for j in range(13):
                dp[i + 1][(mul * k + j) % 13] += dp[i][j]
                dp[i + 1][(mul * k + j) % 13] %= INF
    else:
        k = int(x)
        for j in range(13):
            dp[i + 1][(mul * k + j) % 13] += dp[i][j]
            dp[i + 1][(mul * k + j) % 13] %= INF
    mul = mul * 10 % 13  # 計算量削減のためここで13で割っている

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

import numpy as np
N,K=list(map(int, input().split())) 
P =list(map(int, input().split())) 
e = [sum([ j for j in range(1, P[i]+1)]) / P[i] for i in range(N)]
e_sum = np.cumsum(e)
ans = 0
for i in range(K-1, N):
  if(i == K-1):
    ans = e_sum[i]
  else:
    ans = max([ans, e_sum[i] - e_sum[i-K]])
print(ans)

### FIXED CODE ###

import numpy as np
N,K=list(map(int, input().split())) 
P =list(map(int, input().split())) 
am = np.cumsum(list(range(1, 1000+1)))
e = [am[P[i]-1] / P[i] for i in range(N)]
e_sum = np.cumsum(e)
ans = 0
for i in range(K-1, N):
  if(i == K-1):
    ans = e_sum[i]
  else:
    ans = max([ans, e_sum[i] - e_sum[i-K]])
print(ans)
### BUGGY CODE ###

import sys
from collections import deque
def input(): return sys.stdin.readline().rstrip()
S = deque(input())
rev = False
apdlft = S.appendleft
apd = S.append

for _ in range(int(input())):
    q = input().split()
    if q[0] == '1':
        rev = not(rev)
    else:
        if (q[1]=='1' and rev is False) or (q[1]=='2' and rev is True):
            apdlft(q[2])
        else:
            apd(q[2])

for i in reversed(range(len(S))) if rev else range(len(S)):
    print(S[i], end="")
else:
    print("")

### FIXED CODE ###

import sys
from collections import deque
def input(): return sys.stdin.readline().rstrip()
S = deque(input())
rev = False
apdlft = S.appendleft
apd = S.append

for _ in range(int(input())):
    q = input().split()
    if q[0] == '1':
        rev = not(rev)
    else:
        if (q[1]=='1' and rev is False) or (q[1]=='2' and rev is True):
            apdlft(q[2])
        else:
            apd(q[2])

if rev:
    print((''.join(S))[::-1])
else:
    print(''.join(S))
### BUGGY CODE ###

n, k = list(map(int, input().split()))
s = [0] * k
for i in range(k):
    lr = list(map(int, input().split()))
    s[i] = lr

mod = 998244353
i = 1
dp = [0] * (n+1)
dp[i] = 1
for i in range(n+1):
    for lr in s:
        for d in range(lr[0], lr[1]+1):
            if i+d <= n:
                dp[i+d] += dp[i] % mod

print(dp[n] % mod)


### FIXED CODE ###

# DP, 累積和
n, k = list(map(int, input().split()))
s = list()
for i in range(k):
     l, r = list(map(int, input().split()))
     s.append((l, r))

mod = 998244353
i = 1
dp = [0] * (n+1)
dp[1] = 1
dpsum = [0] * (n+1)
dpsum[1] = 1
for i in range(2, n+1):
    for l, r in s:
        li = i-r
        ri = i-l
        if ri < 1: continue
        li = max(li, 1)
        dp[i] = (dp[i] + dpsum[ri] - dpsum[li-1]) % mod
    dpsum[i] = (dpsum[i-1] + dp[i]) % mod
    
print(dp[n])
### BUGGY CODE ###

from collections import deque

S = list(input())
S = deque(S)
Q = int(input())
query = [input().split() for i in range(Q)]
for i in query:
    if i[0] == '1':
        S.reverse()
    elif i[0]=='2' and i[1]=='1':
        S.appendleft(i[2])
    # elif i[0]=='2' and i[1]=='2':
    else:
        S.append(i[2])
print(''.join(list(S)))

### FIXED CODE ###

from collections import deque

S = list(input())
S = deque(S)
Q = int(input())
reverse = 1
query = [input().split() for i in range(Q)]
for i in query:
    if len(i) == 1:
        reverse *= -1
    elif (i[1]=='1' and reverse == 1) or (i[1]=='2' and reverse==-1):
        S.appendleft(i[2])
    else:
        S.append(i[2])
if reverse == -1:
   S.reverse() 
print(''.join(list(S)))
### BUGGY CODE ###

n, m = map(int, input().split())
l = list()
r = list()
for i in range(m):
    a, b = map(int, input().split())
    l.append(a)
    r.append(b)

ans = 0

for j in range(n):
    flag = 1
    for k in range(m):
        if j < l[k]-1 or j > r[k]-1:
            flag = 0
            break
    if flag == 1:
        ans += 1

print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
l = list()
r = list()
for i in range(m):
    a, b = map(int, input().split())
    l.append(a)
    r.append(b)

if min(r) >= max(l):
    print(min(r) - max(l) + 1)
else:
    print(0)
### BUGGY CODE ###

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

ans = 0

for i in range(N):
    x = 0
    for j in range(i, N):
        x += A[j]
        if x == 0:
            ans += 1

print(ans)

### FIXED CODE ###

from collections import Counter

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

ans = 0

b = [A[0]]

for i in range(1, N):
    b.append(b[-1]+A[i])

cnt = Counter(b)
cnt[0] += 1

for v in cnt.values():
    ans += v*(v-1)//2

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

import math

def prime(x):
    if x==1:
        prime=False
    else:
        prime=True
        for i in range(2,int(math.sqrt(x)+1)):
            if x%i==0:
                prime=False
                break
    return prime

def count_prime(N):    
    if prime(N):
        prime_self=True
        p=[]
    else:
        prime_self=False
        p=[0 for n in range(N//2)]
        end=False
        while N>1 and end==False:
            rtN=int(math.sqrt(N)+1)
            for i in range(2,rtN):
                if N%i==0 and prime(i):
                    p[i]+=1
                    N=N//i
                    break
            if prime(N):
                p[N]+=1
                end=True
    return p,prime_self

def main():
    N=int(input())
    p=count_prime(N)[0]
    cnt=0
    for n in range(len(p)):
        num=1
        while p[n]>=1:
            p[n]-=num
            if p[n]>=0:
                cnt+=1
            num+=1
    if count_prime(N)[1]:
        cnt+=1
    print(cnt)
        
if __name__=="__main__":
    main()

### FIXED CODE ###

import math

def prime(x):
    if x==1:
        prime=False
    else:
        prime=True
        for i in range(2,int(math.sqrt(x)+1)):
            if x%i==0:
                prime=False
                break
    return prime

def count_prime(N):
    p=[0 for n in range(int(math.sqrt(N)+1))]
    
    if prime(N):#初期値が素数の場合
        big_prime=True
        
    else:#初期値が素数でない場合
        big_prime=False
        rtN_init=int(math.sqrt(N)+1)
        
        #素因数分解。ルートＮまでの範囲で素因数を探す。見つかったらpの素因数インデックスを++
        while N>1:
            #素数がルートNを超える場合
            if prime(N) and N>rtN_init:
                big_prime=True
                break
            else:
                for i in range(2,rtN_init):
                    if N%i==0 and prime(i):
                        p[i]+=1
                        N=N//i
                        break
    return p,big_prime

def main():
    N=int(input())
    p,q=count_prime(N)
    cnt=0
    
    for n in range(len(p)):
        num=1
        while p[n]>=1:
            p[n]-=num
            if p[n]>=0:
                cnt+=1
                num+=1
    if q==True:
        cnt+=1
    print(cnt)
        
if __name__=="__main__":
    main()
### BUGGY CODE ###

from collections import Counter
s=input()
n=len(s)
M=[0]*(n+1)
mod=2019
for i in range(n):
	M[n-1-i]=int(s[n-1-i:])%mod
MC=Counter(M)
r=0
for v in MC.values():
	if v>1:
		r+=v*(v-1)//2
print(r)

### FIXED CODE ###

from collections import Counter
s=input()
n=len(s)
M=[0]
mod=2019
for i in range(n):
	m=(M[-1]+int(s[n-1-i])%mod*pow(10,i,mod))%mod
	M.append(m)
MC=Counter(M)
r=0
for v in MC.values():
	if v>1:
		r+=v*(v-1)//2
print(r)
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

MOD = 998244353
MAX_N = 10**7 

fac = [1] + [0] * MAX_N
fac_inv = [1] + [0] * MAX_N
for i in range(1, MAX_N+1):
    fac[i] = fac[i-1] * (i) % MOD
    # Fermat's little theorem says
    # a**(p-1) mod p == 1
    # then, a * a**(p-2) mod p == 1
    # it means a**(p-2) is inverse element
    fac_inv[i] = fac_inv[i-1] * pow(i, MOD-2, MOD) % MOD

def mod_nCr(n, r):
    if n < r or n < 0 or r < 0:
        return 0
    tmp = fac_inv[n-r] * fac_inv[r] % MOD
    return tmp * fac[n] % MOD 
    
def single_mod_nCr(n, r):
    if n < r or n < 0 or r < 0:
        return 0
    if r > n - r:
        r = n - r
    ret = 1
    for i in range(r):
        ret *= n - i
        ret *= pow(i+1, MOD-2, MOD)
        ret %= MOD
    return ret

n = int(input())
ans = 0
for i in range(n//2+1, n+1):
    ans += mod_nCr(n, i) * pow(2, n - i, MOD)
    ans %= MOD
print((pow(3, n, MOD) - ans * 2 + MOD)%MOD)

### FIXED CODE ###

#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

MOD = 998244353
MAX_N = 10**7 

fac = [1] + [0] * MAX_N
fac_inv = [1] + [0] * MAX_N
mod_pow2_n = [1] + [0] * MAX_N
for i in range(1, MAX_N+1):
    fac[i] = fac[i-1] * i % MOD
    mod_pow2_n[i] = mod_pow2_n[i-1] * 2 % MOD

fac_inv[MAX_N] = pow(fac[MAX_N], MOD-2, MOD)
for i in range(MAX_N, 1, -1):
    fac_inv[i-1] = fac_inv[i] * i % MOD

def mod_nCr(n, r):
    if n < r or n < 0 or r < 0:
        return 0
    tmp = fac_inv[n-r] * fac_inv[r] % MOD
    return tmp * fac[n] % MOD 
    
n = int(input())
ans = 0
for i in range(n//2+1, n+1):
    ans += mod_nCr(n, i) * mod_pow2_n[n-i]
    ans %= MOD
print((pow(3, n, MOD) - ans * 2 + MOD)%MOD)
### BUGGY CODE ###

from bisect import bisect_left
n = int(input())
a = list(map(int, input().split()))
a.sort()

def comb(n, k):
    ans = 1
    for i in range(k):
        ans = ans * (n - i) // (i + 1)
    return ans


i = bisect_left(a, a[-1]/2)
ans = comb(a[-1], a[i])
if i > 0:
    if ans > comb(a[-1], a[i-1]):
        print(a[-1], a[i])
    else:
        print(a[-1], a[i-1])
else:
    print(a[-1], a[i])


### FIXED CODE ###

from bisect import bisect_left
n = int(input())
a = list(map(int, input().split()))
a.sort()

def comb(n, k):
    ans = 1
    for i in range(k):
        ans = ans * (n - i) // (i + 1)
    return ans


i = bisect_left(a, a[-1]/2)
if i > 0:
    if abs(a[-1]/2 - a[i]) < abs(a[-1]/2 - a[i-1]):
        print(a[-1], a[i])
    else:
        print(a[-1], a[i-1])
else:
    print(a[-1], a[i])
### BUGGY CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import bisect
import array


def solve():
    n, m, q = map(int, input().split())
    nl = [[] for j in range(n + 1)]
    for e in (input().split() for _ in [0] * m):
        l, r = int(e[0]), int(e[1])
        bisect.insort_left(nl[l], r)
    table = [array.array("i", [0] * (n + 1)) for j in range(n + 1)]
    ran = array.array("i", range(n + 1))
    for i in ran:
        table[i] = [bisect.bisect_right(nl[i], j) for j in ran]

    a = [0] * q
    s = array.array("i", a)
    for i, e in enumerate(input().split() for _ in a):
        l, r = int(e[0]), int(e[1])
        s[i] = sum(table[j][r] - table[j][l - 1] for j in range(l, r + 1))
    print("\n".join(str(e) for e in s))


if __name__ == "__main__":
    solve()


### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import bisect
import array


def solve():
    n, m, q = map(int, input().split())
    nl = [[0 for i in range(n + 1)] for j in range(n + 1)]
    for e in [input().split() for _ in range(m)]:
        l, r = int(e[0]), int(e[1])
        nl[l][r] += 1
    table = [array.array("i", [0] * (n + 2)) for j in range(n + 2)]
    ran = array.array("i", range(n + 1))
    for i in ran:
        for j in ran:
            table[i][j + 1] = table[i][j] + nl[i][j]

    for i, e in enumerate([input().split() for _ in range(q)]):
        l, r = int(e[0]), int(e[1])
        ans = 0
        for j in range(l, r + 1):
            ans += table[j][r + 1] - table[j][l]
        print(ans)


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

# F - LCS
s = input()
t = input()

m = len(s)
n = len(t)

# dp[i][j]: s の i 文字目、 t の j 文字目までを比較したときの LSC の長さ
dp = [[0]*(n+1) for _ in range(m+1)]

# 初期条件
# 0 文字目 (i=0 or j=0) のとき LSC は 0
for i in range(m+1):
    dp[i][0] = 0
for j in range(n+1):
    dp[0][j] = 0

# s の v 文字目について
for v in range(1,m+1):
    # t の w 文字目について
    for w in range(1,n+1):
        # s の v 文字目と t の w 文字目が同じとき
        if s[v-1] == t[w-1]:
            dp[v][w] = dp[v-1][w-1] + 1
        # s の v 文字目と t の w 文字目が異なるとき
        else:
            dp[v][w] = max(dp[v-1][w],dp[v][w-1])

# 文字列を 「復元」
# DP テーブルの値を見ながら、今いるノード (i,j) がどのノードから更新されて来たのかを特定する

# 遡った文字を保持する配列
res = []

# DP テーブルの末端の index
i = m
j = n
while (i>0 and j>0):
    # (i-1, j) -> (i, j) と遷移していた場合 (s[i-1] != t[j-1]) 
    if (dp[i][j] == dp[i-1][j]):
        # DP の遷移を i について 1 遡る
        i -= 1
    else:
        # (i, j-1) -> (i, j) と遷移していた場合 (s[i-1] != t[j-1]) 
        if (dp[i][j] == dp[i][j-1]):
            # DP の遷移を j について 1 遡る
            j -= 1
        # (i-1, j-1) -> (i, j) と遷移していた場合 (s[i-1] == t[j-1]) 
        else:
            # s[i-1] == t[j-1] なので、res.append(t[j-1]) でも良い
            res.append(s[i-1])
            # DP の遷移を遡る
            i -= 1
            j -= 1
            
# res は逆方向から取得したので reverse する
ans = list(reversed(res))
print(''.join(ans))

### FIXED CODE ###

# F - LCS
s = input()
t = input()

m = len(s)
n = len(t)

# dp[i][j]: s の i 文字目、 t の j 文字目までを比較したときの LSC の長さ
dp = [[0]*(n+1) for _ in range(m+1)]

# 初期条件
# 0 文字目 (i=0 or j=0) のとき LSC は 0
for i in range(m+1):
    dp[i][0] = 0
for j in range(n+1):
    dp[0][j] = 0

# s の v 文字目について
for v in range(1,m+1):
    # t の w 文字目について
    for w in range(1,n+1):
        # s の v 文字目と t の w 文字目が同じとき
        if s[v-1] == t[w-1]:
            dp[v][w] = dp[v-1][w-1] + 1
        # s の v 文字目と t の w 文字目が異なるとき
        else:
            dp[v][w] = max(dp[v-1][w],dp[v][w-1])

# 文字列を 「復元」
# DP テーブルの値を見ながら、今いるノード (i,j) がどのノードから更新されて来たのかを特定する

# 遡った文字を保持する配列
res = []

# DP テーブルの末端の index
i = m
j = n
while (i>0 and j>0):
    # (i-1, j) -> (i, j) と遷移していた場合 (s[i-1] != t[j-1]) 
    if (dp[i][j] == dp[i-1][j]):
        # DP の遷移を i について 1 遡る
        i -= 1
    else:
        # (i, j-1) -> (i, j) と遷移していた場合 (s[i-1] != t[j-1]) 
        if (dp[i][j] == dp[i][j-1]):
            # DP の遷移を j について 1 遡る
            j -= 1
        # (i-1, j-1) -> (i, j) と遷移していた場合 (s[i-1] == t[j-1]) 
        else:
            # s[i-1] == t[j-1] なので、res.append(t[j-1]) でも良い
            res.append(s[i-1])
            # DP の遷移を遡る
            i -= 1
            j -= 1
            
# res は逆方向から取得したので reverse する
ans = list(reversed(res))
print(''.join(ans))
### BUGGY CODE ###

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

s = input()
t = input()

if not set(t) <= set(s):
    print(-1)
    exit()

repeat = 0
s_idx = 0
for c in t:
    idx = s[s_idx:].find(c)
    if idx == -1:
        idx = s.find(c)
        repeat += 1
    else:
        idx = idx + s_idx
    s_idx = idx + 1
else:
    ans = repeat * len(s) + s_idx

print(ans)


### FIXED CODE ###

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

from bisect import bisect_left

s = input()
t = input()

if not set(t) <= set(s):
    print(-1)
    exit()

s_dict = {}
for i in range(len(s)):
    c = s[i]
    if c not in s_dict.keys():
        s_dict[c] = [i]
    else:
        s_dict[c].append(i)

repeat = 0
s_idx = 0
for c in t:
    idx = bisect_left(s_dict[c], s_idx)
    if idx == len(s_dict[c]):
        s_idx = s_dict[c][0] + 1
        repeat += 1
    else:
        s_idx = s_dict[c][idx] + 1
else:
    ans = repeat * len(s) + s_idx

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

n = int(input())
s = input()
memo = []
for i in range(10):
  for j in range(10):
    for k in range(10):
      memo.append(str(i) + str(j) + str(k))
ans = 0
for i in memo:
  x = 0
  for j in range(len(s)):
    if i[x] == s[j]:
      x += 1
      if x == 3:
        ans += 1
        break

print(ans)

### FIXED CODE ###

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

num = [0,1,2,3,4,5,6,7,8,9]
memo = []
for i in num:
  for j in num:
    for k in num:
      memo.append(str(num[i]) + str(num[j]) + str(num[k]))

ans = 0

for i in memo:
  x = 0
  for j in range(n):
    if i[x] == s[j]:
      x += 1
      if x == 3:
        break
  if x == 3:
    ans += 1
    
print(ans)
### BUGGY CODE ###

n = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(n):
    A[i] %= (10**9 +7)
for i in range(n-1):
    for j in range(i+1, n):
        ans += A[i]*A[j]
        ans %= (10**9 +7)
print(ans)

### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(n):
    A[i] %= (10**9 +7)
s = sum(A)
for i in range(n-1):
    s -= A[i]
    ans += A[i]*s
print(ans%(10**9 + 7))
### BUGGY CODE ###

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

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

ans = 0

for i in range(n - 1):
    while a[i] + a[i + 1] > x:
        a[i + 1] -= 1
        ans += 1

print(ans)


### FIXED CODE ###

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

cnt, a[0] = sum(a), min(a[0], x)
for i in range(1, n):
    if a[i - 1] + a[i] > x:
        a[i] = x - a[i - 1]
print(cnt - sum(a))
### BUGGY CODE ###


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

tmp = 1
for i in range(n):
    tmp *= A[i] 
if tmp > 10**18:
        tmp = -1
        print(tmp)
        exit()
else:
    print(tmp)




### FIXED CODE ###


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

tmp = 1
A.sort()
#print(A)
if A[0] == 0:
    print(0)
    exit()
for i in range(n):
    tmp *= A[i] 
    if tmp > 10**18:
            tmp = -1
            print(tmp)
            exit()
print(tmp)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
f = [[a, -1] for a in A]
for i in range(N):
    bit = 1<<i
    j = 0
    while j < 1<<N:
        j |= bit
        a, b = f[j]
        c, d = f[j^bit]
        if a < c:
            f[j][0] = c
            f[j][1] = d if d>a else a
        elif b < c:
            f[j][1] = c
        j += 1
Ans = [sum(f[1])]
for a, b in f[2:]:
    Ans.append(max(Ans[-1], a+b))
print("\n".join(map(str, Ans)))


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
f = [[a] for a in A]
for i in range(N):
    for j in range(1<<N):
        if j & 1<<i:
            f[j] = sorted(f[j]+f[j^1<<i], reverse=True)[:2]
Ans = [sum(f[1])]
for a, b in f[2:]:
    Ans.append(max(Ans[-1], a+b))
print("\n".join(map(str, Ans)))
### BUGGY CODE ###

N,M =map(int,input().split())
A = [0] + list(map(lambda x: int(x)%M,input().split()))
for i in range(N):
  A[i+1] = (A[i]+A[i+1])%M
ans = 0
for l in range(N):
  for d in range(N-l):
    if (A[l+d+1]-A[l])%M == 0:
      ans += 1
print(ans)

### FIXED CODE ###

import collections
N,M =map(int,input().split())
A = [0] + list(map(int,input().split()))
for i in range(N):
  A[i+1] = (A[i]+A[i+1])%M
ans = 0
c = collections.Counter(A)
for a in set(A):
  n = c[a]
  ans += int(n*(n-1)/2)
print(ans)
### BUGGY CODE ###

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

import numpy as np
import itertools

P = int(input())
A = [int(x) for x in input().split()]

P,A

one = np.array([1], dtype=np.int64)
arr = [np.array([(-x)%P,1],dtype=np.int64) for x in range(P)]
L = [one] + list(itertools.accumulate(arr[:-1],lambda a,b: np.convolve(a,b) % P))
R = ([one] + list(itertools.accumulate(arr[1:][::-1],lambda a,b: np.convolve(a,b) % P)))[::-1]
X = [np.convolve(A,B) % P for A,B in zip(L,R)]

f = np.zeros(P,dtype=np.int64)
for a,x in zip(A,X):
    if a == 1:
        f -= x

f %= P
print(*f)

### FIXED CODE ###

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

import numpy as np
import itertools

P = int(input())
A = [int(x) for x in input().split()]

# k,i -> i^k
power = np.ones((P,P),dtype = np.int64)
for k in range(1,P):
    power[k] = power[k-1] * np.arange(P,dtype=np.int64) % P

f = np.zeros(P,dtype=np.int64)
for i,a in enumerate(A):
    if a == 1:
        f[0] += 1
        f -= power[:,i][::-1]
f %= P

f %= P
print(*f)