Problem:
日数
2 つの日付を入力とし、その 2 つの日付けの間の日数を出力するプログラムを作成してください。
日付 1 (
y
1
, m
1
, d
1
) は日付 2 (
y
2
, m
2
, d
2
) と同じか、あるいはそれ以前の日付とします。日付 1 は日数に含め、日付 2 は含めません。また、うるう年を考慮にいれて計算してください。うるう年の条件は次のとおりとします。
西暦年が 4 で割り切れる年であること。
ただし、100 で割り切れる年はうるう年としない。
しかし、400 で割り切れる年はうるう年である。
Input
複数のデータセットが与えられます。各データセットの形式は以下のとおりです：
y
1
m
1
d
1
y
2
m
2
d
2
y
1
,
m
1
,
d
1
,
y
2
,
m
2
,
d
2
のいずれかが負の数のとき入力の終わりとします。
データセットの数は 50 を超えません。
Output
データセットごとに、日数を１行に出力してください。
Sample Input
2006 9 2 2006 9 3
2006 9 2 2006 11 11
2004 1 1 2005 1 1
2000 1 1 2006 1 1
2000 1 1 2101 1 1
-1 -1 -1 -1 -1 -1
Output for the Sample Input
1
70
366
2192
36890

Submitted solutions:

code_snippet: #include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 2000000000000000001

int is_uruu(int y){
	if(y%400==0)return 1;
	if(y%100==0)return 0;
	if(y%4==0)return 1;
	return 0;
}

int get(int y,int m){
	vector<int> ms = {0,31,28,31,30,31,30,31,31,30,31,30,31};
	if(m!=2)return ms[m];
	return ms[2] + is_uruu(y);
}

void nxt(int &y,int &m,int &d){
	d++;
	if(get(y,m)<d){
		d = 1;
		m++;
		if(m==13){
			m = 1;
			y++;
		}
	}
}

int main(){
	
	while(true){
		vector<int> y(2),m(2),d(2);
		rep(i,2)cin>>y[i]>>m[i]>>d[i];
		bool f = true;
		rep(i,2){
			if(y[i]<0||m[i]<0||d[i]<0)f = false;
		}
		if(!f)break;
		int ans = 0;
		while(true){
			if(y[0]==y[1]&&m[0]==m[1]&&d[0]==d[1])break;
			ans++;
			nxt(y[0],m[0],d[0]);
		}
		cout<<ans<<endl;
	}
	
    return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 3188
final_rank: 11

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(a) sort(a.begin(),a.end())
#define rSORT(a) sort(a.rbegin(),a.rend())
#define fSORT(a,f) sort(a.begin(),a.end(),f)
#define all(a) a.begin(),a.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define tp(a,i) get<i>(a)
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

ll ctod(ll y, ll m, ll d) {
    // 1・2月 → 前年の13・14月
    if (m <= 2) {
        --y;
        m += 12;
    }
    ll dy = 365 * (y - 1); // 経過年数×365日
    ll c = y / 100;
    ll dl = (y >> 2) - c + (c >> 2); // うるう年分
    ll dm = (m * 979 - 1033) >> 5; // 1月1日から m 月1日までの日数
    return dy + dl + dm + d - 1;
}
bool uru(ll y) {
    if (y % 400 == 0)return true;
    if (y % 100 == 0)return false;
    if (y % 4 == 0)return true;
    return false;
}
ll month[2][13] = {
    {0,31,28,31,30,31,30,31,31,30,31,30,31}
    ,{0,31,29,31,30,31,30,31,31,30,31,30,31}
};
void nextday(ll& y, ll& m, ll& d) {
    if (d == month[uru(y)][m]) {
        m++;
        d = 1;
    }
    else d++;
    if (m == 13) {
        y++;
        m = 1;
    }
}

int main() {
    init();

    for (ll a, b, c, x, y, z; cin >> a >> b >> c >> x >> y >> z && 0 <= a;) {
        int ans = 0;
        for (; a != x || b != y || c != z; ++ans)
            nextday(a, b, c);
        print(ans);
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3152
final_rank: 10

code_snippet: #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999
//#define INF (1LL<<59)

//verified
class date{
public:
    int y,m,d;
    
    date(int _y=0, int _m=0, int _d=0):y(_y),m(_m),d(_d){};
    
    bool isLeap(){ return y%400==0||(y%4==0&&y%100); }
    
    date operator + (const int day)const{
        int days_of_month[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
        date t = *this;
        t.d+=day;
        if(  days_of_month[t.m]+(t.isLeap()&&t.m==2) >= t.d  )return date(t.y,t.m,t.d);
        int dom;
        while(  (dom = days_of_month[t.m]+(t.isLeap()&&t.m==2)) < t.d  ){
            t.d -= dom;
            if(t.m==12) t.y++,t.m=1;
            else        t.m++;
        }
        return t;
    }
    
    bool operator > (const date &date)const{
        int ymd1[] = {y,m,d};
        int ymd2[] = {date.y,date.m,date.m};
        rep(i,3){
            if(ymd1[i]>ymd2[i])return true;
            if(ymd1[i]<ymd2[i])return false;
        }
        return false;
    }
    
    bool operator == (const date &date)const{ return (y==date.y && m==date.m && d==date.d); }
    bool operator != (const date &date)const{ return !(*this==date); }
    bool operator <  (const date &date)const{ return ( !(*this>date) && !(*this==date) ); }
};



int main(){
    while(1){
        date ymd[2];
        rep(i,2)cin>>ymd[i].y>>ymd[i].m>>ymd[i].d;
        if(ymd[0].y==-1)break;
        if(ymd[0]>ymd[1])swap(ymd[0],ymd[1]);
        
        int c=0;
        while(ymd[0]!=ymd[1]){
            c++;
            ymd[0] = ymd[0]+1;
        }
        cout<<c<<endl;
    }
    
}
accuracy: 1
time_ms: 10
memory_kb: 3016
final_rank: 9

code_snippet: #include<iostream>
using namespace std;
int x[5000000], day[13][32], day2[13][32], cnt, a, b, c, d, e, f, daya1, daya2;
int days[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
int days2[13] = { 0,31,29,31,30,31,30,31,31,30,31,30,31 };
int main() {
	for (int i = 1; i < 5000000; i++) {
		if ((i % 4 == 0 && i % 100>0) || i % 400 == 0) {
			x[i] = x[i - 1] + 366;
		}
		else {
			x[i] = x[i - 1] + 365;
		}
	}
	for (int i = 1; i <= 12; i++) {
		for (int j = 1; j <= days[i]; j++) {
			day[i][j] = cnt;
			cnt++;
		}
	}
	cnt = 0;
	for (int i = 1; i <= 12; i++) {
		for (int j = 1; j <= days2[i]; j++) {
			day2[i][j] = cnt;
			cnt++;
		}
	}
	while (true) {
		cin >> a >> b >> c >> d >> e >> f;
		if (a < 0) { break; }
		if (b < 0) { break; }
		if (c < 0) { break; }
		if (d < 0) { break; }
		if (e < 0) { break; }
		if (f < 0) { break; }
		daya1 = 0; daya2 = 0;
		daya1 += x[a - 1];
		daya2 += x[d - 1];
		if ((a % 4 == 0 && a % 100>0) || a % 400 == 0) {
			daya1 += day2[b][c];
		}
		else {
			daya1 += day[b][c];
		}
		if ((d % 4 == 0 && d % 100>0) || d % 400 == 0) {
			daya2 += day2[e][f];
		}
		else {
			daya2 += day[e][f];
		}
		cout << daya2 - daya1 << endl;
	}
}
accuracy: 1
time_ms: 10
memory_kb: 20692
final_rank: 13

code_snippet: #include <iostream>
using namespace std;
int main(){
  int y1,m1,d1,y2,m2,d2,cnt,u,r;
  int d[13]={0,32,29,32,31,32,31,32,32,31,32,31,32};
  while(1){
    cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2;
    if(y1<0||m1<0||d1<0||y2<0||m2<0||d2<0) break;
    cnt=0;
    while(1){
      if(y1==y2&&m1==m2&&d1==d2) break;
      u=0;
      if(y1%400==0) u=1;
      else if(y1%100==0) u=0;
      else if(y1%4==0) u=1;
      if(u==1&&m1==2){
	if(d1==d[m1]+1){
	  m1++;
	  d1=1;
	}else{
	  cnt++;
	  d1++;
	}
      }else{
	if(d1==d[m1]){
	  if(m1==12) m1=1,y1++;
	  else m1++;
	  d1=1;
	}else{
	  cnt++;
	  d1++;
	}
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 1160
final_rank: 3

code_snippet: #include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
int mo[12]={31,28,31,30,31,30,31,31,30,31,30,31};
bool is_leap(int a){
	if(a%400==0) return true;
	if(a%100==0) return false;
	if(a%4==0) return true;
	return false;
}
int foo2(int y1,int m1,int d1,int y2,int m2,int d2){
	int ret=0;
	while(!(y1==y2&&m1==m2&&d1==d2)){
		ret++;
		// int t;
		// cin>>t;
		// cout<<y1<<" "<<m1<<" "<<d1<<endl;
		if(m1==12&&d1==31){
			y1++;
			m1=1;
			d1=1;
		}
		else if(is_leap(y1)&&m1==2){
			if(d1==29){
				m1++;
				d1=1;
			}
			else{
				d1++;
			}
		}
		else if(mo[m1-1]>d1){
			d1++;
		}
		else{
			m1++;
			d1=1;
		}
	}
	return ret;
}
int foo(int y,int m,int d){
	bool f=is_leap(y);
	int ret=0;
	while(m<=12){
		if(m==2&&f){
			ret+=mo[m-1]-d+2;
		}
		else{
			ret+=mo[m-1]-d+1;
		}
		m++;
		d=1;
	}
	// cout<<"ret "<<ret<<endl;
	return ret;
}


void mainmain(){
	vint a(6);
	while(1){
		rep(i,6){
			cin>>a[i];
			if(a[i]==-1) return;
		}
		cout<<foo2(a[0],a[1],a[2],a[3],a[4],a[5])<<endl;
		continue;
		int ans=0;
		if(a[0]==a[3]){
			cout<<-foo(a[3],a[4],a[5])+foo(a[0],a[1],a[2])<<endl;
			continue;
		}
		rep(i,2) ans+=foo(a[0+i*3],a[1+i*3],a[2+i*3]);
		ans-=365;
		if(is_leap(a[3])&&(a[4]==1||a[4]==2)) ans--;
		a[0]++;
		while(a[0]!=a[3]){
			 if(is_leap(a[0])) ans++;
			 ans+=365;
			 a[0]++;
		}
		cout<<ans<<endl;
	}
}



}
main() try{
    mainmain();
}
catch(...){
}
accuracy: 1
time_ms: 10
memory_kb: 1192
final_rank: 8

code_snippet: #include <stdio.h>

int main(void)
{
	int y, m, d, y2, m2, d2;
	int i, j;
	int ans;
	char month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	
	while (1){
		scanf("%d %d %d %d %d %d", &y, &m, &d, &y2, &m2, &d2);
		
		if (y < 0 || m < 0 || d < 0 || y2 < 0 || m2 < 0 || d2 < 0){
			break;
		}
		
		ans = 0;
		
		while (1){
			
			if (y == y2 && d == d2 && m == m2){
				break;
			}
			
			ans++;
			d++;
			
			if (d > month[m - 1]){
				d = 1;
				m++;
			}
			if (m > 12){
				m = 1;
				y++;
			}
			
			if ( (y % 4 == 0 && y % 100 != 0) || y % 400 == 0){
				month[1] = 29;
			}
			else {
				month[1] = 28;
			}
		}
		
		printf("%d\n", ans);
	}
	
	return (0);
}
accuracy: 1
time_ms: 10
memory_kb: 1024
final_rank: 1

code_snippet: #include <iostream>
#include <algorithm>
using namespace std;

const int n_day[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
 
struct Date {
  // year, month[1,12], day(1 origin), a day of the week[0,6]
  int y, m, d, e;
  Date() {}
  Date(int y, int m, int d, int e = -1) : y(y), m(m), d(d), e(e) {}
 
  bool operator < (const Date &o) const {
    if(y != o.y) return y < o.y;
    if(m != o.m) return m < o.m;
    return d < o.d;
  }
 
  bool isLeapYear() {
    if(y % 400 == 0) return true;
    if(y % 100 == 0) return false;
    if(y % 4 == 0) return true;
    return false;
  }

  int getDays() {
    int nd = n_day[m];
    if(m == 2) nd += isLeapYear();
    return nd;
  }

  void next() {
    e = (e+1)%7;
    if(d == getDays()) {
      d = 1;
      if(m == 12) {
        m = 1;
        ++y;
      } else {
        ++m;
      }
    } else {
      ++d;
    }
  }
 
  void back() {
    e = (e+6)%7;
    if(d == 1) {
      if(m == 1) {
        m = 12;
        --y;
      } else {
        --m;
      }
      d = getDays();
    } else {
      --d;
    }
  }
};

// AOJ 0125
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;
    Date d(y1,m1,d1), end(y2,m2,d2);
    int res = 0;
    while(d < end) {
      ++res;
      d.next();
    }
    cout << res << endl;
  }
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 1160
final_rank: 3

code_snippet: #include<iostream>
using namespace std;

int p[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
int y2,m2,d2;

int leap(int y){
  if( !(y%400) ) return 1;
  if( !(y%100) ) return 0;
  if( !(y%4) ) return 1;
  return 0;
}

int solve(int y, int m, int d){

  if(y == y2 && m == m2 && d == d2) return 0;

  if(leap(y) && m == 2 && d == 28) return solve(y,3,1)+2;
  else if(m == 12 && d == 31) return solve(y+1,1,1)+1;
  else if(p[m] == d) return solve(y,m+1,1)+1;
  else return solve(y,m,d+1)+1;

}

int main(){

  int y,m,d;

  while(true){
    cin >> y >> m >> d >> y2 >> m2 >> d2;
    if(y < 0 || m < 0 || d < 0 || y2 < 0 || m2 < 0 || d2 < 0) break;

    cout << solve(y, m, d) << endl;
  }

}
accuracy: 1
time_ms: 10
memory_kb: 1160
final_rank: 3

code_snippet: #include<iostream>
using namespace std;

int p[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
int y2,m2,d2;

bool leap(int y){

  if(y%400 == 0) return true;
  if(y%100 == 0) return false;
  if(y%4 == 0) return true;
  return false;

}

int solve(int y, int m, int d){

  if(y == y2 && m == m2 && d == d2) return 0;

  if(leap(y) && m == 2 && d == 28) return solve(y,3,1)+2;
  else if(m == 12 && d == 31) return solve(y+1,1,1)+1;
  else if(p[m] == d) return solve(y,m+1,1)+1;
  else return solve(y,m,d+1)+1;

}

int main(){

  int y,m,d;

  while(true){
    cin >> y >> m >> d >> y2 >> m2 >> d2;
    if(y < 0 || m < 0 || d < 0 || y2 < 0 || m2 < 0 || d2 < 0) break;

    cout << solve(y, m, d) << endl;
  }

}
accuracy: 1
time_ms: 10
memory_kb: 1160
final_rank: 3

code_snippet: #include<iostream>
using namespace std;

int p[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

bool leap(int y){

  if(y%400 == 0) return true;
  if(y%100 == 0) return false;
  if(y%4 == 0) return true;
  return false;
}

int solve(int y1, int m1, int d1, int y2, int m2, int d2){

  if(y1 == y2 && m1 == m2 && d1 == d2) return 0;

  if(leap(y1) && m1 == 2 && d1 == 28) return solve(y1,3,1,y2,m2,d2)+2;
  else if(m1 == 12 && d1 == 31) return solve(y1+1,1,1,y2,m2,d2)+1;
  else if(p[m1] == d1) return solve(y1,m1+1,1,y2,m2,d2)+1;
  else return solve(y1,m1,d1+1,y2,m2,d2)+1;

}

int main(){

  int y1,m1,d1,y2,m2,d2;

  while(true){
    cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2;
    if(y1 < 0 || m1 < 0 || d1 < 0) break;
    if(y2 < 0 || m2 < 0 || d2 < 0) break;

    cout << solve(y1, m1, d1, y2, m2, d2) << endl;
  }

}
accuracy: 1
time_ms: 10
memory_kb: 1160
final_rank: 3

code_snippet: #include<iostream>
using namespace std;
typedef long long ll;

const int MNUM[] = {12,12};
const int ML[][12] = { {31,28,31,30,31,30,31,31,30,31,30,31},      //day/month in usual year
		      {31,29,31,30,31,30,31,31,30,31,30,31} };  //day/month in leap year
const string DAY[] = {"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){}

  int Leap(void){
    if(y%400==0)return 1;
    if(y%100==0)return 0;
    if(y%4==0)return 1;
    return 0;
  }

  date next(void){
    int l = Leap();
    if(ML[l][m-1]<++d){ d=1; m++; }
    if(MNUM[l]<m){ m=1; y++; }
    return *this;
  }

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

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

  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 operator-(const date x)const{
    return dayCount() - x.dayCount();
  }
};

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;
  }
}
accuracy: 1
time_ms: 110
memory_kb: 1200
final_rank: 14

code_snippet: #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;
}
accuracy: 1
time_ms: 100
memory_kb: 1200
final_rank: 12

code_snippet: #include <cstdio>

using namespace std;

int main(void) {
    while (1) {
        int y1, m1, d1, y2, m2, d2;
        scanf("%d%d%d%d%d%d", &y1, &m1, &d1, &y2, &m2, &d2);
        if (y1 < 0 || m1 < 0 || d1 < 0 || y2 < 0 || m2 < 0 || d2 < 0) {
            break;
        }
        int d = 0;
        while (y1 != y2 || m1 != m2 || d1 != d2) {
            d++;
            d1++;
            /* 2 4 6 9 11 */
            /* 1 3 5 7 8 10 12 */
            // printf("%4d %2d %2d\n", y1, m1, d1);
            if (((m1 == 4 || m1 == 6 || m1 == 9 || m1 == 11) && d1 > 30) ||
                ((m1 == 1 || m1 == 3 || m1 == 5 ||m1 == 7 || m1 == 8 || m1 == 10 || m1 == 12) && d1 > 31)) {
                d1 = 1;
                m1++;
            } else if (m1 == 2) {
                if (y1 % 4 == 0 && y1 % 100 != 0 || y1 % 400 == 0) {
                    if (d1 > 29) {
                        d1 = 1;
                        m1++;
                    }
                } else if (d1 > 28) {
                    d1 = 1;
                    m1++;
                }
            }
            if (m1 > 12) {
                m1 = 1;
                y1++;
            }
        }
        printf("%d\n", d);
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 1024
final_rank: 1