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>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define drep(n,m) for(int i=0;i<n;i++)for(int j=0;j<m;j++)
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000009
#define pb push_back
#define mp make_pair
typedef long long ll;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

ll gcd(ll a,ll b){
    if(a<b){
        int t=a;a=b;b=t;
    }
    int c=a%b;
    while(c!=0){
        a=b;
        b=c;
        c=a%b;
    }
    return b;
}

ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}

bool isPrime(int x){
    if(x==1)return false;
    if(x==2)return true;
    if(x%2==0)return false;
    for(int i=3;i<=sqrt(x);i+=2){
        if(x%i==0)return false;
    }
    return true;
}

int main() {
    string day[7]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
    int t=3;
    int v[12]={31,29,31,30,31,30,31,31,30,31,30,31};
    int mo,da;
    while(cin>>mo>>da){
        if(mo==0&&da==0)break;
        rep(i,1,12+1){
            rep(j,1,v[i-1]+1){
                if(i==mo&&j==da){
                    cout<<day[t]<<endl;
                    goto AWAY;   
                }
                t++;
                if(t==7)t=0;
            }
        }
        AWAY:;
        t=3;
    }
    
  
    return 0;
}

C++: #include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
int stoi(string x){stringstream ss;ss<<x;int tmp;ss>>tmp;return tmp;}
string itos(int x){stringstream ss;ss<<x;return ss.str();}
int cal[12]={31,29,31,30,31,30,31,31,30,31,30,31};//2は29,4,6,9,11は30
string ta[7]={"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};//1月１日が木曜日
int main(){
	int n,m,sum=0,now=0;
	cin>>n>>m;
	for(int i=0;i<n-1;i++)sum+=cal[i];
	sum+=m;
	sum--;
	for(int i=0;i<sum;i++)(now==6)?now=0:now++;
	cout<<ta[now]<<endl;
	return 0;
}

C++: #include <iostream>
#include <string>
using namespace std;
int countup_days(int m, int d) // m月d日が、1月1日から何日目か返す
{
    int         sum     = 0;
    const int   month[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,};
    for (int i=1; i<m; i++) {
        sum += month[i];
    }
    cout << sum + d << endl;
    return sum + d -1;
}
string what_day(int days) // 1/1からdays日後は何曜日か文字列を返す
{
    string day[]   = {"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"};
    return day[days%7];
}
int main()
{
    int m, d;
    while (true) {
        cin >> m >> d;
        if (m==0 && d==0)
            break;
        cout << what_day(countup_days(m, d)) << endl;
    }
}

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

int main(){
	int m,d;
	int mm[]={31,29,31,30,31,30,31,31,30,31,30,31};
	string s[]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	while(cin>>m>>d){
		if(m==0)break;
		int dd=0;
		for(int i=0;i<m-1;i++)dd+=mm[i];
		dd+=d;
		int ans=(dd+2)%7;
		//cout<<dd<<endl;
		cout<<s[ans]<<endl;
	}
	return 0;
}

C++: #include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <cctype>
#include <iostream>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
int size(string x){
	string::size_type size=x.size();
	return size;
}
#define fu(l,k) for(int i=l;i<k;i++)
#define fd(l,k) for(int i=l;i>k;i--)
#define sort(ss) sort(ss.begin(), ss.end())
#define rsort(ss) sort(ss.rbegin(), ss.rend())
typedef  vector<string> vs;
typedef  vector<int> vi;
double pi(){
	return M_PI;
}
typedef set<int> set_i;
typedef set<string> set_s;
int INF=1000000;
int main(){
	int m,d,ans;
	string w[7]={"Monday","Tuesday","Wednesday",
	               "Thursday","Friday","Saturday","Sunday"};
	while(1){
		cin>>m>>d;
		if(m==0&&d==0) break;
		if(m==1||m==4||m==7){
			//start:Thursday
			ans=d%7;
			if(ans<5){
				cout<<w[3+ans-1]<<endl;
			}
			else if(ans==6){
				cout<<w[1]<<endl;
			}
			else cout<<w[2]<<endl;
		}
		if(m==2||m==8){
			//start:Sunday
			ans=d%7;
			if(ans==1) cout<<w[6]<<endl;
			else if(ans==0) cout<<w[5]<<endl;
			else cout<<w[ans-2]<<endl;
		}
		if(m==3||m==11){
			//start:Monday
			ans=d%7;
			if(ans==0) cout<<w[6]<<endl;
			else cout<<w[ans-1]<<endl;
		}
		if(m==6){
			//start:Tuesday
			ans=d%7;
			if(ans!=0){
				cout<<w[ans]<<endl;
			}
			else{
				cout<<w[6]<<endl;
			}
		}
		if(m==10){
			//start:friday
			ans=d%7;
			if(ans<4){
				cout<<w[4+ans-1]<<endl;
			}
			else{
				cout<<w[ans-4]<<endl;
			}
		}
		if(m==5){
			//Saturday
			ans=d%7;
			if(ans==0) cout<<w[4]<<endl;
			else if(ans<3){
				cout<<w[5+ans-1]<<endl;
			}
			else{
				cout<<w[ans-3]<<endl;
			}
		}
		if(m==9||m==12){
			//start:Wednesday
			ans=d%7;
			if(ans==0) cout<<w[1]<<endl;
			else if(ans<6){
				cout<<w[2+ans-1]<<endl;
			}
			else{
				cout<<w[0]<<endl;
			}
		}
	}
}

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

int search(int a){
	int month;
	if(a==2) month = 29;
	else if(a%2!=0) month = 31;
	else month = 30;
	return month;
}

char *Whatday(int a,int b){
	int month;
	char *day;
	int date=0;
	
	for(int i=1;i<a;i++){
		date = date+search(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;
}

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

int main(){
	int md[11] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30};
	int m, d;
	string str[7] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"};
	
	while(true){
		cin >> m >> d;
		
		if(m == 0 && d == 0) return 0;
		
		for(int i = 1; i < m; i++){
			d += md[i - 1];
		}
		
		cout << str[d % 7] << endl;
	}
}