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++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
const int MAX = (int)2e5 + 5;

int dayofweek(int year, int month, int day) {
	struct tm t;
	t.tm_year = year - 1900;
	t.tm_mon = month - 1;
	t.tm_mday = day;
	t.tm_hour = 0;
	t.tm_min = 0;
	t.tm_sec = 0;
	t.tm_isdst = -1;
	if (mktime(&t) == -1) {
		puts("!");
		exit(1);
	}
	return t.tm_wday;
}

int main() {
	vector<string> week_name = { "Sunday", "Monday", "Tuesday", "Wednesday",
		"Thursday","Friday","Saturday" };
	while (1) {
		int m, d;
		cin >> m >> d;
		if (m == 0) break;
		cout << week_name[dayofweek(2004, m, d)] << endl;
	}
	return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000007
#define EPS 1E-12

string s[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
int y, m, d;

int main()
{
  while((cin >> m >> d) && m){
    y = 2004;
    if(m == 1) y = 2003, m = 13;
    if(m == 2) y = 2003, m = 14;
    int D = (d + 26*(m+1)/10 + y + y/4 +5*(y/100) + y/100/4 + 4) % 7;
    cout << s[D] << endl;
  }


  return 0;
}

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

int days[13] = { 0,31,29,31,30,31,30,31,31,30,31,30,31};
string ans[10] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
int main()
{

int month, date;

	//前月までの延べ日数に変換
	for( int i = 1; i < 13; i++ ) {
		days[i] += days[i-1];
	}

	while( cin >> month >> date ) {
		if( month == 0 )
			return -1;
		
		int day = days[month-1] + date + 3;
		int p = day %7;

		cout << ans[p].c_str() << endl;

	}
	return 0;
}

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

int main()
{
  int m,d;

  string week[7] = {"Thursday", "Friday", "Saturday", "Sunday","Mondy", "Tuesday", "Wednesday"};
  int month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

  while ( scanf("%d %d", &m, &d), m != 0 ) {
    int day = 0;
    for (int i = 0; i < (m - 1); i++) {
      day += month[i];
    }
    day += d;
 
    cout << week[(day%7)-1] << endl;
  }
  return 0;
}

C++: #include <stdio.h>

int main()
{
	int month, day, n;
	int md[12] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 31, 30};

	while (1) {
		scanf("%d %d", &month, &day);

		if (month == 0) break;
		n = 0;

		for (int i = 0; i < month; i++) {
			n += md[i];
		}
		n += day;

		switch (n%7) {
			case 0: printf("Wednesday\n"); break;
			case 1: printf("Thursday\n"); break;
			case 2: printf("Friday\n"); break;
			case 3: printf("Saturday\n"); break;
			case 4: printf("Sunday\n"); break;
			case 5: printf("Monday\n"); break;
			case 6: printf("Tuesday\n"); break;
		}
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int m,d;
  while(cin >> m >> d){
    if(m==0)
      break;
    int cd=d;
    for(int i=1;i<=m;i++){
      switch(i){
      case 2:cd+=31;break;
      case 3:cd+=29;break;
      case 4:cd+=31;break;
      case 5:cd+=30;break;
      case 6:cd+=31;break;
      case 7:cd+=30;break;
      case 8:cd+=31;break;
      case 10:cd+=30;break;
      case 9:cd+=31;break;
      case 11:cd+=31;break;
      case 12:cd+=30;break;
      }
    }
    switch(cd%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;
    }
  }
}

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

int main() {
	vector<int> r;
	string d[7]={"Saturday","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday"};
	while (true)
	{
		int m,d;
		cin >> m >> d;
		if (m==0)break;
		if (m<3)m+=12;d-=2;
		r.push_back((5+d+(13*(m+1))/5)%7);
	}
	for (int i=0; i<r.size(); i++)
	{
		cout << d[r[i]] << endl;
	}
	return 0;
}

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

char *Whatday(int a,int b){
	char *day;
	int date=0;
	int month[]={
		0,31,29,31,30,31,30,31,31,30,31,30,31
	};
	
	for(int i=1;i<a;i++){
		date = date+month[i];
	}
	date += b;
	switch(date%7){
		case 0: day ="Wednesday"; break;
		case 1: day ="Thursday"; break;
		case 2: day ="Friday"; break;
		case 3: day ="Saturday"; break; 
		case 4: day ="Sunday"; break;
		case 5: day ="Monday"; break;
		case 6: day ="Tuesday"; break;
	}
	return day;
}

int main() {
	int m,d;
	while(1){
		cin >> m >> d;
		if(m==0) break;
		cout << Whatday(m,d) << endl;
	}
	return 0;
}