In New York City, high-strung stockbroker Joy Ellis McNally (Cameron Diaz) is dumped by her fiancé at his surprise birthday she threw for him in front of all their friends while at the same time easy-going carpenter Jack Fuller (Ashton Kutcher) is fired from his job by his father, Jack, Sr. (Treat Williams). Both become emotionally distraught and, with their best friends Stripper (Lake Bell), a bartender and Shitter (Rob Corddry), a District Attorney, take a debauched trip to Las Vegas. They meet by chance when they are given the same hotel room because of a computer error. After clearing up the misunderstanding and receiving upgraded rooms and coupons to various clubs, they party and drink together and Joy and Jack end up getting married. The next morning, they realize it was a mistake and decide to divorce.Before they do so, Jack uses a quarter Joy gives him in a slot machine. He hits a $3,000,000 dollar jackpot and Joy reminds Jack that they are married and hence, she is entitled to half of the money. The couple returns to New York, where they attempt to divorce. Their judge (Dennis Miller) declares that the couple cannot divorce until they attempt to co-exist for six months, while attending weekly sessions with a marriage counselor (Queen Latifah). If they work at the marriage but still want to divorce after six months, each will be permitted to keep half the winnings. If either party does not cooperate, the money will be tied up in litigation by the judge.The newlyweds devise more and more cunning schemes to undermine each other, such as Jack telling Joy that their counseling session is canceled to prove she's not committed, and Joy inviting girls to their apartment to try to get Jack to cheat on her. Jack gives Joy's ex-fiancé Mason (Jason Sudeikis), her engagement ring back without Joy knowing. At Joy's job retreat, Jack and Joy ironically find themselves developing an unexpected sexual attraction to one another and they soon realize that being with each other has brought out the best in both of them.After they get back from the retreat, it's time for the judge to decide what happens to the money. On her way to the hearing, Joy sees her ex-fiancé Mason and he tells her that he wants her back. He gives her back the engagement ring and tells her that she is good enough for him. Joy realizes that Jack set her up to get back with him, therefore cheating on him and letting Jack keep the money. Joy walks away from Mason and goes to the hearing. At the hearing, their marriage counselor testifies that the couple truly tried to work on their marriage. The judge decides that they each get 1.5 million dollars, taking away taxes and the bills Joy had run up and Jack had spent on his new woodworking business. Joy tells the judge she doesn't want any money, and gives the engagement ring to Jack, telling him she officially doesn't want anything from him. Jack realizes she knows that he talked to Mason.Joy ends up getting the promotion, but tells her boss that she would rather be happy doing nothing than doing something she hated and being miserable. The next scene is of Jack talking to his parents, and them telling him that it looked like he and Joy were actually in love. Realizing his mistake, he goes to her friend Stripper to find out where she is. Stripper tells Jack that she quit her job - a fact she seems quite disgruntled by - and that nobody knows where she is. He has a suspicion that she has gone to a beach (Fire Island, New York) that she told him about, the only place that makes her feel truly happy. Jack asks her to be his wife (again) and she says yes. As the two embrace, Joy says that she quit her job and has no idea what she's going to do. Jack reminds her that they have a lot of money between them. Joy states that they hit the jackpot, to which Jack replies that he certainly did (referring both to the money and to Joy).In the credits it shows a clip of what happened between Stripper and Shitter the day Jack and Joy got married. It also shows Stripper and Shitter subsequently enacting a plan of revenge on Mason, devised by Stripper earlier in the film.In a post-credits scene, Dave is telling Shitter about a party that evening, but Shitter no longer wants to associate with Dave, citing Jack as being "the glue" that held the two of them together as friends. With that, Shitter simply leaves. The movie ends with Dave randomly asking a random guy on the street if he wants to party.
Output: Question: what did the judge make the couple do before he granted them the money?, Answer: He made them try to work on their marriage.