You are given an array $a$ of length $n$ and array $b$ of length $m$ both consisting of only integers $0$ and $1$. Consider a matrix $c$ of size $n \times m$ formed by following rule: $c_{i, j} = a_i \cdot b_j$ (i.e. $a_i$ multiplied by $b_j$). It's easy to see that $c$ consists of only zeroes and ones too.

How many subrectangles of size (area) $k$ consisting only of ones are there in $c$?

A subrectangle is an intersection of a consecutive (subsequent) segment of rows and a consecutive (subsequent) segment of columns. I.e. consider four integers $x_1, x_2, y_1, y_2$ ($1 \le x_1 \le x_2 \le n$, $1 \le y_1 \le y_2 \le m$) a subrectangle $c[x_1 \dots x_2][y_1 \dots y_2]$ is an intersection of the rows $x_1, x_1+1, x_1+2, \dots, x_2$ and the columns $y_1, y_1+1, y_1+2, \dots, y_2$.

The size (area) of a subrectangle is the total number of cells in it.


-----Input-----

The first line contains three integers $n$, $m$ and $k$ ($1 \leq n, m \leq 40\,000, 1 \leq k \leq n \cdot m$), length of array $a$, length of array $b$ and required size of subrectangles.

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($0 \leq a_i \leq 1$), elements of $a$.

The third line contains $m$ integers $b_1, b_2, \ldots, b_m$ ($0 \leq b_i \leq 1$), elements of $b$.


-----Output-----

Output single integer — the number of subrectangles of $c$ with size (area) $k$ consisting only of ones.


-----Examples-----
Input
3 3 2
1 0 1
1 1 1

Output
4

Input
3 5 4
1 1 1
1 1 1 1 1

Output
14



-----Note-----

In first example matrix $c$ is:

 $\left(\begin{array}{l l l}{1} & {1} & {1} \\{0} & {0} & {0} \\{1} & {1} & {1} \end{array} \right)$ 

There are $4$ subrectangles of size $2$ consisting of only ones in it:

 [Image] 

In second example matrix $c$ is:

 $\left(\begin{array}{l l l l l}{1} & {1} & {1} & {1} & {1} \\{1} & {1} & {1} & {1} & {1} \\{1} & {1} & {1} & {1} & {1} \end{array} \right)$

Source: codeforces | Difficulty: MEDIUM
Tags: Sorting

Implementation

Greedy algorithms


Solutions:
import math
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
arr = [0] * (len(a) + 1)
brr = [0] * (len(b) + 1)
for i in range(1, len(a) + 1):
	arr[i] = a[i - 1] + arr[i - 1]
for i in range(1, len(b) + 1):
	brr[i] = b[i - 1] + brr[i - 1]
ans = 0
for f in range(1, int(k ** 0.5) + 1):
	if k % f == 0:
		x = f
		y = k // f
		if y <= m:
			cc = 0
			for i in range(len(arr)):
				if i + x >= len(arr):
					break
				if arr[i + x] - arr[i] == x:
					cc += 1
			bb = 0
			for i in range(len(brr)):
				if i + y >= len(brr):
					break
				if brr[i + y] - brr[i] == y:
					bb += 1
			ans += cc * bb
		if x != y:
			y = f
			x = k // f
			cc = 0
			for i in range(len(arr)):
				if i + x >= len(arr):
					break
				if arr[i + x] - arr[i] == x:
					cc += 1
			bb = 0
			for i in range(len(brr)):
				if i + y >= len(brr):
					break
				if brr[i + y] - brr[i] == y:
					bb += 1
			ans += cc * bb
print(ans)


from bisect import bisect_left

def get_len(a):
	i = 0
	ret = []
	while i < len(a):
		if a[i] == 0:
			i += 1
		else:
			j = i
			while j < len(a) and a[j] == 1:
				j += 1
			ret.append(j - i)
			i = j
	return sorted(ret)

def get_sum(a):
	ret = [0]
	s = 0
	for v in a:
		s += v
		ret.append(s)
	return ret

def count_len(i, a, sa):
	p = bisect_left(a, i)
	n = len(a)
	if p == n:
		return 0
	return sa[n] - sa[p] - (i - 1) * (n - p)

def solve(n, m, k, a, b):
	(a, b) = (get_len(a), get_len(b))
	(sa, sb) = (get_sum(a), get_sum(b))
	ret = 0
	size = []
	for i in range(1, int(k ** 0.5) + 1):
		if k % i == 0:
			size += [i] if k // i == i else [i, k // i]
	for i in size:
		j = k // i
		ret += count_len(i, a, sa) * count_len(j, b, sb)
	return ret

def main():
	inp = lambda : [int(x) for x in input().split()]
	(n, m, k) = inp()
	(a, b) = (inp(), inp())
	print(solve(n, m, k, a, b))
main()


(n, m, k) = map(int, input().split())
p = [(i, k // i) for i in range(1, int(k ** 0.5) + 1) if k % i == 0]
p += [(j, i) for (i, j) in p if i != j]
a = [x for x in input().split()]
b = [x for x in input().split()]
lst1 = []
lst2 = []
s = 0
ans = 0
for i in range(len(a)):
	if a[i] == '1':
		s += 1
		if i == len(a) - 1:
			lst1.append(s)
	else:
		lst1.append(s)
		s = 0
s = 0
for i in range(len(b)):
	if b[i] == '1':
		s += 1
		if i == len(b) - 1:
			lst2.append(s)
	else:
		lst2.append(s)
		s = 0
for (i, j) in p:
	x = 0
	y = 0
	for k in lst1:
		if i <= k:
			x += k - i + 1
	for k in lst2:
		if j <= k:
			y += k - j + 1
	ans += x * y
print(ans)


def getd(a, n):
	d = {i: 0 for i in range(1, n + 1)}
	s = 0
	a.append(0)
	for i in range(n + 1):
		if a[i] == 1:
			s += 1
		else:
			for j in range(1, s + 1):
				d[j] += s - j + 1
			s = 0
	return d
(n, m, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
v = int(k ** 0.5) + 1
divs = []
for i in range(1, v):
	if k % i == 0:
		divs.append((i, k // i))
da = getd(a, n)
db = getd(b, m)
s = 0
for (i, j) in divs:
	if i <= n and j <= m:
		s += da[i] * db[j]
	if i != j:
		if j <= n and i <= m:
			s += da[j] * db[i]
print(s)


(n, m, k) = map(int, input().split())
div = [(i, k // i) for i in range(1, int(k ** 0.5) + 1) if k % i == 0]
div += [(j, i) for (i, j) in div if i != j]
a = [len(i) for i in input().replace(' ', '').split('0') if len(i) != 0]
b = [len(i) for i in input().replace(' ', '').split('0') if len(i) != 0]
print(sum((sum((x - div1 + 1 for x in a if div1 <= x)) * sum((y - div2 + 1 for y in b if div2 <= y)) for (div1, div2) in div)))


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
aa = []
bb = []
c = 0
f = 0
for i in range(n):
	if a[i] == 1:
		if f == 0:
			c = 1
			f = 1
		else:
			c += 1
	elif f == 1:
		f = 0
		aa.append(c)
		c = 0
	else:
		continue
if f == 1:
	aa.append(c)
	c = 0
f = 0
c = 0
for i in range(m):
	if b[i] == 1:
		if f == 0:
			c = 1
			f = 1
		else:
			c += 1
	elif f == 1:
		f = 0
		bb.append(c)
		c = 0
	else:
		continue
if f == 1:
	bb.append(c)
	c = 0
x = []
for i in range(1, int(k ** 0.5) + 1):
	if k % i == 0:
		if i != k // i:
			x.append(i)
			x.append(k // i)
		else:
			x.append(i)
ans = 0
for p in x:
	q = k // p
	y = 0
	z = 0
	for i in aa:
		if i >= p:
			y += i - p + 1
	for i in bb:
		if i >= q:
			z += i - q + 1
	ans += y * z
print(int(ans))


(n, m, k) = map(int, input().split())
a = input().split()
b = input().split()
ans = 0
for i in range(1, int(k ** 0.5) + 1):
	if k % i == 0:
		f1 = i
		f2 = k // i
		if f1 != f2:
			temp1 = 0
			count = 0
			for j in range(n):
				if a[j] == '1':
					count += 1
				else:
					count = 0
				if count >= f1:
					temp1 += 1
			temp2 = 0
			count = 0
			for j in range(m):
				if b[j] == '1':
					count += 1
				else:
					count = 0
				if count >= f2:
					temp2 += 1
			ans += temp1 * temp2
			temp1 = 0
			count = 0
			for j in range(n):
				if a[j] == '1':
					count += 1
				else:
					count = 0
				if count >= f2:
					temp1 += 1
			temp2 = 0
			count = 0
			for j in range(m):
				if b[j] == '1':
					count += 1
				else:
					count = 0
				if count >= f1:
					temp2 += 1
			ans += temp1 * temp2
		else:
			temp1 = 0
			count = 0
			for j in range(n):
				if a[j] == '1':
					count += 1
				else:
					count = 0
				if count >= f1:
					temp1 += 1
			temp2 = 0
			count = 0
			for j in range(m):
				if b[j] == '1':
					count += 1
				else:
					count = 0
				if count >= f2:
					temp2 += 1
			ans += temp1 * temp2
print(ans)


from itertools import groupby

def getSection():
	return list(map(lambda p: len(list(p[1])), filter(lambda p: p[0] is '1', groupby(input().replace(' ', '')))))

def side(arr, x):
	return sum(map(lambda p: p - x + 1, filter(lambda p: p >= x, arr)))
(n, m, k) = map(int, input().split())
(ass, bss) = (getSection(), getSection())
ans = sum([side(ass, x) * side(bss, k // x) + (side(bss, x) * side(ass, k // x) if x * x != k else 0) for x in range(1, int(k ** 0.5 + 0.5) + 1) if k % x == 0])
print(ans)


def getContiguous(arr):
	n = len(arr)
	cnt = 0
	res = []
	for i in range(n):
		if arr[i] == 1:
			cnt += 1
		else:
			if cnt > 0:
				res.append(cnt)
			cnt = 0
	if cnt > 0:
		res.append(cnt)
	return res
(n, m, k) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
aOnes = getContiguous(a)
bOnes = getContiguous(b)
aCounts = [0 for __ in range(n + 1)]
bCounts = [0 for __ in range(m + 1)]
for c in aOnes:
	aCounts[c] += 1
for c in bOnes:
	bCounts[c] += 1
add = 0
add2 = 0
for i in range(n, -1, -1):
	add += aCounts[i]
	add2 += add
	aCounts[i] = 0
	aCounts[i] += add2
add = 0
add2 = 0
rollingTotal = 0
for i in range(m, -1, -1):
	add += bCounts[i]
	add2 += add
	bCounts[i] = 0
	bCounts[i] += add2
validRectangleDimensions = []
for i in range(1, int(k ** 0.5) + 1):
	if k % i == 0:
		validRectangleDimensions.append([i, k // i])
		if i != k // i:
			validRectangleDimensions.append([k // i, i])
ans = 0
for (dimx, dimy) in validRectangleDimensions:
	if dimx <= n and dimy <= m:
		ans += aCounts[dimx] * bCounts[dimy]
print(ans)


from math import *
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cna = []
cn = 0
for i in a:
	if i == 1:
		cn += 1
	else:
		cna.append(cn)
		cn = 0
cna.append(cn)
cnb = []
cn = 0
for i in b:
	if i == 1:
		cn += 1
	else:
		cnb.append(cn)
		cn = 0
cnb.append(cn)
da = [0] * (n + 1)
db = [0] * (m + 1)
for i in cna:
	for j in range(1, i + 1):
		da[j] += i - j + 1
for i in cnb:
	for j in range(1, i + 1):
		db[j] += i - j + 1
ans = 0
h = int(sqrt(k))
for i in range(1, h + 1):
	if k % i == 0:
		f = k // i
		if i != f:
			if i <= n and f <= m:
				ans += da[i] * db[f]
			if i <= m and f <= n:
				ans += da[f] * db[i]
		elif i > n or i > m:
			continue
		else:
			ans += da[i] * db[f]
print(ans)


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
import math
from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def countit(lst, lenr):
	n = len(lst)
	counter = 0
	if lenr > n:
		return 0
	else:
		subcounter = 0
		for i in range(n):
			if lst[i] == 1:
				subcounter += 1
			else:
				if subcounter >= lenr:
					counter += subcounter - lenr + 1
				subcounter = 0
			if i == n - 1:
				if subcounter >= lenr:
					counter += subcounter - lenr + 1
	return counter
(n, m, k) = list(map(int, input().split()))
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
factk = list(factors(k))
factk.sort()
recdimen = []
for ele in factk:
	if ele <= k ** 0.5:
		recdimen.append([ele, k // ele])
	else:
		break
res = 0
for (dima, dimb) in recdimen:
	(ta1, ta2) = (countit(a1, dima), countit(a2, dimb))
	(tb1, tb2) = (countit(a2, dima), countit(a1, dimb))
	if dima == dimb:
		res += ta1 * ta2
	else:
		res += ta1 * ta2 + tb1 * tb2
print(res)


def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
(n, m, k) = map(int, input().split())
data = input().split()
datb = input().split()
divs = make_divisors(k)
rects = []
for x in divs:
	rects.append((x, k // x))
from collections import Counter, defaultdict
da = defaultdict(int)
db = defaultdict(int)
cnt = 0
l = len(data)
for i in range(l):
	if data[i] == '1':
		cnt += 1
	if data[i] == '0' or i == l - 1:
		da[cnt] += 1
		cnt = 0
cnt = 0
l = len(datb)
for i in range(l):
	if datb[i] == '1':
		cnt += 1
	if datb[i] == '0' or i == l - 1:
		db[cnt] += 1
		cnt = 0
res = 0
for lx in da:
	for ly in db:
		for (x, y) in rects:
			reccount = da[lx] * db[ly]
			cx = lx - x
			cy = ly - y
			if cx > -1 and cy > -1:
				cannum = (cx + 1) * (cy + 1) * reccount
				res += cannum
print(res)


from sys import stdin, stdout

def main():
	t = 1
	for x in range(t):
		(n, m, k) = map(int, input().split())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		l = []
		c = 0
		for i in range(m):
			if b[i] == 1:
				c += 1
			else:
				if c != 0:
					l.append(c)
				c = 0
		if c != 0:
			l.append(c)
		lr = []
		c = 0
		for i in range(n):
			if a[i] == 1:
				c += 1
			else:
				if c != 0:
					lr.append(c)
				c = 0
		if c != 0:
			lr.append(c)
		rep1 = 0
		ans = 0
		for i in l:
			if i >= k:
				ans += i - k + 1
		rep1 = sum(l[:])
		len_l = len(l)
		rep = ans
		ans = 0
		for i in a:
			if i != 0:
				ans += rep
		if k % 2 != 0:
			if k != 1:
				for i in lr:
					if i >= k:
						ans += rep1 * (i - (k - 1))
		else:
			repet = {}
			maxi = 0
			if len(lr) > 0:
				maxi = max(lr[:])
			for j in range(2, min(maxi + 1, k // 2 + 1)):
				if k % j == 0:
					for i in l:
						if i >= k // j:
							repet[k // j] = repet.get(k // j, 0) + (i - k // j + 1)
			cnt = 0
			add = 0
			rev = 0
			for i in range(n):
				if a[i] == 1:
					cnt += 1
					if cnt >= 2:
						if cnt >= k:
							add = rep1
							ans += add + rev
						elif k % cnt == 0 and cnt != k:
							rev += repet.get(k // cnt, 0)
							ans += add + rev
							add = 0
						else:
							ans += rev + add
							add = 0
				else:
					cnt = 0
					rev = 0
					add = 0
		print(ans)
main()


def cal_sum(lena, lenb, suma, sumb):
	if lena >= len(suma) or lenb >= len(sumb):
		return 0
	return suma[lena] * sumb[lenb]

def build_sum_arr(arr, sum_arr):
	i = 0
	j = 0
	while i < len(arr):
		if arr[i] == 1:
			j = i
			while i < len(arr) and arr[i] == 1:
				i = i + 1
			ln = i - j
			count = 1
			for ki in range(ln, 0, -1):
				sum_arr[ki] = sum_arr[ki] + count
				count = count + 1
		i = i + 1
	return sum_arr
(n, m, k) = [int(i) for i in input().split(' ')]
a = [int(i) for i in input().split(' ')]
b = [int(i) for i in input().split(' ')]
suma = [0 for i in range(0, len(a) + 1)]
sumb = [0 for i in range(0, len(b) + 1)]
suma = build_sum_arr(a, suma)
sumb = build_sum_arr(b, sumb)
i = 1
sums = 0
while i * i <= k:
	if k % i == 0:
		sums = sums + cal_sum(i, int(k / i), suma, sumb)
		if i * i != k:
			sums = sums + cal_sum(int(k / i), i, suma, sumb)
	i = i + 1
print(sums)


import math
(n, m, k) = [int(x) for x in input().split()]
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a_one = []
b_one = []
i = t = 0
while i < n:
	if a[i] == 1:
		t += 1
	else:
		a_one.append(t)
		t = 0
	i += 1
a_one.append(t)
i = t = 0
while i < m:
	if b[i] == 1:
		t += 1
	else:
		b_one.append(t)
		t = 0
	i += 1
b_one.append(t)

def solve(r, c, a_one, b_one):
	p = q = i = 0
	while i < len(a_one):
		p += max(a_one[i] - (r - 1), 0)
		i += 1
	i = 0
	while i < len(b_one):
		q += max(b_one[i] - (c - 1), 0)
		i += 1
	return p * q
ans = 0
for i in range(1, int(math.sqrt(k)) + 1):
	if k % i == 0:
		c = k // i
		ans += solve(i, c, a_one, b_one)
		if i != c:
			ans += solve(c, i, a_one, b_one)
print(ans)


from collections import Counter
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

def foo(A, l):
	la = [0 for _ in range(l + 2)]
	cont = 0
	for i in range(l):
		if A[i] == 1:
			cont += 1
		else:
			cont = 0
		la[1] += 1
		la[cont + 1] -= 1
	s = 0
	for i in range(l + 2):
		s += la[i]
		la[i] = s
	return la
la = foo(a, n)
lb = foo(b, m)
ans = 0
for i in range(1, n + 1):
	if k % i == 0 and k // i <= m:
		ans += la[i] * lb[k // i]
print(ans)


(n, m, k) = list(map(int, input().split(' ')))
a = ''.join(input().split(' '))
b = ''.join(input().split(' '))
a = a.split('0')
b = b.split('0')
result = 0
divs = []
i = 1
while i * i <= k:
	if k % i == 0:
		divs.append(i)
	i += 1
a_count = dict()
b_count = dict()
for div in divs:
	a_count[div] = 0
	b_count[div] = 0
	a_count[k // div] = 0
	b_count[k // div] = 0
for subset in a:
	l = len(subset)
	for div in divs:
		if div <= l:
			a_count[div] += l - div + 1
		if k // div <= l and div * div != k:
			a_count[k // div] += l - k // div + 1
for subset in b:
	l = len(subset)
	for div in divs:
		if div <= l:
			b_count[div] += l - div + 1
		if k // div <= l and div * div != k:
			b_count[k // div] += l - k // div + 1
for div in divs:
	result += a_count[div] * b_count[k // div]
	if div * div != k:
		result += b_count[div] * a_count[k // div]
print(result)


import sys
input = sys.stdin.buffer.readline
(n, m, k) = [int(c) for c in input().split()]
a = [int(c) for c in input().split()]
b = [int(c) for c in input().split()]
l = 0
an = [0 for i in range(40005)]
bn = [0 for i in range(40005)]
l = 0
for i in a:
	if i == 1:
		l += 1
		an[1] += 1
		an[l + 1] -= 1
	else:
		l = 0
l = 0
for i in b:
	if i == 1:
		l += 1
		bn[1] += 1
		bn[l + 1] -= 1
	else:
		l = 0
for i in range(1, n + 2):
	an[i] += an[i - 1]
for i in range(1, m + 2):
	bn[i] += bn[i - 1]
ans = 0
for i in range(1, n + 1):
	if k % i == 0:
		if k // i <= m:
			ans += an[i] * bn[k // i]
print(ans)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d1 = [0] * (len(a) + 1)
flag = False
ct = 0
i = 0
while i < n:
	if a[i] == 0:
		i += 1
		continue
	j = i
	while j < n and a[j] == 1:
		j += 1
	for l in range(1, j - i + 1):
		d1[l] += j - i - l + 1
	i = j
d2 = [0] * (len(b) + 1)
i = 0
while i < m:
	if b[i] == 0:
		i += 1
		continue
	j = i
	while j < m and b[j] == 1:
		j += 1
	for l in range(1, j - i + 1):
		d2[l] += j - i - l + 1
	i = j
ans = 0
for i in range(1, len(d1)):
	if k % i == 0 and k // i <= m:
		ans += d1[i] * d2[k // i]
print(ans)


(n, m, k) = map(int, input().strip().split())
arr1 = list(map(int, input().strip().split()))
arr2 = list(map(int, input().strip().split()))
rects = []
dicti = {}
conts = []
j = 0
for i in arr2:
	if i == 1:
		j += 1
	else:
		conts.append(j)
		j = 0
if j > 0:
	conts.append(j)
for i in range(1, len(arr1) + 1):
	if k % i == 0:
		sumi = 0
		for j in conts:
			sumi += max(0, j - k // i + 1)
		rects.append([i, sumi])
for i in range(1, len(rects)):
	rects[i][1] += rects[i - 1][1]
for i in rects:
	dicti[i[0]] = i[1]
j = 1
dp = [0 for i in range(len(arr1) + 1)]
for i in range(1, len(arr1) + 1):
	if i in dicti:
		j = i
	dp[i] = dp[i - 1] + dicti[j]
ans = 0
cont = 0
for i in range(len(arr1)):
	if arr1[i] == 1:
		cont += 1
	else:
		ans += dp[cont]
		cont = 0
if cont > 0:
	ans += dp[cont]
print(ans)


import math
from sys import stdin
I = stdin.readline
for _ in range(1):
	(n, m, k) = map(int, I().split())
	ar = list(map(int, I().split()))
	br = list(map(int, I().split()))
	prv = 0
	la = []
	lb = []
	for i in range(n):
		if ar[i] == 1:
			prv += 1
		elif prv != 0 and ar[i] == 0:
			la.append(prv)
			prv = 0
	if prv != 0:
		la.append(prv)
		prv = 0
	for i in range(m):
		if br[i] == 1:
			prv += 1
		elif prv != 0 and br[i] == 0:
			lb.append(prv)
			prv = 0
	if prv != 0:
		lb.append(prv)
		prv = 0
	lena = len(la)
	lenb = len(lb)
	div = [i for i in range(1, int(k ** 0.5) + 1) if k % i == 0]
	div += [k // i for i in div if i != k // i]
	ldiv = len(div)
	cnt = 0
	cnt1 = 0
	cnt2 = 0
	for ij in range(ldiv):
		for i in range(lena):
			if div[ij] > la[i]:
				fl = 1
				continue
			var = la[i] + 1 - div[ij]
			if var < 0:
				var = 0
			cnt1 += var
		for j in range(lenb):
			if k // div[ij] > lb[j]:
				continue
			var = lb[j] + 1 - k // div[ij]
			if var < 0:
				var = 0
			cnt2 += var
		cnt += cnt1 * cnt2
		cnt1 = 0
		cnt2 = 0
	print(cnt)


(n, m, k) = map(int, input().split())
a = [len(i) for i in input().replace(' ', '').split('0') if len(i) > 0]
b = [len(i) for i in input().replace(' ', '').split('0') if len(i) > 0]
d = [(i, k // i) for i in range(1, int(k ** 0.5) + 1) if k % i == 0]
d += [(j, i) for (i, j) in d if i != j]
c = 0
for (x, y) in d:
	c += sum((i - x + 1 for i in a if x <= i)) * sum((j - y + 1 for j in b if y <= j))
print(c)


import sys
read = lambda : list(map(int, sys.stdin.readline().strip().split()))
(n, m, k) = read()
a = read()
b = read()
ca = [0] * (n + 1)
cb = [0] * (m + 1)
countb = 0
for num in b:
	if num == 1:
		countb += 1
	elif countb != 0:
		cb[countb] += 1
		countb = 0
cb[countb] += 1
counta = 0
for num in a:
	if num == 1:
		counta += 1
	else:
		ca[counta] += 1
		counta = 0
ca[counta] += 1
counta = 0
if n - 1 >= 1:
	ca[n - 1] = 2 * ca[n]
for i in range(n - 2, 0, -1):
	counta = ca[i + 2]
	ca[i] += 2 * ca[i + 1]
	ca[i] -= counta
countb = 0
if m - 1 >= 1:
	cb[m - 1] = 2 * cb[m]
for i in range(m - 2, 0, -1):
	countb = cb[i + 2]
	cb[i] += 2 * cb[i + 1]
	cb[i] -= countb
ans = 0
for i in range(1, n + 1):
	if ca[i] > 0 and k % i == 0 and (k // i <= m):
		ans += ca[i] * cb[k // i]
print(ans)


(n, m, k) = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
(a, b) = (b, a)

def search_for_divisors(num):
	i = 1
	while i * i <= num:
		if num % i == 0:
			divisors.append([i, num // i])
			if i != num // i:
				divisors.append([num // i, i])
		i += 1
divisors = []
search_for_divisors(k)
breadth = {}
ones = 0
for a_i in a + [0]:
	if a_i == 1:
		ones += 1
	else:
		if ones not in breadth:
			breadth[ones] = 1
		else:
			breadth[ones] += 1
		ones = 0
height = {}
ones = 0
for b_i in b + [0]:
	if b_i == 1:
		ones += 1
	else:
		if ones not in height:
			height[ones] = 1
		else:
			height[ones] += 1
		ones = 0
subrectangles = {}
for a_i in breadth:
	for b_i in height:
		subrectangles[a_i, b_i] = breadth[a_i] * height[b_i]
total_capacity = 0
for the_size_of_the_rectangle in divisors:
	for borders in subrectangles:
		if the_size_of_the_rectangle[0] <= borders[0] and the_size_of_the_rectangle[1] <= borders[1]:
			total_capacity += (borders[0] - the_size_of_the_rectangle[0] + 1) * (borders[1] - the_size_of_the_rectangle[1] + 1) * subrectangles[borders]
print(total_capacity)


import sys
input = sys.stdin.readline
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cnta = [0] * (n + 1)
cntb = [0] * (m + 1)
cnt = 0
for i in range(n + 1):
	if i == n or a[i] == 0:
		if cnt > 0:
			for w in range(1, cnt + 1):
				cnta[w] += cnt - w + 1
			cnt = 0
	else:
		cnt += 1
cnt = 0
for i in range(m + 1):
	if i == m or b[i] == 0:
		if cnt > 0:
			for w in range(1, cnt + 1):
				cntb[w] += cnt - w + 1
			cnt = 0
	else:
		cnt += 1
ans = 0
for x in range(1, n + 1):
	if k % x == 0:
		y = k // x
		if y <= m:
			ans += cnta[x] * cntb[y]
print(ans)


def check(l, k):
	if len(l) < k:
		return 0
	count = 0
	s = sum(l[:k])
	if s == k:
		count += 1
	for i in range(1, len(l) - k + 1):
		s -= l[i - 1]
		s += l[i + k - 1]
		if s == k:
			count += 1
	return count
ans = 0
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
count = 0
for i in range(1, n + 1):
	if k % i == 0:
		pre = i
		pro = k // i
		ans += check(a, pre) * check(b, pro)
print(ans)


from bisect import bisect_left as bl
(n, m, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a1 = [0] * n
b1 = [0] * m
ans = 0
a1[0] = a[0]
for i in range(1, n):
	if a[i] == 1:
		a1[i] = a1[i - 1] + 1
b1[0] = b[0]
for i in range(1, m):
	if b[i] == 1:
		b1[i] = b1[i - 1] + 1
a1.sort()
b1.sort()
ans = 0
for i in range(1, int(k ** 0.5) + 1):
	if k % i == 0:
		if i == k // i:
			x1 = n - bl(a1, i)
			x2 = m - bl(b1, i)
			ans += x1 * x2
		else:
			x1 = n - bl(a1, i)
			x2 = m - bl(b1, k // i)
			ans += x1 * x2
			x1 = n - bl(a1, k // i)
			x2 = m - bl(b1, i)
			ans += x1 * x2
print(ans)


import math

def printDivisors(n, l):
	list = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				l.append(i)
			else:
				l.append(i)
				list.append(int(n / i))
	for i in list[::-1]:
		l.append(i)
(n, m, k) = map(int, input().split())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
seq1 = []
seq2 = []
l = 0
for i in range(n):
	if l1[i] == 1:
		l += 1
		if i == n - 1:
			seq1.append(l)
	elif l > 0:
		seq1.append(l)
		l = 0
l = 0
for i in range(m):
	if l2[i] == 1:
		l += 1
		if i == m - 1:
			seq2.append(l)
	elif l > 0:
		seq2.append(l)
		l = 0
list_of_div = []
printDivisors(k, list_of_div)
summ = 0
for i in range(len(list_of_div)):
	a = 0
	b = 0
	for j in range(len(seq1)):
		if seq1[j] >= list_of_div[i]:
			a += seq1[j] - list_of_div[i] + 1
	for j in range(len(seq2)):
		if seq2[j] >= k // list_of_div[i]:
			b += seq2[j] - k // list_of_div[i] + 1
	summ += a * b
print(summ)


import sys
input = sys.stdin.readline
(n, m, k) = map(int, input().split())
a = tuple(map(int, input().split()))
b = tuple(map(int, input().split()))
pairs = []
for i in range(1, int(k ** 0.5) + 1):
	if k % i == 0:
		pairs.append((i, k // i))
sa = 0
sb = 0
pa = [0]
pb = [0]
for i in range(n):
	sa += a[i]
	pa.append(sa)
for i in range(m):
	sb += b[i]
	pb.append(sb)
ans = 0
for (fa, fb) in pairs:
	c1 = 0
	c2 = 0
	for i in range(n - fa + 1):
		if pa[i + fa] - pa[i] == fa:
			c1 += 1
	for i in range(m - fb + 1):
		if pb[i + fb] - pb[i] == fb:
			c2 += 1
	ans += c1 * c2
	(c1, c2) = (0, 0)
	if fa == fb:
		continue
	for i in range(n - fb + 1):
		if pa[i + fb] - pa[i] == fb:
			c1 += 1
	for i in range(m - fa + 1):
		if pb[i + fa] - pb[i] == fa:
			c2 += 1
	ans += c1 * c2
print(ans)


from math import sqrt

def func():
	(n, m, k) = map(int, input().strip().split())
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	print(sub_matrix(a, b, n, m, k))

def sub_matrix(nums_a, nums_b, n, m, target):

	def get_len_freq(nums):
		nums_size = len(nums)
		len_freq = [0 for _ in range(nums_size + 2)]
		cur_len = 0
		for i in range(nums_size):
			if nums[i] == 1:
				cur_len += 1
				len_freq[1] += 1
				len_freq[cur_len + 1] -= 1
			else:
				cur_len = 0
		for i in range(1, nums_size + 1):
			len_freq[i] += len_freq[i - 1]
		return len_freq
	len_freq_a = get_len_freq(nums_a)
	len_freq_b = get_len_freq(nums_b)
	res = 0
	for x in range(1, n + 1):
		if target % x != 0:
			continue
		y = target // x
		if y > m:
			continue
		res += len_freq_a[x] * len_freq_b[y]
	return res
func()


(n, m, k) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
D = []
for i in range(1, int(k ** 0.5) + 1):
	if k % i == 0:
		D.append(i)
		if i != k // i:
			D.append(k // i)
D.sort()
D1 = [0 for i in range(len(D))]
D2 = [0 for i in range(len(D))]
cnt = 0
A.append(0)
B.append(0)
for a in A:
	if a == 0:
		if cnt > 0:
			for i in range(len(D)):
				if cnt < D[i]:
					break
				D1[i] += cnt - D[i] + 1
		cnt = 0
	else:
		cnt += 1
for b in B:
	if b == 0:
		if cnt > 0:
			for i in range(len(D)):
				if cnt < D[i]:
					break
				D2[i] += cnt - D[i] + 1
		cnt = 0
	else:
		cnt += 1
ans = 0
for i in range(len(D)):
	ans += D1[i] * D2[-(i + 1)]
print(ans)


from sys import stdin
from math import sqrt, factorial, ceil
from collections import Counter, defaultdict
from heapq import heapify, heapreplace, heappush, heappop
from bisect import bisect_left
(n, m, k) = map(int, stdin.readline().split())
a = list(map(int, stdin.readline().split()))
b = list(map(int, stdin.readline().split()))
(sa, sb) = ([0] * 50000, [0] * 50000)
(i, j) = (0, 0)
while i < n:
	j = i
	while j < n:
		if a[j] == 0:
			break
		j += 1
	if j > i:
		temp = j - i
		c = 1
		for x in range(temp, 0, -1):
			sa[x] += c
			c += 1
	i = j + 1
(i, j) = (0, 0)
while i < m:
	j = i
	while j < m:
		if b[j] == 0:
			break
		j += 1
	if j > i:
		temp = j - i
		c = 1
		for x in range(temp, 0, -1):
			sb[x] += c
			c += 1
	i = j + 1
rect = 0
for x in range(1, int(sqrt(k)) + 1):
	if k % x == 0:
		if max(x, k // x) <= max(n, m):
			rect += sa[x] * sb[k // x]
			if x != k // x:
				rect += sa[k // x] * sb[x]
print(rect)


(n, m, k) = input().strip().split(' ')
(n, m, k) = [int(n), int(m), int(k)]
a = list(map(int, input().strip().split(' ')))
b = list(map(int, input().strip().split(' ')))
v = []
i = 1
while i * i <= k:
	if not k % i:
		if k // i != i:
			v.append([i, k // i])
			v.append([k // i, i])
		else:
			v.append([i, i])
	i += 1
ans = 0
for j in range(len(v)):
	x = v[j][0]
	y = v[j][1]
	c1 = 0
	c2 = 0
	ss = 0
	for kk in range(n):
		if a[kk]:
			ss += 1
		else:
			ss = 0
		if ss >= x:
			c1 += 1
	ss = 0
	for kk in range(m):
		if b[kk]:
			ss += 1
		else:
			ss = 0
		if ss >= y:
			c2 += 1
	ans += c1 * c2
print(ans)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
h = []
q = []
not_b = [-1]
Ans = 0
w_i = 0
i = 0
while i < n:
	while i < n and a[i] == 1:
		w_i += 1
		i += 1
	if w_i in h:
		q[h.index(w_i)] += 1
	elif w_i:
		h.append(w_i)
		q.append(1)
	while i < n and a[i] == 0:
		i += 1
	w_i = 0
ans = 0
w_j = 0
j = 0
while j < m:
	while j < m and b[j] == 1:
		w_j += 1
		j += 1
	if w_j:
		for x in h:
			if w_j * x >= k:
				for p in range(1, x + 1):
					if k % p == 0 and k // p <= w_j:
						w = k // p
						ans += (w_j - w + 1) * (x - p + 1)
			Ans += ans * q[h.index(x)]
			ans = 0
	while j < m and b[j] == 0:
		j += 1
	w_j = 0
print(Ans)


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

def intervals(arr):
	res = []
	curr = 0
	for e in arr:
		if e == 1:
			curr += 1
		if e == 0:
			if curr != 0:
				res.append(curr)
				curr = 0
	if curr != 0:
		res.append(curr)
	return res
a = intervals(list(map(int, input().split())))
b = intervals(list(map(int, input().split())))
factors = []
for x in range(1, int(k ** (1 / 2)) + 1):
	if k % x == 0:
		factors.append(x)

def count(ivs, x):
	total = 0
	for iv in ivs:
		total += max(iv - x + 1, 0)
	return total
total = 0
for f in factors:
	one = count(a, f) * count(b, k // f)
	if f == k // f:
		total += one
		continue
	two = count(a, k // f) * count(b, f)
	total += one
	total += two
print(total)


def yakusu(x):
	div = []
	for i in range(1, int(x ** 0.5) + 1):
		if x % i == 0:
			div.append(i)
			if i != x // i:
				div.append(x // i)
	div.sort()
	return div
(n, m, k) = map(int, input().split())
w = []
h = []
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cnt = 0
for i in range(n):
	if a[i]:
		cnt += 1
	elif cnt > 0:
		w.append(cnt)
		cnt = 0
if cnt > 0:
	w.append(cnt)
	cnt = 0
for i in range(m):
	if b[i]:
		cnt += 1
	elif cnt > 0:
		h.append(cnt)
		cnt = 0
if cnt > 0:
	h.append(cnt)
ans = 0
r = yakusu(k)
for i in range(len(r)):
	yoko = tate = 0
	for j in range(len(w)):
		if w[j] >= r[i]:
			yoko += w[j] - r[i] + 1
	for j in range(len(h)):
		if h[j] >= r[-i - 1]:
			tate += h[j] - r[-i - 1] + 1
	ans += yoko * tate
print(ans)


import sys
import math
from collections import Counter
from functools import lru_cache
(n, m, k) = map(int, next(sys.stdin).split())
a1 = list(map(int, next(sys.stdin).split()))
a2 = list(map(int, next(sys.stdin).split()))

def get_ones_list(a):
	result = []
	current_length = 0
	for x in a:
		if x == 1:
			current_length += 1
		elif x == 0 and current_length > 0:
			result.append(current_length)
			current_length = 0
	if current_length > 0:
		result.append(current_length)
	return result

@lru_cache(maxsize=10)
def get_sizes(kk):
	result = set()
	for x in range(1, int(math.sqrt(kk) + 1)):
		if kk % x == 0:
			result.add((x, int(kk / x)))
			result.add((int(kk / x), x))
	return list(result)

@lru_cache(maxsize=None)
def get_n_inners(a, b, k):
	s = 0
	if k > a * b:
		return 0
	elif k == a * b:
		return 1
	for (size_x, size_y) in get_sizes(k):
		if size_x > a:
			continue
		if size_y > b:
			continue
		s += (a - size_x + 1) * (b - size_y + 1)
	return s
r = 0
counter_a1 = Counter(get_ones_list(a1))
counter_a2 = Counter(get_ones_list(a2))
for (aa, n1) in counter_a1.items():
	for (bb, n2) in counter_a2.items():
		r += get_n_inners(aa, bb, k) * n1 * n2
print(r)


(l1, l2, req) = (int(i) for i in input().split(' '))
lia = [int(i) for i in input().split(' ')]
lib = [int(i) for i in input().split(' ')]
ca = {}
cb = {}
tmp = 0
for i in lia:
	if i == 1:
		tmp += 1
	else:
		if tmp:
			ca[tmp] = ca.get(tmp, 0) + 1
		tmp = 0
if tmp:
	ca[tmp] = ca.get(tmp, 0) + 1
tmp = 0
for i in lib:
	if i == 1:
		tmp += 1
	else:
		if tmp:
			cb[tmp] = cb.get(tmp, 0) + 1
		tmp = 0
if tmp:
	cb[tmp] = cb.get(tmp, 0) + 1
ans = 0
for (keyi, vali) in ca.items():
	for (keyj, valj) in cb.items():
		if keyi * keyj >= req:
			for t in range(1, 1 + keyi):
				if req % t == 0 and req // t <= keyj:
					ans += vali * valj * (keyi - t + 1) * (keyj - req // t + 1)
print(ans)


R = lambda : map(int, input().split())
(n, m, k) = R()
a = list(R())
b = list(R())
a_counts = [0] * (n + 1)
b_counts = [0] * (m + 1)
count = 0
for i in range(n):
	if a[i] == 1:
		count += 1
	if a[i] == 0 or i == n - 1:
		for j in range(1, count + 1):
			a_counts[j] = a_counts[j] + count - j + 1
		count = 0
count = 0
for i in range(m):
	if b[i] == 1:
		count += 1
	if b[i] == 0 or i == m - 1:
		for j in range(1, count + 1):
			b_counts[j] = b_counts[j] + count - j + 1
		count = 0
ans = 0
for i in range(1, n + 1):
	if k % i == 0 and k // i < m + 1:
		ans += a_counts[i] * b_counts[k // i]
print(ans)


import sys
input = sys.stdin.readline
import collections

def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	divisors.sort()
	return divisors

def main():
	(N, M, K) = [int(x) for x in input().split()]
	A = [int(x) for x in input().split()]
	B = [int(x) for x in input().split()]
	divs = make_divisors(K)
	ac = collections.Counter()
	acont = 0
	for a in A:
		if a == 0:
			for d in divs:
				if acont >= d:
					ac[d] += acont - d + 1
				else:
					break
			acont = 0
		else:
			acont += 1
	else:
		for d in divs:
			if acont >= d:
				ac[d] += acont - d + 1
			else:
				break
	bcont = 0
	bc = collections.Counter()
	for b in B:
		if b == 0:
			for d in divs:
				if bcont >= d:
					bc[d] += bcont - d + 1
				else:
					break
			bcont = 0
		else:
			bcont += 1
	else:
		for d in divs:
			if bcont >= d:
				bc[d] += bcont - d + 1
			else:
				break
	ans = 0
	for d in divs:
		ad = K // d
		ans += ac[d] * bc[ad]
	print(ans)
main()


def isqrt(k):
	ret = 0
	x = 2 ** 16
	while x > 0:
		if (ret + x) ** 2 <= k:
			ret += x
		x //= 2
	return ret

def compress(l):
	n = len(l)
	l.append(0)
	ret = []
	x = y = 0
	i = 0
	while True:
		while l[i] == 0 and i < n:
			i += 1
		if i == n:
			break
		x = i
		while l[i] == 1:
			i += 1
		y = i - 1
		ret.append((x, y))
	l.pop()
	return ret

def max_len(a):
	if len(a) == 0:
		return 0
	return max([y - x + 1 for (x, y) in a])

def one_list_count(a, n):
	return sum([y - x - n + 2 for (x, y) in a if y - x + 1 >= n])

def one_div_count(a, b, k, d):
	return one_list_count(a, d) * one_list_count(b, k // d)

def div_less_than_sqrt_count(a, b, k):
	ma = max_len(a)
	mb = max_len(b)
	if mb == 0:
		return 0
	ret = 0
	d = (k - 1) // mb + 1
	while d <= ma and d ** 2 < k:
		if k % d == 0:
			ret += one_div_count(a, b, k, d)
		d += 1
	return ret
(n, m, k) = tuple(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
a = compress(a)
b = compress(b)
ans = div_less_than_sqrt_count(a, b, k)
ans += div_less_than_sqrt_count(b, a, k)
sk = isqrt(k)
if sk ** 2 == k:
	ans += one_div_count(a, b, k, sk)
print(ans)


n = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
k_div = []
count = 1
for i in range(int(n[2] ** (1 / 2))):
	if n[2] % count == 0:
		k_div.append(count)
	count += 1
for i in range(len(k_div)):
	if k_div[i] ** 2 != n[2]:
		k_div.append(int(n[2] / k_div[i]))
gra = {}
grb = {}
c = 0
d = 0
for i in range(n[0]):
	if a[i] == 1:
		c += 1
	elif c != 0:
		gra[c] = gra.get(c, 0) + 1
		c = 0
if c > 0:
	gra[c] = gra.get(c, 0) + 1
for i in range(n[1]):
	if b[i] == 1:
		d += 1
	elif d != 0:
		grb[d] = grb.get(d, 0) + 1
		d = 0
if d > 0:
	grb[d] = grb.get(d, 0) + 1
rect = 0
for i in range(len(k_div)):
	row = 0
	column = 0
	for key in gra.keys():
		if key >= k_div[i]:
			row += (key - k_div[i] + 1) * gra[key]
	for key in grb.keys():
		if key >= n[2] / k_div[i]:
			column += (key - n[2] / k_div[i] + 1) * grb[key]
	rect += int(row * column)
print(rect)


from sys import stdin
from collections import *

def factorize(n):
	(c, ans) = (1, [])
	while c * c < n:
		if n % c == 0:
			ans.extend([c, n // c])
		c += 1
	if c * c == n:
		ans.append(c)
	return sorted(ans)

def arr_inp(n):
	if n == 1:
		return [int(x) for x in stdin.readline().split()]
	elif n == 2:
		return [float(x) for x in stdin.readline().split()]
	else:
		return list(stdin.readline()[:-1])

def row(arr, l):
	(tem, tem2) = (0, [])
	for i in range(l):
		if arr[i]:
			tem += 1
		else:
			if tem:
				tem2.append(tem)
			tem = 0
	if tem:
		tem2.append(tem)
	return sorted(tem2)

def cum():
	(mem, tem, tem1) = (Counter(c), [0], [0])
	for i in range(1, c[-1] + 1):
		tem.append(tem[-1] + mem[i])
		tem1.append(tem1[-1] + mem[i] * i)
	return (tem, tem1)
(n, m, k) = arr_inp(1)
(a, b, ans) = (arr_inp(1), arr_inp(1), 0)
(r, c, facs) = (row(b, m), row(a, n), factorize(k))
if c:
	(sum1, cu) = cum()
	for i in range(len(facs)):
		(r1, c1) = (facs[i], facs[-(i + 1)])
		for j in r:
			if c[-1] >= c1:
				ans += max(j - r1 + 1, 0) * max(0, cu[-1] - cu[c1 - 1] - (sum1[-1] - sum1[c1 - 1]) * (c1 - 1))
print(ans)


import math, collections, sys
input = sys.stdin.readline
factors = set()

def Divisors(n):
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			factors.add(i)
			factors.add(n // i)
		i += 1
(n, m, k) = map(int, input().split())
Divisors(k)
a = list(map(int, input().split()))
b = list(map(int, input().split()))
countA = collections.defaultdict(int)
countB = collections.defaultdict(int)
(za, zb) = ([0], [0])
for i in a:
	za.append(za[-1] + i)
for i in b:
	zb.append(zb[-1] + i)
for i in factors:
	for j in range(n - i + 1):
		if za[j + i] - za[j] == i:
			countA[i] += 1
	for j in range(m - i + 1):
		if zb[j + i] - zb[j] == i:
			countB[i] += 1
ans = 0
x = 1
for i in factors:
	ans += countA[i] * countB[k // i]
print(ans)


import math
(n, m, k) = [int(ele) for ele in input().split()]
a = [int(ele) for ele in input().split()]
b = [int(ele) for ele in input().split()]
lstA = []
lstB = []
prev = 0
for i in range(n):
	if a[i] == 1:
		if prev == 0:
			lstA.append(1)
		else:
			lstA[-1] += 1
		prev = 1
	else:
		prev = 0
prev = 0
for i in range(m):
	if b[i] == 1:
		if prev == 0:
			lstB.append(1)
		else:
			lstB[-1] += 1
		prev = 1
	else:
		prev = 0
factors = []
for i in range(1, int(math.sqrt(k) + 1)):
	if i * i == k:
		factors.append([i, i])
	elif i * (k // i) == k:
		factors.append([i, k // i])
		factors.append([k // i, i])
lst1 = []
lst2 = []
for i in range(n):
	lst1.append(0)
for i in range(m):
	lst2.append(0)
for ele in lstA:
	for i in range(1, ele + 1):
		lst1[i - 1] += ele - i + 1
for ele in lstB:
	for i in range(1, ele + 1):
		lst2[i - 1] += ele - i + 1
count = 0
for factor in factors:
	if factor[0] - 1 < n and factor[1] - 1 < m:
		count += lst1[factor[0] - 1] * lst2[factor[1] - 1]
print(count)


from itertools import groupby
from collections import Counter
(N, M, K, *AB) = map(int, open(0).read().split())
(A, B) = (AB[:N], AB[N:])
A = Counter((len(tuple(v)) for (k, v) in groupby(A) if k == 1))
B = Counter((len(tuple(v)) for (k, v) in groupby(B) if k == 1))
memo = {}

def solve(n, m):
	res = 0
	for x in range(1, n + 1):
		(y, r) = divmod(K, x)
		if r == 0:
			res += max(0, n - x + 1) * max(0, m - y + 1)
	memo[n, m] = res
	return res
ans = 0
for (n, v1) in A.items():
	for (m, v2) in B.items():
		if n * m >= K:
			ans += v1 * v2 * memo.get((n, m), solve(n, m))
print(ans)


(n, m, k) = map(int, input().split())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
factors = []
for i in range(1, int(k ** 0.5) + 1):
	if k % i == 0:
		factors.append((i, k // i))
		if i != k // i:
			factors.append((k // i, i))
(g1, g2) = ([], [])
count = l1[0]
for i in range(1, n):
	if l1[i] == 0 and l1[i - 1] == 1:
		g1.append(count)
		count = 0
	elif l1[i] == 1:
		count += 1
if count != 0:
	g1.append(count)
count = l2[0]
for i in range(1, m):
	if l2[i] == 0 and l2[i - 1] == 1:
		g2.append(count)
		count = 0
	elif l2[i] == 1:
		count += 1
if count != 0:
	g2.append(count)
ans = 0
for i in factors:
	count1 = []
	count2 = []
	for j in g1:
		if j >= i[0]:
			count1.append(j - i[0] + 1)
	for j in g2:
		if j >= i[1]:
			count2.append(j - i[1] + 1)
	for j in count1:
		for k in count2:
			ans += j * k
print(ans)


from math import sqrt
(n, m, k) = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
length_a = [0] * (len(a) + 1)
length_b = [0] * (len(b) + 1)
now_length = 0
for i in range(len(a)):
	if a[i] == 1:
		now_length += 1
	else:
		for j in range(now_length + 1):
			length_a[j] += now_length - j + 1
		now_length = 0
for j in range(now_length + 1):
	length_a[j] += now_length - j + 1
now_length = 0
for i in range(len(b)):
	if b[i] == 1:
		now_length += 1
	else:
		for j in range(now_length + 1):
			length_b[j] += now_length - j + 1
		now_length = 0
for j in range(now_length + 1):
	length_b[j] += now_length - j + 1
res = 0
for i in range(1, int(sqrt(k)) + 1):
	if k % i == 0:
		if i <= n and k // i <= m:
			res += length_a[i] * length_b[k // i]
		if i * i != k:
			if i <= m and k // i <= n:
				res += length_a[k // i] * length_b[i]
print(res)


import os
import sys
from io import BytesIO, IOBase
from math import sqrt
from bisect import bisect_left

def solution(n, m, k, arr, brr):
	pre_sum1 = [0] * n
	pre_sum2 = [0] * m
	pre_sum1[0] = arr[0]
	for i in range(1, n):
		pre_sum1[i] = pre_sum1[i - 1] + 1 if arr[i] else 0
	pre_sum2[0] = brr[0]
	for i in range(1, m):
		pre_sum2[i] = pre_sum2[i - 1] + 1 if brr[i] else 0
	pre_sum1.sort()
	pre_sum2.sort()
	divisors = set()
	for i in range(1, int(sqrt(k)) + 1):
		if k % i == 0:
			divisors.add(i)
			divisors.add(k // i)
	res = 0
	for d in divisors:
		(d1, d2) = (d, k // d)
		(f1, f2) = (bisect_left(pre_sum1, d1), bisect_left(pre_sum2, d2))
		if f1 != n and f2 != m:
			f1 = n - f1
			f2 = m - f2
			res += f1 * f2
	print(res)

def main():
	(n, m, k) = r_array()
	arr = r_array()
	brr = r_array()
	solution(n, m, k, arr, brr)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def write(*args, end='\n'):
	for x in args:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(end)

def r_array():
	return [int(x) for x in input().split()]

def r_int():
	return int(input())

def p_array(arr):
	for x in arr:
		write(x, end=' ')
	write()
main()


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
da = {}
db = {}
i = 0
j = 0
while i < n and j < n:
	while i < n and a[i] == 0:
		i += 1
	j = i
	while j < n and a[j] == 1:
		j += 1
	length = j - i
	for l in range(1, length + 1):
		try:
			da[l] += length - l + 1
		except:
			da[l] = length - l + 1
	i = j + 1
	j = i
i = 0
j = 0
while i < m and j < m:
	while i < m and b[i] == 0:
		i += 1
	j = i
	while j < m and b[j] == 1:
		j += 1
	length = j - i
	for l in range(1, length + 1):
		try:
			db[l] += length - l + 1
		except:
			db[l] = length - l + 1
	i = j + 1
	j = i
ans = 0
for i in da.keys():
	if k % i == 0:
		try:
			ans += da[i] * db[k // i]
		except:
			pass
print(ans)


from collections import Counter
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
mod = int(1000000000.0) + 7

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
(n, m, k) = rinput()
a = list(map(len, input().replace(' ', '').split('0')))
b = list(map(len, input().replace(' ', '').split('0')))
ans = 0
for i in factors(k):
	(temp1, temp2, temp3, temp4) = (0, 0, 0, 0)
	for segment in a:
		if i <= segment:
			temp1 += segment - i + 1
		if k // i <= segment:
			temp3 += segment - k // i + 1
	for segment in b:
		if i <= segment:
			temp2 += segment - i + 1
		if k // i <= segment:
			temp4 += segment - k // i + 1
	ans += temp1 * temp4 + temp2 * temp3
print(ans // 2)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
fact = []
for i in range(1, int(k ** 0.5) + 1):
	if k % i == 0:
		fact.append(i)
		if i != k // i:
			fact.append(k // i)
arr = [0] * (len(a) + 1)
brr = [0] * (len(b) + 1)
for i in range(n):
	arr[i + 1] = arr[i] + a[i]
for i in range(m):
	brr[i + 1] = brr[i] + b[i]
ans = 0
for i in range(1, n + 1):
	if k % i == 0 and k // i <= m:
		aa = 0
		bb = 0
		x = i
		y = k // i
		for ii in range(x, n + 1):
			if arr[ii] - arr[ii - x] == x:
				aa += 1
		for jj in range(y, m + 1):
			if brr[jj] - brr[jj - y] == y:
				bb += 1
		ans += aa * bb
print(ans)


def divisors(n):
	ind = 1
	arr = []
	while ind <= int(n ** 0.5):
		if n % ind == 0:
			if n // ind == ind:
				arr.append(ind)
			else:
				arr.append(ind)
				arr.append(n // ind)
		ind += 1
	arr.sort()
	return arr
(n, m, k) = list(map(int, input().split()))
row = list(map(int, input().split()))
col = list(map(int, input().split()))
div = divisors(k)
row_div = {}
col_div = {}
temp = [0] + row + [0]
cnt = 1
row_div[1] = temp.count(1)
for i in range(1, len(temp)):
	if temp[i] == temp[i - 1] and temp[i] == 1:
		cnt += 1
	else:
		count = 1
		while cnt > 1:
			if cnt in row_div:
				row_div[cnt] += count
			else:
				row_div[cnt] = count
			count += 1
			cnt -= 1
		cnt = 1
temp = [0] + col + [0]
cnt = 1
col_div[1] = temp.count(1)
for i in range(1, len(temp)):
	if temp[i] == temp[i - 1] and temp[i] == 1:
		cnt += 1
	else:
		count = 1
		while cnt > 1:
			if cnt in col_div:
				col_div[cnt] += count
			else:
				col_div[cnt] = count
			count += 1
			cnt -= 1
		cnt = 1
ans = 0
for i in div:
	cur = i
	nex = k // cur
	if cur in row_div and nex in col_div:
		ans += row_div[cur] * col_div[nex]
print(ans)


import sys
import math
from collections import defaultdict, Counter
(n, m, k1) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = 0
l1 = [0] * (n + 1)
l2 = [0] * (m + 1)
c1 = 0
c2 = 0
for j in range(n):
	if a[j]:
		c += 1
	else:
		for k in range(1, c + 1):
			l1[k] += c - k + 1
		c = 0
	c1 = max(c, c1)
for k in range(1, c + 1):
	l1[k] += c - k + 1
c = 0
for j in range(m):
	if b[j]:
		c += 1
	else:
		for k in range(1, c + 1):
			l2[k] += c - k + 1
		c = 0
	c2 = max(c, c2)
for k in range(1, c + 1):
	l2[k] += c - k + 1
ans = 0
for j in range(1, int(math.sqrt(k1)) + 1):
	if k1 % j == 0:
		if j <= c1 and k1 // j <= c2:
			ans += l1[j] * l2[k1 // j]
		if j != k1 // j and j <= c2 and (k1 // j <= c1):
			ans += l2[j] * l1[k1 // j]
print(ans)


from math import sqrt
(n, m, k) = map(int, input().split())
a = map(int, input().split())
b = map(int, input().split())

def make(a):
	d = dict()
	s = 0
	for v in a:
		s += v
		if v == 0 and s != 0:
			if s not in d:
				d[s] = 0
			d[s] += 1
			s = 0
	if s != 0:
		if s not in d:
			d[s] = 0
		d[s] += 1
	return d

def count(i, j, r, c):
	cnt = 0
	for (_r, x) in r:
		if i > _r:
			break
		for (_c, y) in c:
			if j > _c:
				break
			cnt += (_r - i + 1) * (_c - j + 1) * x * y
	return cnt
r = make(a)
c = make(b)
r = sorted(r.items(), key=lambda x: -x[0])
c = sorted(c.items(), key=lambda x: -x[0])
ans = 0
l = int(sqrt(k) + 0.0001) + 1
for i in range(1, l):
	if k % i == 0:
		j = k // i
		ans += count(i, j, r, c)
		if i != j:
			ans += count(j, i, r, c)
print(ans)


(n, m, k) = map(int, input().split())
a = list(map(len, input().replace(' ', '').split('0')))
b = list(map(len, input().replace(' ', '').split('0')))
p = [(i, k // i) for i in range(1, int(k ** 0.5) + 1) if k % i == 0]
p += [(j, i) for (i, j) in p if i != j]
ans = 0
for (i, j) in p:
	A = 0
	B = 0
	for l in a:
		if i <= l:
			A += l - i + 1
	for l in b:
		if j <= l:
			B += l - j + 1
	ans += A * B
print(ans)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve():
	(n, m, k) = sep()
	a = lis()
	b = lis()
	prea = [0] * (n + 1)
	preb = [0] * (m + 1)
	for i in range(n):
		if a[i] == 1:
			prea[i] = prea[i - 1] + 1
		else:
			prea[i] = prea[i - 1]
	for i in range(m):
		if b[i] == 1:
			preb[i] = preb[i - 1] + 1
		else:
			preb[i] = preb[i - 1]
	ff = []
	ss = []
	for i in range(1, floor(k ** 0.5) + 1):
		if k % i == 0:
			if i <= m and k // i <= n or (i <= n and k // i <= m):
				ff.append(i)
				ss.append(k // i)
	cnta = [0] * (n + 1)
	cntb = [0] * (m + 1)
	if ff != [] and ss != [] and (ff[len(ff) - 1] == ss[len(ss) - 1]):
		temp = ff + ss[:len(ss) - 1]
	else:
		temp = ff + ss
	for i in temp:
		if i <= n:
			for j in range(n - i + 1):
				if prea[j + i - 1] - prea[j - 1] == i:
					cnta[i] += 1
		if i <= m:
			for j in range(m - i + 1):
				if preb[j + i - 1] - preb[j - 1] == i:
					cntb[i] += 1
	ans = 0
	for i in range(len(ss)):
		l = ff[i]
		w = ss[i]
		if l <= n and w <= m:
			ans += cnta[l] * cntb[w]
		if l == w:
			continue
		if w <= n and l <= m:
			ans += cnta[w] * cntb[l]
	print(ans)
testcase(1)


from sys import stdin, gettrace
from collections import Counter
if not gettrace():

	def input():
		return next(stdin)[:-1]

def main():
	(n, m, k) = map(int, input().split())
	aa = input().split()
	bb = input().split()
	if m < n:
		(aa, bb) = (bb, aa)
		(n, m) = (m, n)
	asegs = sums(aa, n)
	bsegs = sums(bb, m)
	res = 0
	for i in range(1, min(n, k) + 1):
		if k % i == 0 and k // i <= m:
			res += asegs[i] * bsegs[k // i]
	print(res)

def sums(aa, n):
	acounts = [0] * (n + 1)
	ocount = 0
	for a in aa:
		if a == '1':
			ocount += 1
		else:
			acounts[ocount] += 1
			ocount = 0
	acounts[ocount] += 1
	amsum = 0
	for i in range(1, n + 1):
		amsum += acounts[i] * i
	asum = [0] * (n + 2)
	for i in range(n, 0, -1):
		asum[i] = asum[i + 1] + acounts[i]
	segs = [0, amsum]
	for i in range(2, n + 1):
		segs.append(segs[-1] - asum[i - 1])
	return segs
main()


from math import sqrt

def computesizes(Aarr, Barr, N, M, dims):
	(Awidths, Bwidths) = ([], [])
	(acount, bcount) = (0, 0)
	axiscounts = [[0, 0] for dim in dims]
	for (n, A) in enumerate(Aarr):
		if A == 1:
			acount += 1
			if n == N - 1:
				Awidths.append(acount)
		elif acount > 0 and A == 0:
			Awidths.append(acount)
			acount = 0
	for (m, B) in enumerate(Barr):
		if B == 1:
			bcount += 1
			if m == M - 1:
				Bwidths.append(bcount)
		elif bcount > 0 and B == 0:
			Bwidths.append(bcount)
			bcount = 0
	for A in Awidths:
		for (n, dim) in enumerate(dims):
			axiscounts[n][1] += max(A - dim[1] + 1, 0)
	for B in Bwidths:
		for (n, dim) in enumerate(dims):
			axiscounts[n][0] += max(B - dim[0] + 1, 0)
	blocks = sum((count[0] * count[1] for count in axiscounts))
	return blocks

def computedims(K):
	bound = int(sqrt(K))
	dims = []
	for f in range(1, bound + 1):
		if K % f == 0:
			dims.append((f, K // f))
			if f ** 2 != K:
				dims.append((K // f, f))
	return dims
(N, M, K) = list(map(int, input().split()))
dims = computedims(K)
Aarr = list(map(int, input().split()))
Barr = list(map(int, input().split()))
blockcount = computesizes(Aarr, Barr, N, M, dims)
print(blockcount)


import io, os
from sys import setrecursionlimit
from collections import defaultdict
from itertools import groupby
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def rint():
	return map(int, input().split())

def oint():
	return int(input())

def make_freq_line(a):
	freq = defaultdict(int)
	for (key, iter) in groupby(a):
		if key == 1:
			freq[len(list(iter))] += 1
	return freq

def make_rect(fa, fb):
	rect = defaultdict(int)
	for (ka, va) in fa.items():
		for (kb, vb) in fb.items():
			rect[ka, kb] += va * vb
	return rect

def find_divisor(n):
	i = 1
	div1 = []
	div2 = []
	while i * i < n:
		if n % i == 0:
			div1.append(i)
			div2.append(n // i)
		i += 1
	if i * i == n:
		div1.append(i)
	return div1 + div2[::-1]
(n, m, k) = rint()
a = list(rint())
b = list(rint())
fla = make_freq_line(a)
flb = make_freq_line(b)
rect = make_rect(fla, flb)
div = find_divisor(k)
ans = 0
for ((r, c), v) in rect.items():
	for sr in div:
		sc = k // sr
		if r < sr or c < sc:
			continue
		ans += (r - sr + 1) * (c - sc + 1) * v
print(ans)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
nfact = 0
fact = []
i = 1
while i * i <= k:
	if k % i == 0:
		nfact += 1
		fact = fact + [i]
		if i * i < k:
			nfact += 1
			fact = fact + [k // i]
	i = i + 1
fact.sort()
facta = [0] * nfact
factb = [0] * nfact
cur = 0
for i in range(n):
	if a[i] == 1:
		cur += 1
	elif cur > 0:
		j = 0
		while j < nfact and cur >= fact[j]:
			if cur >= fact[j]:
				facta[j] = facta[j] + cur - fact[j] + 1
			j = j + 1
		cur = 0
if cur > 0:
	j = 0
	while j < nfact and cur >= fact[j]:
		if cur >= fact[j]:
			facta[j] = facta[j] + cur - fact[j] + 1
		j = j + 1
cur = 0
for i in range(m):
	if b[i] == 1:
		cur += 1
	elif cur > 0:
		j = 0
		while j < nfact and cur >= fact[j]:
			if cur >= fact[j]:
				factb[j] = factb[j] + cur - fact[j] + 1
			j = j + 1
		cur = 0
if cur > 0:
	j = 0
	while j < nfact and cur >= fact[j]:
		if cur >= fact[j]:
			factb[j] = factb[j] + cur - fact[j] + 1
		j = j + 1
sol = 0
for i in range(nfact):
	sol = sol + facta[i] * factb[-i - 1]
print(sol)


(c, r, k) = list(map(int, input().split()))
clst = list(map(int, input().split()))
rlst = list(map(int, input().split()))

def check(lst, k):
	if len(lst) < k:
		return 0
	ret = 0
	cursum = sum(lst[:k])
	if cursum == k:
		ret += 1
	for i in range(1, len(lst) - k + 1):
		cursum -= lst[i - 1]
		cursum += lst[i + k - 1]
		if cursum == k:
			ret += 1
	return ret
ans = 0
for i in range(1, c + 1):
	if k % i == 0:
		ccnt = check(clst, i)
		rcnt = check(rlst, k // i)
		ans += ccnt * rcnt
print(ans)


from collections import Counter as C
(n, m, k) = map(int, input().split())
a = list(map(int, input().split())) + [0]
b = list(map(int, input().split())) + [0]
(c, d) = ([], [])
for i in range(1, n + 1):
	if a[i] == 0:
		c.append(a[i - 1])
	else:
		a[i] = a[i - 1] + 1
for i in range(1, m + 1):
	if b[i] == 0:
		d.append(b[i - 1])
	else:
		b[i] = b[i - 1] + 1
a = sorted(C(c).items(), key=lambda x: x[0])
b = sorted(C(d).items(), key=lambda x: x[0])
(s, t) = (len(a), len(b))
ans = 0
for i in range(1, int(k ** 0.5) + 1):
	if k % i == 0:
		(c, d) = (0, 0)
		for j in range(s - 1, -1, -1):
			if a[j][0] >= i:
				c += (a[j][0] - i + 1) * a[j][1]
			if a[j][0] >= k // i:
				d += (a[j][0] - k // i + 1) * a[j][1]
			elif a[j][0] < i and a[j][0] < k // i:
				break
		(e, f) = (0, 0)
		for j in range(t - 1, -1, -1):
			if b[j][0] >= i:
				e += (b[j][0] - i + 1) * b[j][1]
			if b[j][0] >= k // i:
				f += (b[j][0] - k // i + 1) * b[j][1]
			elif b[j][0] < i and b[j][0] < k // i:
				break
		if i != k // i:
			ans += c * f + e * d
		else:
			ans += c * f
print(ans)


(a, b, k) = map(int, input().split())
l = list(map(int, input().split()))
l1 = list(map(int, input().split()))
c = 0
c1 = 0
for i in range(a):
	if l[i] == 0:
		c += 1
for i in range(b):
	if l1[i] == 0:
		c1 += 1
f = [0] * (c + 1)
g = [0] * (c1 + 1)
t = 0
start = 0
l.append(0)
l1.append(0)
for i in range(a + 1):
	if l[i] == 0:
		f[t] = i - start
		start = i + 1
		t += 1
t = 0
start = 0
for i in range(b + 1):
	if l1[i] == 0:
		g[t] = i - start
		start = i + 1
		t += 1
ans = 0
for i in range(1, int(k ** 0.5) + 1):
	if k % i != 0:
		continue
	n = 0
	n1 = 0
	for j in range(c + 1):
		n += max(0, f[j] - i + 1)
	for j in range(c1 + 1):
		n1 += max(0, g[j] - k // i + 1)
	n2 = 0
	n3 = 0
	if i == k // i:
		ans += n * n1
		continue
	for j in range(c + 1):
		n2 += max(0, f[j] - k // i + 1)
	for j in range(c1 + 1):
		n3 += max(0, g[j] - i + 1)
	ans += n * n1 + n2 * n3
print(ans)


def I():
	return list(map(int, input().split()))

def sieve(n):
	a = [1] * n
	for i in range(2, n):
		if a[i]:
			for j in range(i * i, n, i):
				a[j] = 0
	return a
(n, m, k) = I()
a = I()
b = I()
newa = []
newb = []
i = 0
da = {}
db = {}
while i < n:
	while i < n and a[i] == 0:
		i += 1
	c = 0
	j = i
	while i < n and a[i] == 1:
		i += 1
	for subl in range(1, i - j + 1):
		if k % subl == 0:
			da[subl] = da.get(subl, 0) + (i - j + 1 - subl)
	newa.append(c)
newa.sort()
i = 0
while i < m:
	while i < m and b[i] == 0:
		i += 1
	c = 0
	j = i
	while i < m and b[i] == 1:
		i += 1
	for subl in range(1, i - j + 1):
		db[subl] = db.get(subl, 0) + (i - j + 1 - subl)
	newb.append(c)
newb.sort()
n = len(newb)
m = len(newb)
prefb = [0] * (m + 1)
prefb[0] = newb[0]
for i in range(1, m):
	prefb[i] = prefb[i - 1] + newb[i]
l = 0
r = m - 1
ans = 0
for i in da.keys():
	ans += da[i] * db.get(k // i, 0)
print(ans)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
from collections import defaultdict
from itertools import permutations
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ac = [0] * n
bc = [0] * m
a.append(0)
b.append(0)
curr = 0
for i in range(n + 1):
	if a[i] == 1:
		curr += 1
	else:
		ct = 1
		for j in range(curr - 1, -1, -1):
			ac[j] += ct
			ct += 1
		curr = 0
for i in range(m + 1):
	if b[i] == 1:
		curr += 1
	else:
		ct = 1
		for j in range(curr - 1, -1, -1):
			bc[j] += ct
			ct += 1
		curr = 0
r = 0
for i in range(1, int(math.sqrt(k)) + 1):
	if k % i == 0:
		c1 = i - 1
		c2 = k // i - 1
		if c1 < n and c2 < m:
			r += ac[c1] * bc[c2]
		if i * i != k and c2 < n and (c1 < m):
			r += ac[c2] * bc[c1]
print(r)


import math

def handle(a: list, s: list):
	t = []
	cnt = 0
	for i in a:
		if i == 1:
			cnt += 1
		elif cnt != 0:
			t.append(cnt)
			cnt = 0
	if cnt != 0:
		t.append(cnt)
	a.clear()
	a += t
	a.sort()
	s.clear()
	s.append(0)
	for i in a:
		s.append(s[-1] + i)

def lower_bound(a: list, x: int) -> int:
	if len(a) == 0 or a[-1] < x:
		return len(a)
	l = 0
	r = len(a) - 1
	while l < r:
		m = l + r >> 1
		if a[m] < x:
			l = m + 1
		else:
			r = m
	return r

def cal(a: list, x: int, s: list) -> int:
	p = lower_bound(a, x)
	return s[-1] - s[p] - (x - 1) * (len(a) - p)
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
s1 = []
s2 = []
handle(a, s1)
handle(b, s2)
ans = 0
sq = math.sqrt(k)
i = 1
while i < sq:
	if k % i == 0:
		ans += cal(a, i, s1) * cal(b, k // i, s2)
		ans += cal(a, k // i, s1) * cal(b, i, s2)
	i += 1
sq = int(sq)
if sq * sq == k:
	ans += cal(a, sq, s1) * cal(b, sq, s2)
print(ans)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
da = dict()
db = dict()
count = 0
for i in range(n):
	if a[i] == 0:
		for j in range(1, count + 1):
			if j in da.keys():
				da[j] += count - j + 1
			else:
				da[j] = count - j + 1
		count = 0
	else:
		count += 1
if count > 0:
	for j in range(1, count + 1):
		if j in da.keys():
			da[j] += count - j + 1
		else:
			da[j] = count - j + 1
count = 0
for i in range(m):
	if b[i] == 0:
		for j in range(1, count + 1):
			if j in db.keys():
				db[j] += count - j + 1
			else:
				db[j] = count - j + 1
		count = 0
	else:
		count += 1
if count > 0:
	for j in range(1, count + 1):
		if j in db.keys():
			db[j] += count - j + 1
		else:
			db[j] = count - j + 1
ans = 0
for ka in da.keys():
	if ka > k:
		continue
	if k % ka == 0:
		kb = k // ka
		if kb in db.keys():
			ans += da[ka] * db[kb]
print(ans)


import sys

def g(a):
	n = len(a)
	ans = [0] * (n + 1)
	i = 0
	while i < n:
		if a[i] == 0:
			i += 1
			continue
		j = i
		while j < n and a[j] == 1:
			j += 1
		for k in range(1, j - i + 1):
			ans[k] += j - i - k + 1
		i = j
	return ans
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
(c1, c2) = (g(a), g(b))
ans = 0
for i in range(1, len(c1)):
	if k % i == 0 and k // i <= m:
		ans += c1[i] * c2[k // i]
print(ans)


(n, m, k) = map(int, input().split())
a = tuple(map(int, input().split()))
b = tuple(map(int, input().split()))
(al, bl) = ([], [])
tmp = 0
for ai in a:
	if ai == 1:
		tmp += 1
	elif tmp > 0:
		al.append(tmp)
		tmp = 0
if tmp > 0:
	al.append(tmp)
tmp = 0
for bi in b:
	if bi == 1:
		tmp += 1
	elif tmp > 0:
		bl.append(tmp)
		tmp = 0
if tmp > 0:
	bl.append(tmp)
ans = 0
for i in range(1, k + 1):
	if i * i > k:
		break
	if k % i != 0:
		continue
	j = k // i
	(p, q, r, s) = (0, 0, 0, 0)
	for pi in al:
		p += max(0, pi - i + 1)
		r += max(0, pi - j + 1)
	for qi in bl:
		q += max(0, qi - j + 1)
		s += max(0, qi - i + 1)
	if i == j:
		ans += p * q
	else:
		ans += p * q + r * s
print(ans)


def C(n):
	return n * (n - 1) // 2
(a, b, k) = list(map(int, input().split()))
x = list(map(str, input().split()))
y = list(map(str, input().split()))
x = ''.join(x)
y = ''.join(y)
x = x.split('0')
y = y.split('0')
x = [len(i) for i in x]
y = [len(i) for i in y]
total = 0
sumon = {}
vumon = {}
for i in range(1, int(k ** 0.5) + 1):
	if k % i == 0:
		if i != k ** 0.5:
			tx = i
			ty = k // tx
			vumon[tx] = vumon.get(tx, sum([max(0, xi - tx + 1) for xi in x]))
			sumon[ty] = sumon.get(ty, sum([max(0, xi - ty + 1) for xi in y]))
			total += vumon[tx] * sumon[ty]
			(tx, ty) = (ty, tx)
			vumon[tx] = vumon.get(tx, sum([max(0, xi - tx + 1) for xi in x]))
			sumon[ty] = sumon.get(ty, sum([max(0, xi - ty + 1) for xi in y]))
			total += vumon[tx] * sumon[ty]
		else:
			tx = ty = int(k ** 0.5)
			vumon[tx] = vumon.get(tx, sum([max(0, xi - tx + 1) for xi in x]))
			sumon[ty] = sumon.get(ty, sum([max(0, xi - ty + 1) for xi in y]))
			total += vumon[tx] * sumon[ty]
print(total)


import os
import sys
from io import BytesIO, IOBase
import threading
from collections import Counter
mod = 998244353

def main():
	for _ in range(1):
		(n, m, k) = map(int, input().split())
		arr = list(map(int, input().split()))
		brr = list(map(int, input().split()))
		ans = 0
		for num in range(1, n + 1):
			if k % num == 0:
				t = k // num
				i1 = 0
				i2 = 0
				c1 = 0
				for i in arr:
					if i == 0:
						c1 = 0
					else:
						c1 += 1
					if c1 >= num:
						i1 += 1
				c2 = 0
				for i in brr:
					if i == 0:
						c2 = 0
					else:
						c2 += 1
					if c2 >= t:
						i2 += 1
				ans += i1 * i2
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
A = [0 for i in range(n + 1)]
B = [0 for i in range(m + 1)]
ct = 0
for i in range(n):
	if a[i] == 0:
		ct = 0
	else:
		ct += 1
		A[ct] += 1
ct = 0
for i in range(m):
	if b[i] == 0:
		ct = 0
	else:
		ct += 1
		B[ct] += 1
for i in range(n - 1, 0, -1):
	A[i] += A[i + 1]
for i in range(m - 1, 0, -1):
	B[i] += B[i + 1]
i = 1
ans = 0
while i * i <= k:
	if k % i == 0:
		if i <= n and k // i <= m:
			ans += A[i] * B[k // i]
		if i * i != k and i <= m and (k // i <= n):
			ans += B[i] * A[k // i]
	i += 1
print(ans)


import io, os
from sys import setrecursionlimit
from collections import defaultdict
from itertools import groupby
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def rint():
	return map(int, input().split())

def oint():
	return int(input())

def get_str():
	return input().decode().strip()
(n, m, k) = rint()
fla = [len(a) for a in get_str().replace(' ', '').split('0') if len(a)]
flb = [len(a) for a in get_str().replace(' ', '').split('0') if len(a)]
ans = 0
i = 1
while i * i <= k:
	if k % i == 0:
		sr = i
		sc = k // sr
		ans += sum((r - sr + 1 for r in fla if sr <= r)) * sum((c - sc + 1 for c in flb if sc <= c))
		if sr == sc:
			break
		(sr, sc) = (sc, sr)
		ans += sum((r - sr + 1 for r in fla if sr <= r)) * sum((c - sc + 1 for c in flb if sc <= c))
	i += 1
print(ans)


import sys
input = sys.stdin.readline
from math import sqrt
from collections import defaultdict as dd
(n, m, k) = map(int, input().split())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
cou = 0
d1 = dd(int)
for i in range(n):
	if l1[i]:
		cou += 1
	else:
		cc = cou
		for j in range(1, cou + 1):
			d1[j] += cc
			cc -= 1
		cou = 0
cc = cou
for j in range(1, cou + 1):
	d1[j] += cc
	cc -= 1
cou = 0
d2 = dd(int)
cou = 0
for i in range(m):
	if l2[i]:
		cou += 1
	else:
		cc = cou
		for j in range(1, cou + 1):
			d2[j] += cc
			cc -= 1
		cou = 0
cc = cou
for j in range(1, cou + 1):
	d2[j] += cc
	cc -= 1
cou = 0
sk = int(sqrt(k))
su = 0
for i in range(1, sk + 1):
	if k % i == 0:
		su += d1[i] * d2[k // i]
		if i != k // i:
			su += d1[k // i] * d2[i]
print(su)


(n, m, K) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
k = [0] * (n + 1)
l = [0] * (m + 1)
cur = 0
for i in range(n):
	if a[i]:
		cur += 1
	else:
		k[cur] += 1
		cur = 0
k[cur] += 1
cur = 0
for i in range(m):
	if b[i]:
		cur += 1
	else:
		l[cur] += 1
		cur = 0
l[cur] += 1
cur = k[-1]
for i in range(n - 1, -1, -1):
	t = k[i]
	k[i] = k[i] + k[i + 1] + cur
	cur += t
cur = l[-1]
for i in range(m - 1, -1, -1):
	t = l[i]
	l[i] = l[i] + l[i + 1] + cur
	cur += t
ans = 0
i = 1
while i * i <= K:
	if K % i == 0:
		if i <= n and K / i <= m:
			ans += k[i] * l[K // i]
		if K / i <= n and i <= m and (i != K // i):
			ans += k[K // i] * l[i]
	i += 1
print(ans)


(x, y, size) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
test1 = {}
test2 = {}
i = 1
while i * i <= size:
	if size % i == 0:
		test1[i] = 0
		test2[i] = 0
		test1[size // i] = 0
		test2[size // i] = 0
	i += 1
c = 0
for i in range(x):
	if a[i] == 1:
		c += 1
	else:
		for j in test1:
			if j <= c:
				test1[j] += c - j + 1
		c = 0
for j in test1:
	if j <= c:
		test1[j] += c - j + 1
c = 0
for i in range(y):
	if b[i] == 1:
		c += 1
	else:
		for j in test2:
			if j <= c:
				test2[j] += c - j + 1
		c = 0
for j in test2:
	if j <= c:
		test2[j] += c - j + 1
count = 0
for i in test1:
	for j in test2:
		if i * j == size:
			count += test1[i] * test2[j]
print(count)


def factors(n):
	result = set()
	for i in range(1, int(n ** 0.5) + 1):
		(div, mod) = divmod(n, i)
		if mod == 0:
			result |= {i, div}
	return list(result)

def check(l, k):
	if len(l) < k:
		return 0
	count = 0
	s = sum(l[:k])
	if s == k:
		count += 1
	for i in range(1, len(l) - k + 1):
		s -= l[i - 1]
		s += l[i + k - 1]
		if s == k:
			count += 1
	return count
ans = 0
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
f = factors(k)
count = 0
for x in f:
	pre = x
	pro = k // x
	ans += check(a, pro) * check(b, pre)
print(ans)


from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect
import math

def turn(b):
	bdash = []
	m = len(b)
	j = 0
	while j < m:
		tmp = j
		while j + 1 < m and b[j + 1] == b[tmp]:
			j += 1
		if b[tmp] == 1:
			bdash.append(j - tmp + 1)
		j += 1
	return bdash

def test_case():
	info = list(map(int, input().split()))
	(n, m, k) = info
	ksq = int(math.ceil(k ** 0.5))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = 0
	bdash = turn(b)
	adash = turn(a)
	bdash.sort(reverse=True)
	adash.sort(reverse=True)
	dp = {}
	for ydim in adash:
		if ydim in dp:
			ans += dp[ydim]
			continue
		now = 0
		for xdim in bdash:
			if (xdim, ydim) in dp:
				now += dp[xdim, ydim]
				continue
			nnow = 0
			for y in range(1, ydim + 1):
				x = k // y
				if x * y == k and x <= xdim and (y <= ydim):
					nnow += (xdim - x + 1) * (ydim - y + 1)
			now += nnow
			dp[xdim, ydim] = nnow
		dp[ydim] = now
		ans += now
	return ans
ret = test_case()
if ret != None:
	print(ret)


from math import sqrt, ceil

def int_as_array(num):
	return list(map(int, [y for y in str(num)]))

def array_as_int(arr):
	return int(''.join(map(str, arr)))

def read_int():
	return int(input())

def read_array():
	return list(map(int, input().split(' ')))

def array_to_string(arr, sep=' '):
	return sep.join(map(str, arr))

def matrix_to_string(arr, sep=' '):
	return '[\n' + '\n'.join([sep.join(map(str, row)) for row in arr]) + '\n]'

def solve(N, M, K, A, B):
	L_a = max_ones(A)
	L_b = max_ones(B)
	total = 0
	for (p, q) in all_divisors(K):
		total += count_recs(p, q, L_a, L_b)
	print(total)
	return total

def all_divisors(K):
	out = []
	sqrt_k = ceil(sqrt(K + 1))
	for p in range(1, sqrt_k):
		if K % p == 0:
			q = K // p
			out.append((p, q))
			if p != q:
				out.append((q, p))
	return out

def max_ones(a):
	L_a = [0]
	seg_i = 0
	for (i, j) in enumerate(a):
		if j == 1:
			L_a[seg_i] += 1
		elif L_a[seg_i] > 0:
			L_a.append(0)
			seg_i += 1
	return L_a

def count_recs(p, q, L_a, L_b):
	countW = 0
	countH = 0
	for l in L_a:
		if l >= p:
			countW += l - p + 1
	for j in L_b:
		if j >= q:
			countH += j - q + 1
	return countH * countW
(N, M, K) = read_array()
A = read_array()
B = read_array()
solve(N, M, K, A, B)


from sys import stdin
from collections import defaultdict
input = stdin.readline
(n, m, k) = map(int, input().split())
n_map = [0] * (n + 1)
m_map = [0] * (m + 1)
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
count = 0
for elem in l1:
	if elem == 0:
		count = 0
	else:
		count += 1
		n_map[count] += 1
count = 0
for elem in l2:
	if elem == 0:
		count = 0
	else:
		count += 1
		m_map[count] += 1
for idx in range(n - 1, -1, -1):
	n_map[idx] += n_map[idx + 1]
for idx in range(m - 1, -1, -1):
	m_map[idx] += m_map[idx + 1]
count = 0
for i in range(1, n + 1):
	if k % i or k // i >= len(m_map):
		continue
	count += m_map[k // i] * n_map[i]
print(count)


import sys
input = sys.stdin.buffer.readline

def solution():
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.append(0)
	b.append(0)
	d1 = {}
	d2 = {}
	l = 0
	for i in range(n):
		if a[i] == 1:
			l += 1
		if a[i] == 0:
			l = 0
		if a[i] == 1 and a[i + 1] == 0:
			d1[l] = d1.get(l, 0) + 1
	l = 0
	for i in range(m):
		if b[i] == 1:
			l += 1
		if b[i] == 0:
			l = 0
		if b[i] == 1 and b[i + 1] == 0:
			d2[l] = d2.get(l, 0) + 1
	ans = 0
	for i in range(1, int(k ** 0.5) + 1):
		cnt1 = cnt2 = cnt3 = cnt4 = 0
		if k % i == 0:
			j = k // i
			for z in d1.keys():
				if z >= i:
					cnt1 += (z - i + 1) * d1[z]
				if z >= j and i != j:
					cnt2 += (z - j + 1) * d1[z]
			for z in d2.keys():
				if z >= j:
					cnt3 += (z - j + 1) * d2[z]
				if z >= i and i != j:
					cnt4 += (z - i + 1) * d2[z]
			ans += cnt1 * cnt3 + cnt2 * cnt4
	print(ans)
solution()


import sys
import math
import heapq
import collections

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

def inputlist():
	return list(map(int, input().split()))

def inputstring():
	return [x for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d

def get(a):
	rtn = []
	one = False
	cur = 0
	for i in range(len(a)):
		if a[i] == 1 and (not one):
			one = True
		if a[i] == 1 and one:
			cur += 1
		if a[i] == 0 and one:
			rtn.append(cur)
			cur = 0
			one = False
		elif i == len(a) - 1 and cur > 0:
			rtn.append(cur)
	return rtn
(n, m, k) = inputnums()
a = inputlist()
b = inputlist()
length = get(a)
width = get(b)
ans = 0
i = 1
while i * i <= k:
	lengthcount = 0
	widthcount = 0
	if k % i == 0:
		for j in range(len(length)):
			if length[j] >= i:
				lengthcount += length[j] - i + 1
		for j in range(len(width)):
			if width[j] >= k // i:
				widthcount += width[j] - k // i + 1
		ans += lengthcount * widthcount
		lengthcount = 0
		widthcount = 0
		if k != i * i:
			for j in range(len(length)):
				if length[j] >= k // i:
					lengthcount += length[j] - k // i + 1
			for j in range(len(width)):
				if width[j] >= i:
					widthcount += width[j] - i + 1
			ans += lengthcount * widthcount
	i += 1
print(ans)


from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def dict_adder(d, key):
	if key not in d:
		d[key] = 0
	d[key] += 1
	return d
(n, m, k) = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
g = factors(k)
d1 = {}
d2 = {}
a_streak = b_streak = 0
for i in range(n):
	if a[i] == 1:
		a_streak += 1
	else:
		d1 = dict_adder(d1, a_streak)
		a_streak = 0
for i in range(m):
	if b[i] == 1:
		b_streak += 1
	else:
		d2 = dict_adder(d2, b_streak)
		b_streak = 0
d1 = dict_adder(d1, a_streak)
d2 = dict_adder(d2, b_streak)
ans = 0
for i in g:
	(x, y) = (i, k // i)
	cx = cy = 0
	for (key, val) in d1.items():
		if key >= x:
			cx += val * (key - x + 1)
	for (key, val) in d2.items():
		if key >= y:
			cy += val * (key - y + 1)
	ans += cx * cy
print(ans)


def func(arr, length, source):
	count = 0
	for temp_i in range(length):
		if source[temp_i] == 1:
			count += 1
		else:
			arr.append(count)
			count = 0
	else:
		arr.append(count)
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
height = []
weight = []
rem = []
result = 0
func(height, n, a)
func(weight, m, b)
for i in range(1, int(k ** 0.5) + 1):
	if k % i == 0:
		rem.append((i, k // i))
		if i != k // i:
			rem.append((k // i, i))
for i in range(len(rem)):
	l_h = 0
	l_w = 0
	for j in range(len(height)):
		if height[j] >= rem[i][0]:
			l_h += height[j] - rem[i][0] + 1
	for g in range(len(weight)):
		if weight[g] >= rem[i][1]:
			l_w += weight[g] - rem[i][1] + 1
	result += l_h * l_w
print(result)


import math
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
(a_size, b_size) = ([], [])
temp = 0
for i in range(len(a)):
	if a[i] == 1:
		temp += 1
	if a[i] == 0:
		a_size.append(temp)
		temp = 0
if temp != 0:
	a_size.append(temp)
temp = 0
for i in range(len(b)):
	if b[i] == 1:
		temp += 1
	if b[i] == 0:
		b_size.append(temp)
		temp = 0
if temp != 0:
	b_size.append(temp)
(row, col) = (dict(), dict())
(x, y) = (set(), set())
for i in a_size:
	if i in x:
		row[i] += 1
	else:
		row[i] = 1
for i in b_size:
	if i in y:
		col[i] += 1
	else:
		col[i] = 1
ans = 0
rr = int(int(k ** 0.5) + 1)
for i in range(1, rr):
	if k % i == 0:
		n1 = k / i
		n2 = i
		(temp1, temp2) = (0, 0)
		for val in a_size:
			if val >= n1:
				temp1 += int(val - n1 + 1)
		for val in b_size:
			if val >= n2:
				temp2 += int(val - n2 + 1)
		ans += int(temp1 * temp2)
		if n1 != n2:
			(n1, n2) = (n2, n1)
			(temp1, temp2) = (0, 0)
			for val in a_size:
				if val >= n1:
					temp1 += int(val - n1 + 1)
			for val in b_size:
				if val >= n2:
					temp2 += int(val - n2 + 1)
			ans += temp1 * temp2
print(ans)


from math import sqrt
(n, m, k) = map(int, input().split())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
r = []
s = 0
for i in range(len(l1)):
	if i > 0 and l1[i] == l1[i - 1] and (l1[i] == 1):
		s = s + 1
	elif l1[i] == 0:
		r.append(s)
		s = 0
	elif l1[i] == 1:
		s = 1
r.append(s)
r.sort()
r1 = []
s = 0
for i in range(len(l2)):
	if i > 0 and l2[i] == l2[i - 1] and (l2[i] == 1):
		s = s + 1
	elif l2[i] == 0:
		r1.append(s)
		s = 0
	elif l2[i] == 1:
		s = 1
r1.append(s)
r1.sort()
fact = []
for i in range(1, int(sqrt(k)) + 1):
	if k % i == 0 and k % (k // i) == 0 and (i != k // i):
		fact.append(i)
		fact.append(k // i)
	elif k // i == i and k % i == 0:
		fact.append(i)
fact.sort()
d1 = {fact[i]: 0 for i in range(len(fact))}
d2 = {fact[i]: 0 for i in range(len(fact))}
store1 = [0 for i in range(len(r) + 1)]
for i in range(1, len(r) + 1):
	store1[i] = store1[i - 1] + r[i - 1]
i = 0
j = 0
x = len(store1) - 1
while i <= len(fact) - 1 and j <= len(r) - 1:
	if fact[i] <= r[j]:
		d1[fact[i]] = d1[fact[i]] + store1[x] - store1[j] - (x - j) * fact[i] + x - j
		i = i + 1
	elif fact[i] > r[j]:
		j = j + 1
store2 = [0 for i in range(len(r1) + 1)]
y = len(store2) - 1
for i in range(1, len(r1) + 1):
	store2[i] = store2[i - 1] + r1[i - 1]
i = 0
j = 0
while i <= len(fact) - 1 and j <= len(r1) - 1:
	if fact[i] <= r1[j]:
		d2[fact[i]] = d2[fact[i]] + store2[y] - store2[j] - (y - j) * fact[i] + y - j
		i = i + 1
	elif fact[i] > r1[j]:
		j = j + 1
ans = 0
for i in d1:
	ans = ans + d1[i] * d2[k // i]
print(ans)


import math
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
(a_size, b_size) = ([], [])
temp = 0
for i in range(len(a)):
	if a[i] == 1:
		temp += 1
	if a[i] == 0:
		a_size.append(temp)
		temp = 0
if temp != 0:
	a_size.append(temp)
temp = 0
for i in range(len(b)):
	if b[i] == 1:
		temp += 1
	if b[i] == 0:
		b_size.append(temp)
		temp = 0
if temp != 0:
	b_size.append(temp)
ans = 0
rr = int(int(k ** 0.5) + 1)
for i in range(1, rr):
	if k % i == 0:
		n1 = k / i
		n2 = i
		(temp1, temp2) = (0, 0)
		for val in a_size:
			if val >= n1:
				temp1 += int(val - n1 + 1)
		for val in b_size:
			if val >= n2:
				temp2 += int(val - n2 + 1)
		ans += int(temp1 * temp2)
		if n1 != n2:
			(n1, n2) = (n2, n1)
			(temp1, temp2) = (0, 0)
			for val in a_size:
				if val >= n1:
					temp1 += int(val - n1 + 1)
			for val in b_size:
				if val >= n2:
					temp2 += int(val - n2 + 1)
			ans += temp1 * temp2
print(ans)


from collections import defaultdict
R = lambda : list(map(int, input().split()))
(n, m, k) = R()
(ar, br) = (R(), R())

def split_ar(aa, sz):
	(cc, res) = (0, defaultdict(int))
	for i in range(sz):
		if aa[i] == 0:
			continue
		cc += 1
		if i == sz - 1 or aa[i + 1] == 0:
			res[cc] += 1
			cc = 0
	return res

def count_rect(u, v):
	cc = 0
	for i in range(1, u + 1):
		if k % i or k // i > v:
			continue
		cc += (u - i + 1) * (v - k // i + 1)
	return cc
(sa, sb) = (split_ar(ar, n), split_ar(br, m))
cc = 0
for (av, ac) in sa.items():
	for (bv, bc) in sb.items():
		cc += count_rect(av, bv) * ac * bc
print(cc)


import os
import heapq
import sys, threading
import math as mt
import operator
from copy import copy
from collections import defaultdict, deque
from io import BytesIO, IOBase
sys.setrecursionlimit(10 ** 5)

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

def inpt():
	return [int(k) for k in input().split()]

def fun(ar):
	ans = [0] * (len(ar) + 1)
	i = 0
	while i < len(ar):
		if ar[i] == 0:
			i += 1
			continue
		j = i
		count = 0
		while j < len(ar) and ar[j] == 1:
			count += 1
			j += 1
		for k in range(count):
			ans[k + 1] += count - k
		i = j
	return ans

def main():
	(n, m, k) = inpt()
	ar = inpt()
	br = inpt()
	a1 = fun(ar)
	a2 = fun(br)
	ans = 0
	for i in range(1, len(a1)):
		if k % i == 0 and k // i < len(a2):
			ans += a1[i] * a2[k // i]
	print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from math import sqrt
(n, m, k) = list(map(int, input().split()))
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
ac = [0] * (n + 1)
bc = [0] * (m + 1)
cs = 0
for ai in a:
	if ai == 1:
		cs += 1
	if ai == 0:
		ac[cs] += 1
		cs = 0
ac[cs] += 1
cs = 0
for bi in b:
	if bi == 1:
		cs += 1
	if bi == 0:
		bc[cs] += 1
		cs = 0
bc[cs] += 1
pairs = []
for i in range(1, int(sqrt(k) + 1)):
	if k % i == 0:
		pairs.append((i, k // i))
total = 0
for (i, j) in pairs:
	if i <= n and j <= m:
		act = 0
		for k in range(i, n + 1):
			act += ac[k] * (k - i + 1)
		bct = 0
		for k in range(j, m + 1):
			bct += bc[k] * (k - j + 1)
		total += act * bct
	if j <= n and i <= m and (i != j):
		act = 0
		for k in range(j, n + 1):
			act += ac[k] * (k - j + 1)
		bct = 0
		for k in range(i, m + 1):
			bct += bc[k] * (k - i + 1)
		total += act * bct
print(total)


def countseg(a, b, x, y):
	seg1 = 0
	seg2 = 0
	for j in range(len(a)):
		if a[j] >= x:
			seg1 = seg1 + a[j] - x + 1
	for j in range(len(b)):
		if b[j] >= y:
			seg2 = seg2 + b[j] - y + 1
	return seg1 * seg2
from math import sqrt
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ma = list()
mb = list()
c = 0
for i in range(n):
	if a[i] == 1:
		c = c + 1
	else:
		ma.append(c)
		c = 0
if a[n - 1] == 1:
	ma.append(c)
c = 0
for i in range(m):
	if b[i] == 1:
		c = c + 1
	else:
		mb.append(c)
		c = 0
if b[m - 1] == 1:
	mb.append(c)
ans = 0
for i in range(1, int(sqrt(k)) + 1):
	if k % i == 0:
		x = i
		y = k // i
		ans = ans + countseg(ma, mb, x, y)
		if x != y:
			ans = ans + countseg(ma, mb, y, x)
print(ans)


maxn = 40050
f1 = [0] * maxn
f2 = [0] * maxn
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
i = 0
while i < n:
	if a[i] == 0:
		i += 1
		continue
	j = i
	while j < n and a[j] == 1:
		j += 1
	for x in range(1, j - i + 1):
		f1[x] += j - i - x + 1
	i = j
i = 0
while i < m:
	if b[i] == 0:
		i += 1
		continue
	j = i
	while j < m and b[j] == 1:
		j += 1
	for x in range(1, j - i + 1):
		f2[x] += j - i - x + 1
	i = j
res = 0
for x in range(1, maxn):
	if k % x == 0 and k // x < maxn:
		res += f1[x] * f2[k // x]
print(res)


import sys
input = sys.stdin.readline

def fastio():
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()
INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br
(n, m, k) = I()
a = I()
b = I()
ans = 0
(i, j) = (0, 0)
(start_a, start_b) = (0, 0)

def factors(x):
	res = []
	for i in range(1, int(x ** 0.5) + 1):
		if x % i:
			continue
		res.append(i)
	return res
f = factors(k)
(x, y) = (dd(int), dd(int))
cur = 0
for i in range(n):
	cur += a[i]
	if a[i] == 0:
		x[cur] += 1
		cur = 0
if cur:
	x[cur] += 1
cur = 0
for i in range(m):
	cur += b[i]
	if b[i] == 0:
		y[cur] += 1
		cur = 0
if cur:
	y[cur] += 1
for len_a in x:
	count_a = x[len_a]
	for len_b in y:
		count_b = y[len_b]
		for fac in f:
			(a, b) = (fac, k // fac)
			if len_a >= a and len_b >= b:
				ans += max(0, (len_a - a + 1) * (len_b - b + 1) * count_a * count_b)
			if len_a >= b and len_b >= a and (a != b):
				ans += max(0, (len_a - b + 1) * (len_b - a + 1) * count_b * count_a)
print(ans)


import sys
import os
import time
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random
from io import BytesIO, IOBase
from bisect import bisect_left as bl
from bisect import bisect_right as br

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def modpow(b, p, m):
	res = 1
	b = b % m
	while p:
		if p & 1:
			res = res * b % m
		b = b * b % m
		p >>= 1
	return res

def mod_inv(a, m):
	return modpow(a, m - 2, m)

def ncr(n, r, m):
	res = 1
	if r == 0:
		return 1
	if n - r < r:
		r = n - r
	(p, k) = (1, 1)
	while r:
		res = res % m * (n % m * mod_inv(r, m) % m) % m
		n -= 1
		r -= 1
	return res

def ncrlis(n, r, m, fact):
	return fact[n] * (mod_inv(fact[r], m) * mod_inv(fact[n - r], m)) % m % m

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, m, k) = mi()
a = li()
b = li()
r = []
c = []
f = 0
tmp = 0
for i in range(n):
	if a[i] == 1:
		f = 1
		tmp += 1
	if a[i] == 0:
		if f == 1:
			r.append(tmp)
			tmp = 0
			f = 0
if f == 1:
	r.append(tmp)
(f, tmp) = (0, 0)
for i in range(m):
	if b[i] == 1:
		f = 1
		tmp += 1
	elif f == 1:
		c.append(tmp)
		tmp = 0
		f = 0
if f == 1:
	c.append(tmp)
res = 0
for i in range(1, int(k ** 0.5) + 1):
	(c1, c2, c3, c4) = (0, 0, 0, 0)
	if k % i == 0:
		(p, q) = (i, k // i)
		for j in r:
			if j >= p:
				c1 += j - p + 1
			if j >= q:
				c3 += j - q + 1
		for j in c:
			if j >= q:
				c2 += j - q + 1
			if j >= p:
				c4 += j - p + 1
		if i == k // i:
			res += c1 * c2
		else:
			res += c1 * c2 + c3 * c4
print(res)


(n, m, k) = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = 0
aa = []
for e in a:
	if e == 1:
		c += 1
	elif c > 0:
		aa.append(c)
		c = 0
if c > 0:
	aa.append(c)
bb = []
c = 0
for e in b:
	if e == 1:
		c += 1
	elif c > 0:
		bb.append(c)
		c = 0
if c > 0:
	bb.append(c)
s = 0
for i in range(1, int(k ** 0.5) + 1):
	if k % i != 0:
		continue
	(k1, k2, l1, l2) = (0, 0, 0, 0)
	for e in aa:
		if e >= i:
			k1 += e - i + 1
		if e >= k // i:
			k2 += e - k // i + 1
	for e in bb:
		if e >= i:
			l2 += e - i + 1
		if e >= k // i:
			l1 += e - k // i + 1
	s += k1 * l1
	if i != k // i:
		s += k2 * l2
print(s)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a1 = []
b1 = []
x = []
c = 0
out = 0
f = 0
for i in range(n):
	if a[i] == 1:
		if f == 0:
			c = 1
			f = 1
		else:
			c += 1
	elif f == 1:
		f = 0
		a1.append(c)
		c = 0
	else:
		continue
if f == 1:
	a1.append(c)
	c = 0
f = 0
c = 0
for i in range(m):
	if b[i] == 1:
		if f == 0:
			c = 1
			f = 1
		else:
			c += 1
	elif f == 1:
		f = 0
		b1.append(c)
		c = 0
	else:
		continue
if f == 1:
	b1.append(c)
	c = 0
for i in range(1, int(k ** 0.5) + 1):
	if k % i == 0:
		if i != k // i:
			x.append(i)
			x.append(k // i)
		else:
			x.append(i)
for p in x:
	q = k // p
	y = 0
	z = 0
	for i in a1:
		if i >= p:
			y += i - p + 1
	for i in b1:
		if i >= q:
			z += i - q + 1
	out += y * z
print(int(out))


from sys import stdin
input = lambda : stdin.readline().strip()
from math import ceil, sqrt, factorial, gcd
from collections import deque
from bisect import bisect_left
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
da = {}
s = set()
f = 0
x = 0
for i in range(n):
	if a[i] == 1:
		if f == 0:
			x = 1
			f = 1
		elif f == 1:
			x += 1
	elif f == 1:
		if x in da:
			da[x] += 1
		else:
			da[x] = 1
		s.add(x)
		x = 0
		f = 0
if x > 0:
	if x in da:
		da[x] += 1
	else:
		da[x] = 1
	s.add(x)
sa = sorted(s)
db = {}
s = set()
f = 0
x = 0
for i in range(m):
	if b[i] == 1:
		if f == 0:
			x = 1
			f = 1
		elif f == 1:
			x += 1
	elif f == 1:
		if x in db:
			db[x] += 1
		else:
			db[x] = 1
		s.add(x)
		x = 0
		f = 0
if x > 0:
	if x in db:
		db[x] += 1
	else:
		db[x] = 1
	s.add(x)
sb = sorted(s)
l = []
i = 1
while i * i <= k:
	if k % i == 0:
		l.append([i, k // i])
	i += 1
ans = 0
for i in l:
	x = bisect_left(sa, i[0])
	y = bisect_left(sb, i[1])
	count1 = 0
	count2 = 0
	for j in range(x, len(sa)):
		count1 += da[sa[j]] * (sa[j] - i[0] + 1)
	for j in range(y, len(sb)):
		count2 += db[sb[j]] * (sb[j] - i[1] + 1)
	ans += count1 * count2
	if i[0] != i[1]:
		x = bisect_left(sa, i[1])
		y = bisect_left(sb, i[0])
		count1 = 0
		count2 = 0
		for j in range(x, len(sa)):
			count1 += da[sa[j]] * (sa[j] - i[1] + 1)
		for j in range(y, len(sb)):
			count2 += db[sb[j]] * (sb[j] - i[0] + 1)
		ans += count1 * count2
print(ans)


from math import sqrt
from collections import Counter

def get_parts(x):
	start = None
	parts = []
	for (i, s) in enumerate(x):
		if s == 0 and start is not None:
			size = i - start
			if size > 0:
				parts.append(size)
				start = None
		if s == 1 and start is None:
			start = i
	if start is not None:
		parts.append(len(x) - start)
	return parts

def get_divisors(k):
	div = {1}
	for i in range(2, int(sqrt(k)) + 1):
		if k % i == 0:
			div.add(i)
			div.add(k // i)
	div.add(k)
	return sorted(div)

def count_n(n, m):
	return n - m + 1

def solve(n, m, k, a, b):
	a_parts = Counter(get_parts(a))
	b_parts = Counter(get_parts(b))
	res = 0
	div = get_divisors(k)
	for (a_part, a_count) in a_parts.items():
		for (b_part, b_count) in b_parts.items():
			if a_part * b_part >= k:
				for i in div:
					if i <= a_part and k // i <= b_part:
						res += count_n(a_part, i) * count_n(b_part, k // i) * a_count * b_count
	return res
(n, m, k) = [int(x) for x in input().split(' ')]
a = [int(x) for x in input().split(' ')]
b = [int(x) for x in input().split(' ')]
print(solve(n, m, k, a, b))


import sys
input = sys.stdin.readline
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
scale = 40000
ca = [0 for _ in range(scale + 1)]
cb = [0 for _ in range(scale + 1)]
now = 0
for x in a:
	if x:
		now += 1
	else:
		now = 0
	ca[now] += 1
now = 0
for x in b:
	if x:
		now += 1
	else:
		now = 0
	cb[now] += 1
for i in range(scale)[::-1]:
	ca[i] += ca[i + 1]
	cb[i] += cb[i + 1]
ans = 0
roo = int(k ** 0.5)
for i in range(1, roo + 1):
	if k % i == 0 and k // i <= scale:
		ans += ca[i] * cb[k // i]
		ans += cb[i] * ca[k // i]
if roo ** 2 == k:
	ans -= ca[roo] * cb[roo]
print(ans)


(n, m, k) = map(int, input().split())
(*a,) = map(int, input().split())
(*b,) = map(int, input().split())
d = {}
p = 0
l = 0
for i in a + [0]:
	if i == 1:
		l += 1
	else:
		for i in range(l):
			d[l - i] = d.get(l - i, 0) + i + 1
		l = 0
dd = {}
p = 0
l = 0
for i in b + [0]:
	if i == 1:
		l += 1
	else:
		for i in range(l):
			dd[l - i] = dd.get(l - i, 0) + i + 1
		l = 0
print(sum((d[i] * dd.get(k // i, 0) for i in d if k % i == 0)))


from collections import Counter
(n, m, k) = map(int, input().split())
(ar, br) = (input().split(), input().split())

def count_rect(u, v):
	cc = 0
	for i in range(1, u + 1):
		if k % i or k // i > v:
			continue
		cc += (u - i + 1) * (v - k // i + 1)
	return cc
S = lambda aa: Counter([len(s) for s in ''.join(aa).split('0')])
(sa, sb) = (S(ar), S(br))
sa.pop(0, None)
sb.pop(0, None)
cc = 0
for (av, ac) in sa.items():
	for (bv, bc) in sb.items():
		cc += count_rect(av, bv) * ac * bc
print(cc)


(n, m, k) = map(int, input().split(' '))
A = list(map(int, input().split(' ')))
B = list(map(int, input().split(' ')))
factors = []
for i in range(1, int(k ** 0.5) + 1):
	if k % i == 0:
		factors.append((i, k // i))
Ans = 0
newfactors = []
for (i, j) in factors:
	if i != j:
		newfactors.append((j, i))
newfactors = factors + newfactors
for (i, j) in newfactors:
	a = 0
	b = 0
	count = 0
	l = -1
	for k in range(m):
		if k < i:
			if B[k] == 1:
				count += 1
		else:
			l += 1
			if B[l] == 1:
				count -= 1
			if B[k] == 1:
				count += 1
		if count >= i:
			a += 1
	count = 0
	l = -1
	for k in range(n):
		if k < j:
			if A[k] == 1:
				count += 1
		else:
			l += 1
			if A[l] == 1:
				count -= 1
			if A[k] == 1:
				count += 1
		if count >= j:
			b += 1
	Ans += a * b
print(Ans)


from math import sqrt

def gen_dzielniki(val):
	ret = list()
	for i in range(1, int(sqrt(val)) + 1):
		if not val % i:
			ret.append(i)
	for i in range(int(sqrt(val)), 0, -1):
		if not val % i and i * i != val:
			ret.append(val // i)
	return ret

def zamien(lista):
	ret = []
	last = -1
	for i in range(len(lista)):
		if lista[i] == 0 and i != 0 and (lista[i - 1] != 0):
			ret.append(i - last - 1)
			last = i
		elif lista[i] == 1 and i == len(lista) - 1:
			ret.append(i - last)
		elif lista[i] == 0:
			last = i
		else:
			pass
	ret2 = {}
	for u in ret:
		if not ret2.get(u):
			ret2[u] = 1
		else:
			ret2[u] += 1
	return ret2
(n, m, k) = list(map(int, input().split()))
dzielniki = gen_dzielniki(k)

def policz(a, b):
	ans = 0
	for i in dzielniki:
		A = a - i
		B = b - k / i
		if A < 0 or B < 0:
			continue
		ans += (A + 1) * (B + 1)
	return ans
mapa = {}
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A = zamien(A)
B = zamien(B)
ans = 0
for u in A:
	for v in B:
		ans += A[u] * B[v] * policz(u, v)
print(int(ans))


from sys import stdin, stdout
input = stdin.readline
import math
t = 1
for _ in range(t):
	(n, m, k) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	vals = []
	p = 0
	c = 0
	for i in b:
		if p == 0:
			if i:
				c = 1
				p = 1
		elif i:
			c += 1
		else:
			if c:
				vals.append(c)
			p = 0
			c = 0
	if c:
		vals.append(c)
	vals2 = []
	p = 0
	c = 0
	for i in a:
		if p == 0:
			if i:
				c = 1
				p = 1
		elif i:
			c += 1
		else:
			if c:
				vals2.append(c)
			p = 0
			c = 0
	if c:
		vals2.append(c)
	ans = 0
	p1 = [0 for i in range(m + 1)]
	p2 = [0 for i in range(n + 1)]
	for i in vals:
		for j in range(1, i + 1):
			p1[j] += i - j + 1
	for i in vals2:
		for j in range(1, i + 1):
			p2[j] += i - j + 1
	i = 1
	while i <= math.sqrt(k):
		if k % i == 0:
			if k // i == i:
				a = b = i
				if a <= m and b <= n:
					ans += p1[a] * p2[b]
			else:
				a = i
				b = k // i
				if a <= m and b <= n:
					ans += p1[a] * p2[b]
				(a, b) = (b, a)
				if a <= m and b <= n:
					ans += p1[a] * p2[b]
				(a, b) = (b, a)
		i = i + 1
	print(ans)


def getInput():
	return [sum([int(ele) for ele in rang]) for rang in input().replace(' ', '').split('0')]
(n, m, k) = list(map(int, input().split()))
recs = [(i + 1, int(k / (i + 1))) for i in range(int(k ** 0.5)) if k % (i + 1) == 0]
recs += [(p[1], p[0]) for p in recs if p[1] != p[0]]
a = getInput()
b = getInput()
print(sum([sum([mp - x + 1 for mp in b if mp - x > -1]) * sum([np - y + 1 for np in a if np - y > -1]) for (x, y) in recs]))


def count_rectangles(a, b, area):
	a_lens = get_all_lengths(a)
	b_lens = get_all_lengths(b)
	result = 0
	for i in range(1, len(a_lens)):
		if area % i == 0 and area // i <= len(b):
			result += a_lens[i] * b_lens[area // i]
	return result

def get_all_lengths(x):
	lengths = [0 for _ in range(len(x) + 1)]
	i = 0
	while i < len(x):
		if x[i] == 0:
			i += 1
			continue
		j = i
		while j < len(x) and x[j] == 1:
			j += 1
		for length in range(1, j - i + 1):
			lengths[length] += j - i - length + 1
		i = j
	return lengths
area = list(map(lambda x: int(x), input().strip().split()))[2]
a = list(map(lambda x: int(x), input().strip().split()))
b = list(map(lambda x: int(x), input().strip().split()))
print(count_rectangles(a, b, area))


def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	divisors.sort()
	return divisors
(n, m, k) = map(int, input().split())
a = [0] + list(map(int, input().split()))
b = [0] + list(map(int, input().split()))
for i in range(n):
	a[i + 1] += a[i]
for i in range(m):
	b[i + 1] += b[i]
d = make_divisors(k)
ans = 0
for x in d:
	y = k // x
	p = 0
	for i in range(n - x + 1):
		if a[i + x] - a[i] == x:
			p += 1
	q = 0
	for i in range(m - y + 1):
		if b[i + y] - b[i] == y:
			q += 1
	ans += p * q
print(ans)


def counter(l, val):
	cnt = 0
	for i in l:
		if i < val:
			return cnt
		cnt += i - val + 1
	return cnt
(n, m, k) = map(int, input().split())
row = sorted(list(map(lambda x: len(x), input().replace(' ', '').split('0'))), reverse=True)
col = sorted(list(map(lambda x: len(x), input().replace(' ', '').split('0'))), reverse=True)
count = 0
for i in range(1, int(k ** 0.5) + 1):
	if k % i == 0:
		if k // i == i:
			if n >= i and m >= i:
				count += counter(row, i) * counter(col, i)
		else:
			if n >= i and m >= k // i:
				count += counter(row, i) * counter(col, k // i)
			if n >= k // i and m >= i:
				count += counter(col, i) * counter(row, k // i)
print(count)


from sys import stdin
inf = stdin
(n, m, k) = map(int, inf.readline().split(' '))
A = list(map(int, inf.readline().split(' ')))
B = list(map(int, inf.readline().split(' ')))
temp1 = [0] * (n + 1)
temp2 = [0] * (m + 1)
i = 0
while i < n:
	if A[i] == 0:
		i += 1
		continue
	j = i
	while j < n and A[j] == 1:
		j += 1
	for q in range(1, j - i + 1):
		temp1[q] += j - i - q + 1
	i = j
i = 0
while i < m:
	if B[i] == 0:
		i += 1
		continue
	j = i
	while j < m and B[j] == 1:
		j += 1
	for q in range(1, j - i + 1):
		temp2[q] += j - i - q + 1
	i = j
ans = 0
for i in range(1, len(temp1)):
	if k % i == 0 and k // i <= m:
		ans += temp1[i] * temp2[k // i]
print(ans)


import sys
import math
input = sys.stdin.readline

def solve1(arr, n, i):
	curr = 0
	bda = 0
	chota = 0
	for j in range(n):
		if arr[j] == 1:
			curr += 1
		else:
			bda += max(0, curr - i + 1)
			curr = 0
	bda += max(0, curr - i + 1)
	return bda

def solve(k, arr, brr):
	n = len(arr)
	m = len(brr)
	i = 1
	ans = 0
	while i <= math.sqrt(k):
		if k % i == 0:
			if i == k // i:
				bda = solve1(arr, n, i)
				chota = solve1(brr, m, i)
				ans += bda * chota
			else:
				bda = solve1(arr, n, i)
				chota = solve1(brr, m, k // i)
				ans += bda * chota
				bda = solve1(arr, n, k // i)
				chota = solve1(brr, m, i)
				ans += bda * chota
		i += 1
	return ans
(n, m, k) = map(int, input().split())
arr = list(map(int, input().split()))
brr = list(map(int, input().split()))
ans = solve(k, arr, brr)
print(ans)


import math
from collections import defaultdict

def search(a, t):
	l = 0
	r = len(a) - 1
	ans = 0
	while r - l >= 0:
		mid = (l + r) // 2
		if a[mid] < t:
			l = mid + 1
		if a[mid] >= t:
			r = mid - 1
			ans = mid
	return ans

def getFactors(n):
	factors = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				factors.append(i)
			else:
				factors.append(i)
				factors.append(n // i)
		i = i + 1
	return factors
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = defaultdict(int)
factors = getFactors(k)
a_s = []
b_s = []
ct = 0
for i in range(n):
	if a[i]:
		ct += 1
	elif ct:
		a_s.append(ct)
		ct = 0
if ct:
	a_s.append(ct)
ct = 0
for i in range(m):
	if b[i]:
		ct += 1
	elif ct:
		b_s.append(ct)
		ct = 0
if ct:
	b_s.append(ct)
a_s.sort()
b_s.sort()
ans = 0
for i in factors:
	d[i] = sum([max(0, 1 + b_s[j] - i) for j in range(len(b_s))])
for i in factors:
	for j in a_s:
		if j >= i:
			ans += (1 + j - i) * d[k // i]
print(ans)


def Ones(array: list):
	res = []
	count = 0
	for a in array:
		if a == 1:
			count += 1
		else:
			res.append(count)
			count = 0
	if count != 0:
		res.append(count)
	return res
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a_ones = Ones(a)
b_ones = Ones(b)
rectangle = []
for i in range(1, int(k ** 0.5) + 1):
	if k % i == 0:
		rectangle.append((i, k // i))
		if k // i != i:
			rectangle.append((k // i, i))
res = 0
for (wide, lenth) in rectangle:
	widecount = 0
	lenthcount = 0
	for x in a_ones:
		if x >= wide:
			widecount += x - wide + 1
	for x in b_ones:
		if x >= lenth:
			lenthcount += x - lenth + 1
	res += widecount * lenthcount
print(res)


def add_to_dict(d, k):
	if k == 0:
		return
	if k in d:
		d[k] += 1
	else:
		d[k] = 1

def process(A):
	k = 0
	N1 = {}
	for a in A:
		if a == 0:
			add_to_dict(N1, k)
			k = 0
		else:
			k += 1
	add_to_dict(N1, k)
	return list(N1.items())

def find_n(N1, d):
	res = 0
	for (l, n) in N1:
		res += max(0, l - d + 1) * n
	return res

def solve(A, B, k):
	AN1 = process(A)
	BN1 = process(B)
	res = 0
	to = min(len(A), k)
	for i in range(1, to + 1):
		if k % i != 0 or k // i > len(B):
			continue
		res += find_n(AN1, i) * find_n(BN1, k // i)
	return res
(_, _, k) = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
print(solve(A, B, k))


import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque, Counter
from bisect import *
from math import sqrt
import math
from itertools import permutations

def main():
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(c, d) = ([0], [0])
	for i in range(n):
		c.append(c[-1] + a[i])
	for i in range(m):
		d.append(d[-1] + b[i])
	e = []
	for i in range(1, n + 1):
		if k % i == 0:
			if k // i <= m:
				e.append((i, k // i))
	ans = 0
	for j in e:
		(x, y) = j
		(u, v) = (0, 0)
		for i in range(n - x + 1):
			if c[i + x] - c[i] == x:
				u += 1
		for i in range(m - y + 1):
			if d[i + y] - d[i] == y:
				v += 1
		ans += u * v
	print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


(n, m, k) = map(int, input().split())
list1 = list(map(int, input().split()))
list2 = list(map(int, input().split()))
conce_1 = []
conce_2 = []
i = 0
while i < n:
	if list1[i] == 1:
		count = 0
		while i < len(list1) and list1[i] == 1:
			i += 1
			count += 1
		conce_1.append(count)
	else:
		i += 1
i = 0
while i < m:
	if list2[i] == 1:
		count = 0
		while i < len(list2) and list2[i] == 1:
			i += 1
			count += 1
		conce_2.append(count)
	else:
		i += 1
if len(conce_1) == 0:
	print(0)
else:
	p = max(conce_1)
	ans = 0
	for i in range(1, p + 1):
		t = k / i
		if t == int(t):
			s1 = 0
			for j in range(len(conce_1)):
				if conce_1[j] - (i - 1) > 0:
					s1 += conce_1[j] - (i - 1)
			s2 = 0
			for j in range(len(conce_2)):
				if conce_2[j] - (t - 1) > 0:
					s2 += conce_2[j] - (t - 1)
			ans += s1 * s2
	print(int(ans))


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
tempA = [0] * (n + 1)
i = 0
while i < n:
	if a[i] != 1:
		i += 1
		continue
	j = i
	while j < n and a[j] == 1:
		j += 1
	for l in range(1, j - i + 1):
		tempA[l] += j - i + 1 - l
	i = j
tempB = [0] * (m + 1)
i = 0
while i < m:
	if b[i] != 1:
		i += 1
		continue
	j = i
	while j < m and b[j] == 1:
		j += 1
	for l in range(1, j - i + 1):
		tempB[l] += j - i + 1 - l
	i = j
ans = 0
for i in range(1, n + 1):
	if k % i == 0:
		(x, y) = (i, k // i)
		if y <= m:
			ans += tempA[x] * tempB[y]
print(ans)


def getdivs(n):
	i = 1
	a = []
	while i <= int(n ** 0.5):
		if n % i == 0:
			if n // i == i:
				a.append(i)
			else:
				a += [i, n // i]
		i += 1
	return sorted(a)

def getConsecutive(arr):
	arr = [0] + arr + [0]
	sz = 1
	maps = {}
	maps[1] = arr.count(1)
	for i in range(1, len(arr)):
		if arr[i] == arr[i - 1] and arr[i] == 1:
			sz += 1
		else:
			cnt = 1
			while sz > 1 and sz > 1:
				if sz in maps:
					maps[sz] += cnt
				else:
					maps[sz] = cnt
				cnt += 1
				sz -= 1
			sz = 1
	return maps
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
divis = getdivs(k)
map1 = getConsecutive(a)
map2 = getConsecutive(b)
su = 0
for i in divis:
	cur = i
	second = k // cur
	if cur in map1 and second in map2:
		su += map1[cur] * map2[second]
print(su)


import sys
input = sys.stdin.readline
import math
(n, m, k) = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
max_hor = [0] * 40005
max_vert = [0] * 40005

def subrect_finder(l, l2, nm):
	count = l[0]
	l2[count] = count
	for i in range(1, nm):
		if l[i - 1] == l[i] and l[i] == 1:
			count += 1
			l2[count] += 1
		elif l[i] == 1:
			count += 1
			l2[count] += 1
		else:
			count = 0
	return l2
hor = subrect_finder(a, max_hor, n)
vert = subrect_finder(b, max_vert, m)
ans = 0
for j in range(1, math.floor(k ** 0.5) + 1):
	if k % j == 0:
		jk = int(k / j)
		(j, jk) = (min(40001, j), min(40001, jk))
		if vert[j] != 0:
			ans += sum(vert[j:]) * sum(hor[jk:])
		if hor[j] != 0 and j != jk:
			ans += sum(hor[j:]) * sum(vert[jk:])
print(ans)


from collections import Counter
from itertools import product
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a1 = [0]
b1 = [0]
for i in range(n):
	if a[i] == 1:
		a1[-1] += 1
	elif a1[-1] != 0:
		a1.append(0)
for i in range(m):
	if b[i] == 1:
		b1[-1] += 1
	elif b1[-1] != 0:
		b1.append(0)
pr = []
for i in range(1, int(k ** 0.5) + 1):
	if k % i == 0 and k // i <= 40000:
		pr.append((i, k // i))
		if i != k // i:
			pr.append((k // i, i))
ca = Counter(a1)
cb = Counter(b1)
ans = 0
for (i, j) in product(ca.items(), cb.items()):
	for (x, y) in pr:
		if i[0] >= x and j[0] >= y:
			ans += i[1] * j[1] * (i[0] - x + 1) * (j[0] - y + 1)
print(ans)


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

def check(lst, k):
	if len(lst) < k:
		return 0
	ret = 0
	cursum = sum(lst[:k])
	if cursum == k:
		ret += 1
	for i in range(1, len(lst) - k + 1):
		cursum -= lst[i - 1]
		cursum += lst[i + k - 1]
		if cursum == k:
			ret += 1
	return ret
res = 0
for i in range(1, n + 1):
	if k % i == 0:
		count = check(a, i)
		recount = check(b, k // i)
		res += count * recount
print(res)


(n, m, k) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
from collections import defaultdict
aa = []
cc = 0
xr = defaultdict(int)
for z in a:
	if z == 1:
		cc += 1
		continue
	if cc != 0:
		xr[cc] += 1
		cc = 0
if cc != 0:
	xr[cc] += 1
yr = defaultdict(int)
cc = 0
for z in b:
	if z == 1:
		cc += 1
		continue
	if cc != 0:
		yr[cc] += 1
		cc = 0
if cc != 0:
	yr[cc] += 1
subs = []
for z in xr.keys():
	for j in yr.keys():
		subs.append([z, j])
cnt = 0
for (x, y) in subs:
	for i in range(1, x + 1):
		npx = x - i + 1
		if k % i != 0:
			continue
		ny = k // i
		if ny > y:
			continue
		npy = y - ny + 1
		cnt += xr[x] * yr[y] * npx * npy
print(cnt)


import math
l = input().split()
n = int(l[0])
m = int(l[1])
k = int(l[2])
l = []
i = 1
a1 = input().split()
ai = [int(i) for i in a1]
b1 = input().split()
bi = [int(i) for i in b1]
while i * i <= k:
	if k % i == 0 and i != k // i:
		l.append((i, k // i))
		l.append((k // i, i))
	elif k % i == 0:
		l.append((i, i))
	i += 1
arr1 = [0 for i in range(n)]
arr2 = [0 for i in range(m)]
count1 = 0
for i in ai:
	if i == 1:
		count1 += 1
	else:
		for j in range(count1):
			arr1[j] += count1 - j
		count1 = 0
for i in range(count1):
	arr1[i] += count1 - i
count1 = 0
for i in bi:
	if i == 1:
		count1 += 1
	else:
		for j in range(count1):
			arr2[j] += count1 - j
		count1 = 0
for i in range(count1):
	arr2[i] += count1 - i
ans = 0
for i in l:
	if i[0] > n or i[1] > m:
		ans = ans
	else:
		ans += arr1[i[0] - 1] * arr2[i[1] - 1]
print(ans)


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def getd(a, n):
	d = {i: 0 for i in range(1, n + 1)}
	s = 0
	a.append(0)
	for i in range(n + 1):
		if a[i] == 1:
			s += 1
		else:
			for j in range(1, s + 1):
				d[j] += s - j + 1
			s = 0
	return d
(n, m, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
v = int(k ** 0.5) + 1
divs = []
for i in range(1, v):
	if k % i == 0:
		divs.append((i, k // i))
da = getd(a, n)
db = getd(b, m)
s = 0
for (i, j) in divs:
	if i <= n and j <= m:
		s += da[i] * db[j]
	if i != j:
		if j <= n and i <= m:
			s += da[j] * db[i]
print(s)


import io
import os
from bisect import bisect_left
from collections import deque, defaultdict, Counter

def makeRepeat(s):
	repeat = [[s[0], 0]]
	for ch in s:
		if ch == repeat[-1][0]:
			repeat[-1][1] += 1
		else:
			repeat.append([ch, 1])
	return repeat

def solve(N, M, K, A, B):
	aRepeats = [c for (x, c) in makeRepeat(A) if x == 1]
	bRepeats = [c for (x, c) in makeRepeat(B) if x == 1]
	aRepeats.sort()
	bRepeats.sort()
	aCumSum = [0]
	bCumSum = [0]
	for x in aRepeats:
		aCumSum.append(aCumSum[-1] + x)
	for x in bRepeats:
		bCumSum.append(bCumSum[-1] + x)

	def getCount(d1, d2):
		i = bisect_left(aRepeats, d1)
		j = bisect_left(bRepeats, d2)
		aSum = aCumSum[-1] - aCumSum[i]
		aCount = len(aCumSum) - i - 1
		assert aSum == sum(aRepeats[i:])
		bSum = bCumSum[-1] - bCumSum[j]
		bCount = len(bCumSum) - j - 1
		assert bSum == sum(bRepeats[j:])
		ret = aSum * bSum - (d2 - 1) * aSum * bCount - (d1 - 1) * bSum * aCount + (d1 - 1) * (d2 - 1) * aCount * bCount
		return ret
	total = 0
	for d1 in range(1, int(K ** 0.5) + 1):
		(d2, r) = divmod(K, d1)
		if r == 0:
			assert d1 * d2 == K
			total += getCount(d1, d2)
			if d1 != d2:
				total += getCount(d2, d1)
	return total
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(N, M, K) = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = solve(N, M, K, A, B)
print(ans)


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)

def pars(arr, num):
	t = dd()
	c = 0
	for i in range(num):
		if arr[i]:
			c += 1
		else:
			if c:
				t[c] += 1
			c = 0
	if c:
		t[c] += 1
	return t
(n, m, k) = mi()
a = li()
b = li()
aones = pars(a, n)
bones = pars(b, m)
ans = 0
abones = {}
for i in aones:
	for j in bones:
		abones[i, j] = aones[i] * bones[j]
for t in abones:
	for d in divs(k):
		ans += abones[t] * max(0, t[0] - d + 1) * max(0, t[1] - k // d + 1)
print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
setty = set([])
factors = []
for s in range(1, math.ceil(math.sqrt(k)) + 1):
	if k % s == 0:
		if not s in setty:
			setty.add(s)
			factors.append(s)
		if not k // s in setty:
			setty.add(k // s)
			factors.append(k // s)
onea = []
oneb = []
chaina = 0
for s in range(n):
	if a[s] == 1:
		chaina += 1
	else:
		if chaina >= 1:
			onea.append(chaina)
		chaina = 0
if chaina >= 1:
	onea.append(chaina)
chainb = 0
for s in range(m):
	if b[s] == 1:
		chainb += 1
	else:
		if chainb >= 1:
			oneb.append(chainb)
		chainb = 0
if chainb >= 1:
	oneb.append(chainb)
ans = 0
for s in range(len(factors)):
	A = 0
	B = 0
	for j in range(len(onea)):
		if onea[j] >= factors[s]:
			A += onea[j] + 1 - factors[s]
	for j in range(len(oneb)):
		if oneb[j] >= k // factors[s]:
			B += oneb[j] + 1 - k // factors[s]
	ans += A * B
print(ans)


from sys import stdin, stdout
from math import sqrt
get = stdin.readline
put = stdout.write
(n, m, k) = map(int, get().split())
a = sorted(list(map(lambda x: len(x), input().replace(' ', '').split('0'))), reverse=True)
b = sorted(list(map(lambda x: len(x), input().replace(' ', '').split('0'))), reverse=True)
pp = 0
i = 1
while i <= round(sqrt(k)):
	if not k % i:
		j = k // i
		(h, l, hh, ll) = (0, 0, 0, 0)
		(o, p) = (1, 1)
		for t in a:
			if t < i:
				o = 0
			elif o:
				h = h + t - i + 1
			if t < j or i == j:
				p = 0
			elif p:
				hh = hh + t - j + 1
			if t == p == 0:
				break
		(o, p) = (1, 1)
		for t in b:
			if t < j:
				o = 0
			elif o:
				l = l + t - j + 1
			if t < i or i == j:
				p = 0
			elif p:
				ll = ll + t - i + 1
			if p == o == 0:
				break
		pp = pp + h * l + hh * ll
	i += 1
put(str(pp))


line1 = input().split(' ')
for i in range(3):
	line1[i] = int(line1[i])
(n, m, k) = line1
a = dict()
b = dict()

def output(inp, arr, n, k):
	c = 0
	for i in range(n):
		if inp[i] == '1':
			c += 1
		else:
			d = min(c + 1, k + 1)
			for j in range(1, d):
				if j not in arr:
					arr[j] = c + 1 - j
				else:
					arr[j] += c + 1 - j
			c = 0
	d = min(c + 1, k + 1)
	for j in range(1, d):
		if j not in arr:
			arr[j] = c + 1 - j
		else:
			arr[j] += c + 1 - j
	return arr
a = output(input().split(' '), a, n, k)
b = output(input().split(' '), b, m, k)
output = 0
for i in range(1, n + 1):
	if k % i == 0:
		if i in a and k // i in b:
			output += a[i] * b[k // i]
print('%d' % output)


(n, m, k) = [int(x) for x in input().split()]
SN = [0 for _ in range(40005)]
SM = [0 for _ in range(40005)]
cont = 0
nums_n = [int(x) for x in input().split()]
for aux in nums_n:
	if aux:
		cont += 1
		SN[cont] += 1
	else:
		cont = 0
cont = 0
nums_n = [int(x) for x in input().split()]
for aux in nums_n:
	if aux:
		cont += 1
		SM[cont] += 1
	else:
		cont = 0
for i in range(1, 40003):
	SN[40003 - i] += SN[40003 - i + 1]
	SM[40003 - i] += SM[40003 - i + 1]
ans = 0
for i in range(1, n + 1):
	if k % i == 0 and k // i < 40002:
		ans += SN[i] * SM[k // i]
print(ans)


from bisect import *
(n, m, k) = map(int, input().split())
aa = list(map(int, input().split()))
bb = list(map(int, input().split()))
ma = int(k ** 0.5)
co = 0
pre = [-1 for i in range(n)]
pre2 = [-1 for i in range(m)]
cc = []
for i in range(n):
	if aa[i] == 1:
		co += 1
		pre[i] = co
		cc.append(co)
	else:
		co = 0
co = 0
dd = []
for i in range(m):
	if bb[i] == 1:
		co += 1
		pre2[i] = co
		dd.append(co)
	else:
		co = 0
cc.sort()
dd.sort()
tot = 0
for i in range(1, ma + 1):
	if k % i == 0:
		indd = len(cc) - bisect_left(cc, i)
		x = k // i
		ind = len(dd) - bisect_left(dd, x)
		tot += indd * ind
		if i * i == k:
			continue
		indd = len(dd) - bisect_left(dd, i)
		ind = len(cc) - bisect_left(cc, x)
		tot += indd * ind
print(tot)


import math
import collections
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
div_a = collections.defaultdict(int)
div_b = collections.defaultdict(int)
div = 1
div_k = {}
while div <= int(math.sqrt(k)):
	if k % div == 0:
		div_k[div] = 0
		div_k[int(k / div)] = 0
	div += 1
kk = div_k.keys()
a.append(0)
b.append(0)
count = 0
for (pos, i) in enumerate(a):
	if i == 0:
		for j in kk:
			if j <= count:
				div_a[j] += count - j + 1
		count = 0
	else:
		count += 1
count = 0
for (pos, i) in enumerate(b):
	if i == 0:
		for j in kk:
			if j <= count:
				div_b[j] += count - j + 1
		count = 0
	else:
		count += 1
ans = 0
for (key, value) in div_a.items():
	ans += value * div_b[k / key]
print(ans)


from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
M = mod = 10 ** 9 + 7

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip('\n').split()]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n').split(' ')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
(n, m, k) = li()
a = li()
b = li()
d = defaultdict(int)
tot = 0
last = a[0]
curr = a[0]
for i in range(1, n):
	if a[i] == 1:
		if last == 1:
			curr += 1
		else:
			curr = 1
			last = 1
	else:
		add = 1
		for j in range(curr, 0, -1):
			d[j] += add
			add += 1
		curr = 0
		last = 0
if curr:
	add = 1
	for j in range(curr, 0, -1):
		d[j] += add
		add += 1
d2 = defaultdict(int)
curr = last = b[0]
for i in range(1, m):
	if b[i] == 1:
		if last == 1:
			curr += 1
		else:
			curr = 1
			last = 1
	else:
		add = 1
		for j in range(curr, 0, -1):
			d2[j] += add
			add += 1
		curr = 0
		last = 0
if curr:
	add = 1
	for j in range(curr, 0, -1):
		d2[j] += add
		add += 1
tot = 0
for i in factors(k):
	tot += d[i] * d2[k // i]
print(tot)


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

def count(arr, num):
	cur_sum = 0
	res = 0
	for x in arr:
		if x == 0:
			cur_sum = 0
			continue
		cur_sum += x
		if cur_sum >= num:
			res += 1
	return res
total = 0
i = 1
while i * i <= k:
	if k % i == 0:
		x = i
		y = k // i
		total += count(a, x) * count(b, y)
		if x != y:
			total += count(a, y) * count(b, x)
	i += 1
print(total)


import sys
from math import sqrt

def two_factors(k):
	factors = []
	for i in range(1, round(sqrt(k)) + 1):
		if k % i == 0:
			factors.append(i)
			if i * i != k:
				factors.append(k / i)
	return factors
numbers = list(map(int, input().split()))
n = numbers[0]
m = numbers[1]
k = numbers[2]
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if k > n * m:
	print(0)
	sys.exit()
counter = 0
new_a = []
new_b = []
for i in range(0, n):
	if a[i] == 1:
		counter += 1
		if i == n - 1:
			new_a.append(counter)
			counter = 0
	elif a[i] == 0 and counter != 0:
		new_a.append(counter)
		counter = 0
counter = 0
for i in range(0, m):
	if b[i] == 1:
		counter += 1
		if i == m - 1:
			new_b.append(counter)
			counter = 0
	elif b[i] == 0 and counter != 0:
		new_b.append(counter)
		counter = 0
total = 0
factors = two_factors(k)
for i in factors:
	sum_of_factor_1 = 0
	sum_of_factor_2 = 0
	for j in new_a:
		if i <= j:
			factor_1 = j - i + 1
			sum_of_factor_1 += factor_1
	for x in new_b:
		if k / i <= x:
			factor_2 = x - k / i + 1
			sum_of_factor_2 += factor_2
	total += sum_of_factor_1 * sum_of_factor_2
print(round(total))


import bisect
n = [0] * 2
(n[0], n[1], k) = map(int, input().split())
A = [[], []]
for i in range(1, 401 * 100):
	if i > k // i:
		break
	if k % i == 0:
		if i == k // i:
			A[0].append(i)
			A[1].append(i)
		else:
			A[0] += [i, k // i]
			A[1] += [k // i, i]
ans = [1] * len(A[0])
for i in range(2):
	p = map(int, input().split())
	p = list(p) + [0]
	SUM = 0
	arr = []
	for x in p:
		if x == 0 and SUM != 0:
			arr.append(SUM)
			SUM = 0
		elif x == 1:
			SUM += 1
	arr = sorted(arr)
	SUM = sum(arr)
	b = [SUM]
	for x in arr:
		SUM -= x
		b.append(SUM)
	for (j, x) in enumerate(A[i]):
		place = bisect.bisect_left(arr, x)
		ans[j] *= b[place] - (len(arr) - place) * (x - 1)
print(sum(ans))


import io, os
from sys import setrecursionlimit
from collections import defaultdict
from itertools import groupby

def rint():
	return map(int, input().split())

def oint():
	return int(input())

def find_divisor(n):
	i = 1
	div1 = []
	div2 = []
	while i * i < n:
		if n % i == 0:
			div1.append(i)
			div2.append(n // i)
		i += 1
	if i * i == n:
		div1.append(i)
	return div1 + div2
(n, m, k) = rint()
fla = [len(a) for a in input().replace(' ', '').split('0') if len(a)]
flb = [len(a) for a in input().replace(' ', '').split('0') if len(a)]
div = find_divisor(k)
ans = 0
for sr in div:
	sc = k // sr
	ans += sum((r - sr + 1 for r in fla if sr <= r)) * sum((c - sc + 1 for c in flb if sc <= c))
print(ans)


from os import path
from io import BytesIO, IOBase
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, Counter, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input().rstrip()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('0')
file = 1

def ceil(a, b):
	return (a + b - 1) // b

def solve():
	(n, m, k) = mi()
	a = li()
	b = li()
	(x, y) = ([], [])
	c = 0
	for i in range(n):
		if a[i] == 0:
			if c > 0:
				x.append(c)
			c = 0
		else:
			c += 1
	if c > 0:
		x.append(c)
	c = 0
	for i in range(m):
		if b[i] == 0:
			if c > 0:
				y.append(c)
			c = 0
		else:
			c += 1
	if c > 0:
		y.append(c)
	x.sort()
	y.sort()
	(nx, ny) = (len(x), len(y))
	sufx = [0] * nx
	sufy = [0] * ny
	for i in range(nx - 1, -1, -1):
		if i != nx - 1:
			sufx[i] += sufx[i + 1]
		sufx[i] += x[i]
	for i in range(ny - 1, -1, -1):
		if i != ny - 1:
			sufy[i] += sufy[i + 1]
		sufy[i] += y[i]

	def get(p, q):
		idx1 = bisect_left(x, p)
		idx2 = bisect_left(y, q)
		(cnt1, cnt2) = (0, 0)
		if idx2 < ny:
			cnt2 = sufy[idx2] - (q - 1) * (ny - idx2)
		if idx1 < nx:
			cnt1 = sufx[idx1] - (p - 1) * (nx - idx1)
		return cnt1 * cnt2
	ans = 0
	for i in range(2, int(sqrt(k)) + 1):
		if k % i == 0:
			p = i
			q = k // i
			ans += get(p, q)
			if p != q:
				ans += get(q, p)
	ans += get(1, k)
	if k != 1:
		ans += get(k, 1)
	print(ans)
if file:
	if path.exists('tmp/input.txt'):
		sys.stdin = open('tmp/input.txt', 'r')
		sys.stdout = open('tmp/output.txt', 'w')
	else:
		input = sys.stdin.readline
solve()


import sys
from collections import defaultdict as dd
from collections import deque
from fractions import Fraction as f

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
from math import *
import copy
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')

def li():
	return [int(x) for x in input().split()]

def fi():
	return int(input())

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def gh():
	sys.stdout.flush()

def bo(i):
	return ord(i) - ord('a')
from copy import *
from bisect import *
from itertools import permutations
t = 1
while t > 0:
	t -= 1
	(n, m, k) = mi()
	a = li()
	dd = []
	i = 0
	dd = [0 for i in range(min(n, k) + 2)]
	i = 0
	while i < n:
		c = 0
		while i < n and a[i] == 1:
			c += 1
			i += 1
			dd[1] += 1
			dd[min(c, k) + 1] -= 1
		if i < n and a[i] == 0:
			i += 1
	for i in range(1, len(dd)):
		dd[i] += dd[i - 1]
	b = li()
	d = [0 for i in range(min(m, k) + 2)]
	ans = 0
	i = c = 0
	while i < m:
		c = 0
		while i < m and b[i] == 1:
			c += 1
			d[1] += 1
			i += 1
			d[min(k, c) + 1] -= 1
		else:
			i += 1
	for i in range(1, len(d)):
		d[i] += d[i - 1]
	for i in range(1, len(dd)):
		if k % i == 0 and k // i <= m:
			ans += dd[i] * d[k // i]
	print(ans)


def gen_tbl(a):
	n = len(a)
	ans = [0] * (n + 1)
	so_far = 0
	for i in range(n):
		if a[i] == 0:
			for j in range(1, so_far + 1):
				ans[j] += so_far - j + 1
			so_far = 0
		else:
			so_far += 1
	for j in range(1, so_far + 1):
		ans[j] += so_far - j + 1
	so_far = 0
	return ans
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
tbl_a = gen_tbl(a)
tbl_b = gen_tbl(b)
for i in range(1, n + 1):
	j = k // i
	if k != i * j:
		continue
	if j <= m:
		ans += tbl_a[i] * tbl_b[j]
print(ans)


import bisect
import itertools
import math
from functools import reduce
from itertools import accumulate
from operator import mul

def conv(x):
	n = len(x)
	i = 0
	res = []
	while i < n:
		if x[i]:
			j = 0
			while i < n and x[i]:
				i += 1
				j += 1
			res.append(j)
		else:
			i += 1
	return sorted(res)

def decomp(x):
	res = []
	while x % 2 == 0:
		res.append(2)
		x //= 2
	sqr = int(math.sqrt(x)) + 2
	i = 3
	while x > 1 and i < sqr:
		while x % i == 0:
			res.append(i)
			x //= i
		i += 2
	if x > 1:
		res.append(x)
	return res

def divs(x):
	divs = set()
	pr = decomp(x)
	for i in range(0, len(pr) + 1):
		divs.update((reduce(mul, comb, 1) for comb in itertools.combinations(pr, i)))
	return divs

def go():
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = conv(a)
	b = conv(b)
	n = len(a)
	m = len(b)
	ac = [0] + list(accumulate(a))
	bc = [0] + list(accumulate(b))
	res = 0
	kdivs = sorted(divs(k))
	ia = 0
	ib = m - 1
	for ka in kdivs:
		kb = k // ka
		while ia < n and a[ia] < ka:
			ia += 1
		if ia == n:
			break
		while ib >= 0 and b[ib] >= kb:
			ib -= 1
		res += (ac[-1] - ac[ia] - (n - ia) * (ka - 1)) * (bc[-1] - bc[ib + 1] - (m - ib - 1) * (kb - 1))
	return res
print(go())


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a_lenths = {}
curr_len = 0
for i in range(len(a)):
	if a[i] == 1:
		curr_len += 1
	else:
		if curr_len in a_lenths:
			a_lenths[curr_len] += 1
		else:
			a_lenths[curr_len] = 1
		curr_len = 0
if curr_len != 0:
	if curr_len in a_lenths:
		a_lenths[curr_len] += 1
	else:
		a_lenths[curr_len] = 1
b_lenths = {}
curr_len = 0
for i in range(len(b)):
	if b[i] == 1:
		curr_len += 1
	else:
		if curr_len in b_lenths:
			b_lenths[curr_len] += 1
		else:
			b_lenths[curr_len] = 1
		curr_len = 0
if curr_len != 0:
	if curr_len in b_lenths:
		b_lenths[curr_len] += 1
	else:
		b_lenths[curr_len] = 1
k_divs = []
for i in range(1, int(k ** 0.5) + 1):
	if k % i == 0:
		k_divs.append(i)
		if k // i != i:
			k_divs.append(k // i)
ans = 0
for seg_a in a_lenths:
	for div1 in k_divs:
		if div1 <= seg_a:
			div2 = k // div1
			num_seg_a = (seg_a - div1 + 1) * a_lenths[seg_a]
			for seg_b in b_lenths:
				if div2 <= seg_b:
					num_seg_b = (seg_b - div2 + 1) * b_lenths[seg_b]
					ans += num_seg_a * num_seg_b
print(ans)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
length = {}
length2 = {}
t = 0
for i in range(n):
	if a[i] == 1:
		t += 1
	if a[i] == 0 and t > 0:
		if length.get(t) == None:
			length[t] = 1
		else:
			length[t] += 1
		t = 0
if t > 0:
	if length.get(t) == None:
		length[t] = 1
	else:
		length[t] += 1
p = {}
t = 0
for i in range(m):
	if b[i] == 1:
		t += 1
	if b[i] == 0 and t > 0:
		if length2.get(t) == None:
			length2[t] = 1
		else:
			length2[t] += 1
		t = 0
if t > 0:
	if length2.get(t) == None:
		length2[t] = 1
	else:
		length2[t] += 1
for i in length.keys():
	for j in length2.keys():
		if i >= j:
			h = (j, i)
		else:
			h = (i, j)
		if p.get(h) == None:
			p[h] = length[i] * length2[j]
		else:
			p[h] += length[i] * length2[j]
divisors = []
g = int(k ** 0.5)
for d in range(1, g + 1):
	if k % d == 0:
		w = k // d
		divisors.append([d, w])
		if w != d:
			divisors.append([w, d])
divisors.sort()
s = 0
for r in p.keys():
	if r[0] * r[1] < k:
		continue
	for f in divisors:
		if f[0] > r[0]:
			break
		if f[1] > r[1]:
			continue
		s += (r[1] - f[1] + 1) * (r[0] - f[0] + 1) * p[r]
print(s)


from sys import stdin
from math import sqrt
(n, m, k) = list(map(int, stdin.readline().split(' ')))
A = list(map(int, stdin.readline().split(' ')))
B = list(map(int, stdin.readline().split(' ')))
A_dic = []
cur_length = 0
for i in range(n):
	if A[i] == 1:
		cur_length += 1
	else:
		if cur_length != 0:
			A_dic.append(cur_length)
		cur_length = 0
if cur_length != 0:
	A_dic.append(cur_length)
A.clear()
B_dic = []
cur_length = 0
for i in range(m):
	if B[i] == 1:
		cur_length += 1
	else:
		if cur_length != 0:
			B_dic.append(cur_length)
		cur_length = 0
if cur_length != 0:
	B_dic.append(cur_length)
B.clear()
sum = 0
if len(A_dic) == 0 or len(B_dic) == 0:
	print(0)
	exit()
A_dic.sort(reverse=True)
B_dic.sort(reverse=True)
max_A = A_dic[0]
max_B = B_dic[0]
if max_A * max_B < k:
	print(sum)
	exit()
else:
	for i in range(1, int(sqrt(k)) + 1):
		if k % i == 0:
			factor1 = i
			factor2 = k / i
			if factor1 <= max_A and factor2 <= max_B and (factor1 != factor2):
				choose_A = 0
				choose_B = 0
				for item in A_dic:
					if item < factor1:
						break
					else:
						choose_A += item - factor1 + 1
				for item in B_dic:
					if item < factor2:
						break
					else:
						choose_B += item - factor2 + 1
				sum += choose_A * choose_B
			if factor2 <= max_A and factor1 <= max_B:
				choose_A = 0
				choose_B = 0
				for item in A_dic:
					if item < factor2:
						break
					else:
						choose_A += item - factor2 + 1
				for item in B_dic:
					if item < factor1:
						break
					else:
						choose_B += item - factor1 + 1
				sum += choose_A * choose_B
print(int(sum))
exit()


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

def occurence(li, k):
	if k > len(li):
		return 0
	r = 0
	s = sum(li[:k])
	if s == k:
		r += 1
	for i in range(1, len(li) - k + 1):
		s -= li[i - 1]
		s += li[i + k - 1]
		if s == k:
			r += 1
	return r
ans = 0
for i in range(1, n + 1):
	if k % i == 0:
		f = occurence(a, i)
		r = occurence(b, k // i)
		ans += f * r
print(ans)


(n, m, k) = map(int, input().split())
a = list(input().split() + ['0'])
b = list(input().split() + ['0'])
pre = 0
cnt = 0
a2 = []
b2 = []
for i in range(len(a)):
	if a[i] == '1':
		if pre == 0:
			cnt = 1
		else:
			cnt += 1
		pre = 1
	else:
		if pre == 1:
			a2.append(cnt)
			cnt = 0
		pre = 0
for i in range(len(b)):
	if b[i] == '1':
		if pre == 0:
			cnt = 1
		else:
			cnt += 1
		pre = 1
	else:
		if pre == 1:
			b2.append(cnt)
			cnt = 0
		pre = 0
fct1 = []
fct2 = []
for i in range(1, int(k ** (1 / 2) + 3)):
	if k % i == 0:
		fct1.append(i)
		fct2.append(k // i)
fct = set(fct1 + fct2)
ans = 0
for f in fct:
	h = 0
	w = 0
	for ai in a2:
		h += max(0, ai - f + 1)
	for bi in b2:
		w += max(0, bi - k // f + 1)
	ans += h * w
print(ans)


import math
import collections
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

def divisors(n):
	ret = set()
	for i in range(1, math.ceil(n ** 0.5) + 1):
		if n % i == 0:
			ret.add(i)
			if n // i != i:
				ret.add(n // i)
	return ret
s = divisors(k)
aa = [i for i in range(n) if a[i] == 0]
aa.append(n)
aa.append(-1)
bb = [i for i in range(m) if b[i] == 0]
bb.append(m)
bb.append(-1)
aa.sort()
bb.sort()
ans = 0
for x in s:
	tmp = 0
	for i in range(len(aa) - 1):
		d = aa[i + 1] - aa[i]
		if d > x:
			tmp += d - x
	y = k // x
	for i in range(len(bb) - 1):
		d = bb[i + 1] - bb[i]
		if d > y:
			ans += tmp * (d - y)
print(ans)


def get_dividers(k):
	dividers = set()
	for i in range(1, int(k ** 0.5) + 2):
		if k % i == 0:
			dividers.add(i)
			dividers.add(k // i)
	return sorted(list(dividers))
(n, m, k) = map(int, input().split())
dividers = get_dividers(k)
A = list(map(int, input().split()))
B = list(map(int, input().split()))

def count(A, d):
	in_a_row = 0
	res = 0
	for a in A:
		if a == 1:
			in_a_row += 1
			if in_a_row >= d:
				res += 1
		else:
			in_a_row = 0
	return res
a_d = {}
b_d = {}
for d in dividers:
	a_d[d] = count(A, d)
	b_d[d] = count(B, d)
res = 0
for d in dividers:
	res += a_d[d] * b_d[k // d]
print(res)


import math

def printDivisors(n):
	l = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n / i == i:
				l.append(i)
			else:
				l.append(i)
		i = i + 1
	l.sort()
	return l
q = 1
for _ in range(q):
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	l = printDivisors(k)
	ans = 0
	for j in range(len(l)):
		x = l[j]
		y = k // l[j]
		if x == y:
			calc1 = 0
			cnt = 0
			for i in range(n):
				if a[i] == 1:
					cnt += 1
				else:
					cnt = 0
				if cnt >= x:
					calc1 += 1
			cnt = 0
			calc2 = 0
			for i in range(m):
				if b[i] == 1:
					cnt += 1
				else:
					cnt = 0
				if cnt >= y:
					calc2 += 1
			ans += calc2 * calc1
		else:
			calc1 = 0
			cnt = 0
			for i in range(n):
				if a[i] == 1:
					cnt += 1
				else:
					cnt = 0
				if cnt >= x:
					calc1 += 1
			cnt = 0
			calc2 = 0
			for i in range(m):
				if b[i] == 1:
					cnt += 1
				else:
					cnt = 0
				if cnt >= y:
					calc2 += 1
			ans += calc2 * calc1
			calc1 = 0
			cnt = 0
			for i in range(n):
				if a[i] == 1:
					cnt += 1
				else:
					cnt = 0
				if cnt >= y:
					calc1 += 1
			cnt = 0
			calc2 = 0
			for i in range(m):
				if b[i] == 1:
					cnt += 1
				else:
					cnt = 0
				if cnt >= x:
					calc2 += 1
			ans += calc2 * calc1
	print(ans)


import sys
from math import sqrt
from itertools import groupby, product
from collections import Counter
(n, m, k) = map(int, input().split())
a = Counter([len(list(v)) for (k, v) in groupby(input().split()) if k == '1'])
b = Counter([len(list(v)) for (k, v) in groupby(input().split()) if k == '1'])
divisors = {1, k} | ({2, k // 2} if k % 2 == 0 else set())
for i in range(3, int(sqrt(k)) + 2):
	if k % i == 0:
		divisors.add(i)
		if k // i != i:
			divisors.add(k // i)
divisors = sorted(divisors)
ans = 0
for ((ak, av), (bk, bv)) in product(a.items(), b.items()):
	for (di, dj) in zip(divisors, reversed(divisors)):
		if ak >= di and bk >= dj:
			ans += (ak - di + 1) * av * (bk - dj + 1) * bv
print(ans)


from collections import Counter

def aggregate(arr):
	(run_sum, res) = (0, Counter())
	for v in arr:
		if v == '0':
			if run_sum > 0:
				res[run_sum] += 1
			run_sum = 0
		elif v == '1':
			run_sum += 1
	return res

def pairs(k):
	pairs = [(i, k // i) for i in range(1, int(k ** 0.5) + 1) if k % i == 0]
	pairs += [(p2, p1) for (p1, p2) in pairs if p1 != p2]
	return pairs
(n, m, k) = list(map(int, input().split()))
(a, b) = (aggregate(input() + '0'), aggregate(input() + '0'))
print(sum((sum(((l - x + 1) * a[l] for l in a if l >= x)) * sum(((r - y + 1) * b[r] for r in b if r >= y)) for (x, y) in pairs(k))))


import math
from sys import stdin
I = stdin.readline

def divisors(n):
	i = 1
	ans = []
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				ans.append(i)
			else:
				ans.append(i)
				ans.append(n // i)
		i += 1
	return ans
for _ in range(1):
	(n, m, k) = map(int, I().split())
	ar = list(map(int, I().split()))
	br = list(map(int, I().split()))
	prv = 0
	la = []
	lb = []
	for i in range(n):
		if ar[i] == 1:
			prv += 1
		elif prv != 0 and ar[i] == 0:
			la.append(prv)
			prv = 0
	if prv != 0:
		la.append(prv)
		prv = 0
	for i in range(m):
		if br[i] == 1:
			prv += 1
		elif prv != 0 and br[i] == 0:
			lb.append(prv)
			prv = 0
	if prv != 0:
		lb.append(prv)
		prv = 0
	lena = len(la)
	lenb = len(lb)
	div = divisors(k)
	ldiv = len(div)
	cnt = 0
	cnt1 = 0
	cnt2 = 0
	for ij in range(ldiv):
		for i in range(lena):
			if div[ij] > la[i]:
				fl = 1
				continue
			var = la[i] + 1 - div[ij]
			if var < 0:
				var = 0
			cnt1 += var
		for j in range(lenb):
			if k // div[ij] > lb[j]:
				continue
			var = lb[j] + 1 - k // div[ij]
			if var < 0:
				var = 0
			cnt2 += var
		cnt += cnt1 * cnt2
		cnt1 = 0
		cnt2 = 0
	print(cnt)


from bisect import *
import sys
input = sys.stdin.readline
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
(aa, bb) = ([], [])
i = 0
while i < n:
	v = i
	while i < n and a[i] == 1:
		i += 1
	vv = i - 1
	if vv >= v:
		aa.append(vv - v + 1)
	i += 1
i = 0
while i < m:
	v = i
	while i < m and b[i] == 1:
		i += 1
	vv = i - 1
	if vv >= v:
		bb.append(vv - v + 1)
	i += 1
aa.sort()
bb.sort()
(n1, n2) = (len(aa), len(bb))
(div, ans) = (1, 0)
while div * div <= k:
	if k % div == 0:
		q = k // div
		i1 = bisect_left(aa, div)
		i2 = bisect_left(bb, q)
		(r, w) = (0, 0)
		for i in range(i1, n1):
			r += aa[i] - div + 1
		for i in range(i2, n2):
			w += bb[i] - q + 1
		ans += r * w
		if q != div:
			i1 = bisect_left(aa, q)
			i2 = bisect_left(bb, div)
			(r, w) = (0, 0)
			for i in range(i1, n1):
				r += aa[i] - q + 1
			for i in range(i2, n2):
				w += bb[i] - div + 1
			ans += r * w
	div += 1
print(ans)


(n, m, k) = list(map(int, input().strip().split()))
arr_n = list(map(int, input().strip().split()))
arr_m = list(map(int, input().strip().split()))
rec_n = []
rec_m = []
temp_count = 0
for i in range(n):
	if arr_n[i] == 0:
		if temp_count != 0:
			rec_n.append(temp_count)
			temp_count = 0
	else:
		temp_count += 1
else:
	if temp_count:
		rec_n.append(temp_count)
temp_count = 0
for i in range(m):
	if arr_m[i] == 0:
		if temp_count != 0:
			rec_m.append(temp_count)
			temp_count = 0
	else:
		temp_count += 1
else:
	if temp_count:
		rec_m.append(temp_count)
import math

def getDivisors(n):
	i = 1
	divisors = []
	while i <= math.sqrt(n):
		if n % i == 0:
			divisors.append((i, n // i))
			if n // i != i:
				divisors.append((n // i, i))
		i = i + 1
	return divisors
div_k = getDivisors(k)
div_k = sorted(div_k, key=lambda x: x[0])
(div_1, div_2) = zip(*div_k)
len_div = len(div_1)
from bisect import bisect_right

def count_subrect(n, m):
	global div_1, div_2, len_div
	i1 = bisect_right(div_1, n)
	ans = 0
	for i in range(i1):
		l1 = div_1[i]
		l2 = div_2[i]
		if l2 > m:
			continue
		ans += (n - l1 + 1) * (m - l2 + 1)
	return ans
from collections import Counter
rec_n = Counter(rec_n)
rec_m = Counter(rec_m)
final_ans = 0
for i in rec_n.keys():
	for j in rec_m.keys():
		final_ans += count_subrect(i, j) * rec_n[i] * rec_m[j]
print(final_ans)


import math
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

def divisors(x):
	res = []
	i = 1
	while i * i <= x:
		if x % i == 0:
			res.append(i)
			if x // i != i:
				res.append(x // i)
		i += 1
	return res
div = divisors(k)

def countones(ar, x):
	(ans, i) = (0, 0)
	while i < len(ar):
		cnt = 0
		while i < len(ar) and ar[i] == 1:
			cnt += 1
			i += 1
			if cnt >= x:
				ans += 1
		if cnt == 0:
			i += 1
	return ans
ans = 0
for i in range(len(div)):
	p = countones(a, div[i])
	q = countones(b, k // div[i])
	ans += p * q
print(ans)


import math

def printDivisors(n):
	res = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n / i == i:
				res.append([i, i])
			else:
				res.append([i, n // i])
				res.append([n // i, i])
		i = i + 1
	return res

def subsequence(f, arr):
	if len(arr) < f:
		return 0
	count = 0
	cont = 0
	for num in arr:
		if num == 1:
			cont += 1
		elif num == 0:
			if cont >= f:
				count += cont - f + 1
			cont = 0
	if cont >= f:
		count += cont - f + 1
	return count
(n, m, k) = map(int, input().split())
A = list(map(int, input().strip().split()))[:n]
B = list(map(int, input().strip().split()))[:m]
factor = printDivisors(k)
ans = 0
for (a, b) in factor:
	ans += subsequence(a, A) * subsequence(b, B)
print(ans)


(n, m, k) = map(int, input().split())
a = list((len(i) for i in input().replace(' ', '').split('0') if len(i) > 0))
b = list((len(i) for i in input().replace(' ', '').split('0') if len(i) > 0))
dim = [(i, k // i) for i in range(1, int(k ** 0.5) + 1) if k % i == 0]
dim += [(j, i) for (i, j) in dim if i != j]
ans = 0
for (x, y) in dim:
	ans += sum((i - x + 1 for i in a if x <= i)) * sum((j - y + 1 for j in b if y <= j))
print(ans)


import sys
input = sys.stdin.readline
from collections import *
(n, m, k) = map(int, input().split())
a = list(map(int, input().split())) + [0]
b = list(map(int, input().split())) + [0]
cnt1 = [0] * (n + 1)
now = 0
for i in range(n + 1):
	if a[i] == 0:
		for j in range(1, now + 1):
			cnt1[j] += now - j + 1
		now = 0
	else:
		now += 1
cnt2 = [0] * (m + 1)
now = 0
for i in range(m + 1):
	if b[i] == 0:
		for j in range(1, now + 1):
			cnt2[j] += now - j + 1
		now = 0
	else:
		now += 1
ans = 0
for i in range(1, int(k ** 0.5) + 1):
	if k % i == 0:
		if i <= n and k // i <= m:
			ans += cnt1[i] * cnt2[k // i]
		if i != k // i:
			if k // i <= n and i <= m:
				ans += cnt1[k // i] * cnt2[i]
print(ans)


import math

def get_factor_pairs(x):
	out = []
	for i in range(1, 1 + int(math.sqrt(x))):
		if x % i == 0:
			out.append([i, x // i])
	return out

def get_seq(arr, arr_length):
	out = []
	for i in range(arr_length):
		if arr[i] == 0:
			out.append(0)
		elif arr[i] == 1 and i == 0:
			out.append(1)
		else:
			out.append(out[i - 1] + 1)
	return out

def get_count(arr, val):
	count = 0
	for i in arr:
		if i >= val:
			count += 1
	return count
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
pairs = get_factor_pairs(k)
a_seq = get_seq(a, n)
b_seq = get_seq(b, m)
total = 0
for (x, y) in pairs:
	a_count = get_count(a_seq, x)
	b_count = get_count(b_seq, y)
	total += a_count * b_count
	if x != y:
		a_count = get_count(a_seq, y)
		b_count = get_count(b_seq, x)
		total += a_count * b_count
print(total)


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
from bisect import bisect_left
cna = []
cnt = 0
i = 0
while i < n:
	if a[i] == 1:
		cnt += 1
	else:
		cna.append(cnt)
		cnt = 0
	i += 1
if a[-1] == 1:
	cna.append(cnt)
cna.sort()
ca = [0]
for i in range(len(cna)):
	ca.append(ca[-1] + cna[i])
cnb = []
cnt = 0
i = 0
while i < m:
	if b[i] == 1:
		cnt += 1
	else:
		cnb.append(cnt)
		cnt = 0
	i += 1
if b[-1] == 1:
	cnb.append(cnt)
cnb.sort()
cb = [0]
for i in range(len(cnb)):
	cb.append(cb[-1] + cnb[i])
pd = []
for i in range(1, int(k ** 0.5) + 1):
	if k % i == 0:
		if i == k // i and i <= n and (i <= m):
			pd.append([i, i])
		else:
			if i <= n and k // i <= m:
				pd.append([i, k // i])
			if k // i <= n and i <= m:
				pd.append([k // i, i])
ans = 0
for (f, g) in pd:
	pa = bisect_left(cna, f)
	pb = bisect_left(cnb, g)
	sa = ca[-1] - ca[pa]
	sb = cb[-1] - cb[pb]
	na = len(cna) - pa
	nb = len(cnb) - pb
	ans += (sa - na * f + na) * (sb - nb * g + nb)
print(ans)


from __future__ import division, print_function
import sys
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
if os.path.exists('out.txt'):
	sys.stdout = open('out.txt', 'w')

def input():
	return sys.stdin.readline()

def mapi(arg=0):
	return map(int if arg == 0 else str, input().split())
(n, m, k) = mapi()
a = list(mapi())
b = list(mapi())
res = 0
bit = [0] * (n + 1)
nit = [0] * (m + 1)

def update(bit, n, idx, val):
	while idx <= n:
		bit[idx] += val
		idx += idx & -idx

def query(bit, idx):
	res = 0
	while idx > 0:
		res += bit[idx]
		idx -= idx & -idx
	return res
cnt = 0
for i in a:
	if i == 1:
		cnt += 1
		update(bit, n, 1, 1)
		update(bit, n, cnt + 1, -1)
	else:
		cnt = 0
cnt = 0
for i in b:
	if i == 1:
		cnt += 1
		update(nit, m, 1, 1)
		update(nit, m, cnt + 1, -1)
	else:
		cnt = 0
for i in range(1, int(k ** 0.5) + 1):
	if k % i != 0:
		continue
	if i <= n and k // i <= m:
		res += query(bit, i) * query(nit, k // i)
	if k // i != i and k // i <= n and (i <= m):
		res += query(bit, k // i) * query(nit, i)
print(res)


from math import *

def binarySearch(arr, x, i):
	l = i
	r = len(arr) - 1
	while l <= r:
		mid = (l + r) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] < x:
			l = mid + 1
		else:
			r = mid - 1
	return -1

def js(arr, x):
	l = 0
	r = len(arr) - 1
	ans = -1
	while l <= r:
		m = (l + r) // 2
		if arr[m] <= x:
			ans = m
			l = m + 1
		else:
			r = m - 1
	return ans

def jg(arr, x):
	l = 0
	r = len(arr) - 1
	ans = -1
	while l <= r:
		m = (l + r) // 2
		if arr[m] >= x:
			ans = m
			r = m - 1
		else:
			l = m + 1
	return ans
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
p1 = []
for i in range(n):
	if i == 0:
		if a[i] == 0:
			p1.append(0)
		else:
			p1.append(1)
	elif a[i] == 0:
		p1.append(0)
	elif a[i - 1] == 0:
		p1.append(1)
	else:
		p1.append(1 + p1[i - 1])
p2 = []
for i in range(m):
	if i == 0:
		if b[i] == 0:
			p2.append(0)
		else:
			p2.append(1)
	elif b[i] == 0:
		p2.append(0)
	elif b[i - 1] == 0:
		p2.append(1)
	else:
		p2.append(1 + p2[i - 1])
f = []
for i in range(1, int(k ** 0.5) + 1):
	if k % i == 0:
		if k % (k // i) == 0 and k // i != i:
			f.append(k // i)
		f.append(i)
f.sort()
ans = 0
for i in range(len(f)):
	a1 = 0
	for j in range(len(p2)):
		if j < m - 1:
			if p2[j + 1] == 0 and p2[j] >= k // f[i]:
				a1 += p2[j] - k // f[i] + 1
		elif p2[j] >= k // f[i]:
			a1 += p2[j] - k // f[i] + 1
	a2 = 0
	for j in range(len(p1)):
		if j < n - 1:
			if p1[j + 1] == 0 and p1[j] >= f[i]:
				a2 += p1[j] - f[i] + 1
		elif p1[j] >= f[i]:
			a2 += p1[j] - f[i] + 1
	ans += a1 * a2
print(ans)


def lens(arr):
	n = len(arr)
	res = [0] * (n + 1)
	i = 0
	j = 0
	while i < n:
		while arr[i] == 0:
			i += 1
			if i >= n:
				break
		j = i
		while j < n and arr[j] == 1:
			j += 1
		for Len in range(1, j - i + 1):
			res[Len] += j - i - Len + 1
		i = j
	return res
t = [int(x) for x in input().split(' ')]
n = t[0]
m = t[1]
k = t[2]
N_arr = [int(x) for x in input().split()]
M_arr = [int(x) for x in input().split()]
N_lens = lens(N_arr)
M_lens = lens(M_arr)
i = 0
j = 0
res = 0
i = 1
for i in range(1, n + 1):
	if k % i == 0 and k // i <= m:
		res += N_lens[i] * M_lens[k // i]
	i += 1
print(res)


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def divisor(n):
	ret = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			ret.append(i)
			if i * i != n:
				ret.append(n // i)
	return ret

class Binary_Indexed_Tree_RAQ:

	def __init__(self, n):
		self.data = [0] * (n + 1)
		self.n = n + 1

	def __add(self, ind, num):
		while ind <= self.n:
			self.data[ind - 1] += num
			ind += ind & -ind

	def range_add(self, s, t, x):
		self.__add(s, x)
		self.__add(t + 1, -x)

	def query(self, i):
		ret = 0
		while i > 0:
			ret += self.data[i - 1]
			i -= i & -i
		return ret
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cnt = 0
cnt_a = Binary_Indexed_Tree_RAQ(n)
cnt_b = Binary_Indexed_Tree_RAQ(m)
for i in a:
	if i == 1:
		cnt += 1
		cnt_a.range_add(1, cnt, 1)
	else:
		cnt = 0
cnt = 0
for i in b:
	if i == 1:
		cnt += 1
		cnt_b.range_add(1, cnt, 1)
	else:
		cnt = 0
ans = 0
for i in divisor(k):
	j = k // i
	if i <= n and j <= m:
		ans += cnt_a.query(i) * cnt_b.query(j)
print(ans)


import math

def countDivisors(n):
	l = {}
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				l[i] = 0
			else:
				l[i] = 0
				l[n // i] = 0
	return l
(n, m, k) = map(int, input().split())
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
j = 0
(c1, c2) = (0, 0)
f1 = 0
f2 = 0
a1 = [0 for i in range(n + 1)]
a2 = [0 for i in range(m + 1)]
while j < max(n, m):
	if f1 < n:
		if l1[j] == 1:
			c1 += 1
		else:
			if c1 != 0:
				a1[c1] += 1
			c1 = 0
	if f2 < m:
		if l2[j] == 1:
			c2 += 1
		else:
			if c2 != 0:
				a2[c2] += 1
			c2 = 0
	j += 1
	f1 += 1
	f2 += 1
if c1 != 0:
	a1[c1] += 1
if c2 != 0:
	a2[c2] += 1
l3 = countDivisors(k)
l4 = l3.copy()
ans = [0 for i in range(n)]
for i in range(max(m + 1, n + 1)):
	if i < n + 1 and a1[i] > 0:
		for j in sorted(l3.keys()):
			if i >= j:
				l3[j] += a1[i] * (i - j + 1)
				continue
			break
	if i < m + 1 and a2[i] > 0:
		for j in sorted(l4.keys()):
			if i >= j:
				l4[j] += a2[i] * (i - j + 1)
				continue
			break
c = 0
for i in l3:
	c += l3[i] * l4[k // i]
print(c)


(n, m, k) = [int(i) for i in input().split(' ')]
a = [int(i) for i in input().split(' ')]
b = [int(i) for i in input().split(' ')]

def get_interval_lens_of_ones(arr):
	res = [0] * (len(arr) + 1)
	i = 0
	while i < len(arr):
		if arr[i] == 0:
			i += 1
			continue
		cnt = 0
		while i < len(arr) and arr[i] == 1:
			cnt += 1
			i += 1
		for j in range(cnt):
			res[j + 1] += cnt - j
	return res
(ga, gb) = (get_interval_lens_of_ones(a), get_interval_lens_of_ones(b))
res = 0
for i in range(1, n + 1):
	if k % i == 0 and k // i <= m:
		res += ga[i] * gb[k // i]
print(res)


def count(A):
	segs = []
	cur = 0
	flag = 0
	for a in A:
		if a:
			cur += 1
			flag = 1
		elif flag:
			flag = 0
			segs.append(cur)
			cur = 0
	if flag and cur > 0:
		segs.append(cur)
	count = [0] * (len(A) + 1)
	for s in segs:
		for i in range(1, s + 1):
			count[i] += s - i + 1
	return count

def f():
	(n, m, k) = [int(s) for s in input().split()]
	A = [int(s) for s in input().split()]
	B = [int(s) for s in input().split()]
	ans = 0
	countA = count(A)
	countB = count(B)
	for l1 in range(1, n + 1):
		if k % l1:
			continue
		l2 = k // l1
		if l2 > m:
			continue
		ans += countA[l1] * countB[l2]
	print(ans)
f()


import math
import collections

def fun(a):
	s = len(a)
	res = collections.defaultdict(int)
	i = 0
	while i < s:
		if a[i] == 0:
			i += 1
			continue
		j = i
		while j < s and a[j] == 1:
			j += 1
		for x in range(1, j - i + 1):
			res[x] += j - i - x + 1
		i = j
	return res
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
c = fun(a)
d = fun(b)
for el in c:
	if k % el == 0 and k / el <= m:
		ans += c[el] * d[k / el]
print(ans)


[a, a, area] = list(map(int, input().split(' ')))
a = [len(i) for i in input().replace(' ', '').split('0') if len(i) > 0]
b = [len(i) for i in input().replace(' ', '').split('0') if len(i) > 0]
ans = 0
fac = []
k = 1
while k * k <= area:
	if area % k == 0:
		fac.append((k, area // k))
	k += 1
fac += [(j, i) for (i, j) in fac if i != j]
for (x, y) in fac:
	ans += sum((i - x + 1 for i in a if x <= i)) * sum((j - y + 1 for j in b if y <= j))
print(ans)


from collections import defaultdict as d

def getContiguous1sCount(arr):
	n = len(arr)
	c = 0
	cnts = d(lambda : 0)
	for i in range(n):
		if arr[i] == 1:
			c += 1
		else:
			if c > 0:
				cnts[c] += 1
			c = 0
	if c > 0:
		cnts[c] += 1
	return cnts
(n, m, k) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
aCnts = getContiguous1sCount(a)
bCnts = getContiguous1sCount(b)
rects = []
for (x, xx) in aCnts.items():
	for (y, yy) in bCnts.items():
		rects.append([[x, y], xx * yy])
validRects = []
for i in range(1, int(k ** 0.5) + 1):
	if k % i == 0:
		j = k // i
		validRects.append([i, j])
		if i != j:
			validRects.append([j, i])
ans = 0
for (xy, cnts) in rects:
	(x, y) = xy
	for (vx, vy) in validRects:
		ans += max(0, x - vx + 1) * max(0, y - vy + 1) * cnts
print(ans)


import re
(n, m, k) = map(int, input().split())
a = ''.join(input().split())
b = ''.join(input().split())
f = []
for i in range(1, int(k ** 0.5) + 1):
	if k % i == 0:
		f.append((i, k // i))
		if i != k // i:
			f.append((k // i, i))
d1 = [len(i) for i in re.findall('1+', a)]
d2 = [len(i) for i in re.findall('1+', b)]
r = 0
for i in f:
	(c1, c2) = ([], [])
	for j in d1:
		if j >= i[0]:
			c1.append(j - i[0] + 1)
	for j in d2:
		if j >= i[1]:
			c2.append(j - i[1] + 1)
	for j in c1:
		for k in c2:
			r += j * k
print(r)


import sys
input = sys.stdin.readline
import math
from bisect import bisect_left
(N, M, K) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
pA = [0]
for a in A:
	if a:
		pA.append(pA[-1] + 1)
	else:
		pA.append(0)
pB = [0]
for b in B:
	if b:
		pB.append(pB[-1] + 1)
	else:
		pB.append(0)
pA.sort()
pB.sort()
ans = 0
for n in range(1, int(math.sqrt(K)) + 3):
	if K % n == 0 and K // n >= n:
		ans += (N + 1 - bisect_left(pA, n)) * (M + 1 - bisect_left(pB, K // n))
		if K // n != n:
			ans += (N + 1 - bisect_left(pA, K // n)) * (M + 1 - bisect_left(pB, n))
print(ans)


def examA():
	t = I()
	ans = []
	for _ in range(t):
		N = I()
		A = LI()
		flag = False
		for (i, a) in enumerate(A):
			if a % 2 == 0:
				flag = True
				ans.append((1, i + 1))
				break
		if flag:
			continue
		if N == 1:
			ans.append(-1)
			continue
		ans.append(2)
	for v in ans:
		if v == 2:
			print(2)
			print('1 2')
		elif v == -1:
			print(-1)
		else:
			print(v[0])
			print(v[1])
	return

def examB():

	def make_divisors(n):
		divisors = []
		for i in range(1, int(n ** 0.5) + 1):
			if n % i == 0:
				divisors.append(i)
				if i != n // i:
					divisors.append(n // i)
		return divisors
	(N, M, K) = LI()
	a = LI()
	b = LI()
	A = defaultdict(int)
	B = defaultdict(int)
	cur = 0
	for i in range(N):
		if a[i] == 1:
			cur += 1
		elif cur >= 1:
			A[cur] += 1
			cur = 0
	if cur > 0:
		A[cur] += 1
	cur = 0
	for i in range(M):
		if b[i] == 1:
			cur += 1
		elif cur >= 1:
			B[cur] += 1
			cur = 0
	if cur > 0:
		B[cur] += 1
	SA = [0] * (N + 2)
	SB = [0] * (M + 2)
	for i in range(1, N + 1)[::-1]:
		SA[i] = SA[i + 1] + A[i]
	for i in range(1, M + 1)[::-1]:
		SB[i] = SB[i + 1] + B[i]
	SA2 = [0] * (N + 2)
	SB2 = [0] * (M + 2)
	for i in range(1, N + 1)[::-1]:
		SA2[i] = SA2[i + 1] + SA[i + 1] + A[i]
	for i in range(1, M + 1)[::-1]:
		SB2[i] = SB2[i + 1] + SB[i + 1] + B[i]
	S = make_divisors(K)
	if len(S) % 2 == 1:
		S.append(S[-1])
	loop = len(S) // 2
	ans = 0
	for i in range(loop):
		x = S[i * 2]
		y = S[i * 2 + 1]
		if x <= N and y <= M:
			ans += SA2[x] * SB2[y]
		if x == y:
			continue
		x = S[i * 2 + 1]
		y = S[i * 2]
		if x <= N and y <= M:
			ans += SA2[x] * SB2[y]
	print(ans)
	return

def examC():
	N = I()
	S = SI()
	ans = 0
	print(ans)
	return

def examD():
	ans = 0
	print(ans)
	return

def examE():
	ans = 0
	print(ans)
	return

def examF():
	ans = 0
	print(ans)
	return
import sys, copy, bisect, itertools, heapq, math, random
from heapq import heappop, heappush, heapify
from collections import Counter, defaultdict, deque

def I():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LSI():
	return list(map(str, sys.stdin.readline().split()))

def LS():
	return sys.stdin.readline().split()

def SI():
	return sys.stdin.readline().strip()
global mod, mod2, inf, alphabet, _ep
mod = 10 ** 9 + 7
mod2 = 998244353
inf = 10 ** 18
_ep = 10 ** (-12)
alphabet = [chr(ord('a') + i) for i in range(26)]
examB()


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')

	def gao(a):
		n = len(a)
		i = 0
		res = [0] * (n + 1)
		while i < n:
			if a[i] == 0:
				i += 1
			else:
				j = i
				while j < n and a[j] == 1:
					j += 1
				for l in range(1, j - i + 1):
					res[l] += j - i - l + 1
				i = j
		return res
	for _ in range(1):
		(n, m, k) = ria()
		a = ria()
		b = ria()
		za = gao(a)
		zb = gao(b)
		ans = 0
		for i in range(1, n + 1):
			if k % i == 0 and k // i <= m:
				ans += za[i] * zb[k // i]
		print(ans)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


import sys
from sys import stdin
import math

def solve():
	(n, m, k) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	l = [0] * (n + 2)
	r = [0] * (m + 2)
	i = 0
	while i < n:
		if a[i] == 1:
			j = i
			while j < n and a[j] == 1:
				j += 1
			for t in range(1, j - i + 1):
				l[t] += j - i - t + 1
			i = j
		else:
			i += 1
	i = 0
	while i < m:
		if b[i] == 1:
			j = i
			while j < m and b[j] == 1:
				j += 1
			for t in range(1, j - i + 1):
				r[t] += j - i - t + 1
			i = j
		else:
			i += 1
	ans = 0
	sqrtK = int(math.sqrt(k))
	for x in range(1, min(n + 1, sqrtK + 1)):
		if k % x == 0:
			y = int(k / x)
			if y <= m:
				ans += l[x] * r[y]
			if x != y and x <= m and (y <= n):
				ans += l[y] * r[x]
	print(ans)

def main():
	solve()
main()


from sys import stdin, stdout

def cnt(s):
	ans = []
	temp = 0
	for i in range(len(s) - 1):
		if s[i] == 1 and s[i + 1] == 1:
			temp += 1
		elif s[i] == 1 and s[i + 1] == 0:
			ans.append(temp + 1)
			temp = 0
	if s[len(s) - 1] == 1:
		ans.append(temp + 1)
	return ans
(n, m, k) = map(int, stdin.readline().split())
col = list(map(int, stdin.readline().split()))
row = list(map(int, stdin.readline().split()))
fac = []
i = 1
while i * i <= k:
	if k % i == 0:
		fac.append([i, k // i])
	i += 1
ans = 0
co = cnt(col)
ro = cnt(row)
co.sort(reverse=True)
ro.sort(reverse=True)
for i in range(len(fac)):
	if fac[i][0] == fac[i][1]:
		t1 = 0
		t2 = 0
		for j in range(len(co)):
			if co[j] >= fac[i][0]:
				t1 += co[j] - fac[i][0] + 1
			else:
				break
		for j in range(len(ro)):
			if ro[j] >= fac[i][0]:
				t2 += ro[j] - fac[i][0] + 1
			else:
				break
		ans += t1 * t2
	else:
		t1 = 0
		t2 = 0
		for j in range(len(co)):
			if co[j] >= fac[i][0]:
				t1 += co[j] - fac[i][0] + 1
			else:
				break
		for j in range(len(ro)):
			if ro[j] >= fac[i][1]:
				t2 += ro[j] - fac[i][1] + 1
			else:
				break
		ans += t1 * t2
		t1 = 0
		t2 = 0
		for j in range(len(co)):
			if co[j] >= fac[i][1]:
				t1 += co[j] - fac[i][1] + 1
			else:
				break
		for j in range(len(ro)):
			if ro[j] >= fac[i][0]:
				t2 += ro[j] - fac[i][0] + 1
			else:
				break
		ans += t1 * t2
stdout.write(str(ans) + '\n')


import sys
input = sys.stdin.readline
(n, m, k) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
from math import sqrt
ANS = 0
x = int(sqrt(k)) + 3
LIST = []
for i in range(1, x):
	if k % i == 0:
		LIST.append(i)
		LIST.append(k // i)
LIST = set(LIST)
for l in LIST:
	(ax, bx) = (l, k // l)
	count = 0
	A1 = 0
	B1 = 0
	for a in A:
		if a == 1:
			count += 1
		else:
			count = 0
		if count >= ax:
			A1 += 1
	count = 0
	for b in B:
		if b == 1:
			count += 1
		else:
			count = 0
		if count >= bx:
			B1 += 1
	ANS += A1 * B1
print(ANS)


from collections import defaultdict, Counter
from bisect import bisect, bisect_left
from math import sqrt, gcd, ceil, factorial
from heapq import heapify, heappush, heappop
MOD = 10 ** 9 + 7
inf = float('inf')
ans_ = []

def nin():
	return int(input())

def ninf():
	return int(file.readline())

def st():
	return input().strip()

def stf():
	return file.readline().strip()

def read():
	return list(map(int, input().strip().split()))

def readf():
	return list(map(int, file.readline().strip().split()))
ans_ = []

def solve():
	(n, m, k) = read()
	(a, b) = (st().replace(' ', '').split('0'), st().replace(' ', '').split('0'))
	a = [len(i) for i in a]
	b = [len(i) for i in b]
	d1 = defaultdict(int)
	d2 = defaultdict(int)
	for i in a:
		for j in range(1, i + 1):
			d1[j] += i - j + 1
	for i in b:
		for j in range(1, i + 1):
			d2[j] += i - j + 1
	i = 1
	ans = 0
	while i * i <= k:
		if k % i == 0:
			ans += d1[i] * d2[k // i] + (d1[k // i] * d2[i] if i * i != k else 0)
		i += 1
	ans_.append(ans)
solve()
for i in ans_:
	print(i)


def pair(k):
	factor = []
	(x, y) = (k, 1)
	for i in range(1, int(k ** 0.5) + 1):
		if k % i == 0 and i < n + 1 and (k // i < m + 1):
			factor.append((i, k // i))
		if k % i == 0 and i != k // i and (k // i < n + 1) and (i < m + 1):
			factor.append((k // i, i))
	return factor
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
comb = []
if k == 1:
	(oneA, oneB) = (0, 0)
	for i in a:
		if i == 1:
			oneA = oneA + 1
	for i in b:
		if i == 1:
			oneB = oneB + 1
	print(oneB * oneA)
else:
	comb = pair(k)
	ans = 0
	for i in range(len(comb)):
		itr = comb[i][0]
		count1 = 0
		c1 = 0
		for j in a:
			if j == 1:
				c1 = c1 + 1
			else:
				if c1 > itr or c1 == itr:
					count1 = count1 + (c1 - itr + 1)
				c1 = 0
		if c1 > itr or c1 == itr:
			count1 = count1 + (c1 - itr + 1)
		c1 = 0
		itr = comb[i][1]
		count2 = 0
		for j in b:
			if j == 1:
				c1 = c1 + 1
			else:
				if c1 > itr or c1 == itr:
					count2 = count2 + (c1 - itr + 1)
				c1 = 0
		if c1 > itr or c1 == itr:
			count2 = count2 + (c1 - itr + 1)
		ans = ans + count2 * count1
	print(ans)


import sys
inp = sys.stdin.readline

def input():
	return inp().strip()

def iin():
	return int(input())

def lin():
	return list(map(int, input().split()))

def main():
	T = 1
	while T:
		T -= 1
		(n, m, k) = lin()
		mx = max(n, m)
		a = lin() + [0]
		b = lin() + [0]
		ans1 = [0] * (mx + 1)
		ans2 = [0] * (mx + 1)
		ch = 0
		for i in a:
			if i:
				ch += 1
			else:
				ans1[ch] += 1
				ch = 0
		ch = 0
		for i in b:
			if i:
				ch += 1
			else:
				ans2[ch] += 1
				ch = 0
		for i in range(mx + 1):
			if ans1[i]:
				ch = i - 1
				ch2 = ans1[i]
				for j in range(1, i + 1):
					ans1[ch] += (j + 1) * ch2
					ch -= 1
			if ans2[i]:
				ch = i - 1
				ch2 = ans2[i]
				for j in range(1, i + 1):
					ans2[ch] += (j + 1) * ch2
					ch -= 1
		i = 1
		sol = 0
		while i * i <= k:
			if k % i == 0:
				if i <= mx and k // i <= mx:
					sol += ans1[i] * ans2[k // i]
					if i != k // i:
						sol += ans1[k // i] * ans2[i]
			i += 1
		print(sol)
main()


from math import sqrt
(n, m, k) = map(int, input().strip().split())
a = [int(i) for i in input().strip().split()]
b = [int(i) for i in input().strip().split()]
combs = set()
for i in range(1, int(sqrt(k)) + 1):
	if k % i == 0:
		combs.add((i, k // i))
		combs.add((k // i, i))
ans = 0
real_ans = 0
for pair in combs:
	(leng, wid) = pair
	cnt = 0
	(lans, wans) = (0, 0)
	for i in range(n):
		if a[i] == 1:
			cnt += 1
			if cnt >= leng:
				lans += 1
		else:
			cnt = 0
	cnt = 0
	for i in range(m):
		if b[i] == 1:
			cnt += 1
			if cnt >= wid:
				wans += 1
		else:
			cnt = 0
	real_ans += lans * wans
print(real_ans)


def tc():
	(n, m, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.append(0)
	b.append(0)
	achains = []
	cnt = 0
	for x in a:
		if x:
			cnt += 1
		elif cnt:
			achains.append(cnt)
			cnt = 0
	bchains = []
	cnt = 0
	for x in b:
		if x:
			cnt += 1
		elif cnt:
			bchains.append(cnt)
			cnt = 0
	alens = [0] * (n + 1)
	blens = [0] * (m + 1)
	for x in achains:
		for i in range(1, x + 1):
			alens[i] += x - i + 1
	for y in bchains:
		for i in range(1, y + 1):
			blens[i] += y - i + 1
	ans = 0
	for i in range(1, n + 1):
		if k % i == 0 and k // i <= m:
			ans += alens[i] * blens[k // i]
	print(ans)
tc()


import sys
input = sys.stdin.readline
from math import sqrt
from collections import Counter

def factor_pairs(k):
	pairs = []
	for i in range(1, int(sqrt(k)) + 1):
		if k % i == 0:
			pairs.append([i, k // i])
	length = len(pairs)
	if int(sqrt(k)) != sqrt(k):
		pairs.append(pairs[-1][::-1])
	for i in range(length - 2, -1, -1):
		pairs.append(pairs[i][::-1])
	return pairs

def prog():
	(n, m, k) = map(int, input().split())
	a = ''.join(input().split())
	b = ''.join(input().split())
	pairs = factor_pairs(k)
	w_vals = Counter(map(len, a.split('0')))
	l_vals = Counter(map(len, b.split('0')))
	subrectangles = 0
	for width in w_vals:
		for length in l_vals:
			for (x, y) in pairs:
				if x > width:
					break
				elif y <= length:
					subrectangles += w_vals[width] * l_vals[length] * (width - x + 1) * (length - y + 1)
	print(subrectangles)
prog()


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import defaultdict as dd, deque as dq
import math, string

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7
from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def solve():
	(N, M, K) = getInts()
	(A, B) = (getInts(), getInts())
	dp = [[0 for y in range(2)] for x in range(max(N + 1, M + 1))]

	def getNum(arr, L, x):
		curr = 0
		num1 = 0
		for i in range(L):
			if arr[i] == 1:
				curr += 1
			else:
				for j in range(1, curr + 1):
					dp[j][x] += curr + 1 - j
				curr = 0
		for j in range(1, curr + 1):
			dp[j][x] += curr + 1 - j
	getNum(A, N, 0)
	getNum(B, M, 1)
	facs = dq(sorted(list(factors(K))))
	ans = 0
	while facs:
		if len(facs) == 1:
			x = facs.pop()
			ans += dp[x][0] * dp[x][1]
		else:
			(x, y) = (facs.popleft(), facs.pop())
			if y > max(N, M):
				continue
			ans += dp[x][0] * dp[y][1] + dp[y][0] * dp[x][1]
	return ans
print(solve())


from collections import defaultdict
import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]

def main():

	def ser(aa):
		pa = aa[0]
		w = 1
		res = defaultdict(int)
		for a in aa[1:]:
			if pa == a:
				w += 1
			else:
				if pa == 1:
					res[w] += 1
				w = 1
			pa = a
		if pa == 1:
			res[w] += 1
		return res

	def divs(k):
		res = []
		for i in range(1, k + 1):
			if i ** 2 > k:
				break
			if k % i == 0:
				res.append(i)
				res.append(k // i)
		if res[-1] ** 2 == k:
			res.pop()
		return res

	def cntl(cnta, la):
		res = 0
		for (w, c) in cnta.items():
			if w - la + 1 > 0:
				res += (w - la + 1) * c
		return res
	(n, m, k) = MI()
	dd = divs(k)
	aa = LI()
	bb = LI()
	cnta = ser(aa)
	cntb = ser(bb)
	ans = 0
	for la in dd:
		lb = k // la
		ans += cntl(cnta, la) * cntl(cntb, lb)
	print(ans)
main()


(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d1 = {}
d2 = {}
i = 1
while i * i <= k:
	if k % i == 0:
		d1[i] = 0
		d2[i] = 0
		d1[k // i] = 0
		d2[k // i] = 0
	i += 1
c = 0
for i in range(n):
	if a[i] == 1:
		c += 1
	else:
		for j in d1:
			if j <= c:
				d1[j] += c - j + 1
		c = 0
for j in d1:
	if j <= c:
		d1[j] += c - j + 1
c = 0
for i in range(m):
	if b[i] == 1:
		c += 1
	else:
		for j in d2:
			if j <= c:
				d2[j] += c - j + 1
		c = 0
for j in d2:
	if j <= c:
		d2[j] += c - j + 1
ans = 0
for i in d1:
	for j in d2:
		if i * j == k:
			ans += d1[i] * d2[j]
print(ans)


from math import sqrt
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans_a = []
ans_b = []
now = 0
for i in range(n):
	if a[i] == 1:
		now += 1
	elif now != 0:
		ans_a.append(now)
		now = 0
if now != 0:
	ans_a.append(now)
now = 0
for i in range(m):
	if b[i] == 1:
		now += 1
	elif now != 0:
		ans_b.append(now)
		now = 0
if now != 0:
	ans_b.append(now)
ans = 0
i = 1
while i < int(sqrt(k)) + 1:
	if k % i == 0:
		j = k // i
		ans_1 = 0
		for el in ans_a:
			ans_1 += max(0, el - i + 1)
		ans_2 = 0
		for el in ans_b:
			ans_2 += max(0, el - j + 1)
		ans += ans_1 * ans_2
		if j != i:
			ans_1 = 0
			for el in ans_a:
				ans_1 += max(0, el - j + 1)
			ans_2 = 0
			for el in ans_b:
				ans_2 += max(0, el - i + 1)
			ans += ans_1 * ans_2
	i += 1
print(ans)


from bisect import bisect_left as bl, bisect_right as br, insort
import sys
import heapq
from math import *
from collections import defaultdict as dd, deque

def data():
	return sys.stdin.readline().strip()

def mdata():
	return map(int, data().split())

def fac(x):
	f = set()
	for i in range(1, int(x ** 0.5) + 1):
		if x % i == 0:
			f.add(i)
			f.add(x // i)
	return f
(n, m, k) = mdata()
a = list(mdata())
b = list(mdata())
f = sorted(fac(k))
t = 0
a1 = {}
b1 = {}
fa = {}
fb = {}
for i in a:
	if i == 1:
		t += 1
	elif t != 0:
		if a1.get(t) == None:
			a1[t] = 1
		else:
			a1[t] += 1
		t = 0
if t != 0:
	if a1.get(t) == None:
		a1[t] = 1
	else:
		a1[t] += 1
for i in f:
	fa[i] = 0
	for j in a1:
		if i <= j:
			fa[i] += (j - i + 1) * a1[j]
t = 0
for i in b:
	if i == 1:
		t += 1
	elif t != 0:
		if b1.get(t) == None:
			b1[t] = 1
		else:
			b1[t] += 1
		t = 0
if t != 0:
	if b1.get(t) == None:
		b1[t] = 1
	else:
		b1[t] += 1
for i in f:
	fb[i] = 0
	for j in b1:
		if i <= j:
			fb[i] += (j - i + 1) * b1[j]
ans = 0
for i in fa:
	if k // i in fb:
		ans += fa[i] * fb[k // i]
print(ans)


from _collections import OrderedDict

def div_(num, mx):
	mas = list()
	for i in range(1, min(num, mx) + 1):
		if num % i == 0:
			mas.append((i, num // i))
	return mas
(n, m, k) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
ans = 0
lenght = 0
row = OrderedDict()
for i in a:
	if i == 1:
		lenght += 1
	else:
		if lenght:
			if lenght in row:
				row[lenght] += 1
			else:
				row[lenght] = 1
		lenght = 0
if lenght:
	if lenght in row:
		row[lenght] += 1
	else:
		row[lenght] = 1
column = OrderedDict()
lenght = 0
for i in b:
	if i == 1:
		lenght += 1
	else:
		if lenght:
			if lenght in column:
				column[lenght] += 1
			else:
				column[lenght] = 1
		lenght = 0
if lenght:
	if lenght in column:
		column[lenght] += 1
	else:
		column[lenght] = 1
mdiv = div_(k, max(m, n))
if len(row) and len(column):
	for k in mdiv:
		(x, y) = [int(i) for i in k]
		for i in row:
			for j in column:
				if i >= x and j >= y:
					ans += (i - x + 1) * (j - y + 1) * row[i] * column[j]
print(ans)


import sys
input = sys.stdin.readline
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

def subsequent(a):
	n = len(a)
	co = [0] * (n + 1)
	i = 0
	while i < n:
		if not a[i]:
			i += 1
			continue
		j = i
		while j < n and a[j]:
			j += 1
		for l in range(1, j - i + 1):
			co[l] += j - i - l + 1
		i = j
	return co
coa = subsequent(a)
cob = subsequent(b)
ans = 0
for i in range(1, n + 1):
	if k % i == 0:
		d = k // i
		if d <= m:
			ans += coa[i] * cob[d]
print(ans)


import sys
from sys import stdin, stdout
import bisect
import math
import heapq

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
import math

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def intersection(lst1, lst2):
	lst3 = [value for value in lst1 if value in lst2]
	return lst3

def main():
	(n, m, k) = cin()
	a = ain()
	b = ain()
	x = 0
	aa = [0] * (n + 1)
	bb = [0] * (m + 1)
	for i in a:
		if i == 1:
			x += 1
			aa[x] += 1
		else:
			x = 0
	x = 0
	for i in b:
		if i == 1:
			x += 1
			bb[x] += 1
		else:
			x = 0
	for i in range(n, 0, -1):
		aa[i - 1] = aa[i - 1] + aa[i]
	for i in range(m, 0, -1):
		bb[i - 1] = bb[i - 1] + bb[i]
	ans = 0
	a = aa[:]
	b = bb[:]
	for i in range(1, int(math.sqrt(k)) + 1):
		if k % i == 0:
			x = i
			y = k // i
			if x == y:
				if x <= n and x <= m:
					ans += a[x] * b[x]
			else:
				if x <= n and y <= m:
					ans += a[x] * b[y]
				if x <= m and y <= n:
					ans += a[y] * b[x]
	print(ans)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'0'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'0'[0]:
		A.append(sign * numb)
	return A
main()


import sys
import os
import time
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random
import string

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
(n, m, k) = mi()
a = li()
b = li()
d = [[] for _ in range(n)]
ac = dd()
bc = dd()
i = 0
while i < n:
	c = 0
	while i < n and a[i] == 1:
		c += 1
		i += 1
	if c > 0:
		ac[c] += 1
	i += 1
i = 0
while i < m:
	c = 0
	while i < m and b[i] == 1:
		c += 1
		i += 1
	if c > 0:
		bc[c] += 1
	i += 1
r = {}
for i in ac.keys():
	for j in bc.keys():
		r[i, j] = ac[i] * bc[j]
d = divs(k, 1)
res = 0
for (i, j) in r:
	m = r[i, j]
	for q in d:
		x = max(0, i - q + 1)
		y = max(0, j - k // q + 1)
		res += m * x * y
print(res)


(n, m, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
pairs = []
for num1 in range(1, int(k ** (1 / 2)) + 1):
	num2 = k / num1
	if num2.is_integer():
		pairs.append((num1, int(num2)))
contig_a = []
contig_b = []
ongoing = 0
for num in a:
	if num == 1:
		ongoing += 1
	elif num == 0:
		if ongoing > 0:
			contig_a.append(ongoing)
		ongoing = 0
if ongoing > 0:
	contig_a.append(ongoing)
	ongoing = 0
for num in b:
	if num == 1:
		ongoing += 1
	elif num == 0:
		if ongoing > 0:
			contig_b.append(ongoing)
		ongoing = 0
if ongoing > 0:
	contig_b.append(ongoing)
	ongoing = 0
total = 0
for pair in pairs:
	(c, d) = pair
	firsta = [num for num in contig_a if num >= c]
	firstb = [num for num in contig_b if num >= d]
	for x in firsta:
		for y in firstb:
			total += (x - c + 1) * (y - d + 1)
	if c != d:
		firsta = [num for num in contig_a if num >= d]
		firstb = [num for num in contig_b if num >= c]
		for x in firsta:
			for y in firstb:
				total += (x - d + 1) * (y - c + 1)
print(total)


from collections import Counter
(n, m, k) = map(int, input().split())
(*a,) = map(int, input().split())
(*b,) = map(int, input().split())
divisors = []
i = 1
while i * i <= k:
	if k % i == 0:
		j = k // i
		divisors.append((i, j))
		if i != j:
			divisors.append((j, i))
	i += 1

def split(a):
	a_segs = []
	start = 0
	for i in range(len(a)):
		if a[i] == 0:
			if a[start] == 1 and i - start:
				a_segs.append(i - start)
			start = i
		elif a[start] == 0:
			start = i
	if a[start] == 1:
		a_segs.append(len(a) - start)
	return a_segs
a_segs = Counter(split(a))
b_segs = Counter(split(b))
cnt = 0
for (div1, div2) in divisors:
	for (a_seg_size, a_seg_cnt) in a_segs.items():
		if a_seg_size >= div1:
			for (b_seg_size, b_seg_cnt) in b_segs.items():
				if b_seg_size >= div2:
					cnt += a_seg_cnt * b_seg_cnt * (a_seg_size - div1 + 1) * (b_seg_size - div2 + 1)
print(cnt)


def process(a, b, k):
	a_factors = {}
	b_factors = {}
	n = len(a)
	m = len(b)
	for i in range(1, max(n, m) + 1):
		if k % i == 0 and 1 <= i <= n and (1 <= k // i <= m):
			a_factors[i] = 0
		if k % i == 0 and 1 <= i <= m and (1 <= k // i <= n):
			b_factors[i] = 0
	a_list = sorted(a_factors)
	b_list = sorted(b_factors)
	current = 0
	for i in range(n):
		if a[i] == 1:
			current += 1
		else:
			for x in a_list:
				if current >= x:
					a_factors[x] += current - x + 1
				else:
					break
			current = 0
	for x in a_list:
		if current >= x:
			a_factors[x] += current - x + 1
		else:
			break
	current = 0
	for i in range(m):
		if b[i] == 1:
			current += 1
		else:
			for x in b_list:
				if current >= x:
					b_factors[x] += current - x + 1
				else:
					break
			current = 0
	for x in b_list:
		if current >= x:
			b_factors[x] += current - x + 1
		else:
			break
	answer = 0
	for x in a_factors:
		if k // x in b_factors:
			answer += a_factors[x] * b_factors[k // x]
	return answer
(n, m, k) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
print(process(a, b, k))


import bisect
import sys
from collections import Counter
sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2 ** 62 - 1

def read_int():
	return int(input())

def read_int_n():
	return list(map(int, input().split()))

def read_float():
	return float(input())

def read_float_n():
	return list(map(float, input().split()))

def read_str():
	return input().strip()

def read_str_n():
	return list(map(str, input().split()))

def error_print(*args):
	print(*args, file=sys.stderr)

def mt(f):
	import time

	def wrap(*args, **kwargs):
		s = time.time()
		ret = f(*args, **kwargs)
		e = time.time()
		error_print(e - s, 'sec')
		return ret
	return wrap

def divisor(n):
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			yield i
			if i != n // i:
				yield (n // i)

@mt
def slv(N, M, K, A, B):
	ans = 0
	ca = [0]
	for v in A:
		if v == 1:
			ca[-1] += 1
		else:
			ca.append(0)
	cb = [0]
	for v in B:
		if v == 1:
			cb[-1] += 1
		else:
			cb.append(0)
	ca = Counter(ca)
	cb = Counter(cb)
	ans += 0
	for d in divisor(K):
		e = K // d
		for (i, x) in ca.items():
			for (j, y) in cb.items():
				if i < d or j < e:
					continue
				ans += (i - d + 1) * (j - e + 1) * x * y
	return ans

def main():
	(N, M, K) = read_int_n()
	A = read_int_n()
	B = read_int_n()
	print(slv(N, M, K, A, B))
main()


import math

def get_prime_factors(n):
	prime_factors = []
	factor = 2
	lim = math.sqrt(n)
	while n != 1 and factor <= lim:
		count = 0
		while n % factor == 0:
			n //= factor
			count += 1
		if count > 0:
			prime_factors.append((factor, count))
			lim = math.sqrt(n)
		if factor == 2:
			factor += 1
		else:
			factor += 2
	if n != 1:
		prime_factors.append((n, 1))
	return prime_factors

def get_factors(prime_factors):
	factors = [1]
	if len(prime_factors) != 0:
		mult = [0] * len(prime_factors)
		mult[0] = 1
		cont = True
		while cont:
			factor = 1
			for i in range(len(mult)):
				if mult[i] != 0:
					factor *= prime_factors[i][0] ** mult[i]
			factors.append(factor)
			cont = False
			for i in range(len(mult)):
				mult[i] += 1
				if mult[i] > prime_factors[i][1]:
					mult[i] = 0
				else:
					cont = True
					break
	return sorted(factors)
(n, m, k) = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
prime_factors = get_prime_factors(k)
factors = get_factors(prime_factors)

def get_sorted_intervals(a):
	a1 = []
	for i in range(len(a)):
		if a[i] == 1:
			if i == 0 or a[i - 1] == 0:
				a1.append(1)
			else:
				a1[-1] += 1
	a1 = sorted(a1)
	a = []
	for i in range(len(a1)):
		if len(a) != 0 and a[-1][0] == a1[i]:
			a[-1][1] += 1
		else:
			a.append([a1[i], 1])
	return a
a = get_sorted_intervals(a)
b = get_sorted_intervals(b)
cache = {}

def get_count(p):
	if p in cache:
		return cache[p]
	(x, y) = p
	count = 0
	for factor in factors:
		x1 = factor
		y1 = k // factor
		if x1 <= x:
			if y1 <= y:
				count += (x - x1 + 1) * (y - y1 + 1)
		else:
			break
	cache[p] = count
	return count
count = 0
for i in a:
	for j in b:
		count += i[1] * j[1] * get_count((min(i[0], j[0]), max(i[0], j[0])))
print(count)


import sys
input = sys.stdin.readline
import bisect

def divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	divisors.sort()
	return divisors
(n, m, k) = map(int, input().split())
a = [int(item) for item in input().split()] + [0]
b = [int(item) for item in input().split()] + [0]
acnt = []
bcnt = []
c = 0
for item in a:
	if item == 1:
		c += 1
	else:
		acnt.append(c)
		c = 0
c = 0
for item in b:
	if item == 1:
		c += 1
	else:
		bcnt.append(c)
		c = 0
acnt.sort()
bcnt.sort()
ans = 0
div = divisors(k)
for a_val in div:
	b_val = k // a_val
	a_idx = bisect.bisect_left(acnt, a_val)
	b_idx = bisect.bisect_left(bcnt, b_val)
	a_total = sum(acnt[a_idx:]) - (len(acnt) - a_idx) * (a_val - 1)
	b_total = sum(bcnt[b_idx:]) - (len(bcnt) - b_idx) * (b_val - 1)
	ans += a_total * b_total
print(ans)


import sys
import heapq
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt
from collections import defaultdict as dd, deque, Counter as c
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var))

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [[val for i in range(n)] for j in range(m)]

def factor_pair(n):
	fact = set()
	i = 1
	while i <= sqrt(n):
		if n % i == 0:
			fact.add((i, n // i))
			fact.add((n // i, i))
		i += 1
	return fact

def solve(arr, number):
	(ans, cnt) = (0, 0)
	for i in arr:
		if i == 1:
			cnt += 1
			if cnt >= number:
				ans += 1
		else:
			cnt = 0
	return ans
(n, m, k) = sp()
factor = factor_pair(k)
a = l()
b = l()
answer = 0
for i in factor:
	answer += solve(a, i[0]) * solve(b, i[1])
out(answer)


from sys import stdin
from math import sqrt
import bisect

def func(A, B, n, m, h, w):
	count_h = n - bisect.bisect_left(A, h)
	count_w = m - bisect.bisect_left(B, w)
	return count_h * count_w

def main():
	readline = stdin.readline
	(n, m, k) = map(int, readline().split())
	a = list(map(int, readline().split()))
	b = list(map(int, readline().split()))
	A = [0] * n
	B = [0] * m
	now = 0
	for i in range(n):
		if a[i] == 1:
			now += 1
			A[i] = now
		else:
			now = 0
			A[i] = 0
	now = 0
	for i in range(m):
		if b[i] == 1:
			now += 1
			B[i] = now
		else:
			now = 0
			B[i] = 0
	A.sort()
	B.sort()
	count = 0
	for i in range(1, int(sqrt(k)) + 1):
		if k % i == 0:
			h = i
			w = k // i
			count += func(A, B, n, m, h, w)
			if h != w:
				count += func(A, B, n, m, w, h)
	print(count)
main()


def make_divisors(n, k):
	divisors = set()
	for i in range(1, min(n, k) + 1):
		if n % i == 0:
			divisors.add(i)
	return divisors
(N, M, K) = map(int, input().split())
yy = make_divisors(K, max(N, M))
X = list(map(int, input().split()))
c = 0
rs = []
for x in X:
	if x == 1:
		c += 1
	else:
		rs.append(c)
		c = 0
if c > 0:
	rs.append(c)
Y = list(map(int, input().split()))
c = 0
rs2 = []
for x in Y:
	if x == 1:
		c += 1
	else:
		rs2.append(c)
		c = 0
if c > 0:
	rs2.append(c)
from collections import defaultdict
d = defaultdict(int)
for r in rs:
	for y in yy:
		if r >= y:
			d[y] += r - y + 1
R = 0
for r in rs2:
	for y in yy:
		if r >= y:
			R += (r - y + 1) * d[K // y]
print(R)


import sys
input = sys.stdin.readline
(n, m, k) = map(int, input().split())
factors = set()
for i in range(1, int(k ** 0.5) + 3):
	if k % i == 0:
		factors.add(i)
		factors.add(k // i)
x = [*map(int, input().split())]
y = [*map(int, input().split())]
con_x = [0] * n
i = 0
while i < n:
	if x[i]:
		a = 0
		while i + a < n and x[i + a]:
			a += 1
		b = a
		for p in range(i, i + a):
			con_x[p] = b
			b -= 1
		i = i + a
	else:
		i += 1
con_y = [0] * m
i = 0
while i < m:
	if y[i]:
		a = 0
		while i + a < m and y[i + a]:
			a += 1
		b = a
		for p in range(i, i + a):
			con_y[p] = b
			b -= 1
		i = i + a
	else:
		i += 1
ans = 0
for p in factors:
	q = k // p
	if p > n or q > m:
		continue
	c = 0
	for i in range(n - p + 1):
		if con_x[i] >= p:
			c += 1
	if c:
		d = 0
		for j in range(m - q + 1):
			if con_y[j] >= q:
				d += 1
		ans += c * d
print(ans)


import math
(n, m, k) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
l = []
for i in range(2, math.floor(math.sqrt(k)) + 1):
	if k % i == 0:
		l.append((i, k // i))
l.append((1, k))
count = 0
d = {}
r = {}
for i in range(n):
	if a[i] == 1:
		count += 1
	elif count != 0:
		d[count] = d.get(count, 0) + 1
		count = 0
if count != 0:
	d[count] = d.get(count, 0) + 1
	count = 0
for i in range(m):
	if b[i] == 1:
		count += 1
	elif count != 0:
		r[count] = r.get(count, 0) + 1
		count = 0
if count != 0:
	r[count] = r.get(count, 0) + 1
	count = 0
ans = 0
for i in l:
	(ans1, ans2, ans3, ans4) = (0, 0, 0, 0)
	for j in d:
		if i[0] <= j:
			ans1 = ans1 + d[j] * (j - i[0] + 1)
		if i[1] <= j:
			ans2 = ans2 + d[j] * (j - i[1] + 1)
	for j in r:
		if i[0] <= j:
			ans3 = ans3 + r[j] * (j - i[0] + 1)
		if i[1] <= j:
			ans4 = ans4 + r[j] * (j - i[1] + 1)
	if i[0] == i[1]:
		ans += ans1 * ans3
	else:
		ans = ans + ans1 * ans4 + ans2 * ans3
print(ans)


import sys
input = sys.stdin.readline
(n, m, k) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
l = make_divisors(k)
from itertools import accumulate
ca = [0] + A
ca = list(accumulate(ca))
cb = [0] + B
cb = list(accumulate(cb))
ans = 0
for d in l:
	p = d
	q = k // d
	if p > m or q > n:
		continue
	b = 0
	a = 0
	for i in range(m - p + 1):
		if cb[i + p] - cb[i] == p:
			b += 1
	for i in range(n - q + 1):
		if ca[i + q] - ca[i] == q:
			a += 1
	ans += a * b
print(ans)


import math

def stat_matrix(nums):
	length = 0
	arr = []
	for i in range(len(nums)):
		if nums[i] == 0 and length == 0:
			continue
		elif nums[i] == 0:
			arr.append(length)
			length = 0
		else:
			length += 1
	if length != 0:
		arr.append(length)
	return arr

def calc(arr_a, arr_b, k):
	sq = [i for i in range(1, int(math.sqrt(k)) + 1) if k % i == 0]
	cache = {}
	ans = 0
	for i in arr_b:
		w = i
		if w in cache:
			ans += cache[w]
			continue
		cnt = 0
		for j in arr_a:
			h = j
			for z in sq:
				tw = z
				th = k // z
				if tw <= w and th <= h:
					totw = 1 + w - tw
					toth = 1 + h - th
					cnt += totw * toth
				if tw <= h and th <= w and (tw != th):
					revw = 1 + w - th
					revh = 1 + h - tw
					cnt += revw * revh
		ans += cnt
		cache[w] = cnt
	return ans
[n, m, k] = [int(n) for n in input().split(' ')]
a = [int(n) for n in input().split(' ')]
b = [int(n) for n in input().split(' ')]
arr_a = stat_matrix(a)
arr_b = stat_matrix(b)
ans = calc(arr_a, arr_b, k)
print(ans)


from math import ceil
(n, m, k) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
(d, ans, last) = ([], 0, -1)
for i in range(1, ceil(k ** (1 / 2)) + 1):
	if k % i == 0:
		if i == k // last:
			break
		d.append(i)
		last = i
count = 0
(a, b) = ([0] * 40001, [0] * 40001)
for i in range(n):
	if x[i] == 1:
		count += 1
	if count > 0 and (x[i] == 0 or i == n - 1):
		p = 1
		for i2 in range(count, 0, -1):
			a[i2] += p
			p += 1
		count = 0
for i in range(m):
	if y[i] == 1:
		count += 1
	if count > 0 and (y[i] == 0 or i == m - 1):
		p = 1
		for i2 in range(count, 0, -1):
			b[i2] += p
			p += 1
		count = 0
for i in d:
	if i <= 40000 and k // i <= 40000:
		ans += a[i] * b[k // i] + b[i] * a[k // i] * (i != k // i)
print(ans)


import math

def ff(a, r):
	fa = fb = [-1] * 40002
	la = lb = []
	l = 0
	i = 0
	for i in range(r):
		if a[i] == 1:
			l = l + 1
		elif l > 0:
			if fa[l] == -1:
				fa[l] = len(la)
				la.append([l, 1])
			else:
				la[fa[l]][1] += 1
			l = 0
	if l > 0:
		if fa[l] == -1:
			fa[l] = len(la)
			la.append([l, 1])
		else:
			la[fa[l]][1] += 1
			l = 0
	return la
(r, c, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
la = ff(a, r)
lb = ff(b, c)
d = []
lim = int(math.sqrt(k))
for i in range(lim):
	if k % (i + 1) == 0:
		d.append([i + 1, int(k / (i + 1))])
ans = 0
for i in d:
	for j in la:
		for k in lb:
			if i[0] <= j[0] and i[1] <= k[0]:
				tmp = (-i[0] + j[0] + 1) * (-i[1] + k[0] + 1)
				ans = ans + tmp * j[1] * k[1]
			if i[0] != i[1]:
				if i[0] <= k[0] and i[1] <= j[0]:
					t = (-i[0] + k[0] + 1) * (-i[1] + j[0] + 1)
					ans = ans + t * j[1] * k[1]
print(ans)


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 998244353
EPS = 1e-06

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]

def divisors(n):
	div = set()
	for i in range(1, int(sqrt(n)) + 1):
		if n % i == 0:
			div.add(i)
			div.add(n // i)
	return div

def count(a, c):
	ans = 0
	for i in range(len(a) - c):
		ans += a[i + c] - a[i] == c
	return ans
(n, m, k) = value()
a = array()
b = array()
pref_a = [0]
pref_b = [0]
for i in range(n):
	pref_a.append(pref_a[-1] + a[i])
for i in range(m):
	pref_b.append(pref_b[-1] + b[i])
ans = 0
div = divisors(k)
for r in div:
	c = k // r
	ans += count(pref_a, r) * count(pref_b, c)
print(ans)


import sys
from collections import defaultdict
(n, m, k) = map(int, sys.stdin.readline().split())
a = list(map(int, sys.stdin.readline().split()))
b = list(map(int, sys.stdin.readline().split()))
consa = defaultdict(int)
consb = defaultdict(int)
count = 0
arra = set()
arrb = set()
for i in range(n):
	if a[i] == 1:
		count += 1
		arra.add(count)
		consa[count] += 1
	else:
		count = 0
count = 0
for i in range(m):
	if b[i] == 1:
		count += 1
		arrb.add(count)
		consb[count] += 1
	else:
		count = 0
arra = list(arra)
arrb = list(arrb)
arra.sort()
arrb.sort()
arra.reverse()
arrb.reverse()
prev = 0
for i in arra:
	consa[i] += prev
	prev = consa[i]
prev = 0
for i in arrb:
	consb[i] += prev
	prev = consb[i]
ans = 0
vis = defaultdict(int)
for i in range(1, n + 1):
	if k % i == 0:
		ans += consa[i] * consb[k // i]
		vis[k // i] += 1
for i in range(1, m + 1):
	if k % i == 0 and vis[i] == 0:
		ans += consb[i] * consa[k // i]
print(ans)


import sys
input = sys.stdin.readline
from functools import reduce
import math
(n, m, k) = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
max_hor = [0] * 40005
max_vert = [0] * 40005

def factors(n):
	return set(reduce(list.__add__, ([i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
l1 = list(factors(k))

def subrect_finder(l, l2, nm):
	if l[0] == 1:
		count = 1
		l2[count] += 1
	else:
		count = 0
	for i in range(1, nm):
		if l[i - 1] == l[i] and l[i] == 1:
			count += 1
			l2[count] += 1
		elif l[i] == 1:
			count += 1
			l2[count] += 1
		else:
			count = 0
	return l2
hor = subrect_finder(a, max_hor, n)
vert = subrect_finder(b, max_vert, m)
ans = 0
for j in l1:
	jk = int(k / j)
	(j, jk) = (min(40001, j), min(40001, jk))
	if vert[j] != 0:
		ans += sum(vert[j:]) * sum(hor[jk:])
	if hor[j] != 0 and j != jk:
		ans += sum(hor[j:]) * sum(vert[jk:])
print(ans)


t = input().split(' ')
a = input().split(' ')
b = input().split(' ')
c = []
m = []
for j in range(1, int(int(t[2]) ** (1 / 2)) + 1):
	if int(t[2]) % j == 0:
		m.append(j)
		if j != int(int(t[2]) / j):
			m.append(int(int(t[2]) / j))
for i in range(0, len(a)):
	a[i] = int(a[i])
for i in range(0, len(b)):
	b[i] = int(b[i])
a0 = []
b0 = []
for p in range(0, len(a)):
	if a[p] == 0:
		a0.append(p)
for s in range(0, len(b)):
	if b[s] == 0:
		b0.append(s)
filas = []
columnas = []
if len(b0) != 0:
	columnas = [b0[0], len(b) - b0[len(b0) - 1] - 1]
else:
	columnas = [len(b)]
if len(a0) != 0:
	filas = [a0[0], len(a) - a0[len(a0) - 1] - 1]
else:
	filas = [len(a)]
for i in range(1, len(b0)):
	columnas.append(b0[i] - b0[i - 1] - 1)
for i in range(1, len(a0)):
	filas.append(a0[i] - a0[i - 1] - 1)
tot = 0
filas.sort()
columnas.sort()
filasn = []
val = []
colm = []
valc = []
for i in filas:
	if i not in filasn:
		filasn.append(i)
		val.append(0)
for i in columnas:
	if i not in colm:
		colm.append(i)
		valc.append(0)
v = len(filasn) - 1
while filasn[v] * colm[len(colm) - 1] >= int(t[2]) and v > 0:
	v -= 1
z = len(colm) - 1
while colm[z] * filasn[len(filasn) - 1] >= int(t[2]) and z > 0:
	z -= 1
for i in range(0, len(filasn)):
	for j in range(0, len(filas)):
		if filasn[i] == filas[j]:
			val[i] += 1
for i in range(0, len(colm)):
	for j in range(0, len(columnas)):
		if colm[i] == columnas[j]:
			valc[i] += 1
for i in range(0, len(m)):
	for j in range(v, len(filasn)):
		for k in range(z, len(colm)):
			if m[i] <= filasn[j] and int(int(t[2]) / m[i]) <= colm[k]:
				tot += (filasn[j] - m[i] + 1) * (colm[k] - int(t[2]) / m[i] + 1) * val[j] * valc[k]
print(int(tot))


from collections import defaultdict
from math import factorial
from sys import stdin

def read_tuple():
	return map(int, input().split())

def read_int():
	return int(input())

def read_list():
	return list(map(int, input().split()))

def factors(n):
	fact = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			if n // i == i:
				fact.append(i)
			else:
				fact.append(i)
				fact.append(n // i)
	fact.sort()
	return fact

def comb(n, r):
	return factorial(n) // (factorial(n - r) * factorial(r))
(n, m, k) = read_tuple()
a = read_list()
b = read_list()
(cnta, cntb) = (defaultdict(int), defaultdict(int))
cnta[0] = 0
cntb[0] = 0
cnt = 0
for i in range(n):
	if a[i] == 1:
		cnt += 1
	else:
		cnta[cnt] += 1
		cnt = 0
cnta[cnt] += 1
cnt = 0
for i in range(m):
	if b[i] == 1:
		cnt += 1
	else:
		cntb[cnt] += 1
		cnt = 0
cntb[cnt] += 1
factor = factors(k)
ans = 0
for (p1, cnt1) in cnta.items():
	for (p2, cnt2) in cntb.items():
		if p1 * p2 < k:
			continue
		for f in factor:
			(f1, f2) = (f, k // f)
			if p1 >= f1 and p2 >= f2:
				ans += cnt1 * cnt2 * (p1 - f1 + 1) * (p2 - f2 + 1)
print(ans)


import math
(n, m, k) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
delitele = []
for i in range(int(math.sqrt(k))):
	if k % (i + 1) == 0:
		delitele.append([i + 1, k // (i + 1)])
acka = []
doteraz = 0
suvisle = True
for i in range(n):
	if a[i] == 1 and suvisle:
		doteraz += 1
	if a[i] == 0 and suvisle:
		acka.append(doteraz)
		suvisle = False
	if a[i] == 1 and (not suvisle):
		doteraz = 1
		suvisle = True
	if a[i] == 1 and i == n - 1:
		acka.append(doteraz)
bcka = []
doteraz = 0
suvisle = True
for i in range(m):
	if b[i] == 1 and suvisle:
		doteraz += 1
	if b[i] == 0 and suvisle:
		bcka.append(doteraz)
		suvisle = False
	if b[i] == 1 and (not suvisle):
		doteraz = 1
		suvisle = True
	if b[i] == 1 and i == m - 1:
		bcka.append(doteraz)
moznosti = 0
for i in range(len(delitele)):
	prvy = delitele[i][0]
	druhy = delitele[i][1]
	moznostiA = 0
	moznostiB = 0
	for j in range(len(acka)):
		if acka[j] >= prvy:
			moznostiA += acka[j] - prvy + 1
	for j in range(len(bcka)):
		if bcka[j] >= druhy:
			moznostiB += bcka[j] - druhy + 1
	moznosti = moznosti + moznostiA * moznostiB
	if prvy != druhy:
		moznostiA = 0
		moznostiB = 0
		for j in range(len(acka)):
			if acka[j] >= druhy:
				moznostiA += acka[j] - druhy + 1
		for j in range(len(bcka)):
			if bcka[j] >= prvy:
				moznostiB += bcka[j] - prvy + 1
		moznosti = moznosti + moznostiA * moznostiB
print(moznosti)


def getContiguous(arr):
	n = len(arr)
	cnt = 0
	res = []
	for i in range(n):
		if arr[i] == 1:
			cnt += 1
		else:
			if cnt > 0:
				res.append(cnt)
			cnt = 0
	if cnt > 0:
		res.append(cnt)
	return res
(n, m, k) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
aOnes = getContiguous(a)
bOnes = getContiguous(b)
validRectangleDimensions = []
for i in range(1, int(k ** 0.5) + 1):
	if k % i == 0:
		validRectangleDimensions.append([i, k // i])
		if i != k // i:
			validRectangleDimensions.append([k // i, i])
ans = 0
for (dimx, dimy) in validRectangleDimensions:
	nA = 0
	nB = 0
	for A in aOnes:
		if A >= dimx:
			nA += A - dimx + 1
	for B in bOnes:
		if B >= dimy:
			nB += B - dimy + 1
	ans += nA * nB
print(ans)


(N, M, K) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
pA = [0] * (N + 1)
for i in range(N):
	pA[i + 1] = pA[i] + A[i]
pB = [0] * (M + 1)
for i in range(M):
	pB[i + 1] = pB[i] + B[i]
ans = 0
for p in range(1, int(K ** 0.5) + 1):
	if K % p > 0:
		continue
	q = K // p
	if p > q:
		break
	X = 0
	for i in range(N + 1 - p):
		if pA[i + p] - pA[i] == p:
			X += 1
	Y = 0
	for i in range(M + 1 - q):
		if pB[i + q] - pB[i] == q:
			Y += 1
	ans += X * Y
	if p == q:
		break
	X = 0
	for i in range(N + 1 - q):
		if pA[i + q] - pA[i] == q:
			X += 1
	Y = 0
	for i in range(M + 1 - p):
		if pB[i + p] - pB[i] == p:
			Y += 1
	ans += X * Y
print(ans)