solution
stringlengths
11
983k
difficulty
int64
0
21
language
stringclasses
2 values
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << std::endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...); } #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") long long int Months[13] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; map<string, long long int> checking; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); string s; cin >> s; bool ffllg = 0; for (long long int i = 0; i <= s.length() - 10; i++) { long long int cnt = 1; bool datecheck = 1, check = 1, monthchck = 1, yearcheck = 1; string ss = ""; long long int end = i + 10; for (long long int j = i; j < end; j++) { if (cnt <= 2) { if (s[j] == '-') { datecheck = 0; continue; } long long int digit = s[j] - '0'; if (cnt == 1 && ((digit > 3))) { datecheck = 0; } } if (cnt == 3) { if (s[j] != '-') check = 0; } if (cnt > 3 && cnt < 6) { if (s[j] == '-') { monthchck = 0; continue; } long long int digit = s[j] - '0'; if (cnt == 4) { if (digit > 1) monthchck = 0; } } if (cnt == 6) { if (s[j] != '-') check = 0; } if (cnt == 7) { if (s[j] == '-') { yearcheck = 0; continue; } if (s[j] != '2') yearcheck = 0; } if (cnt == 8) { if (s[j] == '-') { yearcheck = 0; continue; } if (s[j] != '0') yearcheck = 0; } if (cnt == 9) { if (s[j] == '-') { yearcheck = 0; continue; } if (s[j] != '1') yearcheck = 0; } if (cnt == 10) { if (s[j] == '-') { yearcheck = 0; continue; } long long int digit = s[j] - '0'; if (digit < 3 || digit > 5) yearcheck = 0; } cnt++; ss += s[j]; } if (ss[0] == '0' && ss[1] == '0') datecheck = 0; if (ss[3] == '0' && ss[4] == '0') monthchck = 0; if (yearcheck && monthchck && datecheck && check) { long long int date = (ss[0] - '0') * 10 + (ss[1] - '0'); long long int month = (ss[3] - '0') * 10 + (ss[4] - '0'); if (Months[month] >= date) { checking[ss]++; ffllg = 1; } } } long long int maxi = INT_MIN; string ssss = ""; for (auto it = checking.begin(); it != checking.end(); it++) { if (it->second > maxi) { maxi = it->second; ssss = it->first; } } cout << ssss << '\n'; return 0; }
8
CPP
#include <bits/stdc++.h> using namespace std; bool isd(char first) { return '0' <= first && first <= '9'; } int main(int argc, char **argv) { string s; cin >> s; int N = s.length(); bool f = 0; int dd, mm, yy; int dom[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; map<string, int> freq; for (int i = (0); i < (N - 9); ++i) { string t = s.substr(i, 10); int m, d, second; string sm, sd, sy; sd = t.substr(0, 2); sm = t.substr(3, 2); sy = t.substr(6, 4); bool ok = 1; for (int j = (0); j < (sd.size()) && (ok); ++j) ok = isd(sd[j]); for (int j = (0); j < (sm.size()) && (ok); ++j) ok = isd(sm[j]); for (int j = (0); j < (sy.size()) && (ok); ++j) ok = isd(sy[j]); ok &= t[2] == '-' && t[5] == '-'; if (!ok) continue; sscanf(sd.c_str(), "%d", &d); sscanf(sm.c_str(), "%d", &m); sscanf(sy.c_str(), "%d", &second); if (2012 < second && second < 2016 && 0 < m < 13) { if (0 < d && d <= dom[m]) { freq[t]++; } } } int res = -1; string sres; for (typeof(freq.begin()) t = freq.begin(); t != freq.end(); t++) if (res < t->second) { res = t->second; sres = t->first; } else if (res == t->second) { int yy, mm, dd; int second, m, d; sscanf(t->first.c_str(), "%d-%d-%d", &d, &m, &second); sscanf(sres.c_str(), "%d-%d-%d", &dd, &mm, &yy); bool rpl = 0; if (second > yy) rpl = 1; else if (second == yy && m > mm) rpl = 1; else if (second == yy && m == mm) rpl = d > dd; if (rpl) sres = t->first; } cout << sres; return 0; }
8
CPP
#include <bits/stdc++.h> const int S[] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; int DtCvt(char *z, bool *F) { static const bool H[10] = {0, 0, 1, 0, 0, 1}; if (10 + H != std::mismatch(H, 10 + H, F).first) return -1; static const int M[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int y, m, d; sscanf(z, "%d", &d), sscanf(3 + z, "%d", &m), sscanf(6 + z, "%4d", &y); return 0 > (y -= 2013) || 2 < y || !m || 11 < --m || !d || M[m] < d-- ? -1 : d + S[m] + 365 * y; } void Output(int s) { int y = 2013 + s / 365, m = std::upper_bound(1 + S, 12 + S, s %= 365) - S, d = 1 + s - S[m - 1]; printf("%02i-%02i-%i\n", d, m, y); } int main(void) { bool F[100000]; char z[100001]; for (long n, m, S[1095]; gets(z); Output(std::max_element(S, 1095 + S) - S)) { for (n = -1; z[++n]; F[n] = '-' == z[n]) ; for (memset(S, 0, sizeof(S)), n -= 9; n--;) if (~(m = DtCvt(n + z, n + F))) ++S[m]; } return 0; }
8
CPP
#include <bits/stdc++.h> using namespace std; char s[200010]; char s1[20]; int ha[40][40][10]; int maxx[3], max1; int main() { memset(ha, 0, sizeof(ha)); cin >> s; for (int i = 0; i < strlen(s) - 9; ++i) { int p, q, r; if (s[i + 5] != '-' || s[i + 2] != '-') continue; if (!(isdigit(s[i + 0]) && isdigit(s[i + 1]))) continue; else p = 10 * (s[i + 0] - 48) + s[i + 1] - 48; if (!(isdigit(s[i + 3]) && isdigit(s[i + 4]))) continue; else q = 10 * (s[i + 3] - 48) + s[i + 4] - 48; if (!(isdigit(s[i + 6]) && isdigit(s[i + 7]) && isdigit(s[i + 8]) && isdigit(s[i + 9]))) continue; else r = 1000 * (s[i + 6] - 48) + 100 * (s[i + 7] - 48) + 10 * (s[i + 8] - 48) + s[i + 9] - 48; if (2013 <= r && r <= 2015 && 1 <= q && q <= 12 && 1 <= p && p <= 31) { if (p > 31) continue; if (p > 28 && q == 2) continue; else if (p == 31 && (q == 4 || q == 6 || q == 9 || q == 11)) continue; ha[p][q][r - 2013]++; if (ha[p][q][r - 2013] > max1) { max1 = ha[p][q][r - 2013]; maxx[0] = p; maxx[1] = q; maxx[2] = r; } } } printf("%02d-%02d-%d\n", maxx[0], maxx[1], maxx[2]); }
8
CPP
from math import * #from bisect import * #from collections import * #from random import * #from decimal import *""" #from heapq import * #from random import * import sys input=sys.stdin.readline #sys.setrecursionlimit(3*(10**5)) global flag def inp(): return int(input()) def st(): return input().rstrip('\n') def lis(): return list(map(int,input().split())) def ma(): return map(int,input().split()) t=1 while(t): t-=1 s=st() dd={} for i in range(len(s)-9): x=s[i:i+10] da=x[:2] mo=x[3:5] fl=0 ye=x[6:10] if(x[2]!='-' or x[5]!='-'): continue try: if(ye in ['2013','2014','2015']): fl+=1 if(int(mo)>=1 and int(mo)<=12): fl+=1 cc=int(mo) if(cc in [1,3,5,7,8,10,12]): if(int(da)>=1 and int(da)<=31): fl+=1 elif(cc in [4,6,9,11]): if(int(da)>=1 and int(da)<=30): fl+=1 elif( cc==2): if(int(da)>=1 and int(da)<=28): fl+=1 if(fl==3): try: dd[x]+=1 except: dd[x]=1 pass except: pass z=max(dd.values()) for i in dd.keys(): if(dd[i]==z): print(i) break
8
PYTHON3
#include <bits/stdc++.h> using namespace std; bool validate(string temp) { if (temp[0] == '-' || temp[1] == '-' || temp[2] != '-' || temp[3] == '-' || temp[4] == '-' || temp[5] != '-') return false; string d = "", m = ""; d += temp[0]; d += temp[1]; m += temp[3]; m += temp[4]; int mm = atoi(m.c_str()); int dd = atoi(d.c_str()); if (mm > 12 || mm < 1) return false; switch (mm) { case 1: if (!(dd <= 31 && dd >= 1)) return false; break; case 2: if (!(dd <= 28 && dd >= 1)) return false; break; case 3: if (!(dd <= 31 && dd >= 1)) return false; break; case 4: if (!(dd <= 30 && dd >= 1)) return false; break; case 5: if (!(dd <= 31 && dd >= 1)) return false; break; case 6: if (!(dd <= 30 && dd >= 1)) return false; break; case 7: if (!(dd <= 31 && dd >= 1)) return false; break; case 8: if (!(dd <= 31 && dd >= 1)) return false; break; case 9: if (!(dd <= 30 && dd >= 1)) return false; break; case 10: if (!(dd <= 31 && dd >= 1)) return false; break; case 11: if (!(dd <= 30 && dd >= 1)) return false; break; case 12: if (!(dd <= 31 && dd >= 1)) return false; break; } return true; } int main() { string in; cin >> in; string x = "2013", y = "2014", z = "2015"; map<string, int> X; for (int i = 0; i < in.size(); i++) { string temp = in.substr(i, 4); if (strcmp(temp.c_str(), x.c_str()) == 0) { temp = in.substr(i - 6, 10); if (validate(temp)) { if (X.find(temp) == X.end()) { X[temp] = 1; } else X[temp]++; } } if (strcmp(temp.c_str(), y.c_str()) == 0) { temp = in.substr(i - 6, 10); if (validate(temp)) { if (X.find(temp) == X.end()) { X[temp] = 1; } else X[temp]++; } } if (strcmp(temp.c_str(), z.c_str()) == 0) { temp = in.substr(i - 6, 10); if (validate(temp)) { if (X.find(temp) == X.end()) { X[temp] = 1; } else X[temp]++; } } } map<string, int>::iterator it, ret; int max = 0; for (it = X.begin(); it != X.end(); it++) { if ((*it).second > max) { max = (*it).second; ret = it; } } cout << (*ret).first << endl; return 0; }
8
CPP
#include <bits/stdc++.h> using namespace std; const long long int mod = 1000000000 + 7; const long long int N = 10000000 + 6; int cal[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; bool check(int d, int m) { if (m <= 12 && m > 0) { if (d >= 1 && d <= cal[m]) return true; } return false; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); string st; cin >> st; int n = st.size(); unordered_map<string, int> hmap; for (int i = 0, j = 9; j < n; i++, j++) { string sub = st.substr(i, 10); if (sub[2] == '-' && sub[5] == '-') { if (sub[6] == '2' && sub[7] == '0' && sub[8] == '1' && (sub[9] - '3' >= 0 && sub[9] - '3' <= 2)) { if (isdigit(sub[0]) && isdigit(sub[1]) && isdigit(sub[3]) && isdigit(sub[4])) { string mo = ""; string da = ""; mo = mo + sub[3] + sub[4]; da = da + sub[0] + sub[1]; int month = stoi(mo); int day = stoi(da); bool b = check(day, month); if (b == true) hmap[sub]++; } } } } string ans; int ma = -1; for (auto it = hmap.begin(); it != hmap.end(); it++) { if (it->second > ma) { ans = it->first; ma = it->second; } } cout << ans; return 0; }
8
CPP
#include <bits/stdc++.h> using namespace std; const double pi = 4.0 * atan(1.0); const int inf = 99999999; const signed long long INF = 0x3f3f3f3f3f3f3f3fLL; const int maxn = 111111; map<int, int> name; int ansa, ansb, ansc; char s[maxn]; bool isok(int a, int b, int c) { if (c < 2013 || c > 2015) return false; if (a < 1 || a > 31) return false; if (b < 1 || b > 12) return false; if (b == 2) { if (a >= 29) return false; return true; } if (b == 4 || b == 6 || b == 9 || b == 11) { if (a > 30) return false; return true; } return true; } void cop(int a, int b, int c) { ++name[c + b * 10000 + a * 1000000]; } void check(char *s) { int a, b, c; int i; for (i = 0; s[i]; ++i) { if (s[i] == '-') break; } if (s[i] == NULL) return; if (isdigit(s[i - 2]) && isdigit(s[i - 1])) a = (s[i - 2] - '0') * 10 + s[i - 1] - '0'; else return; if (isdigit(s[i + 1]) && isdigit(s[i + 2]) && s[i + 3] == '-') b = (s[i + 1] - '0') * 10 + s[i + 2] - '0'; else return; i = i + 4; if (isdigit(s[i]) && isdigit(s[i + 1]) && isdigit(s[i + 2]) && isdigit(s[i + 3])) c = (s[i] - '0') * 1000 + (s[i + 1] - '0') * 100 + (s[i + 2] - '0') * 10 + s[i + 3] - '0'; else return; if (isok(a, b, c)) cop(a, b, c); } void doit() { int k = -1; check(s); int len = strlen(s); for (int i = 2; i < len; ++i) if (s[i] == '-') { check(s + i); } map<int, int>::iterator it; for (it = name.begin(); it != name.end(); ++it) { if (it->second > k) { k = it->second; int z = it->first; ansc = z % 10000; z /= 10000; ansb = z % 100; z /= 100; ansa = z; } } printf("%02d-%02d-%d\n", ansa, ansb, ansc); } int main() { scanf("%s", s); doit(); return 0; }
8
CPP
#include <bits/stdc++.h> using namespace std; int main() { int months[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; string input; map<string, int> cont; int maxmentioned = 0; string ans; cin >> input; int len = input.size(); for (int i = 2; i < len; ++i) { if (i + 7 < len && input[i] == '-' && input[i + 3] == '-') { if (input[i - 1] == '-' || input[i - 2] == '-' || input[i + 1] == '-' || input[i + 2] == '-' || input[i + 4] == '-' || input[i + 5] == '-' || input[i + 6] == '-' || input[i + 7] == '-') continue; int day = (input[i - 2] - '0') * 10 + (input[i - 1] - '0'); int month = (input[i + 1] - '0') * 10 + (input[i + 2] - '0'); int year = (input[i + 4] - '0') * 1000 + (input[i + 5] - '0') * 100 + (input[i + 6] - '0') * 10 + (input[i + 7] - '0'); if (year < 2013 || year > 2015) continue; if (month < 1 || month > 12) continue; if (day < 1 || day > months[month]) continue; char strdate[15]; sprintf(strdate, "%02d-%02d-%d", day, month, year); ++cont[string(strdate)]; if (cont[string(strdate)] > maxmentioned) { maxmentioned = cont[string(strdate)]; ans = string(strdate); } } } cout << ans; return 0; }
8
CPP
#include <bits/stdc++.h> using namespace std; int d[14] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; string s; bool ifis(int it) { if (s[it + 2] != '-' || s[it + 5] != '-') { return 0; } if (s[it] > '9' || s[it] < '0' || s[it + 1] > '9' || s[it + 1] < '0' || s[it + 3] > '9' || s[it + 3] < '0' || s[it + 4] > '9' || s[it + 4] < '0' || s[it + 6] > '9' || s[it + 6] < '0' || s[it + 7] > '9' || s[it + 7] < '0' || s[it + 8] > '9' || s[it + 8] < '0' || s[it + 9] > '9' || s[it + 9] < '0') { return 0; } if (s[it + 6] != '2' || s[it + 7] != '0' || s[it + 8] != '1' || s[it + 9] < '3' || s[it + 9] > '5') { return 0; } int m = (s[it + 3] - '0') * 10 + s[it + 4] - '0'; if (m > 12 || m < 1) { return 0; } int da = (s[it] - '0') * 10 + s[it + 1] - '0'; if (da > d[m] || da == 0) { return 0; } return 1; } map<string, int> tj; int main() { cin >> s; string n; n = " "; tj[n] = -1; for (int i = 0; i <= s.size() - 9; i++) { if (ifis(i) == 1) { string t = s.substr(i, 10); tj[t]++; n = (tj[t] > tj[n] ? t : n); } } cout << n << endl; return 0; }
8
CPP
s = input() months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] n = len(s) d = {} max_k = 0 max_t = '' for i in range(n - 9): if s[i + 2] == '-' and s[i + 5] == '-': if s[i + 3: i + 5].isdigit() and 1 <= int(s[i + 3: i + 5]) <= 12: m = int(s[i + 3: i + 5]) if s[i: i + 2].isdigit() and 1 <= int(s[i: i + 2]) <= months[m - 1]: if s[i + 6: i + 10].isdigit() and 2013 <= int(s[i + 6: i + 10]) <= 2015: t = s[i: i + 10] if d.get(t): d[t] += 1 else: d[t] = 1 if d[t] >= max_k: max_k = d[t] max_t = t print(max_t)
8
PYTHON3
#include <bits/stdc++.h> using namespace std; double pi = 3.1415926536; const int oo = (int)1e9; const long long OO = numeric_limits<long long>::max(); int dx[] = {0, 1, 0, -1}; int dy[] = {1, 0, -1, 0}; int di[] = {0, 0, 1, -1, 1, -1, 1, -1}; int dj[] = {1, -1, 0, 0, 1, -1, -1, 1}; int f1[] = {0, 0, 0, 1, 1, 1, -1, -1, -1}; int f2[] = {-1, 0, 1, -1, 0, 1, -1, 0, 1}; int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; string toString(int x) { stringstream ss; string s; ss << x; ss >> s; return s; } int main() { ios_base::sync_with_stdio(false); map<string, int> mymap; vector<string> myDates; for (int i = 2013; i <= 2015; i++) { for (int j = 1; j <= 12; j++) { for (int k = 1; k <= days[j]; k++) { stringstream ss; string year, month, day; day = toString(k); if (((int)(day).size()) == 1) day = "0" + day; month = toString(j); if (((int)(month).size()) == 1) month = "0" + month; year = toString(i); string date = day + month + year; myDates.push_back(date); } } } string s; cin >> s; for (int i = 0; i < ((int)(s).size()); i++) { string str = s.substr(i, 10); int cnt = 0; string date; for (int j = 0; j < ((int)(str).size()); j++) { if (str[j] == '-') cnt++; else date += str[j]; } if (cnt == 2) { mymap[date]++; } } int idx = -1, mx = -1; for (int i = 0; i < ((int)(myDates).size()); i++) { int take = mymap[myDates[i]]; if (take >= mx) { idx = i; mx = take; } } string ans = myDates[idx]; for (int i = 0; i < ((int)(ans).size()); i++) { cout << ans[i]; if (i == 1) { cout << "-"; } if (i == 3) { cout << "-"; } } }
8
CPP
from re import findall from calendar import monthrange from collections import defaultdict s=input() dic=defaultdict(int) for i in findall('(?=(\d\d-\d\d-201[3-5]))',s): d,m,y = map(int,i.split("-")) if 1<=m<=12 and 1<=d<=monthrange(y,m)[1]: dic[i]+=1 print(max(dic,key=dic.get))
8
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { string s; cin >> s; int f[40][20][10]; int dom[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; memset(f, 0, sizeof(f)); int maxi = 0, ansd, ansm, ansy; for (int i = 0; i < s.length(); ++i) { if (s[i + 2] != '-' || s[i + 5] != '-') continue; bool strip = true; for (int j = 0; j < 9; ++j) { if (j != 2 && j != 5 && s[i + j] == '-') strip = false; } if (!strip) continue; if (s[i + 6] != '2' || s[i + 7] != '0' || s[i + 8] != '1') continue; int d = (s[i] - '0') * 10 + s[i + 1] - '0'; int m = (s[i + 3] - '0') * 10 + s[i + 4] - '0'; int y = s[i + 9] - '0'; if (y < 3 || y > 5) continue; if (m < 1 || m > 12) continue; if (d < 1 || d > dom[m - 1]) continue; ++f[d][m][y]; if (maxi < f[d][m][y]) { maxi = f[d][m][y]; ansd = d; ansm = m; ansy = y; } } cout << ansd / 10 << ansd % 10 << '-' << ansm / 10 << ansm % 10 << '-' << "201" << ansy << endl; return 0; }
8
CPP
#include <bits/stdc++.h> using namespace std; bool is_valid(string s) { int part = 0; string ans = ""; bool ok = true; int day = 0; int month = 0; int year = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == '-') { part++; int num = stoi(ans); ans = ""; if (part == 1) day = num; else if (part == 2) month = num; } else ans += s[i]; } year = stoi(ans); if (year > 2015 || year < 2013) return false; if (month == 0 || month > 12) return false; int arr[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; month--; if (day == 0 || day > arr[month]) return false; return true; } int main() { map<string, int> m; string s; cin >> s; string temp = "dd-mm-yyyy"; int n = s.size(); for (int i = 0; i < n; i++) { int length = n - i; if (length < 10) break; int ptr = i; bool ok = true; for (int j = 0; j < temp.size(); j++, ptr++) { if (temp[j] == 'd' || temp[j] == 'm' || temp[j] == 'y') { if (s[ptr] >= '0' && s[ptr] <= '9') continue; else { ok = false; break; } } else { if (s[ptr] != '-') { ok = false; break; } } } if (ok) { m[s.substr(i, 10)]++; } } int max_num = 0; string ans = ""; for (auto it = m.begin(); it != m.end(); it++) { if (it->second == 0) continue; if (is_valid(it->first)) { if (it->second > max_num) { max_num = it->second; ans = it->first; } } } cout << ans; }
8
CPP
from re import findall from calendar import monthrange from collections import defaultdict S = input() bag = defaultdict(int) for s in findall('(?=(\d\d-\d\d-201[3-5]))', S): # (?=...) implies that overlap is allowed d, m, y = map(int, s.split('-')) if 1 <= m <= 12 and 1 <= d <= monthrange(y, m)[1]: bag[s] += 1 print(max(bag, key = bag.get)) # Made By Mostafa_Khaled
8
PYTHON3
from collections import defaultdict t = input() s = defaultdict(int) for i in range(len(t) - 9): if t[i + 2] == '-' and t[i + 5: i + 9] == '-201' and '2' < t[i + 9] < '6' and '32' > t[i: i + 2] > '00' and '13' > t[i + 3: i + 5] > '00': if t[i + 3: i + 5].isdigit(): if t[i: i + 2].isdigit(): if t[i: i + 2] < '29': s[t[i: i + 10]] += 1 elif t[i: i + 2] < '31': if not (t[i + 3: i + 5] == '02'): s[t[i: i + 10]] += 1 elif not (t[i + 3: i + 5] in ['04', '06', '09', '11']): s[t[i: i + 10]] += 1 m = max(s.values()) for i in s: if s[i] == m: print(i) break
8
PYTHON3
#include <bits/stdc++.h> using namespace std; map<string, int> cnt; string str; int ar[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int main() { cin >> str; for (int i = 0; i < str.size() - 9; i++) { string s = str.substr(i, 10); if (s[0] == '-' || s[1] == '-' || s[2] != '-' || s[3] == '-' || s[4] == '-' || s[5] != '-' || s[6] == '-' || s[7] == '-' || s[8] == '-' || s[9] == '-') continue; int d, m, y; char c; istringstream(s) >> d >> c >> m >> c >> y; if (m < 1 || m > 12) continue; if (d < 1 || d > ar[m - 1]) continue; if (y < 2013 || y > 2015) continue; cnt[s]++; } string x; int mx = 0; for (map<string, int>::iterator it = cnt.begin(); it != cnt.end(); it++) { if (mx < it->second) { mx = it->second; x = it->first; } } cout << x << endl; return 0; }
8
CPP
#include <bits/stdc++.h> using namespace std; int months[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; string s; int main() { while (getline(cin, s)) { int n = (int)s.size(); vector<string> ans; for (int i = 0; i <= n - 10; 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])) { int day = (s[i] - '0') * 10 + s[i + 1] - '0'; int month = (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 && month >= 1 && month <= 12 && day >= 1 && day <= months[month]) ans.push_back(s.substr(i, 10)); } } sort((ans).begin(), (ans).end()); string best = ""; int cnt = 0; int i = 0; while (i < (int)ans.size()) { int c = 1; while (i < (int)ans.size() - 1 && ans[i] == ans[i + 1]) ++i, ++c; if (cnt < c) best = ans[i], cnt = c; ++i; } printf("%s\n", best.c_str()); } return 0; }
8
CPP
#include <bits/stdc++.h> using namespace std; string s; int a[2000] = {}; string r[2000]; const int mon[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; void tr(int p) { int res = true; for (int i = 0; res && i < 10; i++) res = (((i == 2 || i == 5) && s[p + i] == '-') || (i != 2 && i != 5 && s[p + i] != '-')); if (!res) return; int d = (s[p] - '0') * 10 + s[p + 1] - '0', m = (s[p + 3] - '0') * 10 + s[p + 4] - '0', y = (((s[p + 6] - '0') * 10 + s[p + 7] - '0') * 10 + s[p + 8] - '0') * 10 + s[p + 9] - '0'; if (y >= 2013 && y <= 2015 && m >= 1 && m <= 12 && d >= 1 && d <= mon[m - 1]) { d += ((y - 2013) * 12 + m - 1) * 31; a[d]++; r[d] = ""; for (int i = 0; i < 10; i++) r[d] += s[i + p]; } } int main() { cin >> s; for (int i = 0; i <= s.size() - 10; i++) tr(i); int ans = 0; for (int i = 0; i < 1500; i++) if (a[i] > a[ans]) ans = i; cout << r[ans]; }
8
CPP
#include <bits/stdc++.h> using namespace std; string s; string tmp; string ans; int mx; map<string, int> m; const int MD[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; const bool flg[] = {0, 0, 1, 0, 0, 1, 0, 0, 0, 0}; bool check(int l, int r) { int g = 0, d = 0, m = 0, y = 0; for (int i = l; i <= r; i++) { if (s[i] == '-' && flg[i - l]) g++; else if (s[i] == '-' && !flg[i - l]) return false; } if (g != 2) { return false; } for (int i = l + 6; i <= l + 9; i++) { y = y * 10 + s[i] - '0'; } if (y > 2015 || y < 2013) { return false; } for (int i = l + 3; i <= l + 4; i++) { m = m * 10 + s[i] - '0'; } if (m <= 0 || m > 12) { return false; } for (int i = l; i <= l + 1; i++) { d = d * 10 + s[i] - '0'; } if (d <= 0 || d > MD[m]) { return false; } return true; } int main() { cin >> s; int l = 0, r = 9; int sz = s.size(); while (r <= sz) { tmp = ""; tmp = s.substr(l, 10); if (check(l, r)) { m[tmp]++; if (m[tmp] > mx) { mx = m[tmp]; ans = ""; ans = tmp; } } l++; r++; } cout << ans; return 0; }
8
CPP
#include <bits/stdc++.h> using namespace std; int a[200000]; int day[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; vector<string> b; int main() { string s, d; int i, j; cin >> s; int ma, k, da, m, y; for (i = 0; i < s.length(); i++) { if (s[i] == '-') a[i]++; if (i > 0) a[i] += a[i - 1]; } for (i = 0; i < s.length() - 9; i++) if (s[i + 2] == '-' && s[i + 5] == '-' && a[i + 9] - a[i - 1] == 2) { da = (s[i] - 48) * 10 + s[i + 1] - 48; m = (s[i + 3] - 48) * 10 + s[i + 4] - 48; y = (s[i + 6] - 48) * 1000 + (s[i + 7] - 48) * 100 + (s[i + 8] - 48) * 10 + (s[i + 9] - 48); if (1 <= m && m <= 12 && 1 <= da && da <= day[m] && 2013 <= y && y <= 2015) { for (d = "", j = 0; j <= 9; j++) d += s[i + j]; b.push_back(d); } } sort(b.begin(), b.end()); ma = 0, d = "", k = 0; for (i = 0; i < b.size(); i++) { if (i == 0 || b[i] == b[i - 1]) k++; else k = 1; if (k > ma) ma = k, d = b[i]; } cout << d; return 0; }
8
CPP
#include <bits/stdc++.h> using namespace std; char data[13], s[100006], sol[13]; int vmax, an, l, zi, val, maxi; int main() { cin >> s; maxi = 0; for (an = 2013; an <= 2015; an++) { for (l = 1; l <= 12; l++) { int vmax; if (l == 1 || l == 3 || l == 5 || l == 7 || l == 8 || l == 10 || l == 12) vmax = 31; else { if (l == 2) vmax = 28; else vmax = 30; } for (zi = 1; zi <= vmax; zi++) { if (zi < 10) { data[0] = '0'; data[1] = char('0' + zi); } else { data[0] = char(zi / 10 + '0'); data[1] = char(zi % 10 + '0'); } data[2] = '-'; if (l < 10) { data[3] = '0'; data[4] = char(l + '0'); } else { data[3] = char(l / 10 + '0'); data[4] = char(l % 10 + '0'); } data[5] = '-'; data[6] = char(an / 1000 + '0'); data[7] = char(an / 100 % 10 + '0'); data[8] = char(an / 10 % 10 + '0'); data[9] = char(an % 10 + '0'); val = 0; for (unsigned int i = 0; i < strlen(s) - 9; i++) { if (strncmp(s + i, data, 10) == 0) { val++; if (val > maxi) { maxi = val; strcpy(sol, data); } } } } } } cout << sol; return 0; }
8
CPP
a=input() n=len(a) z=[31,28,31,30,31,30,31,31,30,31,30,31] e=[[[0 for k in range(z[j])] for j in range(12)] for i in range(3)] for i in range(n-9): if a[i+2]==a[i+5]=='-' and str(a[i]+a[i+1]).isdigit() and str(a[i+3]+a[i+4]).isdigit() and str(a[i+6]+a[i+7]+a[i+8]+a[i+9]).isdigit(): b,c,d=int(a[i]+a[i+1]),int(a[i+3]+a[i+4]),int(a[i+6]+a[i+7]+a[i+8]+a[i+9]) if 2013<=d<=2015 and 1<=c<=12 and 1<=b<=z[c-1]: e[d-2013][c-1][b-1]+=1 i=j=k=0 for i1 in range(3): for j1 in range(12): for k1 in range(z[j1]): if e[i1][j1][k1]>e[i][j][k]: i,j,k=i1,j1,k1 i,j,k=str(i+2013),str(j+1),str(k+1) print('0'*(2-len(k))+k,'0'*(2-len(j))+j,i,sep='-')
8
PYTHON3
#include <bits/stdc++.h> using namespace std; long long ans, res, p, q, x; int cnt[10]; void solve() { string str, st = "", st1 = "", st2 = "", m = ""; cin >> str; string s1 = "2013"; string s2 = "2014"; string s3 = "2015"; map<string, long long> mp; for (int i = 6; i < str.size() - 3; i++) { st = str.substr(i, 4); if (st == s1 || st == s2 || st == s3) { st1 = "", st2 = ""; if (str[i - 4] != '-') continue; if (str[i - 1] != '-') continue; st1 = st1 + str[i - 3] + str[i - 2]; st2 = st2 + str[i - 6] + str[i - 5]; if ((st1[0] >= '0' || st1[0] <= '9') && (st1[1] >= '0' && st1[1] <= '9')) { if ((st2[0] >= '0' && st2[0] <= '9') && (st2[1] >= '0' && st2[1] <= '9')) { if (st1 == "00" || st2 == "00") continue; if ((st1 == "04" || st1 == "6" || st1 == "09" || st1 == "11") && st2 <= "30") { m = ""; m = m + st2 + "-" + st1 + "-" + st; mp[m]++; } else if (st1 == "02" && st2 <= "28") { m = ""; m = m + st2 + "-" + st1 + "-" + st; mp[m]++; } else if ((st1 == "01" || st1 == "03" || st1 == "05" || st1 == "07" || st1 == "08" || st1 == "10" || st1 == "12") && st2 <= "31") { m = ""; m = m + st2 + "-" + st1 + "-" + st; mp[m]++; } } } } } for (auto it = mp.begin(); it != mp.end(); ++it) { ans = max(ans, it->second); } for (auto it = mp.begin(); it != mp.end(); ++it) { if (it->second == ans) { cout << it->first << "\n"; return; } } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); int tt = 1; while (tt--) solve(); }
8
CPP
#include <bits/stdc++.h> using namespace std; int main() { vector<string> subs; int l; string a, b; cin >> a; l = a.size(); for (int i = 0; i < l - 9; ++i) { b = a.substr(i, 10); if ((b[2] == '-' && b[5] == '-') && ((((b[0] - '0') * 10 + b[1] - '0') <= 28) && (((b[0] - '0') * 10 + b[1] - '0') > 0)) && ((((b[3] - '0') * 10 + b[4] - '0') <= 12) && (((b[3] - '0') * 10 + b[4] - '0') > 0)) && ((b[6] == '2') && (b[7] == '0') && (b[8] == '1') && ((b[9] - '0') >= 3) && ((b[9] - '0') <= 5)) && (((b[0] >= '0') && (b[0] <= '9')) && ((b[1] >= '0') && (b[1] <= '9')) && ((b[3] >= '0') && (b[3] <= '9')) && ((b[4] >= '0') && (b[4] <= '9')))) { subs.push_back(b); } else if ((((b[3] - '0') * 10 + b[4] - '0') != 2) && (b[2] == '-' && b[5] == '-') && ((((b[0] - '0') * 10 + b[1] - '0') > 28) && (((b[0] - '0') * 10 + b[1] - '0') <= 30)) && ((((b[3] - '0') * 10 + b[4] - '0') <= 12) && (((b[3] - '0') * 10 + b[4] - '0') > 0)) && ((b[6] == '2') && (b[7] == '0') && (b[8] == '1') && ((b[9] - '0') >= 3) && ((b[9] - '0') <= 5)) && (((b[0] >= '0') && (b[0] <= '9')) && ((b[1] >= '0') && (b[1] <= '9')) && ((b[3] >= '0') && (b[3] <= '9')) && ((b[4] >= '0') && (b[4] <= '9')))) { subs.push_back(b); } else if ((((b[3] - '0') * 10 + b[4] - '0') != 11) && (((b[3] - '0') * 10 + b[4] - '0') != 9) && (((b[3] - '0') * 10 + b[4] - '0') != 6) && (((b[3] - '0') * 10 + b[4] - '0') != 4) && (((b[3] - '0') * 10 + b[4] - '0') != 2) && (b[2] == '-' && b[5] == '-') && ((((b[0] - '0') * 10 + b[1] - '0') == 31)) && ((((b[3] - '0') * 10 + b[4] - '0') <= 12) && (((b[3] - '0') * 10 + b[4] - '0') > 0)) && ((b[6] == '2') && (b[7] == '0') && (b[8] == '1') && ((b[9] - '0') >= 3) && ((b[9] - '0') <= 5)) && (((b[0] >= '0') && (b[0] <= '9')) && ((b[1] >= '0') && (b[1] <= '9')) && ((b[3] >= '0') && (b[3] <= '9')) && ((b[4] >= '0') && (b[4] <= '9')))) { subs.push_back(b); } } l = subs.size(); sort(subs.begin(), subs.end()); subs.push_back(""); int cmax = -1; int ccur = 0; b = ""; for (int i = 0; i < l; ++i) { if (subs[i] == subs[i + 1]) { ccur++; } else { if (ccur > cmax) { cmax = ccur; b = subs[i]; } ccur = 0; } } cout << b << endl; return 0; }
8
CPP
x,y,z=32,13,2016 cnt=[] for i in range(z): cnt.append([]) for i in range(z): for j in range(y): cnt[i].append([]) for i in range(z): for j in range(y): for k in range(x): cnt[i][j].append(int(0)) s=input() ansstr='' ans=0 a=[0,31,28,31,30,31,30,31,31,30,31,30,31] for i in range(len(s)-9): if(s[i].isdigit()&s[i+1].isdigit()&~s[i+2].isalnum()&s[i+3].isdigit()&s[i+4].isdigit()&~s[i+5].isalnum()&s[i+6].isdigit()&s[i+7].isdigit()&s[i+8].isdigit()&s[i+9].isdigit()): if(((int(s[i+6])*1000+int(s[i+7])*100+int(s[i+8])*10+int(s[i+9]))>=2013)&((int(s[i+6])*1000+int(s[i+7])*100+int(s[i+8])*10+int(s[i+9]))<=2015)): if(((int(s[i+3])*10+int(s[i+4]))<=12)&((int(s[i+3])*10+int(s[i+4]))>=1)): if(((int(s[i])*10+int(s[i+1]))<=a[(int(s[i+3])*10+int(s[i+4]))])&((int(s[i])*10+int(s[i+1]))>=1)): cnt[int(s[i+6])*1000+int(s[i+7])*100+int(s[i+8])*10+int(s[i+9])][int(s[i+3])*10+int(s[i+4])][int(s[i])*10+int(s[i+1])]+=1 if(cnt[int(s[i+6]+s[i+7]+s[i+8]+s[i+9])][int(s[i+3]+s[i+4])][int(s[i]+s[i+1])]>ans): ansstr=str(s[i]+s[i+1]+'-'+s[i+3]+s[i+4]+'-'+s[i+6]+s[i+7]+s[i+8]+s[i+9]) ans=cnt[int(s[i+6]+s[i+7]+s[i+8]+s[i+9])][int(s[i+3]+s[i+4])][int(s[i]+s[i+1])] print(ansstr)
8
PYTHON3
s = input().split('-') ex = {} ans = 0 sans = '' def solve(i): global ex global ans global sans global s day = s[i] month = s[i+1] year = s[i+2] if len(day) < 2 or len(month) != 2 or len(year) < 4: return day = day[-2:] year = year[:4] if int(year) < 2013 or int(year) > 2015: return if int(month) < 1 or int(month) > 12: return if int(day) < 1 or int(day) > 31: return # verifica dia de acordo com o mΓͺs (meu Deus...) tm = int(month) if tm in [1, 3, 5, 7, 8, 10, 12] and int(day) > 31: return if tm == 2 and int(day) > 28: return if tm in [4, 6, 9, 11] and int(day) > 30: return date = day+month+year if date in ex: ex[date] += 1 if ex[date] > ans: ans = ex[date] sans = date else: ex[date] = 1 if ans == 0: ans = 1 sans = date def c(s): print(f'{s[:2]}-{s[2:4]}-{s[4:]}') for i in range(len(s)-2): if len(s[i]) <= 1: continue solve(i) c(sans)
8
PYTHON3
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const int INF = 0x3f3f3f3f; const int MOD = 1e9 + 7; int days[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; struct Node { int d, m, y; bool operator<(const Node &rhs) const { return d < rhs.d || (d == rhs.d && (m < rhs.m || (m == rhs.m && y < rhs.y))); } }; map<Node, int> cnt; char s[N]; int n; void check2(int i) { if (i + 9 >= n) return; if (!isdigit(s[i])) return; if (!isdigit(s[i + 1])) return; if (!isdigit(s[i + 3])) return; if (!isdigit(s[i + 4])) return; if (!isdigit(s[i + 6])) return; if (!isdigit(s[i + 7])) return; if (!isdigit(s[i + 8])) return; if (!isdigit(s[i + 9])) return; if (s[i + 2] != '-' || s[i + 5] != '-') return; int d = s[i] - '0'; d = d * 10 + (s[i + 1] - '0'); int m = s[i + 3] - '0'; m = m * 10 + (s[i + 4] - '0'); int y = s[i + 6] - '0'; y = y * 10 + (s[i + 7] - '0'); y = y * 10 + (s[i + 8] - '0'); y = y * 10 + (s[i + 9] - '0'); if (d < 1 || d > 31) return; if (m < 1 || m > 12) return; if (d > days[m]) return; if (y < 2013 || y > 2015) return; } void check(int i) { int d = 0, m = 0, y = 0; if (i + 2 >= n || s[i + 1] == '-' || s[i + 2] != '-') return; d = s[i++] - '0'; d = d * 10 + (s[i++] - '0'); if (i + 1 >= n || s[i + 1] == '-') return; i++; if (i + 2 >= n || s[i + 1] == '-' || s[i + 2] != '-') return; m = s[i++] - '0'; m = m * 10 + (s[i++] - '0'); if (i + 1 >= n || s[i + 1] == '-') return; i++; if (i + 3 >= n || s[i + 1] == '-' || s[i + 2] == '-' || s[i + 3] == '-') return; y = s[i++] - '0'; y = y * 10 + (s[i++] - '0'); y = y * 10 + (s[i++] - '0'); y = y * 10 + (s[i++] - '0'); if (d < 1 || d > 31) return; if (m < 1 || m > 12) return; if (d > days[m]) return; if (y < 2013 || y > 2015) return; cnt[Node{d, m, y}]++; } int main() { ios::sync_with_stdio(false); cin >> s; n = strlen(s); for (int i = 0; i < n; ++i) { if (s[i] != '-') check(i); } Node ans = {0, 0, 0}; int mx = 0; for (auto p : cnt) { if (p.second > mx) { mx = p.second; ans = p.first; } } if (ans.d < 10) cout << 0; cout << ans.d; cout << "-"; if (ans.m < 10) cout << 0; cout << ans.m; cout << "-"; cout << ans.y << '\n'; return 0; }
8
CPP
#include <bits/stdc++.h> char str[100100]; int a[20], f[60000]; int main() { int i, j, l, r, y, n, x, p, s, ans, h; memset(a, 0, sizeof(a)); a[4] = a[6] = a[9] = a[11] = 1; while (~scanf("%s", str)) { memset(f, 0, sizeof(f)); ans = 0; h = 0; l = strlen(str); for (i = 0; i <= l - 10; i++) { x = 1; for (j = 0; j <= 9; j++) { if ((j == 2) || (j == 5)) { if (str[i + j] != '-') x = 0; } else { if (str[i + j] == '-') x = 0; } } if (x) { p = 1; r = (str[i] - '0') * 10 + (str[i + 1] - '0'); y = (str[i + 3] - '0') * 10 + (str[i + 4] - '0'); n = (str[i + 6] - '0') * 1000 + (str[i + 7] - '0') * 100 + (str[i + 8] - '0') * 10 + (str[i + 9] - '0'); if (n < 2013 || n > 2015) p = 0; if ((y > 12) || (y < 1)) p = 0; if (y == 2) { if (r > 28) p = 0; } else if (a[y]) { if (r > 30) p = 0; } else { if (r > 31) p = 0; } if (r == 0) p = 0; if (p) { s = (n % 10) * 10000 + y * 100 + r; f[s]++; if (f[s] > h) { ans = s; h = f[s]; } if (f[s] == h && ans > s) ans = s; } } } x = ans % 100; ans /= 100; p = ans % 100; ans /= 100; if (x / 10 == 0) printf("0"); printf("%d-", x); if (p / 10 == 0) printf("0"); printf("%d-201%d\n", p, ans); } }
8
CPP
#include <bits/stdc++.h> using namespace std; int hash1(string s) { int n = 0, b = 1; for (int i = 0; i < s.size(); i++, b *= 10) n += s[i] * b; return n; } int main(int argc, char const *argv[]) { string str; cin >> str; int s; int i, j, k, t, p; string date; map<int, int> m; map<int, string> ref; for (i = 0; i < str.size(); i++) { s = 0; string made = ""; j = i - 1; while (1) { j++; if (s == 0) { if (str[j] >= '0' && str[j] <= '9') { s = 1; made.append(1, str[j]); continue; } else break; } if (s == 1) { if (str[j] >= '0' && str[j] <= '9') { s = 2; made.append(1, str[j]); continue; } else break; } if (s == 2) { if (str[j] == '-') { s = 3; made.append(1, str[j]); continue; } else break; } if (s == 3) { if (str[j] >= '0' && str[j] <= '9') { s = 4; made.append(1, str[j]); continue; } else break; } if (s == 4) { if (str[j] >= '0' && str[j] <= '9') { s = 5; made.append(1, str[j]); continue; } else break; } if (s == 5) { if (str[j] == '-') { s = 6; made.append(1, str[j]); continue; } else break; } if (s == 6) { if (str[j] >= '0' && str[j] <= '9') { s = 7; made.append(1, str[j]); continue; } else break; } if (s == 7) { if (str[j] >= '0' && str[j] <= '9') { s = 8; made.append(1, str[j]); continue; } else break; } if (s == 8) { if (str[j] >= '0' && str[j] <= '9') { s = 9; made.append(1, str[j]); continue; } else break; } if (s == 9) { if (str[j] >= '0' && str[j] <= '9') { s = 10; made.append(1, str[j]); continue; } else break; } if (s == 10) { string d = made.substr(0, 2); string mo = made.substr(3, 2); string y = made.substr(6, 4); int date, month, year; istringstream(d) >> date; istringstream(mo) >> month; istringstream(y) >> year; if (!(year >= 2013 && year <= 2015)) break; if (date <= 0) break; if (!(month >= 1 && month <= 12)) break; if (month == 2) { if (date > 28) break; } else if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) { if (date > 31) break; } else { if (date > 30) break; } int h = hash1(made); ref[h] = made; if (m.find(h) == m.end()) m[h] = 1; else m[h] = m[h] + 1; break; } j++; } } map<int, int>::iterator it; int mx = 0; string maxs; for (it = m.begin(); it != m.end(); it++) { if (it->second > mx) { mx = it->second; maxs = ref[it->first]; } } cout << maxs << endl; ; return 0; }
8
CPP
#include <bits/stdc++.h> using namespace std; bool check(string s) { if (s.length() < 10) { return false; } if (s[2] != '-' || s[5] != '-') { return false; } if (s[6] != '2' || s[7] != '0' || s[8] != '1' || (s[9] != '3' && s[9] != '4' && s[9] != '5')) { return false; } if (s[0] < '0' || s[0] > '3') return false; if (s[1] < '0' || s[1] > '9') return false; if (s[3] < '0' || s[3] > '2') return false; if (s[4] < '0' || s[4] > '9') return false; long long d = (long long)(s[0] - '0') * 10 + (long long)(s[1] - '0'); long long m = (long long)(s[3] - '0') * 10 + (long long)(s[4] - '0'); if (m < 1 || m > 12) { return false; } if (m == 4 || m == 6 || m == 9 || m == 11) { if (d < 1 || d > 30) { return false; } } else if (m == 2) { if (d < 1 || d > 28) { return false; } } else { if (d < 1 || d > 31) { return false; } } return true; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); string s; cin >> s; map<string, long long> mp; long long n = s.length(); for (long long i = 0; i < n; i++) { string s1 = s.substr(i, 10); if (check(s1)) { mp[s1]++; } } long long maxi = -1; string s2; for (auto j : mp) { if (j.second > maxi) { maxi = j.second; s2 = j.first; } } cout << s2 << "\n"; return 0; }
8
CPP
#include <bits/stdc++.h> using namespace std; char x[100100]; long x2[100100]; long mes[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; long wr = 0; long res, cur, repsmax = -1; long reps = 0; long tmp1, tmp2, tmp3; string s1; int compare(const void *a, const void *b) { return (*(long *)a - *(long *)b); } long check(long z) { if ((isdigit(x[z])) && (isdigit(x[z + 1])) && (isdigit(x[z + 3])) && (isdigit(x[z + 4])) && (isdigit(x[z + 6])) && (isdigit(x[z + 7])) && (isdigit(x[z + 8])) && (isdigit(x[z + 9]))) { if ((x[z + 2] == x[z + 5]) && (x[z + 2] == '-')) { tmp1 = ((long)(x[z]) - (long)('0')) * 10 + ((long)(x[z + 1]) - (long)('0')); tmp2 = ((long)(x[z + 3]) - (long)('0')) * 10 + ((long)(x[z + 4]) - (long)('0')); tmp3 = ((long)(x[z + 6]) - (long)('0')) * 1000 + ((long)(x[z + 7]) - (long)('0')) * 100 + (((long)(x[z + 8]) - (long)('0')) * 10) + ((long)(x[z + 9]) - (long)('0')); if ((tmp2 <= 12) && (tmp3 <= 2015) && (tmp3 >= 2013)) { if ((tmp1 <= mes[tmp2]) && (tmp2 != 0) && (tmp1 != 0)) { x2[wr++] = tmp1 + tmp2 * 100 + tmp3 * 10000; } } } } if ((!isdigit(x[z + 9])) && (x[z + 9] != '-')) { return -2; } } int main(int argc, char *argv[]) { scanf("%s", &x); long j = 0; while (check(j++) > -2) { } qsort(x2, wr - 1, sizeof(long), compare); cur = x2[0]; for (long j = 0; j < wr; j++) { if (cur == x2[j]) { reps++; } else { if (reps > repsmax) { repsmax = reps; res = cur; } cur = x2[j]; reps = 1; } } if (reps > repsmax) { repsmax = reps; res = cur; } cur = x2[j]; reps = 1; ldiv_t divresult1; divresult1 = ldiv(res, 100); if (divresult1.rem < 10) { cout << "0"; } cout << divresult1.rem << "-"; ldiv_t divresult2; divresult2 = ldiv(res, 10000); if (((divresult2.rem - divresult1.rem) / 100) < 10) { cout << "0"; } cout << (divresult2.rem - divresult1.rem) / 100 << "-"; ldiv_t divresult3; divresult3 = ldiv(res, 100000000); cout << (divresult3.rem - divresult2.rem) / 10000; return EXIT_SUCCESS; }
8
CPP
#include <bits/stdc++.h> using namespace std; map<string, int> f; int k[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; bool invalid(char a) { return a == '-'; } void calc(string s) { if (s[2] != '-' || s[5] != '-') return; for (int i = 0; i < s.length(); i++) if (i == 2 || i == 5) continue; else if (invalid(s[i])) return; string d = s.substr(0, 2), m = s.substr(3, 2), y = s.substr(6, 4); int year = atoi(y.c_str()), month = atoi(m.c_str()), day = atoi(d.c_str()); if (year < 2013 || year > 2015 || month < 1 || month > 12 || day < 1 || day > k[month]) return; f[s]++; } int main() { int maxi = -1; string s, MX = ""; cin >> s; for (int i = 0; i < s.size() - 9; i++) calc(s.substr(i, 10)); for (map<string, int>::iterator it = f.begin(); it != f.end(); it++) if (it->second > maxi) maxi = it->second, MX = it->first; cout << MX << endl; return 0; }
8
CPP
days = [31,28,31,30,31,30,31,31,30,31,30,31] d = [] for i in range(1,32): if i<10: d.append('0'+str(i)) else: d.append(str(i)) mon = [] hash_mo = {} for i in range(1,13): hash_mo[i] = days[i-1] for i in range(1,13): if i<10: mon.append('0'+str(i)) else: mon.append(str(i)) # print(mon) lis = ['2013','2014','2015'] k = input() posn = [] for i in range(1,len(k)): if k[i] == '-' : posn.append(i) # print(posn) hash = {} for i in range(len(posn)-1): if posn[i+1] - posn[i] == 3: m = posn[i] if 0<=m-2<=len(k)-1 and 0<=m-1<=len(k)-1 and 0<=m<=len(k)-1 and 0<=m+2<=len(k)-1 and 0<=m+3<=len(k)-1 and 0<=m+4<=len(k)-1: if k[m+4:m+8] in lis: # print(k[posn[m+1]+1:4]) day = k[m-2] + k[m-1] month = k[m+1] + k[m+2] # print(day,month) if month in mon and day in d: if int(day)<=hash_mo[int(month)]: s = k[m-2] + k[m-1] + k[m] + k[m+1] + k[m+2] + k[m+3] + k[m+4:m+8] try: hash[s] except: hash[s] = 1 else: hash[s]+=1 max = 0 for i in hash.keys(): if hash[i]>max: max = hash[i] yo = i print(yo)
8
PYTHON3
#include <bits/stdc++.h> using namespace std; const int M = 1e5 + 5; char pro[M]; map<string, int> mp; int moon[15] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; bool OK(string a) { int len = a.length(); int year, month, day; year = (a[len - 4] - '0') * 1000 + (a[len - 3] - '0') * 100 + (a[len - 2] - '0') * 10 + (a[len - 1] - '0'); if (year > 2015 || year < 2013) { return false; } month = (a[len - 7] - '0') * 10 + (a[len - 6] - '0'); if (month < 1 || month > 12) { return false; } day = (a[len - 10] - '0') * 10 + (a[len - 9] - '0'); if (day < 1 || day > moon[month]) { return false; } return true; } bool judge(int i) { if (pro[i] != '-' && pro[i + 1] != '-' && pro[i + 2] == '-' && pro[i + 3] != '-' && pro[i + 4] != '-' && pro[i + 5] == '-' && pro[i + 6] != '-' && pro[i + 7] != '-' && pro[i + 8] != '-' && pro[i + 9] != '-') { return true; } return false; } int main() { scanf("%s", pro); int len = strlen(pro); for (int i = 0; i < len - 9; i++) { if (judge(i)) { char temp[15]; memcpy(temp, pro + i, 10); temp[10] = '\0'; mp[temp]++; } } map<string, int>::iterator k = mp.begin(); int num = 0; string ans; for (; k != mp.end(); k++) { if (num < (k->second) && OK(k->first)) { num = (k->second); ans = k->first; } } cout << ans << endl; return 0; }
8
CPP
#include <bits/stdc++.h> using namespace std; string s; int arr[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; pair<int, int> f(int i) { if (i - 6 >= 0 && s[i - 4] == '-' && s[i - 1] == '-' && s[i - 3] >= '0' && s[i - 3] <= '9' && s[i - 2] >= '0' && s[i - 2] <= '9' && s[i - 6] >= '0' && s[i - 6] <= '9' && s[i - 5] >= '0' && s[i - 5] <= '9') { int x = (s[i - 3] - '0') * 10 + (s[i - 2] - '0'); if (x > 0 && x <= 12) { int d = (s[i - 6] - '0') * 10 + (s[i - 5] - '0'); if (d > 0 && d <= arr[x - 1]) return make_pair(d, x); } } return make_pair(-1, -1); } int main() { map<string, int> M; cin >> s; int v; int d = 0; string ans = ""; for (int i = 0; i < s.size(); i++) { if (i + 3 < s.size() && s[i] == '2' && s[i + 1] == '0' && s[i + 2] == '1' && (s[i + 3] >= '3' && s[i + 3] <= '5')) { pair<int, int> p = f(i); if (p.first != -1) { string a = ""; for (int j = i - 6; j < i + 4; j++) a += s[j]; if (M.count(a) == 0) { M[a] = 1; if (1 > d) { d = 1; ans = a; } } else { M[a]++; int t = M[a]; if (t > d) { d = t; ans = a; } } } } } cout << ans; return 0; }
8
CPP
#include <bits/stdc++.h> namespace patch { template <typename T> std::string to_string(const T& n) { std::ostringstream stm; stm << n; return stm.str(); } } // namespace patch using namespace std; long long int days[13] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; map<string, long long int> mp; bool chk(char a) { return (a >= '0' && a <= '9'); } void solve(string S) { if (S[2] == '-' && S[5] == S[2] && chk(S[0]) && chk(S[1]) && chk(S[3]) && chk(S[4]) && chk(S[6]) && chk(S[7]) && chk(S[8]) && chk(S[9])) { stringstream ss; ss << S; long long int D = 0, M = 0, Y = 0; ss >> D >> M >> Y; D = abs(D); M = abs(M); Y = abs(Y); if (D == 0 || D > 31 || M == 0 || M > 12 || Y < 2013 || Y > 2015) { return; } if (D > 0 && D <= days[M - 1]) { mp[S]++; } } } int main() { string S; cin >> S; for (int i = 0; i < S.size() - 9; i++) { string tmp = ""; for (int j = i; j < i + 10; j++) { tmp += S[j]; } solve(tmp); } long long int mx = 0; string tmp; for (auto it : mp) { if (mx < it.second) { mx = it.second; tmp = it.first; } } stringstream ss; long long int X; ss << tmp; ss >> X; X = abs(X); if (X < 10) { cout << 0; } cout << X << '-'; ss >> X; X = abs(X); if (X < 10) { cout << 0; } cout << X << '-'; ss >> X; cout << abs(X); return 0; }
8
CPP
#include <bits/stdc++.h> using namespace std; string in; map<string, int> m; int meses[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int main(int argc, char *argv[]) { cin >> in; for (int i = 2; i < in.size() - 7; ++i) { if (in[i] == '-') { string date(in.c_str() + i - 2, 10); int contador = 0; for (int j = 0; j < date.size(); ++j) if (date[j] == '-') contador++; if (date[2] == '-' && date[5] == '-' && date[0] != '-' && contador == 2) { m[date]++; date.clear(); } } } int maior = -1; string in; for (map<string, int>::iterator it = m.begin(); it != m.end(); ++it) { int day, month, year; sscanf((*it).first.c_str(), "%d-", &day); sscanf((*it).first.c_str() + 3, "%d-", &month); sscanf((*it).first.c_str() + 6, "%d", &year); if ((*it).second > maior && year >= 2013 && year <= 2015) if (day >= 1 && month >= 1 && month <= 12 && day <= meses[month - 1]) { maior = (*it).second; in = (*it).first; } } cout << in << endl; return 0; }
8
CPP
years = {"2013", "2014", "2015"} base = set() for i in range(1, 29): if i < 10: base.add("0" + str(i)) else: base.add(str(i)) info1 = base.copy() info1.add("29") info1.add("30") info2 = info1.copy() info2.add("31") months = { "02": base } for i in [4, 6, 9, 11]: if i < 10: months["0" + str(i)] = info1 else: months[str(i)] = info1 for i in [1, 3, 5, 7, 8, 10, 12]: k = ("0" + str(i)) if i < 10 else str(i) months[k] = info2 s = input() def solve(s, years, months): maps = {} i = 0 while i < len(s) - 9: if s[i+2] != "-" or s[i+5] != "-": i += 1 continue d, m, y = s[i:i+2], s[i+3:i+5], s[i+6:i+10] if y in years and m in months and d in months[m]: k = s[i:i+10] maps[k] = maps.get(k, 0) + 1 i += 1 ans, count = "", 0 for k, v in maps.items(): if count < v: ans, count = k, v return ans ans = solve(s, years, months) print(ans)
8
PYTHON3
#include <bits/stdc++.h> using namespace std; const int k[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; map<string, int> f; string s; int main() { int i, j, n = 0, y, m, d; string t, x; cin >> s; for (i = 0; i + 10 <= (int)s.length(); i++) { x = s.substr(i, 10); if (sscanf((x + "*1").c_str(), "%2d-%2d-%4d*%d", &d, &m, &y, &j) != 4) continue; if (m > 12 || m < 1) continue; if (d > k[m] || d < 1) continue; if (y < 2013 || y > 2015) continue; if (n < ++f[x]) { n = f[x]; t = x; } } cout << t; return 0; }
8
CPP
#!/bin/python # -*- coding: utf-8 -*- n = int(input()) s = input() print(int(s.count('I') == 1) if 'I' in s else s.count('A'))
8
PYTHON3
n=int(input()) c=input() if c.count('I')==0: print(c.count('A')) elif c.count('I')==1: print(1) else: print(0)
8
PYTHON3
cows = int(input()) bets = input() i = bets.count('I') if i > 1: print(0) elif i == 1: print(1) else: print(bets.count('A'))
8
PYTHON3
#include <bits/stdc++.h> using namespace std; template <class T> void pp(T v) { for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); ++it) cout << *it << ' '; cout << endl; } template <class T> void pp(T v, int n) { for (int i = 0; i < (int)n; i++) cout << v[i] << ' '; cout << endl; } template <class T> inline void chmax(T &a, const T b) { a = max(a, b); } template <class T> inline void chmin(T &a, const T b) { a = min(a, b); } const int INF = 1 << 28; const double EPS = 1.0e-9; static const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1}; int main(void) { int N; cin >> N; string line; cin >> line; int A = 0, F = 0, I = 0; for (int i = 0; i < (int)N; i++) { switch (line[i]) { case 'A': A++; break; case 'F': F++; break; case 'I': I++; break; } } int ans = 0; for (int i = 0; i < (int)N; i++) { if (line[i] == 'A' || line[i] == 'I') { int irem = I - (line[i] == 'I' ? 1 : 0); if (irem <= 0) ans++; } } cout << ans << endl; return 0; }
8
CPP
#include <bits/stdc++.h> using namespace std; template <class T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); } template <class T> T maxm(T a, T b) { return a > b ? a : b; } template <class T> T minm(T a, T b) { return a < b ? a : b; } template <class T> T abs(T a) { return a > 0 ? a : (-1) * a; } template <class T> T sq(T a) { return a * a; } char s[200005]; int main() { int n, f = 0, in = 0, a = 0; char ch; scanf("%d", &n); getchar(); for (int i = 0; i < n; i++) { scanf("%c", &ch); if (ch == 'A') a++; else if (ch == 'F') f++; else in++; } if (in == 1) cout << 1; else if (in > 1) cout << 0; else if (in == 0) cout << a; return 0; }
8
CPP
n = int(input()) t = input() if t.count("A") == 0: if t.count("I") == 1: print(1) else: print(0) else: if t.count("I") == 1: print(1) elif t.count("I") > 1: print(0) else: print(t.count("A"))
8
PYTHON3
c=int(input()) s=input() p=[i for i in s] a=p.count("A") i=p.count("I") f=p.count("F") if i==0: print(a) elif i==1: print(i) else: print(0)
8
PYTHON3
n = int(input()) status = list(input()) allin = status.count("A") folded = status.count("F") In = status.count("I") if In > 1: print(0) if In == 1: print(1) if In == 0: print(allin)
8
PYTHON3
#include <bits/stdc++.h> using namespace std; const long double pi = 3.141592654; int main() { cin.tie(0); std::ios::sync_with_stdio(false); int n; cin >> n; string str; cin >> str; int A = 0, F = 0, k = 0; for (int i = 0; i < n; i++) { if (str[i] == 'A') A++; else if (str[i] == 'F') F++; else k++; } if (k == 0) cout << A << endl; else if (k == 1) cout << 1 << endl; else cout << 0 << endl; return 0; }
8
CPP
n=int(input());s=input() a=s.count('A');b=s.count('I') print([a,[1,0][b!=1]][b!=0])
8
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int n, sum = 0, sum1 = 0, sum2 = 0; cin >> n; string str; cin >> str; for (int i = 0; i < str.length(); i++) { if (str[i] == 'A') { sum++; } else if (str[i] == 'I') { sum1++; } else { sum2++; } } if (sum && sum1 == 0) { cout << sum << endl; } else if ((sum1 == 1 && sum) || (sum1 == 1 && sum2)) { cout << sum1 << endl; } else { cout << 0 << endl; } return 0; }
8
CPP
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n >> s; int i = 0, A = 0; for (int j = 0; j < n; j++) { if (s[j] == 'I') i++; if (s[j] == 'A') A++; } if (i == 1) cout << 1 << "\n"; else if (i > 1) cout << 0 << "\n"; else if (i == 0) { cout << A << "\n"; } return 0; }
8
CPP
n = int(input()) a = list(input()) Is = 0 for i in range(len(a)): if a[i]== "I": Is+=1 if Is >= 2: print(0) elif Is == 1: print(1) else: count= 0 for i in range(len(a)): if a[i]=="A": count+=1 print(count)
8
PYTHON3
n = int(input()) c = {'A': 0, 'F': 0, 'I': 0} for ch in input(): c[ch] += 1 if c['I'] == 0: print(c['A']) elif c['I'] == 1: print(1) else: print(0)
8
PYTHON3
a = int(input()) t = list(input()) if t.count('I')==1: print(1) elif t.count('I')==0: print(a-t.count('F')) else: print(0)
8
PYTHON3
#include <bits/stdc++.h> using namespace std; int main(int argc, char **argv) { int n; cin >> n; string s; cin >> s; int in = std::count(s.begin(), s.end(), 'I'); int ans = 0; if (in <= 1) { int all = std::count(s.begin(), s.end(), 'A'); if (in == 0) ans = all; else ans = 1; } cout << ans; return 0; }
8
CPP
#include <bits/stdc++.h> int main() { int n, A = 0, I = 0, F = 0, ans = 0; char c[200001]; scanf("%d", &n); scanf("%s", c); for (int i = 0; i < n; i++) { if (c[i] == 'A') A++; else if (c[i] == 'I') I++; else if (c[i] == 'F') F++; } if (I == 0) ans = A; else if (I == 1) ans = 1; printf("%d\n", ans); return 0; }
8
CPP
n=int(input()) a=input() b=a.count('A') c=a.count('I') print('0'if c>1 else (1,b)[c==0])
8
PYTHON3
n, s = int(input()), input() a, i = s.count('A'), s.count('I') f = n - (a + i) if i == 1 and (f > 0 or a > 0): print(i) elif i == 0 and a > 0: print(a) else: print(0)
8
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { long int count = 0, i, n, a[3] = {0}; string s; cin >> n >> s; for (i = 0; i < s.length(); i++) { if (s[i] == 'A') a[0]++; else if (s[i] == 'I') a[1]++; else a[2]++; } if (a[1] == 1) cout << "1" << endl; else if (a[1] == 0) cout << a[0] << endl; else cout << "0" << endl; return 0; }
8
CPP
#include <bits/stdc++.h> const int N = 100; using namespace std; map<char, int> mp; int main() { ios::sync_with_stdio(false); int t; cin >> t; while (t--) { char ch; cin >> ch; mp[ch]++; } if (mp['I'] == 1) { cout << 1 << endl; } else if (mp['I'] >= 2) { cout << 0 << endl; } else { cout << mp['A'] << endl; } return 0; }
8
CPP
#include <bits/stdc++.h> int main() { long j, n, I, A, F; char aux; scanf("%li", &n); scanf("%c", &aux); A = I = F = 0; for (j = 1; j <= n; j++) { scanf("%c", &aux); if (aux == 'A') { A++; } if (aux == 'F') { F++; } if (aux == 'I') { I++; } } if (I == 1) { printf("1\n"); } else { if (I > 1) { printf("0\n"); } else { printf("%ld\n", A); } } return 0; }
8
CPP
# https://codeforces.com/contest/284/problem/B import sys import math def main(): # sys.stdin = open('E:\\Sublime\\in.txt', 'r') # sys.stdout = open('E:\\Sublime\\out.txt', 'w') # sys.stderr = open('E:\\Sublime\\err.txt', 'w') n = int(sys.stdin.readline().strip()) s = sys.stdin.readline().strip() print([s.count('A'), 1, 0][min(s.count('I'), 2)]) if __name__ == '__main__': main() # hajj # γ€€γ€€γ€€γ€€γ€€γ€€ οΌΏοΌΏ # γ€€γ€€γ€€γ€€γ€€οΌοΌžγ€€γ€€γƒ• # γ€€γ€€γ€€γ€€γ€€| γ€€_γ€€ _ l # γ€€    /` γƒŸοΌΏxγƒŽ # γ€€γ€€ γ€€ /γ€€γ€€γ€€ γ€€ | # γ€€γ€€γ€€ /γ€€ ヽ   οΎ‰ # γ€€ γ€€ β”‚γ€€γ€€|γ€€|γ€€| #  / ̄|γ€€γ€€ |γ€€|γ€€| # γ€€| ( ̄ヽ__ヽ_)__) # γ€€οΌΌδΊŒγ€
8
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { if (false) { freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); } int n; cin >> n; int ni = 0; int na = 0; int nf = 0; for (int i = 0; i < n; i++) { char b; cin >> b; if (b == 'I') { ni++; } else if (b == 'A') { na++; } else if (b == 'F') { nf++; } else { cout << "wrong char" << endl; return -1; } } int ans; if (ni > 1) { ans = 0; } else if (ni == 1) { ans = 1; } else { ans = na; } cout << ans << endl; if (false) { fclose(stdin); fclose(stdout); } return 0; }
8
CPP
#include <bits/stdc++.h> using namespace std; int main() { long int n; long int qtde_i, qtde_a; char ch; cin >> n; qtde_i = 0; qtde_a = 0; for (long int i = 0; i < n; i++) { cin >> ch; if (ch == 'I') { qtde_i += 1; } else if (ch == 'A') { qtde_a += 1; } } if (0) { cout << "MAIN : char lidos =" << n << endl; cout << "QTDE_I = " << qtde_i << endl; cout << "QTDE_A = " << qtde_a << endl; } if (qtde_i > 0) { if (qtde_i > 1) { cout << 0 << endl; } else { cout << 1 << endl; } } else { cout << qtde_a << endl; } return 0; }
8
CPP
n=int(input()) m=input() if m.count('I')==1: print(1) elif m.count('I')>1: print(0) else: print(m.count('A'))
8
PYTHON3
#include <bits/stdc++.h> using namespace std; long long int a[200005], b[200005]; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; long long int n, count = 0, count1 = 0; cin >> n; char c[200005]; for (long long int i = 0; i < n; i++) { cin >> c[i]; if (c[i] == 'I') count++; else if (c[i] == 'A') count1++; } cout << (count ? (count == 1 ? 1 : 0) : count1); }
8
CPP
#include <bits/stdc++.h> using namespace std; int main() { int n, a = 0, i = 0; cin >> n; for (int j = 0; j < n; j++) { char c; cin >> c; if (c == 'A') a++; else if (c == 'I') i++; } if (i == 1) cout << 1; else if (i > 0) cout << 0; else if (i == 0) cout << a; return 0; }
8
CPP
#include <bits/stdc++.h> using namespace std; int main() { int a, i, F = 0, I = 0, A = 0; char c[200001]; cin >> a; for (i = 1; i <= a; i++) { cin >> c[i]; if (c[i] == 'I') { I++; } else if (c[i] == 'F') { F++; } else { A++; } } if (I == 1) { cout << 1; } else if (I > 1) { cout << 0; } else { cout << A; } return 0; }
8
CPP
n = int(input()) daf = list(input()) if daf.count('I') == 0: print(daf.count('A')) elif daf.count('I') > 1: print(0) else: print(1)
8
PYTHON3
# python3 import sys, threading, os.path import string import collections, heapq, math, bisect sys.setrecursionlimit(10 ** 6) threading.stack_size(2 ** 27) def main(): if os.path.exists('in.txt'): input = open('in.txt', 'r') else: input = sys.stdin # --------------------------------INPUT--------------------------------- n = int(input.readline()) st = list(str(input.readline().rstrip('\n'))) dict = {} for x in st: if x in dict: dict[x] += 1 else: dict[x] = 1 result = 0 if 'I' in dict: if dict['I'] == 1: result = 1 else: result = 0 elif 'A' in dict: result = dict['A'] else: result = 0 output = result # -------------------------------OUTPUT---------------------------------- if os.path.exists('out.txt'): open('out.txt', 'w').writelines(str(output)) else: sys.stdout.write(str(output)) if __name__ == '__main__': main() # threading.Thread(target=main).start()
8
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { long int n, i, a, f, in; char ch; cin >> n; a = 0; in = 0; f = 0; for (i = 0; i < n; i++) { cin >> ch; if (ch == 'A') a++; else if (ch == 'I') in++; else f++; } if (in == 1) cout << in; else if (in > 1) cout << 0; else { cout << (a); } return 0; }
8
CPP
#include <bits/stdc++.h> using namespace std; int n, al, in; char s[200010]; int main() { al = in = 0; scanf("%d%s", &n, s); for (int i = 0; i < n; i++) if (s[i] == 'A') al++; else if (s[i] == 'I') in++; if (in == 0) printf("%d\n", al); else if (in == 1) printf("1\n"); else printf("0\n"); return 0; }
8
CPP
#include <bits/stdc++.h> using namespace std; char c; int n, a, i, j; int main() { scanf("%d\n", &n); for (int j = 1; j <= n; j++) { scanf("%c", &c); switch (c) { case 'A': a++; break; case 'I': i++; break; } } if (i) { if (i == 1) printf("1\n"); else printf("0\n"); } else { printf("%d\n", a); } return 0; }
8
CPP
#include <bits/stdc++.h> using namespace std; int cnt[26]; int main() { int n; scanf("%d", &n); string x; cin >> x; for (int i = 0; i < x.length(); i++) { cnt[x[i] - 'A']++; } int A = cnt[0], F = cnt['F' - 'A'], I = cnt['I' - 'A']; int cnt = 0; for (int i = 0; i < x.length(); i++) { if (x[i] != 'F') { int tmp = A + F; if (x[i] == 'A' || x[i] == 'F') tmp--; if (tmp == n - 1) cnt++; } } printf("%d\n", cnt); return 0; }
8
CPP
#include <bits/stdc++.h> int main() { int a[3], i, n, k; char c; while (scanf("%d", &n) != EOF) { getchar(); memset(a, 0, sizeof(a)); k = 0; for (i = 0; i < n; i++) { scanf("%c", &c); if (c == 'A') a[0]++; if (c == 'F') a[1]++; if (c == 'I') a[2]++; } if (a[0] > 0 && a[2] == 0) k += a[0]; else if (a[2] == 1) k++; printf("%d\n", k); } return 0; }
8
CPP
#include <bits/stdc++.h> using namespace std; const int N = 200004; int main() { int n; char s[N]; map<char, int> mp; scanf("%d%s", &n, s); for (int i = 0; i < n; i++) mp[s[i]]++; if (mp.count('I') > 0) { if (mp['I'] >= 2) puts("0"); else puts("1"); } else cout << count(s, s + n, 'A'); return 0; }
8
CPP
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int I = 0, F = 0, A = 0; for (auto ch : s) { if (ch == 'A') A += 1; else if (ch == 'I') I += 1; else F += 1; } if (I == 0) { cout << A << endl; return 0; } if (I > 0) { if (I == 1) cout << 1 << endl; else cout << 0 << endl; } return 0; }
8
CPP
from sys import stdin,stdout ii1 = lambda: int(stdin.readline().strip()) is1 = lambda: stdin.readline().strip() iia = lambda: list(map(int, stdin.readline().strip().split())) isa = lambda: stdin.readline().strip().split() mod = 1000000007 n = ii1() arr = is1() if 'I' in arr: if arr.count('I') > 1: print(0) else: print(1) else: print(arr.count('A'))
8
PYTHON3
#include <bits/stdc++.h> using namespace std; template <class T> inline T MAX(T a, T b) { if (a > b) return a; return b; } template <class T> inline T MIN(T a, T b) { if (a < b) return a; return b; } template <class T> inline T ABS(T x) { if (x < 0) return -x; return x; } inline void OPEN(const string &s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } const static int inf = 1000000000; int n; char input[200005]; bool ada = false; int main() { scanf("%d", &n); scanf("%s", input); int a = 0, b = 0; for (int(i) = (0); (i) < (n); ++(i)) { if (input[i] == 'I') { a++; ada = true; } else if (input[i] == 'A') { b++; } } if (ada) { if (a == 1) printf("1\n"); else printf("0\n"); } else printf("%d\n", b); }
8
CPP
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; long long n, m; while (cin >> n) { string st; cin >> st; long long cnt = 0; for (int i = 0; i < n; i++) { if (st[i] == 'I') cnt++; } if (cnt == 0) { for (int i = 0; i < n; i++) if (st[i] == 'A') cnt++; cout << cnt << endl; } else { if (cnt != 1) cnt = 0; cout << cnt << endl; } } return 0; }
8
CPP
input() s=input() a=s.count('A') i=s.count('I') print([a,[1,0][i!=1]][i!=0])
8
PYTHON3
#include <bits/stdc++.h> using namespace std; long long MD = 1000000007; long long md = 998244353; const long long INF = 1e18L + 5; long long exp(long long a, long long b) { long long r = 1ll; while (b > 0) { if (b & 1) { r = r * (a % md); r = (r + md) % md; } b /= 2; a = (a % md) * (a % md); a = (a + md) % md; } return (r + md) % md; } long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long pow_2(long long a, long long b) { long long res = 1; while (b) { if (b & 1) res = (res * a); a = (a * a); b >>= 1; } return res; } bool isPrime(long long a) { for (long long i = 3; (i * i) <= a; i += 2) { if ((a % i) == 0) return false; } if ((a != 2) && ((a % 2) == 0)) return false; if (a == 1) return false; return true; } string decToBinary(int n) { string s = ""; for (int i = 31; i >= 0; i--) { int k = n >> i; if (k & 1) s = s + "1"; else s = s + "0"; } return s; } int decimalToBinary(int N) { unsigned long long int B_Number = 0; int cnt = 0; while (N != 0) { int rem = N % 2; unsigned long long int c = pow(10, cnt); B_Number += rem * c; N /= 2; cnt++; } return B_Number; } string toString(unsigned long long int num) { std::string number; std::stringstream strstream; strstream << num; strstream >> number; return number; } const double PI = acos(-1); int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; cin >> n; string s; cin >> s; int a = 0, j = 0, f = 0; for (int i = 0; i < n; i++) { if (s[i] == 'A') a++; else if (s[i] == 'I') j++; else f++; } if (j >= 2) cout << "0" << endl; else { if (j == 1) cout << "1" << endl; else { cout << a << endl; } } return 0; }
8
CPP
#include <bits/stdc++.h> using namespace std; int main() { int n, A = 0, F = 0, I = 0; char S[200005]; cin >> n; cin >> S; for (int i = 0; i < n; i++) { if (S[i] == 'A') A++; else if (S[i] == 'I') I++; } if (I == 0) { cout << A << endl; return 0; } if (I == 1) { cout << 1 << endl; return 0; } else cout << 0 << endl; return 0; }
8
CPP
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; string s; cin >> s; int contA = 0, contI = 0, contF = 0; for (int i = 0; i < N; i++) { if (s[i] == 'A') contA++; if (s[i] == 'I') contI++; if (s[i] == 'F') contF++; } if (contI <= 1) { if (contI == 1) cout << 1 << endl; else cout << contA << endl; } else { cout << 0 << endl; } return 0; }
8
CPP
#include <bits/stdc++.h> using namespace std; char ch[200009]; int main() { int n; scanf("%d", &n); scanf("%s", ch); int a = 0, b = 0; for (int i = 0; i < n; i++) if (ch[i] == 'I') a++; for (int i = 0; i < n; i++) if (ch[i] == 'A') b++; if (a == 1) printf("%d\n", a); else if (a == 0) printf("%d\n", b); else printf("0\n"); return 0; }
8
CPP
#include <bits/stdc++.h> using namespace std; int main() { string s; int n; int sumA; int sumF; int sumI; while (cin >> n) { sumA = sumF = sumI = 0; cin >> s; for (int i = 0; i < n; ++i) { if (s[i] == 'A') sumA++; else if (s[i] == 'F') sumF++; else sumI++; } if (sumI == 0) cout << sumA << endl; else if (sumI == 1) cout << "1" << endl; else cout << "0" << endl; } return 0; }
8
CPP
#include <bits/stdc++.h> using namespace std; vector<int> v; int main() { int n; cin >> n; string str; cin >> str; int cnti = 0, cnta = 0; for (int i = 0; i < ((int)(str).size()); i++) { cnti += str[i] == 'I'; cnta += str[i] == 'A'; } if (cnti > 1) cout << 0; else if (cnti == 1) cout << 1; else cout << cnta; return 0; }
8
CPP
#include <bits/stdc++.h> using namespace std; int main() { int countF = 0, countAI = 0, countIN = 0; int n; int show = 0; string game; cin >> n; cin >> game; for (int i = 0; i < n; i++) { if (game[i] == 'F') countF++; else if (game[i] == 'I') countIN++; else if (game[i] == 'A') countAI++; } if ((countIN == 0 && countAI == 0)) show = 0; else if (countIN == 0) show = countAI; else if ((countF != 0 && countIN == 1) || (countAI != 0 && countIN == 1)) show = countIN; cout << show; return 0; }
8
CPP
from sys import stdin,stdout from heapq import heapify,heappush,heappop,heappushpop from collections import defaultdict as dd, deque as dq,Counter as C from bisect import bisect_left as bl ,bisect_right as br from itertools import combinations as cmb,permutations as pmb from math import factorial as f ,ceil,gcd,sqrt,log,inf mi = lambda : map(int,input().split()) ii = lambda: int(input()) li = lambda : list(map(int,input().split())) mati = lambda r : [ li() for _ in range(r)] lcm = lambda a,b : (a*b)//gcd(a,b) MOD=10**9+7 def soe(n): prime = [True for i in range(n+1)] p = 2 while (p * p <= n): if (prime[p] == True): for i in range(p * p, n+1, p): prime[i] = False p += 1 return(prime) def ncr(n,r): p,k=1,1 if (n - r < r): r = n - r if r!=0: while(r): p,k=p*n,k*r m=gcd(p,k) p,k=p//m,k//m n,r=n-1,r-1 else: p=1 return(p) def solve(): n=ii() s=input() if s.count("I")>1: print(0) elif s.count("I")==1: print(1) else: print(s.count("A")) for _ in range(1): solve()
8
PYTHON3
#include <bits/stdc++.h> using namespace std; double PI = 3.1415926536; int main() { long long n; cin >> n; string s; cin >> s; int a = 0, f = 0, I = 0; for (int i = 0; i < n; i++) { if (s[i] == 'F') f++; else if (s[i] == 'I') I++; else if (s[i] == 'A') a++; } if (a > 0 || f > 0) { if (I == 0) cout << a; else if (I == 1) { cout << 1; } else { cout << 0; } } else { cout << 0; } return 0; }
8
CPP
#include <bits/stdc++.h> using namespace std; long long int mod = 1e9 + 7; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n; cin >> n; string s; cin >> s; long long int a = 0; long long int b = 0; long long int c = 0; for (long long int i = 0; i < s.size(); ++i) { if (s[i] == 'A') { a++; } if (s[i] == 'F') { b++; } if (s[i] == 'I') { c++; } } if (c == 0) { cout << a << "\n"; ; return 0; } if (c == 1) { cout << 1 << "\n"; ; return 0; } cout << 0 << "\n"; ; }
8
CPP
#include <bits/stdc++.h> using namespace std; int main() { char s; int i, j, n, all, in, fold, c, d; all = 0; in = 0; fold = 0; cin >> n; for (i = 1; i <= n; i++) { cin >> s; if (s == 'A') all++; if (s == 'I') in++; if (s == 'F') fold++; } if (in == 0) cout << all; else if (in == 1) cout << 1; else cout << 0; return 0; }
8
CPP
import sys,math from collections import deque,defaultdict import operator as op from functools import reduce sys.setrecursionlimit(10**6) I=sys.stdin.readline def ii(): return int(I().strip()) def li(): return list(map(int,I().strip().split())) def mi(): return map(int,I().strip().split()) def ncr(n, r): r = min(r, n-r) numer = reduce(op.mul, range(n, n-r, -1), 1) denom = reduce(op.mul, range(1, r+1), 1) return numer // denom def gcd(x, y): while y: x, y = y, x % y return x def main(): n=ii() s=I().strip() d=defaultdict(int) for i in s: d[i]+=1 if len(d)>2: if d["I"]==1: print(1) else: print(0) else: if d["I"]==0: print(d["A"]) elif d["I"]==1: print(1) else: print(0) if __name__ == '__main__': main()
8
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { int n, r = 0; char s[200000]; cin >> n >> s; int a = 0, f = 0, i = 0; for (int j = 0; j < n; ++j) { if (s[j] == 'A') ++a; else if (s[j] == 'F') ++f; else if (s[j] == 'I') ++i; } if (i > 0) { cout << (i == 1 ? 1 : 0) << endl; } else { cout << (n - f) << endl; } return 0; }
8
CPP
n=int(input()) s=input() arr=[0]*3 c=0 for i in range(0,n): if s[i]=='A': arr[0]=arr[0]+1 if s[i]=='F': arr[1]=arr[1]+1 if s[i]=='I': arr[2]=arr[2]+1 for i in range(0,n): if s[i]=='A': if arr[2]==0: c=c+1 if s[i]=='I': if arr[2]-1==0: c=c+1 print(c)
8
PYTHON3
#include <bits/stdc++.h> using namespace std; int main() { long long int n, i, j, l, a[4] = {}, cnt = 0, maxi = 0; string s; cin >> n >> s; l = s.length(); for (i = 0; i < l; i++) { if (s[i] == 'A') { a[1]++; } else if (s[i] == 'F') { a[2]++; } else if (s[i] == 'I') { a[3]++; } } if (a[3] >= 2) { cout << "0\n"; } else if (a[3] == 1) { cout << "1\n"; return 0; } else { cout << a[1]; } return 0; }
8
CPP
#include <bits/stdc++.h> using namespace std; const int MAX = 200005; int a[MAX]; int main() { int n; cin >> n; string s; cin >> s; int a1 = 0, a2 = 0, a3 = 0; for (int i = 0; i < n; i++) { if (s[i] == 'A') { a1++; } else if (s[i] == 'I') { a2++; } else { a3++; } } if (a2 == 0) { cout << a1 << endl; } else { if (a2 == 1) { cout << 1 << endl; } else { cout << 0 << endl; } } return 0; }
8
CPP
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); long long n, A(0), I(0); string s; cin >> n >> s; for (int i = 0; i < n; i++) { if (s[i] == 'A') { A++; } else if (s[i] == 'I') { I++; } } if (I == 0) { cout << A << endl; } if (I == 1) { cout << I << endl; } else if (I > 1) { cout << 0 << endl; } return 0; }
8
CPP