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> #include<stdint.h> #define int int_fast64_t #pragma GCC optimize(2) using namespace std; typedef pair<int,int> pii; typedef vector<int> VI; #define REP(i,j,k) for(register int (i)=(j);(i)<(k);++(i)) #define RREP(i,j,k) for(register int (i)=(j)-1;(i)>=(k);--(i)) #define ALL(a) (a).begin(),(a).end...
C++
6c46b8ffb15d61ef0a2f5d3e1d14d364
45cd180420c47e9cc82e6063808cd2e1
2,400
PASSED
#include<bits/stdc++.h> using namespace std; #define N 100010 int n,A[N],st[N],Ans[N]; vector<int>B[N],C[N]; struct Binary_Indexed_Tree{ int bit[N]; void Add(int i,int x){ while (i<=n){ bit[i]+=x; i+=i&-i; } } int Query(int x){ int i,res=0; for (i=16;i>=0;i--){ int t=res|(1<<i); if (t<=n && x-bi...
C++
6c46b8ffb15d61ef0a2f5d3e1d14d364
91aa37413b0637582264e228eb9e0f87
2,400
PASSED
#include<bits/stdc++.h> using namespace std; int c[100007]; int vis[100007]; int ans[100007]; int n; int get_cnt(int k) { int res=0,cnt=0; memset(vis,-1,sizeof(vis)); for(int i=1; i<=n; i++) { if(vis[c[i]]==res) continue; vis[c[i]]=res; cnt++; if(cnt>k) { ...
C++
6c46b8ffb15d61ef0a2f5d3e1d14d364
cfdc3e3105cfeaeab53d72bd91984348
2,400
PASSED
/// http://codeforces.com/contest/548/problem/D #include<bits/stdc++.h> #define ll long long #define ld long double #define pii pair<int,int> #define V(x) vector<x> #define pb push_back #define mp make_pair #define mt make_tuple #define eb emplace_back #define SORT(ls) sort(ls.begin(), ls.end()) #define DESC(ls) sort...
C++
5cf25cd4a02ce8020258115639c0ee64
b02e9f1920b476e865ef98bbab7ec1e8
1,900
PASSED
#include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<algorithm> using namespace std; int hi[200010]; int a[200010],b[200010],c[200010]; int main() { int n; int k; while(scanf("%d",&n)!=-1) { hi[0]=hi[n+1]=-1; memset(c,0,sizeof(c)); for(int i=1;i<=n;i++) ...
C++
5cf25cd4a02ce8020258115639c0ee64
26a17577f45eb5ea745d9127891938d6
1,900
PASSED
#include<iostream> #include<algorithm> #include<cstring> #include<cmath> #include<cstdio> #include<queue> #include<set> #include<vector> #include<map> #include<string> #include<cmath> #define pq priority_queue #define Pi acos(-1.0) using namespace std; struct Node { int num,val; }nums[200005]; int stc[200005],top=0...
C++
5cf25cd4a02ce8020258115639c0ee64
a6d16ad76fb29029be6530d9fbd8c92a
1,900
PASSED
#include <bits/stdc++.h> #define FILE 0 #define INPUT "input" #define OUTPUT "output" #define MP make_pair #define MT make_tuple #define PB push_back #define FI first #define SE second #define MAX int( 1e6+100 ) #define INF INT_MAX #define EPS int(1e-7) #define MOD int(...
C++
5cf25cd4a02ce8020258115639c0ee64
18c5b81561afd6d0ae2724ac7acf2408
1,900
PASSED
#include <bits/stdc++.h> #define FILE 0 #define INPUT "input" #define OUTPUT "output" #define MP make_pair #define MT make_tuple #define PB push_back #define FI first #define SE second #define MAX int( 1e6+100 ) #define INF INT_MAX #define EPS int(1e-7) #define MOD int(...
C++
5cf25cd4a02ce8020258115639c0ee64
2a093296096af995915966a19e42b738
1,900
PASSED
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5, MOD = 1e9 + 7; int n, result[N]; pair<int, int> p[N]; int parent[N], sz[N], rnk[N]; void init() { memset(rnk, 0, sizeof rnk); for (int i = 0; i < N; ++i) { parent[i] = i; sz[i] = 1; } } int root(int node) { while (node != parent[node]) {...
C++
5cf25cd4a02ce8020258115639c0ee64
82f08f437ac70f747557ab9f255915f1
1,900
PASSED
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5, MOD = 1e9 + 7; int n, result[N]; pair<int, int> p[N]; set<pair<int, int>> segments; bool left(int index) { auto it = segments.lower_bound({index, 0}); return it != segments.end() && it->first == index + 1; } bool right(int index) { auto it = seg...
C++
5cf25cd4a02ce8020258115639c0ee64
7cd7b86f2934bdb5d1e7626e9366ecf2
1,900
PASSED
#include <bits/stdc++.h> using namespace std; int l[200005] , a[200005] , mn[200005] , n , ans[200005] , mnmn = 1e9 + 10; int main() { cin >> n; for(int i=1;i<=n;i++){ scanf("%d",&a[i]); mnmn = min(mnmn , a[i]); } stack < pair < int , int > > st; st.push(make_pair(n,a[n])); for(int i=n-1;i>=1;i--) { while(!st...
C++
5cf25cd4a02ce8020258115639c0ee64
5fc8ed8a0831a0fd0b2250b9c0ea10ea
1,900
PASSED
#include <iostream> #include <cstdio> #include <algorithm> #include <vector> #include <array> #include <set> #include <stack> using namespace std; using VI = vector<int>; using STK = stack<int>; const int SZ = (int)2e5 + 5; const bool dbg = !true; class D { public: VI inp, left, right; array<int, ...
C++
5cf25cd4a02ce8020258115639c0ee64
0665502558ca7b045bad17c4e8efe43b
1,900
PASSED
#include <bits/stdc++.h> using namespace std; #define DB(v) cerr << #v << ' ' << v << endl #define forn(i,n) for(int i = 0;i < n;++i) #define forup(i,a,b) for(int i = a;i <= b;++i) void print_all(vector <int> &v){ cout << "{ "; for(auto x:v){cout << x + 1<< ", ";} cout << "}"; } static const int INF = 1e9 * 2,...
C++
5cf25cd4a02ce8020258115639c0ee64
85f56ae4e47b8e36d0b095b321992c49
1,900
PASSED
import bisect N, D = map(int, input().split()) A = list(map(int, input().split())) A.sort() ans = 0 for i in range(N): X = bisect.bisect_left(A, A[i] - D) temp = i - X ans += max(0, (temp * (temp - 1))//2) print(ans)
Python
1f6491999bec55cb8d960181e830f4c8
9d9bc4a47c5a78ab69d02b28fea91ec4
1,300
PASSED
from collections import Counter,defaultdict,deque #import heapq as hq #from itertools import count, islice #from functools import reduce #alph = 'abcdefghijklmnopqrstuvwxyz' #from math import factorial as fact #a,b = [int(x) for x in input().split()] import math import sys input=sys.stdin.readline n,d = [int(x) for x ...
Python
1f6491999bec55cb8d960181e830f4c8
00ce1516e7d78732974a474258c9a63f
1,300
PASSED
def f(a,j,d): l=j r=len(a) while(r-l>1): m=(r+l)//2 if(a[m]>d): r=m elif(a[m]<d): l=m else: return (m+1)-j-1 return r-j-1 n,d=map(int,input().split()) a=list(map(int,input().split())) ans=0 for i in range(n): x=f(a,i,a[i]+d) an...
Python
1f6491999bec55cb8d960181e830f4c8
0fcad7f3eba504da5726370c8062db68
1,300
PASSED
def points_on_line(l,d): j=0 combination=0 for i in range(len(l)): while j<len(l) and l[j]<=l[i]+d: j+=1 nums=j-i-1 combination+=nums*(nums-1)//2 return combination n,d=[int(x) for x in input().split()] l=[int(x) for x in input().split()] print (points_on_line(l,d))
Python
1f6491999bec55cb8d960181e830f4c8
a3a5f98712bd6d44094dc871b15fd7e4
1,300
PASSED
n, d = map(int, input().split()) l = list(map(int, input().split())) j = 0 s = 0 for i in range(2, n): while l[i] - l[j] > d: j += 1 k = i-j s += k*(k-1)//2 print(s)
Python
1f6491999bec55cb8d960181e830f4c8
cbbbea9e48e63d5d7714afb935765d27
1,300
PASSED
n,d=map(int,input().split()) l1=list(map(int,input().split())) ans=0 j=0 for i in range(0,n-1): j=max(j,i+1) while j <n and l1[j]-l1[i] <=d: j+=1 j-=1 ans+= ( (j-i)*((j-i-1)) )//2 print(ans)
Python
1f6491999bec55cb8d960181e830f4c8
24e492e5b886192777961c802a3d3312
1,300
PASSED
n,d=map(int,input().split()) c=list(map(int,input().split())) x=0;t=0 for i in range(n-2): while (t<n and c[t]<=c[i]+d): t=t+1 t-i-1 x=x+(t-i-1)*(t-i-2)/2 print(int(x))
Python
1f6491999bec55cb8d960181e830f4c8
175215c44948a61d1912b1d204bd0963
1,300
PASSED
def numbersListInput(): aux = list(map(int,input().strip().split())) return aux def find_tail(arr, n, maxVal): # binary search to find biggest number smaller than maxVal mini = 0 maxi = n mid = int(n/2) while True: if mid == 0 or mid == n-1: return mid if arr[mid...
Python
1f6491999bec55cb8d960181e830f4c8
5fff8267224c9794d3832022c33b67ba
1,300
PASSED
from collections import deque n,m = [int(i) for i in input().split()] list_inp = input().split() D = deque() ways=0 Sum=0 for i in range(n-1): while Sum+int(list_inp[i+1])-int(list_inp[i])>m and len(D)>0: Sum -= D.popleft() if Sum+int(list_inp[i+1])-int(list_inp[i]) <= m: ways += int(len(D)...
Python
1f6491999bec55cb8d960181e830f4c8
a8a9f2052c8b7828438ea27dfbdc777d
1,300
PASSED
n,d=[int(i) for i in input().split()] x=[int(i) for i in input().split()] k=0 S=0 for i in range(2,n): while x[i]-x[k]>d:k=k+1 P=i-k S+=P*(P-1)//2 print(S)
Python
1f6491999bec55cb8d960181e830f4c8
7e14e5320d7d9108d515119b5e753b24
1,300
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 1e5 + 100; int N, K, W; bool candy[MAXN]; int pref[MAXN]; int sum[MAXN][10]; int qua[MAXN][10]; int main() { ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0), cout.precision(15); cin >> N >> K >> W; for ...
C++
3d658789269780f46cce7686fbd090cc
7f90a24f270d5485dbb5d3e9e67bfdb8
null
PASSED
#include <iostream> #include<bits/stdc++.h> using namespace std; int sum[100001],dp[100001][20]; int main() { int i,j,n,k,q,ans=0,l,r; string str; cin>>n>>k>>q; cin>>str; sum[0]=0; for(i=0;i<n;i++) { if(str[i]=='1') sum[i+1]=sum[i]+1; else sum[i+1]=sum[i]; ...
C++
3d658789269780f46cce7686fbd090cc
e8073ce17f78f207f9db70e347282d64
null
PASSED
//there’s light at end of every dark tunnel...keep moving #include <iostream> #include<bits/stdc++.h> using namespace std; #define ll long long int #define inf 1000000000000 #define mod 1000000007 #define pb push_back #define mp make_pair #define all(v) v.begin(),v.end() #define S second #define F first #define boost i...
C++
3d658789269780f46cce7686fbd090cc
e952e3923036175cc711717c1c4d82e4
null
PASSED
#include<bits/stdc++.h> #define ll long long #define f(w,e,y) for(ll w=e;w<y;w++) #define ff(w,e,y) for(ll w=e;w<=y;w++) #define mem(x,y) memset(x,y,sizeof(x)) using namespace std; ll a[100004],s[100004]; int main() { ll n,m,k; cin>>n>>k>>m; string st; cin>>st; a[0]=0; s[0]=0; ff(i,1...
C++
3d658789269780f46cce7686fbd090cc
b72f5f020514557c3f5826de3be3ecfe
null
PASSED
#include<bits/stdc++.h> #define ll long long #define f(w,e,y) for(ll w=e;w<y;w++) #define ff(w,e,y) for(ll w=e;w<=y;w++) #define mem(x,y) memset(x,y,sizeof(x)) using namespace std; ll a[100004],s[100004]; int main() { ll n,m,k; cin>>n>>k>>m; string st; cin>>st; a[0]=0; s[0]=0; ff(i,1...
C++
3d658789269780f46cce7686fbd090cc
d4eef45b56ceb003ad6c30d259247e84
null
PASSED
#include<cstdio> int n,k,w,l,r; int a[100001],c[100001]; char s[100001]; int main(){ scanf("%d%d%d%s",&n,&k,&w,s+1); for(int i=1;i<=k;i++)c[i]=s[i]-'0',a[i]=a[i-1]+s[i]-'0'; for(int i=k+1;i<=n;i++)a[i]=a[i-1]+s[i]-'0',c[i]=c[i-k]+s[i]-'0'; while(w--){ scanf("%d%d",&l,&r); printf("%d\n",a[r]-a[l-1]-c[r]+c[l-1]+(...
C++
3d658789269780f46cce7686fbd090cc
c92262d5aaf3e128d59a989b5e3b2002
null
PASSED
#include <cstdio> #include <sstream> #include <iostream> #include <algorithm> #include <cmath> #include <map> #include <vector> #include <queue> #include <set> using namespace std; int n, k, w; int a[100001]; int d[100001][11]; int main() { cin >> n >> k >> w; string s; cin >> s; for (int i = 0; i < n; i++) {...
C++
3d658789269780f46cce7686fbd090cc
bfce68acffde1e8a543da2cfbffaf71e
null
PASSED
#include <bits/stdc++.h> #define CON 1000000007 using namespace std; const int N = 100005; int cum[11][N]; int norcum[N]; char S[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL), cout.tie(NULL); int n, k , w; cin >> n >> k >> w; for(int i = 1; i <= n; i ++){ cin >> S[i]; ...
C++
3d658789269780f46cce7686fbd090cc
61d409eb6130b60fb38305ba81ff7eea
null
PASSED
#include<iostream> using namespace std; int main(){ ios::sync_with_stdio(false); int n,k,w,p,q; cin >> n >> k >> w; int a[n+1]; int pre1[n+1],pre2[n+1]; pre1[0]=pre2[0]=0; char temp; for(int i=1; i<=n ;i++){ cin >> temp; a[i]=temp-48; if(i<=1) pre1[i]=a[i]; else pre1[i]=pre1[i-1]+a[i]; if(i<=k) pre2[i...
C++
3d658789269780f46cce7686fbd090cc
10e5235669e65523f9bd69edf584cf5d
null
PASSED
#include<bits/stdc++.h> using namespace std; int n, w, k, l, r; string s; int ludost[100005], ludok[100005]; int main(){ cin >> n >> k >> w; cin >> s; for (int i = 1; i <= n; i++){ int b = (s[i - 1] - '0'); ludost[i] = ludost[i - 1] + b; if (i >= k){ ludok[i] = ludok[i - k] ; } ludok[i] += b; } ...
C++
3d658789269780f46cce7686fbd090cc
a98e257f4b9539f8a791e3437a8fab99
null
PASSED
#include<bits/stdc++.h> using namespace std; int arr[6][1010]; vector<int> adj[1010]; int ans[1010]; int best = 0; int visited[1010]; void dfs(int Node) { visited[Node] = 1; for(int i = 0; i < adj[Node].size(); ++ i) { if(!visited[adj[Node][i]]) dfs(adj[Node][i]); ans[Node...
C++
de87bb6ffd3c703d8845d4dd301bdbf5
11df5aa415f5470ee229db4ebf4dc984
1,900
PASSED
#include <bits/stdc++.h> using namespace std ; const int mx=1e3+10 ; #define pb push_back #define F first #define S second typedef pair < int , int > pii ; vector < int > v[mx] ; int mark[mx][mx] , a[mx] , n , k , max1 , dp[mx] ; bool mark1[mx] ; void dfs ( int x ) { mark1[x]=1 ; for ( int i=0 ; i<v[x].size(...
C++
de87bb6ffd3c703d8845d4dd301bdbf5
a3b5175cb9ccadb0c39688beeeb20a37
1,900
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair < int, int > pii; const ll linf = 1e18 + 9; const int inf = 1e9 + 9; const int N = 1e3 + 9; vector < int > gr[N]; int n, k, arr[7][N], hash[N][N], hash2[N], mx, dp[N]; int dfs(int node) { if (dp[node] != -1) return dp[node]; int mx...
C++
de87bb6ffd3c703d8845d4dd301bdbf5
31fd207383b443f704ab86ffb359d1ce
1,900
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair < int, int > pii; const ll linf = 1e18 + 9; const int inf = 1e9 + 9; const int N = 1e3 + 9; vector < int > gr[N]; int n, k, arr[7][N], hash[N][N], hash2[N], mx, dp[N]; int dfs(int node, int stp) { if (dp[node] != -1) return dp[node]...
C++
de87bb6ffd3c703d8845d4dd301bdbf5
e48c430d693cfbdbc4915dd326358642
1,900
PASSED
#include<iostream> #include<cstdio> #include<cstdlib> #include<ctime> #include<utility> #include<algorithm> #include<vector> #include<queue> #include<set> #include<map> #include<cmath> #include<cstring> #include<cctype> #include<string> #include<string.h> #include<list> using namespace std; int n,m; int a[10][1050]; i...
C++
de87bb6ffd3c703d8845d4dd301bdbf5
0bbd36293262a2c52fda979b799f0b38
1,900
PASSED
#include<iostream> #include <cstdio> #include <cstdlib> #include <vector> #include <algorithm> using namespace std; const int NMAX = 1010; int N, K, V[10][NMAX], Pos[10][NMAX], Best[NMAX], Ans; vector<int> G[NMAX]; bool Used[NMAX]; void DFS(int Node){ Used[Node] = 1; for(int i = 0; i < G[Node].size(); ++ ...
C++
de87bb6ffd3c703d8845d4dd301bdbf5
32fb57ee33f14c288501d3faee6ab442
1,900
PASSED
#include <iostream> #include <iomanip> #include <cstring> #include <string> #include <algorithm> #include <queue> #include <map> #include <deque> #include <set> #include <vector> #include <cstdlib> #include <iomanip> #include <ctime> #include <fstream> #define pb push_back #define mp make_pair #define F first #define ...
C++
de87bb6ffd3c703d8845d4dd301bdbf5
35e2a5b253a070f38b94992405c95083
1,900
PASSED
//#pragma comment(linker,"/STACK:100000000000,100000000000") #include <string> #include <cmath> #include <cstring> #include <cstdio> #include <set> #include <utility> #include <vector> #include <algorithm> #include <map> #include <deque> #include <iomanip> #include <queue> #include <iostream> #include <ctime> #include...
C++
de87bb6ffd3c703d8845d4dd301bdbf5
5143bb594101eb508103172b9291fbf5
1,900
PASSED
#include<bits/stdc++.h> using namespace std; #define endl '\n' #define st first #define nd second #define mp make_pair #define lli long long int #define pb pus_back #define pii pair< int, int > #define type(x) __typeof(x.begin()) #define bit __builtin_popcount #ifndef D #define dbgs(x) 0 #define dbg(x) 0 #define ...
C++
de87bb6ffd3c703d8845d4dd301bdbf5
5d88476f31ac0b55e4120fad30f3ece0
1,900
PASSED
#include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> #include <iostream> #include <algorithm> #include <queue> #include <stack> #include <set> #include <map> #include <vector> #include <functional> using namespace std; inline int read () { int res, ok = 1; char ch; for (ch = getchar (); ch < '0' ...
C++
de87bb6ffd3c703d8845d4dd301bdbf5
c6af2ad654e93cca038e2eaddb6620fb
1,900
PASSED
#include <bits/stdc++.h> using namespace std; #define ll long long int #define db long double #define endl "\n" void fast_io() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); } vector<vector<int>> g(100005); vector<int> ans; int maxx = 0, root = 0; int goodBoy = 0; void dfs(int e, int last, int cn...
C++
63098c9d5ef90d445a6a4aa0f037a9c7
38e64acd5708885f82b16de7b7cc91a2
1,400
PASSED
#include <bits/stdc++.h> using namespace std; ifstream fin("input.txt"); ofstream fout("output.txt"); const int N = 107; vector < int > adia[N]; int n; int q[N], dist[N]; int bfs(int & nod) { fill(dist + 1, dist + n + 1, -1); dist[nod] = 0; int st(0), dr(-1); q[++dr] = nod; while (st <= dr) { ...
C++
63098c9d5ef90d445a6a4aa0f037a9c7
22050d86143175dd52d5362d5bd592f9
1,400
PASSED
#include<bits/stdc++.h> using namespace std; #define pfi(a) printf("%d",a); #define pfl(a) printf("%lld",a); #define pfin(a) printf("%d\n",a); #define pfln(a) printf("%lld\n",a); #define sfi(a) scanf("%d",&a); #define sfl(a) scanf("%lld",&a); #define pb push_back #define f(i,a,b) for(int i=a;i<b;i++) #define ll long lo...
C++
63098c9d5ef90d445a6a4aa0f037a9c7
b0ef3c3b2aad90dc0a54c60624326ee7
1,400
PASSED
#include <iostream> #include <algorithm> #include <vector> #include <string> #include <cmath> #include <queue> #define ll long long #define mod 1000000007 #define pii pair<int, int> #define fr(n) for (int i = 0; i < n; i++) #define fr1(n) for (int i = 1; i <= n; i++) using namespace std; int d[102], e[102]; vector<int...
C++
63098c9d5ef90d445a6a4aa0f037a9c7
13d45a6ad9631199af4e18e599490455
1,400
PASSED
#include <bits/stdc++.h> namespace myland{ using namespace std; namespace _abbr{ #define fi first #define se second #define pb push_back #define pr make_pair #define lb lower_bound #define ub upper_bound #define str string #define _1s __builtin_pop...
C++
63098c9d5ef90d445a6a4aa0f037a9c7
80a8252574c29d1d4d7d85e0e9aee217
1,400
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; const int N = 1e2 + 7; vector < int > graph[N + 5]; int dist[N + 5]; bool visit[N]; int n; long long ans; pair < int,int > bfs(int u) { for(int i = 0 ; i <= n ; i++...
C++
63098c9d5ef90d445a6a4aa0f037a9c7
7d5bc9b2f3717fe063cf66113f358e4d
1,400
PASSED
#include <bits/stdc++.h> using namespace std; #define ll long long int const int maxN=110; ll f1,f2,t,n,a[maxN],b[maxN],x,y,r; vector<ll> g[maxN]; ll bfs(ll x){ memset(a,255,sizeof(a)); a[x]=0; b[0]=x; f1=0; f2=1; while(f1<f2){ ll i=b[f1++]; for(ll j=0;j<(int)(g[i].size());j++){ ll k=g[i][j];...
C++
63098c9d5ef90d445a6a4aa0f037a9c7
4ca61ffcabf781977d90f1459f86e906
1,400
PASSED
/* I think the honorable thing for our species to do is deny our programming, stop reproducing. Walk hand in hand into extinction one last midnight. Brothers and sisters opting out of a raw deal. */ #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <string> #include <cctype> #inclu...
C++
63098c9d5ef90d445a6a4aa0f037a9c7
48085982948482f9048d40c225800d56
1,400
PASSED
#include <bits/stdc++.h> using namespace std; #define ll long long #define l long #define pb push_back #define mp make_pair #define mt make_tuple #define ff first #define ss second const int N = 105; int dist[N]; bool vis[N]; int mmax; void dfs(int u, vector<int> adj[]) { vis[u] = 1; for(auto it:adj[u]) { ...
C++
63098c9d5ef90d445a6a4aa0f037a9c7
bfd52e81cd38e49416d082e88a6ef3d2
1,400
PASSED
#include <stdio.h> #include <algorithm> #include <stdlib.h> #include <string.h> #include <iostream> #include <queue> #include <stack> #include <vector> #include <functional> #include <math.h> #include <map> #include <set> #include <string> using namespace std; #define fio ios::sync_with_stdio(false); cin.tie(NULL); ty...
C++
63098c9d5ef90d445a6a4aa0f037a9c7
823c0a55c7fe8a6f72b100e439d378da
1,400
PASSED
#include<bits/stdc++.h> #define ll long long using namespace std; const ll mod = 1e9+7; const int maxn = 1e6+7; ll fa[maxn],A[maxn],in[maxn]; int n; ll power ( ll a, ll b ){ if ( b == 0 )return a; if ( b == 1 )return a; if ( b % 2 )return ( a * power ( a,b-1 ) )%mod; ll t = power ( a,b/2 ); return ( ...
C++
28b7e9de0eb583642526c077aa56daba
6b4e8816a5b3fdf32c2215fc4885ba04
2,300
PASSED
#include<bits/stdc++.h> #define ll long long #define ld long double using namespace std; const ll mod = 1e9+7; const int maxn = 1e6+5; map<ll,ll>mp; ll fa[maxn]; ll in[maxn]; ll power ( ll a, ll b ){ if ( b == 0 )return 1; if ( b == 1 )return a; if ( b % 2 )return ( a * power ( a,b-1 ) )%mod; ll t = ...
C++
28b7e9de0eb583642526c077aa56daba
1750cbfb5bf0c69febc73ce00d36f874
2,300
PASSED
#include<bits/stdc++.h> #define rg register #define fp( i , x , y ) for( rg int i=(x); i<=(y); ++i ) #define fq( i , x , y ) for( rg int i=(y); i>=(x); --i ) using namespace std ; const int N = 1e6+10 , hgs = 1e9+7 ; int a[N] , n , ls[N] , fac[N] , inv[N] ; int qpow( int A , int B ) { int C=1 ; for( ; B ; ...
C++
28b7e9de0eb583642526c077aa56daba
84636cb5b9c8d3171309622ddefb266b
2,300
PASSED
#include<bits/stdc++.h> using namespace std; typedef long long LL; const LL N = 1e6+7; const LL MO = 1e9+7; LL a[N]; LL J[N], A[N]; int main(){ J[0] = 1; for(int i=1; i<N; i++) J[i] = J[i-1] * i % MO; int n; scanf("%d", &n); A[0] = 1; for(int i=1; i<=n; i++) A[i] = A[i-1]*(n-i+1)%MO; for...
C++
28b7e9de0eb583642526c077aa56daba
3497a37bcd33cd6e1a9bbe5e8b1eef9d
2,300
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; #define FOR(i,a) for (int i=0;i<(a);++i) #define FORD(i,a) for (int i=(a)-1;i>=0;i--) #define FORT(i,a,b) for (int i=(a);i<=(b);++i) #define FORTD(i,b,a) for (int i=(b);i>=(a);--i) #define trav(...
C++
28b7e9de0eb583642526c077aa56daba
8b319ec33ecb443ae7ee63f2eada371d
2,300
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 1e6+5; ll fac[MAXN]; const ll MOD = 1e9+7; ll raise(ll a, ll p) { if (p == 0) return 1; ll cur = raise(a, p/2)%MOD; cur = (cur*cur)%MOD; if (p%2) return (cur*a)%MOD; else return cur; } ...
C++
28b7e9de0eb583642526c077aa56daba
4c37cd3463d339a77df98bd97b7309eb
2,300
PASSED
#include<cstdio> #include<cstring> #include<algorithm> #define maxn 1000005 #define mod 1000000007LL #define ll long long using namespace std; ll n,a[maxn],ans=0,inv[maxn],jc[maxn]; inline void init(){ inv[0]=inv[1]=1; for(ll i=2;i<=n;i++)inv[i]=((mod-mod/i)*inv[mod%i])%mod; jc[0]=jc[1]=1; for(ll i=2;i<...
C++
28b7e9de0eb583642526c077aa56daba
3e6fff0c71a9a757dd26b391c2fee214
2,300
PASSED
#include<bits/stdc++.h> using namespace std; const int N=1000000+5; typedef long long ll; const int p=1e9+7; int n; ll f[N],a[N]; ll mog(ll a,int b) { ll ans=1; while(b){ if(b&1) ans=ans*a%p; b>>=1;a=a*a%p; } return ans; } int main() { cin>>n; f[0]=1; for(int i=1;i<=n;i++){ cin>>a[i]; f[i]=f[i-1]*i%p; }...
C++
28b7e9de0eb583642526c077aa56daba
22908f6b53e0eb842af8ba939d413094
2,300
PASSED
/* 1.前面没有大于等于他的 2. f[i]=(i-1)!*(n-i+1)!*C(i-1,n)=n!/(n-i+1) */ #include<cstdio> #include<algorithm> #define int long long using namespace std; inline int read(){int x=0,f=1,ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f;} inline void...
C++
28b7e9de0eb583642526c077aa56daba
16fb8cea015cf7698bf50b6774bcc929
2,300
PASSED
#include<iostream> #include<algorithm> using namespace std; int n; int a[1000010]; long long ksm(long long a,long long b) { long long ret=1; while(b) { if(b&1) ret=ret*a%1000000007; a=a*a%1000000007; b>>=1; } return ret; } long long A=1,ans; int main() { cin>>n; for(int i=1; i<=n; i++) { cin>...
C++
28b7e9de0eb583642526c077aa56daba
d19f102321e09d2c4d8eb0a7e848680b
2,300
PASSED
#include<bits/stdc++.h> using namespace std; #define llong long long int n,K,D; int nu[200200]; struct SEG{ llong mi[2000200]; llong laz[2000200]; void build(int rt,int l,int r) { if(l==r) { mi[rt]=1ll*l*D; return; } int mid=(l+r)/2; build(rt*2,l,mid); build(rt*2+1,mid+1,r); mi[rt]=min(mi[rt*2],...
C++
df2a8ede1294983bdbff7981b86372ad
fe2f8b82648fc2a4af8127bba42283ef
3,100
PASSED
#include<bits/stdc++.h> using namespace std; #define llong long long int n,K,D; int nu[200200]; struct SEG{ llong mi[2000200]; llong laz[2000200]; void build(int rt,int l,int r) { if(l==r) { mi[rt]=1ll*l*D; return; } int mid=(l+r)/2; build(rt*2,l,mid); build(rt*2+1,mid+1,r); mi[rt]=min(mi[rt*2],...
C++
df2a8ede1294983bdbff7981b86372ad
35384cce8616861ef203f9ab6edd52d4
3,100
PASSED
/*      />  フ      |  _  _|      /`ミ _x 彡      /      |     /  ヽ   ?  / ̄|   | | |  | ( ̄ヽ__ヽ_)_)  \二つ */ #include <queue> #include <vector> #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #define MP make_pair #define ll long long #define fi first #define se second using namespace std; ...
C++
df2a8ede1294983bdbff7981b86372ad
3f559ba93cf5334aba5ec545a3546da0
3,100
PASSED
#include <cstdio> #include <algorithm> #define ll long long #define db double #define ull unsigned long long #define uint unsigned int #define FIO "sequence" #define dbug(...) fprintf(stderr, __VA_ARGS__) template <typename Y> inline bool updmin(Y &a, Y b){if (a > b) {a = b; return 1;} return 0;} template <typename Y...
C++
df2a8ede1294983bdbff7981b86372ad
848b3a7ce642add8b5673301340ae55b
3,100
PASSED
#include<bits/stdc++.h> using namespace std; #define N 200010 int adv[N*5],mn[N*5],n,k,d,t[N],al,ar,bc[N],c[N],s1[N],s2[N],t1,t2,b[N],a[N]; void pd(int o){ if(adv[o]){ adv[o*2]+=adv[o];adv[o*2+1]+=adv[o]; mn[o*2]+=adv[o];mn[o*2+1]+=adv[o]; adv[o]=0; } } void up(int o){mn[o]=min(mn[o*2],mn[o*2+1]);} void add(int...
C++
df2a8ede1294983bdbff7981b86372ad
5d940ce27efc5f60515425e3a20a1ee4
3,100
PASSED
#include <bits/stdc++.h> #define Fast_cin ios::sync_with_stdio(false), cin.tie(0); #define rep(i, a, b) for(register int i = a; i <= b; i++) #define per(i, a, b) for(register int i = a; i >= b; i--) using namespace std; typedef unsigned long long ull; typedef pair <int, int> pii; typedef long long ll; template <typen...
C++
df2a8ede1294983bdbff7981b86372ad
9a514fdd6a20723f2af5f232d6bf778d
3,100
PASSED
#include<map> #include<cmath> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; typedef long long ll; const int N=2e5+5; map<int,int>M; int n,a[N],k,d,pll=2147483647,prr=2147483647,tot;//mmp读题是硬伤 int mod[N],lim,t1,t2; void solve_common(){ int ans=0,l=-1,ansl,ansr; for(int ...
C++
df2a8ede1294983bdbff7981b86372ad
a97670581df55954cf6df2ea5150b8a6
3,100
PASSED
#include<bits/stdc++.h> #define re register #define LL long long #define max(a,b) ((a)>(b)?(a):(b)) #define min(a,b) ((a)<(b)?(a):(b)) inline int read() { char c=getchar();int x=0,r=1; while(c<'0'||c>'9') {if(c=='-')r=-1;c=getchar();} while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+c-48,c=getchar();return r*x; } const int maxn...
C++
df2a8ede1294983bdbff7981b86372ad
adf8132f54bf14d1f76759f3d3a6242c
3,100
PASSED
#include<bits/stdc++.h> using namespace std; const int N=2e5+10,M=1e9,INF=1e18; int a[N],b[N],s1[N],s2[N]; int n,m,k,d,top1,top2,ansr,ansl,sum[N],pos[N],t[N],mn[N]; map<int,int>mp; void reset(int x){ mn[x]=INF; for(int i=(x-1)*m+1;i<=min(n,x*m);i++) mn[x]=min(mn[x],t[i]+sum[x]); } inline void add(int l,int r,int c)...
C++
df2a8ede1294983bdbff7981b86372ad
dfab188c02aa45492b8e1d9c3021f447
3,100
PASSED
#include<bits/stdc++.h> using namespace std; #define LL long long #define pa pair<int,int> const int Maxn=200010; const int inf=2147483647; int read() { int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar(); return x*f; } unor...
C++
df2a8ede1294983bdbff7981b86372ad
32ffacdaee1168a1ab0d59828ad15175
3,100
PASSED
//Solution by Tima #include <bits/stdc++.h> #define f first #define s second #define ll long long #define ull unsigned long long #define mp make_pair #define pb push_back #define vi vector <int> #define ld long double #define pii pair<int, int> #define y1 sda #define all(x) x.begin(), x.end() using namespace std; ...
C++
5802f9c010efd1cdcee2fbbb4039a4cb
0cd549e9231bdd40a6d2509846962ea5
1,900
PASSED
#include <bits/stdc++.h> #define fast ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define L long long #define ll long long #define SS string #define PB push_back #define pp pair<L,L> #define f(x, n , i) for (i = x ; i <= n ; i++) #define setE(a, x , size) memset(a,x,size); #define NL 200500...
C++
5802f9c010efd1cdcee2fbbb4039a4cb
57b08b5af8c67550b2ce94ebc2120f19
1,900
PASSED
#include <bits/stdc++.h> #define fast ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define L long long #define ll long long #define SS string #define PB push_back #define pp pair<L,L> #define f(x, n , i) for (i = x ; i <= n ; i++) #define setE(a, x , size) memset(a,x,size); #define NL 200500...
C++
5802f9c010efd1cdcee2fbbb4039a4cb
0783e8a34ef4198a77897bc0bc61c816
1,900
PASSED
#include <bits/stdc++.h> #define fast ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define L long long #define ll long long #define SS string #define PB push_back #define pp pair<L,L> #define f(x, n , i) for (i = x ; i <= n ; i++) #define setE(a, x , size) memset(a,x,size); #define NL 200500...
C++
5802f9c010efd1cdcee2fbbb4039a4cb
1e71b07ad8ed82bc3adb69148e3babcd
1,900
PASSED
#include <bits/stdc++.h> #define fast ios_base::sync_with_stdio(false); \ cin.tie(NULL); #define L long long #define ll long long #define SS string #define PB push_back #define pp pair<L,L> #define f(x, n , i) for (i = x ; i <= n ; i++) #define setE(a, x , size) memset(a,x,size); #define NL 200500...
C++
5802f9c010efd1cdcee2fbbb4039a4cb
4298d52292160122991811fbd6a54363
1,900
PASSED
#include <iostream> #include <vector> #include <algorithm> using namespace std; #define _min(a, b) (a > b ? b : a) const int maxn = 2.2e5; vector<int> g[maxn]; int cnt[maxn]; void init(){ for(int i = 0; i < maxn; ++i){ cnt[i] = 0; } } int main(){ init(); int n, k; cin >> n >> k; vector<i...
C++
5802f9c010efd1cdcee2fbbb4039a4cb
5ab468b954e3e6d3e9fbabeecf676908
1,900
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int INF = 0x3f3f3f3f; const int mod = 1e9+7; const double eps = 1e-5; const int N = 2e5 + 10; void redirect() { #ifdef LOCAL freopen("1.in","r",stdin); freopen("1.out","w",stdout); #endif } ll n, k; int a[N], cnt[N]; ll...
C++
5802f9c010efd1cdcee2fbbb4039a4cb
7b2d3237128e6062047f420244daf265
1,900
PASSED
#include <bits/stdc++.h> #define int long long using namespace std; const int N=2e5+5; int T; int n,k,now,ans,tot; int sum[N],c[N],a[N],l[N],r[N]; vector<int>vec[N]; inline bool jay(int mid) { for (register int i=1; i<=k; ++i) if (mid*c[i]<sum[i]) return false; return true; } signed main(){ scanf("%lld%lld",&n,&k...
C++
5802f9c010efd1cdcee2fbbb4039a4cb
84a79459826e14498ce83d1df83298b2
1,900
PASSED
#include <bits/stdc++.h> #define int long long using namespace std; const int N=2e5+5; int T; int n,k,now,ans,tot; int sum[N],c[N],a[N],l[N],r[N]; vector<int>vec[N]; inline bool jay(int mid) { for (register int i=1; i<=k; ++i) if (mid*c[i]<sum[i]) return false; return true; } signed main(){ scanf("%lld%lld",&n,&k...
C++
5802f9c010efd1cdcee2fbbb4039a4cb
e5386f198279474465be5a8e90276e87
1,900
PASSED
#include<iostream> #include<bits/stdc++.h> #include<stdio.h> #include<stdlib.h> #include<vector> #include<map> using namespace std; typedef long long LL; #define N 201000 int m[N],c[N]; vector<int> ans[N]; int startat[N]; int tong[N]; vector<int> mymove; int prex[N],postx[N]; int main() { setvbuf(stdin, (char *)cal...
C++
5802f9c010efd1cdcee2fbbb4039a4cb
db4fd2c0def82f4aef5ff81670a1e86a
1,900
PASSED
#!/usr/bin/env python # -*- coding: utf-8 -*- from collections import defaultdict from math import factorial as f from fractions import gcd as g N = int(raw_input ()) l = [int(i) for i in raw_input ().split()] ret = l[0] / 3 left = l [0] % 3 for i in range(1, N): x = left * 2 if l [i] >= x: ret += lef...
Python
a8f3e94845cb15a483ce8f774779efac
055a5dbda2f4b6b49345076737ac2f3f
1,900
PASSED
n = int(raw_input()) a = [int(i) for i in raw_input().split(' ')] ans = 0 b = 0 for i in a: p = min(b , i // 2) b -= p q = (i - p * 2) // 3 b += i - p * 2 - q * 3 ans += p + q print ans
Python
a8f3e94845cb15a483ce8f774779efac
e3f57db8a894873549fd2c0bbdd1779f
1,900
PASSED
from sys import stdin from itertools import repeat def main(mn=min): n = int(stdin.readline()) a = map(int, stdin.readline().split(), repeat(10, n)) ans = u = 0 for x in a: t = mn(u, x / 2) ans += t u -= t x -= t * 2 ans += x / 3 u += x % 3 print ans m...
Python
a8f3e94845cb15a483ce8f774779efac
8b9dd2cb87287c2ea2f2ac43f767853c
1,900
PASSED
import sys,math from fractions import gcd from bisect import bisect_left from collections import defaultdict from io import BytesIO sys.stdin = BytesIO(sys.stdin.read()) input = lambda: sys.stdin.readline().rstrip('\r\n') n = int(input()) arr = [int(x) for x in input().split()] res = 0 cnt = 0 for i in range(n): i...
Python
a8f3e94845cb15a483ce8f774779efac
9b7e2e44dbc1db7be101f1343af1a3cd
1,900
PASSED
n, ans, last = int(raw_input()), 0, 0 a = list(map(int, raw_input().split())) for i in range(len(a)): while last > 0 and a[i] >= 2: ans += 1 a[i] -= 2 last -= 1 ans += a[i] // 3 last += a[i] % 3 print(ans)
Python
a8f3e94845cb15a483ce8f774779efac
7c0d721f5d4e3455feb1d5c1fe6fd4ea
1,900
PASSED
def input_s(): return raw_input() def input_i(): return int(raw_input()) def input_2_i(): arr = map(int, raw_input().split()) return arr[0], arr[1] def input_3_i(): arr = map(int, raw_input().split()) return arr[0], arr[1], arr[2] def input_i_array(): return map(int, raw_input().split()...
Python
a8f3e94845cb15a483ce8f774779efac
784471d535d462f83020f7b3a7635c96
1,900
PASSED
#include<stdio.h> #define ll long long int main() { long long int n; scanf("%lld",&n); ll cnt=0,cnt1=0,temp; for(int i=0;i<n;i++) { scanf("%lld",&temp); if(temp==1) cnt1++; else if(temp==2) { if(cnt1>0) { cnt1--; cnt++; } else cnt1+=2; } else { while(temp>=2&&cnt1) { ...
C
a8f3e94845cb15a483ce8f774779efac
9a13216aa625a7e00b9eda8f3b04381e
1,900
PASSED
#include<stdio.h> int main(void){ unsigned long n,p;unsigned long long g=0;int count=0; scanf("%lu\n",&n); while(n>0){ scanf("%lu",&p); while(p>1){ if(count!=0){ count--; g++; p=p-2; } else{ g=g+p/3; if((p%3)==1) count++; else if((p%3)==2) count=count+2; p=0; ...
C
a8f3e94845cb15a483ce8f774779efac
a100fe7b2e217df5488c86a0e1fb3d3d
1,900
PASSED
#include<stdio.h> int main() { long long int n,basket=0,c=0,pair,a; scanf("%lld", &n); for(int i=1;i<=n;i++) { scanf("%lld", &a); pair=a/2; if (basket<(a/2)) pair=basket; basket-=pair; a-=2*pair; c+=pair+a/3; basket+=a%3; } printf("%lld", c); return 0; }
C
a8f3e94845cb15a483ce8f774779efac
c261af7304e6af20abfb823cd39d89dd
1,900
PASSED
#include<stdio.h> int main() { long long N, count=0; long long int carry=0; scanf("%lli", &N); long long int curr; while (N>0) { scanf("%lli", &curr); while (carry>0 && curr>1) { carry--; curr=curr-2; ...
C
a8f3e94845cb15a483ce8f774779efac
309811e127444cb4573c451d296f33c9
1,900
PASSED
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=3e5+50; ll sum[N],odd[N],even[N]; ll a[N],b[N]; int main(){ int n; scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%lld",&a[i]); b[i]=0; for(int j=0;j<64;j++){ if(a[i]&(1LL<<j)){ ...
C++
d197a682b956f000422aeafd874816ce
16b4b05efefca37ec26347f02bb43465
2,000
PASSED
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N=3e5+50; ll sum[N],odd[N],even[N]; ll a[N],b[N]; int main(){ int n; scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%lld",&a[i]); b[i]=0; for(int j=0;j<64;j++){ if(a[i]&(1LL<<j)){ ...
C++
d197a682b956f000422aeafd874816ce
f0099d0e6de3ca12aec967bb8e65833f
2,000
PASSED
#include <bits/stdc++.h> #define endl '\n' #define ll int64_t #define ull uint64_t using namespace std; const int N = int(3e5) + 9; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll n, res{}, s1 = 1, s2{}, sufSum{}; cin >> n; long long a[N]; int b[N]; for(int i = 0; i <n; ++i)...
C++
d197a682b956f000422aeafd874816ce
6055ca656ac2d461b40f030c41d6c1a3
2,000
PASSED
#include <bits/stdc++.h> #define endl '\n' #define ll int64_t #define ull uint64_t using namespace std; const int N = int(3e5) + 9; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll n, res{}, s1 = 1, s2{}, sufSum{}, temp; cin >> n; vector<int> b; for(int i = 0; i <n; ++i){ ...
C++
d197a682b956f000422aeafd874816ce
96617797b880cb39c0adea12036e1bce
2,000
PASSED
#include <bits/stdc++.h> #define sz(x) (long long)x.size() using namespace std; //mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); const int N = 1e5 + 5, M = 1e6 + 7, SM = 1e3 + 5, logN = 20; const long long MOD = 1e9 + 7, INF = 1e18 + 9; const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1}; const int dy...
C++
d197a682b956f000422aeafd874816ce
c177c418648ccb81e56dd872bf35d7bc
2,000
PASSED
#include<bits/stdc++.h> #define mino "1030E" #define ll long long #define pb push_back #define fi first #define se second #define mp make_pair #define FOR(i,a,b) for(int i=a; i<=b; i++) #define Down(i,a,b) for(int i=a; i>=b; i--) #define FOR_(i,a,b) for(int i=a; i<b; i++) #define turbo ios_base::sync_with_stdio(0); ...
C++
d197a682b956f000422aeafd874816ce
57e17f52169f91b4445979a6a2b9e9d5
2,000
PASSED
#include<bits/stdc++.h> #define mino "1030E" #define ll long long #define pb push_back #define fi first #define se second #define mp make_pair #define FOR(i,a,b) for(int i=a; i<=b; i++) #define Down(i,a,b) for(int i=a; i>=b; i--) #define FOR_(i,a,b) for(int i=a; i<b; i++) #define turbo ios_base::sync_with_stdio(0); ...
C++
d197a682b956f000422aeafd874816ce
cdb16a6e2bae221268f7db9cb1273619
2,000
PASSED