If both parents file tax returns claiming the same child as a dependent, the IRS will send a letter to each parent asking for additional documentation to support the dependency claim. Then the IRS will decide who receives the exemption.
If one parent e-files ahead of the other, then the second parent's attempt to e-file will most likely be rejected because the child's social security number already appears on a filed return. The second parent can still list the child as a dependent, but that parent will have to file a paper return.
Regarding the documentation to prove your child lived with you (and for how long), here is a helpful link to IRS Topic 654 which covers such documentation. The topic is divided into sections. Note the section entitled Earned Income Credit where the IRS discusses the particular documentation acceptable for proving that your child lived with you: https://www.irs.gov/taxtopics/tc654.html