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>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
#include<map>
using namespace std;

int main(){
    int mod=1000000007;
    int m,d;
    int p[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
    map<int, string> week;
    week[0]="Monday";
    week[1]="Tuesday";
    week[2]="Wednesday";
    week[3]="Thursday";
    week[4]="Friday";
    week[5]="Saturday";
    week[6]="Sunday";
    for (;;){
        scanf("%d %d",&m,&d);
        if (m==0) break;
        int tmp=3;
        if (m>1) {
            for (int i=1;i<m;i++) {
                tmp=(tmp+p[i])%7;
            }
        }
        cout<<week[(tmp+d-1)%7]<<endl;
    }
    return 0;
}

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

int monthes[]={0,31,29,31,30,31,30,31,31,30,31,30,31};

std::string day[]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};

int main(void){
    int m,d,n;
    while(std::cin>>m>>d){
        if(m==0&&d==0) break;
        n=0;
        int i;
        for(i=1;i<m;i++) n+=monthes[i];
        n+=d;
        std::cout<<day[n%7]<<std::endl;
    }
    return 0;
}

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

int main(void){
  int a, b;
  int m[] = {0, 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335};
  int r = 0;
  while(1){
    cin >> a >> b;
    if(a == 0 && b == 0) break;
    r = (m[a] + b) % 7;
    switch (r)
    {
    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 <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

int main() {
    int m, d;
    int months[] = {31,29,31,30,31,30,31,31,30,31,30,31};
    while(cin >> m >> d, m + d) {
        REP(i,m-1) {
            d += months[i];
        }
        d -= 1;
        switch (d % 7) {
            case 0:
                cout << "Thursday" << endl;
                break;
                
            case 1:
                cout << "Friday" << endl;
                break;
                
            case 2:
                cout << "Saturday" << endl;
                break;
                
            case 3:
                cout << "Sunday" << endl;
                break;
                
            case 4:
                cout << "Monday" << endl;
                break;
                
            case 5:
                cout << "Tuesday" << endl;
                break;
                
            case 6:
                cout << "Wednesday" << endl;
                break;
                
            default:
                break;
        }
    }
    return 0;
}

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

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

int main(void) {
	int m, d, a;

	while (cin >> m >> d, m) {
		a = (t[m-1] + d) % 7;
		if (a == 0) cout << "Wednesday";
		else if (a == 1) cout << "Thursday";
		else if (a == 2) cout << "Friday";
		else if (a == 3) cout << "Saturday";
		else if (a == 4) cout << "Sunday";
		else if (a == 5) cout << "Monday";
		else cout << "Tuesday";
		cout << endl;
	}

	return 0;
}

C++: #include<cstdio>

int main(){
	int a[] = {0,0,31,60,91,121,152,182,213,244,274,305,335,366};
	int m, d;
	char day[7][10] = {"Monday", "Tuesday", "Wednesday", "Thursday","Friday","Saturday","Sunday"};
	while(scanf("%d %d", &m, &d) + 1){
		printf("%s\n", day[(a[m] + d + 2) % 7]);
	}
}

C++: #include <iostream>
using namespace std;
void whatday(int year, int month, int date) {
  string day[7] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
  if(month == 1 || month == 2) {
	year--;
	month += 12;
  }
  int YEAR = year / 100;
  int h = (year + (year >> 2) - YEAR + (YEAR >> 2) + (13*month + 8)/5 + date) % 7;
  cout << day[h] << endl;
}
int main() {
  int month, day;
  while(cin >> month >> day) {
	if(month == 0 && day == 0) break;
	whatday(2004, month, day);
  }

  return 0;
}

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

using namespace std;

int main()
{
	int month = 0, day = 0, total_day = 0, week_num = 0;
	map<int, int> month_num;

	month_num[1] = 0;
	month_num[2] = 31;
	month_num[3] = 60;
	month_num[4] = 91;
	month_num[5] = 121;
	month_num[6] = 152;
	month_num[7] = 182;
	month_num[8] = 213;
	month_num[9] = 244;
	month_num[10] = 274;
	month_num[11] = 305;
	month_num[12] = 335;

	cin >> month >> day;

	while ( month * day != 0 )
	{
		total_day = month_num[month] + day-1;
		switch ( total_day % 7 )
		{
			case 0:
				cout << "Thursday" << endl;
				break;
			case 1:
				cout << "Friday" << endl;
				break;
			case 2:
				cout << "Saturday" << endl;
				break;
			case 3:
				cout << "Sunday" << endl;
				break;
			case 4:
				cout << "Monday" << endl;
				break;
			case 5:
				cout << "Tuesday" << endl;
				break;
			case 6:
				cout << "Wednesday" << endl;
				break;
			default:
				break;
		}
		cin >> month >> day;
	}

	return 0;
}

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

using namespace std;


char str[7][10] = {"Thursday", "Friday", "Saturday","Sunday", "Monday", "Tuesday", "Wednesday"};
int days[13] = {0, 0, 31, 60, 91, 121, 152, 182, 213, 243, 274, 304, 335}; 

int main() {
	int month, day;
	while (scanf("%d%d", &month, &day), month + day) {
		printf ("%s\n", str[(days[month] + day - 1) % 7]);
	}
	return 0;
}

C++: #include <stdio.h>
int main()
{
	char yobi[7][10]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
	int month,day;
	while(1){
		scanf("%d %d",&month,&day);
		if(month==0)
			break;
		for(int i=0;i<month;i++){
			switch(i){
				case 2:
					day+=29;
				case 4:
				case 6:
				case 9:
				case 11:
					day+=30;
				default:
					day+=31;
			}
		}
		printf("%s\n",yobi[day%7]);
	}
	return 0;
}