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 <map> #include <set> #include <unordered_set> #include <algorithm> #include <cmath> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair < int, int >pii; #ifndef ONLINE_JUDGE auto __redirect__ = freopen("in", "r", stdin); #else # include<bits/stdc++.h>...
C++
fd94aea7ca077ee2806653d22d006fb1
b516a3ee838ed06a3ae7ed589f0075bd
1,700
PASSED
#include <iostream> #include <string.h> #include<cstdlib> #include <map> #include <algorithm> #define ll long long using namespace std; ll n,x; ll tree[800005][6],add[400005],pan[400005],shu[400005]; ll num[800005]; char a[10]; map <ll,ll> id; inline ll read(){ int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9') {if...
C++
7607c4c6d26ab3a663fcfa151c75c749
c5a80286b140282a00cb0d04f4531077
2,300
PASSED
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<vector> using namespace std; int n; char tmp[10]; vector <int> v; int main() { scanf("%d",&n); while(n--) { scanf("%s",tmp); if(tmp[0]=='a') { int x; scanf("%d",&x); v.insert(lower_bound(v.begin(),v.end(),x),x); } ...
C++
7607c4c6d26ab3a663fcfa151c75c749
2ecb0121226764b603822d2ffe63591c
2,300
PASSED
#include<bits/stdc++.h> using namespace std; const int mn=100000; int num,n,tree[mn*20+5],L[mn*20+5],R[mn*20+5]; char s[5]; long long sum[mn*20+5][5]; void change(int p,int l,int r,int x){ if(l==r){ tree[p]=1; sum[p][1]=x; return; } int mid=(l+r)>>1; if(x<=mid){ if(!L[p]) L[p]=++num; change(L[p],l,mid,x);...
C++
7607c4c6d26ab3a663fcfa151c75c749
196988632154ded57acc3b12aa4f5d4b
2,300
PASSED
#include<bits/stdc++.h> using namespace std; const long long maxn = 1e5 + 5; long long n, q[maxn], cnt, q2[maxn]; pair<int, int> b[maxn]; bool below[maxn]; struct node{ long long a[5], siz; }f[maxn<<3]; void pushup(long long p){ long long ls = p*2, rs = p*2+1; for(long long i=0; i<5; i++) f[p].a[i] = f[ls].a[i]...
C++
7607c4c6d26ab3a663fcfa151c75c749
3b4494d6edf892d305772c446b860ab0
2,300
PASSED
// Problem : D. Sum of Medians // Contest : Yandex.Algorithm 2011: Round 1 // URL : https://codeforces.com/problemset/problem/85/D // Memory Limit : 256 MB // Time Limit : 3000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) #include <bits/stdc++.h> #define int long long using namespace std; typedef...
C++
7607c4c6d26ab3a663fcfa151c75c749
fd6f039b800de5d39b8cf9d62af6ec42
2,300
PASSED
// Problem : D. Sum of Medians // Contest : Yandex.Algorithm 2011: Round 1 // URL : https://codeforces.com/problemset/problem/85/D // Memory Limit : 256 MB // Time Limit : 3000 ms // Powered by CP Editor (https://github.com/cpeditor/cpeditor) #include <bits/stdc++.h> using namespace std; typedef long long LL; #define...
C++
7607c4c6d26ab3a663fcfa151c75c749
d988e59ddf8a4b1291d0d69a12cd58fe
2,300
PASSED
#include <bits/stdc++.h> #define ll long long using namespace std; const int N=1e5+5; int n,tot; int b[N],add[N<<2]; ll sum[N<<2][5]; struct number{int x,f;}num[N]; char str[10]; void change(int k,int l,int r,int v1,int v2,int pos) { if (l==r) { sum[k][1]+=(ll)v1; add[k]+=v2; return; } int mid=l+r>>1; if (...
C++
7607c4c6d26ab3a663fcfa151c75c749
58320c832064fb232790990e8be4a2ed
2,300
PASSED
#include <bits/stdc++.h> #define ll long long using namespace std; const int N=1e5+5; int n,tot; int b[N],add[N<<2]; ll sum[N<<2][5]; struct number{int x,f;}num[N]; char str[10]; void change(int k,int l,int r,int v1,int v2,int pos) { if (l==r) { sum[k][1]+=(ll)v1; add[k]+=v2; return; } int mid=l+r>>1; if (...
C++
7607c4c6d26ab3a663fcfa151c75c749
c246daf060b476f8b7d27eba42c4b1bf
2,300
PASSED
#include <cstdio> #include <ctype.h> #include <cstring> #include <algorithm> using namespace std; const int MAXN = 1e5 + 7; const int MOD = 5; typedef long long LL; int tx[MAXN], cnt, n; struct Qry { int opt; int val; }qry[MAXN]; namespace SGT { LL tr[MAXN << 2][6]; int sum[MAXN << 2]; inline void pushup(in...
C++
7607c4c6d26ab3a663fcfa151c75c749
f4cc9b53ca031a317fd587b25d97ccee
2,300
PASSED
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i) #define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i) mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count()); template <typename T> inline void chkmax(T &x, T y)...
C++
7607c4c6d26ab3a663fcfa151c75c749
1d35b40b36e5492a4a9cf892572b7f28
2,300
PASSED
#include<cstdio> #include<algorithm> using namespace std; #define LL long long const LL oo=1e15; LL a[100010],ts,tf,t; int n; int main() { LL now,ans,ansv=oo; scanf("%I64d%I64d%I64d%d",&ts,&tf,&t,&n); for (int i=1;i<=n;i++) scanf("%I64d",&a[i]); now=ts; if (a[1]>ts) { printf("%d\n",ts); ...
C++
f169ed11206ccc6900b90d5e889ced27
2be369f6fd9682dc5d218384ce565781
2,100
PASSED
#include<bits/stdc++.h> using namespace std; typedef long long LL; const int N = 1e5+9; const LL INF = 1e12+1; int n; LL ts, tf, t, res, a[N]; int main() { scanf("%I64d %I64d %I64d %d", &ts, &tf, &t, &n); for (int i = 1; i <= n; i++) { scanf("%I64d", &a[i]); } a[n + 1] = INF; LL min = INF; LL cur = ts; fo...
C++
f169ed11206ccc6900b90d5e889ced27
11fbc798b554bf536fdf33bcdb11687b
2,100
PASSED
#include <ctime> #include <cstdio> #include <cstdlib> #include <cstring> #include <cassert> #include <algorithm> #include <iostream> #include <vector> #include <queue> #include <stack> #include <deque> #include <set> #include <map> using namespace std; typedef long long ll; typedef double lf; typedef long double Lf; t...
C++
f169ed11206ccc6900b90d5e889ced27
dedc54e951c04e675410c95945f0ea54
2,100
PASSED
#include <bits/stdc++.h> using namespace std; #define x first #define y second typedef long long ll; typedef pair<ll,int> pt; const ll base = ll(1000000007)*ll(10000000); const int maxn = 300002; int n, dem; ll ts,tf,t,res1,res2,timeht; pt a[maxn]; int main() { int i,j; ll k; //freopen("cf398b.inp","r",...
C++
f169ed11206ccc6900b90d5e889ced27
c714148e2a44f4989f2d5653d0dcc174
2,100
PASSED
//=============================*/*=============================================== // Name : Algorithm.cpp // Author : Jos Ral Prez Rodrguez // Version : // Copp.secondright : p.secondour copp.secondright notice // Description : Hello World in C++, Ansi-stp.secondle //==================================...
C++
f169ed11206ccc6900b90d5e889ced27
40ea973f849b712ece8090820e6d9aaa
2,100
PASSED
#include<bits/stdc++.h> using namespace std; long long A[100005],pre[100005]; map<long long,int>X; int main() { // ios::sync_with_stdio(false); long long ts,tf,t; cin>>ts>>tf>>t; int N; cin>>N; if(N==0) { cout<<ts; return 0; } int i; for (i=1;i<=N;i++) { cin>>A[i]; X[A[i]]++; } vector<pai...
C++
f169ed11206ccc6900b90d5e889ced27
cabb125a1ec2b67455fa44647a9a6289
2,100
PASSED
#include<stdio.h> #include<algorithm> using namespace std; #define LL long long LL a[100005]; int main(void) { int n, i; LL b, e, t, now, ans, bet; scanf("%I64d%I64d%I64d%d", &b, &e, &t, &n); for(i=1;i<=n;i++) scanf("%I64d", &a[i]); ans = 0, bet = 1000000000000000ll, now = b; for(i=1;i<=n;i++) { if(a[i]>now ...
C++
f169ed11206ccc6900b90d5e889ced27
870803aaa11f86e90dc6d914bf7ac519
2,100
PASSED
#include <cstdio> #include <algorithm> using namespace std; #define int long long int ts,tf,wai,n,ans,wt=1e12+7; signed main() { scanf("%I64d%I64d%I64d%I64d",&ts,&tf,&wai,&n); for (int i=1,v;i<=n;i++) { scanf("%I64d",&v); if (v && v+wai<=tf) { if (max(ts,v-1)+wai<=tf && ts-v+1<=wt) { wt=ts-v+1; ans=min...
C++
f169ed11206ccc6900b90d5e889ced27
672bf7873126576af371f6a2eb4473e1
2,100
PASSED
#include<cstdio> long long start, cur, end, ser_time, n, cost, ans; long long num[100010]; int main() { scanf("%lld%lld%lld%lld",&start, &end, &ser_time, &n); cur = start; for(long long i=0;i<n;i++){ scanf("%lld", &num[i]); } cost = 100000000000000000; for(int i=0;i<n;i++){ if(num[i]<=start){ if(cost > cu...
C++
f169ed11206ccc6900b90d5e889ced27
63d34c12031d5a17120fe54864e3eeea
2,100
PASSED
#include<iostream> #include<algorithm> #include<cmath> using namespace std; const int maxn=1000000+5; const long long INF=90000000000000; long long a[maxn],b[maxn]; int main() { long long st,en,t,n; cin>>st>>en>>t>>n; long long p=st; for(int i=1;i<=n;++i) { cin>>a[i]; if(a[i]<p) p+=...
C++
f169ed11206ccc6900b90d5e889ced27
5b401d0e6d21a453cbf60fad642b3691
2,100
PASSED
#include<bits/stdc++.h> using namespace std; map<long long int,long long int> testMap; int main(void){ long long int n,k; cin>>n>>k; long long int max_, min_; max_ = -1; min_ = INT_MAX; for(int i=0; i< n; i++) { long long int v; cin>>v; max_ = max( v, max_); ...
C++
51113dfdbf9f59152712b60e7a14368a
9d5f99e3ed4653dab332637600b4e3eb
2,000
PASSED
#include<iostream> #include<algorithm> using namespace std; #define ll long long ll a[201010]; int main(){ ll n,k,ans=0; scanf("%lld%lld",&n,&k); for(int i=1;i<=n;i++)scanf("%lld",&a[i]); sort(a+1,a+n+1); ans=a[n]-a[1]; if(n%2){ for(int i=1;i<(n/2)+1;i++){ ll t=min(a[i+1]-a[i]+a[n-i+1]-a[n-i],k/i); an...
C++
51113dfdbf9f59152712b60e7a14368a
13ddd09924211d83bbdc66c9f8eefdc8
2,000
PASSED
#include <bits/stdc++.h> #define ll long long #define ld long double using namespace std; int main() { ll n,k; cin>>n>>k; ll ar[n]; map <ll,ll> m; for(ll i=0;i<n;i++) { cin>>ar[i]; m[ar[i]]++; } sort(ar,ar+n); // for(auto x:ar)cout<<x<<" "; //cout<<endl; ll l=0,r=n...
C++
51113dfdbf9f59152712b60e7a14368a
0ccbf664936d49fee52afd534f9e8846
2,000
PASSED
#include <bits/stdc++.h> #define NMAX 100005 #define ll long long int using namespace std; ll n, sp[NMAX], sp2[NMAX], nr[NMAX], k, i, maxelement, st, dr, aux, mid, moves, difmin=1e9+5; ll movesst(ll k){ int st = 0, dr = n+1, mid; while(dr - st > 1){ mid = (st+dr)/2; if(nr[mid] < k) ...
C++
51113dfdbf9f59152712b60e7a14368a
34394ad3262c81ae05fa9e199d9af7c3
2,000
PASSED
#include <bits/stdc++.h> using namespace std; #define DBG(x) \ (void)(cout << "L" << __LINE__ \ << ": " << #x << " = " \ << (x) << '\n') typedef long long ll; const int INF = 0x3f3f3f3f; const int maxn = 110000; ll a[maxn]; ll b[maxn]; ll n, k; bool check...
C++
51113dfdbf9f59152712b60e7a14368a
913cf4c8901807a98d19904d8ffb1db8
2,000
PASSED
#include <bits/stdc++.h> using namespace std; #define DBG(x) \ (void)(cout << "L" << __LINE__ \ << ": " << #x << " = " \ << (x) << '\n') typedef long long ll; const int INF = 0x3f3f3f3f; const int maxn = 110000; ll a[maxn]; ll b[maxn]; ll n, k; bool check...
C++
51113dfdbf9f59152712b60e7a14368a
683606fd3117d273fc128b5d916238d6
2,000
PASSED
#include <bits/stdc++.h> using namespace std; #define DBG(x) \ (void)(cout << "L" << __LINE__ \ << ": " << #x << " = " \ << (x) << '\n') typedef long long ll; const int INF = 0x3f3f3f3f; const int maxn = 110000; ll a[maxn]; ll b[maxn]; ll n, k; bool check...
C++
51113dfdbf9f59152712b60e7a14368a
0b911ec27da77f6fb4203b184a741b2b
2,000
PASSED
//================================================================================================== // Name : a.cpp // Author : lotus.eater086 // Copyright : If you're reading this then this warning is for you. Every word you read of this // useless fine print is another second of your lif...
C++
51113dfdbf9f59152712b60e7a14368a
2efa5b20b930b957408a72d209c9abb6
2,000
PASSED
#include<cstdio> #include<algorithm> #include<queue> #define LL long long using namespace std; const int N=1e5+50; int n; struct node{LL val,sz;}; struct cmp1 { bool operator () (node a,node b) { return a.val>b.val; } }; struct cmp2 { bool operator () (node a,node b) { return a.val<b.val; } }; priority_qu...
C++
51113dfdbf9f59152712b60e7a14368a
a960b9edb06c44b9e90ecd12b22ae746
2,000
PASSED
#define DEBUG(...) /* Strip me down and go to town */ /* Lick me over upside down */ /* Pound and pound and pound and pound */ /* Baby make me make that sound ...
C++
51113dfdbf9f59152712b60e7a14368a
630dd0bee7261461c6fd358e96ee9b15
2,000
PASSED
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e5+5; int T; ll n; int main(){ cin>>T; while(T--){ cin>>n; ll r=n%3; n=(n-1)/3+1; ll w=0; for(ll i=0,n1=n;i<=30;++i) if(n1>(1ll<<2*i)){ w+=(1ll<<2*i+1); n1-=(1ll<<2*i); } n+=w; ll x=0; for(int i=30;~i;--i) ...
C++
37c3725f583ca33387dfd05fe75898a9
ad1d1ab4f89ed6ce0542fccc415a04ed
2,200
PASSED
#include <iostream> using namespace std; int trip[4][3] = {{0, 0, 0}, {1, 2, 3}, {2, 3, 1}, {3, 1, 2}}; int main() { cin.sync_with_stdio(false); cin.tie(0); int t; cin>>t; while(t--) { long long n; cin>>n; long long x = 3, y = 3, a = 0, b = 0, c = 0; int z =...
C++
37c3725f583ca33387dfd05fe75898a9
e6296678008ac14e367b4a03a869a256
2,200
PASSED
#include<bits/stdc++.h> //#include<ext/pb_ds/assoc_container.hpp> //#include<ext/pb_ds/tree_policy.hpp> #define int long long #define fr(i,x,y) for(int i=x;i<y;i++) #define rfr(i,x,y) for(int i=x;i>=y;i--) using namespace std; //using namespace __gnu_pbds; const int N=4e3,P=31,MOD=998244353,INF=1e17; int dp[N][N]; stri...
C++
37c3725f583ca33387dfd05fe75898a9
bc823fd3c67673fd2407df9f6822c348
2,200
PASSED
#include <bits/stdc++.h> typedef long long ll; const ll dak[4] = {0, 2, 3, 1}; void kth(ll k, ll &a, ll &b, ll &c) { if (!k--) {a = 1, b = 2, c = 3; return;} int w = 0; ll z = 4; for (; k >= z; k -= z, z <<= 2); for (a = z + k, b = 0; k; k >>= 2, w += 2) b |= dak[k & 3] << w; b += z << 1, c = a ^ b; } void work...
C++
37c3725f583ca33387dfd05fe75898a9
8b938400290ea065e6601370901dcc37
2,200
PASSED
#pragma GCC optimize ("O3", "unroll-loops") //#pragma GCC target ("avx2") //#pragma comment(linker, "/stack:200000000") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define all(x) x....
C++
37c3725f583ca33387dfd05fe75898a9
84170c6b1a8be0f64efbd6c8d3c1ba42
2,200
PASSED
#include <bits/stdc++.h> using namespace std; #define ll long long #define db double #define pb push_back #define ppb pop_back #define F first #define S second #define mp make_pair #define all(x) (x).begin(), (x).end() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); typedef pair <int, int> pii; t...
C++
37c3725f583ca33387dfd05fe75898a9
04d69d9a5fa354c7b999bf75f60f7310
2,200
PASSED
#include <bits/stdc++.h> using namespace std; #define fr(i,n) for(int i = 0; i<n; i++) #define sz(v) (int)(v).size() #define prin(a) cout << #a << " = " << a << endl #define all(v) (v).begin(),(v).end() typedef long long ll; ll vans[] = {1,2,3,4,8,12,5,10,15,6,11,13,7,9,14}; ll vv[] = {0,2,3,1}; int main(){ ll t; ...
C++
37c3725f583ca33387dfd05fe75898a9
c1b89e8bba03b7087790a2548532d769
2,200
PASSED
#include <bits/stdc++.h> typedef long long ll; int p[10000]; int q[][3] = { {1, 2, 3}, {0, 0, 0}, {1, 2, 3}, {2, 3, 1}, {3, 1, 2} }; ll calc(ll n){ ll belong = (n - 1) / 3 + 1; ll pok = 1; int top_pos = 1; while(belong > pok){ belong -= pok; pok *= 4, ++top_pos; } pok = 4; ll res = 0; for(int i = 1; i ...
C++
37c3725f583ca33387dfd05fe75898a9
093c9c729d1602c4168bbb87f789944a
2,200
PASSED
#include <bits/stdc++.h> typedef long long ll; int p[10000]; int q[][3] = { {1, 2, 3}, {0, 0, 0}, {1, 2, 3}, {2, 3, 1}, {3, 1, 2} }; ll calc(ll n){ ll belong = (n - 1) / 3 + 1; ll pok = 1; int top_pos = 1; while(belong > pok){ belong -= pok; pok *= 4, ++top_pos; } pok = 4; ll res = 0; for(int i = 1; i ...
C++
37c3725f583ca33387dfd05fe75898a9
725e9db5d8cbf082c04236c6ba2a1f66
2,200
PASSED
#include<bits/stdc++.h> #define MAXN 100005 #define reg register #define inl inline #define int long long using namespace std; int n,_[65],A,B,C; void Calc(reg int l,reg int r,reg int x) { B<<=2; if(r-l+1==4) { if(x%4==1) B+=0; if(x%4==2) B+=2; if(x%4==3) B+=3; if(x%4==0) B+=1; return; } reg int len=r-l+...
C++
37c3725f583ca33387dfd05fe75898a9
27e5b1ecc8519cfdf862052de8b15ecb
2,200
PASSED
#define f first #define s second #define ll long long #define loop(a,b) for(ll i=a;i<b;i++) #define vi vector<int> #define vvi vector<vi> #define mp make_pair #define pb push_back #define ppb pop_back #define pii pair<int,int> #define vpii vector<pair<int,int>> #define vll vector<long long> #define loop2(a,b) for(ll ...
C++
a1b6a2f4659169e0e818bbdee6d36e76
eccd3021e45cd31a4ca573c2c9f8ba58
1,300
PASSED
#include <iostream> #include <bits/stdc++.h> using namespace std; int main() { int i,j,n,m,t,sum=0,ans,ans2,i1; cin>>t; char c; vector<vector<int>> v,v1; unordered_map<int,vector<int>> m1; unordered_map<int,int> m2; vector<int> v2; while(t>0) { t--; cin>>n>>m; ...
C++
a1b6a2f4659169e0e818bbdee6d36e76
87d671b926935dd0e02341e9f6df729e
1,300
PASSED
#include<bits/stdc++.h> using namespace std ; #define Fors(n) for(int i=1;i<=n;i++) #define For(n) for(i=0;i<n;i++) #define ll long long #define vint(s) vector<int> s #define pb(x) push_back(x) #define mpair(x,y) make_pair(x,y) #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll x=0,y=0,n=0,i=0; int mai...
C++
a1b6a2f4659169e0e818bbdee6d36e76
4f4e84427a819a1c955ac704f825ba06
1,300
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; vector<vector<char>> c; int solve(int n, int m) { int ret = n + m + 1; int r_v[m][n+1]{}, c_v[n][m+1]{}; // memset(r_v, 0, sizeof(r_v)); // memset(c_v, 0, sizeof(c_v)); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if...
C++
a1b6a2f4659169e0e818bbdee6d36e76
ae71cf8de7f7478e6df3fd2de880bfa7
1,300
PASSED
#include<bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int q;cin>>q; for(int p=0;p<q;p++) { int n,m; cin>>n>>m;string s[n]; for(int i=0;i<n;i++) ...
C++
a1b6a2f4659169e0e818bbdee6d36e76
01c61213e3edc367b3a4d301a845d7aa
1,300
PASSED
#include <iostream> #include<cstring> #include<cstdio> #include<algorithm> #include<map> #include<queue> #include<set> #include<cmath> #include<stack> #include<string> const int maxn = 5e4 + 5; const int mod = 10007; const int inf = 1e9; const long long onf = 1e18; #define me(a, b) memset(a,b,sizeof(a)) #define lowbit...
C++
a1b6a2f4659169e0e818bbdee6d36e76
457a56eabbc51068eafb5065d0552b85
1,300
PASSED
#include <bits/stdc++.h> using namespace std; int main() { string a[50010]; int t; cin>>t; while(t--) { int h[50010]= {0},l[50010]= {0}; int n,m,i,j; cin>>n>>m; for(i=0; i<n; i++) { cin>>a[i]; for(j=0; j<m; j++) { ...
C++
a1b6a2f4659169e0e818bbdee6d36e76
d593fc18d09c8462d2d15c5163ad8ef8
1,300
PASSED
#include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<algorithm> using namespace std; typedef long long ll; int h[50010],l[50010]; int main(){ string s[50010]; int q; cin>>q; while(q--){ memset(h,0,sizeof(h)); memset(l,0,sizeof(l)); int n,m,minn=1000000; cin>>n>>m; for(int i=0;i<n...
C++
a1b6a2f4659169e0e818bbdee6d36e76
310cfb1294c7f9ca9f84d3de8f3d2dc8
1,300
PASSED
#include<bits/stdc++.h> #define ll long long int using namespace std; int main() { ll q; cin>>q; while(q--) { ll n,m,i,j; cin>>n>>m; char a[n][m]; for(i=0;i<n;i++) { cin>>a[i]; } ll r[100007]; ll c[100007]; for(i=0;i<n;i++) { ...
C++
a1b6a2f4659169e0e818bbdee6d36e76
a1923f22019b5bbcf66998b6391a27a9
1,300
PASSED
#include<bits/stdc++.h> #define ll long long int using namespace std; int main() { ll q; cin>>q; while(q--) { ll n,m,i,j; cin>>n>>m; char a[n][m]; for(i=0;i<n;i++) { cin>>a[i]; } ll r[100007]; ll c[100007]; for(i=0;i<n;i++) { ...
C++
a1b6a2f4659169e0e818bbdee6d36e76
c61c0d34bc73c2c02523fdac4b0bbce5
1,300
PASSED
#include <iostream> #include <unordered_map> using namespace std; int n, m; long long a[30][30]; unordered_map<long long, long long> t, t2; void dfs(int x, int y, int ex, int ey, long long k) { if(x == ex && y == ey) { t[k ^ a[x][y]]++; return; } if(x > ex || y > ey) return; dfs(x...
C++
5642e74bc558ca3187d062ebac6e3a95
7697bec6d3a16032155c7c56037fa71c
2,100
PASSED
#include <bits/stdc++.h> using namespace std; #define all(a) a.begin(), a.end() #define pi acos(-1) #define eps 1e-5 #define inf 1e14 typedef long long ll; typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<vi> vvi; const int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}; const int dy[8...
C++
5642e74bc558ca3187d062ebac6e3a95
4beeba417c5c9a8d016fd54f4ce05ae9
2,100
PASSED
#include <cstdio> #include <cmath> #include <cstring> #include <algorithm> #include <queue> #include <map> #include <set> #include <stack> #include <string> #include <iostream> #include <list> #include <cstdlib> #define lowbit(x) (x&(-x)) const int INF = 0x3f3f3f3f; const long long inf = 0x3f3f3f3f3f3f3f3fLL; using nam...
C++
5642e74bc558ca3187d062ebac6e3a95
ca653912dc176d03ee7d93fd8c59a131
2,100
PASSED
#include <bits/stdc++.h> using namespace std; #define ll long long #define N 22 int n, m; ll k, a[N][N], res; map <ll, ll> mp[N][N]; void DFS1(int x, int y, ll S) { if (x > n || y > m) return; S ^= a[x][y]; if (x + y == (n + m) / 2) { ++mp[x][y][S]; return; } DFS1(x + 1, y, S); DFS1(x, y + 1, S); } void ...
C++
5642e74bc558ca3187d062ebac6e3a95
1bdc53eb370d2b7488c108f55769821c
2,100
PASSED
#include <algorithm> #include <cstdio> #include <unordered_map> #define x first #define y second typedef long long lld; const int MAXN = 22; std::unordered_map<lld,lld> dp[MAXN][MAXN]{ }; lld a[MAXN][MAXN]; lld k, ret=0LL; int m, n; int main() { scanf(" %d%d%lld", &n, &m, &k); int diag = std::min(n, m)+1; dp[1][0][...
C++
5642e74bc558ca3187d062ebac6e3a95
953fba05a9a466e99cfa54d1709bff4a
2,100
PASSED
#include <cstdio> #include <unordered_map> typedef long long lld; const int MAXN = 20; std::unordered_map<lld,int> cnt[MAXN][MAXN]{ }; lld a[MAXN][MAXN]{ }; int half, whole; lld k, ret=0LL; int m, n; void dfs_dr(int i, int j, int step, lld val) { val ^= a[i][j]; if(step == half) { ++cnt[i][j][val]; return; } ...
C++
5642e74bc558ca3187d062ebac6e3a95
453cc270ef01457036e13e4bf7e2fd3d
2,100
PASSED
#include <cstdio> #include <map> typedef long long lld; const int MAXN = 20; std::map<lld,int> cnt[MAXN][MAXN]{ }; lld a[MAXN][MAXN]{ }; int half, whole; lld k, ret=0LL; int m, n; void dfs_dr(int i, int j, int step, lld val) { val ^= a[i][j]; if(step == half) { ++cnt[i][j][val]; return; } if(i < n-1) dfs_dr(i...
C++
5642e74bc558ca3187d062ebac6e3a95
1507df4a0ffecdb5efba6b1f549e1705
2,100
PASSED
#include<bits/stdc++.h> using namespace std; #define maxn 10000052 #define MOD 1000000007 #define mod(x) ((x)%MOD) typedef long long int qq; qq a[30][30],c; int n,m; struct point { int x;int y; }; struct pot { qq val;qq num; }; vector<qq>p[22][22]; vector<pot>ak[22][22]; qq val[maxn],num[maxn]; int vis[22][22]...
C++
5642e74bc558ca3187d062ebac6e3a95
98088cc9faf4f1fef6693354620a3fb5
2,100
PASSED
#include <bits/stdc++.h> // #include <boost/math/common_factor.hpp> // #include <boost/multiprecision/cpp_int.hpp> using namespace std; //using namespace boost::multiprecision; typedef long long ll; typedef unsigned long long ull; typedef double dbl; #define max3(a,b,c) max(a,max(b,c)) #define min3(a,b,c) min(a,min(b,c...
C++
5642e74bc558ca3187d062ebac6e3a95
69e2242993be00c379cb381531213a53
2,100
PASSED
#pragma GCC optimize("O3") #include <bits/stdc++.h> #define ll long long #define ld long double #define endl '\n' #define pll pair<ll,ll> #define ff first #define ss second #define INF 10000000000 #define MOD 998244353 using namespace std; ll n,m,k; ll a[25][25]; ll ans =0; map<tuple<ll,ll,ll>,ll> v; void rec(ll i,ll j...
C++
5642e74bc558ca3187d062ebac6e3a95
38b4cf63f93434e67b502a9b2a554a97
2,100
PASSED
/* Author: Ronak Agarwal, reader part not written by me*/ import java.io.* ; import java.util.* ; import static java.lang.Math.min ; import static java.lang.Math.max ; import static java.lang.Math.abs ; import static java.lang.Math.log ; import static java.lang.Math.pow ; import static java.lang.Math.sqrt ; /* Thread i...
Java
078cdef32cb5e60dc66c66cae3d4a57a
d5e5b75f68fd0245110629b6bb4e91aa
2,000
PASSED
/* Author: Ronak Agarwal, reader part not written by me*/ import java.io.* ; import java.util.* ; import static java.lang.Math.min ; import static java.lang.Math.max ; import static java.lang.Math.abs ; import static java.lang.Math.log ; import static java.lang.Math.pow ; import static java.lang.Math.sqrt ; /* Thread i...
Java
078cdef32cb5e60dc66c66cae3d4a57a
323f66ed603be019cdd5169618bc33d1
2,000
PASSED
import java.io.*; import java.util.Arrays; import java.util.Objects; import java.util.StringTokenizer; public final class ProblemF { public static void main(String[] args) throws IOException { final FastIn in = FastIn.fromSystemIn(); final int n = in.nextInt(); final int m = in.nextInt(); ...
Java
078cdef32cb5e60dc66c66cae3d4a57a
8b0ab02420540b1ae469dcbcf24dec7b
2,000
PASSED
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; import java.util.HashMap; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper p...
Java
078cdef32cb5e60dc66c66cae3d4a57a
7bd5be4887ad746714d07f75493f816e
2,000
PASSED
import java.util.*; import java.io.*; public class MainClass { static int[] div; public static void main(String[] args) throws IOException { Reader in = new Reader(); int n = in.nextInt(); int m = in.nextInt(); div = new int[1000000 + 5]; Arrays.fill(div, 1); ...
Java
078cdef32cb5e60dc66c66cae3d4a57a
f51498ee97a86c3b25c1c83804410d9c
2,000
PASSED
import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Bit...
Java
078cdef32cb5e60dc66c66cae3d4a57a
b11676918bf84360f1ed06c7520e863b
2,000
PASSED
/* * Author: Minho Kim (ISKU) * Date: February 02, 2018 * E-mail: minho.kim093@gmail.com * * https://github.com/ISKU/Algorithm * http://codeforces.com/problemset/problem/920/F */ import java.util.*; import java.io.*; public class F { private static int[] divisor; private static long[] tree; private static ...
Java
078cdef32cb5e60dc66c66cae3d4a57a
5e653a95532abad5d2e784cd2342fdd2
2,000
PASSED
import java.util.*; import java.io.*; public class SUMandREPLACE { /************************ SOLUTION STARTS HERE ************************/ static int tau[]; static final int MAX = (int) 1e6; static { tau = new int[MAX + 1]; for(int i = 1; i <= MAX; i++) ...
Java
078cdef32cb5e60dc66c66cae3d4a57a
8c2be2a17b2d92337ca9df0a66d6d85c
2,000
PASSED
import java.awt.List; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.math.BigDecimal; import java.math.BigInteger; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.BitSet; import java....
Java
078cdef32cb5e60dc66c66cae3d4a57a
1b0907f58c06dbfe39ea6ddaa5c85c28
2,000
PASSED
import java.io.*; import java.lang.reflect.Array; import java.math.*; import java.text.DecimalFormat; import java.util.*; public class Main { private static final int MAX = 1000*1000,MAXP2 = 1 << 19,MAXST = MAXP2 << 1; private static int n,m; private static int [] A; private static int [] sig0; ...
Java
078cdef32cb5e60dc66c66cae3d4a57a
5cc4f6eef186da6d44047244cc8ac18c
2,000
PASSED
from sys import stdin input=stdin.readline for _ in range(int(input())): n,m=map(int,input().split()) if n<=m: print((n*(n-1))//2+1) else: print((m*(m+1))//2)
Python
eb3d8259ca598c3c455ddfdbe433cb78
854e94faac0d6749d0d2f0928eeac83e
1,200
PASSED
t=int(input()) for _ in range(t): n,r=map(int,input().split()) if(n>r): ans=(r*(r+1))//2 print (ans) else: ans=(n*(n-1)//2) print (ans+1)
Python
eb3d8259ca598c3c455ddfdbe433cb78
16fa5df094c0709282ceb998ac7ea99d
1,200
PASSED
for _ in range(int(input())): n,r = map(int, input().split()) if n <= r: print(n*(n-1)//2 + 1) else: print(r*(r + 1)//2)
Python
eb3d8259ca598c3c455ddfdbe433cb78
034e359d955df943f8f40d567709791d
1,200
PASSED
for _ in range(int(input())): n,m = map(int, input().split()) if n > m: print((1+m)*m//2) else: print(n-1 + (n-2)*(n-1)//2 + 1)
Python
eb3d8259ca598c3c455ddfdbe433cb78
112e6f9a1eaddfda01fcd87cdf5cc66e
1,200
PASSED
t = int(input()) for _ in range(t): n, r = map(int, input().split()) k = min(n-1, r) ans = k*(k+1)//2 if r > n-1: ans += 1 print(ans)
Python
eb3d8259ca598c3c455ddfdbe433cb78
f2762fef725c81d1bb3423b5fed55d83
1,200
PASSED
t=int(input()) for i in range(t): n,r=map(int,input().split()) s=0 if r<n: print((r*(r+1))//2) else: print(1+(n*(n-1))//2)
Python
eb3d8259ca598c3c455ddfdbe433cb78
22fc60fad0fb9b300a25c99146978185
1,200
PASSED
def sol(read): a,b = read n = min(a-1,b) s = ((1 +n)*n)//2 print(int(s) + (b >=a)) for i in range(int(input())): read = list(map(int,input().split())) sol(read)
Python
eb3d8259ca598c3c455ddfdbe433cb78
971ecaf985acd535dc067c8802b0227c
1,200
PASSED
def shapes(n, r): # ans = sum(range(1, min(n, r + 1))) ans = (1 + min(n - 1, r)) * min(n - 1, r) // 2 if r >= n: ans += 1 return ans if __name__ == "__main__": t = int(input()) for i in range(t): s = input() n, r = int(s.split()[0]), int(s.split()[1]) print(shape...
Python
eb3d8259ca598c3c455ddfdbe433cb78
5e47726b398e12d65cbd1ab378d6e1c8
1,200
PASSED
t=int(input()) for i in range(t): n,r=list(map(int,input().split())) if n==r: n-=1 print(((n*(n+1))//2)+1) elif n>r: print((r*(r+1))//2) else: n-=1 print(((n*(n+1))//2)+1)
Python
eb3d8259ca598c3c455ddfdbe433cb78
47807e4e7cbb2cb86ecc034f368b5eb4
1,200
PASSED
for _ in range(int(input())): n,r=map(int,input().split()) if r>=n: print(n*(n-1)//2+1) else: print((r*(r+1))//2)
Python
eb3d8259ca598c3c455ddfdbe433cb78
2db9a41b0aacbb7a0dfbf58226586182
1,200
PASSED
input() inp = sorted(list(map(int, input().split())))[::-1] taxi = 0 while len(inp) > 0: #print(inp, taxi) taxi += 1 temp = 4 - inp.pop(0) if temp == 0: continue else: while temp > 0 and len(inp) >= 1: if temp - inp[-1] >= 0: temp -= inp[-1] inp.pop() else: break print(taxi)
Python
371100da1b044ad500ac4e1c09fa8dcb
170a32113fdf4ceba02956c7588b62c1
1,100
PASSED
n = int(input()) s = input().split() g1 = s.count("1") g2 = s.count("2") g3 = s.count("3") car = s.count("4") while g1 >= 1 and g3 >= 1: g1, g3 = g1-1, g3-1 car += 1 if g2 >= 2: #print(g2) car += g2//2 g2 = g2-(g2//2*2) #print(car, g2) car += g3 if g2 >= 1: if g1 >= 2: car, g1, g2...
Python
371100da1b044ad500ac4e1c09fa8dcb
ce6fa935b00e9df34a1496ed88b4804f
1,100
PASSED
input();a,b,c,d=map(input().count,('1','2','3','4')) print(d+c+(b*2+max(0,a-c)+3)//4)
Python
371100da1b044ad500ac4e1c09fa8dcb
8e0383cdbc275c40adead673aed12d8a
1,100
PASSED
n=int(input()) s=input().split(' ') s.sort() one=0 two=0 three=0 four=0 k=0 if len(s)>0 and s[-1]=='4': four+=n-s.index('4') s=s[:s.index('4')] n-=four if len(s)>0 and s[-1]=='3': three+=n-s.index('3') s=s[:s.index('3')] n-=three if len(s)>0 and s[-1]=='2': two+=n-s.index('2') s=s[:s.ind...
Python
371100da1b044ad500ac4e1c09fa8dcb
15b88389df651e5665951cccbf71cfe1
1,100
PASSED
N = int(input()) array = list(map(int, input().split())) result = array.count(4) b = array.count(3) c = array.count(2) d = array.count(1) result += min(b, d) if b > d: result += b - d result += c // 2 + (1 if c % 2 != 0 else 0) else: result += (d - b) // 4 + (1 if (d - b) % 4 != 0 else 0) result += c //...
Python
371100da1b044ad500ac4e1c09fa8dcb
1c5054f7cc7baa0bbd1ef911a5f8ab5a
1,100
PASSED
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define ff first #define ss second #define mp make_pair #define pb push_back typedef long long llong; typedef pair<int, int> pii; typedef vector< vector<int> > vvi; typedef vector< vector< set<int> > > vvs; void dfs(vvi &adj, vector<int> &colors, int p...
C++
2aaa31d52d69ff3703f93177b25671a3
d07f37f10a1a1496a6b966b5de39d8f3
1,600
PASSED
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define ff first #define ss second #define mp make_pair #define pb push_back typedef long long llong; typedef pair<int, int> pii; typedef vector< list<int> > vvi; typedef vector< vector< set<int> > > vvs; void dfs(vvi &adj, vector<int> &colors, int par...
C++
2aaa31d52d69ff3703f93177b25671a3
3f4dd2268a5c4cf3e062c718b86ed1d5
1,600
PASSED
#include <algorithm> #include <iostream> #include <sstream> #include <cstring> #include <cstdlib> #include <string> #include <vector> #include <cstdio> #include <cmath> #include <queue> #include <stack> #include <map> #include <set> using namespace std; #define INF 0x3f3f3f3f const int N=200005; const int mod=1e9+7; i...
C++
2aaa31d52d69ff3703f93177b25671a3
b66346c3da39664c9e416a0c87bc2804
1,600
PASSED
#include <algorithm> #include <iostream> #include <sstream> #include <cstring> #include <cstdlib> #include <string> #include <vector> #include <cstdio> #include <cmath> #include <queue> #include <stack> #include <map> #include <set> using namespace std; #define INF 0x3f3f3f3f const int N=200005; const int mod=1e9+7; i...
C++
2aaa31d52d69ff3703f93177b25671a3
d8ccd773753ad8628b098ade14b5ff30
1,600
PASSED
/* ___ ___ / /\ / /\ / / \ / / \ / / / / / / / / / / / / ___ / / / / / /...
C++
2aaa31d52d69ff3703f93177b25671a3
eb32a9f9bf933eadcce37263adeee623
1,600
PASSED
// // main.cpp // C. Andryusha and Colored Balloons#2 // // Created by Dhruv Mullick on 08/03/17. // Copyright © 2017 Dhruv Mullick. All rights reserved. // #include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define pb push_back #define f first #define s second #def...
C++
2aaa31d52d69ff3703f93177b25671a3
7db121f0b341aa650bfac68ab1ccdad6
1,600
PASSED
// // main.cpp // C. Andryusha and Colored Balloons // // Created by Dhruv Mullick on 07/03/17. // Copyright © 2017 Dhruv Mullick. All rights reserved. // #include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned long long #define pb push_back #define f first #define s second #defin...
C++
2aaa31d52d69ff3703f93177b25671a3
ef7d14912c99351fbc094d19a0f25f03
1,600
PASSED
#include <cstdio> #include <cstring> #include <iostream> #include <queue> #include <algorithm> #include <vector> using namespace std; const int maxn=500000; vector<int>G[maxn]; struct node1{ int color; int p1; int p2; }xin[maxn]; void Init(){ for(int i=0;i<=400000;i++){ xin[i].color=-1; ...
C++
2aaa31d52d69ff3703f93177b25671a3
15a696c86814420984a3e6a6320fe522
1,600
PASSED
#include <iostream> #include <algorithm> #include <cstdio> #include <cmath> #include <string> #include <cstring> #include <vector> //#define LOCAL #define rep(i,a,n) for(int i=(a);i<(n);i++) typedef long long LL; const int INF=0x3f3f3f3f; const int maxn=200000+10; using namespace std; vector<int> tree[maxn]; int n,colo...
C++
2aaa31d52d69ff3703f93177b25671a3
b529f1b4927db8674a997929639434fa
1,600
PASSED
#include<iostream> #include<cstdio> #include<cstring> #include<vector> #include<queue> using namespace std; #define si(n) scanf("%d",&n) #define f first #define s second #define mp(a,b) make_pair(a,b) #define MAX 200005 vector<int>graph[MAX]; int n,ans=0,color[MAX]; void bfs(int s){ queue<pair<pair<int,int>,int>...
C++
2aaa31d52d69ff3703f93177b25671a3
1092ebcc68f458dc9bc631b905ddd1dc
1,600
PASSED
#pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize("Ofast") #pragma GCC optimize("inline") #pragma GCC optimize("-fgcse") #pragma GCC optimize("-fgcse-lm") #pragma GCC optimize("-fipa-sra") #pragma GCC optimize("-ftree-pre") #pragma GCC optimize("-ftree-vrp") #pragma GCC optimize("-fpeephole2") #pragm...
C++
587ac3b470aaacaa024a0c6dde134b7c
9363439c7ee1661a3ace96d11de862aa
1,700
PASSED
#include<bits/stdc++.h> using namespace std; #define Mod 1000000007 const int N=1000100; int ans,a[N],n,f[N]; vector<int>p[N]; int main() { scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d",&a[i]); for(int j=1;j*j<=a[i];j++) { if(a[i]%j!=0)continue; p[i].push_back(j); if(j*j!=a[i...
C++
587ac3b470aaacaa024a0c6dde134b7c
5a716df010acf623f3898bd647cc051d
1,700
PASSED
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> #define ll long long using namespace std; const ll mod=1000000007; ll n,m,b[2000001],a[2000001],f[2000001],ans,top; void broke(ll x){ top=0; ll xx=sqrt(a[x]); for(ll i=1;i<=xx;i++){ if(!(a[x]%i)){ if(i*i==a[x])...
C++
587ac3b470aaacaa024a0c6dde134b7c
3d32eccd40b38e40529d27e87fdb1fc3
1,700
PASSED
#include<bits/stdc++.h> #define ll long long using namespace std; const int sz=2e6+527; const int mod=1e9+7; int n; ll ans; int a[sz]; ll dp[sz]; stack<int>s; int main(){ scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",a+i); dp[0]=1; for(int i=1;i<=n;i++){ int k=sqrt(a[i]); for(int j=1;j<=k;j++) if(a[i]%j==0...
C++
587ac3b470aaacaa024a0c6dde134b7c
f98f99e28dbeb7aadeb2a27f392ab7f8
1,700
PASSED