On the first morning, see the masterworks in the Museo del Prado and tour the Paseo del Prado between Estación de Atocha and Plaza Colón, past the fountains at Fuente de Neptuno and the Plaza de la Cibeles. Have lunch in or near Plaza Santa Ana. Then cut through the Puerta del Sol to see Madrid's Times Square -- where locals in Madrid gather to ring in the New Year -- on your way to the Plaza Mayor. Cut behind the glass-and-iron Mercado de San Miguel and through tiny Calle Puñonrostro to Plaza de la Villa on your way to the church of San Nícolas de los Servitas and then the Plaza de Oriente, where you can tour the Palacio Real and the Teatro Real. If it's summer, take in the sunset from a terrace table at El Ventorrillo at the south end of Calle Bailén's Viaducto. Later, visit the tapas bars along Cava de San Miguel and end by having a drink on Plaza de la Paja or at the Café Marula terrace under the Puente de Segovia.
On Day 2, see Picasso's Guernica and other works at the Centro de Arte Reina Sofía. Have lunch on Cava Baja, in La Latina, and visit the nearby Basílica de San Francisco el Grande. If you have room for more art, explore the Museo Thyssen-Bornemisza, and take a stroll at sunset or earlier in the Parque del Buen Retiro before dinner.
Follow the itinerary above, then on Day 3 go to either Toledo or Segovia to spend the day. On Day 4, take a break from museums and wander along the castizo neighborhoods: the literary neighborhood around Plaza Santa Ana, Chueca (with some good lunch stopovers on Calle Libertad and Calle Barbieri), and Malasaña, walking from Centrode Conde Duque to the Templo de Debod, in Parque del Oeste, to catch the last glimpse of the sunset. Finish off the day sipping a drink on any of the terraces on Calle Rosales, near the Templo, before dinner. If it's summer, say goodbye to the city by having an after-dinner drink at one of the terrazas on Castellana.
If you happen to have a few more days, take in the 16th-century Convento de las Descalzas Reales, the Convento de la Encarnación, and the Real Academia de Bellas Artes de San Fernando, and put aside some time to visit Museo Sorolla, the Museo Lázaro Galdiano, the Real Fábrica de Tapices, and Goya's frescos at Ermita San Antonio de la Florida. Use one afternoon to do some shopping in the Salamanca neighborhood or on Calles Fuencarral and Hortaleza. Make room for some flamenco at any of the listed tablaos, listen to recorded flamenco and make your own moves on the dance floor at any of the hangouts on Calle Echegaray (such as Cardamomo, El Burladero, or Los Gabrieles), or, if it's summer, see if there are any concerts at the magnificent main plaza of the Centro de Conde Duque.