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 <iostream>
using namespace std;

int howmany(int);

int main() {
	int month, day, mod;
	

	while (cin >> month >> day) {
		if (month == 0) break;
		int total = 0;

		for (int i = 1;i < month; i++) {
			total += howmany(i);
		}
		total += day;
		mod = total % 7;

		switch (mod) {
		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;
		default:
			break;
		}
	}

	return 0;
}

int howmany(int month) {
	if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) {
		return 31;
	}
	else if (month == 2) {
		return 29;
	}
	else {
		return 30;
	}
}

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

int months[] = {31,29,31,30,31,30,31,31,30,31,30,31};
string days[] = {"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wndnessday"};

int main()
{
	int month,day,sum = 0;
    
    while(cin >> month >> day,month || day)
	{
		for(int i=0;i<month;i++)
		{
	        sum += months[i-1];
		}
        sum += day -1;
		cout << days[sum%7] <<endl;
    }
	return 0;
}

C++: #include <stdio.h>

int main(void)
{
	int MONTH[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	
	char DAYS[7][10] = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"};
	
	int month, date, i;
	
	while(scanf("%d %d",&month, &date)){
		getchar();
		if(month == 0){
			break;
		}
		
		int total = 0;
		for(i = 1;i < month;i++){
			total += MONTH[i - 1];
		} 
		
		total += date -1 ;
		
		//printf("%d\n",total);
		printf("%s\n",DAYS[total % 7]);
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, init, n) for(int i = init; i < (n); i++)

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    vector<int> day = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    REP(i, 1, 12) day[i] += day[i - 1];

    int month, da;

    while(cin >> month >> da, month)
    {
        string ans;
        switch((day[month - 1] + da) % 7)
        {
            case 0:
                ans = "Wednesday";
                break;
            case 1:
                ans = "Thursday";
                break;
            case 2:
                ans = "Friday";
                break;
            case 3:
                ans = "Saturday";
                break;
            case 4:
                ans = "Sunday";
                break;
            case 5:
                ans = "Monday";
                break;
            case 6:
                ans = "Tuesday";
                break;
        }

        cout << ans << endl;
    }

    return 0;
}

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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

int dx[] = { -1, 0, 1, 0 };
int dy[] = {  0, -1, 0, 1 };

enum Day {
  Sat = 0,
  Sun = 1,
  Mon, Tue, Wed, Thu, Fri
};

Day zeller(int y, int m, int d) {
  if (m == 1 || m == 2) {
    --y; m += 12;
  }
  int Y = y % 100;
  int c = y / 100;
  int gamma = 5 * c + c / 4; // Gregorian (1582 <= y)
  //int gamma = 6 * c + 5; // Julian (4 <= y <= 1582)
  int h = d + int(26 * (m+1) / 10)
    + Y + Y / 4 + gamma;
  h %= 7;
  return Day(h);
}

string show_day (Day a) {
  switch (a) {
    case Mon: return "Monday";
    case Tue: return "Tuesday";
    case Wed: return "Wednesday";
    case Thu: return "Thursday";
    case Fri: return "Friday";
    case Sat: return "Saturday";
    case Sun: return "Sunday";
    default: return "Holiday";
  }
}

int main() {

  loop {
    int a,b;
    cin >> a >> b;
    if (!cin) break;
    if (!a && !b) break;
    cout << show_day(zeller(2004, a, b)) << endl;
  }
  return 0;
}

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

int main(int argc, char *argv[]) {
	const int start_day = 3;
	const int days[12] = {
		31, 29, 31, 30, 31, 30,
		31, 31, 30, 31, 30, 31
	};
	const std::string week[] = {
		"Monday", "Tuesday", "Wednesday", "Thursday",
		"Friday", "Saturday", "Sunday"
	};
	
	while (true) {
		int month, day, sum = start_day;
		fscanf(stdin, "%d %d", &month, &day);
		if (month == 0) {
			break;
		}
		sum += day-1;
		for (int i = 0; i < month-1; i++) {
			sum += days[i];
		}
		printf("%s\n", week[sum%7].c_str());
		
	}
	return 0;
}

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

double r(double x1,double y1,double x2,double y2){
	return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
	
	}

int main() {
	// your code goes here
int a[13];
a[1]=31;
a[2]=29;
a[3]=31;
a[4]=30;
a[5]=31;
a[6]=30;
a[7]=31;
a[8]=31;
a[9]=30;
a[10]=31;
a[11]=30;
a[12]=31;

int m,d,z,y;
cin>>m>>d;
while(m!=0){
	if(m==0) z=d;
	else{
		z=d;
		for(int i=1;i<m;i++){
			z=z+a[i];
		}
	}
	y=z%7;
	if(y==1){
		cout<<"Thursday"<<endl;
	}
		if(y==2){
		cout<<"Friday"<<endl;
	}
		if(y==3){
		cout<<"Saturday"<<endl;
	}
		if(y==4){
		cout<<"Sunday"<<endl;
	}
		if(y==5){
		cout<<"Monday"<<endl;
	}
		if(y==6){
		cout<<"Tuesday"<<endl;
	}
		if(y==0){
		cout<<"Wednesday"<<endl;
	}
	
	cin>>m>>d;
}
	
	return 0;
}