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
# Main def main(): num_tests = int(input()) for i in range(num_tests): # Get the number of blocks and the box width n, w = map(int,input().split()) # Build the dictionary of blocks # We want this in descending key order, so use a sorted list block_list = list(...
Python
49ba9921ae8b6bc53726e7a521eefe39
33664694977365668f4c5d2a4143dace
1,300
PASSED
# Function to return the largest power of two less than a number def p2(n): return 1<<(n.bit_length()-1) # Main def main(): num_tests = int(input()) for i in range(num_tests): # Get the number of blocks and the box width n, w = map(int,input().split()) # Build the dict...
Python
49ba9921ae8b6bc53726e7a521eefe39
1a47440f6fb5bb18c99a64aa65fef0ed
1,300
PASSED
import sys import math from collections import defaultdict,Counter from itertools import permutations from collections import deque from decimal import Decimal from fractions import Fraction from heapq import heappush , heappop import bisect def sin(): return int(sys.stdin.readline()) def array(): ...
Python
49ba9921ae8b6bc53726e7a521eefe39
ed1bf9c1a723d81f641bd536cb59dac8
1,300
PASSED
import sys def file_io(): sys.stdin = open('input.txt', 'r') sys.stdout = open('output.txt', 'w') def RL(): return [int(x) for x in sys.stdin.readline().split()] def RI(): return int(sys.stdin.readline()) def RS(): return sys.stdin.readline().strip() def print(*s, end='\n'): ...
Python
49ba9921ae8b6bc53726e7a521eefe39
06672f13fbd2cd19704e2b31f0ee5a3c
1,300
PASSED
import math t=int(input()) for i in range(t): n,w=map(int,input().split()) arr=list(map(int,input().split())) count=[0 for j in range(20)] for i in range(n): count[int(math.log2(arr[i]))]+=1 height=0 count=count[::-1] s=sum(count) while s>0: wid=w fla...
Python
49ba9921ae8b6bc53726e7a521eefe39
1653008c1974bacf9796122f58455d4a
1,300
PASSED
from math import ceil def minimal_height(w: int, a: list[int]) -> int: a = sorted(a, reverse=True) total = 0 needed = 1 for x in a: total += x currently_needed = ceil(total / (w - w % x)) needed = max((needed, currently_needed)) return needed def main(): ...
Python
49ba9921ae8b6bc53726e7a521eefe39
ff1d11d7cea6e34b5c5963e06572b66d
1,300
PASSED
def log2(n): if n == 1: return 0 res = 1 p = 2 while p < n: res += 1 p *= 2 return res def solve(): n, w = read_ints() wseq = read_ints() cnt = [0] * (1 + log2(w)) for wi in wseq: cnt[log2(wi)] += 1 m = len(cnt) ans = ...
Python
49ba9921ae8b6bc53726e7a521eefe39
5f7a1ea000a3eae5b9c0cf01b9cb17f9
1,300
PASSED
from math import log2 def solve_tc(): n, w = list(map(int, input().split())) widths = list(map(int, input().split())) counts = [0 for _ in range(20)] for width in widths: counts[int(log2(width))] += 1 space = w height = 1 for it in range(n): largest = -1...
Python
49ba9921ae8b6bc53726e7a521eefe39
5123266f2bd0c76caae3397dd36fddd6
1,300
PASSED
import math def solve(): #n = int(input()) n, W = map(int, input().split()) a = list(map(int, input().split())) done = ans = 0 t = [0] * 21 for i in a: x = int(math.log2(i)) t[x] += 1 while done < n: ans += 1 space = W ...
Python
49ba9921ae8b6bc53726e7a521eefe39
24edae856ec8fddc5d883a8e1c7c8e32
1,300
PASSED
import math def solve(): t = int(input()) while t: t-=1 n = input() b = 0 for c in n: b += int(c) val = math.gcd(int(n),b) if val>1: print(n) else: temp = int(n) while val < 2: ...
Python
204e75827b7016eb1f1fbe1d6b60b03d
b0964708cb42fead0975db53ce72e05a
800
PASSED
######################################### import math as s x = (int(input())) for i in range(x): a = (int(input())) b = str(a) c = 0 for i in range(len(b)): c+=int(b[i]) if (s.gcd(a,c))>1: print(a) ############################# else: ...
Python
204e75827b7016eb1f1fbe1d6b60b03d
fa2c6b8ee4fd4337a2244065acad2100
800
PASSED
from sys import stdin input = stdin.readline def ii(): return int(input()) def li(): return list(map(int, input().split())) def sumd(n): ans=0 for i in str(n): ans+=int(i) return ans from math import gcd for _ in range(ii()): n=ii() if gcd(n,sumd(n)) > 1 : ...
Python
204e75827b7016eb1f1fbe1d6b60b03d
0b9071b8386e2781a6dffa3114bfb673
800
PASSED
import math n1 = int(input()) list1 = [] for i in range(n1): list1.append(int(input())) b1 = False k1 = 0 while b1==False: if k1==len(list1): break c1 = False ref_int = list1[k1] temp1 = ref_int while c1==False: ref_sum = 0 for i in str(temp1): ...
Python
204e75827b7016eb1f1fbe1d6b60b03d
52664769dd30a73cda0bfceb40e266eb
800
PASSED
n = int(input()) def gcd_sum(a, b): while True: for i in range(2, b+1): if a % i == 0 and b % i == 0: return a a += 1 new_num = str(a) b = sum(map(int, new_num)) for i in range(n)...
Python
204e75827b7016eb1f1fbe1d6b60b03d
fc2e883861de77f4a589b163ea9f379e
800
PASSED
from math import gcd def digits_sum(n: int) -> int: total = 0 while n != 0: total += n % 10 n //= 10 return total def gcd_sum(n: int) -> int: return gcd(n, digits_sum(n)) def smallest_gcd_sum(n: int) -> int: while gcd_sum(n) == 1: n += 1 return n ...
Python
204e75827b7016eb1f1fbe1d6b60b03d
922f75a7422fb38e476adab29db1e577
800
PASSED
import math def sum(n): s = str(n) su = 0 for i in range(len(s)): su += int(s[i]) # print(su) return su for t in range(int(input())): n = int(input()) flag = True while flag: m1 =sum(n) m = math.gcd(n, m1) if m == 1: ...
Python
204e75827b7016eb1f1fbe1d6b60b03d
5e281228700c97da91f85bd75f13a188
800
PASSED
import sys import math import random input = sys.stdin.readline def s(n): p = str(n) ans = 0 for i in range(len(p)): ans += int(p[i]) return ans for _ in range(int(input())): n = int(input()) for i in range(n, n + 3): if math.gcd(i, s(i)) > 1: print(i) ...
Python
204e75827b7016eb1f1fbe1d6b60b03d
95957e7b96974cba2938d875534d7b05
800
PASSED
import os, sys from io import BytesIO, IOBase from collections import defaultdict, deque, Counter from bisect import bisect_left, bisect_right from heapq import heappush, heappop from functools import lru_cache from itertools import accumulate import math import sys # sys.setrecursionlimit(10 ** 6) # Fast...
Python
204e75827b7016eb1f1fbe1d6b60b03d
cf905127c8ef35521cc6cb189c5a777e
800
PASSED
import math from math import gcd a = int(input()) for i in range(a): b = int(input()) while gcd(b , sum(list(map(int,str(b))))) == 1: b += 1 print(b)
Python
204e75827b7016eb1f1fbe1d6b60b03d
aa8ce702897f3d3a7a4afe9dfc0a6118
800
PASSED
#include <bits/stdc++.h> #define sz(x) (int)(x).size() #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define uid uniform_int_distribution #define uint unsigned int #define ld long double #define ll long long #define pii pair<int, int> #define pll pair<ll, ll> #define ar array #define...
C++
90a9d883408d5c283d6e7680c0b94c8b
61246e1c9baef8e991c934c80da48b59
2,200
PASSED
#include <iostream> #include <algorithm> #include <iomanip> #include <vector> #include <queue> #include <deque> #include <set> #include <map> #include <tuple> #include <cmath> #include <numeric> #include <functional> #include <cassert> #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x...
C++
90a9d883408d5c283d6e7680c0b94c8b
c4870300102bf47915c8fb2445e130e3
2,200
PASSED
#include<bits/stdc++.h> using namespace std; bool ask(int u,int v){ cout << "? " << u << ' ' << v << '\n'; fflush(stdout); string s; cin >> s; if(s=="Yes"){return true;} return false; } void ans(int u,int v){ cout << "! " << u << ' ' << v << '\n'; fflush(stdout); } using pi=pair<in...
C++
90a9d883408d5c283d6e7680c0b94c8b
8d3103f379d4ed17aeeba0f9cd3838b2
2,200
PASSED
#include <bits/stdc++.h> // #define endl '\n' #define x first #define y second #define ls (id << 1) #define rs (id << 1 | 1) #define mid (l + r >> 1) #define yes cout << "YES\n" #define no cout << "NO\n" #define ios ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) using namespace std; typedef long long l...
C++
90a9d883408d5c283d6e7680c0b94c8b
1f77c2e6bb45cd8be87cf3e3f2c6050a
2,200
PASSED
#include <bits/stdc++.h> using namespace std; #define MAXN 100001 #define ll long long #define MOD 1000000007 //#define MOD 998244353 #define INFLL 1000000000001000000LL #define INFI 1001000000 #define pii pair<int,int> #define pll pair<ll,ll> #define fi first #define sc second #define m_p make_pair #define p_b push_b...
C++
90a9d883408d5c283d6e7680c0b94c8b
bd4a6f366ef4765cc7b1ee63f7042c9b
2,200
PASSED
// author : sentheta aka vanwij #include<iostream> #include<iomanip> #include<algorithm> #include<cassert> #include<random> #include<chrono> #include<cmath> #include<string> #include<vector> #include<bitset> #include<queue> #include<stack> #include<map> #include<set> using namespace std; #define Int long long #define ...
C++
90a9d883408d5c283d6e7680c0b94c8b
3735d74a0c1cde06fe9322ee2cc858c8
2,200
PASSED
// author : sentheta aka vanwij #include<iostream> #include<iomanip> #include<algorithm> #include<cassert> #include<random> #include<chrono> #include<cmath> #include<string> #include<vector> #include<bitset> #include<queue> #include<stack> #include<map> #include<set> using namespace std; #define Int long long #define ...
C++
90a9d883408d5c283d6e7680c0b94c8b
13b92d8ed51189d61065b18e3bb96cb2
2,200
PASSED
/* * File created on 03/17/2022 at 18:15:33. * Link to problem: * Description: * Time complexity: O() * Space complexity: O() * Status: --- * Copyright: Ⓒ 2022 Francois Vogel */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <functi...
C++
90a9d883408d5c283d6e7680c0b94c8b
4a05d362a623b17b25bd9fd49b53bb38
2,200
PASSED
/* * File created on 03/17/2022 at 18:15:33. * Link to problem: * Description: * Time complexity: O() * Space complexity: O() * Status: --- * Copyright: Ⓒ 2022 Francois Vogel */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <functi...
C++
90a9d883408d5c283d6e7680c0b94c8b
33f63dee58ea8a3768bddec80e90ef3b
2,200
PASSED
//https://codeforces.com/blog/entry/96344 //#pragma GCC optimize("O3,unroll-loops") //#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include <iostream> #include <iomanip> #include <algorithm> #include <cmath> #include <vector> #include <list> #include <set> #include <map> #include <unordered_set> #include <unordered...
C++
90a9d883408d5c283d6e7680c0b94c8b
ada8ec4d2542e557eb600cf3e58762d2
2,200
PASSED
#include<bits/stdc++.h> #define pb push_back using namespace std; int main(){ int t; cin>>t; while(t--){ int n,m; cin>>n>>m; int a[n],b[n],c[m],res[m]={0}; vector<int>v[n+1]; int f=0; for(int i=0;i<n;i++)cin>>a[i]; for(int i=0;i<n;i++)cin>>b[i]; for(int i=0;i<m;i++)cin>>c[i]; for(int i=0;i<n;i++)if...
C++
a350430c707bb18a146df9f80e114f45
1ce9b3bfd7451ff727a8be67928951ac
1,600
PASSED
#include<bits/stdc++.h> using namespace std; #define se second #define fi first #define LINF 0x3f3f3f3f3f3f3f3f #define endl "\n" #define INF 0x3f3f3f3f #define pii pair<int,int> #define ll long long const int N=400006; const int mod=1000000007; int a[N],b[N],c[N],ans[N]; vector<int>vec[N]; int last[N]; void solve(){ ...
C++
a350430c707bb18a146df9f80e114f45
01316766a09be48303e9288bdfa3b4bc
1,600
PASSED
#include<bits/stdc++.h> #define Fast_IO std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define endl '\n' using namespace std; using ll = long long; const int maxn =1e5+10; const int mod = 998244353; int n,m,k,_________; int a[maxn],b[maxn],c[maxn],ans[maxn]; vector<int>g[maxn]; void solve(){ cin>>n>>m; ...
C++
a350430c707bb18a146df9f80e114f45
0c3d7514d0033f3f7d3a0518711a47ce
1,600
PASSED
#include <stdio.h> #include <iostream> #include <fstream> #include <string> #include <cstring> #include <time.h> #include <algorithm> #include <vector> #include <queue> #include <unordered_set> #include <set> #include <map> using namespace std; int t; int n, m; int a[100010], b[100010], c[100010]; vector<int> g[100010]...
C++
a350430c707bb18a146df9f80e114f45
28953cd71cb00f52c38a1c270a7989a2
1,600
PASSED
#include<bits/stdc++.h> #define x first #define y second using namespace std; typedef long long ll; typedef pair<int,int>PI; const int N=1e5+5; int T,n,m; int a[N],b[N],c[N],ans[N],in[N]; bool vis1[N],vis2[N]; queue<int>q[N]; void init(){ for(int i=1;i<=n;i++){ while(!q[i].empty()) q[i].pop(); } } int m...
C++
a350430c707bb18a146df9f80e114f45
a57928b45e36aac8fddcc29cdb41e76b
1,600
PASSED
#include <iostream> #include <cstdio> #include <vector> #include <cstring> using namespace std; const int MAXN = 1e5+7; vector <int> v[MAXN]; int fin[MAXN],a[MAXN],b[MAXN],pos[MAXN],ans[MAXN],x[MAXN],num[MAXN],n; int getpos(const int col){ if(v[col].size() < num[col])return fin[col]; if(v[col].size() != num[col])retu...
C++
a350430c707bb18a146df9f80e114f45
796eee5f21a0b80f9011a17d513b9920
1,600
PASSED
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<vector> #include<string> #include<cstdlib> #include<cmath> #include<map> #include<queue> #include<set> #include<unordered_set> #include<unordered_map> #include<stack> #include<climits> using namespace std; #define dbg(x) cout << #x << " ...
C++
a350430c707bb18a146df9f80e114f45
ade0a8c9f1bcef302fe145c004edcf0d
1,600
PASSED
#include<iostream> #include<cstdio> #include<algorithm> #include<cmath> #include<string> #include<cstdlib> #include<cstring> #include<stack> using namespace std; typedef long long ll; int n; int a[100005]={0},b[100005]={0},c[100005]={0}; int opera[100005]={0}; stack<int>f[100005]; bool have[100005]; int main() { ...
C++
a350430c707bb18a146df9f80e114f45
5936f83543e4cc379f88091e0573601c
1,600
PASSED
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll t,n,m,a[100009],b[100009]; void solve() { cin>>t; while(t--) { cin>>n>>m; vector<ll> dif[n+3],same(n+2); ll diff=0; for(ll i=1;i<=n;i++) scanf("%lld",&a[i]); for(ll i=1;i<=n;i++) { ...
C++
a350430c707bb18a146df9f80e114f45
32e709b0bf90df71d1e07e40f260e5ff
1,600
PASSED
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll t,n,m,a[100009],b[100009]; void solve() { cin>>t; while(t--) { cin>>n>>m; vector<ll> dif[n+1],same(n+1); ll diff=0; for(ll i=1;i<=n;i++) scanf("%lld",&a[i]); for(ll i=1;i<=n;i++) { ...
C++
a350430c707bb18a146df9f80e114f45
b671db1ddbb4941786ed2aae95fbcad1
1,600
PASSED
#include <bits/stdc++.h> using namespace std; // 记得关注题目数据, h[i] <= 100, n <= 100, 所以k>= 1e4的时一定都能走过去了 void solve() { int n, K; cin >> n >> K; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } for (int k = 0; k < K; k++) { int i = 0; while (i < n - 1 && a[i]...
C++
32855bb8ba33973178fde7c3d0beb2ce
d12460c205f9d4aadfdb7a8b5e26a62f
1,100
PASSED
#include <bits/stdc++.h> #include <iostream> #define ll long long #define IOS ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr); using namespace std; void solve() { ll n, k; cin >> n >> k; vector<int> v(n); for (int i = 0; i < n; i++) { cin >> v[i]; } ll lastPos; whi...
C++
32855bb8ba33973178fde7c3d0beb2ce
4ee4f8e1c3801d7fdf3f7f6d1b99a4a9
1,100
PASSED
#pragma region head #include <algorithm> #include <bitset> #include <cassert> #include <cctype> #include <cmath> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <stack> #include <string> #include <...
C++
32855bb8ba33973178fde7c3d0beb2ce
b72731c87e4bf1627b2f851cb7d6d0bb
1,100
PASSED
#include<bits/stdc++.h> #define EslamAhmed171 ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define endl "\n" #define pp push_back #define ll long long #define ld long double #define ull unsigned long long #define pii pair<int,int> #define vi vector<int> #define vii vector<pii> #define all(x) (x).begin(), (x).end()...
C++
32855bb8ba33973178fde7c3d0beb2ce
16091233d6f01caf564bee37df2bbc95
1,100
PASSED
#include<iostream> #include<queue> #include<deque> #include<cstdio> #include <stdlib.h> #include<memory.h> #include<algorithm> #include<cstring> #include<stack> #include<cmath> #include<map> #define ll long long #define inf 0x3f3f3f3f #define endl "\n" #define IOS ios::sync_with_stdio(false); using namespace std; int ...
C++
32855bb8ba33973178fde7c3d0beb2ce
880e7bfeae3ff19e6b5a5876e076ba52
1,100
PASSED
#include <iostream> #include <cmath> #include <algorithm> #include <cstring> #include <vector> #include <stack> #include <cstdio> #include <queue> #define IOS std::ios::sync_with_stdio(false); #define ll long long //#define int ll using namespace std; int vis[100005]; int a[100005]; int main() { //signed main() { ...
C++
32855bb8ba33973178fde7c3d0beb2ce
95c9a8423f9e477b6b7ff2f190b68212
1,100
PASSED
#include <iostream> #include <algorithm> #include <cstring> #include <cmath> using namespace std; typedef long long ll; int a[200]; int main() { int t; cin>>t; int n,k; while(t--) { int ans=1; cin>>n>>k; for(int i=1; i<=n; i++) { cin>>a[i]; } ...
C++
32855bb8ba33973178fde7c3d0beb2ce
ffd3ac81fb460a8241cdd501c626b633
1,100
PASSED
#include <bits/stdc++.h> using namespace std; int main(){ int cases; cin>>cases; for(int z=0; z<cases; z++) { int n,k; cin>>n>>k; int a[n]; for(int i=0;i<n;i++){ cin>>a[i]; } int index; for(int i=0;i<min(k,10000);i++){ int j=1; while(j<n && a[j]<=a[j-1]){ j++; } if(j==n){ index=...
C++
32855bb8ba33973178fde7c3d0beb2ce
0b3b082eaa619286b5fbbc8f6609d277
1,100
PASSED
#include<bits/stdc++.h>//I New Colony using namespace std;//如果下面一个数大于前面的一个数,那么这个增量就留在前面那个数上面,前面的那个数自增1 int a[1010010]; int b[1010100]; int main(){ int t; cin>>t; while(t--){ int n,m; int cnt=0; cin>>n>>m; for(int i=1;i<=n;i++)cin>>a[i]; int ju=1; while(ju){ ju=0; for(int i=1;i<n;i++){ if(a[i...
C++
32855bb8ba33973178fde7c3d0beb2ce
b0ac988c2d1e37c7777173f947358f62
1,100
PASSED
#include<iostream> #include<algorithm> using namespace std; int a[110]; int n; int turn() { //不能到n for (int i = 1; i < n; i++) { if (a[i] < a[i + 1]) { a[i]++; return i; } } return -1; } int main() { int t; cin >> t; while (t--) { int pos = 1; int k; cin >> n >> k; for(int i=1;i<=n;i++) {...
C++
32855bb8ba33973178fde7c3d0beb2ce
57f90b449b993fdbdf0743a9fc94433f
1,100
PASSED
#include<bits/stdc++.h> #define ll long long #define db long double #define pii pair<ll,ll> #define lowbit(x) x&-x #define u64 unsigned long long using namespace std; const int mod = 1e9 + 7; //const int maxn = inline ll read() { ll x=0,f=1; char c=getchar(); while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar(...
C++
65a64ea63153fec4d660bad1287169d3
e1a1d8c8c2fe0d9e31c3e6845b2c865a
800
PASSED
#include<bits/stdc++.h> #define F first #define S second #define fast ios_base::sync_with_stdio(0);cin.tie(); #define pb push_back #define bp pop_back #define pp pair<int,int> #define sf(n) scanf("%d", &n) #define sff(n,m) scanf("%d%d",&n,&m) #define sfl(n) scanf("%I64d", &n) #define sffl(n,m) scanf("%I64d%I64d",&n,&m)...
C++
65a64ea63153fec4d660bad1287169d3
86b2837d2041d9962988b71d35f6ecc8
800
PASSED
#include<bits/stdc++.h> using namespace std; void solve(){ //Input int x , y; cin >> x >> y; string s; cin >> s; //Solution map<char , int > mp; for(int i = 0 , len = s.size() ; i < len ; ++i){ mp[s[i]]++; } if(x >= 0 && y >= 0 && mp['R'] >= x && mp['U'] >= y){ ...
C++
65a64ea63153fec4d660bad1287169d3
c66cf239344a6b7876a8f443b1e78ea1
800
PASSED
#include<bits/stdc++.h> #define EslamAhmed171 ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define endl "\n" #define pp push_back #define ll long long #define ld long double #define ull unsigned long long #define pii pair<int,int> #define vi vector<int> #define vii vector<pii> #define all(x) (x).begin(), (x).end()...
C++
65a64ea63153fec4d660bad1287169d3
4fd8af2ffa5117a62d25e0d35ef150f6
800
PASSED
#include<iostream> #include<cstdio> #include<map> #include<vector> #include<algorithm> using namespace std; const int N=1e5+10; int n,t; int a[N]; string s; int main() { scanf("%d",&t); int x,y; while(t--) { scanf("%d%d",&x,&y); cin>>s; int n=s.size(); int zx=0,zy=0,fx=0,...
C++
65a64ea63153fec4d660bad1287169d3
46e12017780078f92490d01fe5588f51
800
PASSED
#include<iostream> #include<cstdio> #include<cmath> #include<queue> #include<vector> #include<string> #include<cstring> #include<map> #include<stack> #include<algorithm> using namespace std; const int N = 1e6; typedef long long ll; int main() { int t; cin >> t; while (t--) { ll x, y, cnt1 = 0, cnt2 = 0, cnt3 = 0, ...
C++
65a64ea63153fec4d660bad1287169d3
e41dc57e5b8124405902ac858eee8837
800
PASSED
#include <bits/stdc++.h> using namespace std; int main() { int t, x, y, up, down, left, right; bool flag; string s; cin >> t; while (t--) { up = down = left = right = 0; cin >> x >> y >> s; for (char c : s) { switch(c) { case 'U': ++up; bre...
C++
65a64ea63153fec4d660bad1287169d3
263e3fdac92790c122f7856b584dcd73
800
PASSED
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5+10; int t,px,py; string s; int main() { cin>>t; while(t--) { cin>>px>>py; cin>>s; int len = s.length(); int cx,cy; int dx,dy; cx = cy = dx = dy = 0; for(int i=0;i<len;i++) { if(...
C++
65a64ea63153fec4d660bad1287169d3
5c3fc4a6e7aa23e826a641aac725a7be
800
PASSED
#include<bits/stdc++.h> using namespace std; #define inf 0x3f3f3f3f #define IO ios::sync_with_stdio(false) #define bug cout << "-----\n" typedef long long ll; int Mod = 998244353; const int N = 200100; const int M = 500010; char s[N]; int main() { int T,i,j,n,m; cin >> T; while(T--) { int x,y,flag = 0; cin >> x ...
C++
65a64ea63153fec4d660bad1287169d3
79abf8e74136b29665c0ea17e6577040
800
PASSED
#include <iostream> #include <cstdio> #include <cstring> #include <string> #include <algorithm> #include <cmath> const int N = 1e5 + 10; using namespace std; int main() { int t; cin >> t; while (t--) { int x, y, u = 0, d = 0, r = 0, l = 0; char s[N]; scanf("%d%d", &x, &y); scanf("%s", s); f...
C++
65a64ea63153fec4d660bad1287169d3
a915aa75f16b00115a3a0be93944084d
800
PASSED
/* * File created on 12/30/2021 at 11:34:43. * Link to problem: * Description: * Time complexity: O() * Space complexity: O() * Status: --- * Copyright: Ⓒ 2021 Francois Vogel */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <functi...
C++
ed4693d015c9125ae77b9bca0139a135
40b11d45009ca3a0439df9cdb6230d98
2,500
PASSED
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(x, y, z) for (int x = y; x <= (z); x++) #define rep1(x, y, z) for (int x = y; x < (z); x++) #define dep(x, y, z) for (int x = y; x >= (z); x--) #define dep1(x, y, z) for (int x = y; x > (z); x--) #define sz(x) ((int)x.size()) #def...
C++
ed4693d015c9125ae77b9bca0139a135
f92bd159cd818621adb1adc5c3b595a8
2,500
PASSED
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(x, y, z) for (int x = y; x <= (z); x++) #define rep1(x, y, z) for (int x = y; x < (z); x++) #define dep(x, y, z) for (int x = y; x >= (z); x--) #define dep1(x, y, z) for (int x = y; x > (z); x--) #define sz(x) ((int)x.size()) #def...
C++
ed4693d015c9125ae77b9bca0139a135
3c0b5bdc12c35b1b58bc043ce1b95111
2,500
PASSED
/** * author: magnus_hegdahl * created: 05.11.2022 19:50 * problem: E. Sorting Books * url: https://codeforces.com/contest/1481/problem/E */ #include <bits/stdc++.h> using namespace std; int main() { cin.tie(nullptr)->sync_with_stdio(false); int n; cin >> n; vector<int> a(n); for (int &x : a) cin...
C++
ed4693d015c9125ae77b9bca0139a135
14279c0c871ff7995ad76a9fc43da78a
2,500
PASSED
/** * author: magnus_hegdahl * created: 05.11.2022 19:50 * problem: E. Sorting Books * url: https://codeforces.com/contest/1481/problem/E */ #include <bits/stdc++.h> // <range_queries/segtree.hpp> #include <cassert> #include <type_traits> #include <vector> template<class S, class F = std::nullptr_t> struct S...
C++
ed4693d015c9125ae77b9bca0139a135
d0e582827fa49ec97d607822e40259eb
2,500
PASSED
/** * author: magnus_hegdahl * created: 05.11.2022 19:50 * problem: E. Sorting Books * url: https://codeforces.com/contest/1481/problem/E */ #include <bits/stdc++.h> // <range_queries/segtree.hpp> #include <cassert> #include <type_traits> #include <vector> template<class S, class F = std::nullptr_t> struct S...
C++
ed4693d015c9125ae77b9bca0139a135
c4da6acc0b103b16b7c6bf836f4684cd
2,500
PASSED
/** * author: magnus_hegdahl * created: 05.11.2022 19:50 * problem: E. Sorting Books * url: https://codeforces.com/contest/1481/problem/E */ #include <bits/stdc++.h> // <range_queries/segtree.hpp> #include <cassert> #include <type_traits> #include <vector> template<class S, class F = std::nullptr_t> struct S...
C++
ed4693d015c9125ae77b9bca0139a135
221ee587d80be0eb82af2dc05e3857aa
2,500
PASSED
#include<bits/stdc++.h> using namespace std; int n; int a[500005],L[500005],R[500005],tot[500005]; int dp[500005]; int tree[2000005]; void change(int k,int l,int r,int x,int y){ if(l==r){ tree[k]=y; return; } int mid=l+r>>1; if(x<=mid)change(k*2,l,mid,x,y); else change(k*2+1,mid+1,r,...
C++
ed4693d015c9125ae77b9bca0139a135
17a694ac277ea52296f3046458cd7bcb
2,500
PASSED
#include<bits/stdc++.h> using namespace std; int n; int a[500005],L[500005],R[500005],tot[500005]; int dp[500005]; int tree[2000005]; void change(int k,int l,int r,int x,int y){ if(l==r){ tree[k]=y; return; } int mid=l+r>>1; if(x<=mid)change(k*2,l,mid,x,y); else change(k*2+1,mid+1,r,...
C++
ed4693d015c9125ae77b9bca0139a135
c139c713350ff4dcfbdcc412f9da9862
2,500
PASSED
#include<bits/stdc++.h> using namespace std; int n; int a[500005],L[500005],R[500005],tot[500005]; int dp[500005]; int tree[2000005]; void change(int k,int l,int r,int x,int y){ if(l==r){ tree[k]=y; return; } int mid=l+r>>1; if(x<=mid)change(k*2,l,mid,x,y); else change(k*2+1,mid+1,r,...
C++
ed4693d015c9125ae77b9bca0139a135
4815e0d0d21eb7777b507439b9024d88
2,500
PASSED
/* Code by Reyaan Jagnani (reyaan44) */ #include<bits/stdc++.h> #define ll long long int #define ld long double #define ff first #define ss second #define all(x) (x).begin(), (x).end() #define scanit(a,n) for(ll indexaa=0; indexaa<n; indexaa++) cin>>a[indexaa]; #define printit(a,n) for(ll indexaa=0; indexaa<n; ...
C++
79b629047e674883a9bc04b1bf0b7f09
df9bf6d90ff213d8b5ed308033d29efe
2,000
PASSED
/* coded by apoorv_me */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; template<class T> using minheap = priority_queue<T,vector<T>,greater<T> >; template<class T> using ordered_set = tree<T, nul...
C++
79b629047e674883a9bc04b1bf0b7f09
71d778f2f9e87f160fb7335e4be01b3a
2,000
PASSED
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; #pragma GCC optimize ("Ofast") #define int ll #define double ld const int inf = 2e9; const int INF = 4e18; const int mod = 1e9+7; #define F first #define S second #define vi vector<int> #define vvi vector<v...
C++
79b629047e674883a9bc04b1bf0b7f09
f2bac317538c1c4ce4c1cba51ad04c36
2,000
PASSED
#include<bits/stdc++.h> using namespace std ; #define ll int #define pb push_back #define __ ios_base::sync_with_stdio(false); cin.tie(NULL); void vin(vector<ll> &v) {for (auto &it : v) cin>> it ;} const ll N = 1e3 + 8 ; vector<vector<ll>> adja , adjb ; int n , m; vector<char> color; vector<int> parent;...
C++
79b629047e674883a9bc04b1bf0b7f09
86610d848c211a8ae737a99854c709a6
2,000
PASSED
// LUOGU_RID: 90324143 #include<bits/stdc++.h> #define endl '\n' using namespace std; typedef long long LL; const int N = 1e3 + 5; int n, m; char g[N][N]; void Solve() { cin >> n >> m; if (n == 1) { cout << "NO\n"; return; } for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) ...
C++
79b629047e674883a9bc04b1bf0b7f09
700c95b855e0cb5df3baa7f62580ee73
2,000
PASSED
#include<bits/stdc++.h> #define endl '\n' using namespace std; typedef long long LL; const int N = 1e3 + 5; int n, m; char g[N][N]; void Solve() { cin >> n >> m; if (n == 1) { cout << "NO\n"; return; } for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) cin >> g[i][j]; int ...
C++
79b629047e674883a9bc04b1bf0b7f09
f08f8dd3cd6fe7de5f85fcc58c4abdc8
2,000
PASSED
#include <bits/stdc++.h> // #include<ext/pb_ds/assoc_container.hpp> // #include<ext/pb_ds/tree_policy.hpp> using namespace std; using namespace chrono; //using namespace __gnu_pbds; #define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define pb push_back #define ppb pop_back #d...
C++
79b629047e674883a9bc04b1bf0b7f09
fdb58884fa34f7755d2579cbfa96bc32
2,000
PASSED
#include <bits/stdc++.h> using namespace std; const int N = 1005; const int M = 1e5 + 5; int n, m, out[N][2], in[N][2]; char a[N][N]; void solve() { cin >> n >> m; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { cin >> a[i][j]; } } for (int ...
C++
79b629047e674883a9bc04b1bf0b7f09
1cc30ebedb7981abb7395cb48c296a84
2,000
PASSED
#include <bits/stdc++.h> using namespace std; #define int long long #define double long double #define ull unsigned long long #define pii pair<int,int> #define tiii tuple<int,int,int> #define pll pair<long long, long long> #define pdd pair<double, double> #define s second #define f first #define pb push_...
C++
79b629047e674883a9bc04b1bf0b7f09
687aa1ebe6776221dfa4ece5ba2b68d9
2,000
PASSED
#include <bits/stdc++.h> using namespace std; int n, m; string s[1001]; bool skip; void solve() { skip = false; static int test = 0; test++; cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> s[i]; s[i] = '0' + s[i]; } if (skip) { if (test == 59) { ...
C++
79b629047e674883a9bc04b1bf0b7f09
a3ecf5dcb7b853a77b01e73218e6f40e
2,000
PASSED
#include<bits/stdc++.h> #define N 100005 #define M 200005 using namespace std; int n,d[N],h[N],cnt,de,a,sum[N],d1[N],s[N],ansc,ansv,ansv1,cnt1[N],vv[N]; vector<int>s1[N]; vector<pair<int,int> > mi[N]; bool bj[N]; struct bb{ int to,next; }w[M]; void ad(int x,int y){ w[++cnt].to=y; w[cnt].next=h[x]; h[x...
C++
3ffb3a2ae3e96fc26d539c9676389ae5
44280bd2ad399f9d54051b0cb09874d6
3,100
PASSED
#include<bits/stdc++.h> #define N 100005 #define M 200005 using namespace std; int n,d[N],h[N],cnt,de,a,sum[N],d1[N],s[N],ansc,ansv,ansv1,cnt1[N],vv[N]; vector<int>s1[N]; vector<pair<int,int> > mi[N]; bool bj[N]; struct bb{ int to,next; }w[M]; void ad(int x,int y){ w[++cnt].to=y; w[cnt].next=h[x]; h[x...
C++
3ffb3a2ae3e96fc26d539c9676389ae5
bb89ae1c1a142d0917155a2588c2b8c4
3,100
PASSED
//Linkwish's code1 #include<bits/stdc++.h> using namespace std; namespace _Fast_IO{ char ch; int _stack[55],_top,_sign; template<typename _T>inline void read(_T &x){ ch=getchar(),_sign=1; for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')_sign=-1; for(x=0;ch>='0'&&ch<='9';ch=getchar())x=(x<<1)+(x<<3)+(ch^48...
C++
3ffb3a2ae3e96fc26d539c9676389ae5
be522387230db9fb8562b09e3d2f327f
3,100
PASSED
//Linkwish's code #include<bits/stdc++.h> using namespace std; namespace _Fast_IO{ char ch; int _stack[55],_top,_sign; template<typename _T>inline void read(_T &x){ ch=getchar(),_sign=1; for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')_sign=-1; for(x=0;ch>='0'&&ch<='9';ch=getchar())x=(x<<1)+(x<<3)+(ch^48)...
C++
3ffb3a2ae3e96fc26d539c9676389ae5
87abe2fc45942cb0acf5822ecfd4275b
3,100
PASSED
//Linkwish's code #include<bits/stdc++.h> using namespace std; namespace _Fast_IO{ char ch; int _stack[55],_top,_sign; template<typename _T>inline void read(_T &x){ ch=getchar(),_sign=1; for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')_sign=-1; for(x=0;ch>='0'&&ch<='9';ch=getchar())x=(x<<1)+(x<<3)+(ch^48)...
C++
3ffb3a2ae3e96fc26d539c9676389ae5
37e9888c27969a6bfd3a0b1142070dc7
3,100
PASSED
//Linkwish's code #include<bits/stdc++.h> using namespace std; namespace _Fast_IO{ char ch; int _stack[55],_top,_sign; template<typename _T>inline void read(_T &x){ ch=getchar(),_sign=1; for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')_sign=-1; for(x=0;ch>='0'&&ch<='9';ch=getchar())x=(x<<1)+(x<<3)+(ch^48)...
C++
3ffb3a2ae3e96fc26d539c9676389ae5
ad3d93c761c94f451bdcb730e3ed00b6
3,100
PASSED
#include <bits/stdc++.h> using namespace std; typedef pair <int, int> pii; int N, X; vector <int> ch[100005]; int dep[100005], maxdep; char flag='a'; char ans[100005]; // 深度为x的节点有哪些 vector <int> depids[100005], depye[100005], depjing[100005]; ////////// vector <int> cntall[100005]; int dataall...
C++
3ffb3a2ae3e96fc26d539c9676389ae5
091f555591e48ac85df8d19176f5cc1a
3,100
PASSED
//是啊,你就是那只鬼了,所以被你碰到以后,就轮到我变成鬼了{{{ #include<bits/stdc++.h> using namespace std;typedef long long ll; template<typename T>inline void read(T &x) { x=0;char c=getchar(),f=0; for(;c<48||c>57;c=getchar()) if(!(c^45)) f=1; for(;c>=48&&c<=57;c=getchar()) x=(x<<1)+(x<<3)+(c^48); f?x=-x:x; } template<typename T,typename...L...
C++
3ffb3a2ae3e96fc26d539c9676389ae5
afcd5798344db4ffac2e51be4ee6415a
3,100
PASSED
//是啊,你就是那只鬼了,所以被你碰到以后,就轮到我变成鬼了{{{ #include<bits/stdc++.h> using namespace std;typedef long long ll; template<typename T>inline void read(T &x) { x=0;char c=getchar(),f=0; for(;c<48||c>57;c=getchar()) if(!(c^45)) f=1; for(;c>=48&&c<=57;c=getchar()) x=(x<<1)+(x<<3)+(c^48); f?x=-x:x; } template<typename T,typename...L...
C++
3ffb3a2ae3e96fc26d539c9676389ae5
69e77b3d22eeb1663cea71f8ff6f286e
3,100
PASSED
#include <cstdio> #include <iostream> #include <cstring> #include <algorithm> #include <cmath> #include <bitset> #include <vector> #include <unordered_map> using namespace std; const int N = 100007, M = 500007, INF = 0x3f3f3f3f; typedef long long ll; typedef int itn; int n, m, t, x; int fa[N]; int d...
C++
3ffb3a2ae3e96fc26d539c9676389ae5
abcaa504da189e6199b20237f3dd4c8d
3,100
PASSED
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #define AquA cin.tie(0);ios_base::sync_with_stdio(0); #define fs first #define sc second #define p_q priority_queue using namespace std; const int mod=1e9+7; void add(int& x,int y){ x+=y; x-=mod*(x>=mod); x+=mod*(x<0); } int mul(int x,int...
C++
8508d39c069936fb402e4f4433180465
22a665a8fbb5ee3d089d840404b87ff9
2,500
PASSED
#include<bits/stdc++.h> #define int long long using namespace std; const long long md=1e9+7; int f[2000010],dp[1<<15],p[15],q[15],a[15]; int n,cnt1,cnt2; signed main() { f[1]=1; for (int i=2;i<=2000000;i++) f[i]=md-(md/i)*f[md%i]%md; scanf("%lld",&n); for (int i=0;i<n;i++) scanf("%lld",&a[i])...
C++
8508d39c069936fb402e4f4433180465
3904a4aac5008f31238a9eda8aa8ff00
2,500
PASSED
#include<bits/stdc++.h> #define int long long using namespace std; const long long md=1e9+7; int f[2000010],dp[1<<15],p[15],q[15],a[15]; int n,cnt1,cnt2; signed main() { f[1]=1; for (int i=2;i<=2000000;i++) f[i]=md-(md/i)*f[md%i]%md; scanf("%lld",&n); for (int i=0;i<n;i++) scanf("%lld",&a[i]); ...
C++
8508d39c069936fb402e4f4433180465
88ab2041c84b8974030410e534635bf1
2,500
PASSED
#include<bits/stdc++.h> #define int long long using namespace std; const long long md=1e9+7; int f[2000010],dp[1<<15],p[15],q[15],a[15]; int n,cnt1,cnt2; signed main() { f[1]=1; for (int i=2;i<=2000000;i++) f[i]=md-(md/i)*f[md%i]%md; scanf("%lld",&n); for (int i=0;i<n;i++) scanf("%lld",&a[i]); ...
C++
8508d39c069936fb402e4f4433180465
6e498f9a223fe8a0568f0d1dcf42441c
2,500
PASSED
#include<bits/stdc++.h> #define int long long using namespace std; const long long md=1e9+7; int f[2000010],dp[1<<15],p[15],q[15],a[15]; int n,cnt1,cnt2; signed main() { f[1]=1; for (int i=2;i<=2000000;i++) f[i]=md-(md/i)*f[md%i]%md; scanf("%lld",&n); for (int i=0;i<n;i++) scanf("%lld",&a[i]); ...
C++
8508d39c069936fb402e4f4433180465
b8eb7cfaa97660ef5302e2c6478cda99
2,500
PASSED
#include <bits/stdc++.h> #define forn(i,s,t) for(int i = (s); i <= (t); ++i) #define form(i,s,t) for(int i = (s); i >= (t); --i) #define rep(i,s,t) for(int i = (s); i < (t); ++i) using namespace std; const int Mod = 1e9 + 7; struct Mint { int res; Mint() {} Mint(int _r) : res(_r) {} inline friend Mint ope...
C++
8508d39c069936fb402e4f4433180465
2d1851bc382fe86b547349b194d1e08d
2,500
PASSED
#include <iostream> typedef long long ll; const ll p = 1e9 + 7; const int N = 15, M = 5e6 + 5, W = 1 << N; inline void Add(ll & x, const ll & y) { x += y; if (x >= p) x -= p; } inline void mul(ll & x, const ll & y) { x = x * y % p; } ll qpow(ll x, ll y) { ll a = 1; while (y) { if (y & 1) a ...
C++
8508d39c069936fb402e4f4433180465
13aa0c557ea977145517c2c2fa287e17
2,500
PASSED
#include <bits/stdc++.h> #define fi first #define se second #define pb push_back using namespace std; typedef long long ll; typedef unsigned long long ull; inline ll read() { ll s = 0, w = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') w = -1; ch = getchar(); } while (isdigi...
C++
8508d39c069936fb402e4f4433180465
1e1e15dd345a398b2badca7c5a9a5758
2,500
PASSED
#include <bits/stdc++.h> #define fi first #define se second #define pb push_back using namespace std; typedef long long ll; typedef unsigned long long ull; inline ll read() { ll s = 0, w = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') w = -1; ch = getchar(); } while (isdigi...
C++
8508d39c069936fb402e4f4433180465
4626a4bb9964b4c6c1489714c7305eef
2,500
PASSED
#include <bits/stdc++.h> #define fi first #define se second #define pb push_back using namespace std; typedef long long ll; typedef unsigned long long ull; inline ll read() { ll s = 0, w = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') w = -1; ch = getchar(); } while (isdigi...
C++
8508d39c069936fb402e4f4433180465
888d2fde2aabeea686488443544139d5
2,500
PASSED
#pragma GCC optimize("Ofast,unroll-loops") #pragma GCC target("avx,avx2,sse,sse2") #include<bits/stdc++.h> #define all(x) begin(x), end(x) using namespace std; using ll = long long; template<typename F> void multitest(F func) { int t; cin >> t; while(t--) func(); } void report(int ok) { cout << (ok?"...
C++
7fb8b73fa2948b360644d40b7035ce4a
5357dba98138cf043183057fae0b0135
1,800
PASSED