The emergence of cloud computing has established a trend towards building energy-hungry and geographically distributed data centers. Due to their enormous energy consumption, data centers are expected to have major impact on the electric power grid by significantly increasing the load at locations where they are built. Dynamic energy pricing policies in the recently proposed smart grid technology can incentivize the cloud computing controller to shift their computation load towards data centers in regions with cheaper electricity. On the other hand, distributed data centers also provide opportunities to help the smart grid to improve load balancing and robustness. To shed some light into these opportunities, this paper considers an interaction system of the smart grid, the cloud computing system, and other load devices. A nested two stage game based formulation is proposed based on the location-dependent real-time pricing policy of the smart grid. The leading player in this game is the smart grid controller that announces the relationship between the electricity price at each power bus and the total load demand at that bus. In the second stage, the cloud computing controller performs resource allocation as response to the pricing functions, whereas the other load devices perform demand side management. The objective of the smart grid controller is to maximize its own profit and perform load balancing among power buses, whereas the objective of the cloud computing controller is to maximize its own profit with respect to the location-dependent pricing functions. The optimal strategies are derived based on the backward induction principle for the smart grid controller, the cloud computing controller, and the other load devices, using convex optimization and heuristic search.