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 main()
{
  int m, d;
  while(1){
    cin >> m >> d;
    if(m == 0 && d == 0){
      break;
    }else{
      int n = d - 1;
      for(int i = m - 1; i > 0; i--)
	if(i >= 8)
	  if(i & 1)
	    n += 30;
	  else
	    n += 31;
	else if(i == 2)
	  n += 29;
	else
	  if(i & 1)
	    n += 31;
	  else
	    n += 30;
      switch(n % 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;
      }
    }
  }
}

C++: #define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<list>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<map>
#include<queue>
#include<vector>
using namespace std;

string a[7] = {
	"Monday",
	"Tuesday",
	"Wednesday",
	"Thursday",
	"Friday",
	"Saturday",
	"Sunday"
};

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

int main() {
	for (int m, d; cin >> m >> d&&m;) {
		while (m)
			d += b[--m];
		cout << a[d % 7 - 1 + 3] << endl;
	}
	return 0;
}

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, 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
 
    }
  return 0;
}

C++: #include <iostream>

using namespace std;

int main(void) {
  int month[13];
  month[1] = 31;
  month[2] = 29;
  month[3] = 31;
  month[4] = 30;
  month[5] = 31;
  month[6] = 30;
  month[7] = 31;
  month[8] = 31;
  month[9] = 30;
  month[10] = 31;
  month[11] = 30;
  month[12] = 31;

  int m, d, days;
  while(cin >> m >> d) {
    if(m == 0) break;
    
    days = d;
    for(int j = 1; j < m; j++) {
      days = days + month[j];
    }
    if(days%7 == 0) {
      cout << "Wednesday" << '\n';
    } else if(days%7 == 1) {
      cout << "Thursday" << '\n';
    } else if(days%7 == 2) {
      cout << "Friday" << '\n';
    } else if(days%7 == 3) {
      cout << "Saturday" << '\n';
    } else if(days%7 == 4) {
      cout << "Sunday" << '\n';
    } else if(days%7 == 5) {
      cout << "Monday" << '\n';
    } else if(days%7 == 6) {
      cout << "Tuesday" << '\n';
    }
  }

  return 0;
}

C++: #include<stdlib.h>
#include<stdio.h>

int main(){
  int m[366],d[366],i,add,n,num[366];
  i=0;
  do{
    scanf("%d %d",&m[i],&d[i]);
    ++i;
  }while(m[i-1]!=0);
  for(n=0;n<i-1;++n){
    add=0;
    switch(m[n]){
    case 12:
      add+=30;
    case 11:
      add+=31;
    case 10:
      add+=30;
    case 9:
      add+=31;
    case 8:
      add+=31;
    case 7:
      add+=31;
    case 6:
      add+=31;
    case 5:
      add+=30;
    case 4:
      add+=31;
    case 3:
      add+=29;
    case 2:
      add+=31;
    case 1:
      add+=0;
    
    }

    num[n]=(add+d[n])%7;
  
    switch(num[n]){
    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>
#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]={"Thurthday","Fryday","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 main( void )
{
	int days[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
	string d[7] = { "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday" };

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

		for ( int i = 0; i < 11; i++ )
		{
			days[i+1] += days[i];
		}

		if ( month != 1 )
		{
			month -= 2;
			day += days[month];
		}
		day--;
		cout << d[day%7] << endl;

	}

	return 0;
}

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,13){
            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:;
    }
    
  
    return 0;
}