Investigating the association between cancer and dementia risk: a longitudinal cohort study