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

#!/usr/bin/env python
from math import sqrt

def gen_primes(X):
    is_prime = [True for _ in range(0, X+1)]
    is_prime[0] = False
    is_prime[1] = False
    primes = []
    for n in range(2, int(sqrt(X))):
        if is_prime[n]:
            primes.append(n)
            j = n*2
            while j <= X:
                is_prime[j] = False
                j += n
    primes.extend([x for x in range(int(sqrt(X)), X+1) if is_prime[x]])
    return primes


def solve(N, A):
    primes = gen_primes(10**6)
    C = [0] * len(primes)

    for a in A:
        for i, p in enumerate(primes):
            if a < p:
                break
            if a % p == 0:
                C[i] += 1
    M = max(C)
    #print(A)
    #print(M)
    if M <= 1:
        print("pairwise coprime")
    elif M != N:
        print("setwise coprime")
    else:
        print("not coprime")
    
N = int(input())
A = [int(x) for x in input().split()]
solve(N, A)


### FIXED CODE ###

#!/usr/bin/env python
from math import sqrt
from collections import Counter

def gen_primes(X):
    D = [0] * (X+1)
    is_prime = [True for _ in range(0, X+1)]
    is_prime[0] = False
    is_prime[1] = False
    primes = []
    for n in range(2, int(sqrt(X))+1):
        if is_prime[n]:
            primes.append(n)
            j = n*2
            D[n] = n
            while j <= X:
                is_prime[j] = False
                if D[j] == 0:
                    D[j] = n
                j += n
    for n in range(int(sqrt(X)), X+1):
        if is_prime[n]:
            D[n] = n
            primes.append(n)
    return primes, D


def solve(A):
    N = len(A)
    primes, D = gen_primes(10**6)
    C = [0] * (primes[-1]+1)

    for a in A:
        a_ = a
        while a > 1:
            d = D[a]
            while a % d == 0:
                a //= d
            C[d] += 1
        
    M = max(C)
    if M <= 1:
        print("pairwise coprime")
    elif M != N:
        print("setwise coprime")
    else:
        print("not coprime")

#solve([x for x in range(1, 10**6+1)])
N = int(input())
A = [int(x) for x in input().split()]
solve(A)
### BUGGY CODE ###

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

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

def lcm(x, y):
    return x * y // gcd(x, y)

law = 10 ** 9 + 7
ans = 0
l = a[0]
for x in a:
    r = lcm(l, x)
    ans = (ans * (r // l) + (r // x)) % law
    l = r
print(ans)

### FIXED CODE ###

MAX_PRIME = 10**3
is_prime = [1] * MAX_PRIME
primes = []
is_prime[0] = 0
is_prime[1] = 0
for i in range(MAX_PRIME):
    if is_prime[i]:
        primes.append(i)
        for j in range(2, ((MAX_PRIME-1)//i) + 1):
            is_prime[i*j] = 0

def factorization(n):
    factor = {}
    for p in primes:
        if p ** 2 > n:
            break
        while n % p == 0:
            n //= p
            if p not in factor:
                factor[p] = 1
            else:
                factor[p] += 1
    if n > 1:
        factor[n] = 1
    return factor
def extGCD(a, b):
    if b == 0:
        return a, 1, 0
    g, y, x = extGCD(b, a%b)
    y -= a//b * x
    return g, x, y
def moddiv(a, b):
    _, inv, _ = extGCD(b, law)
    return a * inv % law

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

ans = 0
l = {}
lmod = 1
law = 10 ** 9 + 7
for x in a:
    fx = factorization(x)
    for p, c in fx.items():
        if p not in l:
            ans *= p ** c
            lmod *= p ** c
            ans %= law
            lmod %= law
            l[p] = c
        elif c > l[p]:
            ans *= p ** (c - l[p])
            lmod *= p ** (c - l[p])
            ans %= law
            lmod %= law
            l[p] = c
    b = moddiv(lmod, x)
    ans += b
    ans %= law
print(ans)
### BUGGY CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  s=i-min(k,i)
  l+=[min(l[j]+abs(b-a[j])for j in range(s,i))]
print(l[-1])

### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[0]
for i in range(1,n):
  b=a[i]
  l.append(min(l[j]+abs(b-a[j])for j in range(i-min(k,i),i)))
print(l[-1])
### BUGGY CODE ###

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

if __name__ == "__main__":
	H, W, D = list(map(int, input().split()))
	masu_d = {}
	for i in range(H):
		inputs = list(map(int, input().split()))
		for j in range(W):
			masu_d[inputs[j]] = [i, j]

	Q = int(input())
	L = []
	R = []
	for i in range(Q):
		l, r = list(map(int, input().split()))
		L.append(l)
		R.append(r)
	# 総和計算開始
	for i in range(Q):
		ans = 0
		now_l = L[i]
		while 1:
			if now_l == R[i]:
				print(int(ans))
				break
			next_l = now_l + D
			ans += math.fabs(masu_d[now_l][0]-masu_d[next_l][0]) + math.fabs(masu_d[now_l][1]-masu_d[next_l][1])
			now_l = next_l


### FIXED CODE ###

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

if __name__ == "__main__":
	H, W, D = list(map(int, input().split()))
	masu = {}
	for i in range(H):
		inputs = list(map(int, input().split()))
		for j in range(W):
			masu[inputs[j]] = [i, j]

	Q = int(input())
	L = []
	R = []
	for i in range(Q):
		l, r = list(map(int, input().split()))
		L.append(l)
		R.append(r)
	# i=D+1 ~ H*W の累積和Sを求める
	S = [0] * (H*W+1)
	for i in range(D+1, H*W+1):
		S[i] = S[i-D] + abs(masu[i][0]-masu[i-D][0]) + abs(masu[i][1]-masu[i-D][1])
	# 回答する
	for i in range(Q):
		print(S[R[i]] - S[L[i]])
### BUGGY CODE ###

def func():
    a,b = (int(i) for i in input().split())
    if(a>b):
        a,b = b,a
    ans = 1
    
    if(a%2==0 and b%2==0):
        ans += 1
       
    for j in range(3,a+1,2):
        if(a%j==0 and b%j==0):
            a = a // j
            b = b // j
            ans += 1
            
    return ans


print(func())

### FIXED CODE ###

import math
def func(num):
    lists = []
    root = math.floor(math.sqrt(num))
    
    while(num%2==0):
        num = num // 2
        if(num%2!=0):
            lists.append(2)
            
    for j in range(3,root+2,2):
        while(num%j==0):
            num = num //j
            if(num%j!=0):
                lists.append(j)
        if(num==1):
            break

    if(num>2):
        lists.append(num)
    return lists

if __name__ == "__main__":
    a,b = (int(i) for i in input().split())
    
    lists1 = func(a)
    lists2 = func(b)
    
    ans = set(lists1) & set(lists2)
    print(len(ans)+1)
### BUGGY CODE ###

def main():
    ans = 1
    for a in A:
        ans *= a
    if ans > L:
        print(-1)
    else:
        print(ans)


if __name__ == "__main__":
    N = int(input())
    A = [int(a) for a in input().split()]
    L = 10**18
    main()


### FIXED CODE ###

def main():
    if A.count(0) >= 1:
        print(0)
        return
    ans = 1
    for a in A:
        ans *= a
        if ans > L:
            print(-1)
            return
    print(ans)


if __name__ == "__main__":
    N = int(input())
    A = [int(a) for a in input().split()]
    L = 10**18
    main()
### BUGGY CODE ###

import bisect

n = int(input())
a_li = list(map(int, input().split()))
b_li = list(map(int, input().split()))
c_li = list(map(int, input().split()))

b_li.sort()
c_li.sort()

ans = 0

for i in a_li:
    s = bisect.bisect_right(b_li, i)
    
    for j in b_li[s:]:
        t = bisect.bisect_right(c_li, j)
        ans += n-t
        
print(ans)

### FIXED CODE ###

import bisect

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

a.sort()
b.sort()
c.sort()

ans = 0

for middle in b:
    tmp1 = bisect.bisect_left(a, middle)
    tmp2 = bisect.bisect_right(c, middle)
    ans += tmp1 * (n - tmp2)

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

n = int(input())
al = []
for _ in range(n):
    a = int(input())
    if a in al:
        al.remove(a)
    else:
        al.append(a)
    
print(len(al))

### FIXED CODE ###

n = int(input())
al = []
for _ in range(n):
    a = int(input())
    al.append(a)

al = sorted(al)
ans = 0

before = 0
for a in al:
    if before == a:
        ans -= 1
        before = 0
    else:
        ans += 1
        before = a
    
print(ans)
### BUGGY CODE ###

def ans_xyz(x, y, z):
    return ((x ** 2) + (y ** 2) + (z ** 2) + (x * y) + (y * z) + (z * x))

N = int(input())
for n in range(1 , N + 1):
    ans = 0
    for x in range(1, 101):
        xxx = ans_xyz(x, x, x)
        if xxx > n:
            break
        elif xxx == n:
            ans += 1
            break
        for y in range(x + 1, 101):
            xxy = ans_xyz(x, x, y)
            if xxy > n:
                break
            elif xxy == n:
                ans += 3
                break
            xyy = ans_xyz(x, y, y)
            if xyy > n:
                continue
            elif xyy == n:
                ans += 3
                continue
            for z in range(y + 1, 101):
                if ans_xyz(x, y, z) > n:
                    break
                elif ans_xyz(x, y, z) == n:
                    ans += 6
                    break
    print(ans)



### FIXED CODE ###

def ans_xyz(x, y, z):
    return ((x ** 2) + (y ** 2) + (z ** 2) + (x * y) + (y * z) + (z * x))

N = int(input())
ans = [0] * (10 ** 5)
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            ans[ans_xyz(x, y, z)] += 1
print(*ans[1:N + 1], sep='\n')
### BUGGY CODE ###

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

h = []
for i in range(N):
    h.append(int(input()))

h_sort = sorted(h)

h_sort_diff = []

for i in range(len(h_sort) - 1):
    tmp = h_sort[i + 1] - h_sort[i]
    h_sort_diff.append(tmp)

ans = []
for i in range(len(h_sort_diff) - (K - 2)):
    tmp = 0
    for j in range(K - 1):
        tmp += h_sort_diff[i + j]
    ans.append(tmp)

print(min(ans))

### FIXED CODE ###

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

h = []
for _ in range(N):
    h.append(int(input()))

h.sort()
minimum = h[N - 1]- h[0]

for i in range(N - K + 1):
    minimum = min(minimum, h[i + K - 1] - h[i])
print(minimum)
### BUGGY CODE ###

from fractions import gcd
from functools import reduce

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

result = 1
previous_gcd = 0
for i, a in enumerate(A):
    # print("a", a)
    result = max(result, gcd(previous_gcd, reduce(gcd, A[i+1:] + [0])))
    previous_gcd = gcd(previous_gcd, a)
    # print("---")

print(result)


### FIXED CODE ###

from fractions import gcd
from sys import exit

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

l_gcd_list = [0]
r_gcd_list = [0]
for i in range(N):
    l_gcd_list.append(gcd(l_gcd_list[i], A[i]))
    r_gcd_list.append(gcd(r_gcd_list[i], A[-(i+1)]))
r_gcd_list = r_gcd_list[::-1]
# print(l_gcd_list)
# print(r_gcd_list)

results = []
for i in range(N):
    results.append(gcd(l_gcd_list[i], r_gcd_list[i+1]))

print(max(results))
### BUGGY CODE ###

def Serch():
    unit = [2001]
    for j in Tree:
        for i in range(1, n):
            if G[j][i] != -1 and i not in Tree:
                unit.append(G[j][i])
    for j in Tree:
        for i in range(1, n):
            if G[j][i] == min(unit) and i not in Tree:
                ans.append(int(G[j][i]))
                Tree.append(i)
                Serch()
                break


n = int(input())
G = []
for i in range(n):
    G.append(input().split())
    for j in range(len(G[i])):
        G[i][j] = int(G[i][j])

ans = []
Tree = [0]
Serch()
print(sum(ans))

### FIXED CODE ###

n = int(input())
G = []
for i in range(n):
    G.append(input().split())
    for j in range(len(G[i])):
        G[i][j] = int(G[i][j])

ans = 0
mincost = [2001] * n
flag = [0] * n
mincost[0] = 0
while True:
    v = -1
    for j in range(n):
        if flag[j] != 1 and (v == -1 or mincost[j] < mincost[v]):
            v = j
    if v == -1:
        break
    flag[v] = 1
    ans += mincost[v]
    for j in range(n):
        if G[v][j] == -1: continue
        mincost[j] = min(mincost[j], G[v][j])

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

import copy

def main():
    N = int(input())
    A = [list(map(int, input().split())) for i in range(N)]
    
    ans = 0
    finish = False
    base_used = [True] + [False] * N
    count = 0
    
    while not finish and count != N:
        finish = True
        ans += 1
        used = copy.deepcopy(base_used)
        
        for idx, u in enumerate(used):
            if not u:
                a = A[idx-1][0]
                if not used[a] and A[a-1][0] == idx:
                    for x in [idx, a]:
                        used[x] = True
                        A[x-1].pop(0)
                        
                        if not A[x-1]:
                            base_used[x] = True
                            count += 1
                    finish = False     
    
    if N != count:
      ans = -1
    print(ans)
    
if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys

input = sys.stdin.readline

def main():
    N = int(input())
    
    Id = {}
    
    cur = 0
    for i in range(1, N+1):
        for j in range(i+1, N+1):
            Id[(i,j)] = cur
            cur += 1
            
    G = [[] for i in range(N*(N-1)//2)]
    size = [0] * (N*(N-1)//2)
    
    for i in range(1, N+1):
        for idx, j in enumerate(list(map(int, input().split()))):
            if i < j: k = Id[(i, j)]
            else: k = Id[(j, i)]
            if idx: 
                G[par].append(k)
                size[k] += 1
            par = k
            
    g = [idx for idx, s in enumerate(size) if s == 0]
    
    ans = 0
    while g:
        ans += 1
        n_g = []
        
        for v in g:
            length = len(G[v])
            if not length: continue
            
            size[G[v][0]] -= 1
            if not size[G[v][0]]: n_g.append(G[v][0])
    
            if length == 2:
                size[G[v][1]] -= 1
                if not size[G[v][1]]: n_g.append(G[v][1])
        g = n_g
        
    for s in size:
        if s != 0:
            print(-1)
            sys.exit()
    print(ans)
            
if __name__ == '__main__':
    main()
### BUGGY CODE ###

from collections import Counter
h = int(input())
if h == 1:
	print(1)
	exit()
a = list(map(int,input().split()))
t = Counter(a)
b = []
for i, j in t.most_common():
	if j == 1:
		b.append(i)
bset = set(a)

def makediv(n):
	if n==1: return []
	lower_divisors , upper_divisors = [1], []
	i = 2
	while i*i <= n:
		if n % i == 0:
			lower_divisors.append(i)
			if i != n // i:
				upper_divisors.append(n//i)
		i += 1
	return lower_divisors + upper_divisors[::-1]

ans = 0
for i in b:
	t=makediv(i)
	mode = 1
	for l in t:
		if l in bset:
			mode = 0
			break
	if mode:
		ans += 1
print(ans)

### FIXED CODE ###

import itertools
from collections import Counter
h = int(input())
if h == 1:
	print(1)
	exit()
a = list(map(int,input().split()))
t = Counter(a)
b = []
for i, j in t.most_common():
	if j == 1:
		b.append(i)
bset = set(a)

def sieve(n):
	ret = []
	divlis = [-1]*(n+1)  # 何で割ったかのリスト(初期値は-1)
	flag = [True]*(n+1)
	flag[0] = False
	flag[1] = False
	ind = 2
	while ind <= n:
		if flag[ind]:
			ret.append(ind)
			ind2 = ind**2
			while ind2 <= n:
				flag[ind2] = False
				divlis[ind2] = ind
				ind2 += ind
		ind += 1
	#何で割ったかのリストを取得したいとき, divlisも出力する
	return ret

k = sieve(1000)

def pfact(m):
	pf = {}
	cnt = 0
	i = k[cnt]
	st = len(k)
	while m > 1 and cnt < st:
		i = k[cnt]
		while m%i == 0:
			pf[i] = pf.get(i,0) + 1
			m //= i
		cnt += 1
	if m>1 : pf[m]=1
	return pf

def makediv(n):
	s = pfact(n)
	k = [range(i+1) for i in s.values()]
	ansl = []
	for i in itertools.product(*k):
		ans = 1
		for n, j in enumerate(s.keys()):
			ans *= (j**i[n])
		ansl.append(ans)
	ansl.sort()
	return ansl

ans = 0
for i in b:
	t=makediv(i)
	t.remove(i)
	mode = 1
	for l in t:
		if l in bset:
			mode = 0
			break
	if mode:
		ans += 1
print(ans)
### BUGGY CODE ###

n = int(input())
l = list(map(int,input().split()))
m = 0

for i in range(n - 2):
    for j in range(n - i - 2):
        for k in range(n - i - j - 2):
            if l[i] < l[j + i + 1] + l[k + j + i + 2] and l[j + i + 1] < l[k + j + i + 2] + l[i] and l[k + j + i + 2] < l[i] + l[j + i + 1]:
                m += 1
                
print(m)

### FIXED CODE ###

import bisect

n = int(input())
l = sorted(list(map(int, input().split())))
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        a = bisect.bisect_left(l, l[i] + l[j]) - j - 1
        ans += a
print(ans)
### BUGGY CODE ###

H, W=map(int, input().split())
A=[list(map(int, input().split())) for _ in range(H)]
B=[list(map(int, input().split())) for _ in range(H)]
AB=[[abs(A[i][j]-B[i][j]) for j in range(W)] for i in range(H)]

G=[[[0]*(80*162) for j in range(W)] for i in range(H)]
G[0][0][AB[0][0]]=1
  
from collections import deque

def f(data):
  i=data[0]
  j=data[1]
  owari=(i+j+1)*80+1
  if i<H-1 and j<W-1:
    for k in range(owari):
      if G[i][j][k]>0:
        G[i+1][j][k+AB[i+1][j]]=1
        G[i+1][j][abs(k-AB[i+1][j])]=1
        G[i][j+1][k+AB[i][j+1]]=1
        G[i][j+1][abs(k-AB[i][j+1])]=1
    q.append([i+1, j])
    q.append([i, j+1])
  elif i>=H-1 and j<W-1:
    for k in range(owari):
      if G[i][j][k]>0:
        G[i][j+1][k+AB[i][j+1]]=1
        G[i][j+1][abs(k-AB[i][j+1])]=1
    q.append([i, j+1])
  elif i<H-1 and j>=W-1:
    for k in range(owari):
      if G[i][j][k]>0:
        G[i+1][j][k+AB[i+1][j]]=1
        G[i+1][j][abs(k-AB[i+1][j])]=1
    q.append([i+1, j])
    
q=deque()
q.append([0, 0])
while len(q)>0:
  data=q.popleft()
  f(data)
  
out=0
while G[-1][-1][out]==0:
  out+=1
print(out)

### FIXED CODE ###

H, W=map(int, input().split())
A=[list(map(int, input().split())) for _ in range(H)]
B=[list(map(int, input().split())) for _ in range(H)]
AB=[[abs(A[i][j]-B[i][j]) for j in range(W)] for i in range(H)]

G=[[[0]*(80*162) for j in range(W)] for i in range(H)]
G[0][0][AB[0][0]]=1
sumi=[[0]*W for i in range(H)]
  
from collections import deque

def f(data):
  i=data[0]
  j=data[1]
  owari=(i+j+1)*80+1
  if i<H-1 and j<W-1:
    for k in range(owari):
      if G[i][j][k]>0:
        G[i+1][j][k+AB[i+1][j]]=1
        G[i+1][j][abs(k-AB[i+1][j])]=1
        G[i][j+1][k+AB[i][j+1]]=1
        G[i][j+1][abs(k-AB[i][j+1])]=1
    if sumi[i+1][j]==0:
      q.append([i+1, j])
      sumi[i+1][j]=1
    if sumi[i][j+1]==0:
      q.append([i, j+1])
      sumi[i][j+1]=1
  elif i>=H-1 and j<W-1:
    for k in range(owari):
      if G[i][j][k]>0:
        G[i][j+1][k+AB[i][j+1]]=1
        G[i][j+1][abs(k-AB[i][j+1])]=1
    if sumi[i][j+1]==0:
      q.append([i, j+1])
      sumi[i][j+1]=1
  elif i<H-1 and j>=W-1:
    for k in range(owari):
      if G[i][j][k]>0:
        G[i+1][j][k+AB[i+1][j]]=1
        G[i+1][j][abs(k-AB[i+1][j])]=1
    if sumi[i+1][j]==0:
      q.append([i+1, j])
      sumi[i+1][j]=1
    
q=deque()
q.append([0, 0])
while len(q)>0:
  data=q.popleft()
  f(data)
  
out=0
while G[-1][-1][out]==0:
  out+=1
print(out)
### BUGGY CODE ###

import copy
from collections import deque

h, w = map(int, input().split())
grid = [list(map(lambda x: x == "#", input().rstrip())) for _ in range(h)]

q = deque([])
for i in range(h):
    for j in range(w):
        if grid[i][j]:
            q.append([i, j, 0])

moves = [[1, 0], [-1, 0], [0, 1], [0, -1]]

ans = 0
while q:
    curr = q.popleft()
    ans = max(ans, curr[2])
    for m in moves:
        nx, ny = curr[0] + m[0], curr[1] + m[1]
        if nx < 0 or ny < 0 or nx > h - 1 or ny > w - 1 or grid[nx][ny]:
            continue
        else:
            q.append([nx, ny, curr[2] + 1])
            grid[nx][ny] = True

print(ans)

### FIXED CODE ###

import copy
from collections import deque

h, w = map(int, input().split())
grid = [list(map(lambda x: x == "#", input().rstrip())) for _ in range(h)]

q = deque([])
for i in range(h):
    for j in range(w):
        if grid[i][j]:
            q.append([i, j, 0])

moves = [[1, 0], [-1, 0], [0, 1], [0, -1]]

ans = 0
while q:
    curr = q.popleft()
    ans = max(ans, curr[2])
    for m in moves:
        nx, ny = curr[0] + m[0], curr[1] + m[1]
        if nx < 0 or ny < 0 or nx > h - 1 or ny > w - 1 or grid[nx][ny]:
            continue
        else:
            q.append([nx, ny, curr[2] + 1])
            grid[nx][ny] = True

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

def main():
    n = int(input())
    a = list(map(int, input().split()))
    ret = 0
    for i in range(n):
        ret += a[i] * sum(a[i + 1:])
        ret %= 1000000007
    print(ret)

if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    n = int(input())
    a = list(map(int, input().split()))
    ret = 0
    sum_list = [None] * n + [0]
    for i in range(n-1, -1, -1):
        sum_list[i] = sum_list[i+1] + a[i]
    for i in range(n):
        ret += a[i] * sum_list[i+1]
        ret %= 1000000007
    print(ret)

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

N = int(input())
A = [int(input()) for _ in range(N)]

for i in range(N):
    B = A.pop(i)
    print(max(A))
    A.insert(i, B)

### FIXED CODE ###

N = int(input())
A = [int(input()) for _ in range(N)]

newList = sorted(A,reverse=True)

for i in A:
    if newList[0] == i:
        print(newList[1])
    else:
        print(newList[0])
### BUGGY CODE ###

N=int(input())
for i in range(1,3501):
    for j in range(1,3501):
        bw=4*i*j-N*i-N*j
        if bw<=0:
            continue
        elif (N*i*j)%bw==0:
            print(i,j,(N*i*j)//bw)
            exit()

### FIXED CODE ###

N=int(input())
for i in range(1,3501):
    for j in range(1,3501):
        bw=4*i*j-N*i-N*j
        if bw<=0:
            continue
        if (N*i*j)%bw==0:
            print(i,j,(N*i*j)//bw)
            exit()
### BUGGY CODE ###

import itertools

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

c = [0] * (N+1)

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

cnt = 0
for i in range(N+1):
    for j in range(i+1, N+1):
        if c[j] - c[i] == 0:
            cnt += 1
print(cnt)


### FIXED CODE ###

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

c = [0] * (N+1)

for i in range(N):
    c[i+1] = c[i] + A[i]
cnt = {}
for i in range(0,N+1):
    if c[i] not in cnt:
        cnt[c[i]] = 1
    else:
        cnt[c[i]] += 1
count = 0
for v in cnt.values():
    count += v * (v-1) // 2
print(count)
### BUGGY CODE ###

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

for i in range(N):
  pos=0
  cost=0
  for j in range(N):
    if j==i:
      pass
    else:
      #print(j,A[j])
      cost += abs(A[j]-pos)
      pos= A[j]
  if i==N-1:
    cost += abs(A[-2])
  else:
    cost += abs(A[-1])  
  print(cost)


### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
B=[abs(A[0])]

for i in range(1,N):
  B.append(B[-1] + abs(A[i]-A[i-1]))
  
total=B[-1]+abs(A[-1])

for j in range(N):
  ans=total
  if 0<j<N-1:
    ans -= abs(A[j]-A[j-1])
    ans -= abs(A[j+1]-A[j])
    ans += abs(A[j+1]-A[j-1])
  elif j==0:
    ans -= abs(A[0])
    ans -= abs(A[1]-A[0])
    ans += abs(A[1])
  else:
    ans -= abs(A[-1]-A[-2])
    ans -= abs(A[-1])
    ans += abs(A[-2])
  print(ans)
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
X=sum(A)
ans=0
long=[abs(X-sum(A[:i+1])*2) for i in range(N)]
x=long.index(min(long))+1
pl=max(sum(A[:x]),sum(A[x:]))
mi=min(sum(A[:x]),sum(A[x:]))
while mi<pl:
  mi+=1
  ans+=1
  if mi==pl:
    break
print(ans)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
p=q=sum(A)
for i in range(N):
  p-=2*A[i]
  q=min(abs(p),q)
print(q)
### BUGGY CODE ###

ans=1
n=int(input())
for i in range(1,n+1):
    ans*=i
print(ans%(10**9+7))

### FIXED CODE ###

import math
print(math.factorial(int(input()))%(10**9+7))