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; typedef long long ll; typedef array<int,3> triple; #define FOR(i,a,b) for (int i = (a); i < (b); ++i) #define F0R(i,a) FOR(i,0,a) #define FORN(i,a,b) for (int i = (a); i <= (b); ++i) #define F0RN(i,a) FORN(i,0,a) #define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i) #defi...
C++
8f34d2a146ff44ff4ea82fb6481d10e2
57512c854dfb70226c84e5baa96f4f04
2,700
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pi; typedef vector<pi> vpi; typedef array<int,3> ai3; typedef list<ai3> lai3; typedef lai3::iterator lai3it; #define FOR(i,a,b) for (int i = (a); i < (b); ++i) #define F0R(i,a) FOR(i,0,a) #define FORN(i,a,b) for (int i = (a); i ...
C++
8f34d2a146ff44ff4ea82fb6481d10e2
eb6a0325f0cba4cbcbcc8022f3e6d038
2,700
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pi; typedef vector<pi> vpi; typedef array<int,3> ai3; typedef list<ai3> lai3; typedef lai3::iterator lai3it; #define FOR(i,a,b) for (int i = (a); i < (b); ++i) #define F0R(i,a) FOR(i,0,a) #define FORN(i,a,b) for (int i = (a); i ...
C++
8f34d2a146ff44ff4ea82fb6481d10e2
59021f24e175dcbf8d7e72381ab97d49
2,700
PASSED
input() a = [*map(int, input().split())] b = [*map(int, input().split())] for x in range(512): r=1 for v in a:r&=any(v&j|x==x for j in b) if r: print(x);break
Python
3da5075048a127319ffa8913859d2aa7
7077eb6febaec1fc27ba339ad19e5da8
1,600
PASSED
def check(n,m,x): for i in range(n): flag = False for j in range(m): res = a[i]&b[j] if res|x == x: flag = True break if flag is False: return False return True def solve(n,m,a,b): for x in range(0,1<<9): ...
Python
3da5075048a127319ffa8913859d2aa7
138bf6e9355cacb932665aea5dc818a9
1,600
PASSED
n,m = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) min_val = 0 not_found = True while not_found is True: for i in range(n): found = False for j in range(m): if ((a[i] & b[j])|min_val) == min_val: found = True ...
Python
3da5075048a127319ffa8913859d2aa7
fe78788211db9b9bee8d423fce0c00c1
1,600
PASSED
from sys import stdin,stdout from math import gcd,sqrt,factorial from collections import deque,defaultdict input=stdin.readline R=lambda:map(int,input().split()) I=lambda:int(input()) S=lambda:input().rstrip('\n') L=lambda:list(R()) P=lambda x:stdout.write(x) lcm=lambda x,y:(x*y)//gcd(x,y) hg=lambda x,y:((y+x-1)//x)*x ...
Python
3da5075048a127319ffa8913859d2aa7
6c2c4cb14fa9806d1cce69f065198793
1,600
PASSED
n,m=map(int,input().split()) a=list(map(int,input().split())) b=list(map(int,input().split())) for i in range(2000000001): bool1=True for j in a: bool2=False for k in b: if (j&k)|i==i: bool2=True if not bool2: bool1=False break if bool1: print(i) break
Python
3da5075048a127319ffa8913859d2aa7
c33c26243b96e2faaaa7cb8fae99ddf8
1,600
PASSED
from itertools import permutations from functools import reduce def f(l1, l2): ls = {i: [l1[i] & l2[j] for j in range(len(l2))] for i in range(len(l1))} #print(ls) rs = reduce(lambda l1, l2: {x|y for x in l1 for y in l2}, ls.values()) return min(rs) if __name__ == '__main__': n = [int(i) f...
Python
3da5075048a127319ffa8913859d2aa7
c76ffb1caedbe128de743f2d7ea113d9
1,600
PASSED
import sys, heapq as h input = sys.stdin.readline def getInts(): return [int(s) for s in input().split()] def getInt(): return int(input()) def getStrs(): return [s for s in input().split()] def getStr(): return input().strip() def listStr(): return list(input().strip()) import collections as ...
Python
3da5075048a127319ffa8913859d2aa7
dd25182554bb99fbc2f5649752330e55
1,600
PASSED
a = input().split(" ") d = input().split(" ") e = input().split(" ") ans = 10000000000 p = 0 list1 = [] for i in d: for j in e: list1.append(int(i)&int(j)) list1 = list(set(list1)) list1.sort() for l in list1: dict = {l:0} p = l for i in range(len(d)): tag1 = 1000000000 q = 0 ...
Python
3da5075048a127319ffa8913859d2aa7
51904224da111b41c2ca0694f28296e2
1,600
PASSED
import sys input = sys.stdin.buffer.readline I = lambda : list(map(int,input().split())) n,m=I() a=I() b=I() p=[a[0]&b[j] for j in range(m)] for kk in range(513): an=kk;ct=0 for i in range(n): po=0 for j in range(m): if (a[i]&b[j])|kk==kk: po=1;break if po: ct+=1 else: break if ct==n: print(k...
Python
3da5075048a127319ffa8913859d2aa7
3226f935863421ebd64865a20aa4e3bd
1,600
PASSED
# @author --> ajaymodi # Naive approach import sys # sys.stdin=open("input.in","r") # sys.stdout=open("output.out","w") input=lambda : sys.stdin.readline().strip() char = [chr(i) for i in range(97,123)] CHAR = [chr(i) for i in range(65,91)] mp = lambda:list(map(int,input().split())) INT = lambda:int(input()) rn = lamb...
Python
3da5075048a127319ffa8913859d2aa7
343fd323440f8c14484ed189202b537d
1,600
PASSED
#include <bits/stdc++.h> #define int long long using namespace std; const int N = 1e6 + 7; int a[N]; bool killed[N]; signed main() { int n; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; int l = n, r = n; int ans = 0; while (l > 1 && l <= r) { while (l > 1 && l >= r - a[r] + 1) { ans++; ...
C++
beaeeb8757232b141d510547d73ade04
51f1b5a9b72f85ac869e4afda155bef0
1,200
PASSED
#include <bits/stdc++.h> #define int long long using namespace std; const int N = 1e6 + 7; int a[N]; signed main() { ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; int l = n, r = n; int ans = 0; while (l > 1 && l <= r) { while (l...
C++
beaeeb8757232b141d510547d73ade04
8235318491ab6ad088e3d727b8bdd037
1,200
PASSED
#include <iostream> #include <vector> #include <map> #include <string> #include <climits> #include <functional> #include <numeric> #include <iomanip> #include <set> #include <algorithm> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pii; #define FOR(i, a, b) for (int i=a;...
C++
beaeeb8757232b141d510547d73ade04
9e47f74ee5ead23401369e1cc36ef9ca
1,200
PASSED
#include <bits/stdc++.h> using namespace std; int main () { int n, pointer1, pointer2, alives = 0; cin >> n; vector<int> claw_lengths(n + 2, 0); for (int i = 1; i < n + 1; i++) cin >> claw_lengths[i]; pointer2 = n + 1; pointer1 = n; while (pointer1 != 0 && pointer2 >= 1) { if (pointer1 < pointer2) ...
C++
beaeeb8757232b141d510547d73ade04
5954fc5d47de153268f2279ca635a73b
1,200
PASSED
#include <bits/stdc++.h> #define fi first #define se second #define M_P make_pair #define P_B push_back #define y1 CNik #define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define j1 jj using namespace std; typedef long long ll; const int MAXINT=2147483647; const ll MAXLONGINT=9223372036854775807; co...
C++
beaeeb8757232b141d510547d73ade04
ea13a617a9e1a8eaf541b9aa28b3aeb0
1,200
PASSED
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); vector <int> v; int n, xarr, cnt = 1, res; cin >> n; for (int i = 0; i < n; i++) { cin >> xarr; ...
C++
beaeeb8757232b141d510547d73ade04
91d9d7fdfc8822783cdb90e5975ffad8
1,200
PASSED
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { vector <int> v; int n, xarr, cnt = 1, res; cin >> n; for (int i = 0; i < n; i++) { cin >> xarr; v.push_back(xarr); } reverse(v.begin(), v.end()); res = v[0]; for (int i = 1; i < n; i++) { if (res > 0...
C++
beaeeb8757232b141d510547d73ade04
7730127b1a3686ed071f35ece2f97dd6
1,200
PASSED
#include <bits/stdc++.h> using namespace std; int n; long long int v[1000001], b, c; int main(){ cin >> n; for(int x=n-1; x>=0; x--) scanf("%d",&v[x]); b=v[0]; for(int x=1; x<n; x++){ if(b>0){ c++; } b=max(b-1, v[x]); } cout << n-c; }
C++
beaeeb8757232b141d510547d73ade04
bb7193ef4c8cdecdb7b834e2bc36a865
1,200
PASSED
#include<iostream> #include<algorithm> using namespace std; const int maxn=1e6+5; int a[maxn]; int main() { int n; while(cin>>n) { for(int i=0;i<n;i++) cin>>a[i]; int ans=0; int k=0; for(int i=n-1;i>=0;i--) { if(k==0) ans++; ...
C++
beaeeb8757232b141d510547d73ade04
9ca2e135ac42bfcf70e8333dc6e7211c
1,200
PASSED
#include<iostream> #include<cstring> #include<algorithm> #include<cstdio> #include<cstdlib> using namespace std; const int INF=0x3f3f3f3f; int main() { int n; long long ans,l[1000010],t; while(scanf("%d",&n)!=EOF) { for(int i=0;i<n;i++) scanf("%lld",&l[i]); if(l[n-1]>=n-1) ...
C++
beaeeb8757232b141d510547d73ade04
008ea461de58ad2b29ca0d9f296e43dc
1,200
PASSED
#include <iostream> #include <string> using namespace std; int main(){ long long n; cin>>n; long long sum=100000; long long ite=0; for(long long i=1;i<=n/2;i++){ long long aux=0; if(n%i>0)aux=1; if(i+(n/i+aux)<sum){ ite=i; sum=i+(n/i+aux); } } if(n==1)ite=1; string s,sl; //cout<<ite<<endl; for...
C++
6ea899e915cfc95a43f0e16d6d08cc1e
9aa8ce48f0787fc21aa7b2a2e5bcb13c
1,600
PASSED
#pragma clang diagnostic push #pragma ide diagnostic ignored "cert-err34-c" #include <bits/stdc++.h> #define FIO freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #define F first #define S second #define gcd __gcd #define fast ios_base::sync_with_stdio(false); cin.tie(nullptr), cout.tie(nullptr) ...
C++
6ea899e915cfc95a43f0e16d6d08cc1e
d04a52f777d9221815c0fa44dc8116f4
1,600
PASSED
#include<bits/stdc++.h> #define ll long long using namespace std; const int maxn=1000010; int a[maxn]; int main() { int N,tN,i,j,pos=0; scanf("%d",&N); tN=sqrt(N); int p=N; for(i=1;i<=N;i+=tN){ for(j=min(i+tN-1,N);j>=i;j--) a[j]=p--; } for(i=1;i<=N;i++) printf("%d ",a[i]); return 0; }
C++
6ea899e915cfc95a43f0e16d6d08cc1e
17dff4b84463b8d85fd4277c1c10d14a
1,600
PASSED
#include<bits/stdc++.h> using namespace std; const int maxn=1000010; int a[maxn]; int main() { int N,tN,i,j; scanf("%d",&N); tN=sqrt(N); int p=N; for(i=1;i<=N;i+=tN){ for(j=min(N,i+tN-1);j>=i;j--) a[j]=p--; } for(i=1;i<=N;i++) printf("%d ",a[i]); return 0; }
C++
6ea899e915cfc95a43f0e16d6d08cc1e
dec98629df3bd612b319bb8a7f598025
1,600
PASSED
#include <bits/stdc++.h>` #define slld(longvalue) scanf("%lld", &longvalue) #define plld(longvalue) printf("%lld\n", longvalue) #define slf(longvalue) scanf("%lf", &longvalue) #define plf(longvalue) printf("%lf\n", longvalue) #define sc(letter) scanf("%c", &letter) #define pc(letter) printf("%c", letter) #define ss(...
C++
6ea899e915cfc95a43f0e16d6d08cc1e
7b648c658345975b4899734b4064efe7
1,600
PASSED
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <cmath> using namespace std; const int maxn=100000+100; int a[maxn]; int n; int main(){ scanf("%d",&n); int m=sqrt(n); // printf("%d\n",m); for(int i=1;i<=n%m;i++) printf("%d ",n%m-i+1); // printf("\n"); ...
C++
6ea899e915cfc95a43f0e16d6d08cc1e
627609810ae0d4f0e6d92c6c4dac5a09
1,600
PASSED
#include<bits/stdc++.h> using namespace std; int main() { int n; ios::sync_with_stdio(0),cin.tie(0); while(cin>>n){ int l[100001],r[100001]; int block=(int)sqrt(n); int num=n/block; if(n%block) num++; for(int i=1;i<=num;i++) l[i]=(i-1)*block+1,r[i]=i*block...
C++
6ea899e915cfc95a43f0e16d6d08cc1e
d0662d8535dfafb4659dce0c984c072f
1,600
PASSED
#include<bits/stdc++.h> #define pb push_back #define mp make_pair #define fi first #define se second #define MOD 1000000007 #define pi 3.1415926535 #define ms(s, n) memset(s, n, sizeof(s)) #define prec(n) fixed<<setprecision(n) #define eps 0.000001 #define all(v) v.begin(), v.end() #define bolt ios::sync_with_stdio(0) ...
C++
6ea899e915cfc95a43f0e16d6d08cc1e
ce28979589edc3062e284ecb1be1d7e9
1,600
PASSED
#include <iostream> #include <math.h> using namespace std; int main(int argc, char const *argv[]) { int sizu; cin>>sizu; int it=sqrt(sizu); int i=sizu; i-=it-1; int gen_count=0; while(i>0){ for(int j=0; j<it; ++j){ cout<<i<<" "; if(j!=it-1){ ++i; } gen_count++; } ...
C++
6ea899e915cfc95a43f0e16d6d08cc1e
882ec244ba4c1fd6640da3ecc2526d8a
1,600
PASSED
#include <bits/stdc++.h> using namespace std; int n, a[100001]; int lis, lds, ans = 1000000 + 1; void writeAns(int val, int pos) { if (val > n) return; //cout << "* " << val << " " << pos << endl; a[pos] = val; if (val % lis) writeAns(val + 1, pos + 1); else writeAns(val + 1, max(pos - lis * 2 +...
C++
6ea899e915cfc95a43f0e16d6d08cc1e
d34fed6acac2d1ab35b648cd5cc16236
1,600
PASSED
#include<bits/stdc++.h> using namespace std; int main() { unsigned long long int n,m,i,j,k,count=0; cin>>n; unsigned long long int a[n]; for(i=0; i<n; i++) { cin>>a[i]; count+=a[i]; } k = sizeof(a)/sizeof(a[0]); sort(a,a+k); /*for(i=0; i<n; i++) count+=...
C++
c1608f6f71cac56690e31aa130c1990e
e12c16298ddd81b9d0d6753f7586f58a
900
PASSED
#include <bits/stdc++.h> #include<string> using namespace std; int main() { int n; cin>>n; long long int a[n+1]; for(int i=1;i<=n;i++) cin>>a[i]; sort(a+1,a+n+1); for(int i=2;i<=n;i++) a[i]+=a[i-1]; int m; #define int long long a[0]=0; cin>>m; int b[m]; fo...
C++
c1608f6f71cac56690e31aa130c1990e
c833d7b89830da94d375a51aea9aee1b
900
PASSED
#include<iostream> #include<algorithm> using namespace std; long long n,m,a[300005],ans[300005],s[300005],sum; bool cmp(int x,int y){return x>y;} int main(){ cin>>n; for(int i=1;i<=n;i++) { cin>>a[i]; sum+=a[i]; } sort(a+1,a+n+1,cmp); cin>>m; for(int i=1;i<=m;i++){ int b; cin>>b; cout<<sum-a[b]<<endl; }...
C++
c1608f6f71cac56690e31aa130c1990e
8e5061118d8da9daea190ae205b36313
900
PASSED
/* +---------------------+ | BRYAN MAURICIO 2006 | +---------------------+ */ #include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define ar array #define ios ios_base::sync_...
C++
c1608f6f71cac56690e31aa130c1990e
9f3179facf027725b01f7d7cbb6ce55d
900
PASSED
#include<iostream> #include<bits/stdc++.h> using namespace std; int main() { long long int n,i,x,su=0,q; cin >> n; vector<int> arr; for(i=0;i<n;i++) { cin >> x; arr.push_back(x); su=su+x; } sort(arr.rbegin(),arr.rend()); cin >> q; for(i=0;i<q;i++) { ...
C++
c1608f6f71cac56690e31aa130c1990e
04dadf05d6d6158651a01d7bf72f88b8
900
PASSED
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { int n, m, q; cin >> n; vector <ll> a(n); ll sum = 0; for(int i=0; i<n;i++) { cin >> a[i]; sum += a[i]; } sort(a.rbegin(), a.rend()); cin >> m; for(int i=0; i<m;i++) { cin >> q; ...
C++
c1608f6f71cac56690e31aa130c1990e
c0cb3f96c41ee11bf394a6f7fac5dbd2
900
PASSED
#include<bits/stdc++.h> using namespace std; #define mem(a,b) memset(a, b, sizeof(a) ) #define gcd(a,b) __gcd(a,b) #define sqr(a) ((a) * (a)) #define faster() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define fraction(a) cout.unsetf(ios::floatfield); cout.precision(a); cout.setf(ios::fixed,ios::floatfield)...
C++
c1608f6f71cac56690e31aa130c1990e
d72be395663d1fb95c9a9c11e62535ab
900
PASSED
#include<bits/stdc++.h> using namespace std; #define ll long long int int main() { //faster(); int n; cin>>n; int a[n] = {0}; ll sum=0; for(int i=0;i<n;i++){ cin>>a[i]; sum += a[i]; } sort(a,a+n); int m; cin>>m; int q[m]={0}; // mem(r,-1); for(int...
C++
c1608f6f71cac56690e31aa130c1990e
3301f6ae97c10a58db1994c9357f5251
900
PASSED
#pragma GCC optimize("O3") #include <iostream> #include <set> #include <vector> #include <algorithm> #include <numeric> #include <queue> #define all(x) (x).begin(), (x).end() #define ll long long int using namespace std; template<typename T> inline void readIntegerValue(T& f) { bool positive = true; f = 0; ch...
C++
c1608f6f71cac56690e31aa130c1990e
6d2528f4635420f450ab8c4b793b0246
900
PASSED
#pragma GCC optimize("O3") #include <iostream> #include <set> #include <vector> #include <algorithm> #include <numeric> #include <queue> #define all(x) (x).begin(), (x).end() #define ll long long int using namespace std; template<typename T> void readArray(int n, vector<T> &res) { res.resize(n); for(auto &i: res) ci...
C++
c1608f6f71cac56690e31aa130c1990e
06a5f4faee36c0932ea6ba6b2a3d9abc
900
PASSED
#include <bits/stdc++.h> #define ll long long using namespace std; const int N = 2e5; ll n, k, a[N], sum[N], mx, ans; int main(){ scanf("%I64d%I64d", &n, &k); for(int i = 1; i <= n; i++) scanf("%I64d", &a[i]); sort(a + 1, a + n + 1); for(int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[...
C++
3791d1a504b39eb2e72472bcfd9a7e22
ab8ae601e3a6b5ae5c07d8e93540933d
1,600
PASSED
#include<bits/stdc++.h> using namespace std; #define ll long long const int N = 1e5+100; int a[N]; ll s[N]; int n;ll k; int solve(int p){ int l = 0,r = p; while(l<r){ int m = (l+r+1)>>1; if((ll)m*a[p] - (s[p]-s[p-m]) <= k)l = m; else r = m-1; } return l+1; } int main(){ cin>...
C++
3791d1a504b39eb2e72472bcfd9a7e22
9197e0a45a243b627fb2ff0779b099fa
1,600
PASSED
/** ▂▃▅▇█▓▒░۩۞۩ ۩۞۩░▒▓█▇▅▃▂ Make it happen now, not tomorrow. Tomorrow is a loser's excuse. ▂▃▅▇█▓▒░۩۞۩ ۩۞۩░▒▓█▇▅▃▂ **/ #ifndef _GLIbCXX_NO_ASSERT #include <cassert> #endif #include <cctype> #include <cerrno> #include <cfloat> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <csetj...
C++
3791d1a504b39eb2e72472bcfd9a7e22
9729612c3e7a6a1d585cbd1fa0c02d38
1,600
PASSED
#include<bits/stdc++.h> using namespace std; const int mxN = 1e5+10; vector<long long int> a, pref; int n, k; int binarySearch(int low, int high){ int pivot = high; int answer = -1; while(high >= low){ int mid = (high + low)/2; long long int required = (pivot - mid + 1LL)*a[pivot] - (pref[pi...
C++
3791d1a504b39eb2e72472bcfd9a7e22
208702d09f337671bc2796491dfd9148
1,600
PASSED
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ios::sync_with_stdio(0); cin.tie(0); ll n,k; cin>>n>>k; ll arr[n]; for(int i = 0; i < n; i++) cin>>arr[i]; sort(arr,arr+n); //for(auto cc : arr) cout<<cc<<" "; cout<<"\n"; ll pre[n+1]; pre[0] = 0; for(int i = 1; i <= n; i++) pre[i] ...
C++
3791d1a504b39eb2e72472bcfd9a7e22
69a337ac03b02ea2cd5dec03d251357c
1,600
PASSED
#include <bits/stdc++.h> using namespace std; #define clr(i, j) memset(i, j, sizeof(i)) #define pb push_back #define mp make_pair typedef long long ll; ll tot, n, k, a[200001], cnt[200001], ans, idx; int main() { cin >> n >> k; for(int i=0; i<n; i++) cin >> a[i]; sort(...
C++
3791d1a504b39eb2e72472bcfd9a7e22
52e447dc9a1770d78bf9bbcd5a4e4f7a
1,600
PASSED
/*Allah Vorosha*/ #include<bits/stdc++.h> #define ll long long #define ld long double #define ull unsigned long long #define pb push_back #define n_p next_permutation #define p_p prev_permutation #define in insert #define rev reverse #define pf push_front #define pob pop_back #define uniq(v) v.resize(distance(v...
C++
3791d1a504b39eb2e72472bcfd9a7e22
b76e9f31d4cc85b771ba5a63386857a5
1,600
PASSED
/*Allah Vorosha*/ #include<bits/stdc++.h> #define ll long long #define ld long double #define ull unsigned long long #define pb push_back #define n_p next_permutation #define p_p prev_permutation #define in insert #define rev reverse #define pf push_front #define pob pop_back #define uniq(v) v.resize(distance(v...
C++
3791d1a504b39eb2e72472bcfd9a7e22
43d32adc2e3a464af3142b16cfb9d05e
1,600
PASSED
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define here(x) cout << #x << " = " << x << endl; #define show(x) {for( auto i : x) cout << i << '\t'; cout << endl;} #define shop(n, x) {for(int i = 0; i < n...
C++
3791d1a504b39eb2e72472bcfd9a7e22
03cc3f21140424a93523d44e987d4840
1,600
PASSED
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define here(x) cout << #x << " = " << x << endl; #define show(x) {for( auto i : x) cout << i << '\t'; cout << endl;} #define shop(n, x) {for(int i = 0; i < n...
C++
3791d1a504b39eb2e72472bcfd9a7e22
5daf29cdde5e6d70d44a958000bc46af
1,600
PASSED
#include <iostream> #include <fstream> #include <cmath> #include <algorithm> #include <limits> #include <sstream> #include <vector> #include <map> #include<set> #include <string> #include<cstdlib> #include <queue> using namespace std; #define int long long #define fi(i, a, b) for(int i = (a); (i) < (b); (i)++) cons...
C++
ab2db2c83d0c9de72f40c9a4c813a37f
06fddea93e751787b4ea383d34d4cdf0
2,400
PASSED
using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using System.Text; using System.Threading; // (づ°ω°)づミ★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜ public class Solver { class SegmentTree<T> { private readonly int size; private readonly T[] data; ...
C#
ab2db2c83d0c9de72f40c9a4c813a37f
a24305bedd166585d9596bcaff2d34cb
2,400
PASSED
import java.io.*; import java.util.*; /** * @author master_j * @version 0.4.1 * @since Mar 22, 2015 */ public class Solution { private void solve() throws IOException { int w = io.nI(), h = io.nI(), rooksNum = io.nI(), rectsNum = io.nI(); Rook[] rooks = new Rook[rooksNum]; for (int i = 0; ...
Java
ab2db2c83d0c9de72f40c9a4c813a37f
23bf12cc6cafc5361a989abae001c90e
2,400
PASSED
import java.io.*; import java.util.*; /** * @author master_j * @version 0.4.1 * @since Mar 22, 2015 */ public class Solution { private void solve() throws IOException { int w = io.nI(), h = io.nI(), rooksNum = io.nI(), rectsNum = io.nI(); Rook[] rooks = new Rook[rooksNum]; for (int i = 0; ...
Java
ab2db2c83d0c9de72f40c9a4c813a37f
55f1271d613bf0903c60a39faa533fb3
2,400
PASSED
import java.awt.Point; import java.io.BufferedReader; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintStream; import java.io.PrintWriter; import static java.lang.Integer.max; import static java.lan...
Java
ab2db2c83d0c9de72f40c9a4c813a37f
763b841a1a5369f1c6935c2f47f8f61d
2,400
PASSED
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.Comparator; import java.util.StringTokenizer; public class Main { static BufferedReader reader; static StringTokenizer tokenizer; static PrintWriter writ...
Java
ab2db2c83d0c9de72f40c9a4c813a37f
387ab747cdc28e6d8f892300a9b47ceb
2,400
PASSED
import java.io.*; import java.util.*; public class A { FastScanner in; PrintWriter out; int n, m, k, q; class Point { int x, y; public Point(int x, int y) { super(); this.x = x; this.y = y; } } class Query { Point p0, p1; int num; public Query(Point p0, Point p1) { super(); this...
Java
ab2db2c83d0c9de72f40c9a4c813a37f
2a872e715c6fe87fa2b5e1533ec46f2c
2,400
PASSED
import java.io.*; import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.StringTokenizer; public class B { boolean[] vert(int n, int m, int k, int q, Point[] p) { boolean[] ans = new boolean[q]; Arrays.sort(p); ST tree = new ST(100100); for (Point...
Java
ab2db2c83d0c9de72f40c9a4c813a37f
ee43b9985945b6522c6a7b4600220631
2,400
PASSED
import java.util.Arrays; import java.util.ArrayList; import java.io.InputStream; import java.io.InputStreamReader; import java.util.List; import java.io.BufferedReader; import java.math.BigInteger; import java.io.OutputStream; import java.io.PrintWriter; import java.io.IOException; import java.util.StringTokenizer; /*...
Java
ab2db2c83d0c9de72f40c9a4c813a37f
b9bc104a39807c4984f9a0159739663f
2,400
PASSED
import java.io.*; import java.util.*; public class E { FastScanner in; PrintWriter out; void solve() { int n = in.nextInt(), m = in.nextInt(), k = in.nextInt(), q = in .nextInt(); int[] x = new int[k], y = new int[k]; for (int i = 0; i < k; i++) { x[i] = in.nextInt() - 1; y[i] = in.nextInt() - 1; ...
Java
ab2db2c83d0c9de72f40c9a4c813a37f
2b45d67388d4f78915f9f9cbea3fd01a
2,400
PASSED
#include <bits/stdc++.h> using namespace std; int n, m, num = 0, fst[1000010], ideg[1000010], odeg[1000010], sinkid[1000010]; struct edge { int x, y, n; } e[1000010]; bool v[1000010]; vector<int> source; void ins(int x, int y) { e[++num] = {x, y, fst[x]}; fst[x] = num; } void dfs(int x, int &s) { if (...
C++
3a25e051fd89107531e2e61797a32027
cd4c53a69abae8f83e8fba198cd31c92
2,700
PASSED
#include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #incl...
C++
3a25e051fd89107531e2e61797a32027
d188564424fb17047950107237609104
2,700
PASSED
#include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #incl...
C++
3a25e051fd89107531e2e61797a32027
3de819ed78a144111dbcf1e25decda1f
2,700
PASSED
#include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #incl...
C++
3a25e051fd89107531e2e61797a32027
aa622ced6519183c159c929103fc4d02
2,700
PASSED
//#pragma GCC optimize("O3") //#pragma GCC target("arch=corei7-avx") #include <bits/stdc++.h> #ifndef ONLINE_JUDGE # include <sys/time.h> # include <sys/resource.h> #endif /*** TEMPLATE CODE STARTS HERE ***/ #ifndef M_PI #define M_PI 3.1415926535897932384626433832795028841971693993751 #endif using namespace std; ty...
C++
3a25e051fd89107531e2e61797a32027
a88d1ae3a123cb2e73e3c6999a902cf5
2,700
PASSED
#include <bits/stdc++.h> using namespace std; int N, M; const int MAX = 1e6; vector<int> edges[MAX]; int indeg[MAX]; vector<int> source; map<int, int> sink; int reachable[20]; const int BITMAX = 1<<20; int dp[BITMAX]; void dfs(int start, int i){ if(sink.count(i)){ reachable[start] |= sink[i]; }else{ ...
C++
3a25e051fd89107531e2e61797a32027
3a0620cd3d9affd4aa1638ba509139f0
2,700
PASSED
#define __USE_MINGW_ANSI_STDIO 0 #include <iostream> #include <iomanip> #include <stdio.h> #include <stdlib.h> #include <vector> #include <algorithm> #include <queue> #include <map> #include <unordered_map> #include <set> #include <unordered_set> #include <stack> #include <deque> #include <string.h> #include <sstream> ...
C++
3a25e051fd89107531e2e61797a32027
3dc080c3549e64437baf9ddf99caa26a
2,700
PASSED
#include<bits/stdc++.h> #define fo(i,a,b) for(int i=a;i<=b;i++) #define fd(i,a,b) for(int i=a;i>=b;i--) using namespace std; typedef long long LL; typedef double db; int get(){ char ch; while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-'); if (ch=='-'){ int s=0; while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0'...
C++
3a25e051fd89107531e2e61797a32027
ee7651320571ccefd990204187bc61eb
2,700
PASSED
//#pragma optimization_level 3 //#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3") //#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> #include <ext/pb_ds/detail/...
C++
3a25e051fd89107531e2e61797a32027
32c236b453c4a62fd6a7e2ba48282715
2,700
PASSED
#include <bits/stdc++.h> using namespace std; #define MP make_pair #define FF first #define SS second typedef long long ll; typedef long double ld; typedef pair<int, int> pie; const int MOD = 1e9 + 7; const int INF = 2e9; const ll LINF = 4e18; const ll delta = 96181; const int N = 1e6 + 20; vector<int> G[N], sinks, s...
C++
3a25e051fd89107531e2e61797a32027
a087c27a27197c96ef1d568b9162e37c
2,700
PASSED
#include <bits/stdc++.h> using namespace std; #define fo(i,s,t) for(int i = s; i <= t; ++ i) #define fd(i,s,t) for(int i = s; i >= t; -- i) const int maxn = 1000500; const int maxm = 1005; int n, k, a[maxn], dp[maxm*2]; bool ok[maxm]; queue<int> q; int main() { scanf("%d%d",&n,&k); fo(i,1,k) scanf("%d",&a[i]); me...
C++
1aab45f5eed49b8ebdef822497099b59
6f19665ddfe807b26aed486757092369
2,300
PASSED
#include<bits/stdc++.h> using namespace std; const int maxn=1e6+10; int k,n,top; int a[maxn]; int f1[maxn],f2[maxn]; bool judge[maxn]; int main(){ scanf("%d%d",&k,&n); for (int i=1,x;i<=n;++i){ scanf("%d",&x); if (judge[x]) continue; judge[x]=1; a[++top]=x-k; if (x==k){ ...
C++
1aab45f5eed49b8ebdef822497099b59
0b5cf68c015389a7f49b994273194a27
2,300
PASSED
#include <bits/stdc++.h> using namespace std; const int MAXN = 1000; const int MAXK = ( int ) 1e6; const int MAXA = 1000; int N, K; int A[ MAXK ]; bitset< 1000 + 1 > dp[ 2 ]; signed main(){ ios::sync_with_stdio( 0 ); { cin >> N >> K; for( int i = 0; i < K; ++i ){ cin >> A[ i ]; } sort( A, A...
C++
1aab45f5eed49b8ebdef822497099b59
7c0de10a9903fd3d924f33af4ac073f1
2,300
PASSED
#include <iostream> #include <cstring> #include <string> #include <vector> #include <map> #include <set> #include <unordered_map> #include <unordered_set> #include <algorithm> #include <queue> #include <cmath> #include <stdio.h> #define X first #define Y second #define _ << " " << #define debug(x) #x << " = " << x #d...
C++
1aab45f5eed49b8ebdef822497099b59
71b4cc2528b99010f0c41458435ad07d
2,300
PASSED
#include <iostream> #include <cstring> #include <string> #include <vector> #include <map> #include <set> #include <unordered_map> #include <unordered_set> #include <algorithm> #include <queue> #include <cmath> #include <stdio.h> #define X first #define Y second #define _ << " " << #define debug(x) #x << " = " << x #d...
C++
1aab45f5eed49b8ebdef822497099b59
8152ff59669d453ea55248a819dde818
2,300
PASSED
#include <iostream> #include <cstring> #include <string> #include <vector> #include <map> #include <set> #include <unordered_map> #include <unordered_set> #include <algorithm> #include <queue> #include <cmath> #include <stdio.h> #define X first #define Y second #define _ << " " << #define debug(x) #x << " = " << x #d...
C++
1aab45f5eed49b8ebdef822497099b59
9fc774d7adcf1645156cab05dd1b6e3a
2,300
PASSED
#include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PLL pair<LL, LL> #define PLI pair<LL, int> #define PII pair<int, int> #define SZ(x) ((int)x.size()) #define ull unsigned long long using namespace std; const int N = 1000 + 7; const int inf = 0x3f3f3f3f; const...
C++
1aab45f5eed49b8ebdef822497099b59
fd1b39ff0c049b6e57177df1b279aaac
2,300
PASSED
#include <bits/stdc++.h> using namespace std; int a[1010]; unordered_map<int,bool> vis; queue<pair<int,int>> Q; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n,k; cin >> n >> k; int l = 0; for (int i=0;i<k;i++) { int x; cin >> x; if (!vis[x-n]) { a[l] = x-n; vis[a[l]] = true; Q....
C++
1aab45f5eed49b8ebdef822497099b59
1667ccf4ea953c023192a7533c1a3943
2,300
PASSED
#include<bits/stdc++.h> #define maxi 300005 #define f first #define s second #define mp make_pair #define pb push_back #define ll long long #define si(n) scanf("%d",&n) #define sll(n) scanf("%lld",&n) #define TRACE #ifdef TRACE #define trace1(x) cerr << #x << ": " << x << endl; #define trace2(x, y) ...
C++
1aab45f5eed49b8ebdef822497099b59
67b706ad317bac28d1f85650cf44f116
2,300
PASSED
#include<bits/stdc++.h> using namespace std; #define FOR(i,j,k) for(int i=j;i<=k;i++) #define MAX 100010 int n, k, ar[MAX], p; set<int> sota; map<int,int> mopa; queue<int> que; void bfs() { while(!que.empty()) { int pv = que.front(); que.pop(); FOR(i,0,p-1) { i...
C++
1aab45f5eed49b8ebdef822497099b59
fc9fcafcd6e39e96019ad5ddfe585aad
2,300
PASSED
#include <stdio.h> int main() {int T,m; scanf("%d",&T); for(m=0;m<T;m++){ int N,k,i,j,l,min,max,price; scanf("%d%d",&N,&k); int A[N]; for(i=0;i<N;i++) { scanf("%d",&A[i]); } min=A[0]; for(j=1;j<N;j++) { if(A[j]<min) { min=A[j]; ...
C
3b158306d335459ff55dcf29e46010e8
b2e62aacb6734f613c16b19bedd48295
900
PASSED
#include<stdio.h> int main() { int t,n,k,i,max=0,a,min=100000001; scanf("%d",&t); while(t!=0) {max=0;min=100000001; scanf("%d%d",&n,&k); for(i=0; i<n; i++) { scanf("%d",&a); if(a>max) max=a; if(a<min) min=a; } if(min+k>=max-k) printf("%d\n",min+k); else printf("-1\n"); t--;} }
C
3b158306d335459ff55dcf29e46010e8
9e3c956b715973de8d610918ebc1fe26
900
PASSED
#include<stdio.h> int main() { int t, m; scanf("%d",&t); m=t-1; int arr[t]; while(t--) { int n,k,min=1e8,max=0; scanf("%d%d",&n,&k); int ar; for(int i=0;i<n;i++) { scanf("%d",&ar); if(ar>max) max=ar; if(ar<min) min=ar; } if(max-min>(2*k)) arr[...
C
3b158306d335459ff55dcf29e46010e8
62d7eb68a2860e2199398630a8c45aae
900
PASSED
#include <stdio.h> int q, n, k, a[102]; int main(){ scanf("%d", &q); while (q != 0){ int i; scanf("%d%d", &n, &k); for (i = 0; i < n; i++) scanf("%d", &a[i]); int min = a[0] + k, max = a[0] - k; for (i = 1; i < n; i ++){ if (a[i] + k < min) min = a[i] + k; ...
C
3b158306d335459ff55dcf29e46010e8
462218ab43b3b24d7c92b9e148785f19
900
PASSED
#include<stdio.h> #include<math.h> int main() { long long int T,N,K,i,j,l,k,f,min; scanf("%lld",&T); for(i=0;i<T;i++) { f=0; min=0; scanf("%lld %lld",&N,&K); long long int ar[N]; scanf("%lld",&ar[0]); min=ar[0]; // printf("min=%lld",min); for(j=1;j<N;j++) { scanf("%lld",&ar[j]); if(min>ar[j])...
C
3b158306d335459ff55dcf29e46010e8
31993798aee6393d9e0edfabc03d7b3e
900
PASSED
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> typedef long long ll; #define rep(i,n) for(int i=0;i<(int)(n);i++) #define max(l,r) ((l)>(r)?l:r) #define min(l,r) ((l)<(r)?l:r) #define swap(l,r) {ll tp=l;l=r;r=tp;} const ll MOD = 1000000007; const int INF = (1<<30); // > 10^9 const ll LI...
C
3b158306d335459ff55dcf29e46010e8
2c58e91a2f3bda6e5cc4669490ade2e7
900
PASSED
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> typedef long long ll; #define rep(i,n) for(int i=0;i<(int)(n);i++) #define max(l,r) ((l)>(r)?l:r) #define min(l,r) ((l)<(r)?l:r) #define swap(l,r) {ll tp=l;l=r;r=tp;} const ll MOD = 1000000007; const int INF = (1<<30); // > 10^9 const ll LI...
C
3b158306d335459ff55dcf29e46010e8
4b3a9f48c13acf1124bb5838de422762
900
PASSED
#include <stdio.h> void solve(){ int n, k; scanf("%d%d", &n, &k); int mx = 0, mn = 1e8 + 1; for(int i = 0; i < n; i++){ int a; scanf("%d", &a); if(mx < a) mx = a; if(mn > a) mn = a; } if(mn + 2 * k < mx) printf("-1\n"); else printf("%d\n", mn + k); } int mai...
C
3b158306d335459ff55dcf29e46010e8
ec936d4af6ef05c078c90c2236fab5b4
900
PASSED
#include <stdio.h> int a[200]; void swap(int *a, int *b){ int tmp; tmp = *a; *a = *b; *b = tmp; } void bubble_sort(int *a, int sz){ for(int i = 0; i < sz - 1; i++){ for(int j = i + 1; j < sz; j++){ if(a[i] > a[j]) swap(&a[i], &a[j]); } } } void solve(){ int n, k; ...
C
3b158306d335459ff55dcf29e46010e8
c7484d3919c2df0aa62cff892106c590
900
PASSED
#include <stdio.h> int a[150]; void solve(){ int n, k; int mx = 0, mn = 1e8 + 1; scanf("%d%d", &n, &k); for(int i = 0; i < n; i++){ int x; scanf("%d", &x); if(mx < x) mx = x; if(mn > x) mn = x; } if(mx - mn > 2 * k) printf("-1\n"); else printf("%d\n", mn + k...
C
3b158306d335459ff55dcf29e46010e8
1283433b81e1ef45e67948c715a5c526
900
PASSED
#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
cd6fc4d7836a9123bfd5d64dafd3911c
2,400
PASSED
#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
b41c0b3fec74777a2f08b8f724d63b36
2,400
PASSED
#include<bits/stdc++.h> #include<stdint.h> #define int int_fast64_t 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(int (i)=(j)-1;(i)>=(k);--(i)) #define ALL(a) (a).begin(),(a).end() #define MST(a,v) memset((a),(v...
C++
6c46b8ffb15d61ef0a2f5d3e1d14d364
e90752c46efc54d29edec07ae8b022dd
2,400
PASSED
#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
f6369d0a68bec77c6da1442c38f55880
2,400
PASSED
#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
b5f19b2fbdbc08606f2f638ec43c983b
2,400
PASSED
#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
0160b4e69e3956774999f8ad7a78b35f
2,400
PASSED
#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
1fe6d30c6de91362576f99b89daf6bfa
2,400
PASSED