Problem:
マヤの大予言
真也君はテレビで「マヤの大予言！2012年で世界が終る？」という番組を見ました。結局、世界が終るかどうかはよくわかりませんでしたが、番組で紹介されていたマヤの「長期暦」という暦に興味を持ちました。その番組では以下のような説明をしていました。
マヤ長期暦は、右の表のような単位からなる、全部で13バクトゥン(187万2000日)で構成される非常に長い暦である。ある計算法では、この暦は紀元前3114年8月11日に始まり2012年12月21日に終わると考えられていて、このため今年の12月21日で世界が終るという説が唱えられている。しかし、13バクトゥンで１サイクルとなり、今の暦が終わったら新しいサイクルに入るだけという考えもある。
１キン＝１日
１ウィナル＝２０キン
１トゥン＝１８ウィナル
１カトゥン＝２０トゥン
１バクトゥン＝２０カトゥン
「ぼくの二十歳の誕生日はマヤ暦だと何日になるのかな？」真也君はいろいろな日をマヤ長期暦で表してみたくなりました。
では、真也君の代わりに、西暦とマヤ長期暦とを相互変換するプログラムを作成してください。
入力
入力は複数のデータセットからなる。入力の終わりは#１つの行で示される。各データセットは以下の形式で与えられる。
b.ka.t.w.ki
または
y.m.d
データセットは１つの文字列を含む１行からなる。b.ka.t.w.ki はマヤ長期暦の日付、y.m.d は西暦の日付である。与えられる単位は以下の通りである。
マヤ長期暦
b
バクトゥン
(0 ≤ b< 13)
ka
カトゥン
(0 ≤ ka < 20)
t
トゥン
(0 ≤ t< 20)
w
ウィナル
(0 ≤ w < 18)
ki
キン
(0 ≤ ki < 20)
西暦
y
年
(2012 ≤ y ≤ 10,000,000)
m
月
(1 ≤ m ≤ 12)
d
日
(1 ≤ d ≤ 31)
西暦の日の最大値は、大の月、小の月、うるう年かどうかで変わる(うるう年は 4 の倍数の年のうち、100 で割り切れない年か、400 で割り切れる年である)。マヤ長期暦の日付の範囲は 0.0.0.0.0 から 12.19.19.17.19 までとする。ただし、マヤ長期暦の 0.0.0.0.0 は西暦の 2012.12.21 に対応する。また、西暦の日付の範囲は 2012.12.21から 10000000.12.31 までとする。
データセットの数は 500 を超えない。
出力
入力が西暦のときはマヤ長期暦を、マヤ長期暦のときは西暦を、それぞれ入力と同じ形式で出力する。
入力された西暦を換算した結果、マヤ長期暦の次のサイクルに入った場合でも b.ka.t.w.ki の形式で出力してよい。
入力例
2012.12.31
2.12.16.14.14
7138.5.13
10.5.2.1.5
10000000.12.31
#
出力例
0.0.0.0.10
3054.8.15
0.0.0.0.10
6056.2.29
8.19.3.13.2

Submitted solutions:

code_snippet: #include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define Rrep(i,n) for(int i=n-1;i>=0;i--)
#define Rrep1(i,n) for(int i=n;i>0;i--)
#define all(a) a.begin(),a.end()
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
#define INF ((ll)4e18)
#define IINF ((int)1e9)
const double PI = 3.141592653589793;//2384626433832795028841971;
template<typename T>inline bool chmax(T& a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T>inline bool chmin(T& a, T b) { return ((a > b) ? (a = b, true) : (false)); }
#define yesno(ans) cout<<((ans)?"Yes\n":"No\n")
bool eq(double a, double b) { return abs(a - b) < 0.0000001; }
//LRUD
const int di[4] = { 0,-1,0,1 };
const int dj[4] = { -1,0,1,0 };
//const int di[8] = { 0,0,1,1,1,-1,-1,-1 };
//const int dj[8] = { 1,-1,0,-1,1,0,-1,1 };

/*ACL
#include <atcoder/all>
using namespace atcoder;
//using mint=modint;
using mint = modint998244353;
//using mint=modint1000000007;
using vm=vector<mint>;
using vvm=vector<vm>;
using vvvm=vector<vvm>;
//*/

const ll D_2012_=735222+2;
int D[]={31,28,31,30,31,30,31,31,30,31,30,31};
int Dleap[]={31,29,31,30,31,30,31,31,30,31,30,31};

ll gd(string &s){
    string tmp="";
    while(s.size()&&s.back()!='.')tmp+=s.back(),s.pop_back();
    if(s.size()>0)s.pop_back();
    return stoll(tmp);
}
ll leap_num(ll a,ll b){//a年からb年の間のうるう年 [a,b)
    b--,a--;
    return (b/4-b/100+b/400)-(a/4-a/100+a/400);
}

bool isleap(ll y){
    return ((y%4==0&&(y%100!=0)||(y%400==0)));
}
ll all_day(ll y,ll m,ll d){
    return 1;
}
void toSeireki(ll b,ll ka,ll t,ll w,ll ki){
    ka+=b*20,b=0;
    t+=ka*20;ka=0;
    w+=t*18,t=0;
    ki+=w*20;
    ll y=0,m=0,d=ki+D_2012_;
    while(d>365+isleap(y)){
        if(isleap(y))d-=366;
        else d-=365;
        y++;
    }
    m++;
    while(1){
        ll sub=0;
        if(isleap(y))sub=Dleap[m-1];
        else sub=D[m-1];
        if(d-sub<=0)break;
        d-=sub;
        m++;
    }
    printf("%lld.%lld.%lld\n",y,m,d);
}
void toMaya(ll y,ll m,ll d){
    m--;
    for(;m>0;m--){
        if(isleap(y))d+=Dleap[m-1];
        else d+=D[m-1];
    }
    y--;
    for(y;y>=0;y--){
        if(isleap(y))d+=366;
        else d+=365;
    }
    d-=D_2012_;
    ll b,ka,t,w,ki;
    ki=d;
    w=ki/20,ki%=20;
    t=w/18,w%=18;
    ka=t/20,t%=20;
    b=ka/20,ka%=20;
    b%=13;
    printf("%lld.%lld.%lld.%lld.%lld\n",b,ka,t,w,ki);
}
int solve(){
    string S;
    while(cin>>S,S!="#"){
        string tmp="";
        int a,b,c,d,e;
        reverse(all(S));
        a=gd(S);
        b=gd(S);
        c=gd(S);
        if(S.size()==0){     
            toMaya(a,b,c);       
            continue;
        }
        d=gd(S);
        e=gd(S);
        //printf("%d %d %d %d %d\n",a,b,c,d,e);
        toSeireki(a,b,c,d,e);
    }
    return 0;
}

int main()
{
    //std::cin.tie(0)->sync_with_stdio(0);
    int T = 1;
    //cin>>T;
    /*
    ll y=0,m=1,d=1;
    ll ans=0;
    while(y<2012||m<12||d<20){
        d++,ans++;
        if(isleap(y)){
            if(d>Dleap[m-1]){
                d=1;
                m++;
                if(m>12){
                    m=1,y++;
                }
            }
        }else{
            if(d>D[m-1]){
                d=1;
                m++;
                if(m>12){
                    m=1,y++;
                }
            }
        }
        //printf("%lld.%lld.%lld\n",y,m,d);
    }
    cout<<ans<<endl;
    //*/
    while (T--)
    {
        solve();
    }
    return 0;
}
accuracy: 1
time_ms: 1100
memory_kb: 3576
final_rank: 15

code_snippet: #include<iostream>
#include<vector>
#include<string>
#include<sstream>
using namespace std;
typedef long long ll;
static const int D[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
static const int DT[] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365};
static const int MT[] = {144000, 7200, 360, 20, 1};
bool isLeap(int y){ return ( y%4 == 0 && ( y%100 || y%400 == 0 ));}

ll getDay(int y, int m, int d){
  ll sum = 0;
  for ( int i = 1; i <= y; i++ ){
    sum += 365 + (isLeap(i-1)?1:0);
  }
  sum += DT[m-1];
  if ( isLeap(y) && m >= 3 ) sum++;
  sum += d - 1;
  return sum;
}

void toMaya(vector<int> v){
  ll d = getDay(v[0], v[1], v[2]) - getDay(2012, 12, 21);
  d %= MT[0]*13;
  for ( int i = 0; i < 5; i++ ){
    if (i) cout << ".";
    cout << d/MT[i]; d %= MT[i];
  }
  cout << endl;
}

void toGregorian(vector<int> v){
  ll sum = getDay(2012,12,21);
  for ( int i = 0; i < 5; i++ ) sum += v[i]*MT[i];
  ll y = 0, m = 1, d = sum;
  
  while(1){
    int dd = (isLeap(y)?366:365);
    if ( d >= dd ) d -= dd;
    else break;
    y++;
  }

  for ( int i = 0; d >= D[i]; i++ ){
    m = i+2;
    d -= D[i];
    if ( isLeap(y) && i == 1 ) d--;
  }
  d++;
  if ( m == 3 && d == 0 ) { m = 2; d =29; }
  cout << y << "." << m << "." << d << endl;
}

main(){
  string line;
  char ch;
  int x;
  int tcase = 0;
  while(1){
    //cin >> line;
    getline(cin, line);
    if ( line == "#" ) break;
    tcase++;
    vector<int> d;
    stringstream sin(line);
    for ( ; sin >> x ; sin >> ch ) d.push_back(x);
    if ( d.size() == 3 ) toMaya(d);
    else if ( d.size() == 5 ) toGregorian(d);
  }
}
accuracy: 1
time_ms: 910
memory_kb: 3188
final_rank: 3

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct S {
  ll y, m, d;
};
struct Ma {
  ll b, ka, t, w, ki;
};
int M[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

ll check(ll y) { 
  return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)); 
}

S M2S(ll b, ll ka, ll t, ll w, ll ki) {
  ka += b * 20;
  t += ka * 20;
  w += t * 18;
  ki += w * 20;
  S res;
  res.y = 2012, res.m = 12, res.d = 21 + ki;
  ll isLeapYear = check(res.y + 1);
  if (res.d <= 31)
    return res;
  while (res.d / (365 + isLeapYear))
    res.y++, res.d -= (365 + isLeapYear), isLeapYear = check(res.y + 1);
  if (res.d == 0)
    res.m--, res.d = M[res.m - 1] + (isLeapYear && res.m == 2);
  if (res.d <= 31)
    return res;
  res.y++, res.m = 1, res.d -= 31;
  while (res.d / (M[res.m - 1] + (isLeapYear && res.m == 2))) {
    res.d -= (M[res.m - 1] + (isLeapYear && res.m == 2));
    res.m++;
  }
  if (res.d == 0)
    res.m--, res.d = M[res.m - 1] + (isLeapYear && res.m == 2);
  return res;
}

Ma S2M(ll y, ll m, ll d) {
  y -= 2012;
  if (y)
    d += 10;
  else
    d = (d - 21);
  for (int i = 0; i < m - 1 && y; i++)
    d += (M[i] + (i == 1 && check(y + 2012)));
  y--;
  while (y > 0)
    d += (365 + check(y + 2012)), y--;
  Ma res;
  d %= 13 * 20 * 20 * 18 * 20;
  res.ki = d;
  res.w = res.ki / 20;
  res.ki %= 20;
  res.t = res.w / 18;
  res.w %= 18;
  res.ka = res.t / 20;
  res.t %= 20;
  res.b = res.ka / 20;
  res.ka %= 20;
  return res;
}

int main() {
  while (1) {
    string str;
    cin >> str;
    if (str == "#")
      break;
    vector<int> a;
    int i = 0, num = 0;
    while (str[i]) {
      if (str[i] == '.')
        a.push_back(num), num = 0;
      else
        num = num * 10 + str[i] - '0';
      i++;
    }
    a.push_back(num);
    if (a.size() == 5) {
      S ans = M2S(a[0], a[1], a[2], a[3], a[4]);
      cout << ans.y << "." << ans.m << "." << ans.d << endl;
    } else {
      Ma ans = S2M(a[0], a[1], a[2]);
      cout << ans.b << "." << ans.ka << "." << ans.t << "." << ans.w << "."
           << ans.ki << endl;
    }
  }
  return 0;
}
accuracy: 1
time_ms: 1210
memory_kb: 3200
final_rank: 12

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct S {
  ll y, m, d;
};
struct Ma {
  ll b, ka, t, w, ki;
};
int M[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool check(ll y) { return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)); }
S M2S(ll b, ll ka, ll t, ll w, ll ki) {
  ka += b * 20;
  t += ka * 20;
  w += t * 18;
  ki += w * 20;
  S res;
  res.y = 2012, res.m = 12, res.d = 21 + ki;
  if (res.d <= 31)
    return res;
  while (res.d / (365 + check(res.y + 1)))
    res.y++, res.d -= (365 + check(res.y));
  if (res.d == 0)
    res.m--, res.d = M[res.m - 1] + (check(res.y) && res.m == 2);
  if (res.d <= 31)
    return res;
  res.y++, res.m = 1, res.d -= 31;
  while (res.d / (M[res.m - 1] + (check(res.y) && res.m == 2))) {
    res.d -= (M[res.m - 1] + (check(res.y) && res.m == 2));
    res.m++;
  }
  if (res.d == 0)
    res.m--, res.d = M[res.m - 1] + (check(res.y) && res.m == 2);
  return res;
}
Ma S2M(ll y, ll m, ll d) {
  y -= 2012;
  if (y)
    d += 10;
  else
    d = (d - 21);
  for (int i = 0; i < m - 1 && y; i++)
    d += (M[i] + (i == 1 && check(y + 2012)));
  y--;
  while (y > 0)
    d += (365 + check(y + 2012)), y--;
  Ma res;
  d %= 13 * 20 * 20 * 18 * 20;
  res.ki = d;
  res.w = res.ki / 20;
  res.ki %= 20;
  res.t = res.w / 18;
  res.w %= 18;
  res.ka = res.t / 20;
  res.t %= 20;
  res.b = res.ka / 20;
  res.ka %= 20;
  return res;
}
int main() {
  while (1) {
    string str;
    cin >> str;
    if (str == "#")
      break;
    int a[5];
    int i = 0, num = 0, idx = 0;
    while (str[i]) {
      if (str[i] == '.')
        a[idx] = num, num = 0, idx++;
      else
        num = num * 10 + str[i] - '0';
      i++;
    }
    a[idx] = num;
    if (idx == 4) {
      S ans = M2S(a[0], a[1], a[2], a[3], a[4]);
      cout << ans.y << "." << ans.m << "." << ans.d << endl;
    } else {
      Ma ans = S2M(a[0], a[1], a[2]);
      cout << ans.b << "." << ans.ka << "." << ans.t << "." << ans.w << "."
           << ans.ki << endl;
    }
  }
  return 0;
}
accuracy: 1
time_ms: 1210
memory_kb: 3168
final_rank: 9

code_snippet: #include <iostream>
#include <vector>
#include <string>

typedef long long ll;

struct S {
  ll y, m, d;
};

struct Ma {
  ll b, ka, t, w, ki;
};

int M[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

bool isLeapYear(ll y) { return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0); }

S M2S(ll b, ll ka, ll t, ll w, ll ki) {
  ka += b * 20;
  t += ka * 20;
  w += t * 18;
  ki += w * 20;
  S res;
  res.y = 2012, res.m = 12, res.d = 21 + ki;
  if (res.d <= 31)
    return res;
  while (res.d / (365 + isLeapYear(res.y + 1)))
    res.y++, res.d -= (365 + isLeapYear(res.y));
  if (res.d == 0)
    res.m--, res.d = M[res.m - 1] + (isLeapYear(res.y) && res.m == 2);
  if (res.d <= 31)
    return res;
  res.y++, res.m = 1, res.d -= 31;
  while (res.d / (M[res.m - 1] + (isLeapYear(res.y) && res.m == 2))) {
    res.d -= (M[res.m - 1] + (isLeapYear(res.y) && res.m == 2));
    res.m++;
  }
  if (res.d == 0)
    res.m--, res.d = M[res.m - 1] + (isLeapYear(res.y) && res.m == 2);
  return res;
}

Ma S2M(ll y, ll m, ll d) {
  bool isLeap = isLeapYear(y);
  y -= 2012;
  if (y)
    d += 10;
  else
    d = (d - 21);
  for (int i = 0; i < m - 1 && y; i++)
    d += (M[i] + (i == 1 && isLeap));
  y--;
  while (y > 0)
    d += (365 + isLeapYear(y + 2012)), y--;
  Ma res;
  d %= 13 * 20 * 20 * 18 * 20;
  res.ki = d;
  res.w = res.ki / 20;
  res.ki %= 20;
  res.t = res.w / 18;
  res.w %= 18;
  res.ka = res.t / 20;
  res.t %= 20;
  res.b = res.ka / 20;
  res.ka %= 20;
  return res;
}

int main() {
  std::string str;
  while (std::cin >> str) {
    if (str == "#")
      break;
    std::vector<int> a;
    int i = 0, num = 0;
    while (str[i]) {
      if (str[i] == '.')
        a.push_back(num), num = 0;
      else
        num = num * 10 + str[i] - '0';
      i++;
    }
    a.push_back(num);
    if (a.size() == 5) {
      S ans = M2S(a[0], a[1], a[2], a[3], a[4]);
      std::cout << ans.y << "." << ans.m << "." << ans.d << '\n';
    } else {
      Ma ans = S2M(a[0], a[1], a[2]);
      std::cout << ans.b << "." << ans.ka << "." << ans.t << "." << ans.w << "."
           << ans.ki << '\n';
    }
  }
  return 0;
}
accuracy: 1
time_ms: 960
memory_kb: 3140
final_rank: 1

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct S {
  ll y, m, d;
};
struct Ma {
  ll b, ka, t, w, ki;
};
int M[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

inline bool check(ll y) { return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)); }

inline S M2S(ll b, ll ka, ll t, ll w, ll ki) {
  ka += b * 20;
  t += ka * 20;
  w += t * 18;
  ki += w * 20;
  S res;
  res.y = 2012, res.m = 12, res.d = 21 + ki;
  if (res.d > 31) {
    while (res.d > (365 + check(res.y + 1)))
      res.y++, res.d -= (365 + check(res.y));
    res.y++, res.m = 1, res.d -= 31;
    while (res.d > (M[res.m - 1] + (check(res.y) && res.m == 2))) {
      res.d -= (M[res.m - 1] + (check(res.y) && res.m == 2));
      res.m++;
    }
    if (res.d == 0)
      res.m--, res.d = M[res.m - 1] + (check(res.y) && res.m == 2);
  }
  return res;
}

inline Ma S2M(ll y, ll m, ll d) {
  y -= 2012;
  if (y)
    d += 10;
  else
    d = (d - 21);
  for (int i = 0; i < m - 1 && y; i++)
    d += (M[i] + (i == 1 && check(y + 2012)));
  y--;
  while (y > 0)
    d += (365 + check(y + 2012)), y--;
  Ma res;
  d %= 13 * 20 * 20 * 18 * 20;
  res.ki = d;
  res.w = res.ki / 20;
  res.ki %= 20;
  res.t = res.w / 18;
  res.w %= 18;
  res.ka = res.t / 20;
  res.t %= 20;
  res.b = res.ka / 20;
  res.ka %= 20;
  return res;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  while (1) {
    string str;
    cin >> str;
    if (str == "#")
      break;
    vector<int> a;
    int i = 0, num = 0;
    while (str[i]) {
      if (str[i] == '.')
        a.push_back(num), num = 0;
      else
        num = num * 10 + str[i] - '0';
      i++;
    }
    a.push_back(num);
    if (a.size() == 5) {
      S ans = M2S(a[0], a[1], a[2], a[3], a[4]);
      cout << ans.y << "." << ans.m << "." << ans.d << "\n";
    } else {
      Ma ans = S2M(a[0], a[1], a[2]);
      cout << ans.b << "." << ans.ka << "." << ans.t << "." << ans.w << "."
           << ans.ki << "\n";
    }
  }
  return 0;
}
accuracy: 0.16666666666666666
time_ms: 10
memory_kb: 3208
final_rank: 16

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct S {
  ll y, m, d;
};
struct Ma {
  ll b, ka, t, w, ki;
};
int M[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool check(ll y) { return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)); }
bool check2(S a) { return check(a.y) && a.m == 2; }
S M2S(ll b, ll ka, ll t, ll w, ll ki) {
  ka += b * 20;
  t += ka * 20;
  w += t * 18;
  ki += w * 20;
  S res;
  res.y = 2012, res.m = 12, res.d = 21 + ki;
  while (res.d / (365 + check(res.y + 1)))
    res.y++, res.d -= (365 + check(res.y));
  if (res.d == 0)
    res.m--, res.d = M[res.m - 1];
  if (res.d <= 31)
    return res;
  res.y++, res.m = 1, res.d -= 31;
  while (res.d / (M[res.m - 1] + check2(res))) {
    res.d -= (M[res.m - 1] + check2(res));
    res.m++;
  }
  if (res.d == 0)
    res.m--, res.d = M[res.m - 1] + check2(res);
  return res;
}
Ma S2M(ll y, ll m, ll d) {
  y -= 2012;
  if (y)
    d += 10;
  else
    d = (d - 21);
  for (int i = 0; i < m - 1 && y; i++)
    d += (M[i] + (i == 1 && check(y + 2012)));
  y--;
  while (y > 0)
    d += (365 + check(y + 2012)), y--;
  Ma res;
  d %= 13 * 20 * 20 * 18 * 20;
  res.ki = d;
  res.w = res.ki / 20;
  res.ki %= 20;
  res.t = res.w / 18;
  res.w %= 18;
  res.ka = res.t / 20;
  res.t %= 20;
  res.b = res.ka / 20;
  res.ka %= 20;
  return res;
}
int main() {
  while (1) {
    string str;
    cin >> str;
    if (str == "#")
      break;
    vector<int> a;
    int i = 0, num = 0;
    while (str[i]) {
      if (str[i] == '.')
        a.push_back(num), num = 0;
      else
        num = num * 10 + str[i] - '0';
      i++;
    }
    a.push_back(num);
    if (a.size() == 5) {
      S ans = M2S(a[0], a[1], a[2], a[3], a[4]);
      cout << ans.y << "." << ans.m << "." << ans.d << endl;
    } else {
      Ma ans = S2M(a[0], a[1], a[2]);
      cout << ans.b << "." << ans.ka << "." << ans.t << "." << ans.w << "."
           << ans.ki << endl;
    }
  }
  return 0;
}
accuracy: 1
time_ms: 1200
memory_kb: 3148
final_rank: 8

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct S {
  ll y, m, d;
};
struct Ma {
  ll b, ka, t, w, ki;
};
int M[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool check(ll y) { return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)); }
S M2S(ll b, ll ka, ll t, ll w, ll ki) {
  ka += b * 20;
  t += ka * 20;
  w += t * 18;
  ki += w * 20;
  S res;
  res.y = 2012, res.m = 12, res.d = 21 + ki;
  if (res.d <= 31)
    return res;
  while (res.d / (365 + check(res.y + 1)))
    res.y++, res.d -= (365 + check(res.y));
  if (res.d == 0)
    res.m--, res.d = M[res.m - 1] + (check(res.y) && res.m == 2);
  if (res.d <= 31)
    return res;
  res.y++, res.m = 1, res.d -= 31;
  while (res.d / (M[res.m - 1] + (check(res.y) && res.m == 2))) {
    res.d -= (M[res.m - 1] + (check(res.y) && res.m == 2));
    res.m++;
  }
  if (res.d == 0)
    res.m--, res.d = M[res.m - 1] + (check(res.y) && res.m == 2);
  return res;
}
Ma S2M(ll y, ll m, ll d) {
  y -= 2012;
  if (y)
    d += 10;
  else
    d = (d - 21);
  for (int i = 0; i < m - 1 && y; i++)
    d += (M[i] + (i == 1 && check(y + 2012)));
  y--;
  while (y > 0)
    d += (365 + check(y + 2012)), y--;
  Ma res;
  d %= 13 * 20 * 20 * 18 * 20;
  res.ki = d;
  res.w = res.ki / 20;
  res.ki %= 20;
  res.t = res.w / 18;
  res.w %= 18;
  res.ka = res.t / 20;
  res.t %= 20;
  res.b = res.ka / 20;
  res.ka %= 20;
  return res;
}
int main() {
  while (1) {
    string str;
    cin >> str;
    if (str == "#")
      break;
    vector<int> a;
    int i = 0, num = 0;
    while (str[i]) {
      if (str[i] == '.')
        a.push_back(num), num = 0;
      else
        num = num * 10 + str[i] - '0';
      i++;
    }
    a.push_back(num);
    if (a.size() == 5) {
      S ans = M2S(a[0], a[1], a[2], a[3], a[4]);
      cout << ans.y << "." << ans.m << "." << ans.d << endl;
    } else {
      Ma ans = S2M(a[0], a[1], a[2]);
      cout << ans.b << "." << ans.ka << "." << ans.t << "." << ans.w << "."
           << ans.ki << endl;
    }
  }
  return 0;
}
accuracy: 1
time_ms: 1210
memory_kb: 3196
final_rank: 11

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct S {
  ll y, m, d;
};
struct Ma {
  ll b, ka, t, w, ki;
};
const int MONTHDAYS[]={31,28,31,30,31,30,31,31,30,31,30,31};
bool check(ll y) { return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)); }
S M2S(ll b, ll ka, ll t, ll w, ll ki) {
  ka += b * 20;
  t += ka * 20;
  w += t * 18;
  ki += w * 20;
  S res;
  res.y = 2012, res.m = 12, res.d = 21 + ki;
  if (res.d <= 31)
    return res;
  while (res.d / (365 + check(res.y + 1)))
    res.y++, res.d -= (365 + check(res.y));
  if (res.d == 0)
    res.m--, res.d = MONTHDAYS[res.m - 1] + (check(res.y) && res.m == 2);
  if (res.d <= 31)
    return res;
  res.y++, res.m = 1, res.d -= 31;
  while (res.d / (MONTHDAYS[res.m - 1] + (check(res.y) && res.m == 2))) {
    res.d -= (MONTHDAYS[res.m - 1] + (check(res.y) && res.m == 2));
    res.m++;
  }
  if (res.d == 0)
    res.m--, res.d = MONTHDAYS[res.m - 1] + (check(res.y) && res.m == 2);
  return res;
}
Ma S2M(ll y, ll m, ll d) {
  y -= 2012;
  if (y)
    d += 10;
  else
    d = (d - 21);
  for (int i = 0; i < m - 1 && y; i++)
    d += (MONTHDAYS[i] + (i == 1 && check(y + 2012)));
  y--;
  while (y > 0)
    d += (365 + check(y + 2012)), y--;
  Ma res;
  d %= 13 * 20 * 20 * 18 * 20;
  res.ki = d;
  res.w = res.ki / 20;
  res.ki %= 20;
  res.t = res.w / 18;
  res.w %= 18;
  res.ka = res.t / 20;
  res.t %= 20;
  res.b = res.ka / 20;
  res.ka %= 20;
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  while (1) {
    string str;
    cin >> str;
    if (str == "#")
      break;
    vector<int> a;
    int i = 0, num = 0;
    while (str[i]) {
      if (str[i] == '.')
        a.push_back(num), num = 0;
      else
        num = num * 10 + str[i] - '0';
      i++;
    }
    a.push_back(num);
    if (a.size() == 5) {
      S ans = M2S(a[0], a[1], a[2], a[3], a[4]);
      cout << ans.y << "." << ans.m << "." << ans.d << '\n';
    } else {
      Ma ans = S2M(a[0], a[1], a[2]);
      cout << ans.b << "." << ans.ka << "." << ans.t << "." << ans.w << "."
           << ans.ki << '\n';
    }
  }
  return 0;
}
accuracy: 1
time_ms: 940
memory_kb: 3184
final_rank: 4

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct S {
    ll y, m, d;
};
struct Ma {
    ll b, ka, t, w, ki;
};
const int M[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline bool check(ll y) { return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)); }
inline S M2S(ll b, ll ka, ll t, ll w, ll ki) {
    ka += b * 20;
    t += ka * 20;
    w += t * 18;
    ki += w * 20;
    S res{2012, 12, 21 + ki};
    if (res.d <= 31)
        return res;
    while (res.d / (365 + check(res.y + 1)))
        res.y++, res.d -= (365 + check(res.y));
    if (res.d == 0)
        res.m--, res.d = M[res.m - 1] + (check(res.y) && res.m == 2);
    if (res.d <= 31)
        return res;
    res.y++, res.m = 1, res.d -= 31;
    while (res.d / (M[res.m - 1] + (check(res.y) && res.m == 2))) {
        res.d -= (M[res.m - 1] + (check(res.y) && res.m == 2));
        res.m++;
    }
    if (res.d == 0)
        res.m--, res.d = M[res.m - 1] + (check(res.y) && res.m == 2);
    return res;
}
inline Ma S2M(ll y, ll m, ll d) {
    y -= 2012;
    if (y)
        d += 10;
    else
        d = (d - 21);
    for (int i = 0; i < m - 1 && y; i++)
        d += (M[i] + (i == 1 && check(y + 2012)));
    y--;
    while (y > 0)
        d += (365 + check(y + 2012)), y--;
    Ma res;
    d %= 13 * 20 * 20 * 18 * 20;
    res.ki = d;
    res.w = res.ki / 20;
    res.ki %= 20;
    res.t = res.w / 18;
    res.w %= 18;
    res.ka = res.t / 20;
    res.t %= 20;
    res.b = res.ka / 20;
    res.ka %= 20;
    return res;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string str;
    while (cin >> str) {
        if (str == "#")
            break;
        vector<int> a;
        int i = 0, num = 0;
        while (str[i]) {
            if (str[i] == '.')
                a.push_back(num), num = 0;
            else
                num = num * 10 + str[i] - '0';
            i++;
        }
        a.push_back(num);
        if (a.size() == 5) {
            S ans = M2S(a[0], a[1], a[2], a[3], a[4]);
            cout << ans.y << "." << ans.m << "." << ans.d << endl;
        } else {
            Ma ans = S2M(a[0], a[1], a[2]);
            cout << ans.b << "." << ans.ka << "." << ans.t << "." << ans.w << "." << ans.ki << endl;
        }
    }
    return 0;
}
accuracy: 1
time_ms: 860
memory_kb: 3196
final_rank: 2

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct S {
    ll y, m, d;
};
struct Ma {
    ll b, ka, t, w, ki;
};
int M[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool check(ll y) { 
    return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)); 
}
S M2S(ll b, ll ka, ll t, ll w, ll ki) {
    ka += b * 20;
    t += ka * 20;
    w += t * 18;
    ki += w * 20;
    S res;
    res.y = 2012, res.m = 12, res.d = 21 + ki;
    if (res.d <= 31)
        return res;
    while (res.d / (365 + check(res.y + 1)))
        res.y++, res.d -= (365 + check(res.y));
    if (res.d == 0)
        res.m--, res.d = M[res.m - 1] + (check(res.y) && res.m == 2);
    if (res.d <= 31)
        return res;
    res.y++, res.m = 1, res.d -= 31;
    while (res.d / (M[res.m - 1] + (check(res.y) && res.m == 2))) {
        res.d -= (M[res.m - 1] + (check(res.y) && res.m == 2));
        res.m++;
    }
    if (res.d == 0)
        res.m--, res.d = M[res.m - 1] + (check(res.y) && res.m == 2);
    return res;
}
Ma S2M(ll y, ll m, ll d) {
    y -= 2012;
    if (y)
        d += 10;
    else
        d = (d - 21);
    for (int i = 0; i < m - 1 && y; i++)
        d += (M[i] + (i == 1 && check(y + 2012)));
    y--;
    while (y > 0)
        d += (365 + check(y + 2012)), y--;
    Ma res;
    d %= 13 * 20 * 20 * 18 * 20;
    res.ki = d % 20, d /= 20;
    res.w = d % 18, d /= 18;
    res.t = d % 20, d /= 20;
    res.ka = d % 20, d /= 20;
    res.b = d % 20;
    return res;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    while (1) {
        string str;
        cin >> str;
        if (str == "#")
            break;
        vector<int> a;
        int i = 0, num = 0;
        while (str[i]) {
            if (str[i] == '.')
                a.push_back(num), num = 0;
            else
                num = num * 10 + str[i] - '0';
            i++;
        }
        a.push_back(num);
        if (a.size() == 5) {
            S ans = M2S(a[0], a[1], a[2], a[3], a[4]);
            cout << ans.y << "." << ans.m << "." << ans.d << "\n";
        } else {
            Ma ans = S2M(a[0], a[1], a[2]);
            cout << ans.b << "." << ans.ka << "." << ans.t << "." << ans.w << "." << ans.ki << "\n";
        }
    }
    return 0;
}
accuracy: 1
time_ms: 960
memory_kb: 3196
final_rank: 5

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct S {
  ll y, m, d;
};
struct Ma {
  ll b, ka, t, w, ki;
};
const int M[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline bool check(ll y) { return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)); }
inline S M2S(ll b, ll ka, ll t, ll w, ll ki) {
  ka += b * 20;
  t += ka * 20;
  w += t * 18;
  ki += w * 20;
  S res;
  res.y = 2012, res.m = 12, res.d = 21 + ki;
  if (res.d <= 31)
    return res;
  while (res.d / (365 + check(res.y + 1)))
    res.y++, res.d -= (365 + check(res.y));
  if (res.d == 0)
    res.m--, res.d = M[res.m - 1] + (check(res.y) && res.m == 2);
  if (res.d <= 31)
    return res;
  res.y++, res.m = 1, res.d -= 31;
  while (res.d / (M[res.m - 1] + (check(res.y) && res.m == 2))) {
    res.d -= (M[res.m - 1] + (check(res.y) && res.m == 2));
    res.m++;
  }
  if (res.d == 0)
    res.m--, res.d = M[res.m - 1] + (check(res.y) && res.m == 2);
  return res;
}
inline Ma S2M(ll y, ll m, ll d) {
  y -= 2012;
  if (y)
    d += 10;
  else
    d = (d - 21);
  for (int i = 0; i < m - 1 && y; i++)
    d += (M[i] + (i == 1 && check(y + 2012)));
  y--;
  while (y > 0)
    d += (365 + check(y + 2012)), y--;
  Ma res;
  d %= 13 * 20 * 20 * 18 * 20;
  res.ki = d % 20, d /= 20;
  res.w = d % 18, d /= 18;
  res.t = d % 20, d /= 20;
  res.ka = d % 20, d /= 20;
  res.b = d % 20, d /= 20;
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  while (1) {
    string str;
    cin >> str;
    if (str == "#")
      break;
    vector<int> a;
    int i = 0, num = 0;
    while (str[i]) {
      if (str[i] == '.')
        a.push_back(num), num = 0;
      else
        num = num * 10 + str[i] - '0';
      i++;
    }
    a.push_back(num);
    if (a.size() == 5) {
      S ans = M2S(a[0], a[1], a[2], a[3], a[4]);
      cout << ans.y << "." << ans.m << "." << ans.d << '\n';
    } else {
      Ma ans = S2M(a[0], a[1], a[2]);
      cout << ans.b << "." << ans.ka << "." << ans.t << "." << ans.w << "."
           << ans.ki << '\n';
    }
  }
  return 0;
}
accuracy: 1
time_ms: 1430
memory_kb: 3220
final_rank: 14

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct S {
  ll y, m, d;
};
struct Ma {
  ll b, ka, t, w, ki;
};
int M[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool check(ll y) { return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)); }
S M2S(ll b, ll ka, ll t, ll w, ll ki) {
  ka += b * 20;
  t += ka * 20;
  w += t * 18;
  ki += w * 20;
  S res;
  res.y = 2012, res.m = 12, res.d = 21 + ki;
  if (res.d <= 31)
    return res;
  while (res.d / (365 + check(res.y + 1)))
    res.y++, res.d -= (365 + check(res.y));
  if (res.d == 0)
    res.m--, res.d = M[res.m - 1] + (check(res.y) && res.m == 2);
  if (res.d <= 31)
    return res;
  res.y++, res.m = 1, res.d -= 31;
  while (res.d / (M[res.m - 1] + (check(res.y) && res.m == 2))) {
    res.d -= (M[res.m - 1] + (check(res.y) && res.m == 2));
    res.m++;
  }
  if (res.d == 0)
    res.m--, res.d = M[res.m - 1] + (check(res.y) && res.m == 2);
  return res;
}
Ma S2M(ll y, ll m, ll d) {
  y -= 2012;
  if (y)
    d += 10;
  else
    d = (d - 21);
  for (int i = 0; i < m - 1 && y; i++)
    d += (M[i] + (i == 1 && check(y + 2012)));
  y--;
  while (y > 0)
    d += (365 + check(y + 2012)), y--;
  Ma res;
  d %= 13 * 20 * 20 * 18 * 20;
  res.ki = d % 20;
  d /= 20;
  res.w = d % 18;
  d /= 18;
  res.t = d % 20;
  d /= 20;
  res.ka = d % 20;
  d /= 20;
  res.b = d;
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  while (1) {
    string str;
    cin >> str;
    if (str == "#")
      break;
    vector<int> a;
    int i = 0, num = 0;
    while (str[i]) {
      if (str[i] == '.')
        a.push_back(num), num = 0;
      else
        num = num * 10 + str[i] - '0';
      i++;
    }
    a.push_back(num);
    if (a.size() == 5) {
      S ans = M2S(a[0], a[1], a[2], a[3], a[4]);
      cout << ans.y << "." << ans.m << "." << ans.d << endl;
    } else {
      Ma ans = S2M(a[0], a[1], a[2]);
      cout << ans.b << "." << ans.ka << "." << ans.t << "." << ans.w << "."
           << ans.ki << endl;
    }
  }
  return 0;
}
accuracy: 1
time_ms: 1200
memory_kb: 3196
final_rank: 10

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;

struct S {
    ll y, m, d;
};

struct Ma {
    ll b, ka, t, w, ki;
};

int M[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

bool check(ll y) {
    return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));
}

S M2S(ll b, ll ka, ll t, ll w, ll ki) {
    ka += b * 20;
    t += ka * 20;
    w += t * 18;
    ki += w * 20;
    S res;
    res.y = 2012, res.m = 12, res.d = 21 + ki;

    if (res.d <= 31) {
        return res;
    }
    while (res.d / (365 + check(res.y + 1))) {
        res.y++;
        res.d -= (365 + check(res.y));
    }
    if (res.d == 0) {
        res.m--;
        res.d = M[res.m - 1] + (check(res.y) && res.m == 2);
    }
    if (res.d <= 31) {
        return res;
    }
    res.y++, res.m = 1, res.d -= 31;
    while (res.d / (M[res.m - 1] + (check(res.y) && res.m == 2))) {
        res.d -= (M[res.m - 1] + (check(res.y) && res.m == 2));
        res.m++;
    }
    if (res.d == 0) {
        res.m--;
        res.d = M[res.m - 1] + (check(res.y) && res.m == 2);
    }
    return res;
}

Ma S2M(ll y, ll m, ll d) {
    y -= 2012;
    if (y) {
        d += 10;
    } else {
        d = (d - 21);
    }
    for (int i = 0; i < m - 1 && y; i++) {
        d += (M[i] + (i == 1 && check(y + 2012)));
    }
    y--;
    while (y > 0) {
        d += (365 + check(y + 2012)), y--;
    }
    Ma res;
    d %= 13 * 20 * 20 * 18 * 20;
    res.ki = d;
    res.w = res.ki / 20;
    res.ki %= 20;
    res.t = res.w / 18;
    res.w %= 18;
    res.ka = res.t / 20;
    res.t %= 20;
    res.b = res.ka / 20;
    res.ka %= 20;
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    while (1) {
        string str;
        cin >> str;
        if (str == "#") {
            break;
        }
        vector<int> a;
        int i = 0, num = 0;
        while (str[i]) {
            if (str[i] == '.') {
                a.push_back(num), num = 0;
            } else {
                num = num * 10 + str[i] - '0';
            }
            i++;
        }
        a.push_back(num);
        if (a.size() == 5) {
            S ans = M2S(a[0], a[1], a[2], a[3], a[4]);
            cout << ans.y << "." << ans.m << "." << ans.d << "\n";
        } else {
            Ma ans = S2M(a[0], a[1], a[2]);
            cout << ans.b << "." << ans.ka << "." << ans.t << "." << ans.w << "." << ans.ki << "\n";
        }
    }
    return 0;
}
accuracy: 1
time_ms: 960
memory_kb: 3212
final_rank: 7

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct S {
  ll y, m, d;
};
struct Ma {
  ll b, ka, t, w, ki;
};
const int M[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline bool check(ll y) { return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)); }
inline S M2S(ll b, ll ka, ll t, ll w, ll ki) {
  ka += b * 20;
  t += ka * 20;
  w += t * 18;
  ki += w * 20;
  S res = {2012, 12, 21 + ki};
  if (res.d <= 31)
    return res;
  while (res.d / (365 + check(res.y + 1)))
    res.y++, res.d -= (365 + check(res.y));
  if (res.d == 0)
    res.m--, res.d = M[res.m - 1] + (check(res.y) && res.m == 2);
  if (res.d <= 31)
    return res;
  res.y++, res.m = 1, res.d -= 31;
  while (res.d / (M[res.m - 1] + (check(res.y) && res.m == 2))) {
    res.d -= (M[res.m - 1] + (check(res.y) && res.m == 2));
    res.m++;
  }
  if (res.d == 0)
    res.m--, res.d = M[res.m - 1] + (check(res.y) && res.m == 2);
  return res;
}
inline Ma S2M(ll y, ll m, ll d) {
  y -= 2012;
  if (y)
    d += 10;
  else
    d = (d - 21);
  for (int i = 0; i < m - 1 && y; i++)
    d += (M[i] + (i == 1 && check(y + 2012)));
  y--;
  while (y > 0)
    d += (365 + check(y + 2012)), y--;
  Ma res;
  d %= 13 * 20 * 20 * 18 * 20;
  res.ki = d % 20;
  d /= 20;
  res.w = d % 18;
  d /= 18;
  res.t = d % 20;
  d /= 20;
  res.ka = d % 20;
  d /= 20;
  res.b = d;
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  while (1) {
    string str;
    cin >> str;
    if (str == "#")
      break;
    vector<int> a;
    int i = 0, num = 0;
    while (str[i]) {
      if (str[i] == '.')
        a.push_back(num), num = 0;
      else
        num = num * 10 + str[i] - '0';
      i++;
    }
    a.push_back(num);
    if (a.size() == 5) {
      S ans = M2S(a[0], a[1], a[2], a[3], a[4]);
      cout << ans.y << "." << ans.m << "." << ans.d << '\n';
    } else {
      Ma ans = S2M(a[0], a[1], a[2]);
      cout << ans.b << "." << ans.ka << "." << ans.t << "." << ans.w << "."
           << ans.ki << '\n';
    }
  }
  return 0;
}
accuracy: 1
time_ms: 880
memory_kb: 3228
final_rank: 6

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct S {
  ll y, m, d;
};
struct Ma {
  ll b, ka, t, w, ki;
};
int M[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline bool check(ll y) { return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0)); }
S M2S(ll b, ll ka, ll t, ll w, ll ki) {
  ka += b * 20;
  t += ka * 20;
  w += t * 18;
  ki += w * 20;
  S res;
  res.y = 2012, res.m = 12, res.d = 21 + ki;
  if (res.d <= 31)
    return res;
  while (res.d / (365 + check(res.y + 1)))
    res.y++, res.d -= (365 + check(res.y));
  if (res.d == 0)
    res.m--, res.d = M[res.m - 1] + (check(res.y) && res.m == 2);
  if (res.d <= 31)
    return res;
  res.y++, res.m = 1, res.d -= 31;
  while (res.d / (M[res.m - 1] + (check(res.y) && res.m == 2))) {
    res.d -= (M[res.m - 1] + (check(res.y) && res.m == 2));
    res.m++;
  }
  if (res.d == 0)
    res.m--, res.d = M[res.m - 1] + (check(res.y) && res.m == 2);
  return res;
}
Ma S2M(ll y, ll m, ll d) {
  y -= 2012;
  if (y)
    d += 10;
  else
    d = (d - 21);
  for (int i = 0; i < m - 1 && y; i++)
    d += (M[i] + (i == 1 && check(y + 2012)));
  y--;
  while (y > 0)
    d += (365 + check(y + 2012)), y--;
  Ma res;
  d %= 13 * 20 * 20 * 18 * 20;
  res.ki = d;
  res.w = res.ki / 20;
  res.ki %= 20;
  res.t = res.w / 18;
  res.w %= 18;
  res.ka = res.t / 20;
  res.t %= 20;
  res.b = res.ka / 20;
  res.ka %= 20;
  return res;
}
int main() {
  while (1) {
    string str;
    cin >> str;
    if (str == "#")
      break;
    vector<int> a;
    int i = 0, num = 0;
    while (str[i]) {
      if (str[i] == '.')
        a.push_back(num), num = 0;
      else
        num = num * 10 + str[i] - '0';
      i++;
    }
    a.push_back(num);
    if (a.size() == 5) {
      S ans = M2S(a[0], a[1], a[2], a[3], a[4]);
      cout << ans.y << "." << ans.m << "." << ans.d << endl;
    } else {
      Ma ans = S2M(a[0], a[1], a[2]);
      cout << ans.b << "." << ans.ka << "." << ans.t << "." << ans.w << "."
           << ans.ki << endl;
    }
  }
  return 0;
}
accuracy: 1
time_ms: 1210
memory_kb: 3208
final_rank: 13