One of the most basic questions one can ask about a graph H is: how many H-free graphs on n vertices are there? For non-bipartite H, the answer to this question has been well-understood since 1986, when Erdős, Frankl and Rödl proved that there are 2 (1+o(1))ex(n,H) such graphs. For bipartite graphs, however, much less is known: even the weaker bound 2 O(ex(n,H)) has been proven in only a few special cases: for cycles of length four and six, and for some complete bipartite graphs.For even cycles, Bondy and Simonovits proved in the 1970s that ex(n, C 2ℓ ) = O n 1+1/ℓ , and this bound is conjectured to be sharp up to the implicit constant. In this paper we prove that the number of C 2ℓ -free graphs on n vertices is at most 2 O(n 1+1/ℓ ) , confirming a conjecture of Erdős. Our proof uses the hypergraph container method, which was developed recently (and independently) by Balogh, Morris and Samotij, and by Saxton and Thomason, together with a new 'balanced supersaturation theorem' for even cycles. We moreover show that there are at least 2 (1+c)ex(n,C6) C 6 -free graphs with n vertices for some c > 0 and infinitely many values of n ∈ N, disproving a well-known and natural conjecture. As a further application of our method, we essentially resolve the so-called Turán problem on the Erdős-Rényi random graph G(n, p) for both even cycles and complete bipartite graphs.Research supported in part by a CNPq bolsa PDJ (DS) and by CNPq Proc. 479032/2012-2 and Proc. 303275/2013-8 (RM). 1 1.1. History and background. The study of extremal graph theory was initiated roughly 70 years ago by Turán [52], who determined exactly the extremal number of the complete graph, by Erdős and Stone [29], who determined asymptotically (for all r 3) the extremal number of a complete r-partite graph 1 , and by Kővári, Sós and Turán [41] who showed that ex(n, K s,t ) = O(n 2−1/s ), where K s,t denotes the complete bipartite graph with part sizes s and t. (The case K 2,2 = C 4 was solved some years earlier by Erdős [21] during his study of multiplicative Sidon sets.) Over the following decades, a huge amount of effort was put into determining more precise bounds for specific families of graphs (see, e.g., [11,31]), and a great deal of progress has been made. Nevertheless, the order of magnitude of ex(n, H) for most bipartite graphs, including simple examples such as K 4,4 and C 8 , remains unknown.In the 1970s, the problem of determining the number of H-free graphs on n vertices was introduced by Erdős, Kleitman and Rothschild [23], who proved that there are 2 (1+o(1))ex(n,Kr) K r -free graphs, and moreover that almost all triangle-free graphs are bipartite. This latter result was extended to all cliques by Kolaitis, Prömel and Rothschild [39] and to more general graphs by Prömel and Steger [46], and the former to all non-bipartite graphs by Erdős, Frankl and Rödl [24], using Szemerédi's regularity lemma. The corresponding result for k-uniform hypergraphs was proved by Nagle, Rödl and Schacht [44] using hypergraph regularity, and reproved by Balogh,...