Upper bounds on the number of perfect matchings and directed 2-factors in graphs with given number of vertices and edges