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 <bits/stdc++.h>
using namespace std;

const string day[] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"};
const int da[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main(void){
  int m, d;
  while(cin >> m >> d, m | d){
    while(1){
      m--;
      if(m > 0){
        d += da[m];
      }else{
        break;
      }
    }
    cout << day[d%7] << endl;
  }
  return 0;
}

C++: #include	<iostream>

using namespace std;

int main(void) {
	while(1) {
		int mon, day;
		cin >> mon;
		
		if( cin.eof() )		break;
		
		cin >> day;
		
		for(int i = 1; i < mon; i++) {
			switch(i) {
			case 2:
				day += 29;
				break;
			case 4:
			case 6:
			case 9:
			case 11:
				day += 30;
				break;
			default:
				day += 31;
				break;
			}
		}
		
		switch(day % 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;
		}
	}
	
	return 0;
}

C++: #include<stdio.h>
int main(){
  int a,b,s,i;
  int m[12]={31,29,31,30,31,30,31,31,30,31,30,31};
  while(1){ 
 scanf("%d%d",&a,&b);
 if(a==0&&b==0)break;
 s=b;
 for(i=0;i<a-1;i++)s+=m[i];
 if(s%7==1)printf("Thursday\n");
 else if(s%7==2)printf("Friday\n");
 else if(s%7==3)printf("Saturday\n");
 else if(s%7==4)printf("Sunday\n");
 else if(s%7==5)printf("Monday\n");
 else if(s%7==6)printf("Tuesday\n");
 else if(s%7==0)printf("Wednesday\n");
  }
  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <algorithm>

using namespace std;

int dayNum[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string day[7] = { "Monday",
				  "Tuesday",
				  "Wednesday",
				  "Thursday",	// <- 2004/1/1
				  "Friday",
				  "Saturday",
				  "Sunday" };

int main() {
	int m, d;
	
	cin >> m >> d;
	
	while (m != 0 && d != 0) {
		int daySum = 0;
		
		for (int i = 0; i < m - 1; i++) {
			daySum += dayNum[i];
		}
		
		daySum += d;
		
		cout << day[ (daySum + 2) % 7 ] << endl;
		
		cin >> m >> d;
	}
	
	return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int x[13][32], y[13] = { 0,31,29,31,30,31,30,31,31,30,31,30,31 }, sum, n, m; string T[7] = { "Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday" };
int main() {
	sum = 4;
	for (int i = 1; i <= 12; i++) {
		for (int j = 1; j <= y[i]; j++) {
			x[i][j] = sum % 7;
			sum++;
		}
	}
	while (true) {
		cin >> n >> m; if (!n) { break; }
		cout << T[x[n][m]] << endl;
	}
}

C++: #include <stdio.h>

int main(void) {

  int month,day;

  int sum,day_w;
  int month_y[12]={31,29,31,30,31,30,31,31,30,31,30,31};

  int i;

  while(1) {

    scanf("%d %d",&month,&day);

    if(month==0 || day==0) break;

    sum=0;

    for(i=0;i<month-1;i++) {

      sum+=month_y[i];

    }

    sum+=day;

    day_w=sum%7;

    switch(day_w) {

    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 day30[5] = {3,4,6,9,11};

  while(1) {
  int m,d;
  cin >> m >> d;
  if(m == 0 && d == 0) break;
  int a = 1,b = 1,count = 0;

  while(1) {

    if(a == m && b == d) break;
    
    b++;
    count++;

    if(a == 2 && b == 30) {
      a++;
      b = 1;
    }
    else if(b == 31) {
      for(int i=0;i<5;i++) 
	if(day30[i] == a) {
	  a++;
	  b = 1;
	  break;
	}
    }
    if( b == 32) {
      a++;
      b = 1;
    }
  }
  
  if(count % 7 == 4 ) cout <<"Monday"<<endl;
  else if(count % 7 == 5) cout << "Tuesday"<<endl;
  else if(count % 7 == 6) cout <<"Wednesday"<< endl;
  else if(count % 7 == 0) cout <<"Turseday"<< endl;
  else if(count % 7 ==1) cout << "Friday" << endl;
  else if(count % 7 ==2)cout << "Saturday" << endl;
  else if(count % 7 ==3) cout << "Sunday" << endl;
  
  }

  return 0;
}

C++: #include <iostream>
using namespace std;
int main (){
    int a,b;
    while (cin >> a >>b){
        if(a==0 && b==0)
            break;
        switch (a){
            case 1 : break;
            case 2 : b+=31; break;
            case 3 : b+=60; break;
            case 4 : b+=91; break;
            case 5 : b+=121; break;
            case 6 : b+=152; break;
            case 7 : b+=182; break;
            case 8 : b+=213; break;
            case 9 : b+=244; break;
            case 10 : b+=274; break;
            case 11 : b+=305; break;
            case 12 : b+=335; break;
        }
        switch (b%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;
        }
    }
}