text stringlengths 49 983k |
|---|
#include <bits/stdc++.h>
using namespace std;
//int dirs[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
//int dirs[8][2]={{-1,0},{0,-1},{0,1},{1,0},{1,1},{-1,-1},{-1,1},{1,-1}};
long long modd=1e9+7;
vector<int> dsu;
vector<int> height;
vector<bool> has_loop;
int find_leader(int u)
{
if(dsu[u]==u) return u;
return dsu... |
#include<bits/stdc++.h>
#define ll long long
#define FOR(i, s, e) for (int i = (s); i < (e); i++)
#define FOE(i, s, e) for (int i = (s); i <= (e); i++)
#define FOD(i, s, e) for (int i = (s); i >= (e); i--)
#define mp make_pair
using namespace std;
int n, m;
int p[500005], self[500005];
set<int> s;
int find(int x) { ... |
#include <cstdio>
#include <iostream>
#define ll long long
using namespace std;
int n , m , cnt = 0;
const int N = 5e5 + 5;
const int mod = 1e9 + 7;
ll pow2[N];
int num[N] , fa[N];
int find(int x){
if(fa[x] == x)
return x;
return fa[x] = find(fa[x]);
}
int main(){
pow2[0] = 1;
cin >> n >> m;
for(int i = ... |
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define db(a) cout << fixed << #a << " = " << a << endl;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const ll MOD = 1e9 + 7;
const int MAXM = 5e5 + 5;
vector<int> parent(MAXM, -1);
vector<int> rank_(MAXM, -1);
vector<int> indice... |
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int fa[500005];
int vis[500005];
int num[500005];
vector<int> tt;
long long ans=1;
int n,m;
int t;
struct nod{
int tp,a,b,id;
}arr[500005];
int cmp(nod a,nod b)
{
if (a.tp!=b.tp) return a.tp<b.tp;
return a.id<b.id;
}
int find(int x){return x==fa[x]?... |
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
// #include <atcoder/all>
// #include <bits/stdc++.h>
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <ran... |
#include <bits/stdc++.h>
using namespace std;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
const int N=1e6+2,p=1e9+7;
int f[N],st[N],ed[N];
int n,c,i,t,m,j,k,tp,x,y,ans,z,w,la,s;
inline int ksm(register int x,register int y)
{
register int r=1;
while (y)
{
if (y&1) r=(ll)r*x%p;
... |
#include <iostream>
#include <set>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
#include <vector>
#include <assert.h>
#include <queue>
typedef long long ll;
const int mod=1e9+7;
using namespace std;
int n,m,k,v,ans=1,x,y;
int a[500005],par[500005];
vector<int>res;
int find(int x){
return... |
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' ';... |
#include <bits/stdc++.h>
using namespace std;
#define send {ios_base::sync_with_stdio(false);}
#define help {cin.tie(NULL);}
#define f first
#define s second
#define pb push_back
#define vi vector<long long>
#define vii vector<pair<long long,long long>>
#define dict unordered_map<long long, long long>
#define contain... |
/**
* Author : Ujjawal Pabreja [cuber_coder]
* Email : ujjawalpabreja99@gmail.com
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
void Solve() {
int n, m;
cin >> n >> m;
vector<int> vis(m);
vector<int> parent(m);
iota(parent.begin(), parent.end(), 0);
... |
#include <bits/stdc++.h>
#define rep(i, l, r) for (register int i = l; i <= r; i++)
#define per(i, r, l) for (register int i = r; i >= l; i--)
#define srep(i, l, r) for (register int i = l; i < r; i++)
#define sper(i, r, l) for (register int i = r; i > l; i--)
#define erep(i, x) for (register int i = h[x]; i; i = e[i].... |
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
typedef long ... |
#include <bits/stdc++.h>
using namespace std;
template<class T, class U>
void ckmin(T &a, U b)
{
if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
if (a < b) a = b;
}
#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se seco... |
#include <bits/stdc++.h>
using namespace std;
#define INF 10000000000000LL
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef pair<ii,ii> ii2;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1LL<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1LL<<(i))))
#define setbit1... |
#include <bits/stdc++.h>
//#include <bits/extc++.h>
#define ll long long
#define ull unsigned ll
#define endl "\n"
#define pb push_back
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define td(v) v.begin(),v.end()
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define per(i,a,n) for (int i=(n-1... |
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<random>
#include<ctime>
#include<vector>
#include<cmath>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=1e6+5,N2=20;
const ll INF=1e18+5;
inline ll read()
... |
// codeforce
// wangqc
#include<iostream>
#include<vector>
using namespace std;
const int M = 1e9+7;
vector<int> p, rk, ans;
int find(int x)
{
return x == p[x] ? x : p[x]=find(p[x]);
}
int connect(int x, int y)
{
int px = find(x), py = find(y);
if(px == py) return false;
if(rk[px] < rk[py]) swap(px... |
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>... |
#include <bits/stdc++.h>
#define endl '\n'
#define all(a) (a).begin(), (a).end()
#define len(a) (int) (a).size()
#define forn(i, n) for (int (i) = 0; (i) < (n); ++(i))
#define int long long
using namespace std;
void solve();
mt19937 rnd(2007);
signed main(){
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freope... |
/*
构造一个正交化的线性基
实现完全正交 is impossible;
退而求之局部正交,即crucial musk不能出现在其他向量中
竟然要用并查集我日你先人(
*/
#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define pb push_back
const int ha = 1e9+7;
inline int add(int x,int y){ x+=y; return x>=ha?x-ha:x;}
inline void ADD(int &x,int y){ x+=y; if(... |
#include "bits/stdc++.h"
using namespace std;
#define rep(i, a, b) for(int i=a; i<=b; i++)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int) x.size()
#define pb push_back
#define f first
#define s second
#define nl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vec... |
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 500000;
const long long modd = 1000000007;
int n, m;
int kk;
int aa[N + 5];
long long anss[N + 5], co = 0;
int ff[N + 5];
struct ab
{
int u;
int v;
} ee[N + 5];
long long qpow(long long a, long long b)... |
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
ll inf = 4e18, mod = 1e9 + 7;
inline ll power(ll x, ll n, ll m = LLONG_MAX)
{
ll res = 1; x = (x % m + m) % m;
while (n)
{ if (n & 1) res = (res * x) % m;
x = (x * x) % m; n >>= 1;
}
return res;
}
int dsu[500005], siz[5... |
#include <bits/stdc++.h>
#define MOD 1000000007
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef vector<ll> dlist;
typedef vector<dlist> matrix;
struct DS{
vector<bool> uni;
vector<int> p, c;
DS(int n): p(n, 0), c(n, 1), uni(n, false){
for(int i = 0; i < n; ++... |
#include <bits/stdc++.h>
#define LL long long
#define rep(i, s, t) for (register int i = (s), i##end = (t); i <= i##end; ++i)
#define dwn(i, s, t) for (register int i = (s), i##end = (t); i >= i##end; --i)
using namespace std;
inline int read() {
int x = 0, f = 1;
char ch = getchar();
for (; !isdigit(ch); ch = getch... |
#include <stdio.h>
#include <vector>
using namespace std;
const int mod = 1e9 + 7;
int p[500001];
int find(int a) {
if (p[a] != a) p[a] = find(p[a]);
return p[a];
}
bool dsu(int a, int b) {
a = find(a); b = find(b);
if (a == b) return 0;
p[b] = a;
return 1;
}
int main() {
int i, n, m;
long long T = 1;
vector<i... |
#include <bits/stdc++.h>
#define int long long
using namespace std;
int MOD=1e9+7;
int id[500005], sz[500005];
int find(int x){
while(x!=id[x]){
id[x]=id[id[x]];
x=id[x];
}
return x;
}
void unite(int i, int j){
int x=find(i), y=find(j);
if(sz[x]<sz[y]) swap(x, y);
sz[x]+=sz[y];
id[y]=x;
}
signed main(){
ios... |
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define int long long
#define ll long long
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define ff first
#define ss second
#define ld long double
#define pii pair<int, int>
#define ... |
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=... |
//int max = 2 147 483 647 (2^31-1)
//ll max = 9 223 372 036 854 775 807 (2^63-1)
#include<bits/stdc++.h>
using namespace std;
#define forn(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define f first
#define s second
#define pb push_back
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
typedef v... |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
struct tr { ll r, s; int i; };
bool g(tr &a, tr &b) {
if(a.r == b.r && a.s == b.s) return a.i < b.i;
else if(a.r == b.r) return a.s > b.s;
else return a.r < b.r;
}
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(null... |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 10;
const int INF = 0x3f3f3f3f;
int t;
int n,m;
ll a[maxn];
ll res[maxn];
ll x[maxn];
int main()
{
cin >> t;
while(t--)
{
cin >> n >> m;
ll sum = 0;
ll ma = 0;
for(int i = 1;i <= n; ++i)
{
cin >> a[i];
sum += a[... |
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(a,b) for(ll i=a;i<b;i++)
#define pii pair<ll,ll>
#define F first
#define S second
#define mp make_pair
#define pb push_back
ll t,n,m,x,y,bal,MX;
vector<ll>a,pre,mx;
ll tell(ll x){
ll st=1,en=n,md,ans=0;
while(st<=en){
md=(st+... |
#include<bits/stdc++.h>
using namespace std;
#define endl ("\n")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ll long long
#define llu long long unsigned
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inpotp freopen("input.txt", "r", stdin); ... |
#include<stdio.h>
#define N 200007
#define ll long long
inline int read(){
int x=0,flag=1; char c=getchar();
while(c<'0'||c>'9'){if(c=='-') flag=0;c=getchar();}
while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+c-48;c=getchar();}
return flag? x:-x;
}
int T,n,m,a[N],top,pos[N];
ll sta[N];
int main(){
T=read();
while(T--){
... |
// Author :: <Hitesh_Saini>
#include<bits/stdc++.h>
#define __speed() ios_base::sync_with_stdio(false), cin.tie(nullptr);
#define dbg(x) cout << "(" << __LINE__ << ": "<< #x << " = " << x << ")\n"
#define Yes(x) print((x) ? "Yes" : "No")
#define tt int t; for (cin >> t; t--; )
#define f0(i, n) for (i = 0; i < (... |
#pragma GCC optimize("Ofast")
#pragma loop_opt(on)
#include<bits/stdc++.h>
#define Rushia_mywife ios::sync_with_stdio(0);cin.tie(0);
#define F first
#define S second
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define FL cout.flush()... |
#include"bits/stdc++.h"
#define int long long
#define mod 1000000007
#define pf push_forward
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define f(i,in,n) for(i=in; i<n; ++i)
#define scant int t,t2055; cin>>t2055;for(t=1;t<=t2055;t++)
using namespace std;
int32_t main() {
ios_base::sync_... |
#include <bits/stdc++.h>
#define fu(i,a,b) for (long long i=a; i<=b; i++)
#define fd(i,a,b) for (long long i=a; i>=b; i--)
using namespace std;
typedef long long ll;
const ll N=2e5+10;
ll n,q,a[N],s[N],ma[N],query[N];
void Solve()
{
cin>>n>>q;
fu(i,1,n)
{
cin>>a[i];
}
fu(i,1,q)
{
... |
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define lln long long int
#define ld long double
#define all(x) (x).begin(),(x).end()
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int MOD = 1e9 + 7;
int main(){
IOS;
int a1;
cin >> a1;
for(int TT=0;TT<a1;TT++){... |
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
typedef long long ll;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 200005;
int n, qq;
int ... |
#include <bits/stdc++.h>
using namespace std;
#define int long long
int get(vector<int> &a, int n, int k)
{
int low = 0, high = n - 1, ans = -1 ;
while (low <= high)
{
int mid = (low + high) / 2;
if (a[mid] >= k)
{
ans = mid + 1;
high = mid - 1;
}
... |
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;
#define St first
#define Nd second
#define Pb push_back
#define print_pair(p) "{" << (p).St << ", " << (p).Nd << "} "
#define list_format(i, n)... |
#include<bits/stdc++.h>
using namespace std;
template <class T> ostream &operator << (ostream &os, const vector<T> &p) { os << "["; for (auto&it : p) os << it << " "; return os << "]";}
template <class S, class T> ostream &operator << (ostream &os, const pair<S, T> &p) { return os << "(" << p.first << "," << p.second <... |
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
using namespace std;
#define ll long long
#define maxn 200005
ll t,n,m,a[maxn],k;
map<ll,ll> v;
ll bs(ll c){
ll l=0,r=k;
while(l<r){
ll m=(l+r)/2;
if(a[m]>=c) r=m;
else l=m+1;
}
if(r==k) return -1;
return v[a[l]];
}
int main(){
cin>>t;
... |
#include <bits/stdc++.h>
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define endl '\n'
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3fLL;
const int MOD = 1000000007;
const int dx[] = { 0, 0, -1, 1, 1, -1, 1, ... |
#include <bits/stdc++.h>
using namespace std;
int main()
{
int tc;cin>>tc;
while(tc--)
{
int n,m;cin>>n>>m;
vector<int> v(n);
for(int i=0;i<n;i++)cin>>v[i];
vector<long long> ps={v[0]}, ix={0};
long long sp=v[0];
for(int i=1;i<n;i++)
{
sp+=v[i];
if(sp>=ps.back()){ps.push... |
#include <bits/stdc++.h>
using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi... |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[200010];
ll x[200010];
ll sa[200010];
ll sama[200010];
int psama[200010];
inline ll read(){
ll f=1,x=0;char ch;
do{ch=getchar();if(ch=='-')f=-1;}while(!isdigit(ch));
do{x=x*10+ch-'0';ch=getchar();}while(isdigit(ch));
return f*x;
}
int main(){
... |
#include<iostream>
#include<algorithm>
using namespace std;
const int N=2e6+5;
typedef long long ll;
long long n,m;
long long a[N],s[N],v[N],id[N];
int main(){
int t;
scanf("%d",&t);
while(t--){
scanf("%lld%lld",&n,&m);
for(int i=0;i<=n;i++)s[i]=v[i]=0;
ll tot=0;
for(int i=1;i<=n;i++){
scanf("%lld",&... |
/***************************/
/** Author : thantrongtri3 */
/***************************/
#include <bits/stdc++.h>
using namespace std;
namespace IO{
void setIn(string s) {freopen(s.c_str(), "r", stdin);}
void setOut(string s) {freopen(s.c_str(), "w", stdout);}
void setIO(string s = ""){
ios_base:... |
#include <iostream>
#include <bits/stdc++.h>
#define IOS \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define endl "\n"
#define int long long
#define all(a) a.begin(), a.end()
#define forn(i, N) for (int i = 0; i < N; i++)
#define forab(i, a, b) for (int i = a; i < ... |
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yes(ans) if(ans)p... |
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, m;
cin >> n >> m;
vector <ll> vec(n);
vector <pair<ll, int>> add;
ll sum1 = 0, sum2 = 0;
for (int i = 0; i < n; ++i) {
cin >> vec[i];
sum1 += vec[i];
if (su... |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+50;
ll n,m,T,a[maxn],sum[maxn],maxx[maxn],ans[maxn];
int main(){
cin>>T;
while(T--){
cin>>n>>m;
for(int i=1;i<=n;i++)cin>>a[i],sum[i]=sum[i-1]+a[i],maxx[i]=max(maxx[i-1],sum[i]);
for(int i=1;i<=m;i++){
ll x;cin>>x;
if(... |
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
//read domain
typedef long long ll;
int dp[200001][2];
void build(int l, int r, vector<int> const &a, vector<int> &d, int curD = 0) {
if (r < l) {
return;
}
if (l == r) {
d[l] = curD;
return;
}
int m = l;
fo... |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int arr[200005];
ll nax,nim;
int n,m;
ll max(ll a,ll b){
return (a<b)?b:a;
}
ll min(ll a,ll b){
return (a<b)?a:b;
}
int main(){
int t;cin>>t;
while(t--){
cin>>n>>m;
ll nax=LONG_MIN;
ll s=0;
set<pair<l... |
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#pragma GCC optimize("O2", "O3", "fast")
#define _9trash no WA
#define ll long long
#define pb push... |
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define all(X) (X).begin(),(X).end()
#define ln "\n"
#define out cout
#define NON_TOGLIERE ios_base::sync_with_stdio(0); cin.tie(0);
#define ll long long
#define VI vector<int>
#define pii pair<int,int>
#define pll pair<long long,long long... |
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef long long LL;
const int N = 200010;
int n, m;
LL a[N];
LL s[N];
struct Stack
{
LL s, id;
}stk[N];
int main()
{
int t;
cin >> t;
while (t -- )
{
... |
//#include <atcoder/all>
//using namespace atcoder;
//using mint = modint;
#include <bits/stdc++.h>
#define int long long
#define sint signed
#define endl "\n" // fflush(stdout);
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define VVi vector<Vi>
#define VVVi vector<VVi>
#define Vm vector<mint>
#define ... |
//in dp prefix suffix sum helps..
#include<iostream>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<stack>
#include <iterator>
#include <map>
#include<list>
#include <fstream>
#include<unordered_map>
#include<set>
#include<queue>
#define int long long
#define double ... |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define t64 int64_t
#define rep(i,a,b) for(int i=a;i<b;i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORe(i,a,b) for(int i=a;i<=b;i++)
#define FORr(i,a,b) for(int i=a;i>b;i--)
#define FORre(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#defi... |
#include <bits/stdc++.h>
#define w(x) int x; cin >> x; while(x--)
#define endl '\n'
#define mod 1000000007
#define ll long long
using namespace std;
ll pow(ll x, ll y, ll p) {
ll res = 1;
x = x % p;
if(x == 0)
return 0;
while(y > 0) {
if(y & 1)
res = (res * x) % p;
... |
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL,LL> PLL;
const int INF = 0x3f3f3f3f, N = 2e5 + 10;
inline int lc(int u) {return u << 1;}
inline int rc(int u) {return u << 1 | 1;}
inline int lowbit(int x) {return x & (-x);}
LL a[N], s[N];
LL mm[N];
struct n... |
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#include <bits/stdc++.h>
using namespace std ;
const int inf = 1e9 ;
const int MAX = 2e5 + 10 ;
long long arr[MAX] ;
int val[MAX] , suff[MAX] ;
int n , q ;
vector<long long>v ;
long long sum = 0 ;
void compress()
{
for(int i = 1 ; i <= n... |
#include <bits/stdc++.h>
#define IO ios_base::sync_with_stdio(false);\
cin.tie(0);\
cout.tie(0)
using namespace std;
typedef long long ll;
const int N = 2e5 + 10;
int t;
int n, m;
ll a[N], b[N];
ll c[N];
int main()
{
IO;
cin >> t;
while(t --)
{
cin >> n >> m;
for(int i = 1; i <= n; i... |
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=3e5+10;
ll sum[maxn];
ll arr[maxn],xrr[maxn];
ll ans[maxn];
#define PII pair<ll,int>
int main()
{
int T;cin>>T;
while(T--)
{
int n,m;cin>>n>>m;
ll mx=-(1e12);
for(int i=1;i<=n;i++) cin>>arr[i];
... |
#include <bits/stdc++.h>
using namespace std;
#define N 200020
int a[N], x[N], y[N];
long long int s[N];
bool cmp(int i, int j) {
return s[i] < s[j];
}
int main() {
int tc;
scanf("%d", &tc);
for(int cc=0; cc<tc; cc++) {
int n, m;
scanf("%d %d", &n, &m);
for(int i=0; i<n; i... |
#include<bits/stdc++.h>
using namespace std;
#define Go_ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pii pair<int ,int>
#define PII pair<ll ,ll>
const int Max=1e9+100;
const ll MAX=1e18+500;
const ll sz=2e5+100;
map<ll,ll> mp;
int ma... |
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////*****************//////////////////////////////////////
typedef long long ll;
ll z=1000000007;
ll fact[400005];
void buildfact()
{
fact[0]=1;
for(ll i=1;i<400005;i++)
{
fact[i]=(fact[i-1]*i)%z;
}
}
ll power(ll a,ll ... |
#include <bits/stdc++.h>
using ll = long long;
char df = '\n';
using namespace std;
void solve() {
int n, m;
cin >> n >> m;
ll A[n], ar[n], mx[n];
for (int i = 0; i < n; i++) cin >> A[i];
ar[0] = A[0];
for (int i = 1; i < n; i++) ar[i] = A[i]+ar[i-1];
mx[0] = ar[0];
for (int i = 1; i < ... |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+10,M=1e9+7,OO=0x3f3f3f3f;
int n;
int arr[N];
ll pre[N];
ll seg[4*N];
void build(int si=0,int ss=0,int se=n-1){
if(ss==se){
seg[si]=pre[ss];
return;
}
int md=ss+(se-ss)/2,lf=si*2+1,rt=si*2+2;
build(lf... |
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i <= (int)n; ++i)
#define forin(i, a, b) for (int i = a; i <= (int)b; ++i)
#define rofin(i, a, b) for (int i = a; i >= b; --i)
#define all(x) (x).begin(), (x).end()
#define sync \
ios::syn... |
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);cout<<setprecision(25);
#define pb push_back
typedef long long int ll;
ll M=1000000007;
using namespace std;
int main()
{
IOS;
ll T;
cin>>T;
while(T--)
{
ll n,m,i,sum=0;
cin>>n>>m;
ll a[n],mx[n],pref[n];
... |
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+200;
typedef long long ll;
ll a[N],b[N];
ll sum[N];
int main()
{
int T;scanf("%d",&T);
while(T--)
{
ll mx=-1e18;memset(sum,0,sizeof sum);
int n,m;scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
for(int i=1;i<=n;i++){sum[i]=sum[i-1]+a... |
/*
** Author: Kartikey Tewari
** Time: 02-04-2021 17:40:25
*/
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
ll tt;
cin >> tt;
for (ll yy=0;yy<=tt-1;yy++)
{
ll n,m;
cin >> n >> m;
vector<... |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 10;
int n,m;
long long sum;
long long a[N];
vector<pair<long long,int>> v;
int minp[N];
long long solve(long long x){
long long maxv = v[v.size() - 1].first;
if(maxv < x && sum <= 0) return -1;
if(x <= maxv){
... |
/// vonat1us
#pragma GCC optimize("O3")
//#pragma comment(linker, "/STACK:36777216")
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
#define all(z) (z).begin(), (z).end()
using namespace std;
using ll = long long;
using pii = pair<int, int>; ... |
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define INF 1e18
#define N 1000005
using namespace std;
void solve()
{
ll n, m;
cin >> n >> m;
... |
#include <bits/stdc++.h>
using namespace std;
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
while(*sdbg!=',')cerr<<*sdbg++;
cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
template<class T> ostream &operator<... |
#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 ff first
#define ss second
#define YES cout << "YES\n"
#define NO cout << "NO\n"
#define nn "\n"
#define sci(x) scanf("%d", &x)
#define LL_INF (1LL << 62)
#d... |
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define fr first
#define sc second
#define pii pair<ll,ll>
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define rep(i,a,b) for(ll i=a;i<b;i++)
// const ll mod = 10... |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef ve... |
#include <bits/stdc++.h>
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
#define maxn 3e5+10
#define inf32 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int,int>pii;
const int MOD=1e9... |
/*
*
* Author: Hsueh-
* Date: 2021-03-05 21:34:52
*
* */
#include <bits/stdc++.h>
using namespace std;
#define dbg(x...) \
do { \
cout << #x << " -> "; ... |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int lim=1e6;int inf=1e8;
ll mod = 1e9+7;
#define ln '\n'
#define forstl(it,v) for(auto &it: v)
#define fi first
#define se second
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterato... |
//**sn0wrus**//
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define fast \
ios_base::sync_with_stdio(false); \
cout.tie(NULL); \
cin.tie(NULL);
#define write(a) \
for (auto x : a) \
{ \
cout <... |
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
#include<set>
#include<complex>
#include<numeric>
#include<functional>
#include<unordered_map>
#in... |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=2e9;
const int maxn=2e5+10;
int t,n,m;
ll tot;
ll a[maxn],sum[maxn];
ll tw[maxn];
int main()
{
ios::sync_with_stdio(false);cin.tie(0);
cin>>t;
while (t--)
{
cin>>n>>m;tot=0;tw[0]=-inf;
for (int i=1;i<=n;i++)
{
cin>>a[i];
t... |
#include <iostream>
#include <vector>
using namespace std;
class MergeSortTree {
private:
int n;
vector<vector<long long> > t;
inline int left(int i) {return i << 1;}
inline int right(int i) {return (i << 1) + 1;}
void merge(int idx) {
const vector<long long> &a = t[left(idx)];
... |
#include<bits/stdc++.h>
using namespace std;
#define LL long long
const int N = 200010;
int n, m;
LL a[N], s[N];
//
int cnt;
LL val[N];
int id[N];
//
LL ans[N];
void solve()
{
//printf("one Test\n");
//input
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; ++i)
scanf("%lld", &a[i]), s[i] = s[i - 1... |
#include <bits/stdc++.h>
#include <unordered_map>
//Author: Maximilian Paris
using namespace std;
typedef long long ll;
vector<pair<ll, ll>> prefix_sorted;
ll compare = 1e18;
struct sort_pred {
bool operator()(const std::pair<int, int>& left, const std::pair<int, int>& right) {
return left.second < right... |
#include<bits/stdc++.h>
#define read(arr, n) vector<int> arr(n); for(int i=0; i<n; i++) cin>>arr[i];
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fr(i, m, n) for(int i=m;i<n;i++)
#define frr(i, a, b) for(int i=a; i>b; i--)
#define w(tt) int tt; cin>>tt; while(tt--)
#define w1... |
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int inf=1000000000;
int g[300000],q[300000],w[300000];
long long h[300000],v[300000];
int i,k,m,n,o,t,l,r,mid;
long long M;
inline bool cmp(int x,int y)
{
return q[x]<q[y];
}
int main()
{
scanf("%d",&t);
for (o=1;o<=t;o++)
{
... |
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
int main()
{
int t; scanf("%d",&t);
while(t--)
{
int n,m; scanf("%d %d",&n,&m);
ll a[n]; for(int i=0;i<n;i++) scanf("%lld",&a[i]);
int b[m]; for(int i=0;i<m;i++) scanf("%d",&b[i]);
vector<... |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define lp3(i,s,n) for(int i = s;i < int(n); ++i)
#define lp(i, n) lp3(i,0,n)
#define pb push_back
#define debug(x) cout<<"[" << #x << " is: " << x << "] "<<endl;
#define file freopen("input.in","r",stdin);
#define fastIO std::ios::sy... |
#include <bits/stdc++.h>
using namespace std;
string to_string(char x) {
string re;
re += '\'';
re += x;
re += '\'';
return re;
}
template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, ... |
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const ll Inf = 1LL << 62;
ll ar[Max];
ll pos[Max];
ll x[Max];
void Solve() {
ll n, m;
cin >> n >> m;
ll sum = 0, mx = -Inf;
for (ll i = 1; i <= n; i++) {
cin >>... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.