#include<iostream> #include<cstdio> #include<vector> #define maxn 200010 #define ll long long usingnamespacestd;
int n, m; ll k;
vector<int> a[maxn], b[maxn]; vector<ll> s[maxn];
inline ll get_sum(int k, int l, int r){ return s[k][r] - s[k][l - 1]; }
voidwork(){ cin >> n >> m >> k; for (int i = 1; i <= n; ++i) b[i].resize(m + 1); for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) { int x; cin >> x; b[i][j] = x; } if (n > m) { for (int i = 1; i <= m; ++i) a[i].resize(n + 1); for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) a[j][i] = b[i][j]; swap(n, m); } elsefor (int i = 1; i <= n; ++i) a[i] = b[i]; for (int i = 1; i <= m; ++i) { s[i].resize(n + 1); for (int j = 1; j <= n; ++j) s[i][j] = s[i][j - 1] + a[j][i]; } ll ans = 0; for (int i = 1; i <= n; ++i) for (int j = i; j <= n; ++j) { int r = 0; ll sum = 0; for (int l = 1; l <= m; ++l) { while (r < m && sum + get_sum(r + 1, i, j) <= k) ++r, sum += get_sum(r, i, j); ans += r - l + 1; sum -= get_sum(l, i, j); } } cout << ans << "\n"; }