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>

int monthes(int i){
  if(i==2){
    return 29;
  }
  if(i==4||i==6||i==9||i==11){
    return 30;
  }else{
    return 31;
  }
}

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

  while(std::cin >> month >> day){
    if(month==0){
      break;
    }
    sum = 0;
    for(int i=1;i<month;i++){
      sum += monthes(i);
    }
    sum += day-1;
    switch(sum%7){
      case 0: std::cout << "Thursday" << std::endl; break;
      case 1: std::cout << "Friday" << std::endl; break;
      case 2: std::cout << "Saturday" << std::endl; break;
      case 3: std::cout << "Sunday" << std::endl; break;
      case 4: std::cout << "Monday" << std::endl; break;
      case 5: std::cout << "Tuesday" << std::endl; break;
      case 6: std::cout << "Wednesday" << std::endl; break;
    }
  }
}

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

using namespace std;

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

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

int main() {
  int k,m,d;
  string today[7]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
  int mon[12]={31,29,31,30,31,30,31,31,30,31,30,31};

  while(cin >>m>>d){
    if(m==0)break;

    for(int i=0;m-1>i;i++){

      if(m==1)break;
      else d+=mon[i];

  }
    k=d%7+2;
    cout <<today[k]<<endl;
  
  }
}

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

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

int main(){
    int m,d;

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

        cout<<ans<<endl;
    }
}

C++: #include <iostream>
#include <string>
using namespace std;
 int main()
{
	//arrays with number of days in month and the days names
    int days[] = {31,29,31,30,31,30,31,31,30,31,30,31};
    string week[7] = {"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
    int month, day;
    while(cin >> month >> day)//entering day
	{
		
        int n = 0;
        for(int i=1; i<month; i++)
		{
            n += days[i-1];
        }
        n += day;
 
        n %= 7;
        cout << week[n] <<endl;//printing the day
 
    }
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main() {
	char w[7][8]={"Thurs","Fri","Satur","Sun","Mon","Tues","Wednes"};
	int mon[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	int m,d,i,j,s;
    vector<int> a,b;
	while (cin >> m >> d) {
		if (m==0 || d==0) break;
		a.push_back(m); b.push_back(d);
	}
	for (i=0; i<a.size(); i++) {
     s=0;
	 for (j=0;j<a[i]-1;j++) s+=mon[j];
     s=(s+b[i]-1) % 7;
     cout << w[s] << "day" << endl;
	}
	return 0;
}

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

int manth[] = {31,29,31,30,31,31,30,31,31,30,31,30,31};
string date[] = {"Sunday","Manday","Tuesday","Wednesday","Thursday","Friday","Suterday"};

int main(){
	int M, D;
	while( cin >> M >> D, M ){
		int d = 3;
		for(int i=0; i<M-1; i++ ){
			d += manth[i];
		}
		d += D;
		d %= 7;
		cout << date[d] << endl;
	}
}

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

int main(){
	int m, d, year;
	while(1){
		year = 2004;
		cin >> m >> d;
		if(m == 0 && d == 0){
			break;
		}
		if(m <= 2){
			m += 12;
			year -= 1;
		}
		int c = floor(year / 100);
		int gamma = 5 * c + floor(c / 4);
		int y = year % 100;
		int h = d + floor(26 * (m + 1) / 10) + y + floor(y / 4) + gamma;
		int day = h % 7;
		switch(day){
			case 0:
				cout << "Saturday" << endl;
				break;
			case 1:
				cout << "Sunday" << endl;
				break;
			case 2:
				cout << "Monday" << endl;
				break;
			case 3:
				cout << "Tuesday" << endl;
				break;
			case 4:
				cout << "Wednesday" << endl;
				break;
			case 5: 
				cout << "Thursday" << endl;
				break;
			case 6:
				cout << "Friday" << endl;
				break;
			default:
				break;
		}
	}
	return 0;
}

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

int Zeller(int y, int m, int d){
	if (m == 1){ m = 13; --y; }
	else if (m == 2){ m = 14; --y; }
	return (int)(d + floor(26.0 * (m + 1.0) / 10.0) + (y % 100) + floor((y % 100) / 4.0) + (5.0 * (floor(y / 100.0))) + floor(floor(y / 100.0) / 4.0)) % 7;
}

int main(){
	string days[7] = { "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" };
	int m, d;
	
	while (true){
		cin >> m >> d;
		if (m == 0 && d == 0)break;
		cout << days[Zeller(2004, m, d)] << endl;
	}
	return 0;
}

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

int days[13][32];

std::string whatday(int m, int d) {
	switch (days[m][d]) {
	case 0:
		return "Monday";
	case 1:
		return "Tuesday";
	case 2:
		return "Wednesday";
	case 3:
		return "Thursday";
	case 4:
		return "Friday";
	case 5:
		return "Saturday";
	case 6:
		return "Sunday";
	}
	return "";
}

int main() {
	int day = 3;
	for (int i = 1; i < 13; i++) {
		for (int j = 1; j < 32; j++) {
			days[i][j] = day;
			day = (day+1) % 7;
			if (i == 2 && j == 29) break;
			if (i == 4 && j == 30) break;
			if (i == 6 && j == 30) break;
			if (i == 9 && j == 30) break;
			if (i == 11 && j == 30) break;
		}
	}
	int m, d;
	while (std::cin >> m >> d) {
		if (m == 0) break;
		std::cout << whatday(m, d) << std::endl;
	}
	return 0;
}