source_code
stringlengths
26
62k
lang_cluster
stringclasses
11 values
src_uid
stringlengths
32
32
code_uid
stringlengths
32
32
difficulty
int32
-1
3.5k
exec_outcome
stringclasses
1 value
// In The Name Of God. // 27/11/2015 // 1394/09/06 #include <iostream> #include <string> using namespace std; int main() { string s, ss; bool ab = false, ba = false; cin >> s; ss = s; for (int i = 1; i < s.size(); i++) { if (s[i-1] == 'A' && s[i] == 'B' && !ab) { ab = true; s[i-1] = '.'; s[i] = '....
C++
33f7c85e47bd6c83ab694a834fa728a2
0ae7de357202b6230b460f1153884569
1,500
PASSED
#include <iostream> #include <fstream> #include<algorithm> #include<vector> #include<string> using namespace std; std::string f( std::string ss ) { if( ss.size()<=3 ) return "NO"; int pos_1_ab = ss.find("AB"); int pos_2_ab = ss.rfind("AB"); int pos_1_ba = ss.rfind("BA"); int pos_2_ba = ss.find("BA"); if( pos_1_a...
C++
33f7c85e47bd6c83ab694a834fa728a2
ce13b85b125d206989f467ad87027743
1,500
PASSED
#include <iostream> #include <fstream> #include <string> #include <stdlib.h> #include <set> #include <vector> #include <list> #include <algorithm> #include <regex> #include <math.h> #include <map> #include <iterator> #include <climits> #include <numeric> using namespace std; typedef int integer; #define int long long ...
C++
33f7c85e47bd6c83ab694a834fa728a2
ebeae382b255e2da4ca35157affe48ec
1,500
PASSED
#include<vector> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include <string> using namespace std; void main() { string s; bool FA = false, FB = false; cin >> s; for (int i = 0; i < s.size(); i++) { if (s[i] == 'A' && s[(i + 1 == s.size() ? i : i + 1)] == 'B' &&!FA) { FA = tr...
C++
33f7c85e47bd6c83ab694a834fa728a2
b86c049fea660a2a6f439a5b1eba54b4
1,500
PASSED
#include <iostream> #include <string> using namespace std; int main() { string s; cin >> s; if (s.length() < 4) { cout << "NO"; return 0; } int i = 0; bool flag = false; for (; i < s.length() - 1; i++) { if (s[i] == 'A' && s[i + 1] == 'B') { ...
C++
33f7c85e47bd6c83ab694a834fa728a2
303e275d7031f948bfa1db5ac2aaec50
1,500
PASSED
#include<iostream> #include<string> using namespace std; int main() { string s; getline(cin, s); int ls = s.length(); bool ab = false, ba = false; int aba = 0; for (int i = 0; i < ls-1; i++) { if ((ls - i - 2 )>2) if ((s[i] == 'A'&&s[i + 1] == 'B'&&s[i + 2] == 'A') || (s[i] == 'B'&&s[i + 1] == 'A'&&s[i + 2...
C++
33f7c85e47bd6c83ab694a834fa728a2
bcf5d04eb34fa415dccaa7fc7b8b4b0c
1,500
PASSED
#include <iostream> #include <string> #include <vector> #include <set> #include <map> #include <algorithm> #include <cmath> #include <unordered_map> #include <unordered_set> #include <deque> #include <queue> #include <stack> #include <string.h> #include <iterator> using namespace std; typedef long long ll; typedef un...
C++
33f7c85e47bd6c83ab694a834fa728a2
1a9cd5607500891b55b3d4d275528683
1,500
PASSED
#pragma warning (disable : 4996) #include <stdio.h> #include <math.h> char s[100001]; bool s1[100000]; bool s2[100000]; void main(){ int r1 = 0, r2 = 0; int index1 = -1, index2 = -1; int result = 0; int first[3] = { -1, -1, -1 }, last[3] = { -1, -1, -1 }; scanf("%s", s); for (int i = 0; s[i] != NULL; i++){ if ...
C++
33f7c85e47bd6c83ab694a834fa728a2
c6ea9ef3f5c21522402d592fc191956d
1,500
PASSED
# define _CRT_SECURE_NO_WARNINGS # include <iostream> # include <cstdio> # include <string> # include <cmath> # include <cstdlib> # include <sstream> # include <fstream> # include <vector> # include <stack> # include <cctype> # define pi 2*cos(0.) # define e exp(1.) using namespace std; string s; char c[200]; int ma...
C++
33f7c85e47bd6c83ab694a834fa728a2
7d83e0e924214d6e7b7cba5962f2c161
1,500
PASSED
/*input Blb */ #include<bits/stdc++.h> using namespace std; #define ll long long int main() { string s; cin>>s; map<char, int> m; // Bulbasaur B:1 u:2 l:1 b:1 a:2 s:1 r:1 for(int i = 0; i < s.size(); i++) { if(s[i] == 'B' || s[i] == 'u' || s[i] == 'b' || s[i] == 'a' || s[i] == 's' || s[i] == 'r' || s[i] == 'l')...
C++
9c429fd7598ea75acce09805a15092d0
290865abaabe190ed575630a3ea04305
1,000
PASSED
#include <iostream> #include <cstring> int main() { std::string s; std::cin >> s; char ch[100001]; strcpy(ch, s.c_str()); int answer = 0; unsigned long timesMeeted[7] = {0}; for(int i = 0; i < s.size(); i++){ switch (ch[i]) { case 'B': timesMeeted[0]++; ...
C++
9c429fd7598ea75acce09805a15092d0
38b78da8c327dc67af95782ea1ef4377
1,000
PASSED
#include <iostream> #include <cstring> int main() { std::string s; std::cin >> s; char ch[100002]; strcpy(ch, s.c_str()); int answer = 0; unsigned long timesMeeted[7] = {0}; for(int i = 0; i < s.size(); i++){ /*if(ch[i] == 'B'){ timesMeeted[0]++; continue; ...
C++
9c429fd7598ea75acce09805a15092d0
278535cc5ad1540d411655aa0185f757
1,000
PASSED
#include<bits/stdc++.h> using namespace std; int main() { string str; cin>>str; int B=0,u=0,l=0,b=0,a=0,s=0,r=0; for(int i=0; i<str.size(); i++) { if(str[i]=='B') B++; if(str[i]=='u') u++; if(str[i]=='l') l++; if(str[i]=='b') ...
C++
9c429fd7598ea75acce09805a15092d0
4e1cbc8e54a086e743886a1a15d06239
1,000
PASSED
#include<bits/stdc++.h> using namespace std; int main() { string str; cin>>str; int B=0,u=0,l=0,b=0,a=0,s=0,r=0; for(int i=0; i<str.size(); i++) { if(str[i]=='B') B++; if(str[i]=='u') u++; if(str[i]=='l') l++; if(str[i]=='b') ...
C++
9c429fd7598ea75acce09805a15092d0
8ae4fdd7575b577e97fd0e47c08c4318
1,000
PASSED
#include<bits/stdc++.h> #define mod 1000000007 #define ll long long #define vll vector<ll> #define pll vector< pair<ll,ll> > #define pb push_back #define pob pop_back ...
C++
9c429fd7598ea75acce09805a15092d0
1ce34949354b3ad4d9431fc5f9360bf6
1,000
PASSED
#include <iostream> #include<cmath> #include <iomanip> #include <bits/stdc++.h> using namespace std; int main () { ios_base::sync_with_stdio(false); cin.tie(NULL); string q; cin>>q; int B=0,u=0,l=0,b=0,a=0,s=0,r=0; for (int i=0;i<q.length();i++) { if (q[i]=='B') B++; ...
C++
9c429fd7598ea75acce09805a15092d0
e14846afa1e8adacde52be2e9ab2f01a
1,000
PASSED
#include <iostream> #include<cmath> #include <iomanip> #include <bits/stdc++.h> using namespace std; int main () { ios_base::sync_with_stdio(false); cin.tie(NULL); string q; cin>>q; int B=0,u=0,l=0,b=0,a=0,s=0,r=0; for (int i=0;i<q.length();i++) { if (q[i]=='B') B++; ...
C++
9c429fd7598ea75acce09805a15092d0
5baf285cdcd8fd2053ae505a170d531d
1,000
PASSED
#include<bits/stdc++.h> using namespace std ; int ar [1000005] ; int main() { string s ; cin >> s ; for (int i = 0 ; i<s.length();i++) { ar[(int)s[i]]++; } //Bulbbasaur for (int i=1000005;i>=0;i--) { if (ar[(int)'B']>=i && ar[(int)'u']>=i*2 && ar[(int)'l']>...
C++
9c429fd7598ea75acce09805a15092d0
292306ded6a61586bab7870d61041a29
1,000
PASSED
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main() { string s, a = "Bulbasaur"; cin >> s; int c = 0; int ans = 0; map<char, int>f1; for (int i = 0; i < s.size(); ++i) { ++f1[s[i]]; } bool o=1; while(o){ for(int i =0 ; i <a.size();++i) if(--f1[a[i]]>=0); else o=0; ++an...
C++
9c429fd7598ea75acce09805a15092d0
b8e1192b54a782cd68927b6262f27823
1,000
PASSED
#include<bits/stdc++.h> using namespace std; typedef long long int ll; struct Z2Basis{ ll a[53]; int sz; void add(ll x){ for(int i=0;i<53;i++) if((x>>i)&1){ if((a[i]>>i)&1) x^=a[i]; else{ a[i]=x; sz++; return; } } } void norm(){ for(int i=0;i<53;i++) for(int j=0;j<i;j...
C++
6b9cc10c1f4eaf2a1436a81c8ecca6f6
9e02ac9dd1678fb91403b9a9320c1b6b
3,500
PASSED
#pragma GCC optimize("Ofast") #pragma GCC target("avx2") // iostream is too mainstream #include <cstdio> // bitch please #include <iostream> #include <algorithm> #include <vector> #include <set> #include <map> #include <queue> #include <stack> #include <list> #include <chrono> #include <random> #include <cstdlib> #incl...
C++
6b9cc10c1f4eaf2a1436a81c8ecca6f6
b84caa88bb97acd91d7d6ff14ad061ed
3,500
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 200000 + 10, M = 54, mod = 998244353; void add(ll &x,ll y){ (x += y) %= mod; } void dfs(int i,ll x,vector<ll> &v,ll p[]){ if(i==(int)v.size()) p[__builtin_popcountll(x)]++; else dfs(i+1,x,v,p), dfs(i+1,x^v[i],v,p); } ll a[M],b...
C++
6b9cc10c1f4eaf2a1436a81c8ecca6f6
9ac90230292f7fc511e14453051c229c
3,500
PASSED
#include <bits/stdc++.h> using namespace std; using ll=long long; #define int ll #define rng(i,a,b) for(int i=int(a);i<int(b);i++) #define rep(i,b) rng(i,0,b) #define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--) #define per(i,b) gnr(i,0,b) #define pb push_back #define eb emplace_back #define a first #define b second ...
C++
6b9cc10c1f4eaf2a1436a81c8ecca6f6
9d51e4610987158839904cf3330a10e6
3,500
PASSED
#pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #pragma GCC target("avx,avx2,sse,sse2,ssse3,popcnt,sse4.1,sse4.2,tune=native") #include<bits/stdc++.h> #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define pb push_back using namespace std; using ll = long long; //using arr = arra...
C++
6b9cc10c1f4eaf2a1436a81c8ecca6f6
2023ec773f534cbd7c480f884b799b4a
3,500
PASSED
// Words are flowing out like endless rain into a paper cup // They slither while they pass they slip away across the universe // Pools of sorrow, waves of joy are drifting through my open mind // Possessing and caressing me #include <bits/stdc++.h> using namespace std; using LL = long long; namespace _buff { const...
C++
6b9cc10c1f4eaf2a1436a81c8ecca6f6
eaed7725593ced2b87c070f2d26285d2
3,500
PASSED
#include <bits/stdc++.h> using namespace std; using i64 = long long; const int maxN = 223456; const int P = 998244353; int n, m, rnk; i64 base[maxN], p[maxN], dp[60][60][2]; int cnt[maxN], ans[maxN]; void dfs1(int d, i64 x) { if (d == rnk) { cnt[__builtin_popcountll(x)]++; } else { dfs1(d + 1, x); dfs1(d...
C++
6b9cc10c1f4eaf2a1436a81c8ecca6f6
0110bea14f51565ae96590bde7d79670
3,500
PASSED
#pragma GCC optimize("O3") #ifdef ONLINE_JUDGE #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #endif #pragma GCC optimize("unroll-loops") #pragma comment(linker, "/stack:200000000") #include <bits/stdc++.h> #include <deque> #include <type_traits> #include <string.h> #include <stdlib.h> #i...
C++
6b9cc10c1f4eaf2a1436a81c8ecca6f6
a9ae8a961417bacc5a81877bac9f043c
3,500
PASSED
#include<bits/stdc++.h> #define it register int #define ct const int #define il inline typedef long long ll; #define rll register ll #define cll const ll #define P 998244353 const int N=70,M=1000005; int n,m,k,tot,ans[N],cn[N],pw[M],c[N][N],w[N][N]; ll a[M],b[N],o[N],tb[N]; il void ins(rll x){ for(it i=m;~i;--i) ...
C++
6b9cc10c1f4eaf2a1436a81c8ecca6f6
130ae397ee2f16b3cb6680ee7e6233e6
3,500
PASSED
#include<bits/stdc++.h> #define ll long long using namespace std; const int maxN=200005,maxM=60,p=998244353; void MOD(int &x) { if(x>=p)x-=p; } int N,M,K; ll A[maxM],B[maxM]; int pow2[maxN],ipow2[maxM]; void Insert(ll x) { for(int i=M-1;~i;i--) if((x>>i)&1) { if(A[i])x^=A[i]; else { A[i]=x,K++; return; ...
C++
6b9cc10c1f4eaf2a1436a81c8ecca6f6
a8964f8b859912502988901f0682416f
3,500
PASSED
#pragma comment(linker, "/STACK:1000000000") #define _CRT_SECURE_NO_WARNINGS #include <functional> #include <algorithm> #include <iostream> #include <fstream> #include <vector> #include <string> #include <cmath> #include <queue> #include <stack> #include <ctime> #include <set> #include <map> #include <locale> #include...
C++
d8c89bb83592a1ff1b639f7d53056d67
314d76941bc64da60dad51a4a186e55c
1,400
PASSED
//InTheNameOfGOD //Do_You_Wonder_Why_I_Prefer_To_Be_aLoNe? #include <bits/stdc++.h> #define ll long long #define F first #define S second #define PB push_back #define pii pair <int, int> #define Ashar fixed << setprecision(9) #define Mod 1000000007 using namespace std; const int maxn = 2e3 + 10; char a[maxn][maxn]...
C++
d8c89bb83592a1ff1b639f7d53056d67
ee862092b89ffbde67cd44cb4e29039d
1,400
PASSED
#include <algorithm> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #define N 2020 #define M 2020 using namespace std; int n, m; char s[N][M]; bool check(const int &x, const int &y, const int &c) { return x >= 0 && x < n && y >= 0 && y < m && s[x][y] == c; } int main(void) { int ...
C++
d8c89bb83592a1ff1b639f7d53056d67
008f7afb63e1aec29611694ac172fa23
1,400
PASSED
#include<cstring> #include<cstdio> #include<vector> #include<iostream> #include<string> #include<queue> #include<map> #include<set> #include<cmath> #include<algorithm> #include<stack> using namespace std; typedef long long LL; char ch[2010][2010]; int a[2010][2010]; int sum[2010]; int main(){ int n,m,p; scanf(...
C++
d8c89bb83592a1ff1b639f7d53056d67
5655a5b4a18520235d2873114b4215e5
1,400
PASSED
#include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define si(X) scanf("%d", &(X)) #define sll(X) scanf("%lld",&(X)) #define INFL 0x3f3f3f3f3f3f3f3fLL ll gcd(ll a,ll b){ if(b==0) return a; return gcd(b,a%b); } string toBin(ll a) { string res = ""; while (a) { res +=...
C++
d8c89bb83592a1ff1b639f7d53056d67
a9b2d4d5f41acbd7c9c736a44cd29f0c
1,400
PASSED
#include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define si(X) scanf("%d", &(X)) #define sll(X) scanf("%lld",&(X)) #define INFL 0x3f3f3f3f3f3f3f3fLL ll gcd(ll a,ll b){ if(b==0) return a; return gcd(b,a%b); } string toBin(ll a) { string res = ""; while (a) { res +=...
C++
d8c89bb83592a1ff1b639f7d53056d67
4ccac582144f8ee452d2ac08927124fb
1,400
PASSED
#include<iostream> #include<cstdlib> #include<vector> using namespace std; int main(){ int n,m,k; cin >> n >> m >> k; vector<int> res(m); char a; for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ cin >> a; if(a==*"R"){ if(j+i<m)res[j+i]++; } if(a==*"L"){ if(j-i>=0)res[j-i]++; } if(a=...
C++
d8c89bb83592a1ff1b639f7d53056d67
82ff6efe68e4768bfe7c123328a35528
1,400
PASSED
#include <bits/stdc++.h> #define SZ(x) (int)x.size() typedef long long ll; const int SZ=2e3+5; using namespace std; int n,m,k; int res[SZ]; char s[SZ][SZ]; int main() { scanf("%d%d%d",&n,&m,&k); for(int i=0;i<n;i++) scanf("%s",&s[i]); for(int i=0;i<n;i++) for(int j=0;j<m;j++) ...
C++
d8c89bb83592a1ff1b639f7d53056d67
b2e89f70064c2501f53c41ce9eedf3ca
1,400
PASSED
#include <iostream> #include <cstdio> #include <vector> using namespace std; int main() { int numRow, numCol, numSpd; // row, column, spiders cin >> numRow >> numCol >> numSpd; vector<int> spiders(numCol); char c; int i, j=0; for(j=0;j<numCol;++j) cin >> c; for(i=1;i<numRow;++i) { ...
C++
d8c89bb83592a1ff1b639f7d53056d67
8491113108da9419721e753443d789b3
1,400
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define mp make_pair #define pii pair<int,int> const int INF = (int)1e9; const ll INFLL = (ll)1e16; const int MOD=(int)1e9 +7; const int maxn=(int)1e5 +5; template<typename T> void out(T x) { cout << x << endl; exit(0); } bool bysec(const pi...
C++
d8c89bb83592a1ff1b639f7d53056d67
aa84b6458345afd9119999624b4502ce
1,400
PASSED
#include <stdio.h> #include <string.h> #include <algorithm> #include <iostream> #include <stdlib.h> #include <assert.h> #include <vector> #include <string> #include <set> #include <map> using namespace std; typedef long long lint; const int MAX_N=1e5+5; int n,m,fa[MAX_N],dep[MAX_N],op[MAX_N][3],in[MAX_N],out[MAX_N],tot...
C++
eba7fc8d103ba3d643c1424cbbebf571
066c61fe79b987284b6cd84cf4322c2b
2,100
PASSED
#include <iostream> #include <cstdio> #include <algorithm> #include <vector> #define foru(i,a,b) for(int i = (a), _b = (b); i <= _b; ++i) #define ford(i,a,b) for(int i = (a), _b = (b); i >= _b; --i) using namespace std; const int N = 1E5+10; int n, m, cq, et[N], eu[N], ev[N], qt[N], qx[N], qy[N], titem[N], ans[N], pos[...
C++
eba7fc8d103ba3d643c1424cbbebf571
d3ff142bc71f800012e15c2d1366b609
2,100
PASSED
#pragma comment(linker, "/STACK:36777216") #include <iostream> #include <algorithm> #include <vector> using namespace std; const int MAXN = 1e5 + 1; int n, q, cnt[2], type, x, y; int deg[MAXN], depth[MAXN]; bool isRoot[MAXN], exist[MAXN], res[MAXN]; struct node{ int point, time; node(){} node(int a, int b...
C++
eba7fc8d103ba3d643c1424cbbebf571
32f8ff2370db15d232497d7dcad574e1
2,100
PASSED
#include <bits/stdc++.h> using namespace std; #define ll long long int n,m; const int maxn = 100*1000+19; int par[maxn]={0}; int timer[maxn]={0}; int doctime[maxn]={0}; int lev[maxn]={0}; vector<int> docs[maxn]; int doc2[maxn]={0}; int main() { cin>>n>>m; int did = 0; for(int i=1;i<=m;i++) { in...
C++
eba7fc8d103ba3d643c1424cbbebf571
28b28f1bf57f28b7fc8eb70e58efecf5
2,100
PASSED
#include<bits/stdc++.h> using namespace std; #define N 100050 int qr[N][5]; int srt[N],ed[N],pr[N]; int cur; int ans[N]; int deg[N]; vector<pair<int,int> >temp[N]; vector<int>vc[N]; void dfs(int u) { srt[u]=cur++; for(int i=0; i<vc[u].size(); i++) { dfs(vc[u][i]); } cur++; ed[u]=cur; ...
C++
eba7fc8d103ba3d643c1424cbbebf571
832be5d98a6194fa5ea70ce8a3aa3649
2,100
PASSED
#include<bits/stdc++.h> using namespace std; #define N 100050 int qr[N][5]; int srt[N],ed[N],pr[N]; int cur; int ans[N]; int deg[N]; vector<pair<int,int> >temp[N]; vector<int>vc[N]; void dfs(int u) { srt[u]=cur; for(int i=0; i<vc[u].size(); i++) { cur++; dfs(vc[u][i]); } cur++; ...
C++
eba7fc8d103ba3d643c1424cbbebf571
f54a71e312fcd4de572de3f0abf746e8
2,100
PASSED
#include <cstdio> #include <algorithm> #include <vector> using namespace std; int n,m; int p[100000]; int h[100000]; int queries[100000][3]; vector<pair<int,int> > type3[100000]; vector<int> adj[100000]; int visited[100000]; vector<int> who; int top[100000]; int ok[100000]; vector<pair<int,int> > need[100000]; int wh...
C++
eba7fc8d103ba3d643c1424cbbebf571
be79d0afde08d03ec2bb84af4b6c39e7
2,100
PASSED
#include<iostream> #include<cstdio> #include<algorithm> #include<cassert> #include<vector> using namespace std; const int N=100010,M=100010,L=0,R=1,Unknown=0; struct query { int type,a,b; }t[M]; int n,m,last[N]={},end[N]={},next[N]={},total_edge=0; int l[N]={},r[N]={},tl=0,tr=0,root[N]={},qtot=0,dtot=0,ans[N]={}; bool...
C++
eba7fc8d103ba3d643c1424cbbebf571
9837aaa3673bc51c632d2eecedd33445
2,100
PASSED
#include <cstdio> #include <algorithm> #include <iostream> #include <cstring> #include <queue> #include <vector> using namespace std; int n,m,i,j,deg[100005],number,qtn[100005],tin[100005],tout[100005],tmr,ata[100005],ans[100005]; int a,b,u,z; struct qtb{ int t; int x; int y; }d[100005]; vector <int> v[1...
C++
eba7fc8d103ba3d643c1424cbbebf571
1e61beded33d52c6f373e74c049df6c2
2,100
PASSED
 #include<iostream> #include<vector> #include<algorithm> using namespace std; #define MOD 1000000007 const int Nmax = 100100; int QueryToNumber[Nmax] , NumberToQuery[Nmax]; int tin[Nmax], tout[Nmax], dsu[Nmax]; int Number = 0 , timer = 1 , n , m; vector<vector<int> > g; vector<int> Question[Nmax]; int deg[N...
C++
eba7fc8d103ba3d643c1424cbbebf571
d813ec8ac73c46e4c9c5862dd7436800
2,100
PASSED
#include<bits/stdc++.h> #define pb push_back #define ii pair<int,int> #define all(x) (x).begin(),(x).end() #define sz(x) ((int)(x).size()) #define INF 100000000000000000 #define modulo 1000000007 #define mod 998244353 #define int long long int using namespace std; void print(vector<int>& arr){ for(auto p : arr) cout ...
C++
5c17e01d02df26148e87dcba60ddf499
f1c36a33e383f21cd8232bc71a71a274
2,700
PASSED
#include <bits/stdc++.h> #define sqr(a) ((a)*(a)) #define rsz resize #define forr(i,a,b) for(int i=(a);i<(b);i++) #define forn(i,n) forr(i,0,n) #define dforn(i,n) for(int i=n-1;i>=0;i--) #define forall(it,v) for(auto it=v.begin();it!=v.end();it++) #define sz(c) ((int)c.size()) #define zero(v) memset(v, 0, sizeof(v)) #d...
C++
5c17e01d02df26148e87dcba60ddf499
43e2012ccfa2c6a49d13f53458f71b17
2,700
PASSED
#include <bits/stdc++.h> #define sqr(a) ((a)*(a)) #define rsz resize #define forr(i,a,b) for(int i=(a);i<(b);i++) #define forn(i,n) forr(i,0,n) #define dforn(i,n) for(int i=n-1;i>=0;i--) #define forall(it,v) for(auto it=v.begin();it!=v.end();it++) #define sz(c) ((int)c.size()) #define zero(v) memset(v, 0, sizeof(v)) #d...
C++
5c17e01d02df26148e87dcba60ddf499
1b113f50bf0626709fab65817158c27a
2,700
PASSED
/* * ~Botay~ * code by kazalika */ #include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; typedef long long ll; typedef pair<ll, ll> pll; typedef long double ldb; typedef double db; typedef vector<int> vint; typedef vector<ll> vll; #define forn(a, i, n) for (int i = (a); i < (n); ++i)...
C++
5c17e01d02df26148e87dcba60ddf499
96d3377d2ff9e54d415df5e09a8b270f
2,700
PASSED
#include <bits/stdc++.h> using namespace std; // #pragma GCC optimize("Ofast") // #pragma GCC optimize ("unroll-loops") // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") typedef long long ll; typedef long double ld; typedef pair<int,int> p32; typedef pair<ll,ll> p64; typedef pai...
C++
5c17e01d02df26148e87dcba60ddf499
5a7ce4f0288d528c773c1c3cfecbb17f
2,700
PASSED
#include<cstdio> #include<algorithm> #include<cstring> #define ll long long using namespace std; int n; ll k,a[100005],b1[100005],b2[100005]; bool check(ll v) { ll sum=0; for(int i=1;i<=n;i++) { ll l=1,r=a[i]; while(l<=r) { ll mid=(l+r)>>1; if(mid*(a[i]-mid*mid)-((mid-1)*(a[i]-(mid-1)*(mid-1)))>=v)l=mid+...
C++
5c17e01d02df26148e87dcba60ddf499
8da702948689537dd8b70545b48cd80e
2,700
PASSED
#include<bits/stdc++.h> using namespace std; #define ll long long #define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++) #define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--) #define EREP(i,u) for(int i=start[u];i;i=e[i].next) #define fi first #define se second #define mkr(a,b) make_pair(a,b) #define SZ(A) ((int)...
C++
5c17e01d02df26148e87dcba60ddf499
4fd1a9cd4d7112f46fbdf65f50913e36
2,700
PASSED
#include <sstream> #include<complex> #include<iostream> #include<algorithm> #include<vector> #include<set> #include<ctime> #include<cmath> #include<map> #include<unordered_map> #include<stack> #include<random> #include <chrono> #include<queue> #include<list> #include<math.h> #include<bitset> #include<fstream> #include<...
C++
5c17e01d02df26148e87dcba60ddf499
ba88771be040eacf7a7e31aa2985e930
2,700
PASSED
//sobskdrbhvk //remember... #include <bits/stdc++.h> using namespace std; typedef long long int LL; typedef long double LD; typedef pair<int, int> pii; typedef pair<LL, LL> pll; #define PB push_back #define MP make_pair #define L first #define R second #define smin(x, y) (x) = min((x), (y)) #define smax(x, y) (x) = ...
C++
5c17e01d02df26148e87dcba60ddf499
d37bc5ccfed96cc6dae6092427f2983d
2,700
PASSED
#include "bits/stdc++.h" #define ll long long #define mk make_pair #define pb push_back #define pii pair<int,int> #define pll pair<ll,ll> #define pil pair<int,ll> #define pli pair<ll,int> using namespace std; const int MAXN=1e5+9; const ll INF=4e18; ll a[MAXN],fans[MAXN],can_reduce[MAXN]; ll can_take_from_index(ll id,l...
C++
5c17e01d02df26148e87dcba60ddf499
afa790275e7892c6b7a3612150291cd2
2,700
PASSED
#include <iostream> #include <iomanip> #include <algorithm> #include <cmath> using namespace std; typedef long long ll; typedef pair<ll, ll> pp; int main() { ll n, d, ans=0; cin >> n >> d; pair<ll, ll> ar[n]; for (int i = 0; i < n; i++) { ll m, s; cin >> m >> s; ar[i]={m,s}; } sort(ar, ar+n); for (int i = ...
C++
38fe0e19974a7bc60153793b9060369a
e18f5e85fbd7113a9f3dd19a5be48547
1,500
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); ll n,d,ans=0; cin>>n>>d; pair<ll,ll> friends[n]; for (int i=0;i<n;i++) { ll m,s; cin>>m>>s; friends[i]={m,s}; } sort(friends,friends+n); for (int i=1;i<n;i++) { friends...
C++
38fe0e19974a7bc60153793b9060369a
0965a6c42a66f197a7a7379732b8780f
1,500
PASSED
#include <bits/stdc++.h> #define ll unsigned long long using namespace std; struct Frend { ll m, f; }; bool comparator(const Frend& a, const Frend& b) { bool c1 = (a.m < b.m); bool c2 = (a.m == b.m && a.f < b.f); return (c1 || c2); } int main() { int n, d; ll ans = 0; cin ...
C++
38fe0e19974a7bc60153793b9060369a
8195b9cf4e2513ce7c45c2b2a43f19ff
1,500
PASSED
#include<iostream> #include<algorithm> using namespace std; struct KefaFriends{ long long money, friendship; }p[1000010]; bool compare(KefaFriends a , KefaFriends b){ return a.money < b.money; } int main() { long n, d; cin>>n>>d; for(long long i = 0 ; i < n ; i++){ cin>>p[i].money>>p[i].friendship; } s...
C++
38fe0e19974a7bc60153793b9060369a
8352ad22df1e48984381c5d33b79bb85
1,500
PASSED
#include <bits/stdc++.h> using namespace std; long long n, l, r, x, d, s, m, y; main() { vector<pair<long, long>> a; cin >> n >> d; while(cin >> x >> y) a.push_back({x,y}); sort(a.begin(), a.end()); for (; l<n; l++) { while (r<n && a[l].first + d > a[r].first) s += a[r].second, r++; ...
C++
38fe0e19974a7bc60153793b9060369a
e85abd968513962bcb9a04fd24cc7b7c
1,500
PASSED
#pragma GCC optimize("Ofast,fast-math,unroll-loops") #include <bits/stdc++.h> using namespace std; int n, l, r, x, d, y; long long s, m; main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> d; pair<int, int> a[n]; for (int i=0;cin >> x >> y; i++) a[i]={x,y}; sort(a...
C++
38fe0e19974a7bc60153793b9060369a
f6c78d5da1fd454d6ef6ec82a749845a
1,500
PASSED
#include <bits/stdc++.h> using namespace std; int n, l, r, x, d, y; long long s, m; main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> d; pair<int, int> a[n]; for (int i=0;cin >> x >> y; i++) a[i]={x,y}; sort(a, a+n); for (; l<n; s-=a[l].second, l++) { ...
C++
38fe0e19974a7bc60153793b9060369a
c27ce8739856ad6719d326231679dc4e
1,500
PASSED
#include <bits/stdc++.h> using namespace std; int n, l, r, x, d, y; long long s, m; main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> d; vector<pair<int, int>> a; a.reserve(n); while (cin >> x >> y) a.push_back({x,y}); sort(a.begin(), a.end()); for (; l<...
C++
38fe0e19974a7bc60153793b9060369a
a0aef2f73ce2002026b66dd7bf605e9b
1,500
PASSED
#include <bits/stdc++.h> using namespace std; int n, l, r, x, d, y; long long s, m; main() { vector<pair<int, int>> a; cin >> n >> d; while(cin >> x >> y) a.push_back({x,y}); sort(a.begin(), a.end()); for (; l<n; l++) { while (r<n && a[l].first + d > a[r].first) s += a[r].second, r++; ...
C++
38fe0e19974a7bc60153793b9060369a
2ca5f6f43759d45236eef6b04b3a13d7
1,500
PASSED
/* * File: main.cpp * Author: "Youssef_Ackraman" * * Created on 15 November 2020, 01:17 */ #include <bits/stdc++.h> using namespace std; int n,d; vector<pair<long long,long long>>fr; /* * */ void solve(){ sort(fr.begin(),fr.end()); long long ans=0,mx=0; for(int r=0,l=0;r<fr.size();){ i...
C++
38fe0e19974a7bc60153793b9060369a
3c53463a58435dab98f17508320bcd38
1,500
PASSED
from collections import defaultdict, Counter from sys import stdin import io, os input = stdin.readline n, h, l, r = map(int, input().split()) a = list(map(int, input().split())) M = 1000001 n_inf = float('-inf') dp = defaultdict(lambda:n_inf) dp[0] = 0 # iterate through all the sleep hours for i in range(1, n +...
Python
a301e0847a620fbb349fa914db98e752
ef91f1ccbaa26dd88fa877511eccc2f2
1,700
PASSED
import sys import math import bisect from sys import stdin, stdout from math import gcd, floor, sqrt, log2, ceil from collections import defaultdict from bisect import bisect_left as bl, bisect_right as br from collections import Counter from collections import deque ip = lambda : int(stdin.readline()) inp = lambda: ...
Python
a301e0847a620fbb349fa914db98e752
1fab54b0ad752ff6fed732790c2590e4
1,700
PASSED
n, h, l, r = map(int, input().split()) A = list(map(int, input().split())) dp = [[-1] * h for _ in range(2)] dp[1][0] = 0 flag = 1 for i in range(n): for j in range(h): if dp[flag][j] == -1: continue h1 = (j + A[i]) % h h2 = (j + A[i] - 1) % h if l <= h1 <= r: dp[flag ^ ...
Python
a301e0847a620fbb349fa914db98e752
aba1da4bb7dcd5e76987a437e5cb5901
1,700
PASSED
import sys import math input=sys.stdin.readline #t=int(input()) t=1 for _ in range(t): n,h,l,r=map(int,input().split()) a=list(map(int,input().split())) a.insert(0,0) dp=[[0 for j in range(n+1)] for i in range(n+1)] pref=[0]*(n+2) for i in range(1,n+1): pref[i]=pref[i-1]+a[i] if...
Python
a301e0847a620fbb349fa914db98e752
d06ec5db3de1406124c2751e0a682843
1,700
PASSED
import sys, os # import numpy as np from math import sqrt, gcd, ceil, log, floor from bisect import bisect, bisect_left from collections import defaultdict, Counter, deque from heapq import heapify, heappush, heappop input = sys.stdin.readline read = lambda: list(map(int, input().strip().split())) # read_f = lambda fil...
Python
a301e0847a620fbb349fa914db98e752
e9c3e907310a26cb88172428c0008592
1,700
PASSED
from sys import stdin from collections import defaultdict n, h, l, r = map(int, stdin.readline().split()) sleep = list(map(int, stdin.readline().split())) dp = defaultdict(lambda:[float('-inf')]*h) dp[0][0] = 0 for i in range(n): for j in range(h): a = sleep[i] t = (a + j) % h t_ = (a + j - 1) % h dp[i + 1...
Python
a301e0847a620fbb349fa914db98e752
d9b4484c211de6035131450f1b383222
1,700
PASSED
from sys import stdin,stdout import sys from bisect import bisect_left,bisect_right # stdin = open("input.txt", "r"); # stdout = open("output.txt", "w"); n,h,l,r=stdin.readline().strip().split(' ') n,h,l,r=int(n),int(h),int(l),int(r) arr=list(map(int,stdin.readline().strip().split(' '))) dp_arr=[[0 for i in range...
Python
a301e0847a620fbb349fa914db98e752
ef9491b3ee8a3b0441600f0bdc206dfe
1,700
PASSED
#!/usr/bin/env python import os import sys from io import BytesIO, IOBase def main(): n,h,l,r=map(int,input().split()) a=map(int,input().split()) pvr=[-200000]*h pvr[0]=0 for hr in a: cur=[-200000]*h for i in range(h): j=(i+hr)%h cur[j]=max(pvr[i],cur[j]) ...
Python
a301e0847a620fbb349fa914db98e752
5925f7a9c593c21adadeeafdc8268400
1,700
PASSED
# =============================================================================================== # importing some useful libraries. from __future__ import division, print_function from fractions import Fraction import sys import os from io import BytesIO, IOBase from itertools import * import bisect from heapq import ...
Python
a301e0847a620fbb349fa914db98e752
126f17b4e8801514c5c6b14ad015ca00
1,700
PASSED
n, h, l, r = map(int, input().split()) arr = list(map(int, input().split())) dp = [[0 for i in range(n+1)] for j in range(n+1)] cur = 0 for i in range(1,n+1): cur += arr[i-1] for j in range(i+1): temp = (cur - j)% h if temp >= l and temp <= r: dp[i][j] = 1 dp[i][j] += max(dp[...
Python
a301e0847a620fbb349fa914db98e752
2026a7cf27c78de6c4abf4d593b69059
1,700
PASSED
import java.io.*; import java.util.*; public class Main{ static int mod = (int)(Math.pow(10, 9) + 7); public static void main(String[] args) { MyScanner sc = new MyScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); int n =sc.nextInt(); int t = sc.nextInt(); int ...
Java
71be4cccd3b8c494ad7cc2d8a00cf5ed
058cb28a515f02e846e4286e1ab0d2a6
1,000
PASSED
import java.util.*; import java.io.*; public class Main { public static void main(String args[])throws Exception { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw=new PrintWriter(System.out); String str[]=br.readLine().split(" "); int n=Inte...
Java
71be4cccd3b8c494ad7cc2d8a00cf5ed
42cbe77e35282c0603d5e5fc5b0a8234
1,000
PASSED
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { FastReader scan = new FastReader(); //PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("taming.out"))); PrintWriter out = new ...
Java
71be4cccd3b8c494ad7cc2d8a00cf5ed
43cc0cf2c9cf2fd52f5c451af1b24dfb
1,000
PASSED
import java.sql.Array; import java.sql.SQLOutput; import java.util.*; import java.io.*; import java.math.*; public class MyProgram { public static FastIO file = new FastIO(); private static void solve() { // int tt = nextInt(); int tt = 1; long start = 0; while (tt-- > 0) { ...
Java
71be4cccd3b8c494ad7cc2d8a00cf5ed
a46ba36fe950cb99a30abf27135f42a8
1,000
PASSED
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.StringTokenizer; public class Main { static final long M = 1000000007; public static void main(String args[]) { ...
Java
71be4cccd3b8c494ad7cc2d8a00cf5ed
c56de345dfaf7b951c20508cfc8d9ee0
1,000
PASSED
import java.util.*; import java.io.*; import java.math.*; public class A { static class Pair{ int idx,s,d; public Pair(int idx,int s,int d){ this.idx=idx; this.s=s; this.d=d; } } static final int oo= Integer.MAX_VALUE; public static void pr...
Java
71be4cccd3b8c494ad7cc2d8a00cf5ed
102956e19f199faccb8d83d8a8c8ecc7
1,000
PASSED
import java.io.*; import java.util.*; public class Solution { static int MAX = (int)1e5+1; static int ans = Integer.MAX_VALUE; static boolean vis[][]; static int arr[][]; static ArrayList<String> list = new ArrayList<>(); public static void main(String[] args)throws Exception{ //InputReader in...
Java
71be4cccd3b8c494ad7cc2d8a00cf5ed
070060d592065229f2563dcb4695e9af
1,000
PASSED
import java.util.*; import java.io.*; /* */ public class Main{ public static OutputStream out=new BufferedOutputStream(System.out); //nl-->neew line; //l-->line; //arp-->array print; //arpnl-->array print new line public static void nl(Object o) throws IOException{out.write((o+"\n").getBytes());} p...
Java
71be4cccd3b8c494ad7cc2d8a00cf5ed
6f5920c7e6d2b6d433d702c77494ec67
1,000
PASSED
import java.util.*; public class codeforces{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int t=sc.nextInt(); int max=Integer.MAX_VALUE; int index=0; for(int i=1;i<=n;i++){ int s=sc.nextInt(); int d=sc.nextInt(); while(s<t){ s+=...
Java
71be4cccd3b8c494ad7cc2d8a00cf5ed
c4a37390a074ed31c655a23f71857949
1,000
PASSED
import java.util.*; public class servalAndBus { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int t=sc.nextInt(); int a[]=new int [n]; int b[]=new int [n]; for(int i=0;i<n;i++) { a[i]=sc.nextInt(); b[i]=sc.nextInt(); if(a[i]<t) { while(...
Java
71be4cccd3b8c494ad7cc2d8a00cf5ed
d754bc3725d32d83fd8e133262186988
1,000
PASSED
#include<bits/stdc++.h> using namespace std; const int N = 1000; string ans[N],num[N],A[N]; int n, k, i, kol; char ch,ch1; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n >> k; for(i = 1; i <= n - k + 1; ++i) cin >> ans[i]; for(ch = 'A'; ch <= 'Z'...
C++
046d6f213fe2d565bfa5ce537346da4f
6a23ab0b28d8829d2100cc330057cea9
1,500
PASSED
#include<iostream> #include<cstdio> #include<cmath> #include<algorithm> #include<cstring> #define ll long long using namespace std; int n,k; int a[55]; char ch[5]; char code[55][3]; int main(){ for(int i=1;i<=26;i++){ code[i][0]='A'; code[i][1]=i-1+'a'; } for(int i=27;i<=50;i++){ ...
C++
046d6f213fe2d565bfa5ce537346da4f
1d23b1e479575deaf56a2bf270a2c70f
1,500
PASSED
#include <bits/stdc++.h> using namespace std; int vis[2000],n,k; string name[55]; int v[51]; queue<int> q,q1; void make_name(){ int ppp=-1; int temp; memset(vis,0,sizeof(vis)); while(ppp<=50){ temp=rand()%2001; if(!vis[temp]){ vis[temp]=1; ppp++; whi...
C++
046d6f213fe2d565bfa5ce537346da4f
5a1b28a314f770ec05503caa455ec7af
1,500
PASSED
#include<bits/stdc++.h> using namespace std; typedef long long lg; typedef unsigned long long ulg; typedef long double ld; #define mkp make_pair #define pb push_back #define endl "\n" const int N = 1000, M = 2e5 + 5, INFi = 1e9 + 123, MOD = 1e9 + 7, KEY = 1001; const lg INFl = 1e18 + 123; const double EPS = 0.00000001,...
C++
046d6f213fe2d565bfa5ce537346da4f
4839d9ad054ea15e9f5914a5f5beacd3
1,500
PASSED
#include <bits/stdc++.h> using namespace std; string na(int x){ string s; if (x<=10){ s+='A'; for (int i=2;i<=x;i++){ s+='a'; } } else if (x<=20){ s+='B'; for (int i=2;i<=x-10;i++){ s+='b'; } } else if (x<=30){ s+=...
C++
046d6f213fe2d565bfa5ce537346da4f
89a55b08a84095077fde99da0c9299e5
1,500
PASSED
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll n, k, counter; string out[100005]; string gen(ll n){ string s = ""; while(n/26>0){ s += s.length()==0?(char)(n%26+65):(char)(n%26+97); n /= 26; } s += s.length()==0?(char)(n%26+65):(char)(n%26+97); return s; } int main(){ cin >...
C++
046d6f213fe2d565bfa5ce537346da4f
b7b0e5fe79ee100d91cd73ffedcdba74
1,500
PASSED
#include <bits/stdc++.h> using namespace std; const int size = 60; int n, k; string arr[size]; int main(){ string answer = ""; int lastName = 0, lastIndex = 0; // create an array of names; string names[55]; for(int c = 'A'; c<='Z'; c++){ names[c - 'A'] = (char)c; // cout << names[c - 'A']<<"|"; }for(int i = ...
C++
046d6f213fe2d565bfa5ce537346da4f
238123b404d3cd9b2c2e15109fd4cd42
1,500
PASSED
#include<iostream> using namespace std; typedef long long ll; int main(){ // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); std::ios_base::sync_with_stdio(false), cin.tie(0); int n, k; cin >> n >> k; string name[n], state[n - k + 1]; for(int i = 0 ; i < n - k + 1 ; i++){ cin >> ...
C++
046d6f213fe2d565bfa5ce537346da4f
d7e7303c91346d8c4eae9a75addea576
1,500
PASSED
#include <iostream> #include <string> using namespace std; const int N = 51; int v[N]; string nume(int n) { string s; if(n < 26) { s += 'A'; } else { s += 'B'; n -= 26; } s += ('a' + n); return s; } int main() { int n, k; cin >> n >> k; string ...
C++
046d6f213fe2d565bfa5ce537346da4f
952a7f329ed22dc741ca9c4ed1bb8ee6
1,500
PASSED
#include <string> #include <vector> #include <iostream> #include <algorithm> #include <map> #include <queue> #include <cmath> #include <set> #include <stack> #include <unordered_set> #include <unordered_map> #include <climits> using namespace std; int main() { int n, k; cin>>n >>k; vector<int> data(1+n, -1); ve...
C++
046d6f213fe2d565bfa5ce537346da4f
4262cbea2adc453e19ad9751a4dcc1cd
1,500
PASSED
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.*; public class cf771c { public static void main(String[] args) throws IOException { int n = rni(), k = ni(); long dp[][] = new long[n][k + 1]; Graph g = tree(n); dfs(g, 0, -1, dp,...
Java
0b4362204bb9f0e95eaf7e2949315c8f
258be72b8c489f20edf78bbbc222f444
2,100
PASSED