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 <cstdio> typedef long long ll; const int MAXN = 2e5 + 19, MAXK = 5; struct Edge{ int to, next; }edge[MAXN << 1]; int head[MAXN], cnt; inline void add(int from, int to){ edge[++cnt].to = to; edge[cnt].next = head[from]; head[from] = cnt; } int n, k; int num[MAXN][MAXK]; ll dp[MAXN][MAXK], ans; void dfs(...
C++
0b4362204bb9f0e95eaf7e2949315c8f
30e3fb5fe7095f77d93e33375b5fe7ab
2,100
PASSED
#include <cstdio> #include <algorithm> typedef long long ll; const int MAXN = 2e5 + 19, MAXK = 1e6 + 19, INF = 0x3f3f3f3f; struct Edge{ int to, next, dist; }edge[MAXN << 1]; int head[MAXN], cnt; inline void add(int from, int to, int dist){ edge[++cnt].to = to; edge[cnt].next = head[from]; edge[cnt].dist = dist...
C++
0b4362204bb9f0e95eaf7e2949315c8f
e0dd886363cecc577c79b43da091737e
2,100
PASSED
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MXN = 2e5 + 5; ll sol; int n, k; ll dp1[MXN][5]; ll dp2[MXN][5]; vector<int> adj[MXN]; void dfs(int x, int p) { dp1[x][0] = 1; for (int y : adj[x]) { if (y == p) continue; dfs(y, x); sol += dp1[x][0] * dp1[y][0]; for (i...
C++
0b4362204bb9f0e95eaf7e2949315c8f
bd2b6f9d0d3adf3bdecebc6c7f023afd
2,100
PASSED
#include <bits/stdc++.h> using namespace std; int N, K; vector<int> graph[200005]; long long dpd[200005][6], dpc[200005][6], tempd[200005][6], tempc[200005][6]; long long ans = 0; void dfs(int n, int p){ dpc[n][0]++; for(int e : graph[n]){ if(e != p){ dfs(e, n); int t = dpc[e]...
C++
0b4362204bb9f0e95eaf7e2949315c8f
af7bbc5f8a3e977b40fb531ce4bacfc9
2,100
PASSED
#include <bits/stdc++.h> using namespace std; const int N = 200005; vector<int> adj[N]; long long int n, k; long long int dp[N][6], cou[N][6], conti[N][6], contic[N][6], tdp[6], tcdp[6], ans; void find_ans(int v, int p) { for (auto it : adj[v]) { if (it != p) { find_ans(it, v); ...
C++
0b4362204bb9f0e95eaf7e2949315c8f
d509be2cc580eb74d3288da5747f7551
2,100
PASSED
#include <bits/stdc++.h> typedef long long ll; typedef long double ld; //#pragma GCC optimize("unroll-loops") //#pragma GCC optimize("Ofast") //#pragma GCC optimize("-O3") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") using namespace std; #define fi first #define se second #defin...
C++
0b4362204bb9f0e95eaf7e2949315c8f
00cf7049b1c1163aaa529d8502c490eb
2,100
PASSED
#pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma") #pragma GCC optimize("unroll-loops") #include<bits/stdc++.h> #define int long long using namespace std; const int N=200005; vector<int>g[N]; int n,k,dp[N][5],ans=0,sz[N]; void dfs(int node,int par) { dp[node][0]...
C++
0b4362204bb9f0e95eaf7e2949315c8f
093dc278ce2bef140a00dfca6a1fc043
2,100
PASSED
#include <bits/stdc++.h> #define ed end() #define bg begin() #define mp make_pair #define pb push_back #define vv(T) v(v(T)) #define v(T) vector<T> #define all(x) x.bg,x.ed #define newline puts("") #define si(x) ((int)x.size()) #define cls(x,v) memset(x,v,sizeof(x)) #define rep(i,n) for(int i=1;i<=n;++i) #define rrep(...
C++
0b4362204bb9f0e95eaf7e2949315c8f
cb2a38529ef92116bc0fb9adc378ea7b
2,100
PASSED
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int,int> pii; typedef pair<ll, ll> pll; typedef vector<pii> vii; typedef vector<pll> vll; #define PB push_back //#define PB emplace_back #define F first #define S second #define MP make_pair ...
C++
0b4362204bb9f0e95eaf7e2949315c8f
81082dd45bf8bb211ed136adfdd9a60d
2,100
PASSED
q = int(raw_input()) handles = {} for i in range(q): oldName, newName = raw_input().split() handles[oldName] =[newName] for name in handles: if (oldName in handles[name]): handles[name].append(newName) del handles[oldName] break print len(handles) for name in handles: print name, h...
Python
bdd98d17ff0d804d88d662cba6a61e8f
638fe451f3dd14f07ae643f3c9ee795c
1,100
PASSED
numSize,zm = input(),{} for i in range(numSize): a,b = raw_input().split() if a in zm: zm[b] = zm[a] del zm[a] else: zm[b] = a print len(zm) for (a,b) in zm.iteritems(): print b,a
Python
bdd98d17ff0d804d88d662cba6a61e8f
86fb01b614acb950d0419894f763408f
1,100
PASSED
n,zm = input(),{} for i in range(n): a,b = raw_input().split() if a in zm: zm[b] = zm[a] del zm[a] else: zm[b] = a print len(zm) for (a,b) in zm.iteritems(): print b,a
Python
bdd98d17ff0d804d88d662cba6a61e8f
cd3700f79a3c8ca0050c5b44dc72db5b
1,100
PASSED
num = int(input()) OLD = list() NEW = list() for i in range(num): x = raw_input("").split(" ") try: c = NEW.index(x[0]) NEW[c] = x[1] except: OLD.append(x[0]) NEW.append(x[1]) print (len(OLD)) for i in range(len(OLD)): print (OLD[i]+" "+NEW[i])
Python
bdd98d17ff0d804d88d662cba6a61e8f
305c70fd0a44d60072b34152fa4df5d5
1,100
PASSED
num = int(input()) oldHandles = list() newHandles = list() for i in range(num): x = raw_input("").split(" ") try: c = newHandles.index(x[0]) newHandles[c] = x[1] except: oldHandles.append(x[0]) newHandles.append(x[1]) print (len(oldHandles)) for i in range(len(oldHandles)): ...
Python
bdd98d17ff0d804d88d662cba6a61e8f
44e18e4a0efc4c9c3d4ae0fce4390aa6
1,100
PASSED
n = int(raw_input()) actual_names_to_original = {} original_to_actual = {} original_change_times = {} original_sequence = [] for i in range(n): str_input = raw_input().split() if (str_input[0] in actual_names_to_original): original = actual_names_to_original[str_input[0]] original_to_actual[or...
Python
bdd98d17ff0d804d88d662cba6a61e8f
75715a32c149f67970d041712de29091
1,100
PASSED
# coding: utf-8 users = {} n = int(raw_input()) for i in xrange(n): old_user, new_user = raw_input().split() if users.has_key(old_user): users[new_user] = users[old_user] users.pop(old_user) else: users[new_user] = old_user print len(users.keys()) for user in users: print users[user], user
Python
bdd98d17ff0d804d88d662cba6a61e8f
b7ba60e6ac9800854916661daf8ba71e
1,100
PASSED
class Stack: def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def push(self, item): self.items.append(item) def pop(self): return self.items.pop() def peek(self): return self.items[len(self.items)-1] def s...
Python
bdd98d17ff0d804d88d662cba6a61e8f
d8d9cfb2e3653741df412bb48e1108a9
1,100
PASSED
#Misha dic = {} usados = [] for i in range(int(raw_input())): antigo, novo = raw_input().split() new = False if novo not in usados: for j in dic: if dic[j] == antigo: new = True dic[j] = novo usados.append(antigo) if not new: ...
Python
bdd98d17ff0d804d88d662cba6a61e8f
41e102ab0df6914612dc7020f80220b2
1,100
PASSED
n = int(raw_input()) dicionario = {} count = 0 for i in xrange(n): atual, novo = raw_input().split() if((not dicionario.has_key(atual))): count += 1 dicionario[novo] = atual else: dicionario[novo] = dicionario[atual] del dicionario[atual] print count #imprimir handles for i in dicionario: print dici...
Python
bdd98d17ff0d804d88d662cba6a61e8f
65b2c13557207338ff0141c056f3f5df
1,100
PASSED
#include<bits/stdc++.h> using namespace std; #define sf scanf #define pf printf #define ll long long #define fr(I,M,N) for(I=M;I<=N;I++) #define fr_(I,M,N) for(I=M;I>=N;I--) #define re return #define sfn cin>>n #define bal pf("bal\n") #define pb push_back #define ins insert #define sz(X) X.size() #define xx first #de...
C++
869f94e76703cde502bd908b476d970e
15960938253e87fb292ae1d448135301
1,900
PASSED
/* Author : Krit Karan Singh Indian Institue Of Information Technology */ #include <bits/stdc++.h> using namespace std; #define _CRT_SECURE_NO_DEPRECATE // suppress some compilation warning messages (for VC++ users) // Shortcuts for "common" data types in contests typedef long long ll; typedef vector<int...
C++
869f94e76703cde502bd908b476d970e
8f85002c731f96620e4803b6664fc12a
1,900
PASSED
/* my general mistakes that costed me a lot * check for overflows * check and mod and use int type variables where possible to avoid tles * while multiplying two variables whose value can exceed integer limt make sure to typecase them * use scanf when you are not ...
C++
869f94e76703cde502bd908b476d970e
c950c38fb8da9ec09e7bd9fe3f04589e
1,900
PASSED
#include<bits/stdc++.h> using namespace std; #define ff first #define ss second #define mp make_pair #define pb push_back #define ll long long int #define pp pair<int,int> #define ve vector #define mod 1000000007 #define mn 100010 int dx[]={-1,-1,+0,+1,1,+1,+0,-1}; // anticlockwise starting from up! int dy[]={+0,-1,-...
C++
869f94e76703cde502bd908b476d970e
18cbde27fad1153dc93aaa142b72bca5
1,900
PASSED
#include <iostream> #include <stdio.h> #include <vector> #include <algorithm> #define MOD 1000000007 using namespace std; vector <int> g[200001]; int tu,w,aaa,tmp[200001]; long long st[200001],dist[200001],r=1,p=1; bool vi[200001]; void dfs(int s,int f) { tu++; vi[s]=true; for(int i=0;i<g[s].size();i++) { if(...
C++
869f94e76703cde502bd908b476d970e
53cdb726a93540a0d80914b1bda6b1e8
1,900
PASSED
#include <cstdlib> #include <cctype> #include <cstring> #include <cstdio> #include <cmath> #include <algorithm> #include <vector> #include <string> #include <iostream> #include <sstream> #include <map> #include <set> #include <queue> #include <stack> #include <fstream> #include <numeric> #include <iomanip> #include <b...
C++
869f94e76703cde502bd908b476d970e
f102e15ef98d2cead1ee7456952ff1d8
1,900
PASSED
#include"stdio.h" #include"iostream" #include"algorithm" #include"cstring" #include"stack" #include"vector" #define MAXN 200100 using namespace std; typedef long long LL; const LL Mod = 1e9+7; int Low[MAXN], DFN[MAXN]; stack<int> s; vector<int> Edge[MAXN]; vector<int> Component[MAXN]; int vins[MAXN]; int Index, Compone...
C++
869f94e76703cde502bd908b476d970e
94a55236cbbe9602b29b5187da74f4aa
1,900
PASSED
#include"stdio.h" #include"iostream" #include"algorithm" #include"cstring" #include"stack" #include"vector" #define MAXN 250000 using namespace std; typedef long long LL; const LL Mod = 1e9+7; int Low[MAXN], DFN[MAXN]; stack<int> s; vector<int> Edge[MAXN]; vector<int> Component[MAXN]; int vins[MAXN]; int Index, Compone...
C++
869f94e76703cde502bd908b476d970e
e96585db2d9926198163d845ffae13af
1,900
PASSED
#include"stdio.h" #include"iostream" #include"algorithm" #include"cstring" #include"stack" #include"vector" #define MAXN 250000 using namespace std; typedef long long LL; const LL Mod = 1e9+7; int Low[MAXN], DFN[MAXN]; stack<int> s; vector<int> Edge[MAXN]; vector<int> Component[MAXN]; int vins[MAXN]; int Index, Compone...
C++
869f94e76703cde502bd908b476d970e
60ee6d5bce2d51b9fe12dd077a5d767a
1,900
PASSED
#include <bits/stdc++.h> using namespace std; int n; int roads[200005]; int visitCounts[200005]; int groups[200005]; int gcts[200005][2]; int fillIn(int pos, int group, bool add) { while(visitCounts[pos] != 2) { if(visitCounts[pos] == 1 && add) { if(groups[pos] != group && group != 0) { break; } } ...
C++
869f94e76703cde502bd908b476d970e
98ae110dd3d6e5b5a7e7c0fdf4e98e58
1,900
PASSED
#include <cstdio> #include <iostream> #include <queue> #include <algorithm> const int N = 2000 + 10; struct node { int x, y; int l, r; }; std::deque <node> q; char a[N][N], vis[N][N]; int f[N][N]; int n, m; int r, c, x, y; int main(void) { std::ios::sync_with_stdio(0); std::cin.tie(0); std::cin >> n >> m; ...
C++
cfdbe4bd1c9438de2d871768c546a580
f24de05d31e27de6806926f4c14835ca
1,800
PASSED
#include<bits/stdc++.h> using namespace std; struct node{ int x,y,lf,rt; }; int n,m,u,v,l,r,ans=0; char c[2005][2005]; deque<node> dq; signed main(){ cin>>n>>m>>u>>v>>l>>r; for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) cin>>c[i][j]; dq.push_back({u,v,l,r}); while(!dq.empty()){ node p=dq.front(); dq.pop_front(); ...
C++
cfdbe4bd1c9438de2d871768c546a580
94b9fa1cc59de801c6cb47ddbdbf5b3d
1,800
PASSED
#include<bits/stdc++.h> using namespace std; #define PI acos(-1) #define hell 1000000007 #define HELL 998244353 #define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) #define fix(n) cout << fixed << setprecision(n) #define mset(a,n) memset(a,n,sizeof a) #define rep(i,a,b) for (__typeof((b)) i=(a);i<(b);i++...
C++
cfdbe4bd1c9438de2d871768c546a580
c865db3f242ed5b217ba74bd40eebd9f
1,800
PASSED
#include <bits/stdc++.h> using namespace std; #define N 2000 int n, m, r, c, pp, qq, vis[N+5][N+5], ans; char a[N+5][N+5]; struct S { int x, y, le, ri; }; void bfs() { deque<S> q; q.push_front(S{r, c, pp, qq}); vis[r][c] = 1; int nx, ny; while(!q.empty()) { S u = q.front(); q.pop_fr...
C++
cfdbe4bd1c9438de2d871768c546a580
e551721eed2dcf2a91fdd7fa3268a181
1,800
PASSED
#include <bits/stdc++.h> using namespace std; int n,m; int xx,yy; int c1,c2; char a[2010][2010]; int book[2010][2010]={0}; struct node{ int x; int y; int n1; int n2; }; int nt[4][2]={1,0,-1,0,0,-1,0,1}; int ans=1; void bfs(){ node p; p.x=xx; p.y=yy; book[xx][yy]=1; // ans=1; ...
C++
cfdbe4bd1c9438de2d871768c546a580
e46dbfacb3a5a67c1bd5418e1047c6d7
1,800
PASSED
#include <bits/stdc++.h> //#define int long long #define ld long double #define y1 sdopgh using namespace std; int n, m, r, c, x, y, used[2005][2005]; char a[2005][2005]; queue <pair <pair <int, int>, pair <int, int> > > q; void dfs(int i, int j, int X, int Y) { if(X<0 || Y<0 || a[i][j]!='.' || used[i][j]==1) ...
C++
cfdbe4bd1c9438de2d871768c546a580
5b7c7e57fcbd3ca44c9e88edfc2c0d12
1,800
PASSED
#include <bits/stdc++.h> #define int long long using namespace std; const int N=2e3; int n,m,x,y,L,R,w[N][N],dx[]={0,0,-1,1},dy[]={-1,1,0,0}; char a[N][N]; priority_queue<pair<int,pair<int,int>>>q; bool check(int x,int y){ return x>=0&&y>=0&&x<n&&y<m; } void bfs(){ while(q.size()){ int x=q.top().second.first,y=q.to...
C++
cfdbe4bd1c9438de2d871768c546a580
e7162afdc57d029873854b0e9969f1e0
1,800
PASSED
#include<bits/stdc++.h> using namespace std; const int maxn = 2e3 + 5; typedef long long LL; char mp[maxn][maxn]; int vis[maxn][maxn]; struct node{ int x, y, l, r; node(int x, int y, int l, int r): x(x), y(y), l(l), r(r) {} }; int n, m; int sn, sm; int x, y; int dx[4] = {0, 0, 1, -1}; int dy[4] = {-1, 1, 0, 0}...
C++
cfdbe4bd1c9438de2d871768c546a580
ad31e6641ffb22213da9fe9762c65430
1,800
PASSED
#include<bits/stdc++.h> using namespace std; const int maxn = 2e3 + 5; typedef long long LL; char mp[maxn][maxn]; int vis[maxn][maxn]; struct node{ int x, y, l, r; node(int x, int y, int l, int r): x(x), y(y), l(l), r(r) {} }; int n, m; int x, y; int dx[4] = {0, 0, 1, -1}; int dy[4] = {-1, 1, 0, 0}; LL bfs(in...
C++
cfdbe4bd1c9438de2d871768c546a580
07f580c82073f2437ba8616a8dd600a3
1,800
PASSED
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <cstdio> #include <algorithm> #include <vector> #include <map> #include <set> #include <bitset> #include <cmath> #include <stack> #include <string> #include <iomanip> #include <queue> #include <deque> #include <cstring> #include <limits> #include <sstream> #i...
C++
cfdbe4bd1c9438de2d871768c546a580
4f6e262e605b9a1cc6634d033e0811f3
1,800
PASSED
#include<bits/stdc++.h> #define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i) using std::cin; using std::cout; typedef unsigned long long u64; typedef double db; typedef long long ll; typedef unsigned u32; const int N = 2020; int n; int p[N], s[N], is[N]; int go[N]; std::vector<std::pair<int, int>> vec; ...
C++
b97db0567760f2fc5d3ca15611fe7177
dbabfa5c7f1d9ebe4998ec62de5e3d41
2,300
PASSED
/* Soheil Mohammadkhani I will change this text here when i've got "Candidate Master":) */ #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> pll; #define all(x) (x).begin(),(x).end() #define X first ...
C++
b97db0567760f2fc5d3ca15611fe7177
8f66e2ce248460b3cb6fa77a6354f415
2,300
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; constexpr int MAXN = 2000; int p[MAXN + 2], s[MAXN + 2], r[MAXN + 2]; vector<pair<int, int>> swaps; int main() { int n; cin >> n; for(int i = 1; i <= n; i++) cin >> p[i]; for(int i = 1; i <= n; i++) cin >> s[i]; for(int i = 1; i <= n; i++...
C++
b97db0567760f2fc5d3ca15611fe7177
770d768f3c9d92540c69b0b9723245b3
2,300
PASSED
#include<bits/stdc++.h> using namespace std; mt19937 rng(time(0)); typedef long long ll; typedef pair<int,int>pii; typedef pair<ll,ll>pll; const ll mod=1e9+7; const int mn=2e3+10; int p[mn],s[mn],bs[mn],bp[mn]; vector<pii>ans; bool vis[mn]; inline int nxt(int i,int n){return ++i==n?0:i;} inline int pre(int i,int n){ret...
C++
b97db0567760f2fc5d3ca15611fe7177
7f6d8f2e01f9e8c3f5754393cf88aad1
2,300
PASSED
#include <bits/stdc++.h> using namespace std; #define pb push_back #define pf push_front #define db pop_back #define df pop_front #define mp make_pair #define ins insert #define ers erase #define F first #define S second #define dbg(x) cerr<< #x << " = " << x << endl #define ddbg(i,x) cerr<< #i << " = " << i << " / "; ...
C++
b97db0567760f2fc5d3ca15611fe7177
e7096a5e27ee1805407985a82cd9b606
2,300
PASSED
//https://codeforces.com/problemset/problem/584/E #include <bits/stdc++.h> using namespace std; #define el '\n' #define pb push_back #define sp ' ' #define all(x) (x).begin(), (x).end() #define mset(x, y) memset(x, y, sizeof(x)) #define ff first #define ss second // clang-format off bool chmin(int& a, int b){ return ...
C++
b97db0567760f2fc5d3ca15611fe7177
3635f7f160da7afb03c26a1361c1ea41
2,300
PASSED
#include <iostream> #include <algorithm> #include <vector> #include <queue> #include <string> #include <cstring> #include <cmath> #include <set> #include <map> #include <cstdio> #include <stdlib.h> #include <stack> #include <numeric> #include <bitset> #include <cctype> #include <list> #include <assert.h> #include <rand...
C++
b97db0567760f2fc5d3ca15611fe7177
4eebb0027c34baa209d5e88e8fef8a1d
2,300
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll N=2005; ll n,idx,p[N],s[N],pos[N],sum; vector< pair<ll,ll> >ans; int main(){ ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin>>n; for(ll i=0;i<n;i++)cin>>p[i],p[i]--; for(ll i=0;i<n;i++)cin>>s[i],s[i]--...
C++
b97db0567760f2fc5d3ca15611fe7177
bca22a786f39d435e0e80fb416ca97f3
2,300
PASSED
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> // Remove GCC optimizer for codechef #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") using namespace std; using namespace __...
C++
b97db0567760f2fc5d3ca15611fe7177
29d4fc0b4f314b04658de58fda407b83
2,300
PASSED
#include<bits/stdc++.h> using namespace std; #define ll long long const int mod = 1e9 + 7; const int N = 5e5 + 10; int arr[N],brr[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int n; cin >> n; f...
C++
b97db0567760f2fc5d3ca15611fe7177
e20029c4b8d2d616051b9a641fc4cf69
2,300
PASSED
// ObtainTwoZeroes.cpp #include <iostream> #include <vector> #include <algorithm> #include <cstring> #include <map> #include <set> #include <unordered_map> #include <queue> #include <stack> #include <cmath> #include <functional> #include <deque> #include <bitset> #include <climits> #include <cstdio> #include <list> #i...
C++
0a720a0b06314fde783866b47f35af81
a85a7689cf0ebc69d4f2bb65bfad8381
1,300
PASSED
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair #define fi first #define se second // Driver code int main() { int t,a,b,d; cin>>t; while(t--) { cin>>a>>b; if(a>b) swap(...
C++
0a720a0b06314fde783866b47f35af81
06b7f36a2f195e935d7e6526de6f7c30
1,300
PASSED
#include<bits/stdc++.h> using namespace std; #define LL long long int #define L long int #define IM INT_MAX #define Im INT_MIN int main(){ int t; LL a,b; cin>>t; for(int i=0;i<t;i++){ cin>>a>>b; if(a>b)swap(a,b); if( (a+b)%3 == 0){ if(a*2>=b){ cout<<"YES"<<endl; } e...
C++
0a720a0b06314fde783866b47f35af81
27153e41167a172efd633588fde432b8
1,300
PASSED
#pragma region template #include <bits/stdc++.h> using namespace std; #define ll long long #pragma region random mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); template <typename T> T randint(T a, T b) { return uniform_int_distribution<T>(a, b)(rng); } #pragma endregion #pragma region debug st...
C++
0a720a0b06314fde783866b47f35af81
648fc43cefc868502641028d72d073a8
1,300
PASSED
#include<bits/stdc++.h> //typedef long long ll; //#define int long long #define F first #define S second #define endl "\n" #define pb push_back #define mp make_pair #define all(x) x.begin(),x.end() #define memset(a,b) memset(a,b,sizeof(a)); #define IOS i...
C++
0a720a0b06314fde783866b47f35af81
34e7746f507f87777c6c5e08d2fcd313
1,300
PASSED
//#pragma GCC optimize(2) //#pragma GCC target ("sse4") #include<bits/stdc++.h> //typedef long long ll; #define ull unsigned long long #define int long long #define F first #define S second #define endl "\n"//<<flush #define eps 1e-6 #define base 131 #define lowbit(...
C++
0a720a0b06314fde783866b47f35af81
42840508ae9199d2e0a45b7df9791187
1,300
PASSED
#include <bits/stdc++.h> using namespace std; const int M=2e5+3; typedef long long ll; #define vll vector<ll> #define vi vector<int > #define pb push_back int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin>>n; for(int i=0;i<n;i++){ int a,b; cin>>a>>b; if(2*a-b<0) {cout<<"NO"<<endl;continue;}...
C++
0a720a0b06314fde783866b47f35af81
ae1aa65d6a241274f9134d1e0ca23801
1,300
PASSED
#include<bits/stdc++.h> typedef long long ll; using namespace std; #define mod 1000000007 int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin>>t; while(t--) { int a,b; cin>>a>>b; if(a<b) swap(a,b); if(a==0) { cout<<"YES"<<endl; contin...
C++
0a720a0b06314fde783866b47f35af81
78092c1f9acd57ee75f95648ae267c45
1,300
PASSED
#include <bits/stdc++.h> using namespace std; //https://codeforces.com/problemset/problem/1260/B int main(int argc, char const *argv[]) { int n; cin >> n; vector<bool> aVec; bool answer; while(n--) { long long num0, num1, a, b, tmp; cin >> num0 >> num1; a = min(num0, num1); b = max(num0, n...
C++
0a720a0b06314fde783866b47f35af81
254af901b56342e3a1c004417f6721fe
1,300
PASSED
#include<bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while(t--) { long long int x,y; cin >> x >> y; if(y<x) swap(x,y); //cout<<x<<y; if((x+y)%3==0) { if(x*2>=y) cout<<"YES"<<endl; else cout<<"NO"<<endl; }...
C++
0a720a0b06314fde783866b47f35af81
d9b20571a4d099345c31b3602d081d81
1,300
PASSED
#include <string> #include <iostream> using namespace std; int main() { int n; int t; string pirmas; string antras; cin >> n; cin >> t; cin >> pirmas; cin >> antras; string galutinis = ""; int vienodu_cnt = 0; int pirmo_cnt = n - t; int antro_cnt = n - t; for (int i = 0; i < n; i++) { if (pirmas[i] ==...
C++
8ba3a7f7cb955478481c74cd4a4eed14
d2d47cc94bb6752a63ffea5cf1471930
1,700
PASSED
#include<iostream> #include<string> #include<cstring> #include<cstdio> using namespace std; char oth1(char x) { if(x!='z') return x+1; else return x-1; } char oth2(char a,char b) { char ma=(a>b)?a:b; char mi=(a>b)?b:a; if(ma!='z') return ma+1; else if(mi!='a') return mi-1; else return ma-1; } int ...
C++
8ba3a7f7cb955478481c74cd4a4eed14
7bb1c82f47ccfc9b2b9827cec6e942c5
1,700
PASSED
#include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, t; cin >> n >> t; t *= 2; string s1, s2, s3; cin >> s1 >> s2; s3.reserve(s1.size()); bool diff = 0; for(auto i = 0; i != s1.size(); i++) { if(s1[i] != s2[i]) { t--; } } for(auto i = 0; i < s...
C++
8ba3a7f7cb955478481c74cd4a4eed14
3153d46a5fbc1b5560141b8e25b24e95
1,700
PASSED
#include<iostream> using namespace std; char str1[100005], str2[100005], str[1000005]; int pos[100005] = { 0 }; int main() { int n, t, k = 0; cin >> n >> t; cin >> str1 >> str2; for (int i = 0; i < n; i++) { if (str1[i] == str2[i]) { pos[i]++; k++; } ...
C++
8ba3a7f7cb955478481c74cd4a4eed14
2d8051b5de6f70ed373ed10b3385741c
1,700
PASSED
#include<iostream> #include<bits/stdc++.h> typedef long long ll; typedef unsigned long long int _ll; using namespace std; #define INF 1LL<<62 #define mod 1000000007 #define mod1 998244353 #define N 500100 #define PI 3.14159265 #define faster ios_base::sync_with_stdi...
C++
8ba3a7f7cb955478481c74cd4a4eed14
4a680542d10e63d4cca62fad5f711dfb
1,700
PASSED
#include <iostream> #include <vector> #include <set> using namespace std; const int MaxN = 100 * 1000 + 100; int n, t; string s1, s2; vector <int> v1;//the indexes at which both strings have the same character vector <int> v2;//the indexes at which strings have the different characters char ans[MaxN]; int ceil(int a...
C++
8ba3a7f7cb955478481c74cd4a4eed14
395aae3da63e8025552372904ac97616
1,700
PASSED
#include <bits/stdc++.h> using namespace std; char getdiff(char a, char b) { if (a > b) swap(a, b); if (b - a == 1) { if (a == 'y' && b == 'z') return 'a'; return 'z'; } else { return char(a + (b - a) / 2); } } int main() { int n, t; cin >> n >> t; string a, b; ...
C++
8ba3a7f7cb955478481c74cd4a4eed14
64b5c680ec05cefb1a82fd642f1c8512
1,700
PASSED
#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> #include <map> #include <unistd.h> using namespace std; char getdiff(char a, char b) { if (a > b) swap(a, b); if (b - a == 1) { if (a == 'y' && b == 'z') return 'a'; return 'z'; } else { ret...
C++
8ba3a7f7cb955478481c74cd4a4eed14
4fba377e334af2f1cf6f186c54a8a497
1,700
PASSED
#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> #include <map> #include <unistd.h> using namespace std; char getdiff(char a, char b) { if (a > b) swap(a, b); if (b - a == 1) { if (a == 'y' && b == 'z') return 'a'; return 'z'; } else { ret...
C++
8ba3a7f7cb955478481c74cd4a4eed14
cc1be691e1673c971bf61ff31037c167
1,700
PASSED
#include <bits/stdc++.h> using namespace std; #define sz(q) (int(q.size())) #define mp make_pair #define pb push_back #define eb emplace_back #define fi first #define se second typedef int64_t LL; typedef pair<int, int> PII; typedef pair<LL, LL> PLL; int main() { int n, t; cin >> n >> t; string a, b;...
C++
8ba3a7f7cb955478481c74cd4a4eed14
20de04bba991abd9251c0491d111be0d
1,700
PASSED
#include<bits/stdc++.h> using namespace std; const int N = 3e5 + 9; struct Basis { vector<int> a; void insert(int x) { for (auto &i: a) x = min(x, x ^ i); if (!x) return; for (auto &i: a) if((i ^ x) < i) i ^= x; a.push_back(x); sort(a.begin(), a.end()); } bool can(int x) { for(auto &i...
C++
0e0f30521f9f5eb5cff2549cd391da3c
3bb66b7f41dd5e0fe37aced11e895796
2,300
PASSED
#include<bits/stdc++.h> using namespace std; const int N = 2e5 + 9; struct Basis { vector<int> a; void insert(int x) { for (auto &i: a) x = min(x, x ^ i); if (!x) return; for (auto &i: a) if((i ^ x) < i) i ^= x; a.push_back(x); sort(a.begin(), a.end()); } bool can(int x) { for(auto &i...
C++
0e0f30521f9f5eb5cff2549cd391da3c
d3943fa6af431625886154f67dce1f55
2,300
PASSED
#include <iostream> #include <stdio.h> #include <vector> #include <random> #include <algorithm> #include <set> #include <cassert> #define prev asdasdjl using namespace std; typedef long long ll; typedef long double dbl; template<class T> void print(vector<T> s){ for (int i = 0; i < s.size(); i++) cout << s[i] ...
C++
0e0f30521f9f5eb5cff2549cd391da3c
374f51b22ae384b1c017eb572d488cd8
2,300
PASSED
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef long double ld; typedef vector<ll> vi; typedef pair<ll, ll> pii; typedef vector<pii> vii; typedef vector<vi> vvi; const int MOD = 1e9 + 7; #define fastIO \ ios_base::sync_with_stdio(false); cin.tie(nullptr); #define endl '\n' #define pb push_...
C++
0e0f30521f9f5eb5cff2549cd391da3c
375e5075fb101cbe0ebcc638635c7609
2,300
PASSED
#include<bits/stdc++.h> using ll = long long; const ll maxn = 25e+5; const ll maxbit = 64; ll a[maxn], b[maxn], p[maxn]; ll r = 0; void linearBasis(ll n) { //构建线性基 memset(p, 0, sizeof(p)); for (ll i = 1; i <= n; i++) { for (ll j = maxbit - 1; j >= 0; j--) { if ((a[i] >> j) & 1) { if (p[j]) a[i] ^= p[j]; ...
C++
0e0f30521f9f5eb5cff2549cd391da3c
e91f503c2087debfacd5794b0cbc5920
2,300
PASSED
#include <bits/stdc++.h> using namespace std; #define ll long long int basis[31]; int sz; void insert(int msk) { for(int i=0;i<31;i++) { if((msk&(1<<i))==0) continue; if(!basis[i]) { basis[i] = msk; ++sz; return; } msk^=basis[i]; } } int main()...
C++
0e0f30521f9f5eb5cff2549cd391da3c
6d88cd34f05e3ce85461a0a5ae1320fb
2,300
PASSED
/* ..... . . . . . . . . . . . . ..... . ..... . . . . . . */ #pragma GCC optimize("Ofast") #pragma GCC optimize("no-stack-protector") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("fast-math") #pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native") #includ...
C++
0e0f30521f9f5eb5cff2549cd391da3c
d2596ee0def5262d139105ad82b41e66
2,300
PASSED
#include <bits/stdc++.h> using namespace std; int b[31]; int gauss(int x) { for(int i=0; i<31; i++) { if(x & 1 << i) { if(b[i]) x ^= b[i]; else { b[i] = x; return 1; } } } return 0; } int main() { int n, sum = 0, ans = 0; scanf("%d", &n); ...
C++
0e0f30521f9f5eb5cff2549cd391da3c
e63f612ce9ae291109126a7b06b92949
2,300
PASSED
#include <bits/stdc++.h> using namespace std; int b[31]; int gauss(int x) { for(int i=0; i<31; i++) { if(x & 1 << i) { if(b[i]) x ^= b[i]; else { b[i] = x; return 1; } } } return 0; } void solve() { int n, sum = 0, ans = 0; scanf("%d", &n)...
C++
0e0f30521f9f5eb5cff2549cd391da3c
1b52d0ce7756e8afd9aae810c93b0623
2,300
PASSED
// In the name of God. // You are all thing and We're nothing. // Ya Ali! #include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 2e5 + 17, lg = 30; struct Gauss{ int a[lg]; Gauss(){ memset(a, -1, sizeof a); } bool add(int x, bool justTest = 0){ for(int i = lg - 1; i >= 0; i--) ...
C++
0e0f30521f9f5eb5cff2549cd391da3c
5d7bddf48afa6e8f425340488e91f126
2,300
PASSED
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int n; long long int a,b; scanf("%d",&n); for(int i=0; i < n; i++) { scanf("%lld%lld",&a,&b); if(a % 2 && b % 2 && a >= b * b) printf("YES\n"); else if(a % 2 == 0 && b % 2 == 0 && a >= b * b)...
C
a4c82fffb31bc7e42870fd84e043e815
f4da956e4f47225281d8c8806ea8dbcc
1,100
PASSED
#include <stdio.h> #include <math.h> int main() { long long int n , k; int t,lim; scanf("%d",&t); while( t--) { scanf("%lld %lld",&n,&k); lim = floor(sqrt(n)); if( n<k || k>lim || (n%2==0 && k==1) ) printf("No\n"); else if(( n%2==0 && k%2==0)||(n%2!=0 && k%2!=0) || (n%2!=0 && k==1...
C
a4c82fffb31bc7e42870fd84e043e815
837605bc43e8aaaf1204d9fa607cb1b9
1,100
PASSED
#include<stdio.h> int main() { int t; scanf("%d",&t); while(t--) { int n,k; scanf("%d %d",&n,&k ); if(k>n/k) printf("No\n"); else if(k<=n/k) if(n%2==0 && k%2==0) printf("Yes\n"); else if(n%2!=0 && k%2!=0) printf("Y...
C
a4c82fffb31bc7e42870fd84e043e815
8a7be59771e3eb8af38e1ac05937e45f
1,100
PASSED
#include<stdio.h> int main() { int t,n,i; unsigned long long int k; scanf("%d",&t); for(i=0;i<t;i++){ scanf("%d",&n); scanf("%llu",&k); if(n>=k*k && (n&1)==(k&1)){ printf("YES\n"); } else printf("NO\n"); } }
C
a4c82fffb31bc7e42870fd84e043e815
8126eb49c5d14e35722f7fe0133f57e6
1,100
PASSED
#include <stdio.h> int main() { int n; scanf("%d", &n); while (n--) { int a, k; scanf("%d%d", &a, &k); printf(k <= a / k && a % 2 == k % 2 ? "YES\n" : "NO\n"); } return 0; }
C
a4c82fffb31bc7e42870fd84e043e815
0a2ba51bd82291492aad93023c138e23
1,100
PASSED
#include <stdio.h> int main(void) { // your code goes here long long int T; scanf("%lld",&T); for (long long int num=1;num<=T;num++) { long long int n,k; scanf("%lld %lld",&n,&k); if(k*k>n) { printf("NO\n"); } else { long long int check=n-k; if((check...
C
a4c82fffb31bc7e42870fd84e043e815
a3cf684e88f83a2e33b1609e802a3f8a
1,100
PASSED
#include <stdio.h> #include <math.h> int main() { int n; scanf("%d", &n); for (int i = 0; i < n; ++i) { long long numero, quantidade; scanf("%lld%lld", &numero, &quantidade); if ((numero + quantidade) % 2 != 0 || quantidade > sqrt(numero)) printf("NO\n...
C
a4c82fffb31bc7e42870fd84e043e815
2beb0be98d669f6f84b9b7ab0ae5e3ec
1,100
PASSED
#include<stdio.h> int main() { long long int n,a,b,c,i; scanf("%lld", &n); for(i=1; i<=n; i++){ scanf("%lld %lld",&a,&b); c=b*b; if(a>=c && (a-c)%2==0){ printf("YES\n"); } else{ printf("NO\n"); } } }
C
a4c82fffb31bc7e42870fd84e043e815
a38bb8eadf3c1c69540f21e688e1291f
1,100
PASSED
#include <stdio.h> #include <math.h> int main() { long long i,j,l,k,t,c,n,m,a; scanf("%lld",&a); for(i=0;i<a;i++) { scanf("%lld %lld",&m,&n); if(n*n<=m && m%2==n%2 ) { printf("YES\n"); } else printf("NO\n"); } return 0; }
C
a4c82fffb31bc7e42870fd84e043e815
740d7f57f0de36e488bb98e5b2b26cdd
1,100
PASSED
#include<stdio.h> int main() { long long int t,n,k; scanf("%lld",&t); while(t--){ scanf("%lld %lld",&n,&k); if(n>=k*k && (n-k)%2==0){ printf("YES\n"); } else{ printf("NO\n"); } } return 0; }
C
a4c82fffb31bc7e42870fd84e043e815
f27fdf6ca87bb14d626561a1ceb1ce96
1,100
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll>PII; const ll inf=0x000FFFFF7FFFFFFF; #define MAX 100005 int main() { ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); ll n,N; int Min; cin>>n; N=0; Min = inf; std::vector<int> a(n); for(auto &x:a) cin>>x,...
C++
ad5ec7026cbefedca288df14c2bc58e5
32dd2e1e5c0421838a8e5b325784ea42
2,500
PASSED
#include<bits/stdc++.h> using namespace std; #define PII pair<int,int> #define f first #define s second #define VI vector<int> #define LL long long #define MP make_pair #define LD long double #define PB push_back #define PLL pair <LL, LL> #define ALL(V) V.begin(),V.end() #define abs(x) max((x),-(x)) #define PDD pair<LD...
C++
ad5ec7026cbefedca288df14c2bc58e5
ba448bd2f09c5d7ed6251708082bfe0e
2,500
PASSED
#include<bits/stdc++.h> #define int long long using namespace std; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,q; cin>>n; int a[n]; int am=0; for (int i=0;i<n;i++) { cin>>a[i]; am+=a[i]; } for (int i=1;i<=40000;i++) { int ans=0; for (int j=0;j<n;j++) { if (i*((...
C++
ad5ec7026cbefedca288df14c2bc58e5
e9b1232abb37dfa27557355c50b11acd
2,500
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> ii; typedef vector<int> vi; const ll oo = (ll)1e18+7; int n, a[505]; ll check(int i) { ll tmp = 0, ret = oo; bool ok = true; if (i == 1) ok = false; else { for (int j = 1; j <= n; ++j) { ...
C++
ad5ec7026cbefedca288df14c2bc58e5
299bd4749986ab357e5bbde0bf7d7090
2,500
PASSED
#include <bits/stdc++.h> using namespace std; #define forn(i, x, n) for (int i = int(x); i <= int(n); ++i) #define for1(i, n, x) for (int i = int(n); i >= int(x); --i) #define F first #define S second #define pb push_back #define MP make_pair typedef long long ll; typedef pair <int, int> PII; typedef long double ld;...
C++
ad5ec7026cbefedca288df14c2bc58e5
a5d48c7f230706da5ed7f62fbc1cac4c
2,500
PASSED
#include<cstring> #include<cstdlib> #include<cstdio> #include<cmath> #include<iostream> #include<algorithm> #define N 510 #define M 510000 #define inf (1ll<<50) #define LL long long using namespace std; LL n,a[N],p[M],pl,A[M],num; LL ans; void pre(LL x) { LL nex; for(LL i=1;i<=x;i=nex+1) { nex=x/(x/i); p[++pl]=x...
C++
ad5ec7026cbefedca288df14c2bc58e5
ff40005d2cdc56587732deaad5fbb3b3
2,500
PASSED
#include<cstdio> #include<algorithm> #include<cstring> const int N = 201010; int q,i,len,j,n; int a[N]; using namespace std; int main(){ scanf("%d",&n); int l=1,r=1000000000; for (i=1;i<=n;i++) scanf("%d",&a[i]); long long ans=1LL<<50; for (i=1;i<=100000;i++){ long long cnt = 0; for (j=1;j<=n;j++) if (a[...
C++
ad5ec7026cbefedca288df14c2bc58e5
49fbaa29f0e99e6319cc57ef3d362212
2,500
PASSED
#include <iostream> using namespace std; #include <bits/stdc++.h> long long ans=1e18; long long max1=1e18; long long int check(int a[],int x,int n,int k){ long long int s=0; for(int i=0;i<n;i++){ int t=ceil((double)a[i]/(x+1)); //cout<<t<<endl; if(x*t<=a[i]){ s+=t; }...
C++
ad5ec7026cbefedca288df14c2bc58e5
f579be5028a99b2707a40af7fd5dd08f
2,500
PASSED
#include <iostream> using namespace std; #include <bits/stdc++.h> long long ans=1e18; long long max1=1e18; long long int check(int a[],int x,int n,int k){ long long int s=0; for(int i=0;i<n;i++){ int t=ceil((double)a[i]/(x+1)); //cout<<t<<endl; if(x*t<=a[i]){ s+=t; }...
C++
ad5ec7026cbefedca288df14c2bc58e5
7acc92c4489b96fb2631c4f61fdc26d3
2,500
PASSED
#pragma region #include <bits/stdc++.h> using namespace std; // Common Type shorteners and int128 using ll = long long; using ull = unsigned long long; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; template <typename T> using vec = vector<T>; template <typename K, typename V> using umap ...
C++
ad5ec7026cbefedca288df14c2bc58e5
7054d68d92c5c43e0b99bf8239d97b6e
2,500
PASSED
from Queue import Queue n = int(raw_input()) list = map(int, raw_input().split()) adj = [] dist = [] for i in xrange(n): adj.append([]) dist.append(10**9) for i in xrange(n-1): adj[i].append(i+1) adj[i+1].append(i) for i in xrange(n): element = list[i] if (element-1 != i and element != 0 and element-2 != ...
Python
d465aec304757dff34a770f7877dd940
87576c2756b9354a9b092324994d4cd5
1,600
PASSED