Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; const long long modn = 1000000007; inline long long mod(long long x) { return x % modn; } string s; set<string> mp; int seen[10009][6]; void solve(int i, int pr) { if (i <= 5) return; if (seen[i][pr]) return; seen[i][pr] = 1; mp.insert(s.substr(i - 1, 2)); if (pr ...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; string s; map<string, bool> Hash; map<pair<int, int>, bool> HASH; int spl[1000011], spr[1000011]; bool ck(int l, int r) { if (HASH[make_pair(l, r)] == true) return false; return true; } int main() { string a, b; cin >> s; int n = s.size(); int q, p, l, r; q = ...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> #pragma GCC optimize("Ofast,unroll-loops") #pragma GCC target("avx,avx2,sse,sse2") using namespace std; using ll = long long; template <typename F> void multitest(F func) { int t; cin >> t; while (t--) func(); } void report(int ok) { cout << (ok ? "YES" : "NO") << '\n'; } int main() { c...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; void itval(istream_iterator<string> it) {} template <typename T, typename... Args> void itval(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; itval(++it, args...); } const long long int MOD = 1e9 + 7; template <typename T> inline voi...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> #pragma comment(linker, "/stack:336777216") #pragma GCC optimize("O3") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; using ui = unsigned int; template <typename T> ...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; const int N = 11111; const long long INF = 1e9 + 19; string s; void read() { cin >> s; } int dp[N][2]; void solve() { reverse(s.begin(), s.end()); for (int i = 0; i < 5; i++) s.pop_back(); int n = s.size(); dp[0][0] = 1; dp[2][0] = 1; dp[3][1] = 1; for (int i ...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; const int maxn = 20000 + 10; char str[maxn]; int n; bool oksuf[maxn][4]; set<string> ans; string getstr(int l, int r) { string s = ""; for (int i = l; i <= r; i++) { s.push_back(str[i]); } return s; } void prep() { memset(oksuf, 0, sizeof oksuf); n = strlen(...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; string s; bool dp[10005][4]; map<string, bool> used; vector<string> v; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> s; reverse(s.begin(), s.end()); dp[2][2] = true; dp[3][3] = true; int n = s.size(); for (int i = 2; i <= n...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
const memo = {}; const res = {}; function resolve(s, prev) { if (!memo[s + ' ' + prev]) { memo[s + ' ' + prev] = true; var suffix2 = s.slice(s.length - 2); if (suffix2 !== prev && s.length > 6) { res[suffix2] = true; resolve(s.slice(0, s.length - 2), suffix2); } var suffix3 = s.slice(...
JAVA
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
t = input() s, d = set(), set() p = {(len(t), 2)} while p: m, x = p.pop() r = m + x for y in [x, 5 - x]: l = m - y q = (l, y) if q in d or l < 5 or t[l:m] == t[m:r]: continue s.add(t[l:m]) d.add(q) p.add(q) print(len(s)) print('\n'.join(sorted(s)))
PYTHON3
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> const int N = 10010; bool dp[2][N]; char s[N]; std::set<std::string> set; int main() { scanf("%s", s); int len = strlen(s); std::reverse(s, s + len); dp[0][1] = dp[1][2] = true; for (int i = 3; i < len - 5; ++i) { dp[0][i] = dp[1][i - 2] || dp[0][i - 2] && (s[i] != ...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
import sys word = input() suffixes = set() possible = set() my_set = set() not_poss = set() possible.add((len(word), 2)) while possible: tam, x = possible.pop() a = tam + x for i in [x, 5 - x]: root = tam - i new_pos = (root, i) if root < 5 or new_pos in my_set or (word[root:ta...
PYTHON3
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; bool debug = 0; int n, m, k; int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0}; string direc = "RDLU"; long long ln, lk, lm; void etp(bool f = 0) { puts(f ? "Possible" : "Impossible"); exit(0); } void addmod(int &x, int y, int mod = 1000000007) { x += y; if (x >= mod...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> int main() { std::string s; std::cin >> s; int n = s.length(); std::set<std::string> res; bool dp2[n], dp3[n]; dp2[n - 1] = false; dp3[n - 1] = false; dp2[n - 2] = true; dp3[n - 2] = false; dp2[n - 3] = false; dp3[n - 3] = true; for (int i = n - 4; i >= 5; i--) { if ...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; const int maxn = 1e4 + 5; string s; set<string> res; int tot = 0; int vis[4][maxn]; void dfs(int cnt, int endd, int pa) { if (endd - cnt < 4 || vis[cnt][endd]) return; string t; bool flg = 1; for (int i = 0; i < cnt; i++) { t += s[endd - cnt + i + 1]; if (pa...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
// package RatingBased.R1800; import java.io.*; import java.util.*; /* Author - Ribhav MADE ON - 1/2/2019 */ public class CF666A { static FastReader s; static PrintWriter out; static String INPUT = "abcdeabzzzzzzzz\n"; static TreeSet<String> set; static int[] bool; public static void ...
JAVA
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; const int N = 4004; const int mod = 1e9 + 7; string s; int n; map<string, int> was, used; int w[100001]; int dp[10010][10]; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> s; n = s.length(); dp[n - 2][2] = 1; dp[n - 3][3] = 1; for (int i = n - 3; i >=...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
// package codeforces.cf3xx.cf349.div1; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.InputMismatchException; import java.util.List; /** * Created by hama_du on 2016/08/06. */ public class A { public stat...
JAVA
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; const int maxn = (int)1e5 + 5; string s; int n, can[maxn][2]; set<string> ans; int main() { cin >> s; n = s.size(); for (int i = n - 1; i >= 5; i--) { if (i == n - 1) { can[i][0] = 0; can[i][1] = 0; continue; } if (i == n - 2) { can...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; long long power(long long a, long long b, long long md) { return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2, md) % md : power(a * a % md, b / 2, md) % md)); } const int xn = 1e4 + 10; const int xm = -20 + 10; const int sq = 320; cons...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; int valid[10005]; string s; set<string> comb; int main() { cin >> s; if (s.size() < 7) { puts("0"); return 0; } string u; u = s.substr(((int)s.size()) - 2, 2); comb.insert(u); valid[((int)s.size()) - 2] += 2; if (((int)s.size()) >= 8) { u = s.sub...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << ": " << arg1 << endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ','); cerr.write(name...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; string s; set<string> S; bool dp2[10005], dp3[10005], dp[10005]; int main() { cin >> s; dp[s.size()] = 1; dp[s.size() - 1] = 0; for (int i = s.size() - 2; i >= 0; i--) { int x = s.size() - i; if (x >= 2) { char a = s[i], b = s[i + 1]; if (i + 3 >...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; int n; char ipt[10010]; bool dt[10005][2]; vector<string> ans; int main() { scanf("%s", ipt + 1); n = strlen(ipt + 1); dt[n - 1][0] = true; dt[n - 2][1] = true; for (int i = n - 3; i > 5; i--) { for (int k = 0; k < 2; k++) { if (dt[i + k + 2][k ^ 1]) { ...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; int muzu[10005][2]; int main(void) { int N; char Pole[10005]; int i; for (i = 0;; i++) { scanf("%c", &Pole[i]); if (Pole[i] == '\n') { N = i; break; } muzu[i][0] = 0; muzu[i][1] = 0; } muzu[N + 1][0] = 0; muzu[N + 1][1] = 0; v...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
import java.io.*; import java.util.*; public final class reberland { static FastScanner sc=new FastScanner(new BufferedReader(new InputStreamReader(System.in))); static PrintWriter out=new PrintWriter(System.out); static long mod1=1000000000+7,mod2=1000000000+9,base=37; static long[] pow1,pow2; public stat...
JAVA
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; const int MAXN = 10005; int N; string S; bool dp[MAXN][4]; set<string> ans; bool check(int idx, int len) { if (idx + 2 * len > N) return false; for (int i = 0; i < len; i++) if (S[idx + i] != S[idx + len + i]) return true; return false; } int main() { ios::sync_...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; bool dp[10010][2]; string ss[10010]; int main(void) { std::ios::sync_with_stdio(false); string s; cin >> s; int len = s.length(); set<string> res; if (len > 6) dp[len - 2][0] = 1, ss[len - 2] = s.substr(len - 2, 2), res.insert(ss[len - 2]); if...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
import java.util.Scanner; import java.util.Set; import java.util.TreeSet; public class Reberland_Linguistics_new { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String str = scan.nextLine(); Set<String> set=new TreeSet<String>(); set=doTheWork(str.length(),str,set); Sys...
JAVA
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
import java.util.*; public class suffix { public static void main(String[] args) { Scanner sc=new Scanner (System.in); String str=sc.nextLine(); str=str.substring(5); boolean[] fix=new boolean[26*26*27]; boolean[][] check=new boolean[str.length()+1][2]; for (int n=str.length(); n>1; n--) { if (n==str.l...
JAVA
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; void deba(int* a, int n) { cerr << "| "; for (int i = 0; i < (n); i++) cerr << a[i] << " "; cerr << "|" << endl; } inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; } const int INF = 1 << 30; char s[12345]; vector<string> out; vector<string> ou; bool en(...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; long long pwr(long long base, long long p, long long mod = (1000000007LL)) { long long ans = 1; while (p) { if (p & 1) ans = (ans * base) % mod; base = (base * base) % mod; p /= 2; } return ans; } string str; bool allowed[100025][5]; int n; set<string> a...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
import java.util.Scanner; import java.util.TreeSet; public class ReberlandLinguistics { Scanner sc = new Scanner(System.in); private String s; private int n; private boolean[][] v; private boolean[][] m; private TreeSet<String> set; public ReberlandLinguistics(String s) { this.s = s; this.n = this.s.length...
JAVA
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
import java.util.Scanner; import java.util.TreeSet; public class ReberlandLinguistics { static String s; static int n; static boolean valid(int pos, int chars) { if(pos - chars < 0)return true; for(int i = pos-chars+1; i <= pos; i++) { if(s.charAt(i) != s.charAt(i-chars)) return true; } ret...
JAVA
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; const int MaxN = 1e5 + 10; vector<string> tot[MaxN]; int cnt; char s[MaxN]; bool check[MaxN], flag; set<string> ans; int main() { scanf("%s", s); int len = strlen(s); check[len] = 1; for (int i = len - 2; i >= 5; i--) { if (check[i + 2]) { string t; ...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ //System.out.println(); public class Solution { public static void main (String[] args) throws java.lang.Exception { BufferedReade...
JAVA
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; int dp[500005]; int main() { string a, ans; set<string> s; cin >> a; int len = a.length(); dp[len] = 1; for (int i = len - 1; i > 4; i--) { for (int l = 2; l <= 3; l++) { if (dp[i + l]) { ans = a.substr(i, l); if (a.find(ans, i + l) != ...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; char ss[11111]; string s; int n; set<string> used; int can2[11111]; int can3[11111]; int main() { scanf("%s", ss); s = ss; n = (int)(s).size(); can2[n - 2] = 1; can3[n - 3] = 1; for (int i = n - 4; i >= 5; --i) { if (((s[i] != s[i + 2] || s[i + 1] != s[i + 3...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
lectura = input() sufix = set() comb = {(len(lectura), 2)} setPrueba = set() while comb: x, y = comb.pop() pos3 = x + y for i in [y, 5 - y]: posIni = x - i stringActual = (posIni, i) if ( stringActual in setPrueba or (posIni < 5) or (lectura[posIni:x] == lectura[x:pos3]) ): ...
PYTHON3
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
from sys import * setrecursionlimit(20000) dp = [] ans = [] def fun(s, pos, r, ln): if pos <= 4+ln: return 0 if dp[pos][ln-2] != 0: return dp[pos][ln-2] if s[pos-ln:pos] != r: dp[pos][ln-2] = 1 + fun(s, pos - ln, s[pos-ln:pos],2) + fun(s, pos - ln, s[pos-ln:pos],3) ans.append(s[pos-ln:pos]) ''' if pos > 4+l...
PYTHON3
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
d = {} data = raw_input() l = len(data) if l <= 6: print 0 else: dp = [[0 for x in xrange(4)] for y in xrange(l)] dp[l - 2][2] = 1 d[data[-2:]] = 1 if l > 7: dp[l - 3][3] = 1 d[data[-3:]] = 1 for i in xrange(l - 2, 5, -1): for j in xrange(2, 4): if dp[i][j] == 1: if i - 2 >= 5 and data[i - 2:i] != da...
PYTHON
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
import sys sys.setrecursionlimit(100000) '''def query(curr,lasti): global s if curr==len(s):return 1 if dp[curr][lasti]!=-1:return dp[curr][lasti] last=s[curr-(lasti+2):curr] ans=0 for i in xrange(2,4): if curr+i<=len(s): u=s[curr:curr+i] if u!=last: ...
PYTHON
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; const int MAXN = 100000 + 5; const int MAXM = 26 + 3; char str[MAXN]; int treecnt; string out[MAXN]; int vis2[MAXN], vis3[MAXN]; int len; bool check(int st, int l) { int ok = 0; if (st + 2 * l > len) { if (st + 2 * l != len + 1) return false; return true; } ...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; int HashVal(const string& S) { int h = 0; for (int i = 0; i < S.size(); i++) { h = h * 27 + S[i] - 'a' + 1; } return h; } map<pair<int, int>, bool> hashed; string S; int dp[11111][5]; bool Can(int prevpos, int pos) { int L = S.size(); if (pos == L) return tr...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> const int MAXN = 1e5 + 5; std::string str; int n; int f[MAXN][2]; int main() { std::ios::sync_with_stdio(false); std::cin >> str; int n = str.length(); if (n <= 5) { puts("0"); return 0; } f[n + 1][0] = f[n + 1][1] = 1; for (int i = n; i >= 6; --i) { for (int j = 0; j ...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; long long rdtsc() { long long tmp; asm("rdtsc" : "=A"(tmp)); return tmp; } inline int myrand() { return abs((rand() << 15) ^ rand()); } inline int rnd(int x) { return myrand() % x; } void precalc() {} const int maxn = 1e4 + 10; int n; char s[maxn]; bool read() { if ...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
import java.io.*; import java.math.BigInteger; import java.math.RoundingMode; import java.text.DecimalFormat; import java.util.*; public class maind2 { static double eps=(double)1e-6; static long mod=(int)1e9+7; public static void main(String args[]){ InputReader in = new InputReader(System.in); ...
JAVA
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; set<string> out; string in; set<pair<int, string> > visited; void DP(int pos, string prev) { if (pos <= 5) return; pair<int, string> tmp = make_pair(pos, prev); if (visited.find(tmp) != visited.end()) return; visited.insert(tmp); string s = ""; if (pos >= 6) { ...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; signed main() { string s; cin >> s; int n = (int)s.size(); vector<vector<bool>> dp(n, vector<bool>(2)); dp[n - 1][0] = (n >= 7); dp[n - 1][1] = (n >= 8); for (int i = n - 3; i >= 6; --i) { string sub2 = s.substr(i - 1, 2); string sub3 = s.substr(i - 2,...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
import java.util.Scanner; import java.util.TreeSet; public class ReberlandLinguistic { Scanner sc = new Scanner(System.in); String s; int n; boolean[][] v; boolean[][] memo; TreeSet<String> set; void run() { s = sc.next(); n = s.length(); set = new TreeSet<>(); v = new boolean[n + 5][5]; memo = new b...
JAVA
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; const long long int INF = (long long int)1e9 + 10; const long long int INFLL = (long long int)1e18 + 10; const long double EPS = 1e-8; const long long int MOD = 1e9 + 7; template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); } template <class T> T &chmax(T ...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using ii = pair<ll, ll>; using vi = vector<ll>; using vb = vector<bool>; using vvi = vector<vi>; using vii = vector<ii>; using vvii = vector<vii>; const int INF = 2000000000; const ll LLINF = 9000000000000000000; int main() { ...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; string s; int dp[10001][4]; set<string> root; void solve(int x, string str) { if (x < 6) { return; } if (dp[x][str.length()] != -1) { return; } dp[x][str.length()] = 1; if (x >= 6) { string s1 = s.substr(x - 1, 2); if (s1 != str) { root.ins...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> #pragma GCC optimize("O3") using namespace std; using ll = long long; const char E = '\n'; const int N = 10005; const ll mod = 1e9 + 7; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); string s; bool dp[N][2] = {0}; set<string> u; int n; cin >> s; n = s.size...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; set<string> setzera; string s; int len; map<pair<int, string>, int> dp; void solve(int pos, string last) { pair<int, string> state(pos, last); if (pos - 1 <= 4) return; if (dp.count(state)) return; dp[state] = 1; string s2 = s.substr(pos - 1, 2); if (s2 != last)...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; const long long MOD = 1000000007; long long fast_exp(long long base, long long exp, long long mod) { long long res = 1; while (exp > 0) { if (exp % 2 == 1) res = (res * base) % mod; base = (base * base) % mod; exp /= 2; } return res; } set<pair<int, stri...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
word=raw_input() L=len(word) suffixlist=[] l1=list(word) l1.reverse() rvrsword=''.join(l1) dp2=[] dp3=[] if(L<=6): print '0' else: dp2.append(False) dp3.append(False) dp2.append(True) suffixlist.append(rvrsword[0:2]) dp3.append(False) n=2 if(n+1<=L-5): dp2.append(False) d...
PYTHON
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; const int N = 1e4; char s[N + 3]; bool v[2][N + 3]; set<string> ans; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout << fixed; cin >> s; int n = strlen(s); v[0][n] = v[1][n] = true; for (int i = n - 2; i > 4; i--) { ...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; string S; set<string> SS; int mem[4][10100]; int dp(int psz, int i) { if (i >= S.size()) return 1; if (mem[psz][i] != -1) return mem[psz][i]; string p = S.substr(i - psz, psz); int w = 0; for (int j = 2; j <= 3; ++j) { if (i + j <= S.size()) { string n =...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> inline long long read() { long long x = 0; char c = getchar(), f = 1; for (; c < '0' || '9' < c; c = getchar()) if (c == '-') f = -1; for (; '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0'; return x * f; } inline void write(long long x) { static char buf[20]; int len...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
import java.util.Scanner; import java.util.TreeSet; public class C { static TreeSet<String> set = new TreeSet<>(); public static void main(String[] args) throws Exception { Scanner in = new Scanner(System.in); char[] a = in.next().toCharArray(); int n = a.length; boolean[][] dp = new boolean[n+1]...
JAVA
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.io.Writer; import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection...
JAVA
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; string s; int len; set<string> v; bool check[111111][5]; void fuck(string father, int now) { if (now - 2 > 4) { string now1 = s.substr(now - 2, 2); if (now1 != father) { v.insert(now1); if (check[now - 2][2] == true) check[now - 2][2] = false, ...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; char s[10010]; map<int, bool> g[10010]; int i, ans, now, n, last, l; int Map_2[100010], Map_3[100010], a[10010]; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch <=...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); string s; cin >> s; long long n = s.length(); reverse(s.begin(), s.end()); set<string> ans; vector<bool> dp2(n + 1, 0), dp3(n + 1, 0); dp2[1] = 1; dp3[2] = 1; for (long long i = ...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; set<string> poss; string s; int dp[10001][4]; int vis[10001][4]; int solve(int idx, int len) { if (dp[idx][len] != -1) return dp[idx][len]; int &ret = dp[idx][len]; if (idx >= 4) ret = 1; else return 0; if (len != 3) ret |= solve(idx - 3, 3); if (len != ...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; long long a[10010], b[10010], c[10010]; long long n, m, k, t, r, aux, rta; string s, s2; int dp[10010][4]; vector<string> v; bool dist(int i, int j, int sz) { if (j + sz > n) return true; for (int q = 0; q < (sz); q++) { if (s[i + q] != s[j + q]) return true; } ...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; string s; set<string> r; set<string> u[11111]; void go(int pos, string prev) { if (u[pos].count(prev)) return; u[pos].insert(prev); if (pos - 2 >= 4) { string t = s.substr(pos - 1, 2); if (prev != t) { r.insert(t); go(pos - 2, t); } } if (p...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
/* If you want to aim high, aim high Don't let that studying and grades consume you Just live life young ****************************** What do you think? What do you think? 1st on Billboard, what do you think of it Next is a Grammy, what do you think of it However you think, I’m sorry, but shit, I have no fcking inter...
JAVA
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
import java.util.Scanner; import java.util.Set; import java.util.TreeSet; public class Node { static String s=""; static int[][] dp; static Set<String> set=new TreeSet<>(); public static void main(String[] args) { Scanner sc=new Scanner(System.in); s=sc.nextLine(); dp=new int[s.length()][2]; int n=s.len...
JAVA
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; const int MAXN = 10000 + 5; bool dp[MAXN][4]; set<string> s; string A; void solve(int n) { memset(dp, 0, sizeof(dp)); for (int i = n - 1; i >= 5; i--) { for (int j = 2; j <= 3; j++) { if (i + j == n) { dp[i][j] = 1; } else { for (int k = ...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; char s[10010]; char c[27] = {'a', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'}; bool ans[27][27][27], f[10010][4]; int l, i, j, k, num; int main() { scanf("%s"...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
import java.io.*; import java.util.*; public class A { public static void solution(BufferedReader reader, PrintWriter out) throws IOException { In in = new In(reader); String s = in.next(); int n = s.length(); TreeSet<String> suffix = new TreeSet<String>(); boole...
JAVA
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; const long long OO = 1e12; const double EPS = (1e-7); int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; } string root; set<string> myset; vector<string> generate(string s, int l) { vector<string> g(2); for (int i = 0; i < (int)(s.size() - l)...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
import java.util.*; import java.io.*; public class ReberlandLinguistics { public static InputReader in; public static PrintWriter out; public static final int MOD = (int) (1e9 + 7); public static void main(String[] args) { in = new InputReader(System.in); out = new PrintWriter(System.out); String...
JAVA
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); string s; cin >> s; set<string> st; int n = s.size(); vector<vector<bool> > dp(n, vector<bool>(4)); for (int i = n - 2; i >= 5; i--) { for (int j = 2; j <= 3; j++) { ...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; template <class T, class U> inline void chmin(T &t, U f) { if (t > f) t = f; } template <class T, class U> inline void chmax(T &t, U f) { if (t < f) t = f; } long long N; char S[11111]; long long ex[27 * 26 * 26]; long long dp[11111][2]; long long get(long long l, long ...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5 + 5; bool can[MAXN][5]; vector<string> sol; int main() { string s; cin >> s; int n = s.size(); s += "###"; can[n][2] = can[n][3] = true; for (int i = n - 1; i >= 0; --i) { if (i <= 4) break; if (can[i + 2][2] && s.substr(i, 2) != s.s...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10; const int inf = 1e9; string s; int n; bool dp[maxn][3]; string substr(int l, int r) { string ans; for (int i = l; i < r; i++) { ans += s[i]; } return ans; } int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); ci...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; int main() { string word; int rem; set<string> suff; string aux1, aux2, aux3, aux4; int duo; int trio; cin >> word; if (word.size() <= 5) { cout << 0; return 0; } else { duo = word.size() - 4; trio = word.size() - 5; for (int i = word.s...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> #pragma GCC optimize("O2") using namespace std; set<string> ans; string s; int n; const int N = 1e4; int dp[N][4]; void go(int pos, int num) { if (dp[pos][num]) return; dp[pos][num] = 1; string last = ""; if (num) last = s.substr(pos + 1, num); if (pos - 1 >= 5 && s.substr(pos - 1, 2)...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; template <typename T> void get_int(T &x) { char t = getchar(); bool neg = false; x = 0; for (; (t > '9' || t < '0') && t != '-'; t = getchar()) ; if (t == '-') neg = true, t = getchar(); for (; t <= '9' && t >= '0'; t = getchar()) x = x * 10 + t - '0'; if ...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; class ReberlandLinguistics { private: string data_; int n_; set<string> suffixes_; set<pair<int, string> > visited_; void solve(int, string); public: ReberlandLinguistics(); }; ReberlandLinguistics::ReberlandLinguistics() { getline(cin, data_); solve(data...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; set<string> ans; map<int, int> mm; int main() { string s; cin >> s; int i, j, len, k, l; len = s.length(); if (len >= 8) { ans.insert(s.substr(len - 3, 3)); ans.insert(s.substr(len - 2, 2)); mm[len - 3] = 1; mm[len - 2] = 1; } else if (len >= 7) ...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; int main() { string str; cin >> str; int d[100007][4]; int n = str.size(); d[n - 2][2] = d[n - 3][3] = 1; vector<string> ans; for (int i = n - 4; i > 4; i--) { for (int j = 2; j <= 3; j++) { for (int h = 2; h <= 3; h++) { if (i + j + h > n ||...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.util.Set; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.TreeSet; import java.io.InputStream; /**...
JAVA
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; bool mat[10000][10000] = {false}; vector<string> vec; string word; int suff(int size, int len, int past) { if (len - size < 4 || mat[size][len]) return 0; string ans; bool flg = false; for (int i = 0; i < size; i++) { ans += word[len - size + i + 1]; if (pas...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; const int N = 10000 + 1; bool possible[N][2]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); string s; cin >> s; int n = s.size(); for (int i = 0; i < 2; ++i) { possible[n][i] = true; } set<string> ans; for (int i = n - 1; i > 4; --i)...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; bool dp[10005][5]; int main() { string s; cin >> s; set<string> f; int n = s.size(); s += "$$$"; dp[n][2] = dp[n][3] = true; for (int i = n - 1; i >= 5; --i) { if (i + 2 <= n && (dp[i + 2][2] && s.substr(i + 2, 2) != s.substr(i, 2) || ...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
s = input() n = len(s) s += '0000000000' dp = [[0] * 2 for i in range(n + 5)] dp[n] = [1, 1] res = set() for i in range(n - 1, 4, -1): if i + 2 <= n and ((dp[i + 2][0] and s[i: i + 2] != s[i + 2: i + 4]) or dp[i + 2][1]): res.add(s[i: i + 2]) dp[i][0] = 1 if i + 3 <= n and ((dp[i + 3][1] and s[i...
PYTHON3
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; template <class T> void chmin(T& a, const T& b) { if (a > b) a = b; } template <class T> void chmax(T& a, const T& b) { if (a < b) a = b; } string s; int N; set<string> ans; int dp[10010][4]; int main() { cin >> s; N = (int)s.size(); s += "$$"; dp[N][2] = 1; f...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.TreeSet; public class Solution { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); char[] arr = reade...
JAVA
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; const double PI = acos(-1.0); const double eps = 1e-8; const int mod = 1e9 + 7; const int inf = 1061109567; const int dir[][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}}; set<string> s; string str; int vis[10005][4]; void dfs(int pos, int len) { if (pos < 5) return; vis[pos][...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long double E = 1e-10; char ccc; bool _minus = false; inline void read(int &n) { n = 0; _minus = false; while (true) { ccc = getchar(); if (ccc == ' ' || ccc == '\n') break; if (ccc == '-') { _minus = true; ...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int N = 4e5 + 10; const int INF = 1000000000; const int inf = 1e9 + 1; const double eps = 1e-9; set<string> ans; string s; bool go[N][3]; bool equals(int pos, int la, int lb) { if (pos == 0) { return false; } if (la != lb) { retu...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#!/usr/bin/env python def try_split(word, last_suff, len_suff): if len(word) - len_suff <= 4: return (None, None) new_suffix = word[-len_suff:] if new_suffix != last_suff: return word[:-len_suff], new_suffix return (None, None) def get_suff(stack, last, passed, found): while len(st...
PYTHON
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; template <typename Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << std::endl; } template <typename Arg1, typename... Args> void __f(const char* names, Arg1&& arg1, Args&&... args) { const char* comma = strchr(names + 1, ','); cerr.writ...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; char s[10100], ss[10100]; vector<string> q; bool g[10100][2]; bool check(int i, int j, int l) { for (int t = 0; t < l; t++) if (ss[i + t] != ss[j + t]) return 1; return 0; } void get(int i, int l) { string s1; for (int t = 0; t < l; t++) s1 += ss[i - t - 1]; q...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
#include <bits/stdc++.h> using namespace std; int dp[20000 + 100][4]; int main() { string ss; string next = ""; map<string, int> mp; cin >> ss; dp[ss.size()][2] = dp[ss.size()][3] = 1; for (int i = ss.size() - 1; i > 4; i--) { if (i + 2 <= ss.size()) { if (dp[i + 2][3] || (dp[i + 2][2] &...
CPP
666_A. Reberland Linguistics
First-rate specialists graduate from Berland State Institute of Peace and Friendship. You are one of the most talented students in this university. The education is not easy because you need to have fundamental knowledge in different areas, which sometimes are not related to each other. For example, you should know l...
2
7
import java.util.*; import java.io.*; public class A { public static void main(String[] args) throws Exception { FastScanner in = new FastScanner(System.in); PrintWriter out = new PrintWriter(System.out); char[] s = in.next().toCharArray(); boolean[][] dp = new boolean[2][s.length + 1]; dp[0][s.length...
JAVA