Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func zeller(month, day int) int {
	year := 2004
	if month == 1 || month == 2 {
		year--
		month += 12
	}
	return (year + year/4 - year/100 + year/400 + (13*month+8)/5 + day)%7
}

func main() {
	scanner.Split(bufio.ScanWords)
	for {
		month := nextInt()
		day := nextInt()
		if month == 0 && day == 0{
			break
		}
		switch zeller(month, day) {
		case 0:
			fmt.Println("Sunday")
		case 1:
			fmt.Println("Monday")
		case 2:
			fmt.Println("Tuesday")
		case 3:
			fmt.Println("Wednesday")
		case 4:
			fmt.Println("Thursday")
		case 5:
			fmt.Println("Friday")
		case 6:
			fmt.Println("Saturday")
		}
	}
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const string days[] = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" };
// 						   Jan Feb Match April May June July, Aug Sep Oct No  Dec
const int months[] = { 0, 31, 29, 31,   30,   31, 30,  31, 31, 30, 31, 30, 31 };
int main()
{
//	cut here before submit 
//	freopen ("testcase.What_day_is_today", "r", stdin );
	int month, day;
	while (scanf ("%d %d", &month, &day ) && month ){
		int cnt = 3;	// 2004/01/01 is Thursday
		for (int i = 0; i < month; i++ ){
			cnt += months[i];
		} // end for
		cnt += day;
		cnt--;
		cout << days[cnt % 7] << endl;
	} // end loop
		
	return 0;
}

C++: #include <iostream>
using namespace std;

const string DAYS_OF_WEEK[7] = {"Thursday",
                                "Friday",
                                "Saturday",
                                "Sunday",
                                "Monday",
                                "Tuesday",
                                "Wednesday"};

const int FIRST_DAY_NUM[12] = {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335};

int main()
{
    int m;
    int d;
    while(1)
    {
        int day_num;
        cin >> m >> d;
        if(m == 0 && d == 0)
        {
            break;
        }
        /* calculate nunmber of days from Jan 1 */
        day_num = FIRST_DAY_NUM[m - 1] + d - 1;
        cout << DAYS_OF_WEEK[day_num % 7] << endl; 
    }
    return 0;
}

C++: #include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int days[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    char* week[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};

    for(;;){
        int m, d;
        cin >> m >> d;
        if(m == 0)
            return 0;

        int num = 0;
        for(int i=0; i<m-1; ++i)
            num += days[i];
        num += d;

        cout << week[(num+2)%7] << endl;
    }
}

C++: #include<iostream>
using namespace std;
int main()
{
int date,month,day;
while(cin>>month>>date&&month!=0)
{	
switch(month)
{
case 1:
switch(date%7)
{
case 1:
day=4;
break;
case 2:
day=5;
break;
case 3:
day=6;
break;
case 4:
day=7;
break;
case 5:
day=1;
break;
case 6:
day=2;
break;
case 0:
day=3;
break;
}
break;
case 2:
switch(date%7)
{
case 1:
day=7;
break;
case 2:
day=1;
break;
case 3:
day=2;
break;
case 4:
day=3;
break;
case 5:
day=4;
break;
case 6:
day=5;
break;
case 0:
day=6;
break;
}
break;
case 3:
switch(date%7)
{
case 1:
day=1;
break;
case 2:
day=2;
break;
case 3:
day=3;
break;
case 4:
day=4;
break;
case 5:
day=5;
break;
case 6:
day=6;
break;
case 0:
day=7;
break;
}
break;
case 4:
switch(date%7)
{
case 1:
day=4;
break;
case 2:
day=5;
break;
case 3:
day=6;
break;
case 4:
day=7;
break;
case 5:
day=1;
break;
case 6:
day=2;
break;
case 0:
day=3;
break;
}
break;
case 5:
switch(date%7)
{
case 1:
day=6;
break;
case 2:
day=7;
break;
case 3:
day=1;
break;
case 4:
day=2;
break;
case 5:
day=3;
break;
case 6:
day=4;
break;
case 0:
day=5;
break;
}
break;
case 6:
switch(date%7)
{
case 1:
day=2;
break;
case 2:
day=3;
break;
case 3:
day=4;
break;
case 4:
day=5;
break;
case 5:
day=6;
break;
case 6:
day=7;
break;
case 0:
day=1;
break;
}
break;
case 7:
switch(date%7)
{
case 1:
day=4;
break;
case 2:
day=5;
break;
case 3:
day=6;
break;
case 4:
day=7;
break;
case 5:
day=1;
break;
case 6:
day=2;
break;
case 0:
day=3;
break;
}
break;
case 8:
switch(date%7)
{
case 1:
day=7;
break;
case 2:
day=1;
break;
case 3:
day=2;
break;
case 4:
day=3;
break;
case 5:
day=4;
break;
case 6:
day=5;
break;
case 0:
day=6;
break;
}
break;
case 9:
switch(date%7)
{
case 1:
day=3;
break;
case 2:
day=4;
break;
case 3:
day=5;
break;
case 4:
day=6;
break;
case 5:
day=7;
break;
case 6:
day=1;
break;
case 0:
day=2;
break;
}
break;
case 10:
switch(date%7)
{
case 1:
day=5;
break;
case 2:
day=6;
break;
case 3:
day=7;
break;
case 4:
day=1;
break;
case 5:
day=2;
break;
case 6:
day=3;
break;
case 0:
day=4;
break;
}
break;
case 11:
switch(date%7)
{
case 1:
day=1;
break;
case 2:
day=2;
break;
case 3:
day=3;
break;
case 4:
day=4;
break;
case 5:
day=5;
break;
case 6:
day=6;
break;
case 0:
day=7;
break;
}
break;
case 12:
switch(date%7)
{
case 1:
day=3;
break;
case 2:
day=4;
break;
case 3:
day=5;
break;
case 4:
day=6;
break;
case 5:
day=7;
break;
case 6:
day=1;
break;
case 0:
day=2;
break;
}
break;
}
switch(day)
{
case 1:
cout<<"Monday"<<endl;
break;
case 2:
cout<<"Tuesday"<<endl;
break;
case 3:
cout<<"Wednesday"<<endl;
break;
case 4:
cout<<"Thursday"<<endl; 
break;
case 5:
cout<<"Friday"<<endl;
break;
case 6:
cout<<"Saturday"<<endl;
break;
case 7:
cout<<"Sunday"<<endl;
break;
}
}
return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int day[12]={31,29,31,30,31,30,31,31,30,31,30,31};
  int m,d;
  int ans=0;
  while(cin>>m>>d){
    if(m==0&&d==0) break;
    ans = 0;
    for(int i=0;i<m-1;i++) ans += day[i];
    ans += d;
    switch(ans%7){
    case 0:
    cout << "Wednesday" << endl;
    break;
    case 1:
    cout << "Thursday" << endl;
    break;
    case 2:
    cout << "Friday" << endl;
    break;
    case 3:
    cout << "Saturday" << endl;
    break;
    case 4:
    cout << "Sunday" << endl;
    break;
    case 5:
    cout << "Monday" << endl;
    break;
    case 6:
    cout << "Tuesday" << endl;
    break;
    }
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <array>
#include <numeric>
#include <cstdint>

int main()
{
	typedef std::array<std::uint16_t, 12> NumDays;
	NumDays const num_days = {
		0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30
	};
	typedef std::array<std::string, 7> WeekDay;
	WeekDay const days = {
		"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"
	};

	std::uint16_t m, d;
	for (std::cin >> m >> d; !(m == 0 && d == 0); std::cin >> m >> d) {
		std::uint16_t const num_spanned_days =
			d + std::accumulate(num_days.begin(), num_days.begin() + m, 0);
		std::cout << days[num_spanned_days % days.size()] << std::endl;
	}

	return 0;
}