Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
	"time"
)

var sc = bufio.NewScanner(os.Stdin)

//Sliceconvtoi ...
func Sliceconvtoi() []int {
	strs := strings.Split(sc.Text(), " ")

	var ints []int
	var x int

	for _, s := range strs {
		x, _ = strconv.Atoi(s)
		ints = append(ints, x)
	}

	return ints
}

func main() {
	for sc.Scan() {
		i := Sliceconvtoi()

		if i[0] == 0 && i[1] == 0 {
			break
		}

		m := time.Month(i[0])
		d := i[1]
		t := time.Date(2004, m, d, 0, 0, 0, 0, time.Local)
		fmt.Println(t.Weekday())
	}

}

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;
        }
    }
}

C++: #include <iostream>
using namespace std;
int sunday(int);
int monday(int);
int tuesday(int);
int wednesday(int);
int thursday(int);
int flyday(int);
int saturday(int);


int main(){
  int day ,month ,today;
  while(true){
    cin >> month >> day;
    if( month == 0 && day == 0 ){
      break;
    }

    if( month == 1 || month == 4 || month == 7 ){
      today = thursday(day);
    }
    
    if( month == 9 || month == 12 ){
      today = wednesday(day);
    }
    
    if( month == 3 || month == 11 ){
      today =  monday(day);
    }
    
    if( month == 6 ){
      today =  tuesday(day);
    }
    
    if( month == 2 || month == 8 ){
      today = sunday(day);
    }
    
    if( month == 10 ){
      today =  flyday(day);
    }
    
    if( month == 5 ){
      today =  saturday(day);
    }

    switch(today){
    case 0:
      cout << "Sunday" << endl;
      break;

    case 1:
      cout << "Monday" << endl;
      break;
    
    case 2:
      cout << "Tuesday" << endl;
      break;

    case 3:
      cout << "Wednesday" << endl;
      break;

    case 4:
      cout << "Thursday" << endl;
      break;
    
    case 5:
      cout << "Friday" << endl;
      break;

    case 6:
      cout << "Saturday" << endl;
      break;
    }
  }
  return 0;
}
  
int sunday(int day){
  int i ,today=0;
  for( i=1 ; i<day ; i++ ){
    today++;
    if( today == 7 ){
      today = 0;
    }
  }
  return today;
}


int monday(int day){
   int i ,today=1;
  for( i=1 ; i<day ; i++ ){
    today++;
    if( today == 7 ){
      today = 0;
    }
  }
  return today;
}


int tuesday(int day){
   int i ,today=2;
  for( i=1 ; i<day ; i++ ){
    today++;
    if( today == 7 ){
      today = 0;
    }
  }
  return today;
}


int wednesday(int day){
   int i ,today=3;
  for( i=1 ; i<day ; i++ ){
    today++;
    if( today == 7 ){
      today = 0;
    }
  }
  return today;
}


int thursday(int day){
    int i ,today=4;
  for( i=1 ; i<day ; i++ ){
    today++;
    if( today == 7 ){
      today = 0;
    }
  }
  return today;
}


int flyday(int day){
  int i ,today=5;
  for( i=1 ; i<day ; i++ ){
    today++;
    if( today == 7 ){
      today = 0;
    }
  }
  return today;
}


int saturday(int day){
    int i ,today=6;
  for( i=1 ; i<day ; i++ ){
    today++;
    if( today == 7 ){
      today = 0;
    }
  }
  return today;
}