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
#include <iostream> #include <vector> #include <string> #include <queue> #include <map> #include <cmath> #include <cstring> #include <algorithm> using namespace std; int main() { int t; cin>>t; while(t--) { long long a, b; cin>>a>>b; long long p, q; cin>>p>>q; ...
C++
589f3f7366d1e0f9185ed0926f5a10bb
e88aa5836312c04a0c1ce85863f31437
1,700
PASSED
// Bismillahirrahmanir Rahim //NAMOMIZARAHID #include<bits/stdc++.h> #include<cstdio> #include<cstring> #include<cmath> #include<string> #define nl printf("\n") #define sp printf(" ") #define rep(i,a,b) for(i=a;i<=b;i++) #define rev(i,a,b) for(i=a;i>=b;i--) #define fil freopen("input.txt","r",stdin) #define pf prin...
C++
589f3f7366d1e0f9185ed0926f5a10bb
749ba610979647cb8408fac72c0cf0a5
1,700
PASSED
// Bismillahirrahmanir Rahim //NAMOMIZARAHID #include<bits/stdc++.h> #include<cstdio> #include<cstring> #include<cmath> #include<string> #define nl printf("\n") #define sp printf(" ") #define rep(i,a,b) for(i=a;i<=b;i++) #define rev(i,a,b) for(i=a;i>=b;i--) #define fil freopen("input.txt","r",stdin) #define pf prin...
C++
589f3f7366d1e0f9185ed0926f5a10bb
a0088cd0d0cf15a3af2059a6bf5e3142
1,700
PASSED
// Bismillahirrahmanir Rahim //NAMOMIZARAHID #include<bits/stdc++.h> #include<cstdio> #include<cstring> #include<cmath> #include<string> #define nl printf("\n") #define sp printf(" ") #define rep(i,a,b) for(i=a;i<=b;i++) #define rev(i,a,b) for(i=a;i>=b;i--) #define fil freopen("input.txt","r",stdin) #define pf prin...
C++
589f3f7366d1e0f9185ed0926f5a10bb
930fa45460e961453a5d4c16ef6f6ad9
1,700
PASSED
// Bismillahirrahmanir Rahim //NAMOMIZARAHID #include<bits/stdc++.h> #include<cstdio> #include<cstring> #include<cmath> #include<string> #define nl printf("\n") #define sp printf(" ") #define rep(i,a,b) for(i=a;i<=b;i++) #define rev(i,a,b) for(i=a;i>=b;i--) #define fil freopen("input.txt","r",stdin) #define pf prin...
C++
589f3f7366d1e0f9185ed0926f5a10bb
032fe77d341cc1badb6751c6045b7b11
1,700
PASSED
// Bismillahirrahmanir Rahim //NAMOMIZARAHID #include<bits/stdc++.h> #include<cstdio> #include<cstring> #include<cmath> #include<string> #define nl printf("\n") #define sp printf(" ") #define rep(i,a,b) for(i=a;i<=b;i++) #define rev(i,a,b) for(i=a;i>=b;i--) #define fil freopen("input.txt","r",stdin) #define pf prin...
C++
589f3f7366d1e0f9185ed0926f5a10bb
40fe9448bbbaff97fc6d7172b4104d60
1,700
PASSED
# include <iostream> # include <sstream> # include <cstdio> # include <cstdlib> # include <algorithm> # include <string> # include <cstring> # include <cmath> # include <stack> # include <queue> # include <vector> # include <list> # include <map> # include <set> # include <deque> # include <iterator> # include <functio...
C++
589f3f7366d1e0f9185ed0926f5a10bb
85eb7c15a50233bdc837835109295380
1,700
PASSED
#include<cstdio> #include<cstring> typedef long long ll; int main() { ll t,x,y,p,q; scanf("%lld",&t); while(t--) { scanf("%lld%lld%lld%lld",&x,&y,&p,&q); ll l=0,r=1e9,n=-1; while(l<=r) { ll mid=(l+r)/2; ll a=mid*p-x,b=mid*q-y; if(a>=0&&b>=0&&a<=b) { n=mid; r=mid-1; } else l=mid+1; ...
C++
589f3f7366d1e0f9185ed0926f5a10bb
ec0975b8f4da73e193adfe5d01553fcf
1,700
PASSED
#include<bits/stdc++.h> #define x first #define y second using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int,int> pii; const double PI = acos(-1.0); const int INF=0x3f3f3f3f; const int N=1e5+9; ll T, x, y, p, q; int main(void){ //freopen("in", "r", stdin); freopen("out", "w", stdout)...
C++
589f3f7366d1e0f9185ed0926f5a10bb
a6a3c286960a8a22bc7df8b1cecc8d43
1,700
PASSED
#include <bits/stdc++.h> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> #define eps 1e-9 #define endl '\n' #define gcd __gcd #define pi acos(-1) #define ll long long #define LL long long #define IDX(x) x - 'A' #define idx(x) x - 'a' #define idz(x) x - '0' #define ld long double #define l...
C++
eb6362941b5186d20721c99fb4808d52
3715825c77118a8c6a24cc173885f1d7
2,600
PASSED
#include <bits/stdc++.h> const int maxn=2e5+10; using namespace std; int a[maxn],now[maxn],be[maxn],num[maxn],cnt[maxn],ans[maxn];//a 代表输入数据对应离散化后数字 now 修改后代表的数字,每当修改时 会把now传入记录之前值和现在值 be 分块值 num 数字的个数 cnt 数字个数的 个数 ans 保存结果 int n,m,l,r,t; int msz; map<int,int>M;//离散化 记录对应值 struct Query { int l,r,t,i...
C++
eb6362941b5186d20721c99fb4808d52
9a9f3f84d3ad150a08c7d7afecc05e8c
2,600
PASSED
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<map> #include<cmath> using namespace std; const int maxn = 2e5+10; const double IO = 2.0/3.0; typedef long long LL; int Ki[maxn]={0},l = 1,r = 0,m,n,Ans[maxn] = {0},a[maxn]={0},now[maxn]={0},num[maxn]={0},cnt[maxn]={0},tot = 0; map <int,...
C++
eb6362941b5186d20721c99fb4808d52
0cb9afa0882b9871e96325acb225cd4a
2,600
PASSED
#include<bits/stdc++.h> using namespace std; const int L=2154; int n,m; int ans[110000]; int a[110000],aa[110000]; struct change { int p,x,y; }b[110000]; int num1,num2; struct node { int l,r,t,id; friend bool operator < (node a,node b) { if (a.l/L!=b.l/L) return a.l/L<b.l/L; if (a.r/L!=b.r/L) return a.r/L<b.r/...
C++
eb6362941b5186d20721c99fb4808d52
d46fa6813feebb9872676e059818fefb
2,600
PASSED
#pragma optimization_level 3 //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math") #include <iostream> #include <algorithm> #include <fstream> #include <vector> #include <queue> #include <functional> #include <set> #i...
C++
eb6362941b5186d20721c99fb4808d52
4438b46307e8cab963c0d0c44fe479eb
2,600
PASSED
// Sweet dreams are made of this // Who am I to disagree? #pragma GCC optimize("Ofast", "unroll-loops") #include <bits/stdc++.h> #include <unordered_set> #include <unordered_map> #define pb push_back #define pf push_front #define popb pop_back #define popf pop_front #define all(a) (a).begin(), (a).end() #define sz(a) (...
C++
eb6362941b5186d20721c99fb4808d52
e70edc24e8d95b2237d09123be38b7a2
2,600
PASSED
// Sweet dreams are made of this // Who am I to disagree? #pragma GCC optimize("Ofast", "unroll-loops") #include <bits/stdc++.h> #include <unordered_set> #include <unordered_map> #define pb push_back #define pf push_front #define popb pop_back #define popf pop_front #define all(a) (a).begin(), (a).end() #define sz(a) (...
C++
eb6362941b5186d20721c99fb4808d52
78aa757ef0b7ab2afa619f334504b5a4
2,600
PASSED
// Sweet dreams are made of this // Who am I to disagree? #pragma GCC optimize("Ofast", "unroll-loops") #include <bits/stdc++.h> #include <unordered_set> #include <unordered_map> #define pb push_back #define pf push_front #define popb pop_back #define popf pop_front #define all(a) (a).begin(), (a).end() #define sz(a) (...
C++
eb6362941b5186d20721c99fb4808d52
983e068a7fb000ee5453c3353ce88390
2,600
PASSED
// Sweet dreams are made of this // Who am I to disagree? #pragma GCC optimize("Ofast", "unroll-loops") #include <bits/stdc++.h> #include <unordered_set> #include <unordered_map> #define pb push_back #define pf push_front #define popb pop_back #define popf pop_front #define all(a) (a).begin(), (a).end() #define sz(a) (...
C++
eb6362941b5186d20721c99fb4808d52
9f7ad6df800535ef75d8b0dfb6018829
2,600
PASSED
// Sweet dreams are made of this // Who am I to disagree? #pragma GCC optimize("Ofast", "unroll-loops") #include <bits/stdc++.h> #include <unordered_set> #include <unordered_map> #define pb push_back #define pf push_front #define popb pop_back #define popf pop_front #define all(a) (a).begin(), (a).end() #define sz(a) (...
C++
eb6362941b5186d20721c99fb4808d52
ae54600cae4f0964510b5fba6d2575dc
2,600
PASSED
#include <bits/stdc++.h> #define dbg(x) cerr<<#x": "<<x<<"\n" #define dbg_p(x) cerr<<#x": "<<x.first<<","<<x.second<<"\n" #define dbg_v(x, n) do{cerr<<#x"[]: ";for(long long _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0) #define dbg_ok cerr<<"OK!\n" #define st first #define nd second #define DMAX 200100 #define NM...
C++
87f4b8523d0047935931906ccc2ea911
1729536af91618ff98b00f595ed15b1b
2,100
PASSED
#include <bits/stdc++.h> #include<tuple> #include<fstream> #define forin(i, n) for (int i = 0; i < n; ++i) #define foriin(i, n,init) for (int i = init; i < n; ++i) #define fordin(i, n) for (int i = n-1; i >= 0; --i) #define fordiin(i,n,e) for (int i = n-1; i >= e; --i) #define ll long long #define iii tuple<int,int,int...
C++
0137910e44e01385a22cac1afec94ead
38d7d97d3ce5141bf8fccbddfce8de55
2,400
PASSED
#include <bits/stdc++.h> using namespace std; #define int long long typedef long long ll; struct fenwickTree { vector<ll> bit; int n; fenwickTree() { n = (int)(1e5+10)*10; bit.assign(n,0); } ll sum(int r) { ll ret = 0; for(; r >= 0; r = (r&(r+1))-1) ret...
C++
0137910e44e01385a22cac1afec94ead
bfe2d14cbf207790528f7443f88ae542
2,400
PASSED
#include <bits/stdc++.h> using namespace std; #define int long long typedef long long ll; struct SegmentTree { private: vector<ll> tree, lazy; ll n, root, size; public: SegmentTree(int currSize) : n(currSize), root(1) { ll x = (ll)(ceil(log2(currSize))); size = 2*(ll)pow(2, x); tr...
C++
0137910e44e01385a22cac1afec94ead
edb91085d0250d96aa294a56fc94653d
2,400
PASSED
#include <bits/stdc++.h> using namespace std; #define mo 100005 long long num_x[mo],time_y[mo]; void read(long long a[],long long n) { for(long long i=1;i<=n;i++) cin>>a[i]; } #define mk make_pair vector< pair<long long ,long long > > tree[mo]; long long s_tree[mo*40],s_trees[mo*40]; void update(long long...
C++
0137910e44e01385a22cac1afec94ead
16b286fe574e25749d7ad1e7c45954d1
2,400
PASSED
// Brijesh Panara (201601074) // DAIICT (India) #include <bits/stdc++.h> #include <time.h> using namespace std; #define ll long long #define ld long double #define pb push_back #define mp make_pair #define ff first #define ss second #define precision(x,d) cout<<fixed<<setprecision(d)<<x #define minQueue priority_queu...
C++
0137910e44e01385a22cac1afec94ead
fb6dff9d3f1192fc73141d3ac3468183
2,400
PASSED
#include <bits/stdc++.h> using namespace std; #define ll long long #define int ll ll ileCiastek[100000 + 5]; ll ileCzasuNaCiastko[100000 + 5]; ll ojciec[100000 + 5]; vector<int> lista[100000 + 5]; bool odw[100000 + 5]; pair<ll,ll> dp[1000000 + 5]; ll l[100000 + 5]; ll T; ll koszt[100000 + 5]; ll wynikiWstepne[100000 ...
C++
0137910e44e01385a22cac1afec94ead
23a1378c324162d532b8408294e799bc
2,400
PASSED
#include<bits/stdc++.h> using namespace std; template<typename F, typename S> ostream &operator<<(ostream &os, const pair<F, S> &p) { return os << "(" << p.first << ", " << p.second << ")"; } template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os << "{"; typename vector<T>::const_i...
C++
0137910e44e01385a22cac1afec94ead
05a5e376bb0ffc9df5a12fb4b26aee14
2,400
PASSED
#include<bits/stdc++.h> using namespace std; template<typename F, typename S> ostream &operator<<(ostream &os, const pair<F, S> &p) { return os << "(" << p.first << ", " << p.second << ")"; } template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os << "{"; typename vector<T>::const_i...
C++
0137910e44e01385a22cac1afec94ead
7ef24fc26dbf9ce051d9eeddb2159914
2,400
PASSED
#include<bits/stdc++.h> using namespace std; template<typename F, typename S> ostream &operator<<(ostream &os, const pair<F, S> &p) { return os << "(" << p.first << ", " << p.second << ")"; } template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os << "{"; typename vector<T>::const_i...
C++
0137910e44e01385a22cac1afec94ead
a81c305eb06c69a621a3e401ca04c8c7
2,400
PASSED
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 7; long long tree[4 * N]; long long tX[4 * N]; int cnt; void update(int v, int l, int r, int pos, int t, int x){ if(l == r){ tree[v] += t * (long long)x; tX[v] += x; } else{ int m = (r + l) / 2; if(pos <= ...
C++
0137910e44e01385a22cac1afec94ead
8ec64c7aa6aaa45db7c5db9ddb1a6890
2,400
PASSED
#include<bits/stdc++.h> using namespace std; int n,m,c,t[1005]; int main() { for(cin>>n>>m>>c,memset(t,0,sizeof(t));m--;) { int x;cin>>x; if((x<<1)<=c) {for(int i=1;i<=n;i++) if(t[i]>x||!t[i]) {t[i]=x,cout<<i<<endl;break;}} else {for(int i=n;i>=1;i--) if(t[i]<x||!t[i]) {t[i]=x,cout<<i<<endl;break;}} fflush(st...
C++
305159945f077d5fff514bfd398eb10e
cba332c8924aaf9fa8e29e4dfe57fde7
2,000
PASSED
#include<bits/stdc++.h> using namespace std; int n,m,c; int a[1005]; int main() { int cnt = 0; cin>>n>>m>>c; for(int i = 0 ; i < m ; ++i) { int x; cin>>x; if(x <= c / 2) { for(int j = 1 ; j <= n ; ++j) { if(x < a[j]) ...
C++
305159945f077d5fff514bfd398eb10e
6cd246cd3c0cbd0bd38d2caf12cce00b
2,000
PASSED
#include<bits/stdc++.h> #define up(l,r,i) for(int i=l;i<=r;i++) #define dn(l,r,i) for(int i=l;i>=r;i--) using namespace std; typedef long long LL; const int INF =2147483647; const int MAXN =1e3+3; int n,m,c,t,A[MAXN],f; int main(){ scanf("%d%d%d",&n,&m,&c); up(1,m,i){ scanf("%d",&t); if(t<=c/2){ ...
C++
305159945f077d5fff514bfd398eb10e
54f2dd8cd59e7b7e092b61646b4ec884
2,000
PASSED
#include<bits/stdc++.h> #include<tr1/unordered_map> #define fi first #define se second #define show(a) cout<<a<<endl; #define show2(a,b) cout<<a<<" "<<b<<endl; #define show3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl; #define max3(a,b,c) max(a,max(b,c)) #define min3(a,b,c) min(a,min(b,c)) using namespace std; typedef long l...
C++
305159945f077d5fff514bfd398eb10e
ce4c021e781e656e023900e10712fd31
2,000
PASSED
#include <bits/stdc++.h> using namespace std; int n, m, c; #define N 1010 int a[N]; int main() { scanf("%d %d %d", &n, &m, &c); memset(a, -1, sizeof a); bool rv = 0; for (int step = 1, x; step <= m; step ++) { scanf("%d", &x); if (x <= c / 2) { int i = 1; while (i < n && a[i] != -1 && a[i] <= x) i ++;...
C++
305159945f077d5fff514bfd398eb10e
12242b0e52558dbe069fb51aa78cb3b4
2,000
PASSED
#include <cstdio> #include <algorithm> using namespace std; const int MAXN=1100; int a[MAXN]; int main() { // freopen("B.in", "r", stdin); // freopen("B.out", "w", stdout); int n, m, c; scanf("%d%d%d", &n, &m, &c); while (m--) { int v; scanf("%d", &v); if (v<=c/2) { int p=1; while (a[p]!=0&&v>=a[p]) p...
C++
305159945f077d5fff514bfd398eb10e
2101364f7e09f242f41a21d0e6ea23b2
2,000
PASSED
#include<bits/stdc++.h> using namespace std; const int MX = (1<<20); typedef long long ll; int arr[MX] , n , C , m; int main(){ cin>>n>>m>>C; memset(arr , -1 , sizeof(arr)); while(m--){ int x; cin>>x; int pos = -1; if(x <= C/2){ for(int j = 1 ; j <= n ; j++){ ...
C++
305159945f077d5fff514bfd398eb10e
c9bbece76047943c60c97b886bde931b
2,000
PASSED
#include <bits/stdc++.h> using namespace std; int t[1005],n,m,c,x,k,i; int main() { ios::sync_with_stdio(false); cin>>n>>m>>c; for(i=0;i<m;i++) { cin>>x; if(c/2.0>=x) for(k=0;k<n;k++) if((t[k]>x)||(t[k]==0)) { t[k]=x; cout<<k+1<<endl; break; } if(c/2.0<x) for(k=n-1;k>=0;k--) if((t[k]<x)||...
C++
305159945f077d5fff514bfd398eb10e
b79857b06b7cb0e53d48a20c414e4d3e
2,000
PASSED
#include <bits/stdc++.h> using namespace std; const int MaxN = 2333; int n, m, c, a[MaxN]; int main() { int i, t = 0; cin >> n >> m >> c; while(m--) { int x, i; cin >> x; if(x * 2 <= c) for(i = 1; a[i] && a[i] <= x; i++); else for(i = n; a[i] && a[i] >= x; i--); t += !a[i]; a[i] = x; cout << i << e...
C++
305159945f077d5fff514bfd398eb10e
da82fd63996392edb2e6231c4b07ebd4
2,000
PASSED
#include<bits/stdc++.h> using namespace std; int n,m,c,x,p[1010]; int main() { cin>>n>>m>>c; while(m--) { cin>>x; if(x*2<=c) { for(int i=1; i<=n; ++i) if(p[i]>x||!p[i]) { p[i]=x; cout<<i<<endl; break; } } else { for(int i=n; i; --i) if(p[i]<x||!p[i]) { p[i]=x; cout<<i<...
C++
305159945f077d5fff514bfd398eb10e
f2652d6589bb1ed867a98e348c1c5e52
2,000
PASSED
#include <bits/stdc++.h> using namespace std; bool check(string s) { int n = s.size(); for (int i = 0; i < n / 2; i++) if (s[i] != s[n - 1 - i]) return false; return true; } string move(string s) { int n = s.size(); return s[n - 1] + s.substr(0, n - 1); } int main() { string s; cin >> s; string t = s; ...
C++
ffdef277d0ff8e8579b113f5bd30f52a
ffbcf1800f1bd8b95c0abfb26d5a47fc
1,800
PASSED
#include <bits/stdc++.h> using namespace std; int main(){ string s, t = "", p; cin >> s; int n = s.length(); set<char> r; for(int i = 0; i < n; i++) r.insert( s[i] ); if( r.size() == 1 ){ cout << "Impossible" << endl; return 0; } if( r.size() == 2 &&...
C++
ffdef277d0ff8e8579b113f5bd30f52a
0dac777d316b68b39ad4b62a7b619094
1,800
PASSED
#include <iostream> #include <stdio.h> #include <vector> #include <algorithm> #include <math.h> #include <bits/stdc++.h> #include <string.h> #include <queue> #include <map> #define ll long long int using namespace std; int cc(string a,int n) { int i; if(n%2==0) { for(i=0;i<(n+1)/2;i++) { ...
C++
ffdef277d0ff8e8579b113f5bd30f52a
043f566169ef0760a1a5db20b518a4ff
1,800
PASSED
#include "bits/stdc++.h" using namespace std; #define ll long long int #define rep(i,n) for( int i = 0; i < n; i++ ) #define rrep(i,n) for( int i = n; i >= 0; i-- ) #define REP(i,s,t) for( int i = s; i <= t; i++ ) #define RREP(i,s,t) for( int i = s; i >= t; i-- ) #define dump(x) cerr << #x << " = " << (x) << endl; #de...
C++
ffdef277d0ff8e8579b113f5bd30f52a
e315eb48e99547e4aa47869042fb52af
1,800
PASSED
#include<bits/stdc++.h> using namespace std; #define fr(i,n) for(int i=0; i<n; i++) #define rep(i, st, en) for(int i=st; i<=en; i++) typedef long long ll; typedef pair<int, int> pii; ll mod = 1e9+7; int findMinCuts(string &s, int n){ if(n&1) return 2; string l = s.substr(0, n/2); string k = s.sub...
C++
ffdef277d0ff8e8579b113f5bd30f52a
ee425e2d364770fbf725fed97f000243
1,800
PASSED
#include <bits/stdc++.h> using namespace std; #define DIM 300007 #define DIM2 100007 #define DIM3 200007 #define INF 10E16 #define MAXN 2750137 #define LG 18 #define MODULO 998244353 #define fi first #define sc second #define pb push_back #define pu push #define sz size() #define po(power) ( 1<<power) #define schnell ...
C++
ffdef277d0ff8e8579b113f5bd30f52a
838729e025168c582a359b258dff4ec2
1,800
PASSED
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; template <typename T> using ordered_set_rev = tr...
C++
ffdef277d0ff8e8579b113f5bd30f52a
cce8a5cb942deae0ac3590f3ae9d225e
1,800
PASSED
// If you want something you've never had, you must be willing to do something you've never done #include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; typedef pair<int,int> ii; typedef long long ll; typedef long double ld; ...
C++
ffdef277d0ff8e8579b113f5bd30f52a
15a885e6b9a83f83dd5e609da6c9e4d1
1,800
PASSED
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<n;++i) #define repa(i,a,n) for(int i=a;i<n;++i) #define repr(i,n) for(int i=n-1;i>=0;--i) #define repba(i,b,a) for(int i=b;i>=a;--i) #define repab(i,a,b) for(int i=a;i<b;++i) #define ll long long #define ull unsigned long long #define vi vector...
C++
ffdef277d0ff8e8579b113f5bd30f52a
5d031e05192a859c2b2b4623465bb22d
1,800
PASSED
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 5; string s; int n; bool ispal(string x) { string y = x; reverse(y.begin() , y.end()); return x == y; } int solve(int from) { string act = ""; for(int i = from; i < n; ++i) { act += s[i]; } string x = ""; for(int i = 0; i < from; ++i) x += ...
C++
ffdef277d0ff8e8579b113f5bd30f52a
a7d51c773bde584859996e5948a75372
1,800
PASSED
#include <bits/stdc++.h> using namespace std; const int N = 1e6+10 ; int miu[N],p[N],cnt ; bool vis[N] ; inline void prework(int n){ miu[1] = 1 ; for(int i = 2 ; i <= n ; i++){ if(!vis[i]) p[++cnt] = i,miu[i] = -1 ; for(int j = 1 ; j <= cnt ; j++){ if(p[j] > n/i) break ; vis[i*p[j]] = true ; if(i%p[j] =...
C++
a5cc9b7ef5222280b20ee7e096a93394
38512bd473ecdd760b06f18dcdd25e2c
2,200
PASSED
#include <set> #include <cctype> #include <cstdio> using namespace std; const int maxN = 1e6; bool vis[maxN + 1]; int mu[maxN + 1], prime[maxN + 1], tot; void Init() { mu[1] = 1; for (int i = 2; i <= maxN; ++ i) { if (!vis[i]) prime[++tot] = i, mu[i] = -1; for (int j = 1; prime[j...
C++
a5cc9b7ef5222280b20ee7e096a93394
89c33c3f2ea30693bb2b17c70bbda1fb
2,200
PASSED
#include<cmath> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<vector> #define rt register int #define l putchar('\n') #define ll long long #define r read() using namespace std; inline ll read() { register ll x = 0; char zf = 1; char ch; while (ch != '-' && !isdigit(ch)) ch = ge...
C++
a5cc9b7ef5222280b20ee7e096a93394
067388940acc1cefd0e075babad83722
2,200
PASSED
#include<bits/stdc++.h> using namespace std; const int maxn=1e6+10; typedef long long ll; const ll mod=1e9+7; int u[maxn],p[maxn],len; bool vis[maxn]; void mu(){ u[1]=1; for(int i=2;i<maxn;i++){ if(!vis[i]){ u[i]=-1; p[++len]=i; } for(int j=1;p[j]*i<maxn;j++){ vis[p[j]*i]=1; if(i%p[j]==0) break; ...
C++
a5cc9b7ef5222280b20ee7e096a93394
81bfe30c3cc7326f8e3b147605707bb7
2,200
PASSED
#include<cmath> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<vector> #define rt register int #define l putchar('\n') #define ll long long #define r read() using namespace std; inline ll read() { register ll x = 0; char zf = 1; char ch; while (ch != '-' && !isdigit(ch)) ch = ge...
C++
a5cc9b7ef5222280b20ee7e096a93394
fb06bffac831ebc504ac0883c77862e2
2,200
PASSED
#include <bits/stdc++.h> using namespace std; #define rep(i, l, r) for (int i = l; i<r;i++) #define vi vector<int> #define all(v) v.begin(),v.end() #define pb(c) push_back(c) #define vii vector<pair<int,int>> #define ii pair<int,int> #define max(a, b) (((a)<(b))?b:a) #define min(a, b) ((a>b)?b:a) #define mp(i, j) make_...
C++
a5cc9b7ef5222280b20ee7e096a93394
d0d64e47d0065a8f4ee628ea88041b2a
2,200
PASSED
#include<bits/stdc++.h> #define X first #define Y second #define eb push_back #define pb pop_back #define mp make_pair #define siz(a) int(a.size()) //for traversing the container (bcoz we cannot access linked list etc with direct index) //c stands for container and it for iterator #define tr(c, it) \ for(typeof(c.b...
C++
a5cc9b7ef5222280b20ee7e096a93394
a7dfa4c7c1cfe0d32a329867ee9d3cd6
2,200
PASSED
#include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> #include <iostream> #include <algorithm> #include <string> #include <vector> #include <queue> #include <set> #include <map> using namespace std; typedef pair<int,int> P; typedef __int64 ll; vector<int> prime; vector<ll> factors; bool not_prime[100...
C++
a5cc9b7ef5222280b20ee7e096a93394
a62c868ac47505831e406fc341d5ebdb
2,200
PASSED
#include<bits/stdc++.h> using namespace std; #define sd(x) scanf("%lld",&x) #define slld(x) scanf("%lld",&x) #define ss(x) scanf("%s",x) #define mod 1000000007 #define bitcount __builtin_popcountll #define ll long long #define pb push_back #define pi pair<ll,ll> #define pii pair<pi,ll> #define mp make_pair vector<ll> c...
C++
a5cc9b7ef5222280b20ee7e096a93394
f2605e8b585a9c7449334823be2d2425
2,200
PASSED
#include<bits/stdc++.h> using namespace std; vector<int>P; int L=0,T[300005]; bool V[1000005]={0}; long long get(long long x) { int i,j,k; long long s,ans=0; for(i=0;i<(1<<P.size());i++) { for(s=1,k=j=0;j<P.size();j++)if((1<<j)&i)k^=1,s*=P[j]; ans+=x/((k?-1:1)*s); } return ans; } int main() { int i,j,x,p...
C++
a5cc9b7ef5222280b20ee7e096a93394
319e7c5bf312fad6d7890045f9c147af
2,200
PASSED
// ____ ____ _ // | _ \ _ __| _ \ ___ _ __ __| |_ __ ___ // | | | | '__| | | |/ _ \ '_ \ / _` | '__/ _ \ // | |_| | |_ | |_| | __/ | | | (_| | | | (_) | // |____/|_(_)|____/ \___|_| |_|\__,_|_| \___/ // #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include...
C++
89bf97a548fe12921102e77dda63283a
38643b4fc35284c21b5244f5563638d3
2,100
PASSED
#include<iostream> #include<vector> #include<stack> #include<cmath> #include<algorithm> #include<set> #include<map> #include<string> #include<tuple> #include<queue> #include<ctime> #include<bitset> #include<random> using namespace std; //#define double long long; typedef unsigned long long ull; #define double long doub...
C++
89bf97a548fe12921102e77dda63283a
fc8cef922a03fda06f48e0f8caabc73f
2,100
PASSED
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <vector> #include <algorithm> #include <queue> #include <string> #include <map> #include <set> #include <unordered_map> #include <unordered_set> #include <stack> using namespace std; typedef long long ll; #define pii pair<int, int> #define maxn 100001 int n...
C++
89bf97a548fe12921102e77dda63283a
60562567afb192a891534c49917b61a8
2,100
PASSED
//WrittenBiDP //algorithm_lca #include <iostream> #include <fstream> #include <vector> using namespace std; typedef vector <int> vi; typedef vector <bool> vb; #define MAXL 20 vector <vi> tree; vector <vi> up; vi dist, child; vb was; void dfs(int apex, int dad) { was[apex] = true; up[apex][0] = dad; for (int i...
C++
89bf97a548fe12921102e77dda63283a
e5b3b69e49f9a976ac09174c5c827601
2,100
PASSED
#include <iostream> #include <vector> #include <algorithm> using namespace std; typedef vector<int> vi_t; void dfs(vector<vi_t>& C, vi_t& Pred, vi_t& L, vi_t& size, int cr) { int total_size = 1; for (size_t c = 0; c < C[cr].size(); ++c) { int t = C[cr][c]; if (Pred[t] == -1) { Pred[t] = cr; L[t] = L[cr...
C++
89bf97a548fe12921102e77dda63283a
aa1d8a2e43ece3a29ac1a54628247f0e
2,100
PASSED
#include <iostream> #include <vector> #include <string> #include <map> using namespace std; vector<int> g[1000000]; int tin[1000000]; int tout[1000000]; int up[1000000][20]; int cnt[1000000]; int h[1000000]; int t = 0; int dfs(int v, int p, int d) { up[v][0] = p; for (int i = 1; i < 20; i++) up[v][i...
C++
89bf97a548fe12921102e77dda63283a
0ac188de4f2861794699532cf67ea1a1
2,100
PASSED
#include<cstdio> #include<algorithm> #include<cstring> using namespace std; int i,j,k,n,m,x,y,p,k1,size[100001]; struct Node{int ed,before;}s[1000001]; int deep[100001],vis[100001],fox[100001]; int fa[100001][21]; void add(int x,int y) {s[++k1].ed=y; s[k1].before=fox[x]; fox[x]=k1; } void get(int x) { int i; for (i=1...
C++
89bf97a548fe12921102e77dda63283a
92b35c79265b0723350f37949cd09c8e
2,100
PASSED
#define _USE_MATH_DEFINES #include <algorithm> #include <cstdio> #include <functional> #include <iostream> #include <cfloat> #include <climits> #include <cstring> #include <cmath> #include <fstream> #include <list> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #inc...
C++
89bf97a548fe12921102e77dda63283a
d35afcb0623b80262560c68b97797a67
2,100
PASSED
#include <iostream> #include <algorithm> #include <math.h> #include <map> #include <set> #include <vector> #include <algorithm> #include <string> #include <cassert> #include <queue> #include <stack> #include <limits> using namespace std; typedef long long ll; #define M_PI 3.14159265358979323846 bool vv[100007]; v...
C++
89bf97a548fe12921102e77dda63283a
e0875b81a09b315aca2dbe63dde49fe1
2,100
PASSED
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <fstream> #include <vector> #include <string> #include <cassert> #include <iomanip> #include <set> #include <map> #include <algorithm> #include <math.h> #include <ctime> #include <cmath> #include <stack> using namespace std; #define mp make_pair #define sz ...
C++
89bf97a548fe12921102e77dda63283a
c1669239385f2d1a7b9ed716a53b38f6
2,100
PASSED
/***************************************************************************************/ // In The name of GOD // // (*(*(* SaDrA (SADDAS) DaShTi *)*)*) // /*************************************************...
C++
89c27a5c76f4ddbd14af2d30ac8b6330
3253c1b0627ee140a798fcea1e325e50
1,600
PASSED
#include <bits/stdc++.h> using namespace std; set<int> adj[100001]; int c[100001]; bool present[100001]; int main(){ int n, m; cin >> n >> m; for(int i = 1; i <= n; i++) { cin >> c[i]; present[c[i]] = true; } for(int i = 0; i < m; i++){ int a, b; cin >> a >> b; if(c[a] != c[b]){ adj[c[a]].insert(c...
C++
89c27a5c76f4ddbd14af2d30ac8b6330
1885d045d08e504947689ce7098e051d
1,600
PASSED
#include <cstdio> #include <vector> #include <unordered_set> #include <algorithm> using namespace std; typedef pair<int,int> PII; typedef long long LL; const int INF = 1000000007; int n,m,a[100005],x,y,ans=100004; unordered_set<int> u[100005]; int main(){ scanf("%d%d",&n,&m); for(int i=0;i<n;i++){ sc...
C++
89c27a5c76f4ddbd14af2d30ac8b6330
8f31e5855ed8e7fc23920a186b3acede
1,600
PASSED
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <cstdio> #include <set> using namespace std; int main() { //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); long n, m, u, v, t, i, ma; cin>>n>>m; vector<int> c(n+1); set<in...
C++
89c27a5c76f4ddbd14af2d30ac8b6330
4f1d1c794b08bfe8d02cac13c520c3e5
1,600
PASSED
#include <bits/stdc++.h> #define f first #define s second #define mp make_pair #define pb push_back #define INF 1000000000000000000 #define MOD 1000000007 using namespace std; int n, m, x, y, a[100001], mx; set <int> s[100001]; int main() { cin >> n >> m; for (int i = 1; i <= n; i++) cin >> a[i], s[a...
C++
89c27a5c76f4ddbd14af2d30ac8b6330
b660761175b710912fd167cf449d948f
1,600
PASSED
#include<bits/stdc++.h> using namespace std; set<int> s[111111]; int ans = 1e9; main() { #ifndef ONLINE_JUDGE freopen("1.txt", "r", stdin); #endif // ONLINE_JUDGE int n, m; scanf("%d%d", &n, &m); vector<int> col(n); for (int &i : col) { scanf("%d", &i); i--; ans = min(ans...
C++
89c27a5c76f4ddbd14af2d30ac8b6330
f7c8f0e9ea3c5e9651a56342ba7ba5e8
1,600
PASSED
#include <iostream> #include <unordered_set> #include <unordered_map> #include <vector> using namespace std; unordered_map<int,unordered_set<int>> cq;//color_Q(V) function int cols[100005]; int main(){ int n,m,a,b; cin >> n >> m; for(int i = 1; i <= n; ++i) cin >> cols[i],cq[cols[i]]; while(m--){ cin >> a >> b;...
C++
89c27a5c76f4ddbd14af2d30ac8b6330
bda321f5b84e90412f806596184a3380
1,600
PASSED
#include <iostream> #include <set> #include <map> #include <vector> using namespace std; map<int,set<int>> cq;//color_Q(V) function int cols[100005]; int main(){ int n,m,a,b; cin >> n >> m; for(int i = 1; i <= n; ++i) cin >> cols[i],cq[cols[i]]; while(m--){ cin >> a >> b; if(cols[a] != cols[b]) cq[cols[a]]...
C++
89c27a5c76f4ddbd14af2d30ac8b6330
f66f268941135841a1a6d1e79ecf8729
1,600
PASSED
#include <iostream> #include <set> #include <map> #include <vector> using namespace std; map<int,set<int>> cq;//color_Q(V) function int cols[100005]; int main(){ int n,m,a,b; cin >> n >> m; for(int i = 1; i <= n; ++i) cin >> cols[i],cq[cols[i]]; while(m--){ cin >> a >> b; if(cols[a] != cols[b]) cq[cols[a]]...
C++
89c27a5c76f4ddbd14af2d30ac8b6330
a62924388fbba5776fb2dd5038b851ee
1,600
PASSED
#include <iostream> #include <set> #include <vector> using namespace std; set<int> cq[100005];//color_Q(V) function int cols[100005]; int main(){ int n,m,a,b; cin >> n >> m; for(int i = 1; i <= n; ++i) cin >> cols[i]; while(m--){ cin >> a >> b; if(cols[a] != cols[b]) cq[cols[a]].insert(cols[b]), cq[cols...
C++
89c27a5c76f4ddbd14af2d30ac8b6330
2ffd8718449027a984e5cd4007173b6c
1,600
PASSED
#include<bits/stdc++.h> #define pb push_back #define vi vector < int > #define ii pair < int, int > #define vii vector < pair < int, int > > #define vvi vector < vector < int > > #define ll long long #define X first #define Y second #define mp make_pair #define FOR( i, lo, hi ) for( int i = (lo);i < (hi);i++ ) #defin...
C++
6aa01cf719d2ac1dfe80b00e6eda438c
84ee14d2af8eb183a28fe6c400a01388
1,700
PASSED
#include <bits/stdc++.h> using namespace std; const int M = 2e5 + 7; int a[M], p[M]; int main() { int t; scanf("%d", &t); while(t--){ //memset(p, 0, sizeof p); int n; scanf("%d", &n); for(int i = 1; i <= n; i++) scanf("%d", a + i); int m; ...
C++
6aa01cf719d2ac1dfe80b00e6eda438c
c2d89c95cf01e1824c2a6e589c99182e
1,700
PASSED
#include <bits/stdc++.h> using namespace std; const int M = 2e5 + 7; int a[M], p[M]; int main() { ios_base::sync_with_stdio(false), cin.tie(0); int t; cin >> t; while(t--){ //memset(p, 0, sizeof p); int n; cin ...
C++
6aa01cf719d2ac1dfe80b00e6eda438c
aa37443991f745bf497c1dfb5adb5dd9
1,700
PASSED
#include<bits/stdc++.h> using namespace std; //Optimisations #pragma GCC target ("avx2") #pragma GCC optimization ("unroll-loops") #pragma GCC optimize("O2") //shortcuts for functions #define pb push_back #define mp make_pair #define ff first #define ss second #define all(v) v.begin(),v.end() #define prec(n) fixed<<se...
C++
6aa01cf719d2ac1dfe80b00e6eda438c
1cfdf3201b92d69f2442bf83d57d4c79
1,700
PASSED
#include<bits/stdc++.h> using namespace std; #define ll long long int #define me BOSS #define bug() cout<<"AIkahne aise"<<endl ll A[200001]; /* Precode Start Here *\ Sieve void sieve() { for(ll i=3; i<=2000; i+=2) { for(ll j=i*i; j<=4000000; j+=i) A[j]=1; } v.push_back(2); ...
C++
6aa01cf719d2ac1dfe80b00e6eda438c
5c3c9a658791b675908217adf112f5d3
1,700
PASSED
#include<bits/stdc++.h> using namespace std; #define ll long long int #define me BOSS #define bug() cout<<"AIkahne aise"<<endl ll A[200001]; /* Precode Start Here *\ Sieve void sieve() { for(ll i=3; i<=2000; i+=2) { for(ll j=i*i; j<=4000000; j+=i) A[j]=1; } v.push_back(2); ...
C++
6aa01cf719d2ac1dfe80b00e6eda438c
59f8dbecbc98afb0bcdf5cf990792c73
1,700
PASSED
#include <bits/stdc++.h> #define fi first #define se second #define pb push_back #define mp make_pair #define MOD 1000000007 #define pii pair<int,int> #define LL long long using namespace std; int a[200005], n; pii p[200005]; int main () { ...
C++
6aa01cf719d2ac1dfe80b00e6eda438c
67cce3b93ed860ebb35fa8216f34c4e8
1,700
PASSED
#include <bits/stdc++.h> using namespace std; #define rep(N) for (int repetitions=0; repetitions<N; repetitions++) #define forN(i, N) for (int i=0; i<N; i++) #define forNr(i, N) for (int i=N-1; i>=0; i--) #define forNn(i, n, N) for (int i=n; i<N; i++) #define all(obj) (obj).begin(), (obj).end() typedef long long ll;...
C++
6aa01cf719d2ac1dfe80b00e6eda438c
a6a23fa9c092fb4c87f92488ee4cd8fb
1,700
PASSED
#include <bits/stdc++.h> using namespace std; typedef pair<int,int> ii; int t; int n; int a[200011]; int m; ii b[200011]; int val[200011]; int mx[200011]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> t; while(t--) { cin >> n; for (int i=1;i<=n;i++) cin >> a[i]; cin ...
C++
6aa01cf719d2ac1dfe80b00e6eda438c
d3220089db2d6388fea8637adc736f01
1,700
PASSED
#include <bits/stdc++.h> #define Speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); using namespace std; #define st first #define nd second #define pb push_back #define pf push_front #define all(a) (a).begin(), (a).end() #define lwb lower_bound #def...
C++
6aa01cf719d2ac1dfe80b00e6eda438c
277971af651028e2ce61d4fefea2d6a6
1,700
PASSED
import java.util.*; public class Main{ public static void main(String[] args){ Scanner scan = new Scanner(System.in); int T = scan.nextInt(); for (int o=0;o<T;o++){ String ss = scan.next(); String cc = scan.next(); String[] s = ss.split(""); St...
Java
88743b7acb4a95dc0d5bb2e073714c49
cf25a037732c2dfca52b68957d316054
1,600
PASSED
//package contest1281; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class B { private final FastReader fastReader = new FastReader(); private void swap(char[] chars, int i, int j) { char ...
Java
88743b7acb4a95dc0d5bb2e073714c49
81d239a5aad547445f8d88890746766d
1,600
PASSED
import java.io.*; import java.util.*; public class Main { static point a[]; static int check(int wx, int wy, int sx, int sy) { //waurma int cnt = 0; for (int i = 0; i < a.length; i++) { int x = a[i].x; int y = a[i].y; if (wx >= Math.min(sx, x) && wy >= Math...
Java
88743b7acb4a95dc0d5bb2e073714c49
4dbd32654c3ad3accd5ba015b0afaa1e
1,600
PASSED
import java.io.*; import java.util.*; import java.util.Map.Entry; import java.util.stream.*; import java.util.function.*; import java.util.function.Predicate; import java.math.BigInteger; import java.sql.Array; import java.time.Instant; import java.time.Duration; import java.util.concurrent.*; public class Main { ...
Java
88743b7acb4a95dc0d5bb2e073714c49
857bc01c58e4d17ab27b89520fb54e03
1,600
PASSED
import java.util.*; import java.io.*; public class File { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for (int test = 0; test < t; test++) { char[] a = sc.next().toCharArray(); char[] b = sc.next().to...
Java
88743b7acb4a95dc0d5bb2e073714c49
d070535ad5b42d8880e909d9b3e03b6c
1,600
PASSED
import java.io.*; import java.util.*; public class Main { static class PairComparator implements Comparator<Pair> { @Override public int compare(Pair x, Pair y) { if (x.val < y.val)return -1; if (x.val > y.val)return 1; if (x.val == y.val){ if (x.ind < y.ind)return -1; if (x.ind > y.ind)return 1;...
Java
88743b7acb4a95dc0d5bb2e073714c49
7638121333b843cdf7b7a82a06028692
1,600
PASSED
import java.io.PrintWriter; import java.util.Scanner; public class Azamon { static PrintWriter out; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); out = new PrintWriter(System.out); int t = sc.nextInt(); for (int i = 0; i < t; i...
Java
88743b7acb4a95dc0d5bb2e073714c49
25d9a71710199044daa4a1cfa49eddc2
1,600
PASSED
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(Strin...
Java
88743b7acb4a95dc0d5bb2e073714c49
080a0031b3a60803caba0fca88bb4395
1,600
PASSED
import java.io.*; import java.util.*; public class d2prac implements Runnable { private boolean console=false; public void solve(int t) { int i; char s[]=in.ns().toCharArray(); int n=s.length; char s1[]=in.ns().toCharArray(); for(i=0;i<n-1;i++) { char min=s[i]; int ind=-1; for(int j=n-1;j>=i+...
Java
88743b7acb4a95dc0d5bb2e073714c49
42e3b3b993c4870645984046ea2616ed
1,600
PASSED
import java.io.*; import java.util.*; public class B607{ public static void main(String[] args) throws Exception { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0){ String st=sc.next(); String st2=sc.next(); if(st.compareTo(st2)<0){ System.out.println(st);...
Java
88743b7acb4a95dc0d5bb2e073714c49
aa0af7e9d0613524a35910c481b59a31
1,600
PASSED