#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <fstream>
#include <queue>
#include <iostream>
#include <algorithm>
#include <stack>
#include <vector>
#include <set>
#include <math.h>
#include <cmath>
#include <map>
#include <ctime>
#pragma comment(linker, "/STACK:10000000000")

#define ll long long
#define rt return
#define all(a) a.begin(), a.end()
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

const int MAX_SIZE = 1000, INF = 2 * 1e9;
const long long SuperINF = 1e12, MOD = 1e9;
const double eps = 0.5, PI = 20 / 7;

void files() {
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
}

void solve() {
	ll n, m, k;
	cin >> n >> m >> k;
	vector<ll> arr_a, arr_b;

	for (ll i = 0; i < n; i++) {
		ll g;
		cin >> g;
		arr_a.push_back(g);
	}

	for (ll i = 0; i < m; i++) {
		ll c;
		cin >> c;
		arr_b.push_back(c);
	}

	vector<ll> dels;

	for (ll i = 1; i <= sqrt(k); i++) {
		if (k % i == 0) {
			ll a = i;
			ll b = k / i;
			dels.push_back(a);

			if (b != a)
				dels.push_back(b);
		}

	}

	map<ll, ll> cnts1, cnts2;

	bool flag1 = false;
	ll cnt1 = 0;
	for (ll i = 0; i < n; i++) {
		if (!flag1) {
			if (arr_a[i] == 1) {
				cnt1=1;
				flag1 = 1;
			}
			else {
				flag1 = 0;
				cnt1 = 0;
			}
		}
		else {
			if (arr_a[i] == 1)
				cnt1++;
			else {

				for(int j = 0;j < dels.size(); j++){
					ll xx = dels[j];
					cnts1[xx] += max(0LL, cnt1 - xx + 1);

				}
				cnt1 = 0;
				flag1 = false;
			}

		}

	}

	for (ll j = 0; j < dels.size(); j++) {
		ll xx = dels[j];
		cnts1[xx] += max(0LL, cnt1 - xx + 1);
	}

	cnt1 = 0;
	flag1 = false;

	for (ll i = 0; i < m; i++) {
		if (!flag1) {
			if (arr_b[i] == 1) {
				cnt1 = 1;
				flag1 = 1;
			}
			else {
				flag1 = 0;
				cnt1 = 0;
			}
		}
		else {
			if (arr_b[i] == 1)
				cnt1++;
			else {

				for (int j = 0; j < dels.size(); j++) {
					ll xx = dels[j];
					cnts2[xx] += max(0LL, cnt1 - xx + 1);

				}
				cnt1 = 0;
				flag1 = false;
			}

		}

	}

	for (int j = 0; j < dels.size(); j++) {
		ll xx = dels[j];
		cnts2[xx] += max(0LL, cnt1 - xx + 1);
	}

	cnt1 = 0;
	flag1 = false;

	ll ans = 0;
	for (int i = 1; i <= sqrt(k); i++) {
		if (k % i == 0) {
			ll a = i;
			ll b = k / i;
			ans += cnts1[a] * cnts2[b];

			if (a != b) {
				ans += cnts1[b] * cnts2[a];
			}

		}

	}
	cout << ans;
}

int main() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//files();

	int t = 1;
	// >> t;
	while (t--)
		solve();

	rt 0;
}


#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define sp system("pause");
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tcase ll tt; cin>>tt; while (tt--)
#define ll long long
#define in(x); { for (auto &i : x) cin >> i; }
using namespace std;
void main() {
	fastio
		ll m, n, k, a;
	vector<ll>vm(4000, 0), vn(4000, 0), v;
	cin >> m >> n >> k;
	ll sw = 0, sww1 = 0, sw1 = 0, sww2 = 0, sw2 = 0, sum = 0;
	for (long long int i = 1; i <= sqrt(k); i++) {
		if (k % i == 0) {
			v.push_back(i);
			v.push_back(k / i);
			if (i != k / i) {
				v.push_back(k / i);
				v.push_back(i);
			}
		}
	}
	sw = 0;
	for (int i = 0; i < m; i++) {
		cin >> a;
		if (a == 1)
			sw++;
		else {
			for (int j = sw; j > 0; j--) {
				vm[j] += (sw + 1) - j;
			}
			sw = 0;
		}
		if (i == m - 1) {
			for (int j = sw; j > 0; j--) {
				vm[j] += (sw + 1) - j;
			}
			sw = 0;
		}
	}
	sw = 0;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a == 1)
			sw++;
		else {
			for (int j = sw; j > 0; j--) {
				vn[j] += (sw + 1) - j;
			}
			sw = 0;
		}
		if (i == n - 1) {
			for (int j = sw; j > 0; j--) {
				vn[j] += (sw + 1) - j;
			}
			sw = 0;
		}
	}
	for (int i = 0; i < v.size(); i += 2) {
		ll u = vm[v[i]];
		ll uu = vn[v[i + 1]];
		unsigned long long int dd = u * uu;
		sum += dd;
	}
		cout << sum;
}


#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define sp system("pause");
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tcase ll tt; cin>>tt; while (tt--)
#define ll long long
#define in(x); { for (auto &i : x) cin >> i; }
using namespace std;
void main() {
	fastio
		ll m, n, k, a;
	vector<ll>vm(400000, 0), vn(400000, 0), v;
	cin >> m >> n >> k;
	ll sw = 0, sum = 0;
	sw = 0;
	for (int i = 1; i <= m; i++) {
		cin >> a;
		if (a == 1)
			sw++;
		else {
			for (int j = sw; j > 0; j--) {
				vm[j] += (sw + 1) - j;
			}
			sw = 0;
		}
	}
	for (int j = sw; j > 0; j--) {
		vm[j] += (sw + 1) - j;
	}
	sw = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a;
		if (a == 1)
			sw++;
		else {
			for (int j = sw; j > 0; j--) {
				vn[j] += (sw + 1) - j;
			}
			sw = 0;
		}
	}
	for (int j = sw; j > 0; j--) {
		vn[j] += (sw + 1) - j;
	}

	for (long long int i = 1; i <= sqrt(k); i++) {
		if (k % i == 0) {
			sum += vm[i] * vn[k / i];
			if (i != k / i) {
				sum += vm[k / i] * vn[i];
			}
		}
	}
	cout << sum;
}


#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define sp system("pause");
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tcase ll tt; cin>>tt; while (tt--)
#define ll long long
#define in(x); { for (auto &i : x) cin >> i; }
using namespace std;
void main() {
	fastio
	ll m, n, k, a;
	vector<ll>vm(4000,0), vn(4000,0), v;
	cin >> m >> n >> k;
	ll sw = 0, sww1 = 0, sw1 = 0, sww2 = 0, sw2 = 0, sum = 0;
	for (ll i = 1; i <= sqrt(k); i++) {
		if (k % i == 0) {
			v.push_back(i);
			v.push_back(k / i);
			if (i != k / i) {
				v.push_back(k / i);
				v.push_back(i);
			}
		}
	}
	sw = 0;
	for (int i = 0; i < m; i++) {
		cin >> a;
		if (a == 1)
			sw++;
		else {
			for (int j = sw; j > 0; j--) {
				vm[j] += (sw + 1) - j;
			}
			sw = 0;
		}
		if(i==m-1) {
			for (int j = sw; j > 0; j--) {
				vm[j] += (sw + 1) - j;
			}
			sw = 0;
		}
	}
	sw = 0;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a == 1)
			sw++;
		else {
			for (int j = sw; j > 0; j--) {
				vn[j] += (sw + 1) - j;
			}
			sw = 0;
		}
		if (i == n - 1) {
			for (int j = sw; j > 0; j--) {
				vn[j] += (sw + 1) - j;
			}
			sw = 0;
		}
	}
	for (int i = 0; i < v.size(); i+=2) sum += vm[v[i]] * vn[v[i + 1]];cout << sum;

}


#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define sp system("pause");
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tcase ll tt; cin>>tt; while (tt--)
#define ll long long
#define in(x); { for (auto &i : x) cin >> i; }
using namespace std;
void main() {
  fastio
    ll m, n, k, a;
  vector<ll>vm(400000, 0), vn(400000, 0), v;
  cin >> m >> n >> k;
  ll sw = 0, sum = 0;
  sw = 0;
  for (int i = 1; i <= m; i++) {
    cin >> a;
    if (a == 1)
      sw++;
    else {
      for (int j = sw; j > 0; j--) {
        vm[j] += (sw + 1) - j;
      }
      sw = 0;
    }
    }
      for (int j = sw; j > 0; j--) {
        vm[j] += (sw + 1) - j;
      }
  sw = 0;
  for (int i = 1; i < =n; i++) {
    cin >> a;
    if (a == 1)
      sw++;
    else {
      for (int j = sw; j > 0; j--) {
        vn[j] += (sw + 1) - j;
      }
      sw = 0;
    }}
      for (int j = sw; j > 0; j--) {
        vn[j] += (sw + 1) - j;
      }

  for (long long int i = 1; i <= sqrt(k); i++) {
    if (k % i == 0) {
      sum += vm[i] * vn[k/i];
      if (i != k / i) {
        sum += vm[k/i] * vn[i];
      }
    }
  }
  cout << sum;
}


#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define sp system("pause");
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tcase ll tt; cin>>tt; while (tt--)
#define ll long long
#define in(x); { for (auto &i : x) cin >> i; }
using namespace std;
void main() {
  fastio
    ll m, n, k, a;
  vector<ll>vm(40001, 0), vn(40001, 0), v;
  cin >> m >> n >> k;
  ll sw = 0, sum = 0;
  sw = 0;
  for (int i = 1; i <= m; i++) {
    cin >> a;
    if (a == 1)
      sw++;
    else {
      for (int j = sw; j > 0; j--) {
        vm[j] += (sw + 1) - j;
      }
      sw = 0;
    }
  }
  for (int j = sw; j > 0; j--) {
    vm[j] += (sw + 1) - j;
  }
  sw = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a;
    if (a == 1)
      sw++;
    else {
      for (int j = sw; j > 0; j--) {
        vn[j] += (sw + 1) - j;
      }
      sw = 0;
    }
  }
  for (int j = sw; j > 0; j--) {
    vn[j] += (sw + 1) - j;
  }

  for (long long int i = 1; i <= sqrt(k); i++) {
    if (k % i == 0) {
      if(i<=m&&k/i<=n)sum += vm[i] * vn[k / i];
      if (i != k / i&&i<=n&&k/i<=m) {
        sum += vm[k / i] * vn[i];
      }
    }
  }
  cout << sum;
}


#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define sp system("pause");
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tcase ll tt; cin>>tt; while (tt--)
#define ll long long
#define in(x); { for (auto &i : x) cin >> i; }
using namespace std;
void main() {
	fastio
		long long int m, n, k, a;
	vector<int>vm(4000,0), vn(4000,0), v;
	cin >> m >> n >> k;
	long long int sw = 0, sww1 = 0, sw1 = 0, sww2 = 0, sw2 = 0, sum = 0;
	for (int i = 1; i <= sqrt(k); i++) {
		if (k % i == 0) {
			v.push_back(i);
			v.push_back(k / i);
			if (i != k / i) {
				v.push_back(k / i);
				v.push_back(i);
			}
		}
	}
	sw = 0;
	for (int i = 0; i < m; i++) {
		cin >> a;
		if (a == 1)
			sw++;
		else {
			for (int j = sw; j > 0; j--) {
				vm[j] += (sw + 1) - j;
			}
			sw = 0;
		}
		if(i==m-1) {
			for (int j = sw; j > 0; j--) {
				vm[j] += (sw + 1) - j;
			}
			sw = 0;
		}
	}
	sw = 0;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a == 1)
			sw++;
		else {
			for (int j = sw; j > 0; j--) {
				vn[j] += (sw + 1) - j;
			}
			sw = 0;
		}
		if (i == n - 1) {
			for (int j = sw; j > 0; j--) {
				vn[j] += (sw + 1) - j;
			}
			sw = 0;
		}
	}
	for (int i = 0; i < v.size(); i+=2) sum += vm[v[i]] * vn[v[i + 1]];cout << sum;

}


#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define sp system("pause");
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tcase ll tt; cin>>tt; while (tt--)
#define ll long long
#define in(x); { for (auto &i : x) cin >> i; }
using namespace std;
void main() {
	fastio
		int m, n, k, a;
	vector<int>vm, vn, v;
	cin >> m >> n >> k;
	int sw = 0, sww1 = 0, sw1 = 0, sww2 = 0, sw2 = 0, sum = 0;
	for (int i = 0; i < m; i++) {
		cin >> a;
		vm.push_back(a);
	}
	for (int i = 0; i < n; i++) {
		cin >> a;
		vn.push_back(a);
	}
	for (int i = 1; i <= sqrt(k); i++) {
		if (k % i == 0) {
			v.push_back(i);
			v.push_back(k / i);
			v.push_back(k / i);
			v.push_back(i);
		}
	}
	for (int k = 0; k < v.size(); k += 2) {
		sw1 = 0, sw2 = 0, sww1 = 0, sww2 = 0;
		for (int i = 0; i < m; i++) {
			if (vm[i] == 0) {
				sw1 = 0;
			}
			else sw1++;
			if (sw1 == v[k]) {
				sww1++;
				i -= v[k] - 1;
				sw1 = 0;
			}
		}
		for (int i = 0; i < n; i++) {
			if (vn[i] == 0) {
				sw2 = 0;
			}
			else sw2++;
			if (sw2 == v[k + 1]) {
				sww2++;
				i -= v[k + 1] - 1;
				sw2 = 0;
			}
		}
		sum += (sww2 * sww1) ;
	}
	cout << sum;

}


#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define sp system("pause");
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tcase ll tt; cin>>tt; while (tt--)
#define ll long long
#define in(x); { for (auto &i : x) cin >> i; }
using namespace std;
void main() {
	fastio
		int m, n, k, a;
	vector<int>vm, vn, v;
	cin >> m >> n >> k;
	long long int sw = 0, sww1 = 0, sw1 = 0, sww2 = 0, sw2 = 0, sum = 0;
	for (int i = 1; i <= sqrt(k); i++) {
		if (k % i == 0) {
			v.push_back(i);
			v.push_back(k / i);
			if (i != k / i) {
				v.push_back(k / i);
				v.push_back(i);
			}
		}
	}
	for (int i = 0; i < m; i++) {
		cin >> a;
		vm.push_back(a);
	}
	for (int i = 0; i < n; i++) {
		cin >> a;
		vn.push_back(a);
	}
	for (int k = 0; k < v.size(); k += 2) {
		sw1 = 0, sw2 = 0, sww1 = 0, sww2 = 0;
		for (int i = 0; i < m; i++) {
			if (vm[i] == 0) {
				sw1 = 0;
			}
			else sw1++;
			if (sw1 == v[k]) {
				sww1++;
				i -= v[k] - 1;
				sw1 = 0;
			}
		}
		for (int i = 0; i < n; i++) {
			if (vn[i] == 0) {
				sw2 = 0;
			}
			else sw2++;
			if (sw2 == v[k + 1]) {
				sww2++;
				i -= v[k + 1] - 1;
				sw2 = 0;
			}
		}
		sum += (sww2 * sww1) ;
	}
	cout << sum;

}


#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define sp system("pause");
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tcase ll tt; cin>>tt; while (tt--)
#define ll long long
#define in(x); { for (auto &i : x) cin >> i; }
using namespace std;
void main() {
	fastio
		ll m, n, k, a;
	vector<ll>vm(400000, 0), vn(400000, 0), v;
	cin >> m >> n >> k;
	ll sw = 0, sum = 0;
	for (long long int i = 1; i <= sqrt(k); i++) {
		if (k % i == 0) {
			v.push_back(i);
			v.push_back(k / i);
			if (i != k / i) {
				v.push_back(k / i);
				v.push_back(i);
			}
		}
	}
	sw = 0;
	for (int i = 0; i < m; i++) {
		cin >> a;
		if (a == 1)
			sw++;
		else {
			for (int j = sw; j > 0; j--) {
				vm[j] += (sw + 1) - j;
			}
			sw = 0;
		}
		if (i == m - 1) {
			for (int j = sw; j > 0; j--) {
				vm[j] += (sw + 1) - j;
			}
			sw = 0;
		}
	}
	sw = 0;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a == 1)
			sw++;
		else {
			for (int j = sw; j > 0; j--) {
				vn[j] += (sw + 1) - j;
			}
			sw = 0;
		}
		if (i == n - 1) {
			for (int j = sw; j > 0; j--) {
				vn[j] += (sw + 1) - j;
			}
			sw = 0;
		}
	}
	for (int i = 0; i < v.size(); i += 2) {
		ll u = vm[v[i]];
		ll uu = vn[v[i + 1]];
		unsigned long long int dd = u * uu;
		sum += dd;
	}
		cout << sum;
}


#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define sp system("pause");
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tcase ll tt; cin>>tt; while (tt--)
#define ll long long
#define in(x); { for (auto &i : x) cin >> i; }
using namespace std;
void main() {
	fastio
		ll m, n, k, a;
	vector<ll>vm(40001, 0), vn(40001, 0), v;
	cin >> m >> n >> k;
	ll sw = 0, sww1 = 0, sw1 = 0, sww2 = 0, sw2 = 0, sum = 0;
	for (long long int i = 1; i <= sqrt(k); i++) {
		if (k % i == 0) {
			v.push_back(i);
			v.push_back(k / i);
			if (i != k / i) {
				v.push_back(k / i);
				v.push_back(i);
			}
		}
	}
	sw = 0;
	for (int i = 0; i < m; i++) {
		cin >> a;
		if (a == 1)
			sw++;
		else {
			for (int j = sw; j > 0; j--) {
				vm[j] += (sw + 1) - j;
			}
			sw = 0;
		}
		if (i == m - 1) {
			for (int j = sw; j > 0; j--) {
				vm[j] += (sw + 1) - j;
			}
			sw = 0;
		}
	}
	sw = 0;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a == 1)
			sw++;
		else {
			for (int j = sw; j > 0; j--) {
				vn[j] += (sw + 1) - j;
			}
			sw = 0;
		}
		if (i == n - 1) {
			for (int j = sw; j > 0; j--) {
				vn[j] += (sw + 1) - j;
			}
			sw = 0;
		}
	}
	for (int i = 0; i < v.size(); i += 2) {
		ll u = vm[v[i]];
		ll uu = vn[v[i + 1]];
		unsigned long long int dd = u * uu;
		sum += dd;
	}
		cout << sum;
}


#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define sp system("pause");
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tcase ll tt; cin>>tt; while (tt--)
#define ll long long
#define in(x); { for (auto &i : x) cin >> i; }
using namespace std;
void main() {
	fastio
		ll m, n, k, a;
	vector<ll>vm(4000, 0), vn(4000, 0), v;
	cin >> m >> n >> k;
	ll sw = 0, sww1 = 0, sw1 = 0, sww2 = 0, sw2 = 0, sum = 0;
	for (long long int i = 1; i <= sqrt(k); i++) {
		if (k % i == 0) {
			v.push_back(i);
			v.push_back(k / i);
			if (i != k / i) {
				v.push_back(k / i);
				v.push_back(i);
			}
		}
	}
	sw = 0;
	for (int i = 0; i < m; i++) {
		cin >> a;
		if (a == 1)
			sw++;
		else {
			for (int j = sw; j > 0; j--) {
				vm[j] += (sw + 1) - j;
			}
			sw = 0;
		}
		if (i == m - 1) {
			for (int j = sw; j > 0; j--) {
				vm[j] += (sw + 1) - j;
			}
			sw = 0;
		}
	}
	sw = 0;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a == 1)
			sw++;
		else {
			for (int j = sw; j > 0; j--) {
				vn[j] += (sw + 1) - j;
			}
			sw = 0;
		}
		if (i == n - 1) {
			for (int j = sw; j > 0; j--) {
				vn[j] += (sw + 1) - j;
			}
			sw = 0;
		}
	}
	for (int i = 0; i < v.size(); i += 2) sum += vm[v[i]] * vn[v[i + 1]]; cout << sum;
}


#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define sp system("pause");
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tcase ll tt; cin>>tt; while (tt--)
#define ll long long
#define in(x); { for (auto &i : x) cin >> i; }
using namespace std;
void main() {
	fastio
		ll m, n, k, a;
	vector<ll>vm(400000, 0), vn(400000, 0), v;
	cin >> m >> n >> k;
	ll sw = 0, sum = 0;
	sw = 0;
	for (int i = 0; i < m; i++) {
		cin >> a;
		if (a == 1)
			sw++;
		else {
			for (int j = sw; j > 0; j--) {
				vm[j] += (sw + 1) - j;
			}
			sw = 0;
		}
		if (i == m - 1) {
			for (int j = sw; j > 0; j--) {
				vm[j] += (sw + 1) - j;
			}
			sw = 0;
		}
	}
	sw = 0;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a == 1)
			sw++;
		else {
			for (int j = sw; j > 0; j--) {
				vn[j] += (sw + 1) - j;
			}
			sw = 0;
		}
		if (i == n - 1) {
			for (int j = sw; j > 0; j--) {
				vn[j] += (sw + 1) - j;
			}
			sw = 0;
		}
	}
	for (long long int i = 1; i <= sqrt(k); i++) {
		if (k % i == 0) {
			sum += vm[i] * vn[k/i];
			if (i != k / i) {
				sum += vm[k/i] * vn[i];
			}
		}
	}
	cout << sum;
}


#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define sp system("pause");
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tcase ll tt; cin>>tt; while (tt--)
#define ll long long
#define in(x); { for (auto &i : x) cin >> i; }
using namespace std;
void main() {
	fastio
		ll m, n, k, a;
	vector<ll>vm(40001, 0), vn(40001, 0), v;
	cin >> m >> n >> k;
	ll sw = 0, sum = 0;
	sw = 0;
	for (int i = 0; i < m; i++) {
		cin >> a;
		if (a == 1)
			sw++;
		else {
			for (int j = sw; j > 0; j--) {
				vm[j] += (sw + 1) - j;
			}
			sw = 0;
		}
		if (i == m - 1) {
			for (int j = sw; j > 0; j--) {
				vm[j] += (sw + 1) - j;
			}
			sw = 0;
		}
	}
	sw = 0;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a == 1)
			sw++;
		else {
			for (int j = sw; j > 0; j--) {
				vn[j] += (sw + 1) - j;
			}
			sw = 0;
		}
		if (i == n - 1) {
			for (int j = sw; j > 0; j--) {
				vn[j] += (sw + 1) - j;
			}
			sw = 0;
		}
	}
	for (long long int i = 1; i <= sqrt(k); i++) {
		if (k % i == 0) {
			sum += vm[i] * vn[i + 1];
			if (i != k / i) {
				sum += vm[i + 1] * vn[i];
			}
		}
	}
	cout << sum;
}


#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define sp system("pause");
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tcase ll tt; cin>>tt; while (tt--)
#define ll long long
#define in(x); { for (auto &i : x) cin >> i; }
using namespace std;
void main() {
	fastio
		int m, n, k,a;
	vector<int>vm, vn,v;
	cin >> m >> n >> k;
	int sw = 0,sww1=0,sw1=0, sww2 = 0, sw2 = 0,sum=0;
	for (int i = 0; i < m; i++) {
		cin >> a;
		vm.push_back(a);
	}
	for (int i = 0; i < n; i++) {
		cin >> a;
		vn.push_back(a);
	}
	for (int i = 1; i <= sqrt(k); i++) {
		if (k%i==0) {
			v.push_back(i);
			v.push_back(k / i);
		}
	}
	for (int k = 0; k <= (v.size() / 2); k += 2) {
		sw1 = 0, sw2 = 0, sww1 = 0, sww2 = 0;
		for (int i = 0; i < m; i++) {
			if (vm[i] == 0) {
				sw1 = 0;
			}
			else sw1++;
			if (sw1 == v[k]) {
				sww1++;
				i -= v[k] - 1;
				sw1 = 0;
			}
		}
		for (int i = 0; i < n; i++) {
			if (vn[i] == 0) {
				sw2 = 0;
			}
			else sw2++;
			if (sw2 == v[k + 1]) {
				sww2++;
				i -= v[k + 1] - 1;
				sw2 = 0;
			}
		}
		sum += sww2 * sww1;
	}
	cout << sum;
}


#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define sp system("pause");
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tcase ll tt; cin>>tt; while (tt--)
#define ll long long
#define in(x); { for (auto &i : x) cin >> i; }
using namespace std;
void main() {
	fastio
		ll m, n, k, a;
	vector<ll>vm(40000000, 0), vn(40000000, 0), v;
	cin >> m >> n >> k;
	ll sw = 0, sum = 0;
	for (long long int i = 1; i <= sqrt(k); i++) {
		if (k % i == 0) {
			v.push_back(i);
			v.push_back(k / i);
			if (i != k / i) {
				v.push_back(k / i);
				v.push_back(i);
			}
		}
	}
	sw = 0;
	for (int i = 0; i < m; i++) {
		cin >> a;
		if (a == 1)
			sw++;
		else {
			for (int j = sw; j > 0; j--) {
				vm[j] += (sw + 1) - j;
			}
			sw = 0;
		}
		if (i == m - 1) {
			for (int j = sw; j > 0; j--) {
				vm[j] += (sw + 1) - j;
			}
			sw = 0;
		}
	}
	sw = 0;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a == 1)
			sw++;
		else {
			for (int j = sw; j > 0; j--) {
				vn[j] += (sw + 1) - j;
			}
			sw = 0;
		}
		if (i == n - 1) {
			for (int j = sw; j > 0; j--) {
				vn[j] += (sw + 1) - j;
			}
			sw = 0;
		}
	}
	for (int i = 0; i < v.size(); i += 2) {
		ll u = vm[v[i]];
		ll uu = vn[v[i + 1]];
		unsigned long long int dd = u * uu;
		sum += dd;
	}
		cout << sum;
}


#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define sp system("pause");
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tcase ll tt; cin>>tt; while (tt--)
#define ll long long
#define in(x); { for (auto &i : x) cin >> i; }
using namespace std;
void main() {
	fastio
		int m, n, k,a;
	vector<int>vm, vn,v;
	cin >> m >> n >> k;
	int sw = 0,sww1=0,sw1=0, sww2 = 0, sw2 = 0,sum=0;
	for (int i = 0; i < m; i++) {
		cin >> a;
		vm.push_back(a);
	}
	for (int i = 0; i < n; i++) {
		cin >> a;
		vn.push_back(a);
	}
	for (int i = 1; i <= k; i++) {
		if (k%i==0) {
			v.push_back(i);
			v.push_back(k / i);
		}
	}
	for (int k = 0; k  <v.size(); k += 2) {
		sw1 = 0, sw2 = 0, sww1 = 0, sww2 = 0;
		for (int i = 0; i < m; i++) {
			if (vm[i] == 0) {
				sw1 = 0;
			}
			else sw1++;
			if (sw1 == v[k]) {
				sww1++;
				i -= v[k] - 1;
				sw1 = 0;
			}
		}
		for (int i = 0; i < n; i++) {
			if (vn[i] == 0) {
				sw2 = 0;
			}
			else sw2++;
			if (sw2 == v[k + 1]) {
				sww2++;
				i -= v[k + 1] - 1;
				sw2 = 0;
			}
		}
		sum += sww2 * sww1;
	}
	cout << sum;
}


#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define sp system("pause");
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tcase ll tt; cin>>tt; while (tt--)
#define ll long long
#define in(x); { for (auto &i : x) cin >> i; }
using namespace std;
void main() {
	fastio
		int m, n, k, a;
	vector<int>vm, vn, v;
	cin >> m >> n >> k;
	int sw = 0, sww1 = 0, sw1 = 0, sww2 = 0, sw2 = 0, sum = 0;
	for (int i = 0; i < m; i++) {
		cin >> a;
		vm.push_back(a);
	}
	for (int i = 0; i < n; i++) {
		cin >> a;
		vn.push_back(a);
	}
	for (int i = 1; i <= sqrt(k); i++) {
		if (k % i == 0) {
			v.push_back(i);
			v.push_back(k / i);
			if (i != k / i) {
				v.push_back(k / i);
				v.push_back(i);
			}
		}
	}
	for (int k = 0; k < v.size(); k += 2) {
		sw1 = 0, sw2 = 0, sww1 = 0, sww2 = 0;
		for (int i = 0; i < m; i++) {
			if (vm[i] == 0) {
				sw1 = 0;
			}
			else sw1++;
			if (sw1 == v[k]) {
				sww1++;
				i -= v[k] - 1;
				sw1 = 0;
			}
		}
		for (int i = 0; i < n; i++) {
			if (vn[i] == 0) {
				sw2 = 0;
			}
			else sw2++;
			if (sw2 == v[k + 1]) {
				sww2++;
				i -= v[k + 1] - 1;
				sw2 = 0;
			}
		}
		sum += (sww2 * sww1) ;
	}
	cout << sum;

}


#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define sp system("pause");
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tcase ll tt; cin>>tt; while (tt--)
#define ll long long
#define in(x); { for (auto &i : x) cin >> i; }
using namespace std;
ll n, m, k, ans = 0;
vector<ll> cl(400001);
vector<ll> rw(400001);
void col() {
	int length = 0;
	for (int i = 1; i <= m; i++) {
		int a; cin >> a;
		if (a)length++;
		else if (length) {
			for (int j = length; j; j--)cl[j] += length - j + 1;
			length = 0;
		}
	}
	for (int j = length; j; j--)cl[j] += length - j + 1;
}
void row() {
	int length = 0;
	for (int i = 1; i <= n; i++) {
		int a; cin >> a;
		if (a)length++;
		else if (length) {
			for (int j = length; j; j--)rw[j] += length - j + 1;
			length = 0;
		}
	}
	for (int j = length; j; j--)rw[j] += length - j + 1;
}
void main() {
	fastio
	cin >> m >> n >> k;
	ll sw = 0, sum = 0;
	sw = 0;
	row(), col();
	for (long long int i = 1; i <= sqrt(k); i++) {
		if (k % i == 0) {
			sum += cl[i] * rw[k/i];
			if (i != k / i) {
				sum += cl[k/i] * rw[i];
			}
		}
	}
	cout << sum;
}


#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define sp system("pause");
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tcase ll tt; cin>>tt; while (tt--)
#define ll long long
#define in(x); { for (auto &i : x) cin >> i; }
using namespace std;
ll n, m, k, ans = 0;
vector<ll> cl(400001);
vector<ll> rw(400001);
void col() {
	int length = 0;
	for (int i = 1; i <= m; i++) {
		int a; cin >> a;
		if (a)length++;
		else if (length) {
			for (int j = length; j; j--)cl[j] += length - j + 1;
			length = 0;
		}
	}
	for (int j = length; j; j--)cl[j] += length - j + 1;
}
void row() {
	int length = 0;
	for (int i = 1; i <= n; i++) {
		int a; cin >> a;
		if (a)length++;
		else if (length) {
			for (int j = length; j; j--)rw[j] += length - j + 1;
			length = 0;
		}
	}
	for (int j = length; j; j--)rw[j] += length - j + 1;
}
void main() {
	fastio
		cin >> n >> m >> k;
	row(), col();
	for (int i = 1; i <= (k / i); i++) {
		if (!(k % i)) {
			if (i <= n && k / i <= m)ans += rw[i] * cl[k / i];
			if (i != k / i && i <= m && k / i <= n)ans += rw[k / i] * cl[i];
		}
	}
	cout << ans << "\n";

}


#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define sp system("pause");
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tcase ll tt; cin>>tt; while (tt--)
#define ll long long
#define in(x); { for (auto &i : x) cin >> i; }
using namespace std;
/*void main() {
	int t, a = 0, b = 0, c = 0, o = -1, p;
	string s;
	cin >> t;
	vector<pair<int, string>>v;
	vector<int>sum(3, 0);
	for (int i = 0; i < t; i++) {
		cin >> p >> s;
		v.push_back(make_pair(p, s));
	}
	sort(v.begin(), v.end());
	for (int i = 0; i < t; i++) {
		int sw = 0;
		if (a == 0) {
			o = v[i].second.find('A');
			if (o > -1) {
				sw++;
				a++;
				o = -1;
			}
		}
		if (b == 0) {
			o = v[i].second.find('B');
			if (o > -1) {
				sw++;
				b++;
				o = -1;
			}
		}
		if (c == 0) {
			o = v[i].second.find('C');
			if (o > -1) {
				sw++;
				c++;
				o = -1;
			}
		}
		if (sw > 0)sum[0] += v[i].first;
		if (a > 0 && b > 0 && c > 0) break;
		if (i == t - 1) {
			if (a == 0 || b == 0 || c == 0) {
				sum[0] = 0;
			}
		}
	}
	a = 0, b = 0, c = 0;
	for (int i = 0; (i < t) || (a == 0 && b == 0 && c == 0); i++) {
		if (i == t)break;
		o = -1;
		o = v[i].second.find('A');
		if (o > -1) {
			o = -1;
			o = v[i].second.find('B');
			if (o > -1) {
				o = -1;
				o = v[i].second.find('C');
				if (o > -1) {
					sum[2] = v[i].first;
					break;
				}
			}
		}
	}
	a = 0, b = 0, c = 0;
	for (int i = 0; (i < t) || (a == 0 && b == 0 && c == 0); i++) {
		int sw = 0;
		if (i == 0) {
			if (a == 0) {
				o = v[i].second.find('A');
				if (o > -1) {
					sw++;
					a++;
					o = -1;
				}
			}
			if (b == 0) {
				o = v[i].second.find('B');
				if (o > -1) {
					sw++;
					b++;
					o = -1;
				}
			}
			if (c == 0) {
				o = v[i].second.find('C');
				if (o > -1) {
					sw++;
					c++;
					o = -1;
				}
			}
		}
		else {
			if (a > 0 && b == 0 && c == 0) {
				o = -1;
				o = v[i].second.find('B');
				if (o > -1) {
					o = -1;
					o = v[i].second.find('C');
					if (o > -1) {
						sum[1] = v[i].first + v[0].first;
						break;
					}
				}
			}
			else if (a == 0 && b > 0 && c == 0) {
				o = -1;
				o = v[i].second.find('A');
				if (o > -1) {
					o = -1;
					o = v[i].second.find('C');
					if (o > -1) {
						sum[1] = v[i].first + v[0].first;
						break;
					}
				}
			}
			else if (a == 0 && b == 0 && c > 0) {
				o = -1;
				o = v[i].second.find('A');
				if (o > -1) {
					o = -1;
					o = v[i].second.find('B');
					if (o > -1) {
						sum[1] = v[i].first + v[0].first;
						break;
					}
				}
			}
			else if (a == 0 && b > 0 && c > 0) {
				o = -1;
				o = v[i].second.find('A');
				if (o > -1) {
					sum[1] = v[i].first + v[0].first;
					break;
				}
			}
			else if (a > 0 && b == 0 && c > 0) {
				o = -1;
				o = v[i].second.find('B');
				if (o > -1) {
					sum[1] = v[i].first + v[0].first;
					break;
				}
			}
			else if (a > 0 && b > 0 && c == 0) {
				o = -1;
				o = v[i].second.find('C');
				if (o > -1) {
					sum[1] = v[i].first + v[0].first;
					break;
				}
			}

		}
	}
	int ppppppppp = 0;
	sort(sum.begin(), sum.end());
	for (int i = 0; i < 3; i++) {
		if (sum[i] != 0) {
			cout << sum[i];
			ppppppppp++;
			break;
		}
	}
	if (ppppppppp == 0)cout << -1;
	system("pause");
}*/
/*void main() {
	fastio
		tcase{
		int a,sw = 0;
	string s;
	cin >> a >> s;
	if (s[0] == '>' || s[a - 1] == '<') cout << 0<<endl;
	else {
		for (int i = 1; i < a; i++) {
			sw++;
			if (s[i] == '>') {
				sw = i;
				break;
			}
			if (s[a - 1 - i] == '<') {
				sw = i;
				break;
			}
		}
		cout << sw << endl;
	}
	}
	sp

}*/
void main() {
	fastio
		int m, n, k, a;
	vector<int>vm(4000,0), vn(4000,0), v;
	cin >> m >> n >> k;
	long long int sw = 0, sww1 = 0, sw1 = 0, sww2 = 0, sw2 = 0, sum = 0;
	for (int i = 1; i <= sqrt(k); i++) {
		if (k % i == 0) {
			v.push_back(i);
			v.push_back(k / i);
			if (i != k / i) {
				v.push_back(k / i);
				v.push_back(i);
			}
		}
	}
	sw = 0;
	for (int i = 0; i < m; i++) {
		cin >> a;
		if (a == 1)
			sw++;
		else {
			for (int j = sw; j > 0; j--) {
				vm[j] += (sw + 1) - j;
			}
			sw = 0;
		}
		if(i==m-1) {
			for (int j = sw; j > 0; j--) {
				vm[j] += (sw + 1) - j;
			}
			sw = 0;
		}
	}
	sw = 0;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a == 1)
			sw++;
		else {
			for (int j = sw; j > 0; j--) {
				vn[j] += (sw + 1) - j;
			}
			sw = 0;
		}
		if (i == n - 1) {
			for (int j = sw; j > 0; j--) {
				vn[j] += (sw + 1) - j;
			}
			sw = 0;
		}
	}
	for (int i = 0; i < v.size(); i+=2) sum += vm[v[i]] * vn[v[i + 1]];cout << sum;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
long long n,m,k,a[40005],b[40005],c[40005],d[40005],cnt1,cnt2,sum1,sum2,ans;
long long vis[40005],cnt3,sum[40005];
int main()
{
	cin>>n>>m>>k;
	for(int i=1;i<=sqrt(k);i++) if(k%i==0) vis[++cnt3]=i;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(!a[i]) c[++sum1]=i;
	}
	c[++sum1]=n+1;
	for(int i=1;i<=sum1;i++)
		for(int j=1;j<=cnt3;j++) if(vis[j]<=c[i]-c[i-1]-1) sum[j]+=c[i]-c[i-1]-vis[j];
	for(int i=1;i<=m;i++)
	{
		cin>>b[i];
		if(!b[i]) d[++sum2]=i;
	}
	d[++sum2]=m+1;
	for(int i=1;i<=sum2;i++)
		for(int j=1;j<=cnt3;j++) if(d[i]-d[i-1]>=k/vis[j]) ans+=(d[i]-d[i-1]-(k/vis[j]))*sum[j];
	cout<<ans;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
long long n,m,k,a[400005],b[400005],c[400005],d[400005],cnt1,cnt2,sum1,sum2,ans;
long long vis[400005],cnt3,sum[400005],fuck[400005];
int main()
{
	cin>>n>>m>>k;
	for(int i=1;i<=sqrt(k);i++) if(k%i==0) vis[++cnt3]=i;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(!a[i]) c[++sum1]=i;
	}
	c[++sum1]=n+1;
	for(int i=1;i<=sum1;i++)
		for(int j=1;j<=cnt3;j++) if(vis[j]<=c[i]-c[i-1]-1) sum[j]+=c[i]-c[i-1]-vis[j];
	for(int i=1;i<=m;i++)
	{
		cin>>b[i];
		if(!b[i]) d[++sum2]=i;
	}
	d[++sum2]=m+1;
	for(int i=1;i<=sum2;i++)
		for(int j=1;j<=cnt3;j++) if(vis[j]<=d[i]-d[i-1]-1) fuck[j]+=d[i]-d[i-1]-vis[j];
	for(int i=1;i<=sum2;i++)
		for(int j=1;j<=cnt3;j++) if(d[i]-d[i-1]-1>=k/vis[j]) ans+=(d[i]-d[i-1]-(k/vis[j]))*sum[j];
	for(int i=1;i<=sum1;i++)
		for(int j=1;j<=cnt3;j++) if(c[i]-c[i-1]-1>=k/vis[j]&&k/vis[j]!=vis[j]) ans+=(c[i]-c[i-1]-(k/vis[j]))*fuck[j];
	cout<<ans;
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
long long n,m,k,a[40005],b[40005],c[40005],d[40005],cnt1,cnt2,sum1,sum2,ans;
long long vis[40005],cnt3,sum[40005];
int main()
{
	cin>>n>>m>>k;
	for(int i=1;i<=sqrt(k);i++) if(k%i==0) vis[++cnt3]=i;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(!a[i]) c[++sum1]=i;
	}
	c[++sum1]=n+1;
	for(int i=1;i<=sum1;i++)
		for(int j=1;j<=cnt3;j++) if(vis[j]<=c[i]-c[i-1]-1) sum[j]+=c[i]-c[i-1]-vis[j];
	for(int i=1;i<=m;i++)
	{
		cin>>b[i];
		if(!b[i]) d[++sum2]=i;
	}
	d[++sum2]=m+1;
	for(int i=1;i<=sum2;i++)
		for(int j=1;j<=cnt3;j++) if(d[i]-d[i-1]-1>=k/vis[j]) ans+=(d[i]-d[i-1]-(k/vis[j]))*sum[j];
	cout<<ans;
	return 0;
}


#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <string.h>
#define MAX 50000000
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;

map<int, int> a, b;
map<PII, int> rect;

int main(void) {
    int n, m, k, t;
    scanf("%d %d %d", &n, &m, &k);
    ll cnt = 0;
    for (int i = 0; i < n; i++) {
        scanf("%d", &t);
        if (t) cnt++;
        else if (cnt) {
            a[cnt]++;
            cnt = 0;
        }
    }
    if (cnt) {
        a[cnt]++;
        cnt = 0;
    }
    for (int i = 0; i < m; i++) {
        scanf("%d", &t);
        if (t) cnt++;
        else if (cnt) {
            b[cnt]++;
            cnt = 0;
        }
    }
    if (cnt) {
        b[cnt]++;
        cnt = 0;
    }

    for (auto i : a)
        for (auto j : b)
            if (i.first * j.first >= k)
                rect[{min(i.first, j.first), max(i.first, j.first)}] += i.second * j.second;

    for (auto it : rect)
        for (int i = 1; i <= it.first.first; i++)
            if (!(k % i) && k / i <= it.first.second)
                cnt += (it.first.first - i + 1) * (it.first.second - (k / i) + 1) * it.second;

    printf("%lld", cnt);
    return 0;
}


#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <string.h>
#define MAX 50000000
using namespace std;
typedef pair<int, int> PII;

map<int, int> a, b;
map<PII, int> rect;

int main(void) {
    int n, m, k, t, ans = 0;
    scanf("%d %d %d", &n, &m, &k);
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        scanf("%d", &t);
        if (t) cnt++;
        else if(cnt) {
            a[cnt]++;
            cnt = 0;
        }
    }
    if (cnt) {
        a[cnt]++;
        cnt = 0;
    }
    for (int i = 0; i < m; i++) {
        scanf("%d", &t);
        if (t) cnt++;
        else if (cnt) {
            b[cnt]++;
            cnt = 0;
        }
    }
    if (cnt) {
        b[cnt]++;
        cnt = 0;
    }
    for (auto i : a) {
        for (auto j : b) {
            if (i.first * j.first >= k) {
                rect[{min(i.first, j.first), max(i.first, j.first)}] += i.second * j.second;
            }
        }
    }

    for (auto it : rect) {
        for (int i = 1; i <= it.first.first; i++) {
            if (!(k % i)) {
                ans += (it.first.first - i + 1) * (it.first.second - (k / i) + 1) * it.second;
            }
        }
    }
    printf("%d", ans);
    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <cstring>
#include <deque>
#include <stack>
#include <queue>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int n, m;
ll k;
ll a[40005];
ll b[40005];

int main()
{
	vector<ll> h, w;
	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++)
	{
		scanf_s("%lld", &a[i]);
		if (a[i] != 0)
		{
			a[i] += a[i - 1];
			h.push_back(a[i]);
		}
	}
	for (int i = 1; i <= m; i++)
	{
		scanf_s("%lld", &b[i]);
		if (b[i] != 0)
		{
			b[i] += b[i - 1];
			w.push_back(b[i]);
 		}
	}

	int ans = 0, cnt = 0;
	sort(h.begin(), h.end());
	sort(w.begin(), w.end());
	int len = w.size();
	for (ll height : h)
	{
		for (ll cur_h = 1; cur_h <= height; cur_h++)
		{
			if (k % cur_h == 0)
			{
				cnt = lower_bound(w.begin(), w.end(), k / cur_h) - w.begin();
				cnt = len - cnt;
				ans += cnt;
			}
		}
	}

	cout << ans << '\n';
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <cstring>
#include <deque>
#include <stack>
#include <queue>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int n, m;
ll k;
ll a[40005];
ll b[40005];

int main()
{
	vector<ll> h, w;
	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++)
	{
		scanf_s("%lld", &a[i]);
		if (a[i] != 0)
		{
			a[i] += a[i - 1];
			h.push_back(a[i]);
		}
	}
	for (int i = 1; i <= m; i++)
	{
		scanf_s("%lld", &b[i]);
		if (b[i] != 0)
		{
			b[i] += b[i - 1];
			w.push_back(b[i]);
 		}
	}

	int ans = 0;
	sort(h.begin(), h.end());
	sort(w.begin(), w.end());

	int cnt_h = 0, cnt_w = 0;
	int len_h = h.size(), len_w = w.size();
	for (ll height = 1; height <= n; height++)
	{
		if (k % height != 0) continue;

		cnt_h = len_h - (lower_bound(h.begin(), h.end(), height) - h.begin());
		cnt_w = len_w - (lower_bound(w.begin(), w.end(), k / height) - w.begin());

		ans += cnt_h * cnt_w;
	}

	cout << ans << '\n';
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <cstring>
#include <deque>
#include <stack>
#include <queue>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int n, m;
ll k;
ll a[40005];
ll b[40005];

int main()
{
	vector<ll> h, w;
	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++)
	{
		scanf_s("%lld", &a[i]);
		if (a[i] != 0)
		{
			a[i] += a[i - 1];
			h.push_back(a[i]);
		}
	}
	for (int i = 1; i <= m; i++)
	{
		scanf_s("%lld", &b[i]);
		if (b[i] != 0)
		{
			b[i] += b[i - 1];
			w.push_back(b[i]);
 		}
	}

	ll ans = 0;
	sort(h.begin(), h.end());
	sort(w.begin(), w.end());

	ll cnt_h = 0, cnt_w = 0;
	ll len_h = h.size(), len_w = w.size();
	for (ll height = 1; height <= n; height++)
	{
		if (k % height != 0) continue;

		cnt_h = len_h - (ll)(lower_bound(h.begin(), h.end(), height) - h.begin());
		cnt_w = len_w - (ll)(lower_bound(w.begin(), w.end(), k / height) - w.begin());

		ans += cnt_h * cnt_w;
	}

	cout << ans << '\n';
	return 0;
}


/*����a����n������b����m����ֻ��0��1
 һ��n*m�ľ���c�����ɹ���c[i][j]=a[i]*b[j]
 ���ж��ٸ��Ӿ������ŵģ�ֻ��1����
 �������������ĵ�Ԫ��
 ���룺��һ��n��m��1~40000����k
 	   �ڶ���a��Ԫ�أ�������b��Ԫ��
 ����� k��ķ����������Ӿ�����Ŀ
 */

#include<iostream>
#include<cmath>
using namespace std;
typedef long long ll;
ll ans=0;
int fac[40000],n,m,k;
int f()
{
	int j=0;
	for(int i=1;i<=sqrt(k);i++){
		if(k%i==0)	fac[j++]=i;
	}
	return j;
}
int a[50000],b[50000];
int main()
{
	cin>>n>>m>>k;
	int i,j;
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);

	for(i=0;i<m;i++)
		scanf("%d",&b[i]);

	int num;//һ������Ӹ���
	num=f();
	for(i=0;i<num;i++){
		int row=0,col=0;//�ֱ�Ϊa��b�Ͽ�ȡ������1������Ŀ
		int nu=0;//��1��Ŀ���һ�
		for(j=0;j<n;j++){
			if(a[j]==1)	nu++;
			else	nu=0;
			if(nu==fac[i]){
				nu--;
				row++;
			}
		}
		nu=0;
		for(j=0;j<m;j++){
			if(b[j]==1)	nu++;
			else	nu=0;
			if(nu==k/fac[i]){
				nu--;
				col++;
			}
		}
		ans+=row*col;
		if(fac[i]*fac[i]!=k){
				nu=0;
			row=0;
			col=0;
			for(j=0;j<n;j++){
				if(a[j]==1)	nu++;
				else	nu=0;
				if(nu==k/fac[i]){
					nu--;
					row++;
				}
			}
			nu=0;
			for(j=0;j<m;j++){
				if(b[j]==1)	nu++;
				else	nu=0;
				if(nu==fac[i]){
					nu--;
					col++;
				}
			}
			ans+=row*col;
		}
	}

	cout<<ans;
	return 0;
}


/*����a����n������b����m����ֻ��0��1
 һ��n*m�ľ���c�����ɹ���c[i][j]=a[i]*b[j]
 ���ж��ٸ��Ӿ������ŵģ�ֻ��1����
 �������������ĵ�Ԫ��
 ���룺��һ��n��m��1~40000����k
 	   �ڶ���a��Ԫ�أ�������b��Ԫ��
 ����� k��ķ����������Ӿ�����Ŀ
 */

#include<iostream>
#include<cmath>
using namespace std;
typedef long long ll;
ll ans=0;
int fac[40000],n,m,k;
int f()
{
	int j=0;
	for(int i=1;i<=sqrt(k);i++){
		if(k%i==0)	fac[j++]=i;
	}
	return j;
}
int a[50000],b[50000];
int main()
{
	cin>>n>>m>>k;
	int i,j;
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);

	for(i=0;i<m;i++)
		scanf("%d",&b[i]);

	int num;//һ������Ӹ���
	num=f();
	for(i=0;i<num;i++){
		int row=0,col=0;//�ֱ�Ϊa��b�Ͽ�ȡ������1������Ŀ
		int nu=0;//��1��Ŀ���һ�
		for(j=0;j<n;j++){
			if(a[j]==1)	nu++;
			else	nu=0;
			if(nu==fac[i]){
				nu--;
				row++;
			}
		}
		nu=0;
		for(j=0;j<m;j++){
			if(b[j]==1)	nu++;
			else	nu=0;
			if(nu==k/fac[i]){
				nu--;
				col++;
			}
		}
		ans+=row*col;
		nu=0;
		row=0;
		col=0;
		for(j=0;j<n;j++){
			if(a[j]==1)	nu++;
			else	nu=0;
			if(nu==k/fac[i]){
				nu--;
				row++;
			}
		}
		nu=0;
		for(j=0;j<m;j++){
			if(b[j]==1)	nu++;
			else	nu=0;
			if(nu==fac[i]){
				nu--;
				col++;
			}
		}
		ans+=row*col;
	}

	cout<<ans;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
#include <fstream>
#include <vector>
#include <queue>
#include <stack>
#include <sstream>
#include <list>
#include <map>
#include <set>

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second

const int INF = 1 << 30;
const ll LINF = 1ll << 60;

using namespace std;

const int N = 40010;
int a[N], b[N];
map<int, int> dictA, dictB;
vector<int> ar, br;

int main() {
	int n, m, k;
	cin >> n >> m >> k;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] == 0) {
			if (cnt != 0) {
				ar.push_back(cnt);
			}
			cnt = 0;
		}
		else {
			cnt++;
		}
	}
	if (cnt != 0) ar.push_back(cnt);
	cnt = 0;
	for (int i = 0; i < m; i++) {
		cin >> b[i];
		if (b[i] == 0) {
			if (cnt != 0) {
				br.push_back(cnt);
			}
			cnt = 0;
		}
		else {
			cnt++;
		}
	}
	if (cnt != 0) br.push_back(cnt);
	sort(ar.begin(), ar.end());
	sort(br.begin(), br.end());
	for (int i = 0; i < ar.size(); i++) {
		for (int j = 0; j < ar[i]; j++) {
			if (dictA.find(ar[i] - j) == dictA.end()) dictA.insert(pii(ar[i] - j, 0));
			dictA[ar[i] - j] += ar[i] - (ar[i] - j - 1);
		}
	}
	for (int i = 0; i < br.size(); i++) {
		for (int j = 0; j < br[i]; j++) {
			if (dictB.find(br[i] - j) == dictB.end()) dictB.insert(pii(br[i] - j, 0));
			dictB[br[i] - j] += br[i] - (br[i] - j - 1);
		}
	}
	ll ans = 0;
	for (int i = 1; i * i <= k; i++) {
		if (k % i == 0) {
			ans += dictA[i] * dictB[k / i];
		}
	}
	cout << ans;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
#include <fstream>
#include <vector>
#include <queue>
#include <stack>
#include <sstream>
#include <list>
#include <map>
#include <set>

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second

const int INF = 1 << 30;
const ll LINF = 1ll << 60;

using namespace std;

const int N = 40010;
int a[N], b[N];
map<int, int> dictA, dictB;
vector<int> ar, br;

int main() {
	int n, m, k;
	cin >> n >> m >> k;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] == 0) {
			if (cnt != 0) {
				ar.push_back(cnt);
			}
			cnt = 0;
		}
		else {
			cnt++;
		}
	}
	if (cnt != 0) ar.push_back(cnt);
	cnt = 0;
	for (int i = 0; i < m; i++) {
		cin >> b[i];
		if (b[i] == 0) {
			if (cnt != 0) {
				br.push_back(cnt);
			}
			cnt = 0;
		}
		else {
			cnt++;
		}
	}
	if (cnt != 0) br.push_back(cnt);
	sort(ar.begin(), ar.end());
	sort(br.begin(), br.end());
	for (int i = 0; i < ar.size(); i++) {
		for (int j = 0; j < ar[i]; j++) {
			if (dictA.find(ar[i] - j) == dictA.end()) dictA.insert(pii(ar[i] - j, 0));
			dictA[ar[i] - j] += ar[i] - (ar[i] - j - 1);
		}
	}
	for (int i = 0; i < br.size(); i++) {
		for (int j = 0; j < br[i]; j++) {
			if (dictB.find(br[i] - j) == dictB.end()) dictB.insert(pii(br[i] - j, 0));
			dictB[br[i] - j] += br[i] - (br[i] - j - 1);
		}
	}
	ll ans = 0;
	for (int i = 1; i <= n && i <= k; i++) {
		if (k % i == 0) {
			ans += dictA[i] * dictB[k / i];
		}
	}
	cout << ans;
}


#include <cstdio>

using namespace std;

int n,m;
long long int k;
int a[80005];
int b[80005];
int consec;
int c;
int ans;

int main()
{
    scanf("%d %d %lld",&n,&m,&k);
    for(int i=0;i<n;i++){
        scanf("%d",&c);
        if(c){
            consec++;
            a[consec]++;
        }
        else{
            consec=0;
        }
    }

    consec=0;

    for(int i=0;i<m;i++){
        scanf("%d",&c);
        if(c){
            consec++;
            b[consec]++;
        }
        else{
            consec=0;
        }
    }
    int curr=0;

    for(int i=n-1;i>0;i--){
        a[i]+=a[i+1];
    }
    curr=0;
    for(int i=m-1;i>0;i--){
        b[i]+=b[i+1];
    }

    for(long long int i=1;i*i<=k;i++){
        if(k%i==0&&(i<=n)&&((k/i)<=m)){
            ans+=a[i]*b[k/i];
        }
        if(k%i==0&&(i<=m)&&((k/i)<=n)){
            ans+=b[i]*a[k/i];
        }
    }
    printf("%d",ans);
}


#include <cstdio>

using namespace std;

int n,m,k;
int a[80005];
int b[80005];
int consec;
int c;
int ans;

int main()
{
    scanf("%d %d %d",&m,&n,&k);
    for(int i=0;i<m;i++){
        scanf("%d",&c);
        if(c){
            consec++;
            for(int i=1;i<=consec;i++){
                a[i]++;
            }
        }
        else{
            consec=0;
        }
    }

    consec=0;

    for(int i=0;i<n;i++){
        scanf("%d",&c);
        if(c){
            consec++;
            for(int i=1;i<=consec;i++){
                b[i]++;
            }
        }
        else{
            consec=0;
        }
    }

    for(int i=1;i<=k;i++){
        if(k%i==0){
            ans+=a[i]*b[k/i];
        }
    }
    printf("%d",ans);
}


#include <cstdio>

using namespace std;

int n,m,k;
int a[80005];
int b[80005];
int consec;
int c;
int ans;

int main()
{
    scanf("%d %d %d",&n,&m,&k);
    for(int i=0;i<n;i++){
        scanf("%d",&c);
        if(c){
            consec++;
            a[consec]++;
        }
        else{
            consec=0;
        }
    }

    consec=0;

    for(int i=0;i<m;i++){
        scanf("%d",&c);
        if(c){
            consec++;
            b[consec]++;
        }
        else{
            consec=0;
        }
    }
    int curr=0;

    for(int i=n-1;i>0;i--){
        a[i]+=a[i+1];
    }
    curr=0;
    for(int i=m-1;i>0;i--){
        b[i]+=b[i+1];
    }

    for(int i=1;i<=k;i++){
        if(k%i==0&&(i<=n)&&((k/i)<=m)){
            ans+=a[i]*b[k/i];
        }
    }
    printf("%d",ans);
}


#include <cstdio>

using namespace std;

int n,m,k;
int a[40005];
int b[40005];
int consec;
int c;
int ans;

int main()
{
    scanf("%d %d %d",&m,&n,&k);
    for(int i=0;i<m;i++){
        scanf("%d",&c);
        if(c){
            consec++;
            for(int i=1;i<=consec;i++){
                a[i]++;
            }
        }
        else{
            consec=0;
        }
    }

    consec=0;

    for(int i=0;i<n;i++){
        scanf("%d",&c);
        if(c){
            consec++;
            for(int i=1;i<=consec;i++){
                b[i]++;
            }
        }
        else{
            consec=0;
        }
    }

    for(int i=1;i<=k;i++){
        if(k%i==0){
            ans+=a[i]*b[k/i];
        }
    }
    printf("%d",ans);
}


#include <cstdio>

using namespace std;

int n,m;
long long int k;
long long int a[80005];
long long int b[80005];
int consec;
int c;
long long int ans;

int main()
{
    scanf("%d %d %lld",&n,&m,&k);

    for(int i=0;i<n;i++){
        scanf("%d",&c);
        if(c==1){
            consec++;
            a[consec]++;
        }
        if(c==0){
            consec=0;
        }
    }

    consec=0;

    for(int i=0;i<m;i++){
        scanf("%d",&c);
        if(c==1){
            consec++;
            b[consec]++;
        }
        if(c==0){
            consec=0;
        }
    }

    for(int i=n-1;i>=0;i--){
        a[i]+=a[i+1];
    }

    for(int i=m-1;i>=0;i--){
        b[i]+=b[i+1];
    }

    for(long long int i=1;i*i<=k;i++){
        if(k%i==0&&(i<=n)&&((k/i)<=m)){
            ans+=a[i]*b[k/i];
        }
        if(i*i==k){
            break;
        }
        if(k%i==0&&(i<=m)&&((k/i)<=n)){
            ans+=b[i]*a[k/i];
        }
    }
    printf("%lld",ans);
}


#include <cstdio>

using namespace std;

int n,m,k;
int a[80005];
int b[80005];
int consec;
int c;
int ans;

int main()
{
    scanf("%d %d %d",&n,&m,&k);
    for(int i=0;i<n;i++){
        scanf("%d",&c);
        if(c){
            consec++;
            for(int i=1;i<=consec;i++){
                a[i]++;
            }
        }
        else{
            consec=0;
        }
    }

    consec=0;

    for(int i=0;i<m;i++){
        scanf("%d",&c);
        if(c){
            consec++;
            for(int i=1;i<=consec;i++){
                b[i]++;
            }
        }
        else{
            consec=0;
        }
    }

    for(int i=1;i<=k;i++){
        if(k%i==0){
            ans+=a[i]*b[k/i];
        }
    }
    printf("%d",ans);
}


#include <cstdio>

using namespace std;

int n,m,k;
int a[80005];
int b[80005];
int consec;
int c;
int ans;

int main()
{
    scanf("%d %d %d",&n,&m,&k);
    for(int i=0;i<n;i++){
        scanf("%d",&c);
        if(c){
            consec++;
            for(int i=1;i<=consec;i++){
                a[i]++;
            }
        }
        else{
            consec=0;
        }
    }

    consec=0;

    for(int i=0;i<m;i++){
        scanf("%d",&c);
        if(c){
            consec++;
            for(int i=1;i<=consec;i++){
                b[i]++;
            }
        }
        else{
            consec=0;
        }
    }

    for(int i=1;i<=k;i++){
        if(k%i==0&&(i<=n)&&((k/i)<=m)){
            ans+=a[i]*b[k/i];
        }
    }
    printf("%d",ans);
}


#include <cstdio>

using namespace std;

int n,m;
long long int k;
int a[80005];
int b[80005];
int consec;
int c;
int ans;

int main()
{
    scanf("%d %d %lld",&n,&m,&k);
    for(int i=0;i<n;i++){
        scanf("%d",&c);
        if(c){
            consec++;
            a[consec]++;
        }
        else{
            consec=0;
        }
    }

    consec=0;

    for(int i=0;i<m;i++){
        scanf("%d",&c);
        if(c){
            consec++;
            b[consec]++;
        }
        else{
            consec=0;
        }
    }
    int curr=0;

    for(int i=n-1;i>0;i--){
        a[i]+=a[i+1];
    }
    curr=0;
    for(int i=m-1;i>0;i--){
        b[i]+=b[i+1];
    }

    for(int i=1;i*i<=k;i++){
        if(k%i==0&&(i<=n)&&((k/i)<=m)){
            ans+=a[i]*b[k/i];
        }
        if(i*i==k){
            break;
        }
        if(k%i==0&&(i<=m)&&((k/i)<=n)){
            ans+=b[i]*a[k/i];
        }
    }
    printf("%d",ans);
}


#include <cstdio>

using namespace std;

int n,m;
long long int k;
long long int a[80005];
long long int b[80005];
int consec;
int c;
long long int ans;

int main()
{
    scanf("%d %d %lld",&n,&m,&k);

    for(int i=0;i<n;i++){
        scanf("%d",&c);
        if(c==1){
            consec++;
            a[consec]++;
        }
        if(c==0){
            consec=0;
        }
    }

    consec=0;

    for(int i=0;i<m;i++){
        scanf("%d",&c);
        if(c==1){
            consec++;
            b[consec]++;
        }
        if(c==0){
            consec=0;
        }
    }

    for(int i=n-1;i>0;i--){
        a[i]+=a[i+1];
    }

    for(int i=m-1;i>0;i--){
        b[i]+=b[i+1];
    }

    for(long long int i=1;i*i<=k;i++){
        if(k%i==0&&(i<=n)&&((k/i)<=m)){
            ans+=a[i]*b[k/i];
        }
        if(i*i==k){
            break;
        }
        if(k%i==0&&(i<=m)&&((k/i)<=n)){
            ans+=b[i]*a[k/i];
        }
    }
    printf("%d",ans);
}


#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<deque>
#define pi 3.1415926535
#include<chrono>
#define float double
#define floa float
#define MOD 1000000007
#define INF 999999999999999999
#define pb push_back
#define ff first
#define ss second
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define f0 get<0>(temp)
#define f1 get<1>(temp)
#define f2 get<2>(temp)
using namespace std;
ll ncr(ll n, ll r)
{
    ll i, ans = 1, k = 0;
    if (r == 0)
        return 1;
    else if (n < r)
        return 0;
    for (i = n; i >= n - r + 1; i--)
    {
        ans *= i;
        ans /= n - i + 1;
    }

    return ans;

}
bool visited[6] = { false };
int n = 6;
vector<int> adj[6];

void max_heapify(int a[100], int i)
{
    int l, r, largest = i;
    l = 2 * i + 1;
    r = 2 * i + 2;
    if (l<n && a[l]>a[i])
        largest = l;
    if (r<n && a[r]>a[l])
        largest = r;
    if (largest != i)
    {
        int k;
        k = a[i];
        a[i] = a[largest];
        a[largest] = k;
        max_heapify(a, largest);
    }

}
int power(ll x, ll y, ll p)
{
    int res = 1;
    x = x % p;

    while (y > 0)
    {

        if (y & 1)
            res = (res * x) % p;

        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

bool square(ll n)
{
    double x;
    x = sqrt(n);
    if (x == floor(x))
        return true;
    else return false;
}

bool prime(ll n)
{
    ll i;
    for (i = 2; i * i <= n; i++)
    {
        if (n % i == 0)
            return false;
    }
    return true;
}

ll modi(ll a, ll m)
{
    return power(a, m - 2, m);

}
void kmp(string s, ll p[]) {
    int n = (int)s.length();
    p[0] = 0;
    for (int i = 1; i < n; i++) {
        int j = p[i - 1];
        while (j > 0 && s[i] != s[j])
            j = p[j - 1];
        if (s[i] == s[j])
            j++;
        p[i] = j;
    }

}
void zfunc(string s, ll z[]) {

    ll n = (ll)s.length();
    z[0] = 0;
    for (ll i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min(r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }

}
struct pair_hash {
    size_t operator()(const pair<int, int>& p) const noexcept {
        return hash<ll>() ((((ll)p.first) << 32) | ((ll)p.second));
    }
};

bool palin(string s) {
    ll i, n;
    n = s.length();
    for (i = 0; i <= n / 2; i++) {
        if (s[i] != s[n - i - 1]) {
            return false;
        }
    }
    return true;
}
ll sum(ll n) {
    ll i;
    i = n;
    ll sum = 0;
    while (i > 0) {
        sum += i % 10;
        i = i / 10;
    }
    return sum;
}

ll nCr(ll n, ll r, ll p, ll fac[])
{

    if (r == 0)
        return 1;
    fac[0] = 1;
    for (int i = 1; i <= n; i++)
        fac[i] = fac[i - 1] * i % p;

    return (fac[n] * modi(fac[r], p) % p *
        modi(fac[n - r], p) % p) % p;
}

ll gcd(ll a, ll b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
void bfs(vector<ll>& ans, ll k) {
    queue<ll> q;

    while (!q.empty()) {
        ll temp = q.front();

    }
}

void solve(ll l, ll r) {
    if (l >= r) {
        return;
    }
    if ((r - l) % 2 == 1) {
        ll start = (r + l) / 2 + 1;
        ll k = -1, j = 1;
        while (start != l) {

            printf("%lld %lld\n", start, start + k * j);
            //cout <<start <<" "<< start + k * j << endl;
            if (start + k * j == l) {
                break;
            }
            start += k * j;
            j++;
            k *= -1;

        }
    }
    else {
        ll start = (r + l) / 2;
        ll k = 1, j = 1;
        while (start != l) {

            printf("%lld %lld\n", start, start + k * j);
            //cout << start << " " << start + k * j << endl;
            if (start + k * j == l) {
                break;
            }
            start += k * j;
            j++;
            k *= -1;

        }
    }
}

void dfs(ll start, vector<ll> adj[], bool visited[], ll dp[], ll& maxi) {
    visited[start] = true;

    for (auto u : adj[start]) {
        if (!visited[u]) {
            visited[u] = true;
            dp[u] = max(dp[u], dp[start] + 1);
            dfs(u, adj, visited, dp, maxi);
            maxi = max(maxi, dp[u]);
        }

    }
}
float fab(float x) {
    if (x < 0) {
        return -x;
    }
    return x;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll t = 1, i, j;
    //cin >> t;

    while (t--) {
        ll n, m, k;
        cin >> n >> m >> k;
        vector<ll> a(n), b(m);
        for (i = 0; i < n; i++) {
            cin >> a[i];
        }
        for (i = 0; i < m; i++) {
            cin >> b[i];
        }
        ll cnt = 0;
        vector<ll> blockb(16000001), blocka(16000001);
        for (i = 0; i < m; i++) {
            cnt = 0;
            if (b[i] == 1) {
                while (b[i] == 1) {
                    cnt++;
                    i++;

                    if (i == m) {
                        break;
                    }
                }
                for (j = cnt; j >= 1; j--) {
                    blockb[j] += cnt - j + 1;
                }
            }
            else {
                continue;
            }
        }
        cnt = 0;
        for (i = 0; i < n; i++) {
            if (a[i] == 1) {
                cnt = 0;
                while (a[i] == 1) {
                    cnt++;

                    i++;
                    if (i == n) {
                        break;
                    }
                }

                for (j = cnt; j >= 1; j--) {
                    blocka[j] += cnt - j + 1;
               }
            }
            else {
                continue;
            }
        }
        ll ans = 0;

        vector<ll> factors;
        for (i = 1; i * i <= k; i++) {
            if (k % i == 0) {
                factors.pb(i);
                if (i * i != k) {
                    factors.pb(k / i);
                }
            }
        }

        for (auto u : factors) {
            //cout << u << " ";
            //cout << blocka[u] << " " << blockb[k / u] << endl;
            ans += blocka[u] * blockb[k / u];
        }
        cout << ans << endl;
    }

    return 0;
}


#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<deque>
#define pi 3.1415926535
#include<chrono>
#define float double
#define floa float
#define MOD 1000000007
#define INF 999999999999999999
#define pb push_back
#define ff first
#define ss second
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define f0 get<0>(temp)
#define f1 get<1>(temp)
#define f2 get<2>(temp)
using namespace std;
ll ncr(ll n, ll r)
{
    ll i, ans = 1, k = 0;
    if (r == 0)
        return 1;
    else if (n < r)
        return 0;
    for (i = n; i >= n - r + 1; i--)
    {
        ans *= i;
        ans /= n - i + 1;
    }

    return ans;

}
bool visited[6] = { false };
int n = 6;
vector<int> adj[6];

void max_heapify(int a[100], int i)
{
    int l, r, largest = i;
    l = 2 * i + 1;
    r = 2 * i + 2;
    if (l<n && a[l]>a[i])
        largest = l;
    if (r<n && a[r]>a[l])
        largest = r;
    if (largest != i)
    {
        int k;
        k = a[i];
        a[i] = a[largest];
        a[largest] = k;
        max_heapify(a, largest);
    }

}
int power(ll x, ll y, ll p)
{
    int res = 1;
    x = x % p;

    while (y > 0)
    {

        if (y & 1)
            res = (res * x) % p;

        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

bool square(ll n)
{
    double x;
    x = sqrt(n);
    if (x == floor(x))
        return true;
    else return false;
}

bool prime(ll n)
{
    ll i;
    for (i = 2; i * i <= n; i++)
    {
        if (n % i == 0)
            return false;
    }
    return true;
}

ll modi(ll a, ll m)
{
    return power(a, m - 2, m);

}
void kmp(string s, ll p[]) {
    int n = (int)s.length();
    p[0] = 0;
    for (int i = 1; i < n; i++) {
        int j = p[i - 1];
        while (j > 0 && s[i] != s[j])
            j = p[j - 1];
        if (s[i] == s[j])
            j++;
        p[i] = j;
    }

}
void zfunc(string s, ll z[]) {

    ll n = (ll)s.length();
    z[0] = 0;
    for (ll i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min(r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }

}
struct pair_hash {
    size_t operator()(const pair<int, int>& p) const noexcept {
        return hash<ll>() ((((ll)p.first) << 32) | ((ll)p.second));
    }
};

bool palin(string s) {
    ll i, n;
    n = s.length();
    for (i = 0; i <= n / 2; i++) {
        if (s[i] != s[n - i - 1]) {
            return false;
        }
    }
    return true;
}
ll sum(ll n) {
    ll i;
    i = n;
    ll sum = 0;
    while (i > 0) {
        sum += i % 10;
        i = i / 10;
    }
    return sum;
}

ll nCr(ll n, ll r, ll p, ll fac[])
{

    if (r == 0)
        return 1;
    fac[0] = 1;
    for (int i = 1; i <= n; i++)
        fac[i] = fac[i - 1] * i % p;

    return (fac[n] * modi(fac[r], p) % p *
        modi(fac[n - r], p) % p) % p;
}

ll gcd(ll a, ll b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
void bfs(vector<ll>& ans, ll k) {
    queue<ll> q;

    while (!q.empty()) {
        ll temp = q.front();

    }
}

void solve(ll l, ll r) {
    if (l >= r) {
        return;
    }
    if ((r - l) % 2 == 1) {
        ll start = (r + l) / 2 + 1;
        ll k = -1, j = 1;
        while (start != l) {

            printf("%lld %lld\n", start, start + k * j);
            //cout <<start <<" "<< start + k * j << endl;
            if (start + k * j == l) {
                break;
            }
            start += k * j;
            j++;
            k *= -1;

        }
    }
    else {
        ll start = (r + l) / 2;
        ll k = 1, j = 1;
        while (start != l) {

            printf("%lld %lld\n", start, start + k * j);
            //cout << start << " " << start + k * j << endl;
            if (start + k * j == l) {
                break;
            }
            start += k * j;
            j++;
            k *= -1;

        }
    }
}

void dfs(ll start, vector<ll> adj[], bool visited[], ll dp[], ll& maxi) {
    visited[start] = true;

    for (auto u : adj[start]) {
        if (!visited[u]) {
            visited[u] = true;
            dp[u] = max(dp[u], dp[start] + 1);
            dfs(u, adj, visited, dp, maxi);
            maxi = max(maxi, dp[u]);
        }

    }
}
float fab(float x) {
    if (x < 0) {
        return -x;
    }
    return x;
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll t = 1, i, j;
    //cin >> t;

    while (t--) {
        ll n, m, k;
        cin >> n >> m >> k;
        vector<ll> a(n), b(m);
        for (i = 0; i < n; i++) {
            cin >> a[i];
        }
        for (i = 0; i < m; i++) {
            cin >> b[i];
        }
        ll cnt = 0;
        map<ll,ll> blockb, blocka;
        for (i = 0; i < m; i++) {
            cnt = 0;
            if (b[i] == 1) {
                while (b[i] == 1) {
                    cnt++;
                    i++;

                    if (i == m) {
                        break;
                    }
                }
                for (j = cnt; j >= 1; j--) {
                    blockb[j] += cnt - j + 1;
                }
            }
            else {
                continue;
            }
        }
        cnt = 0;
        for (i = 0; i < n; i++) {
            if (a[i] == 1) {
                cnt = 0;
                while (a[i] == 1) {
                    cnt++;

                    i++;
                    if (i == n) {
                        break;
                    }
                }

                for (j = cnt; j >= 1; j--) {
                    blocka[j] += cnt - j + 1;
               }
            }
            else {
                continue;
            }
        }
        ll ans = 0;

        vector<ll> factors;
        for (i = 1; i * i <= k; i++) {
            if (k % i == 0) {
                factors.pb(i);
                if (i * i != k) {
                    factors.pb(k / i);
                }
            }
        }

        for (auto u : factors) {
            //cout << u << " ";
            //cout << blocka[u] << " " << blockb[k / u] << endl;
            ans += blocka[u] * blockb[k / u];
        }
        cout << ans << endl;
    }

    return 0;
}


#include <iostream>
#include <set>
#include <vector>
#include<algorithm>
using namespace std;

int main()
{
	int n, m, k;
	cin >> n >> m >> k;

	//set<int> d;

	vector<int> a;
	vector<int> b;

 /**	for (int i = 1; i <= sqrt(k); ++i)
	{
		if (k % i == 0) {
			d.insert(i);
			d.insert(k / i);
		}
	}

	for (auto i : d)
	{
		cout << (i) << "  ";
	}
	**/

	int cnt=0;

	for (int i = 0; i < n; ++i)
	{
		int x;
		cin >> x;
		if (x)
		{
			cnt++;
		}
		else if (cnt)
		{
			a.push_back(cnt);
			cnt = 0;
		}

	}
	if (cnt) {
		a.push_back(cnt);
	}

	 cnt = 0;

	for (int i = 0; i < m; ++i)
	{
		int x;
		cin >> x;
		if (x)
		{
			cnt++;
		}
		else if (cnt)
		{
			b.push_back(cnt);
			cnt = 0;
		}

	}
	if (cnt) {
		b.push_back(cnt);
	}

	vector<int> a1(max(m, n)+1);
	vector<int> b1(max(m, n)+1);

	for (auto i : a) {
		for (int j = 1, ad = i; j <= i; ++j, --ad)
		{
			a1[j] += ad;
		}
	}

	for (auto i : b) {
		for (int j = 1, ad = i; j <= i; ++j, --ad)
		{
			b1[j] += ad;
		}
	}

	long long res=0;

	int i = 1;

	for (; i * i <k; ++i) {
		if (k % i == 0 && (k / i) <= (max(n, m)))
		{
			res += a1[i] * b1[k / i];
			res += b1[i] * a1[k / i];
		}

	}

	if (i * i == k)
		res += a1[i] * b1[k / i];

	cout << res;

}


#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include<cstring>
#include<vector>
#include <cmath>
#include<ctime>
#include<deque>
#include<set>
#include<windows.h>
#include<unordered_map>
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define STDIN                      \
    freopen("in.txt", "r", stdin); \
    freopen("out.txt", "w", stdout);
using namespace std;
#define ll long long
#define int ll
// const ll N = 100;

// const int p = 998244353;
const int N = 4e4 + 10;
int a[N], b[N];
vector<pair<int, int >> pvec;

void get_divisors(int x)
{
    // vector<int> res;
    for (int i = 1; i <= x / i; i ++ )
        if (x % i == 0)
        {
            // res.push_back(i);
            if (i != x / i)
            {
                pvec.push_back({i, x / i});
            }
            else
            {
                pvec.push_back({i, i});
            }
        }
    // sort(res.begin(), res.end());
    // return res;
}

int f(int a[], int n, int x)
{
    int p1 = 1, p2 = 1;
    // bool flag = false;
    int res = 0;
    if (x > n) return 0;
    // cout << n << " " << x << endl;
    for (; p1<=n&& p2 <= n; p1++)
        {
            // cout << p1 << endl;
            if (a[p1] == 1)
            {
                p2 = p1;
                int cnt = 0;
                while(p2 <= n && a[p2++] == 1)
                {
                    cnt++;
                    if (cnt == x) {
                        res++;
                        break;

                    }
                }
                // cout << "cnt = " << cnt << endl;
            }
        }
        // cout << x << " " << res << endl;
        return res;
}
signed main()
{
    // STDIN
    int n, m, k; cin >> n >> m >> k;
    rep(i, 1, n) cin >> a[i];
    rep(i, 1, m) cin >> b[i];
    get_divisors(k);
    int ans = 0;
    for (auto i:pvec)
    {
        int x = i.first;
        int y = i.second;
        // cout << x << " " << y << endl;
        // cout << f(a, n, x)<< " " << f(b, m, y) << endl;;
        ans += f(a, n, x)*f(b, m, y);
        if (x!=y)
            ans += f(a, n, y)*f(b, m, x);
    }
    cout << ans << endl;
}


#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include<cstring>
#include<vector>
#include <cmath>
#include<ctime>
#include<deque>
#include<set>
#include<windows.h>
#include<unordered_map>
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define STDIN                      \
    freopen("in.txt", "r", stdin); \
    freopen("out.txt", "w", stdout);
using namespace std;
#define ll long long
#define int ll
// const ll N = 100;

// const int p = 998244353;
const int N = 4e4 + 10;
int a[N], b[N];
vector<pair<int, int >> pvec;

void get_divisors(int x)
{
    // vector<int> res;
    for (int i = 1; i <= x / i; i ++ )
        if (x % i == 0)
        {
            // res.push_back(i);
            if (i != x / i)
            {
                pvec.push_back({i, x / i});
            }
            else
            {
                pvec.push_back({i, i});
            }
        }
    // sort(res.begin(), res.end());
    // return res;
}

int f(int a[], int n, int x)
{
    int p1 = 1, p2 = x;
    // bool flag = false;
    int res = 0;
    if (x > n) return 0;
    // cout << n << " " << x << endl;
    int zero = 0, one = 0;
    rep(i, p1, p2)
    {
        if (a[i]) one++;else zero++;
    }
    if (one == x) res++;
    p1++,p2++;
    for (; p1<=n&& p2 <= n; p1++, p2++)
        {
            if (a[p1-1] == 1)
            {
                one--;
            }
            else zero--;
            if (a[p2]) one++; else zero++;
            if (one == x) res++;
        }
        // cout << x << " " << res << endl;
        return res;
}
signed main()
{
    // STDIN
    int n, m, k; cin >> n >> m >> k;
    rep(i, 1, n) cin >> a[i];
    rep(i, 1, m) cin >> b[i];
    get_divisors(k);
    int ans = 0;
    for (auto i:pvec)
    {
        int x = i.first;
        int y = i.second;
        // cout << x << " " << y << endl;
        // cout << f(a, n, x)<< " " << f(b, m, y) << endl;;
        ans += f(a, n, x)*f(b, m, y);
        if (x!=y)
            ans += f(a, n, y)*f(b, m, x);
    }
    cout << ans << endl;
}


#include <iomanip>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <map>
#include <string>

#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define free variable1
#define y0 var1

using namespace std;

const int N = 600010;
const int MOD = 1e9+7;
const int B = 28;

int n, m, k;
int a[N], b[N];
int x[N], y[N];

void calc(int *a, int *x, int n) {
    x[n + 1] = 0;
    for (int i = n; i >= 1; i--) {
        if (a[i] == 1) x[i] = x[i + 1] + 1;
        else x[i] = 0;
    }
}

int getcnt(int *x, int t, int n) {
    int l = 1, r = n;
    while (l + 1 < r) {
        int m = (l + r) / 2;
        if (x[m] < t) r = m - 1;
        else l = m;
    }
    if (x[r] >= t) return r;
    if (x[l] >= t) return l;
    return 0;
}

int solve(int w, int h) {
    //cout << w << " " << h << " " << getcnt(x, w, n) << " " << getcnt(y, h, m) << endl;
    return getcnt(x, w, n) * getcnt(y, h, m);
}

int main() {
    scanf("%d%d%d", &n, &m, &k);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 1; i <= m; i++) scanf("%d", &b[i]);
    calc(a, x, n);
    calc(b, y, m);
    sort(x + 1, x + n + 1);
    sort(y + 1, y + m + 1);
    reverse(x + 1, x + n + 1);
    reverse(y + 1, y + m + 1);
    ll ans = 0;
    for (int i = 1; i * i <= k; i++) {
        if (k % i == 0) {
            ans += solve(i, k / i);
            if (i * i != k) ans += solve(k / i, i);
        }
    }
    cout << ans;
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include <iostream>
#include<iomanip>
#include<vector>
using namespace std;
long long int f(int a[], int n,long long int k)
{
	long long int sum = 0,kk=0,p;
	for (int i = 0; i < n; i++)
	{
		if (a[i] == 1)
			sum++;
		else
		{
			p = sum - k + 1;
			if (p > 0)
				kk += p;
			sum = 0;
		}
	}
	p = sum - k + 1;
	if (p > 0)
		kk += p;
	return kk;
}
int a[40001], b[40001];
vector<int>v;
int main()
{
	int n, m;
	long long int k, x = 0, y = 0, ans = 0;
	cin >> n >> m >> k;
	int ii;
	for ( ii = 1; ii * ii < k; ii++)
	{
		if (k % ii == 0)
			v.push_back(ii), v.push_back(k / ii);
	}
	if (ii * ii == k)
		v.push_back(ii);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		x += a[i];
	}
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
		y += b[i];
	}
	for (int i = 0; i < v.size(); i++)
	{
		ans += f(a, n, v[i]) * f(b, m, k / v[i]);
	}
	cout << ans;
}


#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#pragma warning(disable : 4996)

#define all(v)             v.begin(),v.end()
#define sz(v)            ((int)((v).size()))
#define psh(x)                  push_back(x)
#define sc(x)                 scanf("%d",&x)
#define sc2(x,y)         scanf("%d%d",&x,&y)
#define scl(x)              scanf("%lld",&x)
#define lop(i,n)        for(register int i=0;i<n;i++)
#define loop(i,f,l)     for(register int i=f;i<l;i++)
#define R_(s)         freopen(s, "r", stdin)
#define W_(s)        freopen(s, "w", stdout)
#define R_W R_("input.txt"),W_("output.txt")
#define PI                        acos(-1.0)
#define INF                       1000000000
#define DFS_GRAY  -1
#define DFS_WHITE  0
#define DFS_BLACK  1

#define scc(x)           scanf("%c",&x)
#define mem(v, d)		memset(v, d, sizeof(v))
#define oo				2000000100
#define OO				4000000000000000100
typedef unsigned int uint;
typedef long long ll;

typedef string            ss;
typedef long long         ll;
typedef pair <int, int>   ii;
typedef pair<ss, int>     si;
typedef pair<int, ss>     is;
typedef pair<char, int>  chi;
typedef pair<ss, ss>     pss;
typedef vector<ii>       vii;
typedef vector<int>       vi;
typedef vector<vi>       vvi;
typedef vector<ss>        vs;
typedef vector<ll>       vll;
typedef vector<vll>     vvll;

//-----------------------------------------------------

const ll MOD = 1e9 + 7;

int dx[] = { 0,0,1,-1 };
int dy[] = { 1,-1,0,0 };

ll GCD(ll num, ll ones) { return !ones ? num : GCD(ones, num % ones); }
ll lcm(ll a, ll b) { return (a / GCD(a, b)) * b; }
double Len(int x, int y, int X, int Y) { return sqrt((X - x) * (X - x) + (Y - y) * (Y - y)); }
ll fastP(ll b, ll p)
{
	if (p == 0) return 1;
	else if (p == 1) return b;
	ll a = fastP(b, p / 2) % MOD;
	if (p % 2) return (((a * a) % MOD) * b) % MOD;
	else return (a * a) % MOD;
}
//----------------- ------   -------

const int N = 40010;
const double EPS = 1e-9;
int n, m, k;
int col[N], row[N];
set<int>s;
int dp[N];
int main()
{
	/*
	#ifndef ONLINE_JUDGE
		freopen("i.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	*/
	sc2(n, m);
	sc(k);
	int i;

	for ( i = 1; i * i < k; i++)
	{
		if (k % i == 0)
			s.insert(i),s.insert(k/i);

	}
	if (i * i == k)s.insert(i);

	int j = 0;
	lop(i, n)
	{
		int temp;
		sc(temp);
		if (!temp && !j&&!row[0])continue;
		if (temp > 0)
			row[j] += temp;
		else if(row[j])
			j++;

	}

	 j = 0;
	lop(i, m)
	{
		int temp;
		sc(temp);
		if (!temp && !j&&!col[0])continue;
		if (temp > 0)
			col[j] += temp;
		else if (col[j])
			j++;

	}

	for (auto ver : s)
	{
		int l = 0;
		if (ver <= n && k / ver <= m)
		{
			//l = 0;

			while (col[l])
			{
				if (k / ver <= col[l])
				{
					dp[ver] += 1;
					dp[ver] += col[l] - k / ver;
				}
				l++;
			}
		}
	}

	int l = 0;
	ll ans = 0;
	while (row[l])
	{
		for (auto ver : s)
		{
			if (ver > row[l])break;
				ans += (1+(row[l]-ver))* dp[ver];
		}
		l++;
	}
	cout << ans;
	return 0;
}


#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#pragma warning(disable : 4996)

#define all(v)             v.begin(),v.end()
#define sz(v)            ((int)((v).size()))
#define psh(x)                  push_back(x)
#define sc(x)                 scanf("%d",&x)
#define sc2(x,y)         scanf("%d%d",&x,&y)
#define scl(x)              scanf("%lld",&x)
#define lop(i,n)        for(register int i=0;i<n;i++)
#define loop(i,f,l)     for(register int i=f;i<l;i++)
#define R_(s)         freopen(s, "r", stdin)
#define W_(s)        freopen(s, "w", stdout)
#define R_W R_("input.txt"),W_("output.txt")
#define PI                        acos(-1.0)
#define INF                       1000000000
#define DFS_GRAY  -1
#define DFS_WHITE  0
#define DFS_BLACK  1

#define scc(x)           scanf("%c",&x)
#define mem(v, d)		memset(v, d, sizeof(v))
#define oo				2000000100
#define OO				4000000000000000100
typedef unsigned int uint;
typedef long long ll;

typedef string            ss;
typedef long long         ll;
typedef pair <int, int>   ii;
typedef pair<ss, int>     si;
typedef pair<int, ss>     is;
typedef pair<char, int>  chi;
typedef pair<ss, ss>     pss;
typedef vector<ii>       vii;
typedef vector<int>       vi;
typedef vector<vi>       vvi;
typedef vector<ss>        vs;
typedef vector<ll>       vll;
typedef vector<vll>     vvll;

//-----------------------------------------------------

const ll MOD = 1e9 + 7;

int dx[] = { 0,0,1,-1 };
int dy[] = { 1,-1,0,0 };

ll GCD(ll num, ll ones) { return !ones ? num : GCD(ones, num % ones); }
ll lcm(ll a, ll b) { return (a / GCD(a, b)) * b; }
double Len(int x, int y, int X, int Y) { return sqrt((X - x) * (X - x) + (Y - y) * (Y - y)); }
ll fastP(ll b, ll p)
{
	if (p == 0) return 1;
	else if (p == 1) return b;
	ll a = fastP(b, p / 2) % MOD;
	if (p % 2) return (((a * a) % MOD) * b) % MOD;
	else return (a * a) % MOD;
}
//----------------- ------   -------

const int N = 40010;
const double EPS = 1e-9;
int n, m, k;
int col[N], row[N];
set<int>s;
int dp[N];
int main()
{
	/*
	#ifndef ONLINE_JUDGE
		freopen("i.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	*/
	sc2(n, m);
	sc(k);
	int i;
	for ( i = 1; i * i < k; i++)
	{
		if (k % i == 0)
			s.insert(i),s.insert(k/i);

	}
	if (i * i == k)s.insert(i);

	int j = 0;
	lop(i, n)
	{
		int temp;
		sc(temp);
		if (!temp && !j&&!row[0])continue;
		if (temp > 0)
			row[j] += temp;
		else
			j++;

	}

	 j = 0;
	lop(i, m)
	{
		int temp;
		sc(temp);
		if (!temp && !j&&!col[0])continue;
		if (temp > 0)
			col[j] += temp;
		else
			j++;

	}

	for (auto ver : s)
	{
		if (ver <= n && k / ver <= m)
		{
			int l = 0;
			dp[ver] = 1;
			while (col[l])
			{
				dp[ver] += col[l] - k / ver;
				l++;
			}
		}
	}

	int l = 0;
	ll ans = 0;
	while (row[l])
	{
		for (auto ver : s)
		{
			if (ver > row[l])break;
			if (k / ver <= m)
			{
				ans += (1+(row[l]-ver))* dp[ver];
			}
		}
		l++;
	}
	cout << ans;
	return 0;
}


#include<iostream>
int a[40010],b[40010];
using namespace std;
int main ()
{   int n,m,s,h;
    cin>>n>>m>>s;
    int count=0;
    for(int i=1;i<=n;i++)
    {    cin>>h;
	   if(h==1)   count++;
	   if(h==0||i==n)
	   {    for(int j=1;j<=count;j++)
	           a[j]+=count-j+1;
	           count=0;
		 }
	}
	for(int i=1;i<=m;i++)
	  {   cin>>h;
	    if(h==1) count++;
	    if(h==0||i==m)
	    {
			   for(int j=1;j<=count;j++)
	              b[j]+=count-j+1;
		    count=0;
		}
	  }
	  long long sum=0;
	  for(int i=1;i<=n;i++)
	      if(s>=i&&s%i==0&&s/i<=m) sum+=a[i]*b[s/i];
	  cout<<sum;
	  return 0;
}


#include<iostream>
int a[40010],b[40010];
using namespace std;
int main ()
{   int n,m,s,h;
    cin>>n>>m>>s;
    int count=0;
    for(int i=1;i<=n;i++)
    {    cin>>h;
	   if(h==1)   count++;
	   if(h==0||i==n)
	   {    for(int j=1;j<=count;j++)
	           a[j]+=count-j+1;
	           count=0;
		 }
	}
	for(int i=1;i<=m;i++)
	  {   cin>>h;
	    if(h==1) count++;
	    if(h==0||i==m)
	    {
			   for(int j=1;j<=count;j++)
	              b[j]+=count-j+1;
		    count=0;
		}
	  }
	  long long sum=0;
	  for(int i=1;i<=n;i++)
	      if(s>=i&&s%i==0) sum+=a[i]*b[s/i];
	  cout<<sum;
	  return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;

int A[40'005];
int B[40'005];
int A_cnt[40'005], B_cnt[40'005];
vector<int>A_exist;
vector<int>B_exist;

int main() {
	cin.tie(NULL);
	cout.tie(NULL);
	int N, M;
	long long K;
	cin >> N >> M >> K;
	int one_pos = -1;
	for (int n = 0; n < N; n++) {
		cin >> A[n];
		if (A[n] == 0) {
			if (one_pos == -1) {
				continue;
			}
			else {
				if (A_cnt[n - one_pos] == 0) {
					A_exist.push_back(n - one_pos);
				}
				A_cnt[n - one_pos]++;
				one_pos = -1;
			}
		}
		else {
			if (one_pos == -1) {
				one_pos = n;
				continue;
			}
			else {
				continue;
			}
		}
	}
	if (A_cnt[N - one_pos] == 0) {
		A_exist.push_back(N- one_pos);
	}
	A_cnt[N - one_pos]++;
	one_pos = -1;
	for (int m = 0; m < M; m++) {
		cin >> B[m];
		if (B[m] == 0) {
			if (one_pos == -1) {
				continue;
			}
			else {
				if (B_cnt[m - one_pos] == 0) {
					B_exist.push_back(m - one_pos);
				}
				B_cnt[m - one_pos]++;
				one_pos = -1;
			}
		}
		else {
			if (one_pos == -1) {
				one_pos = m;
				continue;
			}
			else {
				continue;
			}
		}
	}
	if (B_cnt[M- one_pos] == 0) {
		B_exist.push_back(M - one_pos);
	}
	B_cnt[M - one_pos]++;
	sort(A_exist.begin(), A_exist.end());
	sort(B_exist.begin(), B_exist.end());

	int sum = 0;
	for (ll i = 1; i <= sqrt(K); i++) {
		if (K % i == 0) {
			ll b_mod = K / i;
			int a_sum = 0, b_sum = 0;
			for (int a : A_exist) {
				if (a >= i) {
					a_sum+=(a - i + 1)*A_cnt[a];
				}
			}
			for (int b : B_exist) {
				if (b >= b_mod) {
					b_sum += (b - b_mod + 1)*B_cnt[b];
				}
			}
			sum += a_sum * b_sum;
		}
	}
	cout << sum;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;

int A[40'005];
int B[40'005];
int A_cnt[40'005], B_cnt[40'005];
vector<int>A_exist;
vector<int>B_exist;

int main() {
	cin.tie(NULL);
	cout.tie(NULL);
	int N, M;
	long long K;
	cin >> N >> M >> K;
	int one_pos = -1;
	for (int n = 0; n < N; n++) {
		cin >> A[n];
		if (A[n] == 0) {
			if (one_pos == -1) {
				continue;
			}
			else {
				if (A_cnt[n - one_pos] == 0) {
					A_exist.push_back(n - one_pos);
				}
				A_cnt[n - one_pos]++;
				one_pos = -1;
			}
		}
		else {
			if (one_pos == -1) {
				one_pos = n;
				continue;
			}
			else {
				continue;
			}
		}
	}
	if (A_cnt[N - one_pos] == 0) {
		A_exist.push_back(N- one_pos);
	}
	A_cnt[N - one_pos]++;
	one_pos = -1;
	for (int m = 0; m < M; m++) {
		cin >> B[m];
		if (B[m] == 0) {
			if (one_pos == -1) {
				continue;
			}
			else {
				if (B_cnt[m - one_pos] == 0) {
					B_exist.push_back(m - one_pos);
				}
				B_cnt[m - one_pos]++;
				one_pos = -1;
			}
		}
		else {
			if (one_pos == -1) {
				one_pos = m;
				continue;
			}
			else {
				continue;
			}
		}
	}
	if (B_cnt[M- one_pos] == 0) {
		B_exist.push_back(M - one_pos);
	}
	B_cnt[M - one_pos]++;
	sort(A_exist.begin(), A_exist.end());
	sort(B_exist.begin(), B_exist.end());

	int sum = 0;
	for (ll i = 1; i <= sqrt(K); i++) {
		if (K % i == 0) {
			bool flag = false;
			ll b_mod = K / i;
			int a_sum = 0, b_sum = 0;
			for (int a : A_exist) {
				if (a >= i) {
					a_sum+=(a - i + 1)*A_cnt[a];
				}
			}
			for (int b : B_exist) {
				if (b >= b_mod) {
					b_sum += (b - b_mod + 1)*B_cnt[b];
				}
			}
			if (b_sum == 0 || a_sum == 0)flag = true;
			sum += a_sum * b_sum;
			if (flag) {
				a_sum = 0; b_sum = 0;
				for (int a : A_exist) {
					if (a >= b_mod) {
						a_sum += (a - b_mod + 1) * A_cnt[a];
					}
				}
				for (int b : B_exist) {
					if (b >= i) {
						b_sum += (b - i + 1) * B_cnt[b];
					}
				}
				sum += a_sum * b_sum;
			}
		}
	}
	cout << sum;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;

ll A[40'005];
ll B[40'005];
ll A_cnt[40'005], B_cnt[40'005];
vector<ll>A_exist;
vector<ll>B_exist;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll N, M;
	long long K;
	cin >> N >> M >> K;
	ll one_pos = -1;
	for (ll n = 0; n < N; n++) {
		cin >> A[n];
		if (A[n] == 0) {
			if (one_pos == -1) {
				continue;
			}
			else {
				if (A_cnt[n - one_pos] == 0) {
					A_exist.push_back(n - one_pos);
				}
				A_cnt[n - one_pos]++;
				one_pos = -1;
			}
		}
		else {
			if (one_pos == -1) {
				one_pos = n;
				continue;
			}
			else {
				continue;
			}
		}
	}
	if (one_pos != -1) {
		if (A_cnt[N - one_pos] == 0) {
			A_exist.push_back(N - one_pos);
		}
		A_cnt[N - one_pos]++;
	}
	one_pos = -1;

	for (ll m = 0; m < M; m++) {
		cin >> B[m];
		if (B[m] == 0) {
			if (one_pos == -1) {
				continue;
			}
			else {
				if (B_cnt[m - one_pos] == 0) {
					B_exist.push_back(m - one_pos);
				}
				B_cnt[m - one_pos]++;
				one_pos = -1;
			}
		}
		else {
			if (one_pos == -1) {
				one_pos = m;
				continue;
			}
			else {
				continue;
			}
		}
	}
	if (one_pos != -1) {
		if (B_cnt[M - one_pos] == 0) {
			B_exist.push_back(M - one_pos);
		}
		B_cnt[M - one_pos]++;
	}

	ll sum = 0;
	for (ll i = 1; i <= sqrt(K); i++) {
		if (K % i == 0) {
			bool flag = false;
			ll b_mod = K / i;
			ll a_sum = 0, b_sum = 0;
			for (ll a : A_exist) {
				if (a >= i) {
					a_sum+=(a - i + 1)*A_cnt[a];
				}
			}
			for (ll b : B_exist) {
				if (b >= b_mod) {
					b_sum += (b - b_mod + 1)*B_cnt[b];
				}
			}
			sum += a_sum * b_sum;

			if (i != b_mod)flag = true;
			if (flag) {
				a_sum = 0; b_sum = 0;
				for (ll a : A_exist) {
					if (a >= b_mod) {
						a_sum += (a - b_mod + 1) * A_cnt[a];
					}
				}
				for (ll b : B_exist) {
					if (b >= i) {
						b_sum += (b - i + 1) * B_cnt[b];
					}
				}
				sum += a_sum * b_sum;
			}
		}
	}
	cout << sum;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;

int A[40'005];
int B[40'005];
int A_cnt[40'005], B_cnt[40'005];
vector<int>A_exist;
vector<int>B_exist;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int N, M;
	long long K;
	cin >> N >> M >> K;
	int one_pos = -1;
	for (int n = 0; n < N; n++) {
		cin >> A[n];
		if (A[n] == 0) {
			if (one_pos == -1) {
				continue;
			}
			else {
				if (A_cnt[n - one_pos] == 0) {
					A_exist.push_back(n - one_pos);
				}
				A_cnt[n - one_pos]++;
				one_pos = -1;
			}
		}
		else {
			if (one_pos == -1) {
				one_pos = n;
				continue;
			}
			else {
				continue;
			}
		}
	}
	if (one_pos != -1) {
		if (A_cnt[N - one_pos] == 0) {
			A_exist.push_back(N - one_pos);
		}
		A_cnt[N - one_pos]++;
	}
	one_pos = -1;

	for (int m = 0; m < M; m++) {
		cin >> B[m];
		if (B[m] == 0) {
			if (one_pos == -1) {
				continue;
			}
			else {
				if (B_cnt[m - one_pos] == 0) {
					B_exist.push_back(m - one_pos);
				}
				B_cnt[m - one_pos]++;
				one_pos = -1;
			}
		}
		else {
			if (one_pos == -1) {
				one_pos = m;
				continue;
			}
			else {
				continue;
			}
		}
	}
	if (one_pos != -1) {
		if (B_cnt[M - one_pos] == 0) {
			B_exist.push_back(M - one_pos);
		}
		B_cnt[M - one_pos]++;
	}

	int sum = 0;
	for (ll i = 1; i <= sqrt(K); i++) {
		if (K % i == 0) {
			bool flag = false;
			ll b_mod = K / i;
			int a_sum = 0, b_sum = 0;
			for (int a : A_exist) {
				if (a >= i) {
					a_sum+=(a - i + 1)*A_cnt[a];
				}
			}
			for (int b : B_exist) {
				if (b >= b_mod) {
					b_sum += (b - b_mod + 1)*B_cnt[b];
				}
			}
			sum += a_sum * b_sum;

			if (i != b_mod)flag = true;
			if (flag) {
				a_sum = 0; b_sum = 0;
				for (int a : A_exist) {
					if (a >= b_mod) {
						a_sum += (a - b_mod + 1) * A_cnt[a];
					}
				}
				for (int b : B_exist) {
					if (b >= i) {
						b_sum += (b - i + 1) * B_cnt[b];
					}
				}
				sum += a_sum * b_sum;
			}
		}
	}
	cout << sum;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;

int A[40'005];
int B[40'005];
int A_cnt[40'005], B_cnt[40'005];
vector<int>A_exist;
vector<int>B_exist;

int main() {
	cin.tie(NULL);
	cout.tie(NULL);
	int N, M;
	long long K;
	cin >> N >> M >> K;
	int one_pos = -1;
	for (int n = 0; n < N; n++) {
		cin >> A[n];
		if (A[n] == 0) {
			if (one_pos == -1) {
				continue;
			}
			else {
				if (A_cnt[n - one_pos] == 0) {
					A_exist.push_back(n - one_pos);
				}
				A_cnt[n - one_pos]++;
				one_pos = -1;
			}
		}
		else {
			if (one_pos == -1) {
				one_pos = n;
				continue;
			}
			else {
				continue;
			}
		}
	}
	if (A_cnt[N - one_pos] == 0) {
		A_exist.push_back(N- one_pos);
	}
	A_cnt[N - one_pos]++;
	one_pos = -1;

	for (int m = 0; m < M; m++) {
		cin >> B[m];
		if (B[m] == 0) {
			if (one_pos == -1) {
				continue;
			}
			else {
				if (B_cnt[m - one_pos] == 0) {
					B_exist.push_back(m - one_pos);
				}
				B_cnt[m - one_pos]++;
				one_pos = -1;
			}
		}
		else {
			if (one_pos == -1) {
				one_pos = m;
				continue;
			}
			else {
				continue;
			}
		}
	}
	if (B_cnt[M- one_pos] == 0) {
		B_exist.push_back(M - one_pos);
	}
	B_cnt[M - one_pos]++;

	sort(A_exist.begin(), A_exist.end());
	sort(B_exist.begin(), B_exist.end());

	int sum = 0;
	for (ll i = 1; i <= sqrt(K); i++) {
		if (K % i == 0) {
			bool flag = false;
			ll b_mod = K / i;
			int a_sum = 0, b_sum = 0;
			for (int a : A_exist) {
				if (a >= i) {
					a_sum+=(a - i + 1)*A_cnt[a];
				}
			}
			for (int b : B_exist) {
				if (b >= b_mod) {
					b_sum += (b - b_mod + 1)*B_cnt[b];
				}
			}
			if (i != b_mod)flag = true;
			sum += a_sum * b_sum;
			if (flag) {
				a_sum = 0; b_sum = 0;
				for (int a : A_exist) {
					if (a >= b_mod) {
						a_sum += (a - b_mod + 1) * A_cnt[a];
					}
				}
				for (int b : B_exist) {
					if (b >= i) {
						b_sum += (b - i + 1) * B_cnt[b];
					}
				}
				sum += a_sum * b_sum;
			}
		}
	}
	cout << sum;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;

ll A[40'005];
ll B[40'005];
ll A_cnt[40'005], B_cnt[40'005];
vector<ll>A_exist;
vector<ll>B_exist;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll N, M;
	long long K;
	cin >> N >> M >> K;
	ll one_pos = -1;
	for (ll n = 0; n < N; n++) {
		cin >> A[n];
		if (A[n] == 0) {
			if (one_pos == -1) {
				continue;
			}
			else {
				if (A_cnt[n - one_pos] == 0) {
					A_exist.push_back(n - one_pos);
				}
				A_cnt[n - one_pos]++;
				one_pos = -1;
			}
		}
		else {
			if (one_pos == -1) {
				one_pos = n;
				continue;
			}
			else {
				continue;
			}
		}
	}
	if (one_pos != -1) {
		if (A_cnt[N - one_pos] == 0) {
			A_exist.push_back(N - one_pos);
		}
		A_cnt[N - one_pos]++;
	}
	one_pos = -1;

	for (ll m = 0; m < M; m++) {
		cin >> B[m];
		if (B[m] == 0) {
			if (one_pos == -1) {
				continue;
			}
			else {
				if (B_cnt[m - one_pos] == 0) {
					B_exist.push_back(m - one_pos);
				}
				B_cnt[m - one_pos]++;
				one_pos = -1;
			}
		}
		else {
			if (one_pos == -1) {
				one_pos = m;
				continue;
			}
			else {
				continue;
			}
		}
	}
	if (one_pos != -1) {
		if (B_cnt[M - one_pos] == 0) {
			B_exist.push_back(M - one_pos);
		}
		B_cnt[M - one_pos]++;
	}

	int sum = 0;
	for (ll i = 1; i <= sqrt(K); i++) {
		if (K % i == 0) {
			bool flag = false;
			ll b_mod = K / i;
			ll a_sum = 0, b_sum = 0;
			for (ll a : A_exist) {
				if (a >= i) {
					a_sum+=(a - i + 1)*A_cnt[a];
				}
			}
			for (ll b : B_exist) {
				if (b >= b_mod) {
					b_sum += (b - b_mod + 1)*B_cnt[b];
				}
			}
			sum += a_sum * b_sum;

			if (i != b_mod)flag = true;
			if (flag) {
				a_sum = 0; b_sum = 0;
				for (ll a : A_exist) {
					if (a >= b_mod) {
						a_sum += (a - b_mod + 1) * A_cnt[a];
					}
				}
				for (ll b : B_exist) {
					if (b >= i) {
						b_sum += (b - i + 1) * B_cnt[b];
					}
				}
				sum += a_sum * b_sum;
			}
		}
	}
	cout << sum;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;

int A[40'005];
int B[40'005];
int A_cnt[40'005], B_cnt[40'005];
vector<int>A_exist;
vector<int>B_exist;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int N, M;
	long long K;
	cin >> N >> M >> K;
	int one_pos = -1;
	for (int n = 0; n < N; n++) {
		cin >> A[n];
		if (A[n] == 0) {
			if (one_pos == -1) {
				continue;
			}
			else {
				if (A_cnt[n - one_pos] == 0) {
					A_exist.push_back(n - one_pos);
				}
				A_cnt[n - one_pos]++;
				one_pos = -1;
			}
		}
		else {
			if (one_pos == -1) {
				one_pos = n;
				continue;
			}
			else {
				continue;
			}
		}
	}
	if (one_pos != -1) {
		if (A_cnt[N - one_pos] == 0) {
			A_exist.push_back(N - one_pos);
		}
		A_cnt[N - one_pos]++;
	}
	one_pos = -1;

	for (int m = 0; m < M; m++) {
		cin >> B[m];
		if (B[m] == 0) {
			if (one_pos == -1) {
				continue;
			}
			else {
				if (B_cnt[m - one_pos] == 0) {
					B_exist.push_back(m - one_pos);
				}
				B_cnt[m - one_pos]++;
				one_pos = -1;
			}
		}
		else {
			if (one_pos == -1) {
				one_pos = m;
				continue;
			}
			else {
				continue;
			}
		}
	}
	if (one_pos != -1) {
		if (B_cnt[M - one_pos] == 0) {
			B_exist.push_back(M - one_pos);
		}
		B_cnt[M - one_pos]++;
	}
	sort(A_exist.begin(), A_exist.end());
	sort(B_exist.begin(), B_exist.end());

	int sum = 0;
	for (ll i = 1; i <= sqrt(K); i++) {
		if (K % i == 0) {
			bool flag = false;
			ll b_mod = K / i;
			int a_sum = 0, b_sum = 0;
			for (int a : A_exist) {
				if (a >= i) {
					a_sum+=(a - i + 1)*A_cnt[a];
				}
			}
			for (int b : B_exist) {
				if (b >= b_mod) {
					b_sum += (b - b_mod + 1)*B_cnt[b];
				}
			}
			sum += a_sum * b_sum;

			if (i != b_mod)flag = true;
			if (flag) {
				a_sum = 0; b_sum = 0;
				for (int a : A_exist) {
					if (a >= b_mod) {
						a_sum += (a - b_mod + 1) * A_cnt[a];
					}
				}
				for (int b : B_exist) {
					if (b >= i) {
						b_sum += (b - i + 1) * B_cnt[b];
					}
				}
				sum += a_sum * b_sum;
			}
		}
	}
	cout << sum;
}


#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <string>
#include <iomanip>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <limits>
#include <fstream>
#include <stack>

using namespace std;

typedef long long li;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define fr first
#define sc second
#define pb push_back
#define mp make_pair
#define forn(i, n) for(int i = 0; i < int(n); ++i)
#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
#define forb(i, n) for(int i = int(n) - 1; i >= 0; --i)

const int INF = 1e9 + 1000;
const li INF64 = 1e18 + 1000;

const int N = 2 * 1e5 + 1000;
const int MOD = 1e9 + 7;
const double EPS = 1E-9;

void spr(int x) { cout << setprecision(x) << fixed; }

int count(vi a, vi b, li need_a, li need_b) {
	li in_a = 0, in_b = 0;

	li cur_a = 0, cur_b = 0;

	for (auto it : a) {
		if (it == 0) cur_a = 0;
		else {
			cur_a++;
			if (cur_a >= need_a) ++in_a;
		}
	}
	for (auto it : b) {
		if (it == 0) cur_b = 0;
		else {
			cur_b++;
			if (cur_b >= need_b) ++in_b;
		}
	}

	return in_a * in_b;
}

int main() {

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, m;

	cin >> n >> m;
	li k;
	cin >> k;
	vi a(n), b(m);

	forn(i, n)
		cin >> a[i];

	forn(i, m)
		cin >> b[i];

	li ans = 0;
	for (li i = 1; i * i <= k; ++i) {
		if (k % i) continue;

		li need_a = i, need_b = k / i;

		li extr = count(a, b, need_b, need_a);
		ans += count(a, b, need_a, need_b);

		if (need_a != need_b)
			ans += extr;
	}

	cout << ans;

}


#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <string>
#include <iomanip>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <limits>
#include <fstream>
#include <stack>

using namespace std;

typedef long long li;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define fr first
#define sc second
#define pb push_back
#define mp make_pair
#define forn(i, n) for(int i = 0; i < int(n); ++i)
#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
#define forb(i, n) for(int i = int(n) - 1; i >= 0; --i)

const int INF = 1e9 + 1000;
const li INF64 = 1e18 + 1000;

const int N = 2 * 1e5 + 1000;
const int MOD = 1e9 + 7;
const double EPS = 1E-9;

void spr(int x) { cout << setprecision(x) << fixed; }

int main() {

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n, m, k;

	cin >> n >> m >> k;
	vi a(n), b(m);

	forn(i, n)
		cin >> a[i];

	forn(i, m)
		cin >> b[i];

	li ans = 0;
	for (int i = 1; i * i <= k; ++i) {
		if (k % i) continue;

		int need_a = i, need_b = k / i;

		int in_a = 0, in_b = 0;

		int cur_a = 0, cur_b = 0;

		for (auto it : a) {
			if (it == 0) cur_a = 0;
			else {
				cur_a++;
				if (cur_a >= need_a) ++in_a;
			}
		}
		for (auto it : b) {
			if (it == 0) cur_b = 0;
			else {
				cur_b++;
				if (cur_b >= need_b) ++in_b;
			}
		}

		ans += in_a * 1ll * in_b;
	}

	cout << ans;

}