#include #include #include using namespace std; using int64 = long long; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n,m,k; cin >> n >> m >> k; char op; cin >> op; bool plus = op == '+'; vector bk(k,0); vector ak(k,0); int i,j; int a,b; for (i=0; i> b; bk[b % k]++; } for (i=0; i> a; ak[a % k]++; } int64 ans = 0; if (plus) { for (i=0; i