solution
stringlengths 11
983k
| difficulty
int64 0
21
| language
stringclasses 2
values |
---|---|---|
#include <bits/stdc++.h>
using namespace std;
map<string, int> mp;
const int day[15] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int n = 0, y, m, d, j;
string str, v, x;
int main() {
cin >> str;
for (int i = 0; i + 10 <= str.length(); i++) {
x = str.substr(i, 10);
if (sscanf((x + "*1").c_str(), "%2d-%2d-%4d*%d", &d, &m, &y, &j) != 4)
continue;
if (y < 2013 || y > 2015 || m < 1 || m > 12 || d < 1 || d > day[m])
continue;
mp[x]++;
if (n < mp[x]) n = mp[x], v = x;
}
cout << v << endl;
return 0;
}
| 8 |
CPP
|
s=input()
l=len(s)
m=['01','02','03','04','05','06','07','08','09','10','11','12']
d=[31,28,31,30,31,30,31,31,30,31,30,31]
ans={}
for i in range(l-9):
if s[i+2] == '-':
if s[i+3]+s[i+4] in m:
if s[i+5] == '-':
if s[i+6]+s[i+7]+s[i+8]+s[i+9] in ['2013','2014','2015']:
if s[i] in '0123456789':
if s[i+1] in '0123456789':
if int(s[i]+s[i+1])>0 and int(s[i]+s[i+1]) <= d[int(s[i+3]+s[i+4])-1]:
if s[i:i+10] in ans:
ans[s[i:i+10]]+=1
else:
ans[s[i:i+10]]=1
#print(ans)
x=-1
a=None
for i in ans:
if ans[i]>x:
x=ans[i]
a=i
print(a)
| 8 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int ctoi(char c) { return int(c - '0'); }
bool goodDate(string s) {
if (s[9] < '3' || s[9] > '5' || s[8] != '1' || s[7] != '0' || s[6] != '2' ||
s[9] == '-')
return false;
if (s[5] != '-') return false;
if (s[3] > '1' || s[3] == '-') return false;
if (s[3] == '1') {
if (s[4] > '2' || s[4] == '-') return false;
} else {
if (s[4] == '0' || s[4] == '-') return false;
}
if (s[2] != '-') return false;
int men = ctoi(s[3]) * 10 + ctoi(s[4]);
if (s[0] == '-' || s[1] == '-') return false;
int dien = ctoi(s[0]) * 10 + ctoi(s[1]);
if (dien == 0) return false;
if (men == 1 || men == 3 || men == 5 || men == 7 || men == 8 || men == 10 ||
men == 12) {
if (dien > 31) return false;
} else if (men == 4 || men == 6 || men == 9 || men == 11) {
if (dien > 30) return false;
} else {
if (dien > 28) return false;
}
return true;
}
map<string, int> dq;
int main() {
string s;
cin >> s;
for (int i = 0; i < s.size() - 9; i++) {
string date = s.substr(i, 10);
if (goodDate(date)) {
dq[date]++;
}
}
map<string, int>::iterator it;
int best = 0;
string bestDate = "";
for (it = dq.begin(); it != dq.end(); it++) {
if ((*it).second > best) {
best = (*it).second;
bestDate = (*it).first;
}
}
cout << bestDate << endl;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int to_n(string &s, long long c, int n) {
int ans = 0;
int i;
for (i = 0; i < n; i++) {
ans = ans * 10 + s[c + i] - '0';
}
return ans;
}
bool is_dig(char a) {
if ('0' <= a && a <= '9') {
return true;
} else {
return false;
}
}
int main() {
long long i, j, k;
string s;
cin >> s;
int d[3][13][32];
for (i = 0; i < 3; i++) {
for (j = 0; j < 13; j++) {
for (k = 0; k < 32; k++) {
d[i][j][k] = 0;
}
}
}
int m[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
long long c = -1;
int yr, mnth, dt;
while (1) {
c = s.find("201", c + 1);
if ((c == string::npos) || (c + 3 >= s.length())) {
break;
} else if (!('3' <= s[c + 3] && s[c + 3] <= '5')) {
continue;
} else if (c < 6) {
continue;
} else if (s[c - 1] != '-' || s[c - 4] != '-') {
continue;
} else if (!is_dig(s[c - 2]) || !is_dig(s[c - 3]) || !is_dig(s[c - 5]) ||
!is_dig(s[c - 6])) {
continue;
}
yr = to_n(s, c, 4);
mnth = to_n(s, c - 3, 2);
dt = to_n(s, c - 6, 2);
if (dt > m[mnth]) {
continue;
}
d[yr - 2013][mnth][dt]++;
}
long long max_i = 0, max_j = 0, max_k = 0, max_v = d[0][0][0];
for (i = 0; i < 3; i++) {
for (j = 1; j < 13; j++) {
for (k = 1; k < 32; k++) {
if (max_v < d[i][j][k]) {
max_i = i;
max_j = j;
max_k = k;
max_v = d[i][j][k];
}
}
}
}
if (max_k < 10) {
cout << "0" << max_k << "-";
} else {
cout << max_k << "-";
}
if (max_j < 10) {
cout << "0" << max_j << "-";
} else {
cout << max_j << "-";
}
cout << max_i + 2013;
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
string kip[100005];
int rec[100005], a[100005];
char s[100005];
map<string, int> mm;
string cur;
int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline bool chk(int id) {
int flag, i, d1, m1, y1;
flag = true;
cur.clear();
for (i = id; i < id + 10; i++) {
if (i == (id + 2) || i == (id + 5)) {
if (s[i] != '-') flag = false;
} else {
if (s[i] > '9' || s[i] < '0') flag = false;
}
a[i] = s[i] - '0';
cur = cur + s[i];
}
char b = 0;
cur = cur + b;
if (flag == false) return false;
d1 = a[id] * 10 + a[id + 1];
m1 = a[id + 3] * 10 + a[id + 4];
y1 = a[id + 6] * 1000 + a[id + 7] * 100 + a[id + 8] * 10 + a[id + 9];
flag = false;
if (2012 < y1 && y1 < 2016) {
if (0 < m1 && m1 < 13) {
if (0 < d1 && d1 <= mon[m1]) {
flag = true;
}
}
}
return flag;
}
int main() {
int k, mxnow, cnt, i;
scanf("%s", s);
k = strlen(s);
mm.clear();
mxnow = -1;
cnt = 1;
for (i = 0; i < k - 9; i++) {
if (chk(i) == false) continue;
if (mm.find(cur) == mm.end()) {
mm[cur] = cnt;
rec[cnt] = 0;
kip[cnt] = cur;
cnt++;
}
int now;
now = mm[cur];
rec[now]++;
mxnow = max(rec[now], mxnow);
}
for (i = 1; i < cnt; i++) {
if (rec[i] == mxnow) {
printf("%s\n", kip[i].c_str());
break;
}
}
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int ans[33][33][2222], n, k;
string t, res;
int dig(char c) { return (int)(c - '0'); }
void check() {
if (t[2] != '-' || t[5] != '-') return;
int cnt = 0;
for (int i = 0; i < 10; i++)
if (t[i] == '-') cnt++;
if (cnt > 2) return;
int d = dig(t[0]) * 10 + dig(t[1]);
int m = dig(t[3]) * 10 + dig(t[4]);
int y = dig(t[6]) * 1000 + dig(t[7]) * 100 + dig(t[8]) * 10 + dig(t[9]);
if (m < 1 || m > 12) return;
if (d < 1 || d > month[m]) return;
if (y < 2013 || y > 2015) return;
ans[d][m][y]++;
if (ans[d][m][y] > k) {
k = ans[d][m][y];
res = t;
}
}
int main() {
string s;
cin >> s;
n = s.size();
for (int i = 0; i < n; i++) {
t = "00-00-0000";
for (int j = i, at = 0; j < i + 10 && j < n; j++, at++) t[at] = s[j];
check();
}
cout << res << endl;
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int ok[] = {0, 1, 3, 4, 6, 7, 8, 9};
int len;
map<string, int> m;
char in[100001];
void solve(int p) {
if (p + 10 > len) return;
string aux;
for (int i = 0; i < 10; ++i) aux += in[i + p];
bool k = 1;
for (int i = 0; i < 8 && k; ++i) k = aux[ok[i]] <= '9' && aux[ok[i]] >= '0';
k &= aux[2] == '-' && aux[5] == '-';
if (k) {
int day, month, year;
sscanf(aux.c_str(), "%d-%d-%d", &day, &month, &year);
if (month > 0 && month <= 12 && day > 0 && day <= days[month] &&
year >= 2013 && year <= 2015)
m[aux]++;
}
solve(p + 1);
}
int main() {
scanf("%s", in);
len = strlen(in);
solve(0);
vector<pair<int, string> > vet;
for (typeof(m.begin()) it = m.begin(); it != m.end(); ++it)
vet.push_back(make_pair(it->second, it->first));
sort(vet.begin(), vet.end());
printf("%s\n", vet[vet.size() - 1].second.c_str());
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
const int MIN = 2013, MAX = 2015;
const int months[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int dist[13] = {0};
struct Date {
int year, month, day;
Date() { year = month = day = 0; }
Date(int n) {
n++;
year = month = day = 0;
while (n > 365) {
n -= 365;
year++;
}
for (int i = 0; i < 13; i++)
if (n > dist[i]) month = i + 1;
day = n - dist[month - 1];
}
int toInt() { return dist[month - 1] + day + 365 * year; }
friend ostream &operator<<(ostream &output, const Date &date) {
return output << setw(2) << setfill('0') << date.day << "-" << setw(2)
<< setfill('0') << date.month << "-" << MIN + date.year;
}
bool isValid() const {
return 0 <= year && year < 3 && 1 <= month && month < 13 && 1 <= day &&
day <= months[month];
}
};
string input;
int freq[3 * 365 + 1] = {0};
inline int strToInt(const string &str) {
stringstream ss(str);
int res;
ss >> res;
return res;
}
void parse(const string &str) {
Date date;
string strs[3];
strs[0] = str.substr(0, 2), strs[1] = str.substr(3, 2),
strs[2] = str.substr(6, 4);
bool ok = true;
for (int i = 0; i < 3; i++)
for (int j = 0; j < (int)strs[i].size(); j++)
if (!isdigit(strs[i][j])) ok = false;
if (!ok || str[2] != '-' || str[5] != '-') return;
date.day = strToInt(strs[0]);
date.month = strToInt(strs[1]);
date.year = strToInt(strs[2]) - MIN;
if (date.isValid()) freq[date.toInt()]++;
}
int main() {
for (int i = 1; i < 13; i++) dist[i] = dist[i - 1] + months[i];
cin >> input;
const int LEN = 10;
for (int i = 0; i + LEN <= (int)input.size(); i++)
parse(input.substr(i, LEN));
int ans = 0, mFreq = 0;
for (int i = 0; i < 3 * 365 + 1; i++)
if (freq[i] > mFreq) {
mFreq = freq[i];
ans = i;
}
cout << Date(ans - 1) << endl;
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
map<string, string> mp;
map<string, int> mpp;
int main(int argc, char** argv) {
ios::sync_with_stdio(0);
cin.tie(0);
string s;
cin >> s;
int j = 0;
for (int j = 0; j < s.size(); j++) {
string findd = "";
findd += s[j];
if (j <= s.size() - 4) {
findd += s[j + 1];
findd += s[j + 2];
findd += s[j + 3];
}
if (findd == "2013") {
string tmp = "";
for (int i = j + 3; i >= 0 && i >= j - 6; i--) {
tmp += s[i];
}
reverse(tmp.begin(), tmp.end());
string tmp1 = "";
string tmp2 = "";
tmp1 += tmp[3];
tmp1 += tmp[4];
tmp2 += tmp[0];
tmp2 += tmp[1];
int a = 0;
a = atoi(tmp2.c_str());
if (isdigit(tmp[0]) && isdigit(tmp[1]) && isdigit(tmp[3]) &&
isdigit(tmp[4]) && tmp[2] == '-' && tmp[5] == '-' &&
((a > 0 && tmp1 == "01" && a <= 31) ||
(a > 0 && tmp1 == "03" && a <= 31) ||
(a > 0 && tmp1 == "05" && a <= 31) ||
(a > 0 && tmp1 == "07" && a <= 31) ||
(a > 0 && tmp1 == "09" && a <= 30) ||
(a > 0 && tmp1 == "11" && a <= 30) ||
(a > 0 && tmp1 == "02" && a <= 28) ||
(a > 0 && tmp1 == "04" && a <= 30) ||
(a > 0 && tmp1 == "06" && a <= 30) ||
(a > 0 && tmp1 == "08" && a <= 31) ||
(a > 0 && tmp1 == "10" && a <= 31) ||
(a > 0 && tmp1 == "12" && a <= 31))) {
mpp[tmp]++;
}
} else if (findd == "2014") {
string tmp = "";
for (int i = j + 3; i >= j - 6; i--) {
tmp += s[i];
}
reverse(tmp.begin(), tmp.end());
string tmp1 = "";
string tmp2 = "";
tmp1 += tmp[3];
tmp1 += tmp[4];
tmp2 += tmp[0];
tmp2 += tmp[1];
int a = 0;
a = atoi(tmp2.c_str());
if (isdigit(tmp[0]) && isdigit(tmp[1]) && isdigit(tmp[3]) &&
isdigit(tmp[4]) && tmp[2] == '-' && tmp[5] == '-' &&
((a > 0 && tmp1 == "01" && a <= 31) ||
(a > 0 && tmp1 == "03" && a <= 31) ||
(a > 0 && tmp1 == "05" && a <= 31) ||
(a > 0 && tmp1 == "07" && a <= 31) ||
(a > 0 && tmp1 == "09" && a <= 31) ||
(a > 0 && tmp1 == "11" && a <= 31) ||
(a > 0 && tmp1 == "02" && a <= 28) ||
(a > 0 && tmp1 == "04" && a <= 30) ||
(a > 0 && tmp1 == "06" && a <= 30) ||
(a > 0 && tmp1 == "08" && a <= 30) ||
(a > 0 && tmp1 == "10" && a <= 30) ||
(a > 0 && tmp1 == "12" && a <= 30))) {
mpp[tmp]++;
}
} else if (findd == "2015") {
string tmp = "";
for (int i = j + 3; i >= j - 6; i--) {
tmp += s[i];
}
reverse(tmp.begin(), tmp.end());
string tmp1 = "";
string tmp2 = "";
tmp1 += tmp[3];
tmp1 += tmp[4];
tmp2 += tmp[0];
tmp2 += tmp[1];
int a = 0;
a = atoi(tmp2.c_str());
if (isdigit(tmp[0]) && isdigit(tmp[1]) && isdigit(tmp[3]) &&
isdigit(tmp[4]) && tmp[2] == '-' && tmp[5] == '-' &&
((a > 0 && tmp1 == "01" && a <= 31) ||
(a > 0 && tmp1 == "03" && a <= 31) ||
(a > 0 && tmp1 == "05" && a <= 31) ||
(a > 0 && tmp1 == "07" && a <= 31) ||
(a > 0 && tmp1 == "09" && a <= 31) ||
(a > 0 && tmp1 == "11" && a <= 31) ||
(a > 0 && tmp1 == "02" && a <= 28) ||
(a > 0 && tmp1 == "04" && a <= 30) ||
(a > 0 && tmp1 == "06" && a <= 30) ||
(a > 0 && tmp1 == "08" && a <= 30) ||
(a > 0 && tmp1 == "10" && a <= 30) ||
(a > 0 && tmp1 == "12" && a <= 30))) {
mpp[tmp]++;
}
}
}
int mx = 0;
for (map<string, int>::iterator it = mpp.begin(); it != mpp.end(); it++) {
mx = max((*it).second, mx);
}
for (map<string, int>::iterator it = mpp.begin(); it != mpp.end(); it++) {
if ((*it).second == mx) {
cout << (*it).first << endl;
return 0;
}
}
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
map<string, int> date;
int month_len[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
for (int y = 2013; y <= 2015; y++) {
for (int m = 1; m <= 12; m++) {
for (int d = 1; d <= month_len[m]; d++) {
stringstream ss;
ss << setfill('0') << setw(2) << d << '-';
ss << setfill('0') << setw(2) << m << '-' << y;
date[ss.str()] = 0;
}
}
}
string s;
cin >> s;
for (int i = 0; i <= s.length() - 10; i++)
if (date.count(s.substr(i, 10))) date[s.substr(i, 10)]++;
string ans;
int max_cnt = -1;
for (map<string, int>::iterator it = date.begin(); it != date.end(); it++)
if (it->second > max_cnt) {
ans = it->first;
max_cnt = it->second;
}
cout << ans << endl;
return 0;
}
| 8 |
CPP
|
#!/usr/bin/env python3
from collections import Counter
from datetime import datetime
import re
def is_date_correct(date):
try:
datetime.strptime(date, "%d-%m-%Y")
return True
except ValueError:
return False
def count(s, sub):
result = 0
for i in range(len(s) + 1 - len(sub)):
result += (s[i:i + len(sub)] == sub)
return result
def main():
s = input()
dates = Counter(filter(is_date_correct, (x.group(1) for x in re.finditer('(?=([0-3]\d-[0-1]\d-201[3-5]))', s))))
print(dates.most_common(1)[0][0])
if __name__ == '__main__':
main()
| 8 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int d, m, y, k, mx, mxi;
int day[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool f;
int dd[5000], mm[5000], yy[5000], s[5000];
int pm(char x) {
if (((x - 48) >= 0) && ((x - 48) <= 9)) {
return x - 48;
} else {
return -1;
}
}
int main() {
string a;
cin >> a;
for (int i = 0; i < a.length(); i++) {
if ((pm(a[i]) != -1) && (pm(a[i + 1]) != -1) && (a[i + 2] == '-') &&
(pm(a[i + 3]) != -1) && (pm(a[i + 4]) != -1) && (a[i + 5] == '-') &&
(pm(a[i + 6]) != -1) && (pm(a[i + 7]) != -1) && (pm(a[i + 8]) != -1) &&
(pm(a[i + 9]) != -1) && (pm(a[i + 3]) * 10 + pm(a[i + 4]) <= 12) &&
((pm(a[i]) * 10 + pm(a[i + 1]) <=
day[pm(a[i + 3]) * 10 + pm(a[i + 4])]))) {
d = pm(a[i]) * 10 + pm(a[i + 1]);
m = pm(a[i + 3]) * 10 + pm(a[i + 4]);
y = pm(a[i + 6]) * 1000 + pm(a[i + 7]) * 100 + pm(a[i + 8]) * 10 +
pm(a[i + 9]);
if ((d == 0) || (m == 0)) continue;
if ((y < 2013) || (y > 2015)) continue;
f = true;
for (int j = 0; j < k; j++) {
if ((dd[j] == d) && (mm[j] == m) && (yy[j] == y)) {
f = false;
s[j]++;
}
}
if (f) {
dd[k] = d;
mm[k] = m;
yy[k] = y;
s[k] = 1;
k++;
}
}
}
for (int i = 0; i < k; i++) {
if (s[i] > mx) {
mx = s[i];
mxi = i;
}
}
if (dd[mxi] / 10 == 0) {
cout << 0 << dd[mxi] << "-";
} else {
cout << dd[mxi] << "-";
}
if (mm[mxi] / 10 == 0) {
cout << 0 << mm[mxi] << "-";
} else {
cout << mm[mxi] << "-";
}
cout << yy[mxi];
return 0;
}
| 8 |
CPP
|
from sys import *
from bisect import *
from collections import *
from itertools import *
from fractions import *
Input = []
#stdin = open('in', 'r')
#stdout = open('out', 'w')
## for i, val in enumerate(array, start_i_value)
def Out(x):
stdout.write(str(x) + '\n')
def In():
return stdin.readline().strip()
def inputGrab():
for line in stdin:
Input.extend(map(str, line.strip().split()))
'''--------------------------------------------------------------------------------'''
ans = dict()
def dateConv(dd, mm, yy):
dds = str()
if(dd < 10):
dds = '0'+str(dd)
else:
dds = str(dd)
mms = str()
if(mm < 10):
mms = '0'+str(mm)
else:
mms = str(mm)
return dds+'-'+mms+'-'+str(yy)
def main():
s = In()
Date = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
MaxCnt = 0
ans = str()
for mm in range(1, 13):
for dd in range(1, Date[mm-1]+1):
for yy in range(2013, 2016):
#print("Search for", dateConv(dd, mm, yy))
cnt = s.count(dateConv(dd, mm, yy))
if cnt > MaxCnt:
ans = dateConv(dd, mm, yy)
MaxCnt = cnt
print(ans)
if __name__ == '__main__':
main()
| 8 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
map<string, int> mp;
int main() {
int T[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string s, t, Ans = "", M;
int d = 0, m = 0, y = 0, x = 0;
cin >> s;
for (int i = 0; i <= s.length() - 10; i++) {
t = s.substr(i + 6, 4);
if (t != "2013" && t != "2014" && t != "2015") continue;
if (s[i + 2] != '-' || s[i + 5] != '-') continue;
if (s[i + 3] == '-' || s[i + 4] == '-') continue;
if (s[i] == '-' || s[i + 1] == '-') continue;
m = 10 * int(s[i + 3] - '0') + int(s[i + 4] - '0');
d = 10 * int(s[i] - '0') + int(s[i + 1] - '0');
if (m > 12 || d > T[m] || d == 0) continue;
M = s.substr(i, 10);
mp[M]++;
if (mp[M] > x) Ans = M, x = mp[M];
}
cout << Ans;
}
| 8 |
CPP
|
from collections import Counter
numbers = '0123456789'
days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
def check(s):
if s[2] != '-' or s[5] != '-':
return False
if any(c not in numbers for (i, c) in enumerate(s) if i != 2 and i != 5):
return False
d = int(s[:2])
m = int(s[3:5])
y = int(s[6:])
if y < 2013 or y > 2015:
return False
if m == 0 or m > 12:
return False
return d != 0 and d <= days[m - 1]
s = input()
print(Counter(s[i:i+10] for i in range(len(s) - 9) if check(s[i:i+10])).most_common(1)[0][0])
| 8 |
PYTHON3
|
import sys
def input(): return sys.stdin.readline().strip()
def iinput(): return int(input())
def rinput(): return map(int, sys.stdin.readline().strip().split())
def get_list(): return list(map(int, sys.stdin.readline().strip().split()))
mod = int(1e9)+7
s = input()
l = len(s)
d = {}
for i in range(l-9):
# print(i)
if s[i]!='-' and s[i+1]!='-' and s[i+2]=='-' and s[i+3]!='-' and s[i+4]!='-' and s[i+5]=='-' and s[i+6]!='-' and s[i+7]!='-' and s[i+8]!='-' and s[i+9]!='-':
year = int(s[i+6:i+10])
month = int(s[i+3:i+5])
date = int(s[i:i+2])
if (year<2013 or year>2015 or month<1 or month>12 or date<=0):
continue
if ((month==1 and date>31) or (month==2 and date>28) or (month==3 and date>31) or (month==4 and date>30) or (month==5 and date>31) or (month==6 and date>30) or (month==7 and date>31) or (month==8 and date>31) or (month==9 and date>30) or (month==10 and date>31) or (month==11 and date>30) or (month==12 and date>31)):
continue
year = str(s[i+6:i+10])
month = str(s[i+3:i+5])
date = str(s[i:i+2])
res = date + "-" + month + "-" + year
d[res] = d.get(res, 0)+1
m = 0
ans = ''
for key in d:
if d[key]>m:
m = d[key]
ans = key
print(ans)
| 8 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
bool correct(int day, int month) {
if (day == 0 || month == 0) return false;
if (month == 2 && day <= 28)
return true;
else if ((month == 4 || month == 6 || month == 9 || month == 11) && day <= 30)
return true;
else if (day <= 31 && (month == 1 || month == 3 || month == 5 || month == 7 ||
month == 8 || month == 10 || month == 12))
return true;
return false;
}
int main() {
stringstream ss;
vector<string> v;
map<string, int> mp;
string s, t, month, day, res;
cin >> s;
int x, y;
for (int i = s.size() - 1; i >= 9; i--) {
t.push_back(s[i - 3]);
t.push_back(s[i - 2]);
t.push_back(s[i - 1]);
t.push_back(s[i]);
if (t == "2013" || t == "2015" || t == "2014") {
if (s[i - 4] == '-' && s[i - 7] == '-' && isdigit(s[i - 6]) &&
isdigit(s[i - 5]) && isdigit(s[i - 9]) && isdigit(s[i - 8])) {
month.push_back(s[i - 6]);
month.push_back(s[i - 5]);
day.push_back(s[i - 9]);
day.push_back(s[i - 8]);
ss << month;
ss >> x;
ss.clear();
ss << day;
ss >> y;
ss.clear();
if (correct(y, x)) {
res = day + "-" + month + "-" + t;
v.push_back(res);
mp[res]++;
}
month = "";
day = "";
}
}
t = "";
}
res = v[0];
for (int i = 1; i < v.size(); i++) {
if (mp[v[i]] > mp[res]) res = v[i];
}
cout << res;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
int YEAR[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int A[32][13][3];
int main(void) {
char S[100005] = "";
char* str;
int l, max = 0, md, mm, my;
memset(A, 0, 32 * 13 * 3 * sizeof(int));
scanf("%s", S);
l = strlen(S);
str = S;
while (str < S + l) {
int m, d, y;
while (str[0] < '0' && str[1] < '1' && str + 1 < S + l) str++;
if (str[2] != '-' && str + 2 < S + l) {
str++;
continue;
}
if (str[3] < '0' || str[4] < '0' || str + 4 >= S + l) {
str += 4;
continue;
}
m = (str[3] - '0') * 10 + (str[4] - '0');
if (m == 0 || m > 12) {
str += 3;
continue;
}
d = (str[0] - '0') * 10 + (str[1] - '0');
if (d == 0 || d > YEAR[m]) {
str += 3;
continue;
}
if (str[5] != '-') {
str += 4;
continue;
}
if (str[6] < '0' || str[7] < '0' || str[8] < '0' || str[9] < '0' ||
str + 9 >= S + l) {
str += 3;
continue;
}
y = (str[6] - '0') * 1000 + (str[7] - '0') * 100 + (str[8] - '0') * 10 +
(str[9] - '0');
if (y < 2013 || y > 2015) {
str += 8;
continue;
}
A[d][m][y - 2013]++;
str += 8;
}
for (int i = 0; i < 32; i++) {
for (int j = 0; j < 13; j++) {
for (int k = 0; k < 3; k++) {
int a = A[i][j][k];
if (a > max) {
max = a;
md = i;
mm = j;
my = 2013 + k;
}
}
}
}
printf("%02d-%02d-%d\n", md, mm, my);
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
const int mod = ((1E9) + 7);
const int intmax = ((1E9) + 7);
using namespace std;
string s[1120];
int lps[15];
int count_[1120];
void cal_lcp(string &p) {
int j = -1;
int i = 0;
lps[0] = -1;
while (i < p.size()) {
while (j >= 0 && p[i] != p[j]) j = lps[j];
i++;
j++;
lps[i] = j;
}
}
void kmp(string &t, string &p, int x) {
int i = 0, j = 0;
while (i < t.size()) {
while (j >= 0 && t[i] != p[j]) j = lps[j];
i++;
j++;
if (j == p.size()) count_[x]++;
}
}
string to_string_(int a) {
stringstream ss;
ss << a;
string t;
ss >> t;
return t;
}
int main() {
ios::sync_with_stdio(0);
int test, a, b, c;
int n, m;
int max_ = 0, pos = -1;
string text;
cin >> text;
int x = 0;
for (int i = 1; i <= 31; i++)
for (int j = 1; j <= 12; j++)
for (int k = 2013; k <= 2015; k++) {
if (j == 2 && i > 28) break;
if (j <= 7 && j % 2 == 0 && i == 31) break;
if (j > 7 && j % 2 != 0 && i == 31) break;
if (i < 10) s[x] += '0';
s[x] += to_string_(i);
s[x] += '-';
if (j < 10) s[x] += '0';
s[x] += to_string_(j);
s[x] += '-';
s[x] += to_string_(k);
x++;
}
for (int i = 0; i < x; i++) {
cal_lcp(s[i]);
kmp(text, s[i], i);
if (count_[i] > max_) {
pos = i;
max_ = count_[i];
}
}
cout << s[pos];
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 10;
const long long mod = 1e9 + 7;
const long long inf = -1e18;
const long long INF = 1e18;
long long d[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string s, ans;
map<string, int> us;
long long mx;
int main() {
cin >> s;
for (int i = 0; i < s.size(); i++) {
if (i + 9 < s.size()) {
if (s[i + 2] == s[i + 5] && s[i + 5] == '-') {
if (isdigit(s[i]) && isdigit(s[i + 1]) && isdigit(s[i + 3]) &&
isdigit(s[i + 4]) && isdigit(s[i + 6]) && isdigit(s[i + 7]) &&
isdigit(s[i + 8]) && isdigit(s[i + 9])) {
int day = (s[i] - '0') * 10 + (s[i + 1] - '0');
int mounth = (s[i + 3] - '0') * 10 + (s[i + 4] - '0');
int year = (s[i + 6] - '0') * 1000 + (s[i + 7] - '0') * 100 +
(s[i + 8] - '0') * 10 + (s[i + 9] - '0');
if (year >= 2013 && year <= 2015) {
if (mounth >= 1 && mounth <= 12) {
if (day >= 1 && day <= d[mounth]) {
string str = "";
for (int j = i; j <= i + 9; j++) {
str += s[j];
}
us[str]++;
if (us[str] > mx) {
mx = us[str];
ans = str;
}
}
}
}
}
}
}
}
cout << ans;
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10,
mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int n, m, x, y, z, a[3][13][32], mx, ans;
char s[N];
inline bool check(int y, int m, int d) {
if (y < 2013 || y > 2015) return 0;
if (m <= 0 || m > 12) return 0;
if (d <= 0 || d > mon[m]) return 0;
return 1;
}
int main() {
scanf("%s", s);
for (int i = 0; s[i + 9]; ++i)
if (s[i] != '-' && s[i + 1] != '-' && s[i + 2] == '-' && s[i + 3] != '-' &&
s[i + 4] != '-' && s[i + 5] == '-' && s[i + 6] != '-' &&
s[i + 7] != '-' && s[i + 8] != '-' && s[i + 9] != '-') {
x = (s[i] - 48) * 10 + s[i + 1] - 48;
y = (s[i + 3] - 48) * 10 + s[i + 4] - 48;
z = (s[i + 6] - 48) * 1000 + (s[i + 7] - 48) * 100 +
(s[i + 8] - 48) * 10 + s[i + 9] - 48;
if (check(z, y, x))
if (++a[z - 2013][y][x] > mx) mx = a[z - 2013][y][x], ans = i;
}
for (int i = ans; i <= ans + 9; ++i) putchar(s[i]);
return 0;
}
| 8 |
CPP
|
s = input()
date_ = {1:31,2:28,3:31,4:30,5:31,6:30,7:31,8:31,9:30,10:31,11:30,12:31}
def is_Date_Correct(s):
return (1<=int(s[3:5])<=12 and 2013<=int(s[6:])<=2015 and 1<=int(s[:2])<=date_[int(s[3:5])])
def is_dateformat(s):
if s[2]=='-' and s[5]=='-':
for i in range(len(s)):
if i==2 or i==5: continue
if s[i] == '-':
return False;
return True;
return False;
i = 0
map = {}
while(i<len(s)):
x = s[i:i+10]
if is_dateformat(x) and is_Date_Correct(x):
if x in map:
map[x]+=1
else:
map[x]=1
i+=8
else:
i+=1
if i+10>len(s): break
count = 0
res = ""
for i in map:
if map[i] > count:
res = i
count = map[i]
print(res)
| 8 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int toInt(string s) {
int r = 0;
istringstream sin(s);
sin >> r;
return r;
}
long long toInt64(string s) {
long long r = 0;
istringstream sin(s);
sin >> r;
return r;
}
double toDouble(string s) {
double r = 0;
istringstream sin(s);
sin >> r;
return r;
}
string toString(long long n) {
string s, s1;
while (n / 10 > 0) {
s += (char)((n % 10) + 48);
n /= 10;
}
s += (char)((n % 10) + 48);
n /= 10;
s1 = s;
for (long long i = 0; i < s.length(); i++) s1[(s.length() - 1) - i] = s[i];
return s1;
}
bool isUpperCase(char c) { return c >= 'A' && c <= 'Z'; }
bool isLowerCase(char c) { return c >= 'a' && c <= 'z'; }
bool isLetter(char c) { return c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z'; }
bool isDigit(char c) { return c >= '0' && c <= '9'; }
char toLowerCase(char c) { return (isUpperCase(c)) ? (c + 32) : c; }
char toUpperCase(char c) { return (isLowerCase(c)) ? (c - 32) : c; }
long long Max[50][50][10], maxx = 0;
int months[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
long long A, B, C;
string s, s1;
void chemidunam() {
if (s[0] == '-') return;
if (s[1] == '-') return;
if (s[2] != '-') return;
if (s[3] == '-') return;
if (s[4] == '-') return;
if (s[5] != '-') return;
if (s[6] != '2') return;
if (s[7] != '0') return;
if (s[8] != '1') return;
if (s[9] != '3' && s[9] != '4' && s[9] != '5') return;
int jday = (int)(s[0] - '0') * 10 + (s[1] - '0');
int jmonth = (int)(s[3] - '0') * 10 + (s[4] - '0');
if (jmonth < 1 || jmonth > 12) return;
if (jday < 1 || jday > months[jmonth - 1]) return;
int jyear = s[9] - '0';
Max[jday][jmonth][jyear]++;
if (Max[jday][jmonth][jyear] > maxx) {
A = jday;
B = jmonth;
C = jyear;
maxx = Max[jday][jmonth][jyear];
};
}
int main() {
cin >> s1;
s = "dd-mm-yyyy";
for (int i = 0; i + s.length() <= s1.size(); i++) {
for (int j = 0; j < s.length(); j++) s[j] = s1[i + j];
chemidunam();
}
if (A < 10) cout << "0";
cout << A;
cout << "-";
if (B < 10) cout << "0";
cout << B;
cout << "-";
cout << "201" << C << endl;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
inline int to_int(string s) {
int x = 0;
for (int i = 0; i < (int)s.size(); ++i) x *= 10, x += s[i] - '0';
return x;
}
char s[100005];
map<string, int> mp;
string tmp, mx;
int d, mn, y, mxx = -1, n,
m[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main(int argc, char **argv) {
scanf("%s", s);
n = strlen(s);
for (int i = 0; i < n - 9; ++i) {
if (isdigit(s[i]) && isdigit(s[i + 1]) && s[i + 2] == '-' &&
isdigit(s[i + 3]) && isdigit(s[i + 4]) && s[i + 5] == '-' &&
isdigit(s[i + 6]) && isdigit(s[i + 7]) && isdigit(s[i + 8]) &&
isdigit(s[i + 9])) {
tmp = "";
for (int j = i; j < i + 10; ++j) tmp += s[j];
d = (s[i] - '0') * 10 + (s[i + 1] - '0');
mn = (s[i + 3] - '0') * 10 + (s[i + 4] - '0');
y = (s[i + 6] - '0') * 1000 + (s[i + 7] - '0') * 100 +
(s[i + 8] - '0') * 10 + (s[i + 9] - '0');
if (y >= 2013 && y <= 2015 && mn >= 1 && mn <= 12 && d <= m[mn] &&
d >= 1) {
++mp[tmp];
if (mp[tmp] > mxx) {
mxx = mp[tmp];
mx = tmp;
}
}
}
}
printf("%s", mx.c_str());
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int getDaysInMonth(int month) {
month--;
if (month == 1) return 28;
return 31 - (month % 7) % 2;
}
bool check(string &value, int start) {
int day = 0, month = 0, year = 0;
for (int i = 0; i < 10; i++) {
if ((i == 2) || (i == 5)) {
if (value[start + i] != '-') return false;
} else if (value[start + i] == '-')
return false;
}
year = (value[start + 6] - '0') * 1000 + (value[start + 7] - '0') * 100 +
(value[start + 8] - '0') * 10 + (value[start + 9] - '0');
if (!((year >= 2013) && (year <= 2015))) return false;
month = (value[start + 3] - '0') * 10 + (value[start + 4] - '0');
if (!((month >= 1) && (month <= 12))) return false;
day = (value[start] - '0') * 10 + (value[start + 1] - '0');
if (!((day >= 1) && (day <= getDaysInMonth(month)))) return false;
return true;
}
int main() {
string in;
cin >> in;
int biggest = 0;
string anwser;
map<string, int> dict;
int len = in.size() - 9;
map<string, int>::iterator it;
for (int i = 0; i < len; i++) {
if (check(in, i)) {
string tmp(in, i, 10);
it = dict.find(tmp);
int count = 1;
if (it != dict.end()) {
count = ++(it->second);
} else {
dict.insert(make_pair(tmp, 1));
}
if (count > biggest) {
biggest = count;
anwser = tmp;
}
}
}
cout << anwser;
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100100;
const bool digitPos[] = {1, 1, 0, 1, 1, 0, 1, 1, 1, 1};
const int digitPosNum = 10;
const int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
char s[MAXN];
inline bool isDigit(char ch) { return ch >= '0' && ch <= '9'; }
inline int getNum(const char *str, int n) {
int res = 0;
for (int i = 0; i < n; ++i) {
res = res * 10 + str[i] - '0';
}
return res;
}
inline void printZero(int x) {
if (x < 10) {
printf("0");
}
printf("%d", x);
}
struct Date {
int year, month, day;
int time;
bool tryParse(const char *date) {
for (int i = 0; i < digitPosNum; ++i) {
if (digitPos[i]) {
if (!isDigit(date[i])) {
return false;
}
} else {
if (date[i] != '-') {
return false;
}
}
}
day = getNum(date, 2);
month = getNum(date + 3, 2);
year = getNum(date + 6, 4);
if (year < 2013 || year > 2015) {
return false;
}
if (month < 1 || month > 12) {
return false;
}
if (day < 1 || day > days[month]) {
return false;
}
time = year * 10000 + month * 100 + day;
return true;
}
bool operator<(const Date &date) const { return time < date.time; }
void output() {
printZero(day);
printf("-");
printZero(month);
printf("-%d\n", year);
}
};
map<Date, int> dateNum;
int main() {
while (~scanf("%s", s)) {
Date date;
dateNum.clear();
for (int i = 0; s[i]; ++i) {
if (date.tryParse(s + i)) {
++dateNum[date];
}
}
int ans = 0;
for (map<Date, int>::iterator it = dateNum.begin(); it != dateNum.end();
++it) {
if (it->second > ans) {
ans = it->second;
date = it->first;
}
}
date.output();
}
return 0;
}
| 8 |
CPP
|
def valid(s):
if(not(s[2]==s[5]=='-')):
return False
for i in range(10):
if(i==2 or i==5):
continue
if(s[i]=='-'):
return False
m=int(s[6:])
if(m<2013 or m>2015):
return False
m=int(s[3:5])
if(m<1 or m>12):
return False
d=int(s[0:2])
if(d<1 or d>D[m-1]):
return False
return True
D=[31,28,31,30,31,30,31,31,30,31,30,31]
A={}
s=input()
x=s[0:10]
if(valid(x)):
A[x]=1
for i in range(10,len(s)):
x=x[1:]+s[i]
if(valid(x)):
if(x in A):
A[x]+=1
else:
A[x]=1
maxx=0
ans=""
for item in A:
if(A[item]>maxx):
maxx=A[item]
ans=item
print(ans)
| 8 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int a[50][50][50];
int main() {
string s;
cin >> s;
int arr[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int d = 0, m = 0, y = 0, mx = 0, ans1 = 0, ans2 = 0, ans3 = 0;
for (int i = 0; i < s.size() - 9; i++) {
if (s[i + 2] != '-' || s[i + 5] != '-') continue;
bool c = false;
for (int j = 0; j < 9; j++)
if (j != 5 && j != 2 && s[i + j] == '-') c = true;
if (c) continue;
if (s[i + 6] != '2' || s[i + 7] != '0' || s[i + 8] != '1') continue;
d = (s[i] - 48) * 10 + (s[i + 1] - 48);
m = (s[i + 3] - 48) * 10 + (s[i + 4] - 48);
y = s[i + 9] - 48;
if (y < 3 || y > 5) continue;
if (m < 1 || m > 12) continue;
if (d < 1 || d > arr[m]) continue;
a[y][m][d]++;
if (a[y][m][d] > mx) {
mx = a[y][m][d];
ans1 = d;
ans2 = m;
ans3 = y;
}
}
cout << ans1 / 10 << ans1 % 10 << "-" << ans2 / 10 << ans2 % 10 << "-201"
<< ans3 << endl;
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int mes[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
map<string, int> M;
void Valid(string s) {
int ct = 0;
for (int i = 0; i < s.size(); i++)
if (s[i] == '-') s[i] = ' ', ct++;
if (ct != 2) return;
if (s[2] != ' ' || s[5] != ' ') return;
istringstream in(s);
int d, m, a;
in >> d >> m >> a;
if (m <= 0 || m > 12) return;
if (a < 2013 || a > 2015) return;
if (d <= 0 || d > mes[m - 1]) return;
s[2] = s[5] = '-';
M[s]++;
}
int main() {
string s;
while (cin >> s) {
for (int i = 0; i < s.size(); i++)
if (i + 9 < s.size()) Valid(s.substr(i, 10));
int maxi = 0;
string ans = "";
map<string, int>::iterator it;
for (it = M.begin(); it != M.end(); ++it) {
if (maxi < it->second) maxi = it->second, ans = it->first;
}
cout << ans << endl;
}
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int dp[35][15][5];
int month[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
char s[100005];
int main() {
int d, m, y;
int ad, am, ay, mx = 0;
scanf("%s", s);
int len = strlen(s);
for (int i = 0; i + 9 < len; i++) {
if (s[i + 2] != '-' || s[i + 5] != '-') continue;
if (s[i + 6] != '2' || s[i + 7] != '0' || s[i + 8] != '1') continue;
bool flag = true;
for (int j = 0; j <= 9; j++) {
if (j == 2 || j == 5) continue;
if (s[i + j] < '0' || s[i + j] > '9') {
flag = false;
break;
}
}
if (flag == false) continue;
d = (s[i] - '0') * 10 + s[i + 1] - '0';
m = (s[i + 3] - '0') * 10 + s[i + 4] - '0';
if (m < 1 || m > 12 || d < 1 || d > month[m]) continue;
y = s[i + 9] - '0';
if (y < 3 || y > 5) continue;
dp[d][m][y]++;
if (dp[d][m][y] > mx) {
mx = dp[d][m][y];
ad = d, am = m, ay = y;
}
}
printf("%02d-%02d-201%d\n", ad, am, ay);
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int toNum(string s) {
int ans = 0;
for (int i = 0; i < s.size(); i++)
if (s[i] >= '0' && s[i] <= '9') {
ans = ans * 10 + (s[i] - '0');
} else
return -1;
return ans;
}
bool check(string s) {
if (s[2] != '-' || s[5] != '-') return 0;
string ngay = s.substr(0, 2);
int Ngay = toNum(ngay);
if (Ngay < 1 || Ngay > 31) return 0;
string thang = s.substr(3, 2);
int Thang = toNum(thang);
if (Thang < 1 || Thang > 12) return 0;
string nam = s.substr(6, 4);
int Nam = toNum(nam);
if (Nam < 2013 || Nam > 2015) return 0;
if (Thang == 4 || Thang == 6 || Thang == 9 || Thang == 11)
if (Ngay > 30) return 0;
if (Thang == 2 && Ngay > 28) return 0;
return 1;
}
string s;
map<string, int> m;
map<string, int>::iterator it;
int main() {
cin >> s;
for (int i = 0; i < s.size() - 9; i++)
if (s[i] != '-') {
string tmp = s.substr(i, 10);
if (check(tmp)) m[tmp]++;
}
string ans = "1";
m[ans] = 0;
for (it = m.begin(); it != m.end(); it++) {
if (it->second > m[ans]) ans = it->first;
}
cout << ans << endl;
return 0;
}
| 8 |
CPP
|
def main():
s = input()
l=[]
a=["0","1","2","3","4","5","6","7","8","9"]
for i in range(len(s)-9):
if ((s[i] in a) or s[i]=="-") and (s[i+1] in a) and s[i+2]=="-" and (s[i+3] in a) and (s[i+4] in a) and s[i+5]=="-" and (s[i+6] in a) and (s[i+7] in a) and (s[i+8] in a) and (s[i+9] in a):
l.append(s[i:i+10])
elif ((s[i] in a) or s[i]=="-") and (s[i+1] in a) and s[i+2]=="-" and (s[i+3] in a) and s[i+4]=="-" and (s[i+5] in a) and (s[i+6] in a) and (s[i+7] in a) and (s[i+8] in a):
l.append(s[i:i+9])
i=0
while(i<len(l)):
if len(l[i])==10:
date1 = l[i][0:2]
month1 = l[i][3:5]
year = l[i][6:10]
date1 = list(date1)
month1 = list(month1)
else:
date1 = l[i][0:2]
month1=l[i][3:4]
year = l[i][5:9]
date1=list(date1)
month1=list(month1)
if date1[0]=="-":
date1[0]="0"
date=""
month=""
for i_ in date1:
date+=i_
for j_ in month1:
month+=j_
if len(month)==1:
month="0"+month
thirtyone =[1,3,5,7,8,10,12]
twen=[2]
#poss=[2013,2014,2015]
#print(int(year))
if int(year)>=2013 and int(year)<=2015:
#print(int(year))
if int(month) in thirtyone:
if int(date)>0 and int(date)<=31:
i+=1
continue
else:
l.remove(l[i])
elif int(month) in twen:
if int(date)>0 and int(date)<=28:
i+=1
continue
else:
l.remove(l[i])
else:
if int(date)>0 and int(date)<=30:
i+=1
continue
else:
l.remove(l[i])
else:
l.remove(l[i])
#print(l)
sett = set(l)
m=0
ans=0
for i in sett:
cnt = l.count(i)
if cnt>m:
ans=i
m=cnt
print(ans)
if __name__ == '__main__':
main()
| 8 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
long long get() {
char c = getchar();
long long x = 0LL;
while (c < '0' || c > '9') c = getchar();
while (c >= '0' && c <= '9') {
x *= 10LL;
x += (c - '0');
c = getchar();
}
return x;
}
string s;
int dm[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
map<string, int> mp;
int main() {
ios::sync_with_stdio(0);
cin >> s;
for (int i = 0; i < s.size() - 9; i++) {
string t = s.substr(i, 10);
string d = t.substr(0, 2), m = t.substr(3, 2), y = t.substr(6, 4);
if (t[2] != '-' || t[5] != '-') continue;
bool f = true;
for (int j = 0; j < 2; j++)
if (!isdigit(d[j]) || !isdigit(m[j])) f = false;
for (int j = 0; j < 4; j++)
if (!isdigit(y[j])) f = false;
if (!f) continue;
int dd, mm, yy;
dd = mm = yy = 0;
for (int j = 0; j < 2; j++) {
dd = dd * 10 + (d[j] - '0');
mm = mm * 10 + (m[j] - '0');
}
for (int j = 0; j < 4; j++) yy = yy * 10 + (y[j] - '0');
if (dd < 1 || dd > dm[mm]) continue;
if (mm < 1 || mm > 12) continue;
if (yy < 2013 || yy > 2015) continue;
mp[t]++;
}
int mx = 0;
for (__typeof(mp.begin()) it = (mp.begin()); it != (mp).end(); it++) {
if (it->second > mx) mx = it->second;
}
for (__typeof(mp.begin()) it = (mp.begin()); it != (mp).end(); it++) {
if (it->second == mx) {
cout << it->first;
return 0;
}
}
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, max1, dd, mm, yy;
string s;
int store[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int cache[50][2050][20];
bool check(int k) {
for (int i = 0; i < 9; i++) {
if (i == 2 || i == 5) {
if (s[k + i] != '-') return false;
} else {
if (!(s[k + i] >= '0' && s[k + i] <= '9')) return false;
}
}
return true;
}
int calc(int k) { return (s[k] - '0') * 10 + (s[k + 1] - '0'); }
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
cin >> s;
n = s.size();
for (int i = 0; i < n - 9; i++) {
if (check(i)) {
int date = calc(i);
int month = calc(i + 3);
int year = calc(i + 6) * 100 + calc(i + 8);
if (year >= 2013 && year <= 2015 && month >= 1 && month <= 12 &&
date >= 1 && date <= store[month]) {
cache[date][month][year]++;
if (cache[date][month][year] > max1) {
max1 = cache[date][month][year];
dd = date;
mm = month;
yy = year;
}
}
}
}
printf("%02d-%02d-%04d", dd, mm, yy);
return 0;
}
| 8 |
CPP
|
# Enter your code here. Read input from STDIN. Print output to STDOUT# ===============================================================================================
# importing some useful libraries.
from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from math import *
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import ceil, floor
from copy import *
from collections import deque, defaultdict
from collections import Counter as counter # Counter(list) return a dict with {key: count}
from itertools import combinations # if a = [1,2,3] then print(list(comb(a,2))) -----> [(1, 2), (1, 3), (2, 3)]
from itertools import permutations as permutate
from bisect import bisect_left as bl
from operator import *
# If the element is already present in the list,
# the left most position where element has to be inserted is returned.
from bisect import bisect_right as br
from bisect import bisect
# If the element is already present in the list,
# the right most position where element has to be inserted is returned
# ==============================================================================================
# fast I/O region
BUFSIZE = 8192
from sys import stderr
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "A" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
def print(*args, **kwargs):
"""Prints the values to a stream, or to sys.stdout by default."""
sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
at_start = True
for A in args:
if not at_start:
file.write(sep)
file.write(str(A))
at_start = False
file.write(kwargs.pop("end", "\n"))
if kwargs.pop("flush", False):
file.flush()
if sys.version_info[0] < 3:
sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
# inp = lambda: sys.stdin.readline().rstrip("\r\n")
# ===============================================================================================
### START ITERATE RECURSION ###
from types import GeneratorType
def iterative(f, stack=[]):
def wrapped_func(*args, **kwargs):
if stack: return f(*args, **kwargs)
to = f(*args, **kwargs)
while True:
if type(to) is GeneratorType:
stack.append(to)
to = next(to)
continue
stack.pop()
if not stack: break
to = stack[-1].send(to)
return to
return wrapped_func
#### END ITERATE RECURSION ####
###########################
# Sorted list
class SortedList:
def __init__(self, iterable=[], _load=200):
"""Initialize sorted list instance."""
values = sorted(iterable)
self._len = _len = len(values)
self._load = _load
self._lists = _lists = [values[start:start + _load] for start in range(0, _len, _load)]
self._list_lens = [len(_list) for _list in _lists]
self._mins = [_list[0] for _list in _lists]
self._fen_tree = []
self._rebuild = True
def _fen_build(self):
"""Build a fenwick tree instance."""
self._fen_tree[:] = self._list_lens
_fen_tree = self._fen_tree
for start in range(len(_fen_tree)):
if start | start + 1 < len(_fen_tree):
_fen_tree[start | start + 1] += _fen_tree[start]
self._rebuild = False
def _fen_update(self, index, value):
"""Update `fen_tree[index] += value`."""
if not self._rebuild:
_fen_tree = self._fen_tree
while index < len(_fen_tree):
_fen_tree[index] += value
index |= index + 1
def _fen_query(self, end):
"""Return `sum(_fen_tree[:end])`."""
if self._rebuild:
self._fen_build()
_fen_tree = self._fen_tree
A = 0
while end:
A += _fen_tree[end - 1]
end &= end - 1
return A
def _fen_findkth(self, k):
"""Return a pair of (the largest `idx` such that `sum(_fen_tree[:idx]) <= k`, `k - sum(_fen_tree[:idx])`)."""
_list_lens = self._list_lens
if k < _list_lens[0]:
return 0, k
if k >= self._len - _list_lens[-1]:
return len(_list_lens) - 1, k + _list_lens[-1] - self._len
if self._rebuild:
self._fen_build()
_fen_tree = self._fen_tree
idx = -1
for d in reversed(range(len(_fen_tree).bit_length())):
right_idx = idx + (1 << d)
if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:
idx = right_idx
k -= _fen_tree[idx]
return idx + 1, k
def _delete(self, pos, idx):
"""Delete value at the given `(pos, idx)`."""
_lists = self._lists
_mins = self._mins
_list_lens = self._list_lens
self._len -= 1
self._fen_update(pos, -1)
del _lists[pos][idx]
_list_lens[pos] -= 1
if _list_lens[pos]:
_mins[pos] = _lists[pos][0]
else:
del _lists[pos]
del _list_lens[pos]
del _mins[pos]
self._rebuild = True
def _loc_left(self, value):
"""Return an index pair that corresponds to the first position of `value` in the sorted list."""
if not self._len:
return 0, 0
_lists = self._lists
_mins = self._mins
lo, pos = -1, len(_lists) - 1
while lo + 1 < pos:
mi = (lo + pos) >> 1
if value <= _mins[mi]:
pos = mi
else:
lo = mi
if pos and value <= _lists[pos - 1][-1]:
pos -= 1
_list = _lists[pos]
lo, idx = -1, len(_list)
while lo + 1 < idx:
mi = (lo + idx) >> 1
if value <= _list[mi]:
idx = mi
else:
lo = mi
return pos, idx
def _loc_right(self, value):
"""Return an index pair that corresponds to the last position of `value` in the sorted list."""
if not self._len:
return 0, 0
_lists = self._lists
_mins = self._mins
pos, hi = 0, len(_lists)
while pos + 1 < hi:
mi = (pos + hi) >> 1
if value < _mins[mi]:
hi = mi
else:
pos = mi
_list = _lists[pos]
lo, idx = -1, len(_list)
while lo + 1 < idx:
mi = (lo + idx) >> 1
if value < _list[mi]:
idx = mi
else:
lo = mi
return pos, idx
def add(self, value):
"""Add `value` to sorted list."""
_load = self._load
_lists = self._lists
_mins = self._mins
_list_lens = self._list_lens
self._len += 1
if _lists:
pos, idx = self._loc_right(value)
self._fen_update(pos, 1)
_list = _lists[pos]
_list.insert(idx, value)
_list_lens[pos] += 1
_mins[pos] = _list[0]
if _load + _load < len(_list):
_lists.insert(pos + 1, _list[_load:])
_list_lens.insert(pos + 1, len(_list) - _load)
_mins.insert(pos + 1, _list[_load])
_list_lens[pos] = _load
del _list[_load:]
self._rebuild = True
else:
_lists.append([value])
_mins.append(value)
_list_lens.append(1)
self._rebuild = True
def discard(self, value):
"""Remove `value` from sorted list if it is a member."""
_lists = self._lists
if _lists:
pos, idx = self._loc_right(value)
if idx and _lists[pos][idx - 1] == value:
self._delete(pos, idx - 1)
def remove(self, value):
"""Remove `value` from sorted list; `value` must be a member."""
_len = self._len
self.discard(value)
if _len == self._len:
raise ValueError('{0!r} not in list'.format(value))
def pop(self, index=-1):
"""Remove and return value at `index` in sorted list."""
pos, idx = self._fen_findkth(self._len + index if index < 0 else index)
value = self._lists[pos][idx]
self._delete(pos, idx)
return value
def bisect_left(self, value):
"""Return the first index to insert `value` in the sorted list."""
pos, idx = self._loc_left(value)
return self._fen_query(pos) + idx
def bisect_right(self, value):
"""Return the last index to insert `value` in the sorted list."""
pos, idx = self._loc_right(value)
return self._fen_query(pos) + idx
def count(self, value):
"""Return number of occurrences of `value` in the sorted list."""
return self.bisect_right(value) - self.bisect_left(value)
def __len__(self):
"""Return the size of the sorted list."""
return self._len
def __getitem__(self, index):
"""Lookup value at `index` in sorted list."""
pos, idx = self._fen_findkth(self._len + index if index < 0 else index)
return self._lists[pos][idx]
def __delitem__(self, index):
"""Remove value at `index` from sorted list."""
pos, idx = self._fen_findkth(self._len + index if index < 0 else index)
self._delete(pos, idx)
def __contains__(self, value):
"""Return true if `value` is an element of the sorted list."""
_lists = self._lists
if _lists:
pos, idx = self._loc_left(value)
return idx < len(_lists[pos]) and _lists[pos][idx] == value
return False
def __iter__(self):
"""Return an iterator over the sorted list."""
return (value for _list in self._lists for value in _list)
def __reversed__(self):
"""Return a reverse iterator over the sorted list."""
return (value for _list in reversed(self._lists) for value in reversed(_list))
def __repr__(self):
"""Return string representation of sorted list."""
return 'SortedList({0})'.format(list(self))
# ===============================================================================================
# some shortcuts
mod = 1000000007
def testcase(t):
for p in range(t):
solve()
def pow(A, B, p):
res = 1 # Initialize result
A = A % p # Update A if it is more , than or equal to p
if (A == 0):
return 0
while (B > 0):
if ((B & 1) == 1): # If B is odd, multiply, A with result
res = (res * A) % p
B = B >> 1 # B = B/2
A = (A * A) % p
return res
from functools import reduce
def factors(n):
return set(reduce(list.__add__,
([start, n // start] for start in range(1, int(n ** 0.5) + 1) if n % start == 0)))
def gcd(a, b):
if a == b: return a
while b > 0: a, b = b, a % b
return a
# discrete binary search
# minimise:
# def search():
# l = 0
# r = 10 ** 15
#
# for start in range(200):
# if isvalid(l):
# return l
# if l == r:
# return l
# m = (l + r) // 2
# if isvalid(m) and not isvalid(m - 1):
# return m
# if isvalid(m):
# r = m + 1
# else:
# l = m
# return m
# maximise:
# def search():
# l = 0
# r = 10 ** 15
#
# for start in range(200):
# # print(l,r)
# if isvalid(r):
# return r
# if l == r:
# return l
# m = (l + r) // 2
# if isvalid(m) and not isvalid(m + 1):
# return m
# if isvalid(m):
# l = m
# else:
# r = m - 1
# return m
##############Find sum of product of subsets of size k in a array
# ar=[0,1,2,3]
# k=3
# n=len(ar)-1
# dp=[0]*(n+1)
# dp[0]=1
# for pos in range(1,n+1):
# dp[pos]=0
# l=max(1,k+pos-n-1)
# for j in range(min(pos,k),l-1,-1):
# dp[j]=dp[j]+ar[pos]*dp[j-1]
# print(dp[k])
def prefix_sum(ar): # [1,2,3,4]->[1,3,6,10]
return list(accumulate(ar))
def suffix_sum(ar): # [1,2,3,4]->[10,9,7,4]
return list(accumulate(ar[::-1]))[::-1]
def N():
return int(inp())
dx = [0, 0, 1, -1]
dy = [1, -1, 0, 0]
def YES():
print("YES")
def NO():
print("NO")
def yes():
print("yes")
def no():
print("no")
def Yes():
print("Yes")
def No():
print("No")
# =========================================================================================
from collections import defaultdict
def numberOfSetBits(start):
start = start - ((start >> 1) & 0x55555555)
start = (start & 0x33333333) + ((start >> 2) & 0x33333333)
return (((start + (start >> 4) & 0xF0F0F0F) * 0x1010101) & 0xffffffff) >> 24
class MergeFind:
def __init__(self, n):
self.parent = list(range(n))
self.size = [1] * n
self.num_sets = n
# self.lista = [[_] for _ in range(n)]
def find(self, a):
to_update = []
while a != self.parent[a]:
to_update.append(a)
a = self.parent[a]
for b in to_update:
self.parent[b] = a
return self.parent[a]
def merge(self, a, b):
a = self.find(a)
b = self.find(b)
if a == b:
return
if self.size[a] < self.size[b]:
a, b = b, a
self.num_sets -= 1
self.parent[b] = a
self.size[a] += self.size[b]
# self.lista[a] += self.lista[b]
# self.lista[b] = []
def set_size(self, a):
return self.size[self.find(a)]
def __len__(self):
return self.num_sets
def lcm(a, b):
return abs((a // gcd(a, b)) * b)
# #
# to find factorial and ncr
# tot = 100005
# mod = 10**9 + 7
# fac = [1, 1]
# finv = [1, 1]
# inv = [0, 1]
#
# for start in range(2, tot + 1):
# fac.append((fac[-1] * start) % mod)
# inv.append(mod - (inv[mod % start] * (mod // start) % mod))
# finv.append(finv[-1] * inv[-1] % mod)
def inp(): return sys.stdin.readline().rstrip("\r\n") # for fast input
def out(var): sys.stdout.write(str(var)) # for fast output, always take string
def lis(): return list(map(int, inp().split()))
def stringlis(): return list(map(str, inp().split()))
def sep(): return map(int, inp().split())
def strsep(): return map(str, inp().split())
def fsep(): return map(float, inp().split())
def nextline(): out("\n") # as stdout.write always print sring.
def arr1d(n, v):
return [v] * n
def arr2d(n, m, v):
return [[v] * m for _ in range(n)]
def arr3d(n, m, p, v):
return [[[v] * p for _ in range(m)] for start in range(n)]
def ceil(a, b):
return (a + b - 1) // b
"""
def main():
t = int(input())
for _ in range(t):
n,m = map(int,input().split())
l=[]
ans=[]
p=[]
for i in range(m):
arr = list(map(int,input().split()))
arr.pop(0)
p.append(arr)
for j in arr:
l.append(j)
f = (m)//2
#print(p)
l = sorted(l)
sett = set(l)
sett = list(sett)
#print(sett)
for i in sett:
if l.count(i)<=f:
ans+=[i]*l.count(i)
else:
ans+=[i]*(f)
# print(ans)
ans1=[]
for i in range(m):
for j in range(len(p[i])):
if p[i][j] in ans:
ans1.append(p[i][j])
ans.remove(p[i][j])
break
if len(ans1)>=m:
print("YES")
print(*ans1)
else:
print("NO")
if __name__ == '__main__':
main()
"""
"""
def main():
t = int(input())
for _ in range(t):
s = input()
l=[]
ss = list(s)
for i in range(len(s)-4):
if ss[i]=="p" and ss[i+1]=="a" and ss[i+2]=="r" and ss[i+3]=="t" and ss[i+4]=="y":
ss[i],ss[i+1],ss[i+2],ss[i+3],ss[i+4]="p","a","w","r","i"
ans=""
for i in ss:
ans+=i
print(ans)
if __name__ == '__main__':
main()
"""
"""
def main():
n,m = sep()
aan = lis()
aam = lis()
if n<m:
print("0"+"/"+str(1))
exit()
elif n>m:
if (aan[0]>=0 and aam[0]>=0) or (aan[0]<0 and aam[0]<0):
print("Infinity")
else:
print("-Infinity")
else:
if aan[0]>0 and aam[0]>0:
k = gcd(aan[0],aam[0])
aan[0]//=k
aam[0]//=k
print(str(aan[0])+"/"+str(aam[0]))
else:
k = gcd(abs(aan[0]),abs(aam[0]))
p = abs(aan[0])//k
q = abs(aam[0])//k
if aan[0]<0 and aam[0]<0:
print(str(p)+"/"+str(q))
else:
print("-"+str(p)+"/"+str(q))
if __name__ == '__main__':
main()
"""
def main():
s = input()
l=[]
a=["0","1","2","3","4","5","6","7","8","9"]
for i in range(len(s)-9):
if ((s[i] in a) or s[i]=="-") and (s[i+1] in a) and s[i+2]=="-" and (s[i+3] in a) and (s[i+4] in a) and s[i+5]=="-" and (s[i+6] in a) and (s[i+7] in a) and (s[i+8] in a) and (s[i+9] in a):
l.append(s[i:i+10])
elif ((s[i] in a) or s[i]=="-") and (s[i+1] in a) and s[i+2]=="-" and (s[i+3] in a) and s[i+4]=="-" and (s[i+5] in a) and (s[i+6] in a) and (s[i+7] in a) and (s[i+8] in a):
l.append(s[i:i+9])
i=0
while(i<len(l)):
if len(l[i])==10:
date1 = l[i][0:2]
month1 = l[i][3:5]
year = l[i][6:10]
date1 = list(date1)
month1 = list(month1)
else:
date1 = l[i][0:2]
month1=l[i][3:4]
year = l[i][5:9]
date1=list(date1)
month1=list(month1)
if date1[0]=="-":
date1[0]="0"
date=""
month=""
for i_ in date1:
date+=i_
for j_ in month1:
month+=j_
if len(month)==1:
month="0"+month
thirtyone =[1,3,5,7,8,10,12]
twen=[2]
#poss=[2013,2014,2015]
#print(int(year))
if int(year)>=2013 and int(year)<=2015:
#print(int(year))
if int(month) in thirtyone:
if int(date)>0 and int(date)<=31:
i+=1
continue
else:
l.remove(l[i])
elif int(month) in twen:
if int(date)>0 and int(date)<=28:
i+=1
continue
else:
l.remove(l[i])
else:
if int(date)>0 and int(date)<=30:
i+=1
continue
else:
l.remove(l[i])
else:
l.remove(l[i])
#print(l)
sett = set(l)
m=0
ans=0
for i in sett:
cnt = l.count(i)
if cnt>m:
ans=i
m=cnt
print(ans)
if __name__ == '__main__':
main()
| 8 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
map<string, int> cnt;
const int day[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
void check(string s) {
if (count(s.begin(), s.end(), '-') != 2) {
return;
}
string ddS, mmS, yyS;
string cur = "";
for (char x : s) {
if (x == '-') {
if (ddS == "") {
ddS = cur;
} else if (mmS == "") {
mmS = cur;
} else if (yyS == "") {
yyS = cur;
}
cur = "";
} else {
cur += x;
}
}
yyS = cur;
if (ddS == "" or mmS == "" or yyS == "") return;
if (yyS[0] == '0') return;
int dd = stoi(ddS);
int mm = stoi(mmS);
int yy = stoi(yyS);
if (yy >= 2013 and yy <= 2015) {
if (mm >= 1 and mm <= 12) {
if (dd > 0) {
if (dd <= day[mm]) {
if (ddS.size() == 1) {
ddS = "0" + ddS;
}
if (mmS.size() == 1) {
mmS = "0" + mmS;
}
string built = ddS + "-" + mmS + "-" + yyS;
cnt[built]++;
}
}
}
}
}
signed main() {
ios::sync_with_stdio(0);
cin.sync_with_stdio(0);
cin.tie(0);
string s;
cin >> s;
for (int add = 9; add <= 9; add++) {
for (int i = 0; i + add < s.size(); i++) {
string a;
for (int j = 0; j <= add; j++) {
a += s[i + j];
}
check(a);
}
}
int ma = 0;
string mas = "?";
for (auto x : cnt) {
if (x.second >= ma) {
ma = x.second;
mas = x.first;
}
}
cout << mas << '\n';
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
string a;
int h1[100][100][10];
int moth[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool panduan[10] = {0, 0, 1, 0, 0, 1};
bool pan(string m) {
string h(m, 6, 4);
if (h != "2013" && h != "2014" && h != "2015") return 0;
int u = (m[0] - '0') * 10 + m[1] - '0', v = (m[3] - '0') * 10 + m[4] - '0',
z = m[9] - '0';
if ((0 < v && v <= 12 && u > 0 && u <= moth[v]) == 0) return 0;
for (int i = 0; i < 10; i++)
if (panduan[i] != (m[i] == '-')) return 0;
h1[u][v][z]++;
return 1;
}
string huanyuan(int i, int j, int o) {
string u = "";
u += char(i / 10 + int('0'));
u += char(i % 10 + int('0'));
u += '-';
u += char(j / 10 + int('0'));
u += char(j % 10 + int('0'));
u += '-';
u += "201";
u += char(o + int('0'));
return u;
}
int main(int argc, char *argv[]) {
cin >> a;
for (int i = 0; i <= a.size() - 10; i++) {
string m(a, i, 10);
pan(m);
}
string e;
int u = 0;
for (int i = 0; i < 40; i++) {
for (int j = 0; j < 20; j++) {
for (int o = 0; o < 10; o++) {
if (h1[i][j][o] > u) {
u = h1[i][j][o];
e = huanyuan(i, j, o);
}
}
}
}
cout << e << endl;
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
ifstream fin("input.txt");
ofstream fout("output.txt");
int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int cnt[100000];
int calc(string str) {
if (str[2] != '-' || str[5] != '-') return 50000;
if (str[6] != '2') return 50000;
if (str[7] != '0') return 50000;
if (str[8] != '1') return 50000;
if (str[9] < '3' || str[9] > '5') return -1;
for (int i = 0; i < 5; i++)
if (str[i] == '-' && i != 2) return 50000;
int d = (str[0] - '0') * 10 + str[1] - '0';
int m = (str[3] - '0') * 10 + str[4] - '0';
if (m < 1 || m > 12) return 50000;
if (d < 1 || d > day[m - 1]) return 50000;
return (str[9] - '3') * 10000 + m * 100 + d;
}
int main() {
string str;
cin >> str;
for (int i = 0; i + 9 < str.length(); i++) cnt[calc(str.substr(i, 10))]++;
int idx = -1, mx = 0;
for (int i = 0; i < 30000; i++)
if (mx < cnt[i]) idx = i, mx = cnt[i];
printf("%02d-%02d-%d\n", idx % 100, (idx / 100) % 100, 2013 + idx / 10000);
return 0;
}
| 8 |
CPP
|
import re
from collections import defaultdict
s = input()
x = re.findall("(?=(\d\d-\d\d-\d\d\d\d))", s)
ans = ""
def val():
return 0
date_count = defaultdict(val)
max_count = 0
for date in x:
d, m, y = [int(x) for x in date.split('-')]
if(2013 <= y <= 2015 and 1 <= d <= 31 and 1 <= m <= 12):
if m in [1, 3, 5, 7, 8, 10, 12] and 1 <= d <= 31:
date_count[date] += 1
elif m == 2 and 1 <= d <= 28:
date_count[date] += 1
elif m in [4, 6, 9, 11] and 1 <= d <= 30:
date_count[date] += 1
if date in date_count and date_count[date] > max_count:
max_count = date_count[date]
ans = date
else:
pass
# print(x)
# print(date_count)
print(ans)
| 8 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int read() {
int x;
scanf("%d", &x);
return x;
}
long long readL() {
long long x;
scanf("%I64d", &x);
return x;
}
bool isdigits(string s) {
int sl = s.length();
for (int i = 0; i < sl; i++) {
if (!isdigit(s[i])) return false;
}
return true;
}
int sstoi(string s) {
istringstream buffer(s);
int value;
buffer >> value;
return value;
}
bool ispattern(string s) {
int sl = s.length();
if (sl != 10) return false;
if (s[2] != '-' || s[5] != '-') return false;
int f = s.find('-');
if (f < 2 || f > 5 || (f > 2 && f < 5)) return false;
if (!isdigits(s.substr(0, 2)) || !isdigits(s.substr(3, 2)) ||
!isdigits(s.substr(6, 4)))
return false;
int dd = sstoi(s.substr(0, 2));
if (dd < 1 || dd > 31) return false;
int mm = sstoi(s.substr(3, 2));
if (mm < 1 || mm > 12 || (mm == 2 && dd > 28) ||
((mm == 4 || mm == 6 || mm == 9 || mm == 11) && dd > 30))
return false;
int yyyy = sstoi(s.substr(6, 4));
if (yyyy < 2013 || yyyy > 2015) return false;
return true;
}
string res;
map<string, int> m;
int main() {
string s;
cin >> s;
int sl = s.length();
if (sl < 10) return cout << -1, 0;
for (int i = 0; i <= sl - 9; i++) {
if (ispattern(s.substr(i, 10))) m[s.substr(i, 10)]++;
}
int mx = -1e9;
for (auto e : m) {
if (e.second > mx) {
mx = e.second;
res = e.first;
}
}
if (mx == -1e9) return cout << -1, 0;
cout << res;
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
char s[100005];
int num[100005];
map<int, string> ans;
map<string, int> mp;
int mouth[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int k = 1;
void judge(int i) {
char ss[20];
int l = 0;
if (s[i + 2] != '-' || s[i + 5] != '-') return;
for (int j = i; j < i + 10; j++) {
ss[l++] = s[j];
if (j == i + 2 || j == i + 5) continue;
if (!(s[j] >= '0' && s[j] <= '9')) return;
}
ss[l] = '\0';
int dd = (s[i] - '0') * 10 + s[i + 1] - '0';
int mm = (s[i + 3] - '0') * 10 + s[i + 4] - '0';
int yy = 0;
for (int j = i + 6; j < i + 10; j++) {
yy = yy * 10 + s[j] - '0';
}
if (!(yy >= 2013 && yy <= 2015)) return;
if (!(mm >= 1 && mm <= 12)) return;
if (!(dd >= 1 && dd <= mouth[mm])) return;
if (!mp[ss]) {
ans[k] = ss;
mp[ss] = k++;
}
num[mp[ss]]++;
}
int main() {
cin >> s;
int len = strlen(s);
for (int i = 0; i <= len - 10; i++) {
judge(i);
}
int index, max_ = -1;
for (int i = 1; i < k; i++) {
if (num[i] > max_) {
max_ = num[i];
index = i;
}
}
cout << ans[index];
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
template <typename T>
void out(T x) {
cout << x << endl;
exit(0);
}
const int maxn = 1e6 + 5;
const string S = "dd-mm-yyyy";
int M[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool valid(string s) {
if (s.length() != S.length()) return false;
if (s[2] != '-') return false;
if (s[5] != '-') return false;
for (int i = 0; i < int(s.length()); i++) {
if (i == 2) continue;
if (i == 5) continue;
if (!(s[i] >= '0' && s[i] <= '9')) return false;
}
int dd = stoi(s.substr(0, 2));
int mm = stoi(s.substr(3, 2));
int yy = stoi(s.substr(6));
return yy >= 2013 && yy <= 2015 && mm >= 1 && mm <= 12 && dd >= 1 &&
dd <= M[mm];
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
map<string, int> mp;
string s;
cin >> s;
int n = s.length();
for (int i = 0; i + int(S.length()) <= n; i++) {
string tmp;
for (int j = 0; j < int(S.length()); j++) tmp += s[i + j];
if (valid(tmp)) mp[tmp]++;
}
string res = "*";
for (auto p : mp) {
if (res == "*" || p.second > mp[res]) res = p.first;
}
assert(res != "*");
cout << res << endl;
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
long long G(long long a, long long b) {
if (b == 0) return a;
return G(b, a % b);
}
map<string, int> m;
map<string, bool> mark;
vector<string> v;
vector<pair<int, string> > q;
int day[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
ios_base::sync_with_stdio(false);
string s;
cin >> s;
for (int i = 0; i < s.length() - 9; i++) {
string ss = s.substr(i, 10);
if (!mark[ss]) v.push_back(ss);
mark[ss] = 1;
m[ss]++;
}
for (int i = 0; i < v.size(); i++) q.push_back(make_pair(m[v[i]], v[i]));
sort(q.begin(), q.end());
reverse(q.begin(), q.end());
for (int i = 0; i < q.size(); i++) {
string s = q[i].second;
if (s[2] != '-' || s[5] != '-') continue;
s[2] = s[5] = '0';
bool b = 0;
for (int j = 0; j < s.length(); j++)
if (s[j] == '-') b = 1;
if (b) continue;
s[2] = s[5] = '-';
int da, mo, ye;
da = 10 * s[0] + s[1] - 11 * '0';
mo = 10 * s[3] + s[4] - 11 * '0';
ye = 1000 * s[6] + 100 * s[7] + 10 * s[8] + s[9] - 1111 * '0';
if (ye < 2013 || ye > 2015) continue;
if (mo < 1 || mo > 12) continue;
if (da < 1 || da > day[mo]) continue;
cout << s << endl;
break;
}
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
map<string, int> mp;
int days[20] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int mx = -1;
string ans, neww;
int main() {
string a, b = "dd-mm-yyyy";
cin >> a;
int d, m, y, j;
for (int i = 0; i < a.length() - b.length() + 1; i++) {
neww = a.substr(i, b.length());
if (sscanf((neww + "*1").c_str(), "%2d-%2d-%4d*%d", &d, &m, &y, &j) != 4)
continue;
if (d >= 1 && d <= days[m] && m <= 12 && m >= 1 && y >= 2013 && y <= 2015) {
if (mx < ++mp[neww]) {
mx = mp[neww];
ans = neww;
}
}
}
cout << ans;
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
bool valid(string s) {
int day = (s[0] - '0') * 10 + s[1] - '0';
int month = (s[3] - '0') * 10 + s[4] - '0';
int year =
(s[6] - '0') * 1000 + (s[7] - '0') * 100 + (s[8] - '0') * 10 + s[9] - '0';
if (year > 2012 && year < 2016) {
if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 ||
month == 10 || month == 12) {
if (day < 32 && day > 0) {
return true;
}
} else if (month == 2) {
if (day < 29 && day > 0) {
return true;
}
} else {
if (month < 13 && day < 31 && day > 0) {
return true;
}
}
}
return false;
}
int main() {
string s;
cin >> s;
vector<string> a;
for (int i = 0; s[i + 9] != '\0'; i++) {
if (s[i + 2] == '-' && s[i + 5] == '-' && s[i] != '-' && s[i + 1] != '-' &&
s[i + 3] != '-' && s[i + 4] != '-') {
string t = string(s.begin() + i, s.begin() + i + 10);
if (valid(t)) {
a.push_back(t);
}
}
}
int ma = 0, ind = -1;
sort(a.begin(), a.end());
for (int i = 0; i < a.size(); i++) {
int t = count(a.begin() + i, a.end(), a[i]);
if (t >= ma) {
ma = t;
ind = i;
}
i += t - 1;
}
cout << a[ind];
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
string s;
unordered_map<string, int> mp;
const int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool check(string s) {
if (s[2] != '-' || s[5] != '-') return false;
for (int i = 0; i < 10; ++i)
if (i != 2 && i != 5 && !isdigit(s[i])) return false;
int day, month, year;
char c;
stringstream ss(s);
ss >> day >> c >> month >> c >> year;
if (year < 2013 || year > 2015) return false;
if (month < 1 || month > 13) return false;
if (day < 1 || day > days[month]) return false;
return true;
}
int main() {
cin >> s;
for (int i = 0; i <= s.size() - 10; ++i) {
string t = s.substr(i, 10);
if (!check(t)) continue;
mp[t]++;
}
int mx = 0;
string ans;
for (auto &it : mp) {
if (it.second > mx) {
mx = it.second;
ans = it.first;
}
}
cout << ans << endl;
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
char s[100001];
int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int validate(char* date) {
if (date[2] != '-' || date[5] != '-') return 0;
int dashes = 0;
for (int i = 0; i < 10; i++) dashes += date[i] == '-';
if (dashes != 2) return 0;
int day = (date[0] - '0') * 10 + date[1] - '0';
int month = (date[3] - '0') * 10 + date[4] - '0';
int year = (date[6] - '0') * 1000 + (date[7] - '0') * 100 +
(date[8] - '0') * 10 + (date[9] - '0');
if (year < 2013 || year > 2015) return 0;
if (month < 1 || month > 12) return 0;
if (day < 1 || day > days[month]) return 0;
return 1;
}
int main(void) {
cin >> s;
int len = strlen(s);
map<string, int> counter;
for (int i = 2, n = len - 7; i < n; i++) {
if (s[i] == '-') {
if (validate(s + i - 2)) {
string date(s + i - 2, 10);
counter[date]++;
}
}
}
map<string, int>::iterator ita, itb;
ita = counter.begin();
itb = counter.end();
string answ;
int maxi = 0;
for (; ita != itb; ita++) {
if (ita->second > maxi) {
maxi = ita->second;
answ = ita->first;
}
}
cout << answ << endl;
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000;
const long long linf = 1000000000000000000LL;
typedef struct {
int dia, mes, ano;
} data;
vector<data> vetor;
string linha, str;
map<int, int> mapa;
int main() {
cin >> linha;
int s = linha.size();
data d;
for (int i = int(0); i <= int(s - 10); i++) {
str = linha.substr(i, 10);
if (isdigit(str[0]) && isdigit(str[1]) && !isdigit(str[2]) &&
isdigit(str[3]) && isdigit(str[4]) && !isdigit(str[5]) &&
isdigit(str[6]) && isdigit(str[7]) && isdigit(str[8]) &&
isdigit(str[9])) {
d.dia = (str[0] - '0') * 10 + str[1] - '0';
d.mes = (str[3] - '0') * 10 + str[4] - '0';
d.ano = (str[6] - '0') * 1000 + (str[7] - '0') * 100 +
(str[8] - '0') * 10 + str[9] - '0';
if (d.ano >= 2013 && d.ano <= 2015 && d.mes >= 1 && d.mes <= 12 &&
d.dia) {
if (d.mes == 2) {
if (d.dia <= 28) vetor.push_back(d);
} else if (d.mes <= 7) {
if (d.mes % 2) {
if (d.dia <= 31) vetor.push_back(d);
} else if (d.dia <= 30)
vetor.push_back(d);
} else {
if (d.mes % 2) {
if (d.dia <= 30) vetor.push_back(d);
} else if (d.dia <= 31)
vetor.push_back(d);
}
}
mapa[1000000 * d.dia + 10000 * d.mes + d.ano] = 0;
}
}
s = vetor.size();
int a, b, c;
for (int i = 0; i < s; i++) {
a = vetor[i].dia, b = vetor[i].mes, c = vetor[i].ano;
mapa[1000000 * a + 10000 * b + c]++;
}
int m = 0;
for (map<int, int>::iterator it = mapa.begin(); it != mapa.end(); it++)
if ((it->second) > m) m = it->second, a = it->first;
printf("%.2d-%.2d-%.4d\n", a / 1000000, a % 1000000 / 10000, a % 10000);
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int cnt[42][42][42];
char s[555555];
int every_month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
scanf("%s", s);
int n = strlen(s);
int mx = 0, ad = 0, am = 0, ay = 0;
memset(cnt, 0, sizeof(cnt));
for (int i = 0; i + 9 < n; i++) {
if (s[i + 2] != '-' || s[i + 5] != '-') continue;
int flag = 1;
for (int j = 0; j < 10; j++) {
if (j != 2 && j != 5 && s[i + j] == '-') flag = 0;
}
if (!flag) continue;
int dd = (s[i] - '0') * 10 + (s[i + 1] - '0');
int mm = (s[i + 3] - '0') * 10 + (s[i + 4] - '0');
if (s[i + 6] != '2' || s[i + 7] != '0' || s[i + 8] != '1') continue;
int yy = s[i + 9] - '0';
if (yy < 3 || yy > 5) continue;
if (mm < 1 || mm > 12) continue;
if (dd < 1 || dd > every_month[mm]) continue;
cnt[dd][mm][yy]++;
if (cnt[dd][mm][yy] > mx) {
mx = cnt[dd][mm][yy];
ad = dd, am = mm, ay = yy;
}
}
printf("%02d-%02d-%d", ad, am, ay + 2010);
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
string s;
int num[2][13][105];
int month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
void solve(string d) {
if (d[0] == '-' || d[1] == '-' || d[2] != '-' || d[3] == '-' || d[4] == '-' ||
d[5] != '-' || d[6] == '-' || d[7] == '-' || d[8] == '-' || d[9] == '-')
return;
int p = 0, y = 0, m = 0;
string t;
for (int i = 0; i < 2; i++) p = p * 10 + d[i] - '0';
for (int i = 3; i < 5; i++) m = m * 10 + d[i] - '0';
for (int i = 6; i < 10; i++) y = y * 10 + d[i] - '0';
if (y < 2013 || y > 2015) return;
if (m < 1 || m > 12) return;
if (p < 1 || p > month[m]) return;
num[y - 2013][m][p]++;
}
int y, m, d, mx;
void print() {
if (d < 10) cout << '0';
cout << d << '-';
if (m < 10) cout << '0';
cout << m;
cout << '-' << y;
}
int main() {
cin >> s;
for (int i = 0; i + 9 < s.size(); i++) solve(s.substr(i, 10));
for (int i = 0; i < 3; i++)
for (int j = 1; j <= 12; j++)
for (int k = 1; k <= month[j]; k++) {
if (num[i][j][k] > mx) {
y = i + 2013, m = j, d = k;
mx = num[i][j][k];
}
}
print();
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
map<string, int> sum;
string ans;
int maks = -1;
int pola[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
char in[100008];
int len;
bool valid(int a, int b) {
for (int i = a; i <= b; i++) {
if (i == a + 2 || i == a + 5) {
if (in[i] != '-') return 0;
} else {
if (in[i] == '-') return 0;
}
}
int day = ((in[a] - '0') * 10) + (in[a + 1] - '0');
int month = ((in[a + 3] - '0') * 10) + (in[a + 4] - '0');
int year = ((in[a + 6] - '0') * 1000) + ((in[a + 7] - '0') * 100) +
((in[a + 8] - '0') * 10) + (in[a + 9] - '0');
if (year < 2013 || year > 2015) return 0;
if (month < 1 || month > 13 || day < 1) return 0;
if (day > pola[month - 1]) return 0;
return 1;
}
void process() {
int a = 0, b = 9;
while (b < len) {
if (valid(a, b)) {
string tmp = "";
for (int i = a; i <= b; i++) {
tmp += in[i];
}
sum[tmp]++;
int n = sum[tmp];
if (n > maks) {
maks = n;
ans = tmp;
}
}
a++;
b++;
}
hell:
cout << ans << endl;
}
int main() {
scanf("%s", in);
len = strlen(in);
process();
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int d[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int pos[] = {0, 1, 3, 4, 6, 7, 8, 9};
map<string, int> m;
string parse(vector<char> v) {
string ans = "";
for (int i = 0; i < v.size(); i++) ans += v[i];
return ans;
}
void valid(vector<char> v) {
if (v.size() != 10) return;
for (int i = 0; i < 8; i++) {
if (v[pos[i]] < 48 || v[pos[i]] > 57) return;
}
if (v[2] != '-' || v[5] != '-') return;
int month = (v[3] - 48) * 10 + v[4] - 48;
int date = (v[0] - 48) * 10 + v[1] - 48;
int year = (v[6] - 48) * 1000 + (v[7] - 48) * 100 + (v[8] - 48) * 10 +
(v[9] - 48) * 1;
if (year >= 2013 && year <= 2015 && month >= 1 && month <= 12 && date >= 1 &&
date <= d[month]) {
m[parse(v)]++;
}
}
void pop_front(vector<char> &v) {
if (!v.empty()) {
v.erase(v.begin());
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
string s;
cin >> s;
vector<char> v;
for (int i = 0; i < 10; i++) v.push_back(s[i]);
valid(v);
for (int i = 10; i < s.size(); i++) {
pop_front(v);
v.push_back(s[i]);
valid(v);
}
string ans = "";
int maxi = -1;
for (auto it : m) {
if (it.second > maxi) {
maxi = it.second;
ans = it.first;
}
}
cout << ans << '\n';
}
| 8 |
CPP
|
import sys
import re
from collections import defaultdict
s = input()
x = re.finditer('(?=([0-9]{2}-[0-9]{2}-[0-9]{4}))', s)
x = [match.group(1) for match in x]
d = defaultdict(int)
for i in x:
l = i.split('-')
if(int(l[2]) >= 2013 and int(l[2]) <= 2015):
if int(l[1]) in [1, 3, 5, 7, 8, 10, 12]:
if int(l[0]) > 0 and int(l[0]) < 32:
d[i] = d[i] + 1
elif int(l[1]) in [4, 6, 9, 11]:
if int(l[0]) > 0 and int(l[0]) < 31:
d[i] = d[i] + 1
elif(int(l[1]) == 2):
if int(l[0]) > 0 and int(l[0]) < 29:
d[i] = d[i] + 1
k = 0
m = 0
for i, j in d.items():
if j > k:
m = i
k = j
print(m)
| 8 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int MAX = 1000000;
int MIN = -1000000;
int INF = 1000000000;
int x4[4] = {0, 1, 0, -1};
int y4[4] = {1, 0, -1, 0};
int x8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int y8[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int i, j, k;
int day[20] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool valid(string A) {
int i, garis = 0;
for (i = (0); i < (A.size()); i++)
if (A[i] == '-') garis++;
if (garis != 2) return false;
if (A[2] != '-' || A[5] != '-') return false;
int hari = ((A[0] - '0') * 10) + (A[1] - '0');
int bulan = ((A[3] - '0') * 10) + (A[4] - '0');
int tahun = ((A[6] - '0') * 1000) + ((A[7] - '0') * 100) +
((A[8] - '0') * 10) + (A[9] - '0');
if (bulan > 12 || bulan < 1) return false;
if (day[bulan] < hari || hari < 1) return false;
if (tahun < 2013 || tahun > 2015) return false;
return true;
}
int main() {
int i;
string kalimat, temp;
map<string, int> m;
vector<string> v;
cin >> kalimat;
for (i = 0; i <= kalimat.size() - 10; i++) {
temp.clear();
for (j = i; j < i + 10; j++) temp.push_back(kalimat[j]);
if (valid(temp) == true) {
if (m[temp] == 0) v.push_back(temp);
m[temp]++;
}
}
int maks = 0;
string ans;
for (i = (0); i < (v.size()); i++) {
int wew = m[v[i]];
if (wew > maks) {
ans = v[i];
maks = wew;
}
}
cout << ans << endl;
{
fflush(stdin);
getchar();
};
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
string s;
getline(cin >> ws, s);
vector<string> a;
string b = "";
for (int i = 0; i < s.size(); i++) {
if (s[i] == '-') {
a.push_back(b);
b = "";
} else {
b += s[i];
}
}
a.push_back(b);
map<string, int> cnt;
int condition;
if (a.size() > 2) {
condition = a.size();
} else if (a.size() == 2) {
condition = 3;
}
for (int i = 2; i < condition; i++) {
if (a[i].size() >= 4) {
string year = "";
year += a[i][0];
year += a[i][1];
year += a[i][2];
year += a[i][3];
if (stoi(year) >= 2013 && stoi(year) <= 2015) {
if (a[i - 1].size() == 2) {
string month = "";
month = a[i - 1];
if (stoi(month) >= 1 && stoi(month) <= 12) {
if (a[i - 2].size() >= 2) {
string day = "";
day += a[i - 2][a[i - 2].size() - 2];
day += a[i - 2][a[i - 2].size() - 1];
if (stoi(month) <= 7) {
if (stoi(month) % 2) {
if (stoi(day) <= 31 && stoi(day) > 0) {
string ans = "";
ans += day + '-' + month + '-' + year;
cnt[ans]++;
} else {
continue;
}
} else {
if (stoi(month) == 2) {
if (stoi(day) <= 28 && stoi(day) > 0) {
string ans = "";
ans += day + '-' + month + '-' + year;
cnt[ans]++;
} else {
continue;
}
} else {
if (stoi(day) <= 30 && stoi(day) > 0) {
string ans = "";
ans += day + '-' + month + '-' + year;
cnt[ans]++;
} else {
continue;
}
}
}
} else {
if (stoi(month) % 2) {
if (stoi(day) <= 30 && stoi(day) > 0) {
string ans = "";
ans += day + '-' + month + '-' + year;
cnt[ans]++;
} else {
continue;
}
} else {
if (stoi(day) <= 31 && stoi(day) > 0) {
string ans = "";
ans += day + '-' + month + '-' + year;
cnt[ans]++;
} else {
continue;
}
}
}
}
}
}
}
}
}
int ans = 0;
string an;
for (auto it = cnt.begin(); it != cnt.end(); it++) {
if (it->second > ans) {
ans = it->second;
an = it->first;
}
}
cout << an << "\n";
}
| 8 |
CPP
|
#include <bits/stdc++.h>
char a[100000 + 2];
int vis[32][13][6];
int save[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
void solve() {
memset(vis, 0, sizeof(vis));
int len = strlen(a);
int max = 0, d, m, y;
for (int i = 9; i < len; i++) {
if ((a[i] == '3' || a[i] == '4' || a[i] == '5') && a[i - 1] == '1' &&
a[i - 2] == '0' && a[i - 3] == '2') {
if (a[i - 4] != '-' || a[i - 7] != '-' || a[i - 5] == '-' ||
a[i - 6] == '-' || a[i - 8] == '-' || a[i - 9] == '-')
continue;
int dd = (a[i - 9] - '0') * 10 + (a[i - 8] - '0');
int mm = (a[i - 6] - '0') * 10 + (a[i - 5] - '0');
if (mm <= 12 && mm > 0 && dd > 0 && dd <= save[mm - 1]) {
int k = ++vis[dd][mm][a[i] - '0'];
if (k > max) {
max = k;
d = dd;
m = mm;
y = 2010 + a[i] - '0';
}
}
}
}
if (d < 10) printf("0");
printf("%d-", d);
if (m < 10) printf("0");
printf("%d-%d\n", m, y);
}
int main() {
while (gets(a)) {
solve();
}
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) { return y == 0 ? x : gcd(y, x % y); }
int toInt(char xx) { return xx - '0'; }
char toChar(int xx) { return xx + '0'; }
bool isDigit(char xx) { return ('0' <= xx && xx <= '9'); }
bool isCharacter(char xx) {
return (('a' <= xx && xx <= 'z') || ('A' <= xx && xx <= 'Z'));
}
void swapInt(int &x, int &y) {
x = x ^ y;
y = x ^ y;
x = x ^ y;
}
inline void clear_buffer() {
string tmp;
getline(cin, tmp);
}
struct Date {
int d, m, y;
Date() { d = m = y = 0; }
bool operator<(const Date &other) const {
if (y != other.y) return y < other.y;
if (d != other.d) return d < other.d;
if (m != other.m) return m < other.m;
return false;
}
void display() {
if (d >= 10) {
printf("%d-", d);
} else {
printf("0");
printf("%d-", d);
}
if (m >= 10) {
printf("%d-", m);
} else {
printf("0");
printf("%d-", m);
}
printf("%d\n", y);
}
};
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const int Mod = 10;
const int maxn = (1e6) + 10;
bool exitInput = false;
const int days_in_month[15] = {0, 31, 28, 31, 30, 31, 30,
31, 31, 30, 31, 30, 31};
const char gach = '-';
int dd, mm, yy;
map<Date, int> mp;
string s;
bool isCorrectFormat(int i) {
if (s[i + 2] != gach || s[i + 5] != gach) return false;
for (int j = 0; j < 9; ++j) {
if (j != 2 && j != 5 && s[i + j] == gach) return false;
}
return true;
}
bool isValidFormat(int i) {
int d, m, y;
d = toInt(s[i]) * 10 + toInt(s[i + 1]);
m = toInt(s[i + 3]) * 10 + toInt(s[i + 4]);
y = toInt(s[i + 6]) * 1000 + toInt(s[i + 7]) * 100 + toInt(s[i + 8]) * 10 +
toInt(s[i + 9]);
dd = d;
mm = m;
yy = y;
if (y < 2013 || y > 2015) {
return false;
}
if (m < 1 || m > 12) {
return false;
}
if (d < 1 || d > days_in_month[m]) return false;
return true;
}
void read() { cin >> s; }
void init() {}
void solve() {
int len = s.size();
for (int i = 0; i <= len - 8; ++i) {
if (isCorrectFormat(i)) {
if (isValidFormat(i)) {
Date x;
x.d = dd;
x.m = mm;
x.y = yy;
mp[x]++;
}
}
}
int tmp_cnt = 0;
map<Date, int>::iterator it;
for (it = mp.begin(); it != mp.end(); ++it) {
Date x = (*it).first;
tmp_cnt = max(tmp_cnt, (*it).second);
}
for (it = mp.begin(); it != mp.end(); ++it) {
if (tmp_cnt == (*it).second) {
Date x = (*it).first;
x.display();
return;
}
}
}
int main() {
int ntest = 1;
int itest = 1;
for (itest = 1; itest <= ntest; ++itest) {
read();
if (exitInput) {
break;
}
init();
solve();
}
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
vector<string> v;
for (int i = 0; i < s.size() - 9; i++) {
if (s[i + 3] == '0') {
if (s[i + 4] == '1' || s[i + 4] == '3' || s[i + 4] == '5' ||
s[i + 4] == '7' || s[i + 4] == '8') {
if (!(s[i] == '0' && s[i + 1] == '0')) {
if (!(s[i] == '3' &&
(s[i + 1] == '2' || s[i + 1] == '3' || s[i + 1] == '4' ||
s[i + 1] == '5' || s[i + 1] == '6' || s[i + 1] == '7' ||
s[i + 1] == '8' || s[i + 1] == '9'))) {
if (s[i] >= '0' && s[i] <= '3' && s[i + 1] >= '0' &&
s[i + 1] <= '9') {
if (s[i + 2] == '-' && s[i + 5] == '-' && s[i + 6] == '2' &&
s[i + 7] == '0' && s[i + 8] == '1' && s[i + 9] >= '3' &&
s[i + 9] <= '5') {
v.push_back(s.substr(i, 10));
continue;
}
}
}
}
} else if (s[i + 4] == '2') {
if (!(s[i] == '0' && s[i + 1] == '0')) {
if (!(s[i] == '2' && s[i + 1] == '9')) {
if (s[i] >= '0' && s[i] <= '2' && s[i + 1] >= '0' &&
s[i + 1] <= '9') {
if (s[i + 2] == '-' && s[i + 5] == '-' && s[i + 6] == '2' &&
s[i + 7] == '0' && s[i + 8] == '1' && s[i + 9] >= '3' &&
s[i + 9] <= '5') {
v.push_back(s.substr(i, 10));
continue;
}
}
}
}
} else if (s[i + 4] == '4' || s[i + 4] == '6' || s[i + 4] == '9') {
if (!(s[i] == '0' && s[i + 1] == '0')) {
if (!(s[i] == '3' &&
(s[i + 1] == '1' || s[i + 1] == '2' || s[i + 1] == '3' ||
s[i + 1] == '4' || s[i + 1] == '5' || s[i + 1] == '6' ||
s[i + 1] == '7' || s[i + 1] == '8' || s[i + 1] == '9'))) {
if (s[i] >= '0' && s[i] <= '3' && s[i + 1] >= '0' &&
s[i + 1] <= '9') {
if (s[i + 2] == '-' && s[i + 5] == '-' && s[i + 6] == '2' &&
s[i + 7] == '0' && s[i + 8] == '1' && s[i + 9] >= '3' &&
s[i + 9] <= '5') {
v.push_back(s.substr(i, 10));
continue;
}
}
}
}
}
} else if (s[i + 3] == '1') {
if (s[i + 4] == '0' || s[i + 4] == '2') {
if (!(s[i] == '0' && s[i + 1] == '0')) {
if (!(s[i] == '3' &&
(s[i + 1] == '2' || s[i + 1] == '3' || s[i + 1] == '4' ||
s[i + 1] == '5' || s[i + 1] == '6' || s[i + 1] == '7' ||
s[i + 1] == '8' || s[i + 1] == '9'))) {
if (s[i] >= '0' && s[i] <= '3' && s[i + 1] >= '0' &&
s[i + 1] <= '9') {
if (s[i + 2] == '-' && s[i + 5] == '-' && s[i + 6] == '2' &&
s[i + 7] == '0' && s[i + 8] == '1' && s[i + 9] >= '3' &&
s[i + 9] <= '5') {
v.push_back(s.substr(i, 10));
continue;
}
}
}
}
} else if (s[i + 4] == '1') {
if (!(s[i] == '0' && s[i + 1] == '0')) {
if (!(s[i] == '3' &&
(s[i + 1] == '1' || s[i + 1] == '2' || s[i + 1] == '3' ||
s[i + 1] == '4' || s[i + 1] == '5' || s[i + 1] == '6' ||
s[i + 1] == '7' || s[i + 1] == '8' || s[i + 1] == '9'))) {
if (s[i] >= '0' && s[i] <= '3' && s[i + 1] >= '0' &&
s[i + 1] <= '9') {
if (s[i + 2] == '-' && s[i + 5] == '-' && s[i + 6] == '2' &&
s[i + 7] == '0' && s[i + 8] == '1' && s[i + 9] >= '3' &&
s[i + 9] <= '5') {
v.push_back(s.substr(i, 10));
continue;
}
}
}
}
}
}
}
int ma = 0, count = 1;
string t;
sort(v.begin(), v.end());
for (int i = 0; i < v.size() - 1; i++) {
if (v[i] == v[i + 1])
count++;
else {
if (count > ma) t = v[i];
ma = max(ma, count);
count = 1;
}
}
if (count > ma) t = v[v.size() - 1];
cout << t;
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int main() {
char a[1000000];
cin >> a;
int l = strlen(a);
int i, j;
int month;
int year;
int date;
int found[10000][4] = {0};
int founi = 0;
int flag;
int ac[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
for (i = 2; i < l - 7; i++) {
if (a[i - 2] != '-' && a[i - 1] != '-' && a[i + 0] == '-' &&
a[i + 1] != '-' && a[i + 2] != '-' && a[i + 3] == '-' &&
a[i + 4] != '-' && a[i + 5] != '-' && a[i + 6] != '-' &&
a[i + 7] != '-') {
month = (a[i + 1] - '0') * 10 + (a[i + 2] - '0');
date = (a[i - 2] - '0') * 10 + (a[i - 1] - '0');
year = (a[i + 4] - '0') * 1000 + (a[i + 5] - '0') * 100 +
(a[i + 6] - '0') * 10 + (a[i + 7] - '0');
if (month <= 12 && month >= 1 && year <= 2015 && year >= 2013) {
if (date <= ac[month] && date >= 1) {
flag = 0;
for (j = 0; j < founi; j++) {
if (found[j][0] == year && found[j][1] == month &&
found[j][2] == date) {
flag = 1;
found[j][3]++;
}
}
if (flag == 0) {
found[founi][0] = year;
found[founi][1] = month;
found[founi][2] = date;
found[founi][3] = 1;
founi++;
}
}
}
}
}
int max = -1;
max = -1;
for (i = 0; i < founi; i++) {
if (max < found[i][3]) {
max = found[i][3];
year = found[i][0];
month = found[i][1];
date = found[i][2];
}
}
if (date < 10) {
cout << "0" << date;
} else {
cout << date;
}
cout << '-';
if (month < 10) {
cout << "0" << month;
} else {
cout << month;
}
cout << "-";
cout << year << endl;
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
string a;
int cnt[40][20][10];
int m[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
cin >> a;
int n = a.size(), mx = 0, ansd = 0, ansm = 0, ansy = 0;
for (int i = 0; i + 9 < n; i++) {
if (a[i] == '-' || a[i + 1] == '-' || a[i + 2] != '-' || a[i + 3] == '-' ||
a[i + 4] == '-' || a[i + 5] != '-' || a[i + 6] != '2' ||
a[i + 7] != '0' || a[i + 8] != '1' || a[i + 9] == '-')
continue;
int dd = (a[i] - 48) * 10 + a[i + 1] - 48;
int mm = (a[i + 3] - 48) * 10 + a[i + 4] - 48;
int yy = a[i + 9] - 48;
if (3 <= yy && yy <= 5 && 1 <= mm && mm <= 12 && 1 <= dd && dd <= m[mm]) {
cnt[dd][mm][yy]++;
if (cnt[dd][mm][yy] > mx) {
mx = cnt[dd][mm][yy];
ansd = dd;
ansm = mm;
ansy = yy;
}
}
}
printf("%d%d-%d%d-%d\n", ansd / 10, ansd % 10, ansm / 10, ansm % 10,
2010 + ansy);
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
string s;
map<string, int> cnt;
int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string ans = "0";
void solve(string x) {
if (x[2] != '-' or x[5] != '-') return;
for (int i = 0; i < 10; i++) {
if ((i == 2 or i == 5) and x[i] != '-') return;
if (i == 2 or i == 5) continue;
if (x[i] < '0' or x[i] > '9') return;
}
int day = (x[0] - '0') * 10 + x[1] - '0';
int month = (x[3] - '0') * 10 + x[4] - '0';
int year =
(x[6] - '0') * 1000 + (x[7] - '0') * 100 + (x[8] - '0') * 10 + x[9] - '0';
if (year < 2013 or year > 2015) return;
if (month < 1 or month > 12) return;
if (day < 1 or day > days[month]) return;
if (cnt.find(x) == cnt.end())
cnt[x] = 1;
else
cnt[x]++;
if (cnt[x] > cnt[ans]) ans = x;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> s;
cnt["0"] = -1;
for (int i = 0; i + 9 < s.size(); i++) {
solve(s.substr(i, 10));
}
cout << ans;
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string ans, s;
int len, L;
inline void check(int y, int m, int d) {
string res = "";
for (int i = 1; i <= 4; ++i) {
res += char(y % 10 + '0');
y /= 10;
}
res += '-';
for (int i = 1; i <= 2; ++i) {
res += char(m % 10 + '0');
m /= 10;
}
res += '-';
for (int i = 1; i <= 2; ++i) {
res += char(d % 10 + '0');
d /= 10;
}
reverse(res.begin(), res.end());
if (s.find(res) == string::npos) return;
int book = 0;
for (int i = 0; i < L; ++i) {
if (s.substr(i, 10) == res) {
book++;
if (book > len) {
len = book;
ans = res;
}
}
}
}
int main() {
cin >> s;
L = s.size();
for (int y = 2013; y <= 2015; ++y) {
for (int m = 1; m <= 12; ++m) {
for (int d = 1; d <= mon[m]; ++d) {
check(y, m, d);
}
}
}
cout << ans << endl;
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
const int inf = 1000 * 1000 * 1000;
const int maxn = 1000;
int c, mx, mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string mxs, s, ans[1001];
map<string, int> u;
bool find(string x) {
for (int i = 0; i < x.size(); i++) {
if (x[i] == '-' && i != 2 && i != 5) return false;
if (i == 2 || i == 5) {
if (x[i] != '-') return false;
}
}
int dd;
dd = (x[0] - 48) * 10 + (x[1] - 48);
int mm;
mm = (x[3] - 48) * 10 + (x[4] - 48);
int yy;
yy = (x[6] - 48) * 1000 + (x[7] - 48) * 100 + (x[8] - 48) * 10 + (x[9] - 48);
if (yy < 2013 || yy > 2015) return false;
if (dd > mon[mm] || dd <= 0) return false;
return true;
}
int main() {
cin >> s;
for (int i = 0; i < s.length(); i++) {
string st = "";
for (int j = i; j < i + 10; j++) {
st += s[j];
}
if (find(st)) {
if (u[st] == 0) ans[++c] = st;
u[st]++;
}
}
for (int i = 1; i <= c; i++) {
if (u[ans[i]] > mx) {
mx = u[ans[i]];
mxs = ans[i];
}
}
cout << mxs;
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
template <typename T>
T inline SQR(const T &a) {
return a * a;
}
template <typename T>
T inline ABS(const T &a) {
return a < 0 ? -a : a;
}
const double EPS = 1e-9;
inline int SGN(double a) {
return ((a > EPS) ? (1) : ((a < -EPS) ? (-1) : (0)));
}
inline int CMP(double a, double b) { return SGN(a - b); }
using namespace std;
int ndays[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main(int argc, char *argv[]) {
ios::sync_with_stdio(false);
string s;
cin >> s;
map<string, int> occ;
int i = 0, j = 9;
while (j < int((s).size())) {
if (s[i + 2] == s[i + 5] && s[i + 5] == '-') {
int mm = -1, dd = -1, yy = -1;
if (s[i] != '-' && s[i + 1] != '-') {
dd = 10 * (s[i] - '0') + (s[i + 1] - '0');
}
if (s[i + 3] != '-' && s[i + 4] != '-') {
mm = 10 * (s[i + 3] - '0') + (s[i + 4] - '0');
}
if (s[i + 6] != '-' && s[i + 7] != '-' && s[i + 8] != '-' &&
s[i + 9] != '-') {
yy = 1000 * (s[i + 6] - '0') + 100 * (s[i + 7] - '0') +
10 * (s[i + 8] - '0') + (s[i + 9] - '0');
}
if ((mm != -1) && (dd != -1) && (yy != -1)) {
if (2013 <= yy && yy <= 2015) {
if (1 <= mm && mm <= 12) {
if (1 <= dd && dd <= ndays[mm]) {
occ[s.substr(i, 10)]++;
}
}
}
}
}
i++, j++;
}
int mx = -1;
string res;
for (__typeof((occ).begin()) dt = occ.begin(); dt != occ.end(); dt++) {
if (dt->second > mx) {
mx = dt->second;
res = dt->first;
}
}
cout << res << "\n";
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int stoi(string &s) {
int n = 0;
for (int i = 0; i < s.size(); i++) {
n *= 10;
n += s[i] - 48;
}
return n;
}
string itos(int n) {
string s;
s.push_back(n / 10 + 48);
s.push_back(n % 10 + 48);
return s;
}
int date[32][13][3];
int main() {
string s;
cin >> s;
int d, m, y;
for (int i = 6; i < s.size() - 3; i++) {
string yyyy = s.substr(i, 4);
if (yyyy == "2013" || yyyy == "2014" || yyyy == "2015") {
if (s[i - 1] != '-') continue;
if (s[i - 2] == '-') continue;
if (s[i - 3] == '-') continue;
if (s[i - 4] != '-') continue;
if (s[i - 5] == '-') continue;
if (s[i - 6] == '-') continue;
y = stoi(yyyy);
string dd = s.substr(i - 6, 2);
string mm = s.substr(i - 3, 2);
d = stoi(dd);
m = stoi(mm);
switch (m) {
case 1:
if (d > 31) d = -1;
break;
case 2:
if (d > 28) d = -1;
break;
case 3:
if (d > 31) d = -1;
break;
case 4:
if (d > 30) d = -1;
break;
case 5:
if (d > 31) d = -1;
break;
case 6:
if (d > 30) d = -1;
break;
case 7:
if (d > 31) d = -1;
break;
case 8:
if (d > 31) d = -1;
break;
case 9:
if (d > 30) d = -1;
break;
case 10:
if (d > 31) d = -1;
break;
case 11:
if (d > 30) d = -1;
break;
case 12:
if (d > 31) d = -1;
break;
default:
d = -1;
break;
}
if (d == -1 || d == 0) continue;
date[d][m][y - 2013]++;
}
}
int t = 0;
for (int i = 0; i < 32; i++)
for (int j = 0; j < 13; j++)
for (int k = 0; k < 3; k++)
if (t < date[i][j][k]) {
d = i;
m = j;
y = k + 2013;
t = date[i][j][k];
}
string dd = itos(d);
string mm = itos(m);
cout << dd << "-" << mm << "-" << y;
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int64_t m[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
map<string, int64_t> date;
string s;
cin >> s;
s = "00" + s;
int64_t n = s.length();
for (int64_t i = 0; i < n - 8; ++i) {
string a = s.substr(i, 9);
if (count((a).begin(), (a).end(), '-') == 2 and a[2] == '-' and
a[4] == '-') {
int64_t day = stoi(a.substr(0, 2));
int64_t month = stoi(a.substr(3, 1));
int64_t year = stoi(a.substr(5, 4));
if (month >= 1 and month <= 12 and day >= 1 and day <= m[month - 1] and
year >= 2013 and year <= 2015) {
string real;
real += a[0], real += a[1], real += '-', real += '0', real += a[3],
real += '-', real += a.substr(5, 4);
date[real]++;
cout << a << '\n';
}
}
}
for (int64_t i = 0; i < n - 9; ++i) {
string a = s.substr(i, 10);
if (count((a).begin(), (a).end(), '-') == 2 and a[2] == '-' and
a[5] == '-') {
int64_t day = stoi(a.substr(0, 2));
int64_t month = stoi(a.substr(3, 2));
int64_t year = stoi(a.substr(6, 4));
if (month >= 1 and month <= 12 and day >= 1 and day <= m[month - 1] and
year >= 2013 and year <= 2015) {
string real;
real += a.substr(0, 2), real += '-', real += a.substr(3, 2),
real += '-', real += a.substr(6, 4);
date[real]++;
}
}
}
int64_t best = 0;
string val;
for (auto& x : date) {
if (x.second >= best) {
best = x.second;
val = x.first;
}
}
cout << val;
}
| 8 |
CPP
|
from collections import deque
from math import log,sqrt,ceil
def ii(): return int(input())
def si(): return input()
def mi(): return map(int,input().strip().split(" "))
def li(): return list(mi())
s=si()
a=[]
s1=""
f=1
mon=[0,31,28,31,30,31,30,31,31,30,31,30,31]
for i in range(len(s)):
if(s[i]=='-'):
a.append(s[i])
if(s1!=""):
if(len(s1)==1):
a.append(int(s1))
elif(len(s1)>=4 and f):
a.append(int(s1[:4]))
a.append(int(s1[-2:]))
else:
a.append(int(s1[-2:]))
s1=""
f=1
else:
f=0
else:
s1+=s[i]
a.append('-')
if(len(s1)==1):
a.append(int(s1))
elif(len(s1)>=4):
a.append(int(s1[:4]))
else:
a.append(int(s1[-2:]))
m={}
for i in range(len(a)):
x,y=0,0
if(a[i]!='-' and a[i]>=2013 and a[i]<=2015):
if(i-2>=0 and a[i-2]!='-'):
x=a[i-2]
if(i-4>=0 and a[i-4]!='-'):
y=a[i-4]
if(x>=1 and x<=12):
if(y>0 and y<=mon[x]):
tup=(y,x,a[i])
if tup not in m:
m[tup]=1
else:
m[tup]+=1
x=0
for i in m.keys():
if(m[i]>x):
x=m[i]
y=i
dd=y[0]
if(dd<10):
dd='0'+str(dd)
mm=y[1]
if(mm<10):
mm='0'+str(mm)
yy=y[2]
s=str(dd)+'-'+str(mm)+'-'+str(yy)
print(s)
| 8 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
string str, s, rezz, datums[40005];
int i, j, k, d, m, y, n, z, rez;
int monthdays[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int mas[40005], bijan[40005];
int main() {
cin >> str;
k = str.length() - 9;
for (i = 0; i < k; ++i) {
s = str.substr(i, 10);
m = 0;
for (j = 0; j < 10; ++j) {
if (s[j] == '-') {
++m;
}
}
if (((m == 2) && (s[2] == '-')) && (s[5] == '-')) {
d = (s[0] - '0') * 10 + s[1] - '0';
m = (s[3] - '0') * 10 + s[4] - '0';
y = (s[6] - '0') * 1000 + (s[7] - '0') * 100 + (s[8] - '0') * 10 + s[9] -
'0';
if ((((y >= 2013) && (y <= 2015)) &&
((m <= 12) && (d <= monthdays[m]))) &&
((d > 0) && (m > 0))) {
n = (2016 - y) * 10000 + m * 100 + d;
++mas[n];
if (mas[n] == 1) {
bijan[z] = n;
datums[z] = s;
++z;
}
rez = max(rez, mas[n]);
}
}
}
for (i = 0; i < z; ++i) {
if (mas[bijan[i]] == rez) {
cout << datums[i];
}
}
return 0;
}
| 8 |
CPP
|
s=input()
def correct(s):
c={2,5}
for i in range(10):
if i not in c:
if s[i]=="-":
return False
else:
if s[i]!="-":
return False
###check for day
if int(s[0:2])<32 and int(s[0:2])>0:
pass
else:
return False
##check for month
if int(s[3:5])>0 and int(s[3:5])<13:
pass
else:
return False
#check for year
y={"2013","2014","2015"}
if s[6:] not in y:
return False
if s[0:2]=="31":
m={"01","03","05","07","08","10","12"}
if s[3:5] not in m:
return False
if s[3:5]=="02":
if int(s[0:2])>28:
return False
return True
dict={}
n=len(s)
i=0
while i<=n-10:
if correct(s[i:i+10])==True:
if s[i:i+10] in dict:
dict[s[i:i+10]]+=1
else:
dict[s[i:i+10]]=1
i+=8
else:
i+=1
m=0
ans=None
for key,item in dict.items():
if item>m:
m=item
ans=key
print(ans)
| 8 |
PYTHON3
|
#include <bits/stdc++.h>
char str[100001];
int num[32][13][2020];
int months[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int isnum(char c) {
if (c >= '0' && c <= '9')
return 1;
else
return 0;
}
int isleap(int year) {
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
return 1;
else
return 0;
}
int main() {
while (scanf("%s", str) != EOF) {
memset(num, 0, sizeof(num));
int month, year, day, dcount = 0;
month = 0, year = 0, day = 0;
int len = strlen(str), ans = 0, y = 0, m = 0, d = 0;
for (int i = 0; i < len; i++) {
if (isnum(str[i]) && (i + 9) < len) {
if (isnum(str[i + 1]) && !isnum(str[i + 2]) && isnum(str[i + 3]) &&
isnum(str[i + 4]) && !isnum(str[i + 5]) && isnum(str[i + 6]) &&
isnum(str[i + 7]) && isnum(str[i + 8]) && isnum(str[i + 9])) {
day = (str[i] - '0') * 10 + str[i + 1] - '0';
if (day > 31 || day == 0) continue;
month = (str[i + 3] - '0') * 10 + str[i + 4] - '0';
if (day > months[month]) continue;
if (month > 12) continue;
year = (str[i + 6] - '0') * 1000 + (str[i + 7] - '0') * 100 +
(str[i + 8] - '0') * 10 + str[i + 9] - '0';
if (year < 2013 || year > 2015) continue;
num[day][month][year]++;
if (ans < num[day][month][year]) {
d = day;
m = month;
y = year;
ans = num[day][month][year];
}
}
}
}
if (d < 10)
printf("0%d-", d);
else
printf("%d-", d);
if (m < 10)
printf("0%d-", m);
else
printf("%d-", m);
printf("%d\n", y);
}
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int y, m, d, j, n = 0, i,
day[15] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
map<string, int> mp;
string x, v, s;
int main() {
cin >> s;
for (i = 0; i + 10 <= s.size(); i++) {
x = s.substr(i, 10);
if (sscanf((x + "*1").c_str(), "%2d-%2d-%4d*%d", &d, &m, &y, &j) != 4)
continue;
if (y < 2013 || y > 2015 || m < 1 || m > 12 || d < 1 || d > day[m])
continue;
mp[x]++;
if (n < mp[x]) n = mp[x], v = x;
}
cout << v;
}
| 8 |
CPP
|
from operator import itemgetter
def var(a):
sim = 0
mes = {1:31,2:28,3:31,4:30,5:31,6:30,7:31,8:31,9:30,10:31,11:30,12:31}
dia = 0
if a[2] >= 2013 and a[2] <= 2015:
sim += 1
if a[1] in mes:
sim += 1
dia = mes[a[1]]
if a[0] <= dia and a[0] > 0:
sim += 1
return sim
data = input()
tam = len(data)
i = 0
j = 10
datas = dict()
while j <= tam:
a = data[i:j]
if a[2] == a[5] and a[2] == '-':
a = a.split('-')
if len(a)==3:
opa = var(list(map(int,a)))
if opa == 3:
aux = '-'.join(a)
if aux in datas:
datas[aux] += 1
else:
datas[aux] = 1
i +=1
j +=1
print(sorted(datas.items(), key=itemgetter(1))[-1][0])
| 8 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
map<string, int> m;
bool isok(char *ss) {
int i = 0, cnt = 0;
for ((i) = 0; (i) < (10); (i)++) {
if (!isdigit(*(ss + i))) cnt++;
}
if (cnt == 2 && *(ss + 2) == '-' && *(ss + 5) == '-') return true;
return false;
}
bool isvalid(char *ss) {
int d, m, y;
sscanf(ss, "%2d%*c%2d%*c%4d", &d, &m, &y);
return (y >= 2013 && y <= 2015) && (m > 0 && m <= 12) &&
(d >= 1 && d <= days[m - 1]);
}
char s[100005];
int main() {
scanf("%s", s);
int n = strlen(s), i, mx = 0, j;
string ans;
for ((i) = 0; (i) < (n - 9); (i)++) {
if (isok(s + i) && isvalid(s + i)) {
string a = "";
for ((j) = 0; (j) < (10); (j)++) a.push_back(s[j + i]);
if (m.find(a) == m.end())
m[a] = 1;
else
m[a]++;
if (m[a] > mx) {
mx = m[a];
ans = a;
}
}
}
cout << ans << endl;
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
struct date {
int d;
int m;
int y;
};
int* maxdm(void) {
int i = 0;
int* mdm = (int*)malloc(13 * sizeof(int));
for (i = 1; i < 13; i++) {
mdm[i] = 30;
if (i < 8) {
if (i % 2 == 0) {
if (i == 2) {
mdm[i] = 28;
} else {
mdm[i] = 30;
}
} else {
mdm[i] = 31;
}
} else {
if (i % 2 == 0) {
mdm[i] = 31;
} else {
mdm[i] = 30;
}
}
}
return mdm;
}
int isdigit(char c) {
if (c < 58 && c > 47) {
return 1;
} else {
return 0;
}
}
int dateiscorrect(int d, int m, int y, int* mdm) {
if (m < 0 || m > 12 || y > 2015 || y < 2013 || d < 1) {
return 0;
} else {
if (mdm[m] >= d) {
return 1;
} else {
return 0;
}
}
}
int main(void) {
int* mdm = maxdm();
char* s = (char*)malloc(100000);
scanf("%s", s);
int d, m, y;
int i = 0;
int nb = 0;
int tab[12 * 31 * 3];
for (i = 0; i < 12 * 31 * 3; i++) {
tab[i] = 0;
}
i = 0;
while (s[i + 9] != '\0') {
if (isdigit(s[i + 0]) && isdigit(s[i + 1]) && isdigit(s[i + 3]) &&
isdigit(s[i + 4]) && isdigit(s[i + 6]) && isdigit(s[i + 7]) &&
isdigit(s[i + 8]) && isdigit(s[i + 9]) && s[i + 2] == '-' &&
s[i + 5] == '-') {
int d = (s[i + 0] - 48) * 10 + (s[i + 1] - 48);
int m = (s[i + 3] - 48) * 10 + (s[i + 4] - 48);
int y = (s[i + 6] - 48) * 1000 + (s[i + 7] - 48) * 100 +
(s[i + 8] - 48) * 10 + (s[i + 9] - 48);
if (dateiscorrect(d, m, y, mdm)) {
tab[d - 1 + (m - 1) * 31 + (y - 2013) * 372]++;
nb++;
}
}
i++;
}
int pmax = 0;
int max = 0;
int tmp = 0;
for (i = 0; i < 12 * 31 * 3; i++) {
if (tab[i] > max) {
max = tab[i];
pmax = i;
}
}
y = 2013 + pmax / 372;
m = (pmax % 372) / 31 + 1;
d = ((pmax % 372) % 31) + 1;
if (d < 10) {
printf("0");
}
printf("%d-", d);
if (m < 10) {
printf("0");
}
printf("%d-", m);
printf("%d", y);
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int main() {
char str[100005], res[15], Max[15];
char temp[15] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int len, i, j, t, max, day, mon, year;
while (gets(str)) {
map<string, int> num;
len = strlen(str);
for (i = 0, max = 0; i < len - 9; i++) {
if (str[i + 2] == '-' && str[i + 5] == '-') {
memset(res, 0, sizeof(res));
for (j = 0; j < 10; j++) {
if (j != 2 && j != 5 && str[j + i] == '-') break;
res[j] = str[i + j];
}
if (j >= 10) {
res[10] = '\0';
year = (((str[i + 6] - '0') * 10 + str[i + 7] - '0') * 10 +
str[i + 8] - '0') *
10 +
str[i + 9] - '0';
if (year > 2015 || year < 2013) continue;
mon = (str[i + 3] - '0') * 10 + str[i + 4] - '0';
if (mon > 12 || mon < 1) continue;
day = (str[i] - '0') * 10 + str[i + 1] - '0';
if (day > temp[mon - 1] || day < 1) continue;
num[res]++;
if (max < num[res]) {
max = num[res];
strcpy(Max, res);
}
}
}
}
printf("%s\n", Max);
}
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
int q = 0, w = 0, e = 0;
string p = "";
string s;
cin >> s;
vector<pair<int, string>> a;
vector<int> b = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
a.push_back(make_pair(-1000000, "kek"));
for (int i = 0; i < s.length(); i++) {
if (s[i] != '-' && i + 9 < s.length() && s[i + 1] != '-' &&
s[i + 2] == '-' && s[i + 3] != '-' && s[i + 4] != '-' &&
s[i + 5] == '-' && s[i + 6] != '-' && s[i + 7] != '-' &&
s[i + 8] != '-' && s[i + 9] != '-') {
p = "";
p.push_back(s[i]);
p.push_back(s[i + 1]);
p.push_back(s[i + 2]);
p.push_back(s[i + 3]);
p.push_back(s[i + 4]);
p.push_back(s[i + 5]);
p.push_back(s[i + 6]);
p.push_back(s[i + 7]);
p.push_back(s[i + 8]);
p.push_back(s[i + 9]);
for (int j = 0; j < a.size(); j++) {
if (a[j].second != p && j == a.size() - 1) {
a.push_back(make_pair(1, p));
if (((int(p[0]) - '0') * 10 + int(p[1]) - '0') == 0 ||
((int(p[3]) - '0') * 10 + int(p[4]) - '0') == 0 ||
((int(p[8]) - '0') * 10 + int(p[9]) - '0') > 16 ||
((int(p[8]) - '0') * 10 + int(p[9]) - '0') <= 12 ||
((int(p[3]) - '0') * 10 + int(p[4]) - '0') > 12 ||
b[((int(p[3]) - '0') * 10 + int(p[4]) - '0') - 1] <
((int(p[0]) - '0') * 10 + int(p[1]) - '0'))
a[a.size() - 1].first = -1100000;
break;
} else if (a[j].second == p) {
a[j].first++;
}
}
}
}
sort(a.begin(), a.end());
cout << a[a.size() - 1].second;
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int mon[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
map<string, int> mp;
vector<pair<int, string> > vis;
int isCorrect(string s) {
int year, month, day;
if (s[0] == '-' || s[1] == '-' || s[3] == '-' || s[4] == '-' || s[6] == '-' ||
s[7] == '-' || s[8] == '-' || s[9] == '-')
return 0;
if (s[2] != '-' || s[5] != '-') return 0;
day = (s[0] - '0') * 10 + s[1] - '0';
month = (s[3] - '0') * 10 + s[4] - '0';
year = 0;
for (int i = 0; i < 4; i++) year = year * 10 + s[6 + i] - '0';
if (year >= 2013 && year <= 2015 && month >= 1 && month <= 12 && day >= 1 &&
day <= 31 && day <= mon[month])
return 1;
else
return 0;
}
int main() {
string s;
cin >> s;
for (int i = 0; i < s.length() - 9; i++) {
string s1(s, i, 10);
if (isCorrect(s1)) mp[s1]++;
}
for (map<string, int>::iterator it = mp.begin(); it != mp.end(); it++)
vis.push_back(make_pair(it->second, it->first));
sort(vis.begin(), vis.end());
cout << vis[vis.size() - 1].second << endl;
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int day[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int dm(string str) {
int s;
s = (int)str[0] - 48;
s = (s * 10) + (int)str[1] - 48;
return s;
}
int year(string str) {
int s;
s = (int)str[0] - 48;
s = (s * 10) + (int)str[1] - 48;
s = (s * 10) + (int)str[2] - 48;
s = (s * 10) + (int)str[3] - 48;
return s;
}
bool iscorrect(string str) {
if (str[2] != '-' || str[5] != '-') return false;
int d, m, y, cnt = 0;
for (int i = 0; i < str.size(); i++)
if (str[i] == '-') cnt++;
if (cnt > 2) return false;
y = year(str.substr(6, 4));
m = dm(str.substr(3, 2));
d = dm(str.substr(0, 2));
if (y < 2013 || y > 2015) return false;
if (m < 1 || m > 12) return false;
if (d < 1 || d > day[m]) return false;
return true;
}
int main() {
map<string, int> mp;
map<string, int>::iterator it;
string str, tmp;
cin >> str;
mp.clear();
for (int i = 0; i <= str.size() - 10; i++) {
tmp = str.substr(i, 10);
if (iscorrect(tmp)) {
if (mp.find(tmp) == mp.end())
mp[tmp] = 1;
else
mp[tmp]++;
}
}
int max = -1;
for (it = mp.begin(); it != mp.end(); ++it) {
if (it->second > max) {
max = it->second;
tmp = it->first;
}
}
cout << tmp << endl;
}
| 8 |
CPP
|
"""
Template written to be used by Python Programmers.
Use at your own risk!!!!
Owned by adi0311(rating - 5 star at CodeChef and Specialist at Codeforces).
"""
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nlargest, nsmallest, _heapify_max, _heapreplace_max
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as c
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
# sys.setrecursionlimit(2*pow(10, 6))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(var): sys.stdout.write(str(var))
def outln(var): sys.stdout.write(str(var)+"\n")
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]
dp = dd(int)
s = data()
intlist = deque()
for i in range(len(s)):
if '0' <= s[i] <= '9':
intlist.append(s[i])
dash_count = 0
else:
intlist.clear()
# else:
# intlist.popleft()
# intlist.popleft()
if len(intlist) == 4:
if i-9 >= 0:
temp = s[i-9:i+1]
n = 10
if 2013 <= int(temp[n-4:]) <= 2015 and temp[2] == temp[5] == '-':
if '0' <= temp[3] <= '9' and '0' <= temp[4] <= '9':
month = int(temp[3:5])
else:
month = -1
if '0' <= temp[0] <= '9' and '0' <= temp[1] <= '9':
day = int(temp[:2])
else:
day = -1
if 1 <= month <= 12:
if month in [1, 3, 5, 7, 8, 10, 12]:
if 1 <= day <= 31:
dp[temp] += 1
elif month == 2:
if 1 <= day <= 28:
dp[temp] += 1
elif month in [4, 6, 9, 11]:
if 1 <= day <= 30:
dp[temp] += 1
intlist.popleft()
intlist.popleft()
answer, cnt = "", 0
for i in dp.keys():
if dp[i] > cnt:
answer = i
cnt = dp[i]
outln(answer)
exit()
| 8 |
PYTHON3
|
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const int INF = 1 << 30;
const int base = 1000 * 1000 * 1000;
const int N = 1100000;
const int DAYS[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
char s[110000] = {};
map<string, int> M;
int len = 0;
void Solve() {
char date[11] = "01-01-2013";
for (int i = 3; i < 6; i++)
for (int j = 1; j < 13; j++)
for (int day = 1; day <= DAYS[j - 1]; day++) {
date[0] = day / 10 + '0';
date[1] = day % 10 + '0';
date[3] = j / 10 + '0';
date[4] = j % 10 + '0';
date[9] = i + '0';
int Count = 0;
for (int k = 0; k < len - 9; k++)
if (strncmp(&s[k], date, 10) == 0) Count++;
M[date] = Count;
}
}
int main() {
gets(s);
len = strlen(s);
Solve();
string answ;
int Max = -1;
for (map<string, int>::iterator it = M.begin(); it != M.end(); it++)
if (it->second > Max) {
answ = it->first;
Max = it->second;
}
for (int i = 0; i < answ.size(); i++) putchar(answ[i]);
putchar('\n');
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int day[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int record[5][20][40];
int main() {
char s[100015];
vector<int> num[3];
int len, m, d, y, ans, M, D, Y;
while (scanf(" %s", s) != EOF) {
for (int i = 0; i < 5; i++)
for (int j = 0; j < 20; j++)
for (int k = 0; k < 40; k++) record[i][j][k] = 0;
len = strlen(s), ans = 0;
for (int i = 0; i < 3; i++) num[i].clear();
s[len++] = '-';
for (int i = 0; i < len; i++) {
if (s[i] == '-') {
if (num[0].size() > 0 && num[1].size() == 2 && num[2].size() > 0) {
if (num[0].size() >= 2)
d = num[0][num[0].size() - 2] * 10 + num[0][num[0].size() - 1];
m = num[1][0] * 10 + num[1][1];
y = 0;
for (int x = 0; x < 4; x++) y = y * 10 + num[2][x];
if (2013 <= y && y <= 2015 && 1 <= m && m <= 12 && 1 <= d &&
d <= day[m]) {
record[y - 2013][m][d]++;
if (record[y - 2013][m][d] > ans) {
ans = record[y - 2013][m][d];
M = m;
D = d;
Y = y;
}
}
}
num[0] = num[1];
num[1] = num[2];
num[2].clear();
} else {
num[2].push_back(s[i] - '0');
}
}
printf("%02d-%02d-%d\n", D, M, Y);
}
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
string str;
struct node {
string tt;
int c;
};
map<string, int> vis;
node nodes[1000008];
int cnt;
bool check(int dd, int mm) {
if (dd <= 0) return false;
if (mm <= 0) return false;
if (mm == 2) {
if (dd <= 28)
return true;
else
return false;
}
if (mm == 1 || mm == 3 || mm == 5 || mm == 7 || mm == 8 || mm == 10 ||
mm == 12) {
if (dd <= 31)
return true;
else
return false;
}
if (mm == 2 || mm == 4 || mm == 6 || mm == 9 || mm == 11) {
if (dd <= 30)
return true;
else
return false;
}
return false;
}
void findS(int s) {
string tmp;
int dd, yy, mm;
if (s < 2) return;
if (str[s - 1] >= '0' && str[s - 1] <= '9' && str[s - 2] <= '9' &&
str[s - 2] >= '0') {
dd = (int)(str[s - 2] - '0') * 10 + (int)(str[s - 1] - '0');
if (str[s + 1] >= '0' && str[s + 1] <= '9' && str[s + 2] >= '0' &&
str[s + 2] <= '9') {
mm = (str[s + 1] - '0') * 10 + (str[s + 2] - '0');
if (!check(dd, mm)) return;
if (str[s + 3] != '-') return;
if (str[s + 4] >= '0' && str[s + 4] <= '9' && str[s + 5] >= '0' &&
str[s + 5] <= '9' && str[s + 6] >= '0' && str[s + 6] <= '9' &&
str[s + 7] >= '0' && str[s + 7] <= '9')
yy = (str[s + 4] - '0') * 1000 + (str[s + 5] - '0') * 100 +
(str[s + 6] - '0') * 10 + str[s + 7] - '0';
else
return;
if (yy < 2013 || yy > 2015) return;
tmp.push_back(str[s - 2]);
tmp.push_back(str[s - 1]);
tmp.push_back(str[s + 1]);
tmp.push_back(str[s + 2]);
tmp.push_back(str[s + 4]);
tmp.push_back(str[s + 5]);
tmp.push_back(str[s + 6]);
tmp.push_back(str[s + 7]);
if (vis[tmp]) {
nodes[vis[tmp]].c++;
} else {
vis[tmp] = ++cnt;
nodes[vis[tmp]].c = 1;
nodes[vis[tmp]].tt = tmp;
}
}
}
}
bool cmp(node a, node b) { return a.c > b.c; }
int main() {
cin >> str;
vis.clear();
cnt = 0;
for (int i = 0; i < str.length(); i++) {
if (str[i] == '-') {
findS(i);
}
}
sort(nodes + 1, nodes + 1 + cnt, cmp);
cout << nodes[1].tt[0] << nodes[1].tt[1] << "-" << nodes[1].tt[2]
<< nodes[1].tt[3] << "-" << nodes[1].tt[4] << nodes[1].tt[5]
<< nodes[1].tt[6] << nodes[1].tt[7] << endl;
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int d, m, y, res;
string line, cur, best;
map<string, int> s;
int main() {
res = 0;
getline(cin, line);
for (int i = (0); i < (line.length() + 1); i++) {
cur.clear();
for (int j = (0); j < (10); j++) cur += line[i + j];
if (!isdigit(cur[0]) || !isdigit(cur[1]) || !isdigit(cur[3]) ||
!isdigit(cur[4]) || !isdigit(cur[6]) || !isdigit(cur[7]) ||
!isdigit(cur[8]) || !isdigit(cur[9]) || isdigit(cur[2]) ||
isdigit(cur[5]))
continue;
d = 10 * (cur[0] - '0') + (cur[1] - '0');
m = 10 * (cur[3] - '0') + (cur[4] - '0');
y = 1000 * (cur[6] - '0') + 100 * (cur[7] - '0') + 10 * (cur[8] - '0') +
(cur[9] - '0');
if (m < 1 || m > 12 || y < 2013 || y > 2015) continue;
if (d < 1) continue;
if (m < 8) {
if (m % 2) {
if (d > 31) continue;
} else {
if (d > 30 || (m == 2 && d > 28)) continue;
}
} else {
if (m % 2) {
if (d > 30) continue;
} else {
if (d > 31) continue;
}
}
map<string, int>::iterator it = s.find(cur);
if (it == s.end()) {
s.insert(make_pair(cur, 1));
if (!res) {
res = 1;
best = cur;
}
} else {
++it->second;
if (it->second > res) {
res = it->second;
best = cur;
}
}
}
cout << best << endl;
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
map<string, int> m;
int d[13] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool check(string a) {
for (int i = 0; i < 10; i++) {
if (i == 2 || i == 5) {
if (a[i] != '-') return false;
} else {
if (a[i] < '0' || a[i] > '9') return false;
}
}
int year = (a[6] - '0') * 1000 + (a[7] - '0') * 100 + (a[8] - '0') * 10 +
(a[9] - '0');
int month = (a[3] - '0') * 10 + (a[4] - '0');
int date = (a[0] - '0') * 10 + (a[1] - '0');
if (year < 2013 || year > 2015) return false;
if (month <= 0 || month > 12) return false;
if (date > d[month] || date <= 0) return false;
return true;
}
int main() {
string s;
cin >> s;
for (int i = 0; i <= s.size() - 10; i++) {
if (check(s.substr(i, 10))) {
m[s.substr(i, 10)]++;
}
}
int maxc = -1;
string id;
for (map<string, int>::iterator it = m.begin(); it != m.end(); it++) {
if ((it->second) > maxc) {
id = (it->first);
maxc = (it->second);
}
}
cout << id;
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
void lpss(vector<int> &lps, string &s) {
lps[0] = 0;
lps[1] = 0;
int i = 2, j = 0;
while (i < s.length()) {
if (s[i] == s[j + 1]) {
lps[i] = ++j;
++i;
} else {
if (j != 0)
j = lps[j];
else {
lps[i] = 0;
++i;
}
}
}
}
int chk(string &s, string &p, vector<int> &lps) {
int i = 0, j = 0, c = 0;
while (i < s.length()) {
if (s[i] == p[j + 1]) {
i++;
j++;
if (j == p.length() - 1) {
c++;
j = lps[j];
}
} else {
if (j != 0)
j = lps[j];
else
i++;
}
}
return c;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int test = 1;
while (test--) {
string s;
cin >> s;
string d[31] = {"01", "02", "03", "04", "05", "06", "07", "08",
"09", "10", "11", "12", "13", "14", "15", "16",
"17", "18", "19", "20", "21", "22", "23", "24",
"25", "26", "27", "28", "29", "30", "31"};
string m[12] = {"01", "02", "03", "04", "05", "06",
"07", "08", "09", "10", "11", "12"};
string y[3] = {"2013", "2014", "2015"};
string ans;
ans.reserve(15);
int mx = 0;
for (int dd = 0; dd < 31; dd++) {
for (int mm = 0; mm < 12; mm++) {
for (int yy = 0; yy < 3; yy++) {
if ((mm == 1 && dd <= 27) ||
(((mm == 3) || (mm == 5) || (mm == 8) || (mm == 10)) &&
dd <= 29) ||
(mm == 0 || mm == 2 || mm == 4 || mm == 6 || mm == 7 || mm == 9 ||
mm == 11)) {
string p;
p.reserve(15);
p = "#";
p += d[dd];
p += "-";
p += m[mm];
p += "-";
p += y[yy];
vector<int> lps(p.length());
lpss(lps, p);
int c = chk(s, p, lps);
if (c > mx) {
mx = c;
ans = p.substr(1);
}
}
}
}
}
cout << ans;
}
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
const int kd[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int n, i, j;
char s[666666];
int cnt[42][42][42];
int mx, ad, am, ay;
int main() {
scanf("%s", s);
int n = strlen(s);
memset(cnt, 0, sizeof(cnt));
for (i = 0; i + 9 < n; i++) {
if (s[i + 2] != '-' || s[i + 5] != '-') continue;
int ok = 1;
for (j = 0; j < 10; j++)
if (j != 2 && j != 5 && s[i + j] == '-') ok = 0;
if (!ok) continue;
int dd = (s[i] - 48) * 10 + (s[i + 1] - 48);
int mm = (s[i + 3] - 48) * 10 + (s[i + 4] - 48);
if (s[i + 6] != '2' || s[i + 7] != '0' || s[i + 8] != '1') continue;
int yy = s[i + 9] - 48;
if (yy < 3 || yy > 5) continue;
if (mm < 1 || mm > 12) continue;
if (dd < 1 || dd > kd[mm]) continue;
cnt[dd][mm][yy]++;
if (cnt[dd][mm][yy] > mx) {
mx = cnt[dd][mm][yy];
ad = dd;
am = mm;
ay = yy;
}
}
printf("%d%d-%d%d-%d\n", ad / 10, ad % 10, am / 10, am % 10, 2010 + ay);
return 0;
}
| 8 |
CPP
|
days=dict()
for year in range(2013,2016):
for month in range(1,13):
if month in [1,3,5,7,8,10,12]:
for day in range(1,32):
if(day<10):
if(month<10):days['0'+str(day)+'-'+'0'+str(month)+'-'+str(year)]=0;
else:days['0'+str(day)+'-'+str(month)+'-'+str(year)]=0;
elif(month<10):days[str(day)+'-'+'0'+str(month)+'-'+str(year)]=0;
else:days[str(day)+'-'+str(month)+'-'+str(year)]=0;
elif month in [4,6,9,11]:
for day in range(1,31):
if(day<10):
if(month<10):days['0'+str(day)+'-'+'0'+str(month)+'-'+str(year)]=0;
else:days['0'+str(day)+'-'+str(month)+'-'+str(year)]=0;
elif(month<10):days[str(day)+'-'+'0'+str(month)+'-'+str(year)]=0;
else:days[str(day)+'-'+str(month)+'-'+str(year)]=0;
elif month in [2]:
for day in range(1,29):
if(day<10):
if(month<10):days['0'+str(day)+'-'+'0'+str(month)+'-'+str(year)]=0;
else:days['0'+str(day)+'-'+str(month)+'-'+str(year)]=0;
elif(month<10):days[str(day)+'-'+'0'+str(month)+'-'+str(year)]=0;
else:days[str(day)+'-'+str(month)+'-'+str(year)]=0;
st=input()
for i in days:
days[i]=st.count(i)
print(max(days, key=days.get))
| 8 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
string s, k;
cin >> s;
map<string, int> m;
for (int i = 0; i < s.size() - 9; i++) {
if (s[i] != '-' && s[i + 1] != '-' && s[i + 2] == '-' && s[i + 3] != '-' &&
s[i + 4] != '-' && s[i + 5] == '-' && s[i + 6] != '-' &&
s[i + 7] != '-' && s[i + 8] != '-' && s[i + 9] != '-') {
if (s[i + 6] == '2' && s[i + 7] == '0' && s[i + 8] == '1' &&
s[i + 9] >= '3' && s[i + 9] <= '5') {
if ((s[i + 3] == '0' &&
(s[i + 4] == '1' || s[i + 4] == '8' || s[i + 4] == '7' ||
s[i + 4] == '5' || s[i + 4] == '3')) ||
(s[i + 3] == '1' && (s[i + 4] == '0' || s[i + 4] == '2'))) {
if ((s[i] == '0' && s[i + 1] > '0') || (s[i] < '3' && s[i] > '0') ||
(s[i] == '3' && (s[i + 1] == '1' || s[i + 1] == '0'))) {
k = s[i];
k += s[i + 1];
k += s[i + 2];
k += s[i + 3];
k += s[i + 4];
k += s[i + 5];
k += s[i + 6];
k += s[i + 7];
k += s[i + 8];
k += s[i + 9];
m[k]++;
}
} else if ((s[i + 3] == '0' &&
(s[i + 4] == '4' || s[i + 4] == '6' || s[i + 4] == '9')) ||
(s[i + 3] == '1' && (s[i + 4] == '1'))) {
if ((s[i] == '0' && s[i + 1] > '0') || (s[i] < '3' && s[i] > '0') ||
(s[i] == '3' && (s[i + 1] == '0'))) {
k = s[i];
k += s[i + 1];
k += s[i + 2];
k += s[i + 3];
k += s[i + 4];
k += s[i + 5];
k += s[i + 6];
k += s[i + 7];
k += s[i + 8];
k += s[i + 9];
m[k]++;
}
} else if (s[i + 3] == '0' && s[i + 4] == '2') {
if ((s[i] == '0' && s[i + 1] > '0') || (s[i] < '2' && s[i] > '0') ||
(s[i] == '2' && (s[i + 1] >= '0' && s[i + 1] <= '8'))) {
k = s[i];
k += s[i + 1];
k += s[i + 2];
k += s[i + 3];
k += s[i + 4];
k += s[i + 5];
k += s[i + 6];
k += s[i + 7];
k += s[i + 8];
k += s[i + 9];
m[k]++;
}
}
}
}
}
map<string, int>::iterator it = m.begin();
int maxx = -1;
for (; it != m.end(); it++) {
if (maxx < it->second) {
maxx = it->second;
s = it->first;
}
}
cout << s;
}
| 8 |
CPP
|
from re import compile
from collections import defaultdict
from time import strptime
def validDate(date):
try:
strptime(date, "%d-%m-%Y")
return True
except:
return False
myFormat = compile(r'(?=([0-2]\d|3[0-1])-(0\d|1[0-2])-(201[3-5]))' )
Dict = defaultdict(int)
for d in myFormat.finditer(input()):
temp = "-".join([d.group(1),d.group(2),d.group(3)])
if validDate (temp):
Dict[temp] = -~Dict[temp]
print(max(Dict, key=Dict.get))
| 8 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
const int N = int(2e5 + 5);
const int INF = 1e9 + 7;
int d[13] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string s;
vector<int> prefix_function(string s) {
int n = (int)s.length();
vector<int> pi(n);
for (int i = 1; i < n; ++i) {
int j = pi[i - 1];
while (j > 0 && s[i] != s[j]) j = pi[j - 1];
if (s[i] == s[j]) ++j;
pi[i] = j;
}
return pi;
}
int calc(string x) {
string t = x + '#' + s;
vector<int> p = prefix_function(t);
int res = 0;
for (int i : p) {
if (i == x.size()) {
++res;
}
}
return res;
}
string get(int a, int b, int c) {
string res, res1, res2, res3;
if (c < 10) {
res += '0';
}
while (c) {
int x = c % 10;
res1 += char(x + '0');
c /= 10;
}
reverse(res1.begin(), res1.end());
res += res1;
res += '-';
if (b < 10) {
res += '0';
}
while (b) {
int x = b % 10;
res2 += char(x + '0');
b /= 10;
}
reverse(res2.begin(), res2.end());
res += res2;
res += '-';
while (a) {
int x = a % 10;
res3 += char(x + '0');
a /= 10;
}
reverse(res3.begin(), res3.end());
res += res3;
return res;
}
int main() {
cin >> s;
string ans;
int mx = 0;
for (int i = 2013; i <= 2015; ++i) {
for (int j = 1; j <= 12; ++j) {
for (int t = 1; t <= d[j - 1]; ++t) {
string cur = get(i, j, t);
if (calc(cur) > mx) {
mx = calc(cur);
ans = cur;
}
}
}
}
cout << ans;
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:66777216")
using namespace std;
typedef struct coor {
int x, y;
};
int nomalDay[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int leapDay[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int ARRSIZE = 100100;
const int STRSIZE = 100100;
const int GRIDSIZE = 510;
const int MAXINF = (2 << 20);
const int MININF = (~(2 << 20));
inline bool upcmp(int a, int b) { return a < b; }
inline bool downcmp(int a, int b) { return a > b; }
int hs[50][50][10];
int main() {
string s, res;
cin >> s;
int i, j, len = (int)s.size(), Max = MININF;
for (i = 0; i < len - 8; i++) {
string tp = "";
int cnt = 0;
for (j = 0; j < 10; j++) {
tp += s[i + j];
if (s[i + j] == '-') cnt++;
}
if (cnt > 2) continue;
int day = (tp[0] - '0') * 10 + tp[1] - '0';
int mon = (tp[3] - '0') * 10 + tp[4] - '0';
int year = (tp[6] - '0') * 1000 + (tp[7] - '0') * 100 + (tp[8] - '0') * 10 +
tp[9] - '0';
if (tp[2] != '-' || tp[5] != '-') continue;
if (year < 2013 || year > 2015) continue;
if (mon < 1 || mon > 12) continue;
if (day > nomalDay[mon] || day < 1) continue;
int h1 = hs[day][mon][year - 2013]++;
h1++;
if (h1 > Max) {
res = tp;
Max = h1;
}
}
cout << res << endl;
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int months[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
tuple<int, int, string> dates(0, 0, "fine");
map<tuple<int, int, string>, int> mp;
int day, month;
string year;
bool check_month(char a, char b) {
if (a == '-' || b == '-') return false;
month = (int)a - (int)'0';
int y = (int)b - (int)'0';
month *= 10;
month += y;
if (month >= 1 && month <= 12) return true;
return false;
}
bool is_day(char a, char b) {
if (a == '-' || b == '-') return false;
if (a == '0' && b == '0') return false;
day = (int)a - (int)'0';
day *= 10;
day += (int)b - (int)'0';
return (day <= months[month - 1]);
}
bool check_year(string nyear) {
year = nyear;
return (nyear == "2013" || nyear == "2014" || nyear == "2015");
}
void add_tomap() {
tuple<int, int, string> news(day, month, year);
mp[news]++;
if (mp[news] > mp[dates]) dates = news;
}
int main() {
string s;
cin >> s;
for (int i = 2; i < s.length() - 5; i++) {
if (s[i] == '-' && s[i + 3] == '-' && check_month(s[i + 1], s[i + 2]) &&
is_day(s[i - 2], s[i - 1]) && check_year(s.substr(i + 4, 4))) {
add_tomap();
}
}
(get<0>(dates) < 10) ? cout << 0 << get<0>(dates) : cout << get<0>(dates);
cout << "-";
(get<1>(dates) < 10) ? cout << 0 << get<1>(dates) : cout << get<1>(dates);
cout << "-";
cout << get<2>(dates);
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
bool prime[100000 + 1];
void sieve() {
memset(prime, true, sizeof(prime));
for (long p = 2; p * p <= 100000; p++) {
if (prime[p] == true) {
for (long i = p * p; i <= 100000; i += p) prime[i] = false;
}
}
}
long long gcd(long long a, long long b) {
if (a == 0) return b;
return gcd(b % a, a);
}
long power(int v, int a) {
long prod = 1;
for (int i = 0; i < a; i++) prod *= v;
return prod;
}
int countFreq(string &pat, string &txt) {
int M = pat.length();
int N = txt.length();
int res = 0;
for (int i = 0; i <= N - M; i++) {
int j;
for (j = 0; j < M; j++)
if (txt[i + j] != pat[j]) break;
if (j == M) {
res++;
j = 0;
}
}
return res;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int T = 1;
while (T--) {
string s;
vector<string> v;
int d[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
for (int i = 2013; i <= 2015; i++) {
for (int j = 1; j <= 12; j++) {
for (int k = 1; k <= d[j - 1]; k++) {
string temp = "";
if (k / 10 == 0) temp += "0";
temp += to_string(k) + "-";
if (j / 10 == 0) temp += "0";
temp += to_string(j) + "-";
temp += to_string(i);
v.push_back(temp);
}
}
}
cin >> s;
int ans = 0;
string final;
for (int i = 0; i < v.size(); i++) {
int t = countFreq(v[i], s);
if (ans < t) {
ans = t;
final = v[i];
}
}
cout << final;
}
cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
return 0;
}
| 8 |
CPP
|
s=input().rstrip()
ans=[]
p=dict()
p[1]=p[3]=p[5]=p[7]=p[8]=p[10]=p[12]=31
p[4]=p[6]=p[9]=p[11]=30
p[2]=28
for i in range(len(s)-3):
if s[i:i+4]=='2013' or s[i:i+4]=='2014' or s[i:i+4]=='2015':
#print('halua')
if s[i-1]=='-' and s[i-2]!='-' and s[i-3]!='-' and s[i-4]=='-' and s[i-5]!='-' and s[i-6]!='-':
#print('hand',int(s[i-3] + s[i-2]))
if int(s[i-3]+s[i-2])>=1 and int(s[i-3]+s[i-2])<=12:
#print('bhadu')
if int(s[i-6]+s[i-5])<=p[int(s[i-3]+s[i-2])] and int(s[i-6]+s[i-5])>=1:
ans.append(s[i-6:i+4])
#print(ans)
p=dict()
for i in ans:
if i in p:
p[i]+=1
else:
p[i]=1
mini=0
ans=''
for i in p:
if p[i]>mini:
mini=p[i]
ans=i
print(ans)
| 8 |
PYTHON3
|
#include <bits/stdc++.h>
using namespace std;
char s[100100];
int days[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int toInt(int i, int n) {
int res = 0;
for (int j = (0); j < ((n)); ++j) res = 10 * res + (s[i + j] - '0');
return res;
}
bool good(int i) {
if (s[i + 2] != '-' || s[i + 5] != '-') return false;
for (int j = (0); j < ((10)); ++j)
if (j != 2 && j != 5)
if (s[i + j] == '-') return false;
int d = toInt(i, 2), m = toInt(i + 3, 2), y = toInt(i + 6, 4);
if (y < 2013 || y > 2015) return false;
if (m < 1 || m > 12) return false;
if (d < 1 || d > days[m - 1]) return false;
return true;
}
int main() {
scanf("%s", s);
int n = strlen(s);
map<string, int> cnt;
for (int i = (0); i < ((n - 9)); ++i)
if (good(i)) {
string ss(s + i, s + i + 10);
++cnt[ss];
}
int mx = 0;
for (map<string, int>::const_iterator i = cnt.begin(); i != cnt.end(); ++i)
mx = max(mx, i->second);
for (map<string, int>::const_iterator i = cnt.begin(); i != cnt.end(); ++i)
if (i->second == mx) {
cout << i->first << endl;
return 0;
}
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
double pi = 3.141592653589793238;
const int M = 1e9 + 7;
const int Nmax = 5005;
const int MM = 1e7 + 1;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int T = 1;
while (T--) {
set<string> ss;
string s;
cin >> s;
int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
for (int i = 2013; i <= 2015; i++) {
for (int j = 1; j <= 12; j++) {
for (int k = 1; k <= day[j - 1]; k++) {
string date = "";
if (k < 10) date += '0';
date += to_string(k);
date += '-';
if (j < 10) date += '0';
date += to_string(j);
date += '-';
date += to_string(i);
ss.insert(date);
}
}
}
map<string, int> m;
for (int i = 0; i <= s.size() - 10; i++) {
string k = s.substr(i, 10);
if (ss.count(k)) m[k]++;
}
int mx = 0;
string ans;
for (auto x : m) {
if (x.second > mx) {
ans = x.first;
mx = x.second;
}
}
cout << ans;
}
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
vector<string> A;
for (int I = 0; I < s.length() - 9; I += 1) {
string sub = s.substr(I, 10);
bool ValidDM = false;
int Day = 0;
if (sub[0] == '0') {
Day = sub[1] - '0';
} else
Day = (sub[0] - '0') * 10 + (sub[1] - '0');
int Mon = 0;
if (sub[3] == '0') {
Mon = sub[4] - '0';
} else
Mon = (sub[3] - '0') * 10 + (sub[4] - '0');
if (sub[0] >= '0' && sub[0] <= '9' && sub[1] >= '0' && sub[1] <= '9' &&
sub[3] >= '0' && sub[3] <= '9' && sub[4] >= '0' && sub[4] <= '9') {
if (Mon == 1)
if (Day <= 31) ValidDM = true;
if (Mon == 2)
if (Day <= 28) ValidDM = true;
if (Mon == 3)
if (Day <= 31) ValidDM = true;
if (Mon == 4)
if (Day <= 30) ValidDM = true;
if (Mon == 5)
if (Day <= 31) ValidDM = true;
if (Mon == 6)
if (Day <= 30) ValidDM = true;
if (Mon == 7)
if (Day <= 31) ValidDM = true;
if (Mon == 8)
if (Day <= 31) ValidDM = true;
if (Mon == 9)
if (Day <= 30) ValidDM = true;
if (Mon == 10)
if (Day <= 31) ValidDM = true;
if (Mon == 11)
if (Day <= 30) ValidDM = true;
if (Mon == 12)
if (Day <= 31) ValidDM = true;
} else
continue;
if (Day == 0) continue;
bool ValidY = false;
if (sub[6] == '2' && sub[7] == '0' && sub[8] == '1' &&
(sub[9] == '3' || sub[9] == '4' || sub[9] == '5'))
ValidY = true;
bool ValidOther = false;
if (sub[2] == '-' && sub[5] == '-') ValidOther = true;
if (ValidOther && ValidY && ValidDM) {
A.push_back(sub);
continue;
}
}
int maxT = 0;
int res;
for (int I = 0; I < A.size(); I += 1) {
int occ = 0;
for (int T = 0; T < A.size(); T += 1) {
if (A[I] == A[T]) occ += 1;
}
if (occ > maxT) {
maxT = occ;
res = I;
}
}
cout << A[res];
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
const int SIZE = 1e6;
int str2int(string str) {
stringstream ss(str);
int val;
ss >> val;
return (val);
}
string int2str(int num) {
stringstream ss;
string ans;
ss << num;
ans = ss.str();
return ans;
}
const bool testing = 0;
const int day[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
void program() {
string str;
cin >> str;
map<string, int> ans;
for (int i = 0; i < str.length() - 9; i++) {
string temp = str.substr(i, 10);
bool bad = 0;
for (int j = 0; j < 10; j++)
if (j != 2 && j != 5)
if (!isdigit(temp[j])) {
bad = 1;
break;
}
if (bad) continue;
int d = str2int(temp.substr(0, 2)), m = str2int(temp.substr(3, 2)),
y = str2int(temp.substr(6, 4));
char ch1 = temp[2], ch2 = temp[5];
if (ch1 == '-' && ch2 == '-') {
if (y > 2012 && y < 2016)
if (m >= 1 && m <= 12)
if (d >= 1 && d <= day[m])
if (ans.find(temp) != ans.end())
ans[temp]++;
else
ans[temp] = 1;
}
}
int max = 0;
auto mymax = ans.begin();
for (auto it = ans.begin(); it != ans.end(); it++) {
if (it->second > max) max = it->second, mymax = it;
}
cout << mymax->first;
}
int main() {
if (!testing) {
program();
return 0;
}
FILE* fin = NULL;
fin = fopen("in.txt", "w+");
fprintf(fin, "15-1--201315-1--201301-01-2013\n");
fclose(fin);
freopen("in.txt", "r", stdin);
printf("test case(1) => expected : \n");
printf("13-12-2013");
printf("test case(1) => founded : \n");
program();
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
char str[123456];
char it[123];
char day[13][5] = {"31", "28", "31", "30", "31", "30",
"31", "31", "30", "31", "30", "31"};
map<string, int> m;
map<string, int>::iterator ut;
int main() {
scanf("%s", str);
int len = strlen(str);
m.clear();
for (int i = 0; i < len - 3; i++) {
if (str[i] == '-' && str[i + 3] == '-' && str[i + 4] == '2' &&
str[i + 5] == '0' && str[i + 6] == '1') {
int flag = 0;
for (int j = 0; j < 10; j++) {
it[j] = str[i + j - 2];
}
it[10] = '\0';
if (it[9] < '3' || it[9] > '5') flag = 1;
if (it[3] < '0' || it[3] > '9' || it[3] > '1') flag = 1;
if (it[3] == '0') {
if (it[4] < '0' || it[4] > '9' || it[4] == '0') flag = 1;
}
if (it[3] == '1') {
if (it[4] < '0' || it[4] > '9' || it[4] > '2') flag = 1;
}
if (it[0] < '0' || it[0] > '9') flag = 1;
if (it[0] == '0') {
if (it[1] <= '0' || it[1] > '9') flag = 1;
} else {
if (it[1] < '0' || it[1] > '9') flag = 1;
}
int u = (it[3] - '0') * 10 + (it[4] - '0');
char t[3];
t[0] = it[0], t[1] = it[1];
t[2] = '\0';
if (strcmp(t, day[u - 1]) > 0) flag = 1;
if (!flag) {
string t = "";
for (int j = 0; j < 10; j++) t += it[j];
m[t]++;
}
}
}
string ans;
int u = -1;
for (ut = m.begin(); ut != m.end(); ut++) {
if (ut->second > u) {
u = ut->second;
ans = ut->first;
}
}
cout << ans << endl;
return 0;
}
| 8 |
CPP
|
#include <bits/stdc++.h>
using namespace std;
const double eps(1e-8);
const double pi(3.14159265358979);
const int N = 100100;
const int month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
char ch[N] = {};
int main() {
gets(ch + 1);
int l = strlen(ch + 1);
map<int, int> bucket;
for (int i = 3; i <= l - 7; ++i)
if (ch[i] == '-' && ch[i + 3] == '-') {
bool flag = isdigit(ch[i - 2]);
flag &= isdigit(ch[i - 1]);
flag &= isdigit(ch[i + 1]);
flag &= isdigit(ch[i + 2]);
flag &= isdigit(ch[i + 4]);
flag &= isdigit(ch[i + 5]);
flag &= isdigit(ch[i + 6]);
flag &= isdigit(ch[i + 7]);
if (!flag) continue;
int d = (ch[i - 2] - '0') * 10 + ch[i - 1] - '0';
int m = (ch[i + 1] - '0') * 10 + ch[i + 2] - '0';
int y = (((ch[i + 4] - '0') * 10 + (ch[i + 5] - '0')) * 10 + ch[i + 6] -
'0') *
10 +
ch[i + 7] - '0';
if (2013 <= y && y <= 2015 && 1 <= m && m <= 12 && 1 <= d &&
d <= month[m])
++bucket[d * 1000000 + m * 10000 + y];
}
int d1 = 0, m1 = 0, y1 = 0, t = 0;
for (auto p : bucket)
if (p.second > t)
d1 = p.first / 1000000, m1 = p.first % 1000000 / 10000,
y1 = p.first % 10000, t = p.second;
printf("%02d-%02d-%d\n", d1, m1, y1);
return 0;
}
| 8 |
CPP
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.