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 <bits/stdc++.h> using namespace std; #define FOR(i,n) for (int i=1;i<=n;i++) #define REP(i,a,b) for (int i=a;i<=b;i++) #define pb push_back #define fi first #define se second #define pi pair<int,int> #define mp make_pair #define sz(x) ((int)(x).size()) typedef long long ll; const int inf=0x3f3f3f3f; const...
C++
c2362d3254aefe30da99c4aeb4e1a894
5515fb387a422049bd3fb13e8cae8e44
2,200
PASSED
#include <bits/stdc++.h> using namespace std; #define FOR(i,n) for (int i=1;i<=n;i++) #define REP(i,a,b) for (int i=a;i<=b;i++) #define pb push_back #define fi first #define se second #define pi pair<int,int> #define mp make_pair #define sz(x) ((int)(x).size()) typedef long long ll; const int inf=0x3f3f3f3f; const...
C++
c2362d3254aefe30da99c4aeb4e1a894
5309d74e54890664be1a6e1c02923667
2,200
PASSED
#include<stdio.h> #include<math.h> int main() { long x,n,k,i,j,z=0,t; scanf("%ld",&t); while(t--){ scanf("%ld",&n); z=1; i=2; j=1e9; while(j>0){ z=pow(2,i)-1; j=(n%z); i++; } printf("%ld\n",(n/z)); } }
C
d04cbe78b836e53b51292401c8c969b2
0f020fb4b14b9b1404bc22e6667217ea
900
PASSED
#include <stdio.h> int main(void) { long long t, n, initial, sum; scanf("%lld",&t); while(t--) { scanf("%lld",&n); initial = 4; sum = 3; while(n%sum != 0) { sum+=initial; initial*=2; } printf("%lld\n",n/sum); } ...
C
d04cbe78b836e53b51292401c8c969b2
1837c1210acbcc9212baf87724a249d2
900
PASSED
#include <stdio.h> #include <stdlib.h> int main() { int t; scanf("%d\n",&t); while(t--) { long i,n,p=1,power,num; scanf("%ld\n",&n); long *a=(long *)malloc(sizeof(long)); a[0]=3; i=0; power=2; while(a[i]<=n) { power=power*2; ...
C
d04cbe78b836e53b51292401c8c969b2
dabc09eaca2455e1ef27ae309524e462
900
PASSED
#include <stdio.h> #include<math.h> int main() { int t; scanf("%d" ,&t); while(t--){ long long int n,i,c=0,d=0; scanf("%lld" ,&n); d=(int)(log(n+1)/log(2)); for(i=2;i<=d+1;i++){ c=pow(2,i)-1; if(n%c==0){ ...
C
d04cbe78b836e53b51292401c8c969b2
84959501e55c2022f33f7ca314f5801e
900
PASSED
#include<stdio.h> #include<stdlib.h> long long int candies(long long int n); int main() { int test,i; scanf("%d ",&test); long long int arr[test]; for(i=0;i<test;i++) { scanf("%lld",&arr[i]); } for(i=0;i<test;i++) { printf("%lld\n",candies(arr[i])); } } long long int ...
C
d04cbe78b836e53b51292401c8c969b2
c3f257ccba5fee0c5bf279e1b9897b92
900
PASSED
#include<stdio.h> #include<math.h> int main() { int t; scanf("%d",&t); while(t>0) { long long n,sum=0,i,x=0,k; scanf("%lld",&n); for(k=2; ; k++) { i=n/(pow(2,k)-1); for(i=i;i>0; i--) { sum=i*(pow(2,k)-1); ...
C
d04cbe78b836e53b51292401c8c969b2
dd5856660df9aeebb28dec53fcfdec94
900
PASSED
#include<stdio.h> #include<malloc.h> #include<math.h> int main() { int flag=0,i; int cases,k=2,z,rem; int *arr; double n,x; scanf("%d",&cases); arr=( int*)malloc(cases*sizeof(int)); for(i=0;i<cases;i++) scanf("%d",&arr[i]); for(i=0;i<cases;i++) { flag=0;k=2; n=(do...
C
d04cbe78b836e53b51292401c8c969b2
f017e649ce9b5b56a1c713e2ed403244
900
PASSED
#include<math.h> #include<stdio.h> int main() { int t; scanf("%d",&t); for(int i=0;i<t;i++) { int n; long k; scanf("%d",&n); for(k=2;;k++) { if(n%((long)pow(2,k)-1)==0) break; } printf("%lu\n",(n/((long)pow(2,k)-1))); } return 0; }
C
d04cbe78b836e53b51292401c8c969b2
68daf7d72e4b8a0d197a78dbb141ba98
900
PASSED
#include <stdio.h> #include<math.h> int main(void) { int t; scanf("%d",&t); while(t) { long long int a,n,temp=3,i=2; scanf("%lld",&n); while(n%temp!=0) { temp=temp+pow(2,i); i++; } a=n/temp; printf("%lld\n",a); ...
C
d04cbe78b836e53b51292401c8c969b2
b49476b1a5be8bd4557dc3b0b82923d6
900
PASSED
#include <stdio.h> #include<math.h> int main(void) { long int t,x,i,j,n,ans=0; scanf("%ld",&t); long c[t]; for(i=0;i<t;i++) scanf("%ld",&c[i]); for(i=0;i<t;i++){ n=0; for(j=2;n<=c[i];j++){ n=pow(2,j)-1; x=c[i]%n; if (x==0) {ans=c[i]/n; break;}} printf("%ld\n",ans); } r...
C
d04cbe78b836e53b51292401c8c969b2
e06ee8c186add66ea6e3e1cf60ee3387
900
PASSED
#include<bits/stdc++.h> using namespace std; const int maxn=1e5+10; long long a[maxn],b[maxn],sum[maxn],f[maxn]; int main() { int n,k; scanf("%d%d",&n,&k); for(int i=1;i<=n;i++) { scanf("%lld",a+i); sum[i]=sum[i-1]+a[i]; } for(int i=1;i<=n;i++)scanf("%lld",b+i); if(k>=2) { long long Min=1e16; for(int i=1;...
C++
ca6325cc32ba34614e3bd1257d2eef97
2421929b37cef7d4686b5d9c2eadb6d3
2,200
PASSED
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; #define fi first #define se second #define mp make_pair #define pb push_back #define pop_b pop_back #define pf push_front #define pop_f pop_front #define mt make_tuple #define eb emplace_back #define sf(x) sizeof(x) #define len(x) x.length() ...
C++
ca6325cc32ba34614e3bd1257d2eef97
c9eda37579ebb1153fee5a82d421cfb2
2,200
PASSED
#include "iostream" #include "cstdlib" #include "cstdio" #include "cstring" #include "cmath" #include "cctype" #include "ctime" #include "iomanip" #include "algorithm" #include "set" #include "queue" #include "map" #include "stack" #include "deque" #include "vector" #define R register #define INF 0x3f3f3f3f #define deb...
C++
ca6325cc32ba34614e3bd1257d2eef97
83baa6798f7cd6676e241f836d97380d
2,200
PASSED
////#include <bits/stdc++.h> ////using namespace std; ////int main() ////{ //// int T; //// cin>>T; //// while(T--) //// { //// long long n; //// long long ans=0; //// scanf("%lld",&n); //// bool flag=true; //// while(n>=1) //// { //// if(flag) //// ...
C++
ca6325cc32ba34614e3bd1257d2eef97
8855eb89f8937b5c6cfbd14b12f931e5
2,200
PASSED
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn=1e5+5; const int inf=1e9+10; int n,k; ll a[maxn],d[maxn],sum[maxn],mn[maxn]; ll ans; int main(){ scanf("%d%d",&n,&k); mn[0]=inf; for(int i=1;i<=n;i++){ scanf("%d",&a[i]); sum[i]=sum[i-1]+a[i]; } for(int i=1;i<=n;i++){ scanf("%d...
C++
ca6325cc32ba34614e3bd1257d2eef97
98f38c4827d1f9cd925ebecd34f1cf24
2,200
PASSED
#include <bits/stdc++.h> using namespace std; #define ll long long #define mp make_pair #define pb push_back #define eprintf(...) fprintf(stderr, __VA_ARGS__) #define rep(i, n) for (int i = 0; i < (int)(n); ++ i) const int mxn = 1e5 + 5; int n, k, a[mxn], d[mxn]; ll sum[mxn]; int main() { ios::sync_with_stdio(f...
C++
ca6325cc32ba34614e3bd1257d2eef97
0e4dd1165ce9547a4acefa0779f19535
2,200
PASSED
#include<bits/stdc++.h> #define rd(x) x=read() #define inf 1000005 #define N 100005 #define int long long using namespace std; int n,k; int a[N],d[N],mn[N],smn[N],fmn[N],s[N]; inline int read() { int x=0,f=1;char ch=getchar(); while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();if(ch==-1)return 0;} whi...
C++
ca6325cc32ba34614e3bd1257d2eef97
b0f9e84d23d76d15a73fc2763918c8fb
2,200
PASSED
#include<cstdio> #include<algorithm> #include<cmath> #include<map> #define reg register inline int read(){ register int x=0;register int y=0; register char c=getchar(); while(c<'0'||c>'9'){if(c=='-')y=1;c=getchar();} while(c>='0'&&c<='9') x=x*10+c-48,c=getchar(); return y?-x:x; } #define N 100006 int n; long long ...
C++
ca6325cc32ba34614e3bd1257d2eef97
5d0a535bce8d6f52662fc356fdfb9e2c
2,200
PASSED
#include <bits/stdc++.h> using namespace std; using ll = long long; #define INF (0x3f3f3f3f) int const N = 1e5 + 10; int n, k; ll a[N], d[N]; ll suf[N]; ll pre[N]; int minval, minvalpos; int mincost, mincostpos; int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); #endif minval = INF; minco...
C++
ca6325cc32ba34614e3bd1257d2eef97
2208640f553f1eab452940217d148af8
2,200
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 1e5 + 3; ll A[maxn], D[maxn], dp[maxn], sum[maxn], E[maxn]; int main() { int N, K; scanf("%d%d", &N, &K); for (int i = 1; i <= N; ++i) { scanf("%lld", &A[i]); sum[i] = sum[i - 1] + A[i]; } fo...
C++
ca6325cc32ba34614e3bd1257d2eef97
77984e76b266bed9b9bfe67f850963c1
2,200
PASSED
#define isFile 0 #include <iostream> #include <math.h> #include <queue> #include <cstring> #include <string> #include <algorithm> #include <iomanip> #include <vector> #include <stack> #include <iomanip> #include <map> #include <set> #include <utility> #include <cstdlib> #include <fstream> #include <stdio.h> #include <u...
C++
b1eebb3928925b84a95b9f1e5a31e4f3
615e52ceec9031f529a91a6538ac5e34
1,800
PASSED
//__________________Do_What_You_want___// //__________I_DO_What_I_Want___________________________// #include<bits/stdc++.h> #include <map> #include "ext/pb_ds/assoc_container.hpp" #include "ext/pb_ds/tree_policy.hpp" #include "ext/pb_ds/detail/standard_policies.hpp" using namespace __gnu_pbds; using namespace std ; ...
C++
b1eebb3928925b84a95b9f1e5a31e4f3
ed55cd85451a3258dc5a2bb9af33fb5e
1,800
PASSED
#include <bits/stdc++.h> using namespace std; #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define endl "\n" #define int long long int n; string s; string ans=""; int32_t main() { IOS; cin>>s; n=s.size(); int dig=-1, idx=-1; for(int i=0;i<n;i++) { if(s[i]>='1' && s[i]<='9') { dig=s[i]-'...
C++
b1eebb3928925b84a95b9f1e5a31e4f3
31d7e1faaf845567162e3f5e5a4bacd1
1,800
PASSED
#include "iostream" #include "fstream" #include "algorithm" #include "iomanip" #include "stack" #include "queue" #include "string" #include "vector" #include "map" #include "set" #include "unordered_set" #include "unordered_map" #include "iterator" #include <ctime> #include "bitset" #include "cmath" #include "list" #in...
C++
b1eebb3928925b84a95b9f1e5a31e4f3
8e49ee05041bf9e7a7da476392b58596
1,800
PASSED
#include<iostream> #include<string> #include<cmath> #include<cstdio> #include<cstring> #include<iomanip> #include<cstdlib> #include<ctime> #include<set> #include<map> #include<utility> #include<queue> #include<vector> #include<stack> #include<sstream> #include<algorithm> //#include"functions.h" #define pb push_back #de...
C++
b1eebb3928925b84a95b9f1e5a31e4f3
9c55677b96667e7c7446cebf3ca0f5c9
1,800
PASSED
#include<bits/stdc++.h> using namespace std; #define ll long long int #define mod 1000000007 #define endl "\n" #define pb push_back #define mp make_pair int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); string s; cin>>s; ll n=s.length(),m,i,j,p,x,y; for(i=0;;i++) { if(s[i]!='0') { break; ...
C++
b1eebb3928925b84a95b9f1e5a31e4f3
ad71a48cafa9d791d18534147590f4e8
1,800
PASSED
/** * author: vdv09/op_invalid * created: 13.10.2020 **/ #pragma gcc optimize("Ofast,no-stack-protector,tune=native") #pragma gcc optimize("sse,sse2,sse3,sse4,ssse3") #pragma gcc optimize("abm,mmx,avx,avx2,unroll-loops,fast-math,section-anchors") #include <bits/stdc++.h> using namespace std; #define ...
C++
b1eebb3928925b84a95b9f1e5a31e4f3
51f309a0c5bb97468b954642a142b970
1,800
PASSED
#include <cstdio> #include <cstring> #include <string> #include <map> #include<math.h> #include <queue> #include<iostream> #include <algorithm> using namespace std; int a[1000005]; int main() { string s; cin>>s; int n=s.size(); int it; it=s.find('.'); for(int i=0; i<n; i++) a[i]=s[i]-'0'...
C++
b1eebb3928925b84a95b9f1e5a31e4f3
46d3d7978fceb5938ace79224df8e9a1
1,800
PASSED
#include <cstdio> #include <cstring> #include <string> #include <map> #include<math.h> #include <queue> #include<iostream> #include <algorithm> using namespace std; int a[1000005]; int main() { string s; cin>>s; int n=s.size(); int it; it=s.find('.'); for(int i=0; i<n; i++) a[i]=s[i]-'0'...
C++
b1eebb3928925b84a95b9f1e5a31e4f3
16716305840a3660ee43ef1ac3cf16c2
1,800
PASSED
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); string s; cin >> s; deque<char> str; str.assign(s.begin(), s.end()); while (!str.empty() && str[0] == '0') str.pop_front(); for (int i = 0; i < (int) str.size(); ...
C++
b1eebb3928925b84a95b9f1e5a31e4f3
23b6dafd757632ed9447cee15d477349
1,800
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<pair<int,int>> vpi; #define FOR(i,a,b) for (int i = (a); i < (b); ++i) #define F0R(i,a) FOR(i,0,a) #define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i) #define R0F(i,a) ROF(i,0,a) #de...
C++
4d0a2617db2b85802d9cd0e9a89b924c
63e718e5b12914332c1ca996c634c58e
1,900
PASSED
#include<bits/stdc++.h> using namespace std; typedef long long ll; const ll oo=500009; ll data[2][oo]; ll men[2][oo]; ll res[oo]; ll n; void solve(ll idx) { stack<pair<ll,ll>>st; for(ll i=0;i<n;i++) { while(!st.empty() && st.top().first >=data[idx][i]) st.pop(); men[idx][i]= s...
C++
4d0a2617db2b85802d9cd0e9a89b924c
be0b7776097329d092a5bc087522b18e
1,900
PASSED
#include<bits/stdc++.h> #define ll long long #define pii pair<int,int> using namespace std; const int N = 5e5+10; ll a[N]; int pos[N],posr[N]; ll dpl[N],dpr[N]; stack<pii> que; int main(){ int n; cin >> n; for(int i=1;i<=n;++i){ cin >> a[i]; while(que.size() && que.top().first > a[i]){ ...
C++
4d0a2617db2b85802d9cd0e9a89b924c
147b365f1c22d3fbb262c5d82762165f
1,900
PASSED
#include <iostream> #include <stack> using namespace std; const int N = 1e6 + 10; typedef long long LL; LL a[N],l[N],r[N]; LL b[N]; int main() { int n; cin >> n; for(int i = 1;i <= n;i ++)cin >> a[i]; stack<int>stk; for(int i = 1;i <= n;i ++) { while(stk.size() && a[st...
C++
4d0a2617db2b85802d9cd0e9a89b924c
6ccc6f39aca4844448301d7e3044d428
1,900
PASSED
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll a[500005],res[500005]; ll l[500005],r[500005]; ll n; int main() { cin >> n; for ( int i=0; i<n; i++ ) scanf("%lld",&a[i]); l[0] = a[0]; stack<int> S; S.push(0); for ( int i=1; i<n; i++ ) { while ( !S.empty() && a[S....
C++
4d0a2617db2b85802d9cd0e9a89b924c
212b641f9794772f8cba806f97921b29
1,900
PASSED
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll a[500005],res[500005]; ll l[500005],r[500005]; ll n; int main() { cin >> n; for ( int i=1; i<=n; i++ ) scanf("%lld",&a[i]); stack<int> S; S.push(0); for ( int i=1; i<=n; i++ ) { while ( !S.empty() && a[S.top()]>=a[i] ) ...
C++
4d0a2617db2b85802d9cd0e9a89b924c
21e4e0d3745ef3c53131f36922b157b6
1,900
PASSED
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll a[500005],res[500005]; ll l[500005],r[500005]; ll n; int main() { cin >> n; for ( int i=1; i<=n; i++ ) scanf("%lld",&a[i]); stack<int> S; S.push(0); for ( int i=1; i<=n; i++ ) { while ( !S.empty() && a[S.top()]>a[i] ...
C++
4d0a2617db2b85802d9cd0e9a89b924c
c780d03b558631dde484a086c4d44399
1,900
PASSED
#include<bits/stdc++.h> #define ll long long using namespace std; const int M = 5e5+7; ll a[M]; ll b[M]; struct tree { int l,r; ll data; int id; tree() { data=1e18; } } t[4*M]; void build(int p,int l,int r) { t[p].r=r,t[p].l=l; if(r==l) { t[p].data=a[l]; t[p]....
C++
4d0a2617db2b85802d9cd0e9a89b924c
a0081f7cfc7055cf5f20a2354a9c335e
1,900
PASSED
///Codeforces Round #622 (Div. 2)C2 #include<bits/stdc++.h> #define debug(x) cout <<#x<<" = "<<x<<endl #define gg cout <<"---------------QAQ---------------"<<endl #define fi first #define se second #define pb push_back #define L(i,u) for (register int i=head[u]; i; i=nxt[i]) #define rep(i,a,b) for (register int i=(a)...
C++
4d0a2617db2b85802d9cd0e9a89b924c
4efb4ec8f56173fdffba993c4be6ccb6
1,900
PASSED
#include<bits/stdc++.h> using namespace std; #define res register int #define ll long long //#define cccgift //#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++) //char buf[1<<21],*p1=buf,*p2=buf; template<typename T> inline void read(T &x) { static char ch;bool f=1; for(x=0,ch=g...
C++
4d0a2617db2b85802d9cd0e9a89b924c
cf622b1583c133846d93d729d815c7eb
1,900
PASSED
#include<bits/stdc++.h> using namespace std; #define ll long long int #define db(x) cout<<#x<<" -> "<<x<<endl vector<int>vec; map<int,int>mp; map<int,bool>vis; int csum[(int)1e5+5]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n,k; cin>>n>>k; for(int i=1; i<=n; i++) { ...
C++
55297e2a65144323af4d6abd6a6ef050
7725043854ae5460e81f479c6976255f
1,200
PASSED
#define _CRT_SECURE_NO_WARNINGS #include<iostream> #include<vector> #include<cmath> #include<string> #include<map> #include<algorithm> using namespace std; int comp(const void* a, const void* b) { return (*(int*)a - *(int*)b); } long long n, k; int m[205000]; int main() { ios::sync_with_stdio(false); //freope...
C++
55297e2a65144323af4d6abd6a6ef050
79984768d7d67714a98b2dd2c54d2a46
1,200
PASSED
/* copyright # all rights reserved # 3/2/2019 */ #define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <stdio.h> #include <utility> #include <string> #include <string.h> #include <algorithm> #include <vector> #include <math.h> #include <stack> #include <set> #include <iterator> using namespace std; int n,...
C++
55297e2a65144323af4d6abd6a6ef050
94f45dc104928b6a931b87571b823713
1,200
PASSED
/** * @Author: K C-L * @DateTime: 2018-05-06 21:40:33 * @Description: */ #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef stringstream strstm; #define INF 0X3f3f3f3f #define pb push_back #define PI acos(-1.0) #define E 2.718281829459 #define lowbit(x) (x & (-x)) #define DBG(x) c...
C++
55297e2a65144323af4d6abd6a6ef050
82edac8ebaa4bd7f32c2351d8d74a419
1,200
PASSED
#include<bits/stdc++.h> #include<iostream> #include<algorithm> #include<cassert> #include<string> #include<sstream> #include<set> #include<bitset> #include<vector> #include<stack> #include<map> #include<queue> #include<deque> #include<cstdlib> #include<cstdio> #include<cstring> #include<cmath> #include<ctime> #include<...
C++
55297e2a65144323af4d6abd6a6ef050
4d1bf5e6500ab3b1471754f79599bb39
1,200
PASSED
#include <bits/stdc++.h> using namespace std; #define MST(a, b) memset(a, b, sizeof(a)); #define CLR(a) MST(a, 0); #define DBG(x) cout << '#' << " = " << (x) << endl; #define ALL(x) x.begin(), x.end() #define INS(x) inserter(x, x.begin()) #define lson(x) (x) << 1 #define rson(x) (x) << 1|1 #define pb push_back #define ...
C++
55297e2a65144323af4d6abd6a6ef050
b869601b93e8cb850fec1eba8e3787a9
1,200
PASSED
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int a[N]; int main() { int n, k; cin >> n >> k; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); if (!k) { if (a[0] == 1) cout << -1 << endl; else cout << 1 << endl; return 0; } if (a[k - 1] == a[k]) cout << -1 << endl; e...
C++
55297e2a65144323af4d6abd6a6ef050
d12e48d22e1fb627836f3bcb7427290a
1,200
PASSED
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> PII; const int N = 2e5 + 10; int a[N]; int main() { int n, k; cin >> n >> k; for (int i = 0; i < n; i++) cin >> a[i]; sort(a, a + n); if (k == 0) { if(a[0] == 1) cout << -1 << endl; else cout << 1 << endl; ...
C++
55297e2a65144323af4d6abd6a6ef050
94c157594d5b471e6c646cfdac88da73
1,200
PASSED
#include <bits/stdc++.h> using namespace std; int main() { int n, k; scanf("%d %d", &n, &k); vector<int> a(n); for (int i = 0; i < n; ++i) scanf("%d", &a[i]); sort(a.begin(), a.end()); int ans; if (k == 0) { ans = a[0] - 1; } else { ans = a[k - 1]; } int cnt = 0; for (int i = 0; i < n; ++...
C++
55297e2a65144323af4d6abd6a6ef050
3cb5b6df76f406c4c99c880656f08814
1,200
PASSED
#include <stdio.h> #include <algorithm> using namespace std; int read() { char ch = getchar(); int f = 1; int x = 0; while(ch < '0' || ch > '9'){if(ch == '-')f = 0;ch = getchar();} while(ch >= '0' && ch <= '9'){x = x * 10 + ch - '0';ch = getchar();} return f?x:x*-1; } int ans[200005] = {}; void ...
C++
55297e2a65144323af4d6abd6a6ef050
3baf9f374af22ae7a86f52805c202fe0
1,200
PASSED
#include<string.h> #include<iostream> #include<vector> int ans=0; using namespace std; int dp[50005][505]; int n,k; vector<int> arr[50005]; int dfs(int u, int par){ int v; memset(dp[u],0,sizeof(dp[u])); dp[u][0]=1; for(int j=0;j<arr[u].size();j++){ v = arr[u][j]; if(v==par) continue; dfs(v,u); for(int i=0;i<k;i++){...
C++
2fc19c3c9604e746a17a63758060c5d7
6cd978af473caea9f77ff30a31a3c919
1,800
PASSED
#include<string.h> #include<iostream> #include<vector> long long ans=0; using namespace std; long long dp[50005][505]; int n,k; vector<int> arr[50005]; int dfs(int u, int par){ int v; memset(dp[u],0,sizeof(dp[u])); dp[u][0]=1; for(int j=0;j<arr[u].size();j++){ v = arr[u][j]; if(v==par) continue; dfs(v,u); for(int i=0;...
C++
2fc19c3c9604e746a17a63758060c5d7
783fcc1c942de5b81e0d3170928d6ac7
1,800
PASSED
#include<string.h> #include<iostream> #include<vector> long ans=0; using namespace std; long dp[50005][505]; int n,k; vector<int> arr[50005]; int dfs(int u, int par){ int v; memset(dp[u],0,sizeof(dp[u])); dp[u][0]=1; for(int j=0;j<arr[u].size();j++){ v = arr[u][j]; if(v==par) continue; dfs(v,u); for(int i=0;i<k;i++)...
C++
2fc19c3c9604e746a17a63758060c5d7
35087f581cd570b7f8753a47b1395cae
1,800
PASSED
#include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cfloat> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iostream> #include <iomanip> #include <limits> #include <list> #incl...
C++
2fc19c3c9604e746a17a63758060c5d7
100b41f68caf48a86f955468d255ac28
1,800
PASSED
#include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <algorithm> using namespace std; typedef long long ll; const int MAX_N = 50000 + 10; struct Edge { int t; Edge *n; } *tot_Edge; ll ans; int N, K; ll f [MAX_N][500 + 10]; int dist [MAX_N]; Edge edges [MAX_...
C++
2fc19c3c9604e746a17a63758060c5d7
9937cf439987fc7c1e293f94074a0ffd
1,800
PASSED
#include <iostream> #include <vector> using namespace std; #define pb push_back int dist[51000][600]; vector<int>vecc[51000],real[51000]; int visited[51000],total=0,N,K; void dfs1(int node,int parent) { int size=vecc[node].size(); visited[node]=1; for(int i=0; i<size; i++) { if(v...
C++
2fc19c3c9604e746a17a63758060c5d7
52a5dab4f2efb5a322c032db9296d958
1,800
PASSED
#include<iostream> #include<stdio.h> #include<vector> #include<algorithm> using namespace std; long long d[5134],y,f[50002],step=1,b[200005]; int a[50001],A[50001],c[50001],C[50001],q1[50002],q2[50002],Q1,Q2,Count,x=100002,num[50002],prime[5134]; int dump_array[50100]; void precompute(){ dump_array[0]=dump_a...
C++
2fc19c3c9604e746a17a63758060c5d7
4f198f86922c2d99ba080e818a7b77b8
1,800
PASSED
#include<iostream> #include<stdio.h> #include<vector> #include<algorithm> using namespace std; long long b[200005],d[50002],c[50001],x=100002,y,f[50002],step=1,q1[50002],q2[50002],Q1,Q2,Count; long long a[50001]; main() { long long i,j,k,n,p,q,r,e,g,t; long long l,m; cin>>n>>k; vector<long long> v[n+1],...
C++
2fc19c3c9604e746a17a63758060c5d7
999d7f135252610afe3b29efdd849a22
1,800
PASSED
#include<fstream> #include<iostream> #include<string> #include<map> #include<cmath> #include<algorithm> #include<vector> #include<list> #include<set> #include<cstring> #include<climits> #include<deque> #include<stack> #define PI 3.14159265 #define MOD 1000000007 #define LL long long using namespace std ; /* #define ...
C++
2fc19c3c9604e746a17a63758060c5d7
b685088b22b9433361911f1dd65dd5cf
1,800
PASSED
#include<fstream> #include<iostream> #include<string> #include<map> #include<cmath> #include<algorithm> #include<vector> #include<list> #include<set> #include<cstring> #include<climits> #include<deque> #include<stack> #define PI 3.14159265 #define MOD 1000000007 #define LL long long using namespace std ; /* #define ...
C++
2fc19c3c9604e746a17a63758060c5d7
590f7732e1c0ca8b1a5c045cdfa347ac
1,800
PASSED
#include<bits/stdc++.h> using namespace std; int a,b,c,d,e,j[401]; vector <int> v[401][2]; vector <int>::iterator t; bool w[401][401]; priority_queue <pair <int, int> > q; pair <int, int> p[1]; int main(){ ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0); cin>>a>>b; for(c=1; c<=b; c++){ cin>>d>>e; v[d][0]...
C++
fbfc333ad4b0a750f654a00be84aea67
a4661e2b0e936ecd3c51dcc8cd189e58
1,600
PASSED
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; const int N = 400; int n, m, u, v, by_train, by_bus; int dist[N]; bool visited[N]; vector<int> train[N]; vector<int> bus[N]; queue<int> q; set<pii> rails; int bfs(vector<int>* adj) { memset(dist, 63, sizeof(dist)); memset(visited, false, size...
C++
fbfc333ad4b0a750f654a00be84aea67
a402b545d86d605ad287a621e3e3b659
1,600
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long int lli; typedef pair<int, int> pii; const int N = 401; vector<int> adj1[N], adj2[N]; int dis1[N], dis2[N]; bool mark[N][N]; int main(){ ios::sync_with_stdio(0); int n, m; cin >> n >> m; for(int i = 0; i < m; i++){ int a, b; cin >> a >> b; adj1...
C++
fbfc333ad4b0a750f654a00be84aea67
6ba8d63eaafd02ae750520e82d1d428f
1,600
PASSED
#include<bits/stdc++.h> using namespace std; int disrail[1000]; int disroad[1000]; int a[1000][1000]; vector<int> road[1000]; vector<int> rail[1000]; int n,m,x,y; void bfsrail(){ queue<int> q; q.push(1); disrail[1] = 0; while(!q.empty()){ int u = q.front(); q.pop(); for(int i = 0;i < rail[u].size();i++){ ...
C++
fbfc333ad4b0a750f654a00be84aea67
3673dcaa87e59eb9f0f2dcbd3c4d14f5
1,600
PASSED
#include <bits/stdc++.h> using namespace std; #define INF 10000 typedef pair<int, int> ii; vector<ii> train[401]; int DT[401], VT[401]; int art[401][401]; priority_queue< ii, vector<ii>, greater<ii> > heap; int main(){ int n, m; scanf("%d %d", &n, &m); for(int i = 0; i < n; i++) DT[i] = INF; int u, v; ...
C++
fbfc333ad4b0a750f654a00be84aea67
21b753352eb42d9ff53838e95cda7a95
1,600
PASSED
#include <bits/stdc++.h> using namespace std; vector<int> g1[404]; vector<int> g2[404]; queue<int> q; int dist[404]; int main() { bool rail[404][404]; memset(rail,false,sizeof(rail)); int n, m,u,v,dist1,dist2; cin >> n >> m; while(m--) { cin>>u>>v; rail[u][v]=true; rail[v][u]=true; g1[u].push_back(v); ...
C++
fbfc333ad4b0a750f654a00be84aea67
d6abe69f71fb21db158a9fe4b5aa8306
1,600
PASSED
#include <bits/stdc++.h> #define pb push_back using namespace std; const int oo = 0x3f3f3f3f; typedef pair<int, int> ii; int n, m, dist1[500], dist2[500]; vector<int> adj1[500], adj2[500]; set<ii> can; void BFS1() { memset(dist1, 0x3f, sizeof dist1); queue< pair<int, int> > fila; fila.push(ii(0, 1)); while(!fi...
C++
fbfc333ad4b0a750f654a00be84aea67
7fcd107b2d8b98e243c0efa1be12996e
1,600
PASSED
#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; int ap[405][405]; int bp[405][405]; int n,m,q; const int inf=0x3f3f3f3f; void init() { for(int i=1; i<=n; i++) { for(int j=1; j<=n; j++) { ap[i][j]=inf;//t bp[i][j]=1;//g } } } ...
C++
fbfc333ad4b0a750f654a00be84aea67
d4ec03f7997c1eca524039ee9426e687
1,600
PASSED
#include<iostream> #include<cstring> using namespace std; int a[405][405]; int c[2][405][405]; int main() { int x,y; int n,m; while(cin >> n >> m) { memset(a,0,sizeof(a)); memset(c,0x3f3f3f3f,sizeof(c)); for(int i=1; i<=m; ++i) { cin >> x >> y; a...
C++
fbfc333ad4b0a750f654a00be84aea67
41e0fbc4710af8031517bd20e3d5f355
1,600
PASSED
#include<iostream> #include<cstdio> #include<cstring> using namespace std; int n,m,e[410][410],len[2][410][410]; int main() { scanf("%d%d",&n,&m); memset(len,0x3f,sizeof(len)); for(int x,y,i=1;i<=m;i++) { scanf("%d%d",&x,&y); e[x][y]=e[y][x]=1; } for(int t=0;t<2;t++) for(...
C++
fbfc333ad4b0a750f654a00be84aea67
bad5ad484751a3b19ebdd467af4e5e69
1,600
PASSED
#include<bits/stdc++.h> using namespace std; string str[102]; bool comp(string f, string s){ return f.length()<s.length(); } int main(){ int n; cin>>n; for(int i=0; i<n; i++){ cin>>str[i]; } sort(str,str+n,comp); bool ok=true; for(int i=1; i<n; i++){ if(str[i].find(str[i...
C++
5c33d1f970bcc2ffaea61d5407b877b2
f579e9367669675f54f0a8061a188329
1,100
PASSED
#include<bits/stdc++.h> using namespace std; string str[100]; bool comp(string f, string s){ return f.length()<s.length(); } int main(){ int n; cin>>n; bool ok=true; for(int i=0; i<n; i++){ cin>>str[i]; } sort(str,str+n,comp); for(int i=1; i<n; i++){ if(str[i].find(...
C++
5c33d1f970bcc2ffaea61d5407b877b2
6cc2cdca0014d4f1257178e0b9c6d7d7
1,100
PASSED
#include <iostream> #include <vector> #include <string> #include <algorithm> using namespace std; bool comp(string a, string b){ return a.size() < b.size(); } int main(void) { char temp; vector<string> s; string str; int n, k, j; cin >> n; for(int i = 0; i < n; i++){ cin >> str; int size = str.size(); fo...
C++
5c33d1f970bcc2ffaea61d5407b877b2
f0d14fdd3d9ba66ffdc1860162d29514
1,100
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; ll gcd(ll a, ll b) { for (; b; a %= b, swap(a, b)); return a; } int dx[4] = { 1, -1, 0, 0 }; int dy[4] = { 0, 0, 1, -1 }; #define INF 101112987654321 int main(void) { ios::sync_with_stdio(0); ...
C++
5c33d1f970bcc2ffaea61d5407b877b2
14ebd308e32e75cb1b5baa4a45b33982
1,100
PASSED
#include<iostream> #include<algorithm> #include<string> #include<queue> #include<map> #include<set> #include<cstring> #include<cstdio> #include<cmath> using namespace std; typedef long long ll; typedef unsigned long long ull; #define mem(x) memset(x,0,sizeof(x)) const int maxn=1e2+10; int a[maxn],b[maxn],vis[maxn]; //i...
C++
5c33d1f970bcc2ffaea61d5407b877b2
ef9cf3d1cc160e21ee3ab42ffe08e377
1,100
PASSED
#include <iostream> using namespace std; int main() { int n; string str[1000]; cin>>n; for(int i=0;i<n;i++) cin>>str[i]; for(int i=0;i<n-1;i++){ for(int j=i+1;j<n;j++){ if(str[i].size()>str[j].size()){ string tmp=str[i]; str[i]=str[j]; str[j]=tmp; } } } /* cout<<endl<<str[0].size()<<endl;...
C++
5c33d1f970bcc2ffaea61d5407b877b2
1e09ca6e4203a6bb87ead64793ddbe61
1,100
PASSED
#include <iostream> using namespace std; int main() { int n; string str[101]; cin>>n; for(int i=0;i<n;i++) cin>>str[i]; for(int i=0;i<n-1;i++){ for(int j=i+1;j<n;j++){ if(str[i].size()>str[j].size()){ swap(str[i],str[j]); } } } /* cout<<endl<<str[0].size()<<endl; for(int i=0;i<n;i++) cout<<str[i...
C++
5c33d1f970bcc2ffaea61d5407b877b2
950c429cc7f8aa4306d0f333ec4abb03
1,100
PASSED
#include <iostream> using namespace std; int main() { int n; string str[1000]; cin>>n; for(int i=0;i<n;i++) cin>>str[i]; for(int i=0;i<n-1;i++){ for(int j=i+1;j<n;j++){ if(str[i].size()>str[j].size()){ swap(str[i],str[j]); } } } /* cout<<endl<<str[0].size()<<endl; for(int i=0;i<n;i++) cout<<str[...
C++
5c33d1f970bcc2ffaea61d5407b877b2
20de8845f66b54273d0d012f9e87ff9c
1,100
PASSED
/*This Code Is Written By Prateek Rai*/ #include<bits/stdc++.h> #define ll long long #define ul unsigned long long int #define ff(i,n) for(i=0;i<n;i++) #define pb push_back #define mod 1000000007 #define f first #define ss second #define fff(it,v) for(it=v.begin(),it!=v.end();it++) #define iv vector<long long> :: iter...
C++
5c33d1f970bcc2ffaea61d5407b877b2
49271f866d8a3695ff7d9f018f3d8f3a
1,100
PASSED
/*This Code Is Written By Prateek Rai*/ #include<bits/stdc++.h> #define ll long long #define ul unsigned long long int #define ff(i,n) for(i=0;i<n;i++) #define pb push_back #define mod 1000000007 #define f first #define ss second #define fff(it,v) for(it=v.begin(),it!=v.end();it++) #define iv vector<long long> :: iter...
C++
5c33d1f970bcc2ffaea61d5407b877b2
d5812a5fe6cec40f2a146a2a168cae1d
1,100
PASSED
#include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> using namespace std; void __print(int x) {cerr << x;} void __print(long x) {cerr << x;} void __print(long long x) {cerr << x;} void __print(unsigned x) {cerr << x;} void __print(unsigned long x) {cerr << x;} void __pri...
C++
5ce8de80c6953cd1e6e6eefd9ad35f7e
ea40bd6d01c9eaaa111bfcf47f3408fb
1,700
PASSED
#include <bits/stdc++.h> #define int long long using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif string str; cin >> str; int sz = str.size(); int ...
C++
5ce8de80c6953cd1e6e6eefd9ad35f7e
6281a708940cf3e55f712226a591d040
1,700
PASSED
#include <cstdio> #include <cstring> char s[1000010]; int p[1000010]; int main() { scanf("%s",s); int len=strlen(s); memset(p,0,sizeof(p)); p[len-1]=0; for(int i=len-2;i>=0;i--){ int nxt=i+p[i+1]+1; if((s[i]=='('&&s[nxt]==')')||(s[i]=='['&&s[nxt]==']')){...
C++
5ce8de80c6953cd1e6e6eefd9ad35f7e
1752cb2a77d67f6e72deb89da434a6a9
1,700
PASSED
#include <bits/stdc++.h> using namespace std; /* * * * * * * * * * */ typedef long long ll; typedef long double ld; typedef pair<int, int> pii; #define ms(a,v) memset(a,v,sizeof a) /* * * * * * * * * * */ /* * * * I love Ylva Eriksson * * */ int main(){ ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(...
C++
5ce8de80c6953cd1e6e6eefd9ad35f7e
1fb34b1f47c55592f0ee2d1165a3d2da
1,700
PASSED
#include <bits/stdc++.h> #define _ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define pb push_back #define po pop_back using namespace std; string s; int be[100001]={0}; vector<int> st; int cnt(int l, int r) { int res = 0; l--, r--; for(int i=r; i>=l; i--) if(s[i]==']') ...
C++
5ce8de80c6953cd1e6e6eefd9ad35f7e
da2cbd5168f93d2d0c355322a73fe015
1,700
PASSED
#include <bits/stdc++.h> #define pb push_back #define po pop_back using namespace std; string s; int be[100001]={0}; vector<int> st; int cnt(int l, int r) { int res = 0; l--, r--; for(int i=r; i>=l; i--) if(s[i]==']') res++; return res; } int main() { cin >> s; for(int i...
C++
5ce8de80c6953cd1e6e6eefd9ad35f7e
4da66a9e826c36b6f1cedb16ad6c9570
1,700
PASSED
#include <iostream> #include <stack> #include <cstring> using namespace std; char s[100000+10]; int pre[100000+10], nxt[100000+10]; stack<int> st; int main() { scanf("%s", s + 1); int n = strlen(s + 1); for (int i = 1; i <= n; i ++) { if (s[i] == '[') pre[i] = pre[i-1] + 1; else...
C++
5ce8de80c6953cd1e6e6eefd9ad35f7e
72f4b4549f68be93044cd740fc7a8e48
1,700
PASSED
#include <bits/stdc++.h> using namespace std; #define ll long long int string str; stack<ll> s; stack<pair<ll,ll> > s2; ll maxi,x,y,emp; ll seg[300100]; void build(ll v,ll x,ll y) { if(x==y) { if(str[x]=='[') seg[v] = 1; else seg[v] = 0; return; } ll mid = (x+y)/2; ll left = 2*v+1; ll right = 2*v...
C++
5ce8de80c6953cd1e6e6eefd9ad35f7e
11f808b9be6f0323270387079bca70f4
1,700
PASSED
#include <bits/stdc++.h> using namespace std; #define st first #define nd second #define mp make_pair #define pb push_back #define cl(x, v) memset((x), (v), sizeof(x)) #define gcd(x,y) __gcd((x),(y)) #ifndef ONLINE_JUDGE #define db(x) cerr << #x << " == " << x << endl #define dbs(x) cerr << x << endl #define _ ...
C++
5ce8de80c6953cd1e6e6eefd9ad35f7e
7c4198db136c83091971bf43874a2e79
1,700
PASSED
#include<bits/stdc++.h> #define fi first #define se second #define pb push_back #define pob pop_back #define mp make_pair #define REPP(i,l,r,c) for (int i=l;i<r;i+=c) #define REP(i,l,r) REPP(i,l,r,1) #define REPS(i,l,r) REP(i,l,r+1) #define FOR(i,n) REP(i,0,n) #define REPD(i,l,r) for (int i=r-1;i>=l;i--) #define FORD(i...
C++
5ce8de80c6953cd1e6e6eefd9ad35f7e
eb0a45ad14b6e2845525fc0577765ab1
1,700
PASSED
#include <bits/stdc++.h> using namespace std; typedef vector<int> VI; typedef vector<VI> VVI; typedef long long Long; template<typename T, typename U> struct SegmentTree { struct Node { bool hasCarry = 0; int b = 0,e = 0; U carry = U(); T val = T(); Node(){ } void join(const Node &l, const Node &r){ v...
C++
7fdf7b0c58189aac64051b696259965f
80e6ad72818526a89dd05682c79831fe
2,300
PASSED
#include <bits/stdc++.h> #define REP(a, b) for(int a = 0; a < b; a++) #define FOR(i, a, b) for(int i = a; i <= b; i++) #define mp make_pair #define f first #define s second #define pb push_back using namespace std; typedef long long ll; typedef pair<int, int> ii; typedef pair<ll, ll> LL; typedef vector<int> vi; const...
C++
7fdf7b0c58189aac64051b696259965f
037ba604703e76baacac08058370200c
2,300
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define pb push_back #define endl "\n" pair<int, int> a[3100]; int n, mx[3100][3100]; int ans[3100]; int main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin >> n; for (int i = 1; i <= n; i++){ ...
C++
7fdf7b0c58189aac64051b696259965f
494f51c8d59b6589689fa2f12e567cd3
2,300
PASSED
#include <bits/stdc++.h> using namespace std; const int MaxN = 3e3 + 33; int n; struct T{ int k1, k2, k3; int ans1, ans2, ans3; }; bool comp(T a, T b) { return make_pair(a.ans1, make_pair(a.ans2, a.ans3)) < make_pair(b.ans1, make_pair(b.ans2, b.ans3)); } int ans[MaxN]; int b[MaxN]; int main() { // ...
C++
7fdf7b0c58189aac64051b696259965f
5b7b57d22191c880a106d41d465e6df0
2,300
PASSED
#include <bits/stdc++.h> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pii; template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statisti...
C++
7fdf7b0c58189aac64051b696259965f
e723dbc18b5b37d75ea8e7dde5b738f7
2,300
PASSED
#include <bits/stdc++.h> using namespace std; #define PB push_back #define ZERO (1e-10) #define INF int(1e9+1) #define CL(A,I) (memset(A,I,sizeof(A))) #define DEB printf("DEB!\n"); #define D(X) cout<<" "<<#X": "<<X<<endl; #define EQ(A,B) (A+ZERO>B&&A-ZERO<B) typedef long long ll; typedef pair<ll,ll> pll; typedef vecto...
C++
7fdf7b0c58189aac64051b696259965f
a6e8bac7ecdf13b4047d841fd9314de4
2,300
PASSED
#include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <vector> #include <utility> #include <algorithm> #include <unordered_map> #include <unordered_set> #include <numeric> #include <set> #include <map> #include <queue> #include <memory> #include <bitset> #include <sstream> using namespace s...
C++
7fdf7b0c58189aac64051b696259965f
24fbdfe490c298c670cf2b82240865a2
2,300
PASSED
#include<iostream> #include<algorithm> #include<queue> #include<string> #include<vector> #include<map> #include<list> #include<set> #include<cstring> #include<ctime> #include<cmath> #include<limits> #include<iterator> #include<functional> #include<unordered_map> #include<stack> #include<bitset> #define all(v) v.begin(...
C++
7fdf7b0c58189aac64051b696259965f
8f154f812a7121aa7e73b46d0c2067fe
2,300
PASSED