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> #define INF 0x3f3f3f3f using namespace std; #define LL long long const int maxn= 1e6+10; int a[maxn]; int dp[maxn][2]; int main() { int T; scanf("%d",&T); while(T--) { int n; scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d",a+i); ...
C++
d34ffd75ef82111d1077db4b033d5195
257ee4b8f5c72bbbe2900eb52485b068
1,500
PASSED
// // Created by 刘晴瑞 on 2020/9/14. // #include "cstdio" #include "cstring" #define MAXN 200005 #define min(a,b) (a < b ? a : b) int t,n,d[MAXN][3][3]; inline int read(){ int num = 0; char c = getchar(); while(c < '0' || '9' < c) c = getchar(); while ('0' <= c && c <= '9'){ num = 10 * num...
C++
d34ffd75ef82111d1077db4b033d5195
2b5735a2b0d07a66b294e38e74badd5e
1,500
PASSED
#include<iostream> using namespace std; int main(){ int t, n; cin >> t; while(t--){ cin >> n; int a[n], ans; for(int i = 0; i < n; i++) cin >> a[i]; ans = (a[0] == 1); for(int i = 1; i < n; i++){ if(a[i] == 0) continue; int j = i; w...
C++
d34ffd75ef82111d1077db4b033d5195
d8e42cd307ef12b8ff20c87122708011
1,500
PASSED
/****************************************************************************** Online C++ Compiler. Code, Compile, Run and Debug C++ program online. Write your code in this editor and press "Run" button to compile and execute it. ******************************************...
C++
d34ffd75ef82111d1077db4b033d5195
05bbacaa5cd84ec2bb87689aeb16d243
1,500
PASSED
#include <iostream> #include <string> #include <bits/stdc++.h> #define lli long long int #define pb push_back #define vi vector<int> #define asort(a) sort(a.begin(),a.end()) #define dsort(a) sort(a.rbegin(),a.rend()) #define f(i, a, b) for (long long i = a; i < b; i++) #define rf(i, a, b) for (int i = b; i >= a; i--) #...
C++
d34ffd75ef82111d1077db4b033d5195
b0d41219587c663e1a3441977f4ae49f
1,500
PASSED
#include <bits/stdc++.h> using namespace std; #define all(x) (x).begin(), (x).end() #define sz(x) (int)x.size() #define len(x) (int)x.length() #define ac(x, i) get<i>(x) #define pb push_back #define mp make_pair #define pii pair<int, int> #define pll pair<ll ,ll> #define pli pair<ll, int> #define ff first #define ss se...
C++
d34ffd75ef82111d1077db4b033d5195
a8d2ab7688571f26cea11ca853e95b65
1,500
PASSED
#include<bits/stdc++.h> #define N #define M #define V #define INF 0x7fffffff #define _INF 1e18 #define oo 0x3f3f3f3f #define inf 0x3fffffff #define LL long long #define LLU unsigned long long #define FOR(i,l,r) for(int i=(l);i<=(r);++i) #define _FOR(i,l,r,x) for(int i=(l);i<=(r);i+=x) #define REP(i,l,r) for(int i=(l);...
C++
d34ffd75ef82111d1077db4b033d5195
68be5ca26d4c4da500c4d46f23acc260
1,500
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef unsigned int uint; #pragma GCC optimize(2) #pragma GCC optimize(3) #define endl '\n' #define lowbit(x) (x & -x) #define ls(x) (x << 1) #define rs(x) (x << 1 | 1) #define ck(x) (x >= mod ? x - mod : x) #define in...
C++
d34ffd75ef82111d1077db4b033d5195
980265722f0da85d4e34094c888ea96e
1,500
PASSED
//package ecr95; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.*; public class G { InputStream is; PrintWriter out; String INPUT = ""; void solve() { // 2:45 int n = ni(); int[] a = na(n); Random gen = new Rando...
Java
fc91e26a2cae7ef51f61114e4bf428eb
f86b60f9afb5f928b12e9fde708c17b4
2,500
PASSED
/* In the name of Allah */ #include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int, int> #define pll pair<long long, long long> #define pb push_back #define LL_INF 1LL << 62 #define INF 1 << 30 #define SetBit(x, k) (x |= (1LL << k)) #define ClearBit(x, k) (x &= ~(1LL << k)) #define Che...
C++
fc91e26a2cae7ef51f61114e4bf428eb
caa02f8cb2ea3c6d634ed7afbcf83b39
2,500
PASSED
#include<iostream> using namespace std; int main() { int n,k=0,l=0,o=0; cin>>n; o=n; while(n>=0) { if(n%7==0) { k=n/7; for(int i=1;i<=l;i++)cout<<"4"; for(int i=1;i<=k;i++)cout<<"7"; return 0; } else {n-=4;l++;} } co...
C++
2584fa8c1adb1aa8cd5c28a8610ff72d
60ed86713c48623476b31a80c51e9cab
1,000
PASSED
#include<stdio.h> using namespace std; int main() { int n,i,j; scanf("%d",&n); for(i=0;i<=n/4;i++) { int a,b; a=i*4; b=n-a; if(b%7==0) { for(j=1;j<=i;j++)printf("4"); b/=7; for(j=1;j<=b;j++)printf("7"); return 0; ...
C++
2584fa8c1adb1aa8cd5c28a8610ff72d
6efb13b8e72f8dac44118cbb3d0f4688
1,000
PASSED
#include<iostream> #include<algorithm> using namespace std; int main() { int n; cin >> n; int f=0, s = 0; s = n / 7 + 1; for (; s >= 0; s--) { if (n - s * 7 >= 0 && (n - s *7 ) % 4 == 0) { f = (n - s * 7) / 4; break; } } if (f>0||s>0) { for (int i = 0; i < f; i++) { cout << 4; } for (int i = 0...
C++
2584fa8c1adb1aa8cd5c28a8610ff72d
a20cc0cbedb33e0ce8df3aab53181161
1,000
PASSED
#include<iostream> #include<algorithm> #include<stdio.h> #include<cstdio> using namespace std; int main(){ int n; cin>>n; for(int i=0;i<n/4+1;i++){//循环枚举4的数量 if((n-4*i)%7==0){//如果把4全部减掉后能被7整除 n=n-4*i;//这时候n/7表示7的数量 for(int j=0;j<i;j++){//先输出4 cout<<'4'; ...
C++
2584fa8c1adb1aa8cd5c28a8610ff72d
9d44ebd1fabfaea74380849f3497d0e9
1,000
PASSED
#include<iostream> #include<cstdio> using namespace std; int n,sum,cnt; int fr(){ char c; int neg=1; while((c=getchar())<'0'||c>'9')if(c=='-')neg=-1; int tot=c-'0'; while((c=getchar())>='0'&&c<='9')tot=(tot<<3)+(tot<<1)+c-'0'; return tot*neg; } void out(){ int m=sum/4; for(int i=1;i<=m;i++)printf("4"); m=(n-su...
C++
2584fa8c1adb1aa8cd5c28a8610ff72d
4ac54b1fb28ab0fa6c2bfbee5d08839e
1,000
PASSED
#include<iostream> using namespace std; int main() { int s; cin>>s; if (s==4||s==7) { cout<<s; return 0; } if (s<7) { cout<<"-1"; return 0; } int s2=s%7,o=s/7; if (s2==4) { string u=""; for (int i=0;i<o;i++) u+='7'; cout<<'4'<<u; return 0; } else { while (o!=-1&&s2%4!=0) { s2+=7; ...
C++
2584fa8c1adb1aa8cd5c28a8610ff72d
7b1313081112a9139937366e9b2647d9
1,000
PASSED
#include<bits/stdc++.h> using namespace std; int main(){ long long n,i=0,j=0; scanf("%lld",&n); i=n/4;n-=i*4; if(n){ while(i>0){ n+=4;i--; if(n%7==0) { j=n/7; n=0; break; } } } if(n)printf("-1"); else{ while(i>=7){...
C++
2584fa8c1adb1aa8cd5c28a8610ff72d
a66ad7ddba19094a57edcad214c64cf6
1,000
PASSED
#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; for(int i=0;i<=n/4;i++) { int f,s; f=i*4; s=n-f; if(s%7==0) { for(int j=0;j<i;j++) cout<<'4'; s/=7; for(int j=0;j<s;j++) cout<<'7'; return 0;...
C++
2584fa8c1adb1aa8cd5c28a8610ff72d
6820e3d82015cd1cba67fcb74c1dc3cc
1,000
PASSED
#include<bits/stdc++.h> using namespace std; int main(){ long long n,i=0,j=0; scanf("%lld",&n); i=n/4;n-=i*4; if(n){ while(i>0){ n+=4;i--; if(n%7==0){j=n/7;n=0;break;} } } if(n)printf("-1"); else{ while(i>=7){i-=7;j+=4;} whi...
C++
2584fa8c1adb1aa8cd5c28a8610ff72d
216655d769fa6960d657f34263cedda7
1,000
PASSED
#include<bits/stdc++.h> using namespace std; int main(){ long long n,i=0,j=0; scanf("%lld",&n); i=n/4;n-=i*4; if(n){ while(i>0){ n+=4;i--; if(n%7==0){ j=n/7;n=0;break; } } } if(n)printf("-1\n"); else{ while(i>=7){ i-=7; j+=4; } while(i--) ...
C++
2584fa8c1adb1aa8cd5c28a8610ff72d
83a251b2f683b1decfba210b4eed702c
1,000
PASSED
#include <bits/stdc++.h> #define F first #define S second #define Mp make_pair using namespace std; int n,m,A,B,a,d; vector<long long>v[100002]; pair<int,int> go(int x,int y) { d++; int M1=0; int M2=0; int Z=0; int ZZ=0; for (int i=0; i<v[x].size(); i++) if (y!=v[x][i]) { pair<int,int> X=go(v[x][i],x);...
C++
40a965a28e38bad3aff9c58bdeeeb8f6
4a5a488ca847a5d5cad208fd81fc8e77
1,500
PASSED
#include <iostream> #include <cstdlib> #include <cstring> #include <cassert> #include <string> #include <unordered_map> #include <unordered_set> #include <queue> #include <stack> #include <set> #include <utility> #include <vector> void getTwoNumbersSTDIN(int &v1, int &v2) { char buffer[25]; std::cin.getline(buffer...
C++
40a965a28e38bad3aff9c58bdeeeb8f6
da3e9144a92003f154961ea3222c7c28
1,500
PASSED
#include <iostream> #include <algorithm> #include <vector> #include <cmath> #include <string> #include <queue> #include <map> #include <ctime> #include <cstdio> using namespace std; #define ll long long #define mp make_pair #define f first #define s second int n,m,ans=0, p, q; int ctr; vector<vector<int> > gr; bool myc...
C++
40a965a28e38bad3aff9c58bdeeeb8f6
272f4d6bc10956b60090ebf0cdf6d6b7
1,500
PASSED
import java.io.*; import java.util.*; public class TreeofLife { public static void main(String args[])throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int n = Integer.parseInt(st.nextToken()); //int m = Inte...
Java
fdd50853348b6f297a62a3b729d8d4a5
d4805203dc0a7f53ec2b07111672bd78
1,300
PASSED
import java.util.*; public class Main{ public static void main(String[] args) { Scanner in = new Scanner(System.in); int n=in.nextInt(); Vector<Integer> graph[]; graph = new Vector[110000]; for(int i=0;i<110000;++i){ graph[i]=new Vector<>(); } bo...
Java
fdd50853348b6f297a62a3b729d8d4a5
5c91fbc7395f5d53d12632f6c53b0159
1,300
PASSED
#include<bits/stdc++.h> #pragma GCC optimize("O2") #define S second #define F first #define PB push_back #define sz(x) (int) x.size() #define all(x) x.begin(),x.end() #define L(x) 2*x #define R(x) 2*x+1 #define M(x,y) (x+y)/2 using namespace std; typedef long long ll; const int N=1e5+1; vector<int> co[N]; ll ans=0; voi...
C++
fdd50853348b6f297a62a3b729d8d4a5
3d4a18b7ff53d5838edb511f0f27a58e
1,300
PASSED
#include <iostream> #include <array> using namespace std; int main() { int num = 0; cin >> num; int graph[num]; for(int i = 0; i < num;i++){ graph[i] = 0; } for(int i = 0; i < num-1;i++){ int a = 0, b = 0; cin >> a >> b; graph[a-1]++; graph[b-1]++; ...
C++
fdd50853348b6f297a62a3b729d8d4a5
f48a0352e1d658922703f739fec5865f
1,300
PASSED
#include <bits/stdc++.h> using namespace std; int main() { int n, res = 0; cin >> n; n = n*2 - 2; vector<int> v(n); for (int i = 0; i < n; ++i) cin >> v[i]; sort(begin(v), end(v)); for (int i = 0; i < n;) { int cnt = distance(begin(v) + i, upper_bound(begin(v) + i, end(v), ...
C++
fdd50853348b6f297a62a3b729d8d4a5
91f8a824e18f44d4057d9e12f29f5f30
1,300
PASSED
#include <iostream> #include <cstring> using namespace std; int main() { int n; cin >> n; int deg[n + 1]; memset(deg, 0, sizeof(deg)); int v, u; for (int i = 0; i < n - 1; i++) { cin >> v >> u; deg[v] ++; deg[u] ++; } int p2 = 0; for (int i = 1; i <= n; i++) { p2 += deg[i] * (deg[i] - 1) / 2; } ...
C++
fdd50853348b6f297a62a3b729d8d4a5
0b72c5c572e59980f6c3f4e9771f40e2
1,300
PASSED
/* In the name of Allah */ #include<bits/stdc++.h> using namespace std; int n, deg[10005]; long long ans; int main() { cin >> n; for (int i = 1; i < n; i++) { int u, v; cin >> u >> v; deg[u]++, deg[v]++; } for (int i = n; i; i--) ans += (deg[i] - 1LL) * deg[i] / 2; cout << ans; }
C++
fdd50853348b6f297a62a3b729d8d4a5
0b5cca0494c5f00ecc9b95e4affe3bb2
1,300
PASSED
#include <iostream> #include <cmath> #include <algorithm> using namespace std; const int MAX = 10000; int degree[MAX] = {0}; int main() { int n; // read input cin >> n; for (int i = 0; i < n - 1; i++) { int from, to; cin >> from >> to; from--; to--; degree[from]++; degree[to]++; } int count = 0...
C++
fdd50853348b6f297a62a3b729d8d4a5
8db0a352f7f612f1c3309c1f409abc30
1,300
PASSED
#include<bits/stdc++.h> typedef long long ll; typedef long long ld; #define re return(0); #define ce continue; using namespace std; vector<int> g[100005]; vector<bool> vis(100005,false); int ans=0; void dfs(int start,int s) { vis[start]=true; if(s==2) { ans++; return; } for(auto to:g[start]) { if(vis[to]==f...
C++
fdd50853348b6f297a62a3b729d8d4a5
455e9778719b4713acb5ca497463ac9a
1,300
PASSED
#include<bits/stdc++.h> using namespace std; typedef pair<int, int> iPair; #define PB push_back #define MP make_pair #define F first #define S second #define SZ(a) (int)(a.size()) #define ALL(a) a.begin(),a.end() #define SET(a,b) memset(a,b,sizeof(a)) #define rep1(i, a, b) for (int i = (a); i < (b); ++i) #define rep(i,...
C++
fdd50853348b6f297a62a3b729d8d4a5
850db5f61459fcecc2ff5f1bf2f8ad68
1,300
PASSED
#include <bits/stdc++.h> using namespace std; using ll = int64_t; const ll P = 29; const ll MOD = 998244353; const ll N = 1000000; string s; ll n; ll pre[N]; ll suf[N]; ll POW[N]; void init_pow() { POW[0] = 1; for (int i = 1; i < N; ++i) { POW[i] = (POW[i - 1] * P) % MOD; } } ll fwd_hash(int l, int r) { if (...
C++
beaccd2c0213a330538fe741d1f4b5bf
c98eaa2695f04a8e6793a3d28739af19
1,800
PASSED
#include <bits/stdc++.h> using namespace std; using ll = int64_t; const ll P = 29; const ll MOD = 998244353; const ll N = 1000000; string s; ll n; ll pre[N]; ll suf[N]; ll POW[N]; void init_pow(); void init_presuf(); bool check_palin(int l, int r); int main() { #ifndef ONLINE_JUDGE #include <fileio.h> #endif ...
C++
beaccd2c0213a330538fe741d1f4b5bf
76ea86bb34718035f82e9b9358e5836f
1,800
PASSED
#include <bits/stdc++.h> using namespace std; using ll = int64_t; const int P = 29; const ll MOD = 998244353; const int N = 1000000; int n; ll pre[N + 2]; ll suf[N + 2]; ll POW[N]; // Returns (n^p) modulo MOD in O(log(p)) // n >= 0, p > 0 and MOD > 1 ll pow(ll a, ll n, ll MOD) { ll ans = 1; while (n) { if (n&1)...
C++
beaccd2c0213a330538fe741d1f4b5bf
d7b790c2714eb3a89289596bfcfd34d1
1,800
PASSED
#include <bits/stdc++.h> using namespace std; using ll = int64_t; const int P = 875329; const int MOD = 998244353; const int N = 1000000; string s; int n; int pre[N]; int suf[N]; ll POW[N]; // Returns (n^p) % MOD in O(log(p)) // n >= 0, p > 0 and MOD > 1 int fpow(ll n, int p, int MOD) { ll res = 1; while (p) { ...
C++
beaccd2c0213a330538fe741d1f4b5bf
0cb4bc4e082d901d15b0dd24d0adeffe
1,800
PASSED
#include <bits/stdc++.h> using namespace std; // REF: https://codeforces.com/blog/entry/3107 int LPP(string s) { string rev="",str=s; int m=s.size(),longestPalindromicPrefix=1; if(m==0 || m==1) longestPalindromicPrefix=m; for(int i=m-1;i>=0;i--) rev+=s[i]; s+='#'; s+=rev; int n=s....
C++
beaccd2c0213a330538fe741d1f4b5bf
12560ef50c806cc09d14966dbd58846f
1,800
PASSED
#include <bits/stdc++.h> using namespace std; using ll = int64_t; const ll P = 29; const ll MOD = 998244353; const ll N = 1000000; string s; ll n; ll pre[N]; ll suf[N]; ll POW[N]; // Returns (n^p) % MOD in O(log(p)) // n >= 0, p > 0 and MOD > 1 ll fpow(ll n, ll p, ll MOD) { ll res = 1; while (p) { if (p & 1) { ...
C++
beaccd2c0213a330538fe741d1f4b5bf
c8153908d575e89fa4ccaace748fbaf7
1,800
PASSED
#include <bits/stdc++.h> using namespace std; using ll = int64_t; const int P = 29; const int MOD = 998244353; const int N = 1000000; string s; int n; int pre[N]; int suf[N]; ll POW[N]; // Returns (n^p) % MOD in O(log(p)) // n >= 0, p > 0 and MOD > 1 int fpow(ll n, int p, int MOD) { ll res = 1; while (p) { if (...
C++
beaccd2c0213a330538fe741d1f4b5bf
60a00f98fcd38d809f14ca50cde7ab88
1,800
PASSED
#import<bits/stdc++.h> #define endl '\n' using namespace std; int i,j,k,l,n,t,x,y,o[1000005]; string s; main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); for(cin>>t;t--;) { cin>>s; n=s.size(); for(i=0,j=n-1;s[i]==s[j]&&i<j;) { i++; j--; } if(i>=j)cout<<s<<endl; else { for(o[k...
C++
beaccd2c0213a330538fe741d1f4b5bf
41d4f63f579b12db2db245ed75f746d7
1,800
PASSED
/* Author : Mohd Athar */ #include<bits/stdc++.h> using namespace std; #define ll long long const int M = (int)(2e6 + 239); int lps[M]; string prefix_func(const string &a){ //Prefix function Based on KMP.. string s = a; reverse(s.begin() , s.end()); s = a + '#' + s; // Here Actually we are looking for...
C++
beaccd2c0213a330538fe741d1f4b5bf
be414cd8d4a2ea4d7850eaf437b5d536
1,800
PASSED
/* Author : Mohd Athar */ #include<bits/stdc++.h> using namespace std; #define ll long long const int M = (int)(2e6 + 239); int lps[M]; string prefix_func(const string &a){ //Prefix function Based on KMP.. string s = a; reverse(s.begin() , s.end()); s = a + '#' + s; //here Longest proper prefix array ...
C++
beaccd2c0213a330538fe741d1f4b5bf
f3c148b7fd6ec90782366d41ecd051a5
1,800
PASSED
#include <cstdio> #include <vector> using namespace std; #define Maxn 1000000 vector<int> ed[Maxn+5]; int n,m; int fa[Maxn+5]; bool can[Maxn+5]; int sz[Maxn+5]; int f[Maxn+5]; int dfn[Maxn+5]; int dep[Maxn+5]; void add(int x,int a){ for(int i=x;i<=n;i+=(i&(-i))){ f[i]+=a; } } int sum(int x){ int ans=0; for(int i=...
C++
7dccfaab4ed17b93a27202affa9408d4
3d8274bbc52011bd409658f8eb88244e
2,200
PASSED
#include <cstdio> #include <vector> using namespace std; #define Maxn 1000000 vector<int> ed[Maxn+5]; int n,m; int fa[Maxn+5]; bool can[Maxn+5]; int b[Maxn+5][35]; int sum[Maxn+5]; void dfs(int x){ sum[x]=sum[fa[x]]+1; for(int i=0;i<(int)ed[x].size();i++){ if(ed[x][i]!=fa[x]){ fa[ed[x][i]]=x; dfs(ed[x][i]); ...
C++
7dccfaab4ed17b93a27202affa9408d4
5f67560e287710ff31774707c6e9f0b9
2,200
PASSED
#include<bits/stdc++.h> using namespace std; const int maxn=1e6+1; const int maxnlog=20+1; int father[maxn][maxnlog]; int depth[maxn]; int n,m,root; int book[maxn]; vector<int>G[maxn]; void dfs(int x,int f,int dis) { father[x][0]=f; depth[x]=dis; for(auto i:G[x]){ if(i==f)continue; dfs(...
C++
7dccfaab4ed17b93a27202affa9408d4
6ae9656ab637bc4db8011b7bf9d4a370
2,200
PASSED
#include<bits/stdc++.h> using namespace std; const int maxn=1e6+1; const int maxnlog=20+1; int father[maxn][maxnlog]; int depth[maxn]; int n,m,root; int book[maxn]; vector<int>G[maxn]; void dfs(int x,int f,int dis) { father[x][0]=f; depth[x]=dis; for(auto i:G[x]){ if(i==f)continue; dfs(...
C++
7dccfaab4ed17b93a27202affa9408d4
52841f2eafbbeb4e77d7a1bc5dbf3e29
2,200
PASSED
#include<bits/stdc++.h> using namespace std; const int maxn = int(1e6) + 5; const int maxlogn = int(20) + 5; int n, m, root; vector<int> G[maxn]; int parent[maxlogn][maxn]; // 向上走 pow(2, k) 步走到的节点 int depth[maxn]; void dfs(int u, int p, int d) { parent[0][u] = p; depth[u] = d; for (auto v : G[u])...
C++
7dccfaab4ed17b93a27202affa9408d4
58fd733a6789eea2e8147eecd488a7e2
2,200
PASSED
#include<bits/stdc++.h> using namespace std; const int maxn=1e6+3; const int maxnlog=20+1; vector<int>G[maxn]; int father[maxn][maxnlog]; int depth[maxn]; int n,m; void dfs(int x,int f,int d) { father[x][0]=f; depth[x]=d; for(auto v:G[x]) { if(v==f)continue; dfs(v,x,d+1); } } void in...
C++
7dccfaab4ed17b93a27202affa9408d4
f04720b6371b01081b6b9e5a5ffffcea
2,200
PASSED
#include<bits/stdc++.h> #define file(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout) #define go(x, i) for(register int i = head[x]; i; i = nxt[i]) #define For(i, a, b) for(register int i = (a), i##_end_ = (b); i <= i##_end_; ++ i) #define FOR(i, a, b) for(register int i = (a), i##_end_ = (b); i >= i##_en...
C++
7dccfaab4ed17b93a27202affa9408d4
3357cd808ec3c7ccab9c2af35e070e02
2,200
PASSED
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define mp make_pair typedef long long ll; typedef pair<int, int> ii; const int len = 1e6+6; int dp[25][len], dep[len], vis[len], p[len]; vector<int> adj[len]; void fix(int u, int d){ dep[u] = d; for (int j ...
C++
7dccfaab4ed17b93a27202affa9408d4
fa5452e49acc5713376fe7c6767fad8c
2,200
PASSED
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define mp make_pair typedef long long ll; typedef pair<int, int> ii; const int len = 1e6+6; int dp[22][len], dep[len], vis[len], p[len]; vector<int> adj[len]; void fix(int u, int d){ dep[u] = d; for (int j ...
C++
7dccfaab4ed17b93a27202affa9408d4
326c3f8a2f3ed4154bbdca8182837f2d
2,200
PASSED
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define mp make_pair typedef long long ll; typedef pair<int, int> ii; const int len = 1e6+6; int dp[len][25], dep[len], vis[len], p[len]; vector<int> adj[len]; void fix(int u, int d){ dep[u] = d; for (int j ...
C++
7dccfaab4ed17b93a27202affa9408d4
b4c17ce9c2a11c2b6bac6faa5f499ec2
2,200
PASSED
#include<cstdio> #include<vector> #include<algorithm> using namespace std; vector< pair<int,int> > h; int main(){ // Last Change: 2012-01-22 16:57:32 int a,b,c,d; scanf("%d%d%d%d",&a,&b,&c,&d); if(abs(c-d)>1){ puts("-1"); return 0; } h.clear(); if(c>d||(c==d&&a>c)...
C++
f63cef419fdfd4ab1c61ac6d7e7657a6
8f93bea4479b439dec4ab3ec174471a8
1,800
PASSED
#include <algorithm> #include <iostream> #include <sstream> #include <string> #include <vector> #include <queue> #include <stack> #include <set> #include <map> #include <list> #include <bitset> #include <deque> #include <numeric> #include <iterator> #include <cstdio> #include <cstdlib> #include <cstring> #include <ccty...
C++
f63cef419fdfd4ab1c61ac6d7e7657a6
be87242852933b9f679df23c3dde8f2a
1,800
PASSED
#include <algorithm> #include <iostream> #include <sstream> #include <string> #include <vector> #include <queue> #include <stack> #include <set> #include <map> #include <list> #include <bitset> #include <deque> #include <numeric> #include <iterator> #include <cstdio> #include <cstdlib> #include <cstring> #include <ccty...
C++
f63cef419fdfd4ab1c61ac6d7e7657a6
6dac0f3c0c2f842fdf939a36ba94c745
1,800
PASSED
#include <iostream> #include <cstdio> #include <cstdlib> #include <vector> #include <cstring> #include <cmath> #include <algorithm> #include <utility> using namespace std; int a, b, c, d; string s = "\0"; bool check () { if (a < 0 || b < 0 || d < 0 || c < 0) { printf ("-1"); exit (0); } } int main() { #ifn...
C++
f63cef419fdfd4ab1c61ac6d7e7657a6
6bdf21f021f77cf3215b3b3039e4596b
1,800
PASSED
#include <algorithm> #include <bitset> #include <cctype> #include <cfloat> #include <climits> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <functional> #include <iostream> #include <iterator> #include <map> #include <numeric> #include <queue> #include <set> #inclu...
C++
f63cef419fdfd4ab1c61ac6d7e7657a6
34337bdc5dfbbe54d76236fcd6a433ab
1,800
PASSED
#include <cstdio> #include <algorithm> using namespace std; int i, j, r,st; int a[4]; char c[] = { '4', '7' }; int main(){ for (i = 0; i < 4; i++) scanf("%d",&a[i]); st = 1; if (a[2] > a[3] || a[2] == a[3] && a[0] > a[2]) st = 0; r = max(a[2], a[3]); a[0] -= r; a[1] -...
C++
f63cef419fdfd4ab1c61ac6d7e7657a6
7522e766e41d266f04127f423b36d951
1,800
PASSED
#include <cstdio> #include <algorithm> using namespace std; int i, j, r,st; int a[4]; char c[] = { '4', '7' }; int main(){ for (i = 0; i < 4; i++) scanf("%d",&a[i]); st = 1; if (a[2] > a[3] || a[2] == a[3] && a[0] > a[2]) st = 0; r = max(a[2], a[3]); a[0] -= r; a[1] -...
C++
f63cef419fdfd4ab1c61ac6d7e7657a6
1e9f9f26282abf0a6b8c3fab3e74efcd
1,800
PASSED
// CF.cpp: define el punto de entrada de la aplicaci?n de consola. // #include <cstdio> #include <algorithm> #include <vector> #include <string> #include <cmath> #include <map> typedef std::pair<int,int> ii; typedef long long int Int; typedef unsigned long long int uInt; typedef std::vector<int> vi; typedef std::vecto...
C++
f63cef419fdfd4ab1c61ac6d7e7657a6
8fa78968cfb36bc5464ea3b4719dda9d
1,800
PASSED
#include <iostream> #include <stdio.h> using namespace std; typedef long long Int; Int ABS(Int a) { if (a<0) return a*-1; else return a; } int main() { Int a1,a2,a3,a4; Int fours,sevens; Int i; scanf("%I64d %I64d %I64d %I64d",&a1,&a2,&a3,&a4); if ( ABS(a3-a4)>1 ) { pr...
C++
f63cef419fdfd4ab1c61ac6d7e7657a6
13bf0eeebac8e13a565a5dd4f41cd5b0
1,800
PASSED
#include<iostream> #include<algorithm> #include<string> #define f(i,p,n) for(int i = p; i < n; i++) using namespace std; int main() { int a1, a2, a3, a4, pos = 0; cin >> a1 >> a2 >> a3 >> a4; if (abs(a3-a4) > 1) {cout << "-1" << endl;return 0;} if (a2 < max(a3,a4)) {cout << "-1" << endl;return 0;}...
C++
f63cef419fdfd4ab1c61ac6d7e7657a6
2e0264ff89a3dc637428a09644c6ea7f
1,800
PASSED
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); ArrayList<String[]> a = new ArrayList<>(); for(int i=0; i<t; i++) { int n = sc.nextInt(); String[] s = new String[n]; for(int j=0; j<n; j++) s[j] = sc.ne...
Java
3d6cd0a82513bc2119c9af3d1243846f
071ec6a480ff06d632363e5b520b1982
800
PASSED
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); ArrayList<String[]> a = new ArrayList<>(); for(int i=0; i<t; i++) { int n = sc.nextInt(); String[] s = new String[n]; for(int j=0; j<n; j++) s[j] = sc.ne...
Java
3d6cd0a82513bc2119c9af3d1243846f
3a508d60613bd5f8c5272aec91649c0f
800
PASSED
import java.util.*; public class JugglingLetters { public static void main(String args[]) { Scanner scanner = new Scanner(System.in); int t = scanner.nextInt(); while (t-- > 0) { int n = scanner.nextInt(); scanner.nextLine(); int letters[] = new int[26]; boolean cando = true; for (int l = 0; ...
Java
3d6cd0a82513bc2119c9af3d1243846f
bfadce30097e58355bfe010314746d34
800
PASSED
//package com.cf.r666; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; p...
Java
3d6cd0a82513bc2119c9af3d1243846f
f948ffda64b5d596f2993185cae6d40d
800
PASSED
import java.util.Scanner; public class JugglingLetters { public static void main(String[] args) { Scanner entrada = new Scanner(System.in); int numero, diferente, m = 1; numero = entrada.nextInt(); for (int i = 0; i < numero; i++) { int n = entrada.nextInt(); ...
Java
3d6cd0a82513bc2119c9af3d1243846f
56c1150ca5e473a44224697ae5b013a2
800
PASSED
import java.util.*; import java.io.*; import java.lang.*; public class test { public static void main(String args[]) { try{ Scanner sc= new Scanner(System.in); int t = sc.nextInt(); while(t-->0) { int a[] = new int[256]; boolean check = true; ...
Java
3d6cd0a82513bc2119c9af3d1243846f
3f54e3ccf08ff078246ebea3025e8b8a
800
PASSED
import java.text.DecimalFormat; import java.util.stream.LongStream; import java.util.stream.IntStream; import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { FastScanner sc = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int t...
Java
3d6cd0a82513bc2119c9af3d1243846f
37b1a4d0091a4e763bb50089b3b10eaf
800
PASSED
import java.text.DecimalFormat; import java.util.stream.LongStream; import java.util.stream.IntStream; import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { FastScanner sc = new FastScanner(); PrintWriter out = new PrintWriter(System.out); int t...
Java
3d6cd0a82513bc2119c9af3d1243846f
d4e25c838cf0214c05bbc8280394443b
800
PASSED
import java.io.*; // for handling input/output import java.util.*; // contains Collections framework public class Solution { public static void main (String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); while(t-->0){ int n = in.nextInt(); Map<Charac...
Java
3d6cd0a82513bc2119c9af3d1243846f
e2cfd1e99d857e887deed427b500d2ba
800
PASSED
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class CF_A_1397 { public static void main(String[] args) throws IOException { long t = readLong(); TestLoop: for (int __ = 0; __ < t; __++) { long ...
Java
3d6cd0a82513bc2119c9af3d1243846f
291f6956662fb7586d1925177e34f805
800
PASSED
#include <iostream> #include <algorithm> #include <string> #include <cstring> #include <cstdio> #include <cmath> #include <set> #include <map> #include <vector> #include <stack> #include <queue> #include <bitset> const int INF=0x3f3f3f3f; const int maxn=1e5+5; const int mod=1e9+7; const double eps=1e-7; typedef long...
C++
769859d86a3ceb2d89a444cd64c9a73b
641d985e0150f5fe4ac35ac1e257468e
1,900
PASSED
#include <iostream> #include <cstdio> #include <cstring> #include <vector> #include <algorithm> #include <unordered_map> #include <cmath> #include <set> #include <map> #include <queue> #define N 100005 #define M 10005 #define inf 1000000000 #define pii pair<int, int> using namespace std; typedef long long ll; const ll ...
C++
769859d86a3ceb2d89a444cd64c9a73b
1ff1407b7ec7db125f67562fa794d32d
1,900
PASSED
// in the name of Allah ; #include<bits/stdc++.h> using namespace std ; const int maxn = 1e5 + 10 ; vector < pair < long long , long long > > a , b ; int n , s ; long long ans = 0 , suma , sumb ; void input() { cin >> n >> s ; for ( int i = 0 ; i < n ; i++ ) { long long ss , aa , bb ; cin >> ss >> aa >> bb ; ...
C++
769859d86a3ceb2d89a444cd64c9a73b
f5d448a4411e051f63d1f40bb0693b95
1,900
PASSED
#include <bits/stdc++.h> using namespace std; struct Person { long long first; long long second; long long parts; }; long long make(long long number, long long s) { return (number / s + (number % s == 0 ? 0 : 1)); } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); long long n, s; cin >...
C++
769859d86a3ceb2d89a444cd64c9a73b
0193b6a2d6c94d8202ecf1fe7338aba8
1,900
PASSED
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #define ll long long int main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); int n, S; cin >> n >> S; pair<ll, ll> pac[n+1]; ll sum = 0, ans = 0, tot = 0; for(in...
C++
769859d86a3ceb2d89a444cd64c9a73b
568ae833e0711fbea96b88472964331a
1,900
PASSED
#include <bits/stdc++.h> using namespace std; #define inf 2000000000 #define INF 1e18 typedef long long ll; typedef long double ld; typedef double db; typedef string str; typedef pair<ll,ll> ii; typedef pair<ii,ll> iii; typedef vector<ll> vl; typedef vector<ii> vii; #define getbit(n,i) (((n)&(1LL<<(i)))!=0) #define...
C++
769859d86a3ceb2d89a444cd64c9a73b
5105daaa2d357449fd61af0889cec02c
1,900
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define ar array const int M = 1e9 + 7; void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __pri...
C++
769859d86a3ceb2d89a444cd64c9a73b
845d057684ec08debdc3fb19ab81cdd3
1,900
PASSED
#include <algorithm> #include <cmath> #include <iostream> #include <utility> // std::pair, std::make_pair #include <vector> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; bool comp(pll a, pll b) { return a.first > b.first; } // x is number of pieces to consume ll findBest(vector<pll>& ps, ll...
C++
769859d86a3ceb2d89a444cd64c9a73b
2048200b295df613fe9e968b4126ea97
1,900
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define ar array const int M = 1e9 + 7; void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __pri...
C++
769859d86a3ceb2d89a444cd64c9a73b
84bfdb879bb3dbe4b410a5fea78792f9
1,900
PASSED
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef long long ll; const int N = 1e5+1; ll n, S; ll s[N],a[N],b[N]; struct node { ll x; int id; bool operator < (const node&r)const{ return x < r.x; } }c[N]; int main() { int i, f = 0; ll ans = 0, sum = 0, a1=...
C++
769859d86a3ceb2d89a444cd64c9a73b
5ec9d1d3cd67706a5ed11ffb098735b5
1,900
PASSED
#include <bits/stdc++.h> using namespace std; // ============================================================================= // BEGIN template // ============================================================================= #ifdef ONLINE_JUDGE #define fastio std::ios::sync_with_stdio(false) #define dbg(X)...
C++
27e766729f3f23861f730b19d6519b29
95dd56923c31239b3ea6b4e874344c36
2,500
PASSED
#include <bits/stdc++.h> using namespace std; // ============================================================================= // BEGIN template // ============================================================================= #ifdef ONLINE_JUDGE #define fastio std::ios::sync_with_stdio(false) #define dbg(X)...
C++
27e766729f3f23861f730b19d6519b29
fca5d3c12144e29b62f6c8a174e2d940
2,500
PASSED
#include <bits/stdc++.h> using namespace std; // ============================================================================= // BEGIN template // ============================================================================= #ifdef ONLINE_JUDGE #define fastio std::ios::sync_with_stdio(false) #define dbg(X)...
C++
27e766729f3f23861f730b19d6519b29
5f12cf16e9d7c6a0989a7fe45777c593
2,500
PASSED
#include <bits/stdc++.h> using namespace std; // ============================================================================= // BEGIN template // ============================================================================= #ifdef ONLINE_JUDGE #define fastio std::ios::sync_with_stdio(false) #define dbg(X)...
C++
27e766729f3f23861f730b19d6519b29
ec6b7e77eaa7a751cc9e7e6174fe7502
2,500
PASSED
#include <bits/stdc++.h> #define MAXN 300010 using namespace std; typedef long long LL; int ch[MAXN][26]; int ans[MAXN],maxdep = 0; int N; int merge(vector<int>now) { int res = now.size()-1; vector<int>next; for (int i=0;i<26;i++) { next.clear(); for (int j=0;j<now.size();j++) ...
C++
27e766729f3f23861f730b19d6519b29
99dab94690c0820d1182d19053bb61ee
2,500
PASSED
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int maxn=300005; int n,u,v,x,trie[maxn<<1][26],sz[maxn<<1],tot,cnt[maxn],res; char op[2]; int merge(int a,int b) { if (!a||!b) return a+b; int rt=++tot; //memset(trie[rt],0,sizeof trie[rt]); sz[rt]=1; for (i...
C++
27e766729f3f23861f730b19d6519b29
3be77a6f285250f85183ab7573f44616
2,500
PASSED
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int maxn=300005; int n,u,v,x,trie[maxn<<1][26],sz[maxn<<1],tot,cnt[maxn],res; char op[2]; int merge(int a,int b) { if (!a||!b) return a+b; int rt=++tot; sz[rt]=1; for (int i=0;i<26;++i) { trie[rt][i]=mer...
C++
27e766729f3f23861f730b19d6519b29
23f11f782a0b4b7eeca5239466355c8d
2,500
PASSED
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int maxn=300005; int n,u,v,x,trie[maxn<<1][26],sz[maxn<<1],tot,cnt[maxn],res; char op[2]; int merge(int a,int b) { if (!a||!b) return a+b; int rt=++tot; memset(trie[rt],0,sizeof trie[rt]); sz[rt]=1; for (int...
C++
27e766729f3f23861f730b19d6519b29
08b090bbd7daee5c0f394d9fa1b86dba
2,500
PASSED
#include <algorithm> #include <bitset> #include <cmath> #include <cstdio> #include <cstring> #include <fstream> #include <iostream> #include <map> #include <queue> #include <set> #include <stack> #include <time.h> #include <vector> #define ff first #define ss second #define MP make_pair #define y1 wasdasfnasoifan #defi...
C++
27e766729f3f23861f730b19d6519b29
455eaa6a33428e4946b4b3a395acde8b
2,500
PASSED
#include<bits/stdc++.h> #define pb push_back #define mp make_pair #define MAXN 300010 #define inf 100000000 using namespace std; int sz[MAXN],heavy[MAXN],edge[MAXN][30],ans,ans1,cnt,ans2,res=inf,ind,mxdpt; vector<pair<int,int>>adj[MAXN],rollbk; vector<int>depth[MAXN]; void dfsinit(int node,int par,int dpt){ sz[node]...
C++
27e766729f3f23861f730b19d6519b29
fcd81ea4e3960ae1baff73c863eaae49
2,500
PASSED
#include <iostream> using namespace std; int main() { int n; cin>>n; int a[n],aa[n]; int mini=1000001; for(int i=0;i<n;i++) { cin>>a[i]; } for(int j=0;j<n;j++) { for(int i=0;i<n;i++) { if(mini>a[i] && a[i]>0) { mini=a[i]; } ...
C++
f93a8bd64a405233342f84542fce314d
ea53c7d7b43c56d90190f3e9b22bd4af
800
PASSED
#include<iostream> #include<math.h> #include<algorithm> typedef long long ll; using namespace std; int main() { ll x; cin>>x; ll a[1003]; for(int i=0;i<x;i++){ cin>>a[i]; } sort(a,a+x); if(x%2==0) cout<<a[x/2-1]; else cout<<a[x/2]; return 0; }
C++
f93a8bd64a405233342f84542fce314d
8bfd5d788928afb22f6fa219949c5118
800
PASSED
#include<bits/stdc++.h> using namespace std; #define ll long long const int N=2e5+5; vector<ll>v; map<ll,ll>mp; int main() { ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL); ll n,t,y,i,x,k,cnt=0,ans=0,l,r,maxi=-1,sum=0,m,flag=0; cin>>n; ll a[n]; for(int i=0;i<n;i++) cin>>a[i]; s...
C++
f93a8bd64a405233342f84542fce314d
48e9d83bc860efdf8c0bdb4b31ab5c34
800
PASSED
#include<bits/stdc++.h> using namespace std; int main(){ vector<int>vec; int n; scanf("%d",&n); int i; for(i=0;i<n;i++){ int x; scanf("%d",&x); vec.push_back(x); } sort(vec.begin(),vec.end()); if(n%2==0){ printf("%d\n",vec[(n/2)-1]); } else{ ...
C++
f93a8bd64a405233342f84542fce314d
001dddbd4ee12df062d7698417fa9937
800
PASSED
/* B-Game */ #include <iostream> #include<bits/stdc++.h> #include <stdio.h> #include<vector> #include<algorithm> #include <deque> #include <list> #include <set> #include <map> using namespace std; int main() { int i,t,n; scanf("%d",&n); int ara[n]; for(i=0;i<n;i++){ scanf("%d",&ara[i]); } ...
C++
f93a8bd64a405233342f84542fce314d
979c894831811512a0709b70a847f701
800
PASSED
#include<bits/stdc++.h> using namespace std; int main(){ int a; cin >>a; vector<long long> arr; for(int i = 0;i<a;i++){ int val; cin >>val; arr.push_back(val); } sort(arr.begin(),arr.end()); cout <<arr[((a+1)/2)-1]<<endl; return 0; }
C++
f93a8bd64a405233342f84542fce314d
a65333b071add20a950314ab26432c2f
800
PASSED
#include<bits/stdc++.h> using namespace std; int main(){ int a,arr[1005]; cin >>a; for(int i = 0;i<a;i++) cin >>arr[i]; sort(arr,arr+a); cout <<arr[(a-1)/2]<<endl; return 0; }
C++
f93a8bd64a405233342f84542fce314d
197d782dbe75a4768f31b317fe8d4395
800
PASSED