Go: package main

import (
        "fmt"
)

func main() {
        var weeks = []string{"Thursday",
                "Friday",
                "Saturday",
                "Sunday",
                "Monday",
                "Tuesday",
                "Wednesday"}

        for {
                var m, d int
                _, err := fmt.Scanf("%d %d", &m, &d)
                if err != nil || m + d == 0 {
                        break
                }
                var days int

                for {
                        lm, ld := getLastDay(m, d)
                        if lm + ld == 0 {
                                break
                        }
                        days++
                        m = lm
                        d = ld
                }
                fmt.Println(weeks[days%7])
        }
}

func getLastDay(m int, d int) (lm int, ld int) {
        if m == 1 && d == 1 {
                return 0, 0
        }

        if d > 1 {
                return m, d-1
        } else {
                if m == 3 {
                        return m-1, 29
                }
                if m == 3 || m == 5 || m == 7 || m == 10 || m == 12 {
                        return m-1, 30
                } else {
                        return m-1, 31
                }
        }
}

C++: #include <bits/stdc++.h>
using namespace std;

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

//Zeller's conguence

int main()
{
    int h, y, m, d;
    h = 20;
    y = 4;
    while (true)
    {
        cin >> m >> d;
        if (m == 0 && d == 0)
            break;
        if (m == 1 || m == 2)
        {
            m += 12;
            y--;
        }
        int r = 5 * h + h / 4;
        int w = {d + ((13 * (m + 1)) / 5) +
                 y + y / 4 + r + 5};

        int ans = w % 7 + 1;
        switch (ans)
        {
        case 7:
            cout << "Sunday" << endl;
            break;
        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;
        }
    }
    return 0;
}

C++: #include<iostream>
#include<numeric>

using namespace std;


int main() {
	// 各月の日数を定数として定義しておく
	// 最初に0があるのは
	// 1.配列のインデックスと月が異なるとややこしくなる
	// 2.1月の場合に例外的な処理をしなくていいようにするため
	const int offset_days[]{
		0,31,29,31,30,31,30,31,31,30,31,30,31
	};
	const char* day_str[]{
		"Monday",
		"Tuesday",
		"Wednesday",
		"Thursday",
		"Friday",
		"Saturday",
		"Sunday"
	};
	// 処理を簡単にするため、前年の大晦日を起点に考える
	const int day_12_31 = 2;

	int m, d;
	while (cin >> m >> d, m != 0) {
		// 各月の日数の和を求める。
		// オフセットとして前年の大晦日に対応する値を設定する。
		int sum = std::accumulate(&offset_days[0], &offset_days[m], day_12_31);
		// 該当する日の曜日を求めるため、日数を加算して7で割ったあまりを求める。
		int day = (sum + d) % 7;
		cout << day_str[day] << endl;
	}

	return 0;
}

C++: //2004 366 1/1 Thursday

#include <cstdio>

using namespace std;

void today(int mon, int day);

int main()
{
	int mon, day;
	
	while (1){
		scanf("%d %d", &mon, &day);
		
		if (mon == 0){
			break;
		}
		
		today(mon, day);
	}
	
	return (0);
}

void today(int mon, int day)
{
	int tmp = 0;
	
	for (int i = 1; i < mon; i++){
		if (i == 4 || i == 6 || i == 9 || i == 11){
			tmp += 30;
		}
		else if (i == 2){
			tmp += 29;
		}
		else {
			tmp += 31;
		}
	}
	
	switch ((tmp + day) % 7){
	  case 0:
	    puts("Wednesday");
		break;
		
	  case 1:
	    puts("Thursday");
		break;
		
	  case 2:
	    puts("Friday");
		break;
		
	  case 3:
	    puts("Saturday");
		break;
		
	  case 4:
	    puts("Sunday");
		break;
		
	  case 5:
	    puts("Monday");
		break;
		
	  case 6:
	    puts("Tuesday");
		break;
	}
}

C++: //2004??´???366??\ /1/1 Thursday

#include <cstdio>

using namespace std;

void today(int mon, int day);

int main()
{
	int mon, day;
	
	while (1){
		scanf("%d %d", &mon, &day);
		
		if (mon == 0){
			break;
		}
		
		today(mon, day);
	}
	
	return (0);
}

void today(int mon, int day)
{
	int tmp = 0;
	
	for (int i = 1; i < mon; i++){
		if (mon == 4 || mon == 6 || mon == 9 || mon == 11){
			tmp += 30;
		}
		else if (mon == 2){
			tmp += 29;
		}
		else {
			tmp += 31;
		}
	}
	
	switch ((tmp + day) % 7){
	  case 0:
	    puts("Wednesday");
		break;
		
	  case 1:
	    puts("Thursday");
		break;
		
	  case 2:
	    puts("Friday");
		break;
		
	  case 3:
	    puts("Saturday");
		break;
		
	  case 4:
	    puts("Sunday");
		break;
		
	  case 5:
	    puts("Monday");
		break;
		
	  case 6:
	    puts("Tuesday");
		break;
	}
}

C++: #include<iostream>
using namespace std;
int main()
{
int day,month,day
while(cin>>month>>day&&month!=0)
{	
switch(m)
{
cace 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;
}