Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		input := strings.Split(scanner.Text(), " ")
		ele_t1 := [3]int{}
		ele_t2 := [3]int{}
		for i := range ele_t1 {
			ele_t1[i], _ = strconv.Atoi(input[i])
			ele_t2[i], _ = strconv.Atoi(input[i+3])
		}
		if ele_t1[0] < 0 || ele_t1[1] < 0 || ele_t1[2] < 0 ||
			ele_t2[0] < 0 || ele_t2[1] < 0 || ele_t2[2] < 0 {
				break
		}
		t1 := time.Date(ele_t1[0], time.Month(ele_t1[1]), ele_t1[2], 0, 0, 0, 0, time.UTC)
		t2 := time.Date(ele_t2[0], time.Month(ele_t2[1]), ele_t2[2], 0, 0, 0, 0, time.UTC)
		diff := t2.Sub(t1)
		fmt.Printf("%v\n", int64(diff/(time.Hour*24)))
	}
}

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

int leap[1000000] = {0};

int main(){
    long long days1,days2;
    int y1,m1,d1,y2,m2,d2;
    for(int i=0;i<=STA;i++){
        if(i % 400 == 0 ||(i % 4 == 0 && i % 100 != 0)) leap[i] = 1;
    }
    while(1){
        days1 = 0;
        days2 = 0;
        cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2;
        if(y1 < 0 || m1 < 0 || d1 < 0 || y2 < 0 || m2 < 0 || d2 < 0) break;
        for(int i=0;i<y1;i++){
            if(leap[i] == 1) days1 += 366;
            else days1 += 365;
        }
        for(int i=0;i<y2;i++){
            if(leap[i] == 1) days2 += 366;
            else days2 += 365;
        }
        for(int i=1;i<m1;i++){
            switch(i){
                case 4:
                case 6:
                case 9:
                case 11:
                    days1 += 30;
                    break;
                case 2:
                    if(leap[y1] == 1) days1 += 29;
                    else days1 += 28;
                    break;
                default:
                    days1 += 31;
                    break;
            }
        }
        for(int i=1;i<m2;i++){
            switch(i){
                case 4:
                case 6:
                case 9:
                case 11:
                    days2 += 30;
                    break;
                case 2:
                    if(leap[y2] == 1) days2 += 29;
                    else days2 += 28;
                    break;
                default:
                    days2 += 31;
                    break;
            }
        }
        days1 += d1;
        days2 += d2;
        cout << days2 - days1 << endl;
    }
}

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


using namespace std;


int day_per_month[13] ={0,31, 28, 31, 30, 31, 30 ,31, 31, 30, 31, 30, 31};
int day_per_month_leap_year[13] ={0,31, 29, 31, 30, 31, 30 ,31, 31, 30, 31, 30, 31};

int main(){

    int y1, m1, d1, y2, m2, d2;
    while(cin>>y1>>m1>>d1>>y2>>m2>>d2){
        if(y1<0||m1<0||d1<0||y2<0||m2<0||d2<0){
            break;
        }
        int y,m;
        y=y1;
        int day = 0;

        
        while(1){
            if(y+1>y2)break;
            
            day+=365;
            if(y%4==0){
                day++;
                if(y%100==0){
                    day--;
                    if(y%400==0){
                        day++;
                    }
                }
            }
            y++;
            
        }
        
        if(m1<m2){
            m=m1;
            while(1){
                if(m+1>m2)break;
                double flag=false;
                if(y1%4==0){
                    flag=true;
                    if(y1%100==0){
                        flag=false;
                        if(y1%400){
                            flag=true;
                        }
                    }
                }
                
                if(flag){
                    day+=day_per_month_leap_year[m];
                    m++;
                }else{
                    day+=day_per_month[m];
                    m++;
                }
            }
        }else if(m1>m2){
            m=m2;
            while(1){
                if(m-1<m1)break;
                double flag=false;
                if(y2%4==0){
                    flag=true;
                    if(y2%100==0){
                        flag=false;
                        if(y2%400){
                            flag=true;
                        }
                    }
                }
                
                if(flag){
                    day-=day_per_month_leap_year[m];
                    m++;
                }else{
                    day-=day_per_month[m];
                    m++;
                }
            }
        }
        
        day+=d2-d1;
        
        cout<<day<<endl;
        
        
        
    }
}

C++: #include<iostream>
#include<cmath>
#include<vector>
using namespace std;
typedef long long ll;

const int MNUM = 12, leapMNUM = 12;
const int ML[] = {31,28,31,30,31,30,31,31,30,31,30,31};      //day/month in usual year
const int leapML[] = {31,29,31,30,31,30,31,31,30,31,30,31};  //day/month in leap year
const string days[] = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};

struct date{
  int y,m,d;

  date(void):y(0),m(1),d(1){}
  date(int a,int b,int c):y(a),m(b),d(c){}
  
  bool isLeap(void){
    if(y%400==0)return true;
    if(y%100==0)return false;
    if(y%4==0)return true;
    return false;
  }

  date next(void){
    d++;
    if(isLeap()){
      if(leapML[m-1]<d){ d=1; m++; }
      if(leapMNUM<m){ m=1; y++; }
    }else{
      if(ML[m-1]<d){ d=1; m++; }
      if(MNUM<m){ m=1; y++; }
    }
    return *this;
  }

  bool operator==(const date x)const{return (y==x.y && m==x.m && d==x.d);}

  bool operator<(const date x)const{
    if(y!=x.y)return y<x.y;
    if(m!=x.m)return m<x.m;
    return d<x.d;
  }

  bool operator<=(const date x)const{return (*this==x || *this<x); }
  bool operator>(const date x)const{return !(*this<=x);}
  bool operator>=(const date x)const{return !(*this<x);}

  ll dayCount(void)const{
    date tmp;
    for(ll res=0;;res++){
      if(tmp==*this)return res;
      tmp.next();
    }
    return 0;
  }

  ll operator-(const date x)const{
    return dayCount() - x.dayCount();
  }

  //calculate days from Julian Day(-4713/01/01) using Fliegel's formula.
  ll Fliegel(void){
    int a = (14-m)/12, Y = y+4800-a, M = m+12*a-3;
    return (ll)d + (153*M+2)/5 + 365*Y + Y/4 - Y/100 + Y/400 - 32045;
  }

  //calculate day of week using Zeller congruence.
  int Zeller(void){
    int Y = y, M = m;
    if(M<3){ Y--; M+=12; }
    return (Y + Y/4 - Y/100 + Y/400 + (13*M+8)/5 + d)%7;
  }
};

int main(){
  int y1,m1,d1,y2,m2,d2;
  while(cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2,y1>=0)
    cout << date(y2,m2,d2)-date(y1,m1,d1) << endl;
}

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

using namespace std;

bool uru(int n){
	if( (n%4==0 && n%100!=0) || (n%4==0 && n%100==0 && n%400==0) )
		return true;
	else return false; 
}

int main(){
	while(1){
		int y1, y2, m1, m2, d1, d2;
		int d[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
		long ans=0;
		
		cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2;
		if(y1==-1) break;
	
		if(y1==y2){
			if(m1==m2) ans=d2-d1;
			else{
				ans += d[m1-1]-d1+1;
				if(uru(y1) && m1==2) ++ans;
				++m1;
			
				while(m1!=m2){
					ans += d[m1-1];
					if(uru(y1) && m1==2) ++ans;
						
					++m1;
					//printf("%ld\n", ans);
				
				}
				ans+=d2-1;
			}
				
		}else{
			ans += d[m1-1]-d1+1;
			if(uru(y1) && m1==2) ++ans;
			++m1;	
			//printf("%ld\n", ans);
		
			while(m1<=12){
					ans += d[m1-1];
					if(uru(y1) && m1==2) ++ans;
						
					++m1;
					//printf("%ld\n", ans);
			}
			
			ans += d2-1;
			--m2;
			
			while(m2>=1){
					ans += d[m2-1];
					if(uru(y2) && m2==2) ++ans;
						
					//printf("%ld\n", ans);
					--m2;
			}
		
			for(int i=y1+1; i<=y2-1; ++i){
				if(uru(i)) ans += 366;
				else ans += 365;
			} 
	
		}
	
		printf("%ld\n", ans);
	
	}

	return 0;
}