uuid string | repo_name string | relative_path string | content string | category string | algo_rel_score float64 | quality_score float64 |
|---|---|---|---|---|---|---|
3f4a65e0-bc98-4266-97e4-2071d8f94e0e | PranitChawla/ACM-ICPC-Regionals-Codes | ayoub_and_lost_array.cpp | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dp[200004][3];
ll m=1000000007;
int main()
{
ll n,l,r;
cin>>n>>l>>r;
ll a,b,c;
ll tot=r-l+1;
a=tot/3;
b=tot/3;
c=tot/3;
if (tot%3==1)
{
if (r%3==0)
a++;
else if (r%3==1)
b++;
else if (r%3==2)
c++;
}
else if (tot%3==2)
... | ALGO | 0.999869 | 3.655509 |
1dbb68e8-c000-4357-b200-d168c0fabf77 | yang48699997/code | vp/The 10th Shandong Provincial Collegiate Programming Contest/problemB.cpp | #include <bits/stdc++.h>
using namespace std;
struct DSU{
vector<int> fa, sz;
DSU(int n) : fa(n), sz(n, 1) {
for ( int i = 0; i < n; i++) fa[i]=i;
}
int find(int x) {
if (fa[x] == x) return x;
fa[x] = find(fa[x]);
return fa[x];
}
bool merge(int x, int y) {... | ALGO | 0.999984 | 4.557235 |
e66a0243-c1a0-484c-be71-73ed6f95bdd6 | Cindragon/Leetcode-Practice-Grind-75 | 1482-how-many-numbers-are-smaller-than-the-current-number/1482-how-many-numbers-are-smaller-than-the-current-number.cpp | class Solution {
public:
vector<int> smallerNumbersThanCurrent(vector<int>& nums) {
vector<int> temp=nums;
vector<int> res;
sort(temp.begin(), temp.end());
unordered_map<int, int> mp;
for(int i=0;i<temp.size();i++){
if(mp.find(temp[i])==mp.end()){
... | ALGO | 0.999995 | 5.997246 |
01155190-c724-40cc-a73d-2f90ed666b2e | Sainy-Mishra/LeetCode | 2966- Divide Array Into Arrays With Max Difference/2966- Divide Array Into Arrays With Max Difference.cpp | class Solution {
public:
vector<vector<int>> divideArray(vector<int>& nums, int k) {
sort(nums.begin(),nums.end());
int size=nums.size()/3;
vector<vector<int>> result;
for(int i=2;i<nums.size();i+=3){
if(nums[i]-nums[i-2]>k){
return {};
}
... | ALGO | 0.999985 | 5.485218 |
abadb786-c44d-48ad-8632-3c8b632c96ef | zhengzp2019/algorithm | UVA/10474.cpp | #include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
const int MAXN = 10000 + 100;
int a[MAXN];
int main()
{
int N, Q;
int kase = 0;
while (scanf("%d %d", &N, &Q) == 2 && N | Q)
{
memset(a, -1, sizeof(a));
for (int i = 0; i < N; i++)
{
scanf(... | ALGO | 0.999463 | 3.805178 |
c715eda7-4103-4d57-b862-2eecd7998507 | ARFNeto-CH/chp21-1121-loto | chp21-1121-loto.cpp | #include <iomanip>
#include <iostream>
#include "Sorteio10.h"
int main()
{ // -1 excluido 0 sorteio 1 fixo
//clang-format-off
//Regra regra_teste({-1, -1, -1, -1, 0, 1, 1, 1, 0, 0});
Regra regra_teste({ 1, 1, 1,-1,-1, 0, 0, 0, 0, -1});
Amostra numeros = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
... | ALGO | 0.993164 | 4.047384 |
1014df59-e2b8-4d18-8f6a-c6183f806876 | vishal1patidar/leetcode_hub | Rearrange an array with O(1) extra space - GFG/rearrange-an-array-with-o1-extra-space.cpp | //{ Driver Code Starts
#include<bits/stdc++.h>
using namespace std;
// } Driver Code Ends
class Solution{
public:
// arr: input array
// n: size of array
//Function to rearrange an array so that arr[i] becomes arr[arr[i]]
//with O(1) extra space.
void arrange(long long arr[], int n) {
... | ALGO | 0.999943 | 5.794935 |
31a8cd26-bab4-43d6-9d9b-12c76f075298 | ishandutta2007/codeforces | davi_bart/normal/1262/D1.cpp | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<pair<int,int> > v,p;
vector<pair<pair<int,int>,int> > q;
vector<int> sol(200010);
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int N;
cin>>N;
for(int i=0;i<N;i++){
int a;
cin>>a;
v.push_back({a... | ALGO | 0.999996 | 4.178129 |
6115cd9f-35e1-409a-85ea-bd6e70b563d8 | TanayK07/LeetCode | 1620-check-if-array-pairs-are-divisible-by-k/1620-check-if-array-pairs-are-divisible-by-k.cpp | class Solution {
public:
bool canArrange(vector<int>& arr, int k) {
// int l=0,r=0;
int n=arr.size();
// sort(arr.begin(),arr.end());
// for(int i=0;i<arr.size()/2;i++){
// if((arr[i]+arr[n-1-i])%k!=0) return false;
// }
unordered_map<int,int> m1;
... | ALGO | 0.999968 | 5.455488 |
7a5995c9-737a-4df9-8331-3d2c604dbdd0 | daocrossover/Leetcode-Cpp | 5. Longest Palindromic Substring/Solution1.cpp | // 5. Longest Palindromic Substring
// Description:
// Given a string s, find the longest palindromic substring in s.
// Example 1:
// Input: s = "babad"
// Output: "bab"
// Note: "aba" is also a valid answer.
// Example 2:
// Input: s = "cbbd"
// Output: "bb"
// Example 3:
// Input: s = "a"
// Output: "a"
// Examp... | ALGO | 0.999746 | 6.362187 |
9b8b0564-00e7-4142-8145-308f4b8b2ee8 | leopeng1995/acplusplus | LintCode/Maximum Subarray/分治法.cpp | // 分治法,O(nlogn)
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;
int max(int a, int b, int c) {
return max(max(a, b), c);
}
class Solution {
public:
int maxSubArray(vector<int> nums) {
if (nums.empty()) return 0;
if (nums.size() == 1) return nums[0];
r... | ALGO | 0.999976 | 5.256134 |
3f776ce2-49f2-4be5-a5cc-ec9bca795a91 | thom6435/MultiContour-Fire-Analysis | MultiContour.cpp | /*
* program: MultiContour
* modified: 25-February-2022
* author: Ed Thomas
* purpose: Experiment to examine potential of using OpenCV multi-contour image
* processing methods to analyze fire imagery.
* Library: OpenCV 4.2
*
*/
#include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include ... | TOOL | 0.910277 | 5.805995 |
0241a624-34b5-4a91-b0ac-7a2e03836482 | ishandutta2007/codeforces | fop_zzz/normal/898/E.cpp | #include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<map>
#include<cmath>
#define For(i,j,k) for(ll i=j;i<=k;++i)
#define Dow(i,j,k) for(ll i=k;i>=j;--i)
#define ll long long
using namespace std;
inline ll read()
{
ll t=0,f=1;char c=getchar();
while(c<'0'||c>'9') {c=getchar();}
while(c... | ALGO | 0.999902 | 3.263058 |
9d74455f-d4cb-45c2-be8e-e35205a7a173 | avidLearnerInProgress/placementPreparation | Trees/BinaryTrees/identicalTrees.cpp | #include<bits/stdc++.h>
using namespace std;
typedef struct node{
int data;
struct node *left;
struct node *right;
}Node;
//typedef struct node Node;
Node *createNode(int data){
Node *temp=new Node();
temp->data=data;
temp->left=NULL;
temp->right=NULL;
return temp;
}
bool identicalTrees(Node ... | ALGO | 0.999982 | 3.752603 |
53b53ee7-8ca0-4f85-920c-1a9fa47efd9e | tempure/algorithm-advance | OJ/acwing/第29场周赛/b.cpp | #include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define um unordered_map
#define pq priority_queue
#define sz(x) ((int)(x).size())
#define x first
#define y second
#define endl '\n'
#define watch(x) cerr << (#x) << " is " << (x) << endl
typedef vector<int> vi;
ty... | ALGO | 0.99991 | 4.701521 |
2720d166-d6fd-4e23-bcff-22c4ac8c2857 | xg-wang/leetcodes | CppCode/M_133_Clone_Graph.cpp | #include "lc_header.h"
using namespace std;
/**
* Definition for undirected graph.
* struct UndirectedGraphNode {
* int label;
* vector<UndirectedGraphNode *> neighbors;
* UndirectedGraphNode(int x) : label(x) {};
* };
*/
class Solution {
public:
UndirectedGraphNode *cloneGraph(UndirectedGraphNod... | ALGO | 0.999665 | 6.333256 |
b6d9011e-67aa-476d-a461-9ca119cd8531 | Shaf3eii/DS | Stack/Stack HW 2-5 Medium to Hard/main.cpp | #include <iostream>
#include <stack>
#include <vector>
#include <algorithm>
using namespace std;
// problem #1
void Asteroid_collision() {
int n;
cin >> n;
int arr[n];
for (int i = 0; i < n; ++i)
cin >> arr[i];
stack<int> out;
for (auto &i: arr) {
bool alive = true;
whi... | ALGO | 0.999895 | 4.239113 |
aeb9f211-365e-432a-b684-9f6be40f6fdf | Saifu0/Competitive-Programming | CP/1500/87B.cpp | #include<bits/stdc++.h>
using namespace std;
#define NINJA ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define iii tuple<int,int,int>
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define int long long
#defin... | ALGO | 0.999842 | 4.390055 |
102b2270-75aa-40ca-b70b-502bf4cb544b | tkguswls1106/ProblemSolving-cpp | Algorithm_sub/Simulation_BOJ-15683_BEST.cpp | // 이와 비슷하지만 보다 괜찮은 풀이는 다음 웹사이트 링크를 참고하자.
// 참고로 다음 링크 코드의 tmp배열은 arr배열을 dir반복문마다 재초기화해서 원래값으로 원상복구시켜줄 임시 배열을 의미한다.
// https://0m1n.tistory.com/115
#include <vector>
#include <queue>
#include <tuple>
#include <iostream>
#include <algorithm>
using namespace std;
int n, m;
vector<vector<int>> board; // -1값이면 최종결정난 cct... | ALGO | 0.999845 | 5.967823 |
2ce0294f-ef6e-418f-be94-e27d6e427512 | Yestercafe/oj | codeforces/Codeforces Round 890 (Div. 2) supported by Constructor Institute_/c.cpp | #include <bits/stdc++.h>
using i64 = long long;
void sol() {
int n, k;
std::cin >> n >> k;
std::vector<int> arr(n + 1);
int ans = 0;
for (int i = 0; i < n; ++i) {
std::cin >> arr[i];
ans = std::max(ans, arr[i]);
}
arr.back() = -8e8;
for (int i = 0; i < n - 1; ++i) {
int left = ans - 1, right = 1e8 + 200... | ALGO | 0.999934 | 5.365504 |
5d98a3a9-565a-40fe-bec4-75a6e9c25efa | AnuragPatel1/Codeforces-Problem | A_Factory.cpp | #include <bits/stdc++.h>
using namespace std;
#define PI (3.141592653589)
#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i,j) for(int i = 0; i<j; i++)
#define rrep(i,j) for(int i = j; i>=0; i--)
#define all(x) x.begin(), x.end()
#define print(x) cout << x << endl
#define YES co... | ALGO | 0.999825 | 3.588346 |
9866c86f-fd1a-434d-9ef1-9b60b179a388 | Vinay-Garg/Data-Structures | challenge3/3.cpp | /*
The structure of the node is
typedef struct node
{
int freq;
char data;
node * left;
node * right;
}node;
*/
void decode_huff(node * root,string s)
{
node* temp = root;
for (int i = 0; s[i]!='\0'; ++i)
{
if(s[i]=='0')
temp = temp->left;
else if(s[i]=='1')
temp = temp->right;
... | ALGO | 0.999409 | 3.219712 |
ab5c9d06-efde-44d0-839e-c3be80fe13f7 | raincross7/code-similarity | codes/train_code/problem338/problem338_252.cpp | const int LG = 21;
const int FN = 400005;
const long long MOD = 998244353;
const long long INF = 1e9;
const long long INFLL = 1e18;
#include <bits/stdc++.h>
const double PI = acos(-1);
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef ve... | ALGO | 0.999635 | 4.009235 |
a9e57a9e-ef43-44cd-9af0-1290b1340cd0 | TianyiChen/Exercises | POJ/1256.cpp | #include <iostream>
#include<algorithm>
using namespace std;
char c[13];
int main(){
int cs, t, len; cin >> cs;
while (cs--){
scanf("%s",c); len = strlen(c);
for (t = 0; t < len; t++)
if (c[t] <= 'Z')c[t] = (c[t] - 0x40) * 2;
else c[t] = (c[t] - 0x60) * 2 + 1;
sort(c, c + len);
do{
for (t = 0; t <... | ALGO | 0.999968 | 4.390603 |
ef71fac7-27bf-4ba9-92ee-1a1af99d627a | TM-DEV-PRO/DSA-CP | funtion-snippets/strivers/day7/max-cons-1's.cpp | #include<bits/stdc++.h>
using namespace std;
const long long INF = 1e18L + 5;
const long double D_INF = 1e10;
long double ans = 0.0;
long long res = 0;
long long int md = 1000000007LL;
int findMaxConsecutiveOnes(vector<int>& nums) {
int mx = 0;
int curr = 0;
for(auto i:nums){
if(i==0)
c... | ALGO | 0.999919 | 4.193473 |
1f120838-767e-4296-be7b-7e60d5ff1dfc | Suvekshyajha/discrete-structure | lab3/qn3.cpp | #include<iostream>
using namespace std;
int main(){
int p[4]={1,1,0,0},
q[4]={1,0,1,0},
a[4],m[4],n[4];
for(int i=0;i<4;i++){
m[i]=!p[i];
}
for(int i=0;i<8;i++){
n[i]=!q[i];
}
for(int i=0;i<4;i++){
if(m[i]==1&&n[i]==0){
a[i]=0;
}
else{
a[i]=1;
}
}
cout<<"-----------------------------... | ALGO | 0.996877 | 3.217307 |
c57a25eb-8321-44a6-9297-d1e18c52cf8a | jainammm/geeksforgeeks-Must-Do-Interview-Preparations | String/q4.cpp | #include <iostream>
#include <bits/stdc++.h>
#include<vector>
#include<stack>
using namespace std;
#define NO_OF_CHARS 256
int longestUniqueSubsttr(string str)
{
int n = str.size();
int cur_len = 1; // length of current substring
int max_len = 1; // result
int prev_index; // previous index
... | ALGO | 0.999826 | 5.162907 |
197c6d7f-8a44-4af5-822f-c72a826f97c2 | AnjaliIrusumalla/Coding-Learn | checksum.cpp | // C++ implementation of the above approach
#include <bits/stdc++.h>
using namespace std;
// Function to find the One's complement
// of the given binary string
string Ones_complement(string data)
{
for (int i = 0; i < data.length(); i++) {
if (data[i] == '0')
data[i] = '1';
else
data[i] = '0';
}
return ... | ALGO | 0.999949 | 6.21323 |
2986cdfe-2e08-4fa8-91ad-3b7d9f1ed84e | Enhmunh-E/codeforces-solutions | 580A.cpp | #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main () {
int n;
vector <int> a;
cin >> n;
int bair[n+1];
for (int i = 0; i < n; i++) {
cin >> bair[i];
}
bair[n] = 0;
int k = 1;
int hed = 1;
for (int i = 0; i < n; i++) {
if (bai... | ALGO | 0.999995 | 4.117153 |
fae2fbf5-c69b-43af-9e6b-b59645c9dd74 | iscat123/myFirstRepo | 数据结构与算法/c++/路飞吃桃/路飞吃桃.cpp | #include <stdio.h>
int arr[10];
int test(int n)
{
if (n == 1) return 1;
return (test(n - 1) + 1) * 2;
}
int test02(int i, int n)
{
if (i > n) return 0;
return 1 + test02(i + arr[i], n);
}
void printf_one(int i)
{
for (int k = 0; k <= i; ++k)
{
printf("%d ", arr[k]);
}
printf("\n");
}
void test02(int i, int... | ALGO | 0.999978 | 3.605244 |
42f16f97-94eb-4392-92aa-e1d0d6f187b0 | ishandutta2007/codeforces | lucina/normal/1419/E.cpp | #include<bits/stdc++.h>
using namespace std;
const int nax = 3e5 + 10;
vector <int> get_grey_code(int x) {
///why I wrote it recursively let's see performance
///guess : not much different or not at all
vector <int> cur{0, 1};
for (int i = 1 ; i < x ; ++ i) {
for (int j = int(cur.size()) - 1 ;j... | ALGO | 0.999979 | 4.172058 |
6575e6c0-4a9f-435d-8dc5-5a3129bea2df | hosszugyula/BHAX | thematic_tutorials/bhax_textbook_sajat/Welch/z3a18a2_from_scratch.cpp | #include <iostream>
#include <random>
template <typename ValueType>
class BinRandTree {
protected:
class Node {
private:
ValueType value;
Node *left;
Node *right;
int count{0};
// TODO rule of five
Node(const Node &);
Node & operator = (const Node &);... | ALGO | 0.999314 | 4.565692 |
bf324865-cfca-49de-a8de-29a1904b92f3 | negniy/aisd2.3 | Source.cpp | #include "stdio.h"
#include <stdlib.h>
#include <string>
#include <ctype.h>
#include <math.h>
#include <locale.h>
#include <windows.h>
#include <conio.h>
#include <time.h>
#include <iostream>
#include <vector>
#include <chrono>
#include <vector>
#include <stdio.h>
#include <iostream>
#include <queue>
#include <algorith... | ALGO | 0.991716 | 3.339308 |
b64af618-33d4-4203-97e2-7fdf36c24195 | guptavarun619/Data-Structure | Recursion/quick_sort.cpp | #include<iostream>
using namespace std;
// Bestcase complexity - O(NlogN)
// Worstcase complexity - O(N^2)
int partition(int a[], int s, int e)
{
int i = s-1;
int j = s;
int pivot = a[e];
for( ;j <= e-1; j++)
{
if(a[j] < pivot)
{
// here merge the smaller element into t... | ALGO | 0.999979 | 4.860635 |
e4c9c4dc-03f9-4396-ab51-6e1137d9f96c | markoelez/leetcode_ml | ds/design-a-number-container-system.cpp | // Time: ctor: O(1)
// change: O(logn)
// find: O(1)
// Space: O(n)
// bst
class NumberContainers {
public:
NumberContainers() {
}
void change(int index, int number) {
if (idx_to_num_.count(index)) {
num_to_idxs_[idx_to_num_[index]].erase(index);
... | ALGO | 0.999375 | 6.126009 |
7dc22a7c-9f92-4414-8881-2ba831ea0649 | solakian/RISE | src/Library/Materials/OrenNayarBRDF.cpp | #include "pch.h"
#include "OrenNayarBRDF.h"
#include "../Interfaces/ILog.h"
#include "../Utilities/Optics.h"
#include "../Utilities/math_utils.h"
using namespace RISE;
using namespace RISE::Implementation;
OrenNayarBRDF::OrenNayarBRDF(
const IPainter& reflectance,
const IPainter& roughness
) :
pReflectance( re... | ALGO | 0.992843 | 6.391073 |
a015bbdd-c299-40b6-b739-a2585c697a7b | pranatsharma1/Competitve-Programming | Trees/euler_tour_of_a_tree.cpp | #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace ... | ALGO | 0.999983 | 4.941184 |
33f21787-8d28-416d-b08a-46a2836bae14 | mrpawan-gupta/DSA-inNout | 6]. 150 SDE Questions Leecode/Cpp/Move Zeroes.cpp | class Solution
{
public:
void moveZeroes(vector<int> &nums)
{
int j = 0;
// move all the nonzero elements advance
for (int i = 0; i < nums.size(); i++)
{
if (nums[i] != 0)
{
nums[j++] = nums[i];
}
}
for (; j < nu... | ALGO | 0.999785 | 6.314575 |
33ddb8df-9f58-4188-b3a0-3d83f9206c5f | shivanshsanoria1/LeetcodeSolutions | CPP [1-500]/60.permutation_sequence [2].cpp | class Solution {
public:
void factorial(vector<int>& fact) //calculates factorial from 0 to (n-1)
{
fact[0]=1;
for(int i=1; i<fact.size(); i++)
fact[i]= i*fact[i-1];
}
void solve(int n, int k, vector<bool>& dig, vector<int>& fact, string& ans)
{
if(n==0)
... | ALGO | 0.999982 | 5.94925 |
b56ef9f9-9f5c-450c-93e0-4223de50530b | zech-chi/CodeForces | training/A/A_Launch_of_Collider.cpp | #include <algorithm>
#include <cstddef>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <iterator>
#include <set>
#include <vector>
#include <numeric>
#include <cmath>
#include <iomanip>
typedef long long ll;
using namespace std;
const double PI = 3.141592653589793;
int min(int a, int b) { return (a... | ALGO | 0.999938 | 3.81169 |
3765f1f5-d64b-4c8e-bfb9-210a01b3acdd | ConradWarren/LeetCode-Challenges | 1359-CountAllValidPickupandDeliveryOptions.cpp | class Solution {
public:
int countOrders(int n) {
std::vector<long long> dp(n + 1, 0);
dp[0] = 1;
for (int i = 1; i <= n; i++) {
dp[i] = (dp[i - 1] * (i * (i + (i - 1)))) % ((long long)(1e9) + 7LL);
}
return dp.back();
}
};
| ALGO | 0.999966 | 5.783648 |
35a33a0f-fb12-4a57-bb87-1449a06b25dd | ssuljic/codeeval | number_pairs/main.cpp | #include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
using namespace std;
vector<string> &split(const string &s, char delim, vector<string> &elems) {
stringstream ss(s);
string item;
while (std::getline(ss, item, delim)) {
elems.push_back(item);
}
return elems;
}
vec... | ALGO | 0.99566 | 3.820039 |
3bc6e92b-9189-4d29-916d-961a3f8e0bf6 | AlexanderStein1978/AlexanderStein1978 | NR_C301/legacy/nr2/CPP_211/examples/xqgaus.cpp | #include <iostream>
#include <iomanip>
#include <cmath>
#include "nr.h"
using namespace std;
// Driver for routine qgaus
DP func(const DP x)
{
return x*exp(-x);
}
int main(void)
{
const DP X1=0.0,X2=5.0;
const int NVAL=10;
int i;
DP dx,ss,x;
dx=(X2-X1)/NVAL;
c... | ALGO | 0.9998 | 3.747399 |
bec95ee0-86ec-4d39-be65-834ad77f3541 | dhruvik1999/Competitive-Programming | Codeforces/1062D.cpp | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define MOD 1000000007
#define maxlen 9223372036854775807
#define minlen -9223372036854775807
#define fin(n) for(int i=0;i<n;i++)
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
vector<int> primeFact(int n){vector<int> ans;for(int t=2;t<=sq... | ALGO | 0.999936 | 4.257366 |
f5c2b7cf-747c-44a6-855d-b47c10277cb8 | sheeluofficial/practice | OthersCode/LeetCode-Solutions-master/LeetCode-Solutions-master/C++/compare-version-numbers.cpp | // Time: O(n)
// Space: O(1)
class Solution {
public:
int compareVersion(string version1, string version2) {
const int n1 = version1.length(), n2 = version2.length();
for (int i = 0, j = 0; i < n1 || j < n2; ++i, ++j) {
int v1 = 0, v2 = 0;
while (i < n1 && version1[i] != '.... | ALGO | 0.999795 | 5.837152 |
a6a7483c-7c49-4c00-b4de-2df4f715e0c4 | afrozchakure/Competitive-Programming-Solutions | LeetCode/Algorithms/Medium/UniqueLength3PalindromicSubsequences.cpp | class Solution {
public:
int countPalindromicSubsequence(string s) {
vector<pair<int, int>> v(26, {-1, -1});
int n = s.size();
for(int i=0; i<n; i++)
{
if(v[s[i] - 'a'].first == -1)
v[s[i] - 'a'].first = i;
else
v[s[i]... | ALGO | 0.999977 | 6.810551 |
c2022a5b-549d-4e51-90b0-e794a5272416 | aravind-kumar/Coding | count_univalue_trees.cpp | /**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
int countUnivalSubtrees(TreeNode* root) {
int count = 0;
countUnivalSu... | ALGO | 0.999892 | 6.895426 |
eda2cdf1-360b-4cde-9f3c-65197b8dcd2d | mdshakibsami/Number-Theory-Algorithms | Primality Test/Problems/Primality Test.cpp | /*
https://www.codechef.com/problems/PRB01
*/
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
const int MOD = 1e9 + 7;
bool isPrime(int n)
{
if (n < 2)
return false;
for (int i = 2; i * i <= n; i++)
{
if (n % i == 0)
return false;
}
... | ALGO | 0.997875 | 5.730382 |
48282e37-65a3-414b-b3a9-94ca5d8deb58 | regindex/suffixient-array | include/LZ/lz77index/utils.cpp | #include "utils.h"
/* construction sa libdivsufsort */
#include "divsufsort.h"
#include "basics.h"
//#include "lfs.h"
#include <cstdio>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <algorithm>
#include <sys/time.h>
#include <sys/resource.h>
#include <time.h>
#include <iostream>
namespace lz7... | TOOL | 0.997065 | 3.86912 |
9fcb1654-3424-4b3b-96c9-ba7f8824cf3b | adityarajmazumdar007/LeetCode | 2016-reduction-operations-to-make-the-array-elements-equal/reduction-operations-to-make-the-array-elements-equal.cpp | class Solution {
public:
int reductionOperations(vector<int>& nums) {
int n = nums.size();
if(n == 1) return 0;
int count = 0;
sort(nums.begin(), nums.end());
for(int i = 0; i < n; i++){
while(nums[i]== nums[i+1]){
i++;
}
... | ALGO | 0.999921 | 5.869743 |
c823e733-729e-40be-9e00-5bab91d51ec0 | JosephLWalker96/FreeWILLI | listener_program/src/algorithms/localization/gcc_phat.cpp | #include "gcc_phat.h"
GCC_PHAT::GCC_PHAT(int paddedLength, int spectraLength, int numChannels, int sampleRate)
: mPaddedLength(paddedLength),
mNumChannels(numChannels),
mSampleRate(sampleRate),
mNumTdoas(numChannels * (numChannels - 1) / 2),
mMaxShift(paddedLength / 2),
mNormalizedCros... | ALGO | 0.998553 | 5.88761 |
94201b2f-6b45-4cef-b45d-3ae3a624e900 | Arshtyi/SDUOJ-Solutions | src/home/1033/main.cpp | #include <bits/stdc++.h>
using namespace std;
int main(){
int cnt = 0,st,ed;cin >> st >> ed;
vector<int> v;
for(int i = st;i <= ed;i++){
if((i % 4 == 0 && i % 100 != 0) || i % 400 == 0){
v.push_back(i);
cnt++;
}
}
cout << cnt << endl;
for(auto i : v) cout ... | ALGO | 0.999959 | 3.302817 |
ef616baf-c711-421a-86a1-cec9c92d6c11 | rosmontisu/SolveBOJ | DP/11726 2xn 타일링.cpp | #include <iostream>
using namespace std;
int dp[10007];
int main()
{
int n;
cin >> n;
dp[0] = 0;
dp[1] = 1;
dp[2] = 2;
// 현재 dp번째 도형이 세로라고 가정했을때의 경우의 수와
// 현재 dp번째 도형이 가로라고 가정했을때의 경우의 수를
// 생각해보면 쉽게 풀린다.
for (int i = 3; i <= n; i++)
{
dp[i] = (dp[i - 1] + dp[i - 2]) %... | ALGO | 0.999952 | 4.288368 |
ec2c8348-2d1b-4d2c-a26f-0d1df5181178 | Kriminal589/Infa_MIREA | Доп задачи/Спиннеры и не только /Задача 2/Задача 2/main.cpp | #include <iostream>
using namespace std;
int main(){
int M; cin >> M;
int s_3 = 0; int s_4 = 0;
while (M > 2){
if (M % 4 == 0){
s_4++;
M -= 4;
}
else {
s_3++;
M -= 3;
}
}
if (M == 0){
cout << s_3<<endl;
c... | ALGO | 0.999822 | 3.687062 |
e999ee50-6993-46c2-a69c-a409c2821ba4 | Ma-YX/UCAS_CODlab | Project4-MultiCycle-RISCV/benchmark/microbench/src/ssort/ssort.cpp | // This is the Skew algorithm's reference implementation.
#include <benchmark.h>
static int N;
inline bool leq(int a1, int a2, int b1, int b2) { // lexic. order for pairs
return(a1 < b1 || (a1 == b1 && a2 <= b2));
} // and triples
inline bool leq(int a1, int a2,... | ALGO | 0.999673 | 5.546779 |
15fdaa75-805a-4f77-9ef0-45bc9d248d18 | seheonnn/Algorithm | Programmers/부분합_누적합/광고 삽입.cpp | // 프로그래머스 광고 삽입 누적합
#include <string>
#include <vector>
using namespace std;
int stringToSec(string time) {
int h = stoi(time.substr(0, 2));
int m = stoi(time.substr(3, 2));
int s = stoi(time.substr(6, 2));
return (h * 3600) + (m * 60) + s;
}
string secToString(int sec) {
int h = sec / 3600;
... | ALGO | 0.998382 | 5.850902 |
45ffa515-a0a2-4878-9d3a-fa4de0865870 | Pradumnk23/CF-P-C | Binary Removals.cpp | #include <bits/stdc++.h>
#include <math.h>
#include<algorithm>
#include <vector>
#include <string>
#define lli long long int
using namespace std;
int main()
{
lli t;
cin>>t;
while(t--)
{
string s;
cin>>s;
lli n=s.length();
lli i=0; // Imp step
for(; i<n-1; i++)
... | ALGO | 0.999824 | 4.276375 |
3c12d387-2553-4b2d-baeb-b1fa209769d6 | kfaswhy/raw_process | defog.cpp | #include "defog.h"
//#include "raw_process.h"
U8 defog_process(RGB* rgb, IMG_CONTEXT context, G_CONFIG cfg)
{
if (cfg.defog_on == 0)
{
return OK;
}
U16 w0 = context.width;
U16 h0 = context.height;
U16 w1 = w0 / cfg.defog_smp_ratio;
U16 h1 = h0 / cfg.defog_smp_ratio;
U16 y_max = (1 << cfg.rgb_... | ALGO | 0.988773 | 3.725042 |
6c51815f-bba0-495e-9885-062b223d7f7c | joejaeyoung/codetree-TILs | 250303/선두를 지켜라/keep-the-lead.cpp | #include <iostream>
using namespace std;
int N, M;
int v[1000], t[1000];
int v2[1000], t2[1000];
unsigned int dis[1000001];
unsigned int dis2[1000001];
int main() {
cin >> N >> M;
for (int i = 0; i < N; i++) cin >> v[i] >> t[i];
for (int i = 0; i < M; i++) cin >> v2[i] >> t2[i];
// Write your cod... | ALGO | 0.99993 | 4.015672 |
670a987b-bd61-4671-a281-da7fb421c1b9 | residencia18/240004-albert-silva-de-jesus | modulo-01-programacao-imperativa/semana2/solucoes-praticas/PI-P008/exercicio3/atv2b.cpp | /*Exercício 3: Manipulação de strings tipo C
● Implemente uma aplicação em C que:
b. Modifique o exemplo anterior de forma a verificar se a data fornecida é uma data válida (Ex. 31/02/1990 e 24/15/2002 não são datas válidas);*/
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace... | TOOL | 0.941145 | 3.79158 |
4884e09a-bd01-442e-a446-ed07c8da2899 | willjhliang/usa-computing-olympiad | implementations/ConvexHull.cpp | //
// Created by WillJ on 7/18/2019.
//
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#define INF 2000000000
using namespace std;
struct Coord {
int x, y;
};
namespace convexHull {
Coord bot = Coord{INF, INF};
/**
* Calculates direction of bc in relation with ab
... | ALGO | 0.999741 | 4.590203 |
01e9ba0c-a3d5-454d-a147-0fdea09d3d9f | apovilauskas/mokykliniai-cpp-kodai | Problem 4.3. 16. 5 kaimynai.cpp | #include <bits/stdc++.h>
void skaitymas(int &n,int &m, std::vector<std::vector<int>> &lenta){
std::ifstream fd("U1.txt");
fd >> n >>m;
lenta.resize(n, std::vector<int>(m));
for(int i=0; i<lenta.size(); i++){
for(int j=0; j<lenta[i].size(); j++){
fd >> lenta[i][j];
}
}
}
bo... | ALGO | 0.999825 | 4.155209 |
2b8eb694-5a61-4516-a5f7-691e86d930be | atomic0x90/Personal-Develop | algorithmProblem/boj_10952_A+B-5/sum.cpp | #include <iostream>
using namespace std;
int main()
{
int a,b;
while(1)
{
cin>>a>>b;
if(!a && !b)
break;
cout<<a+b<<"\n";
}
return 0;
}
| ALGO | 0.992746 | 3.699055 |
c62ee1d5-1ef8-42d3-9dfa-7d3a5b519a8d | pedromxnoz/EDD | Clase 02/ejercicio4.cpp | #include<stdio.h>
// Lea números enteros indefinidamente hasta que llegue el
// numero cero y luego escriba la suma de todos ellos.
int main(){
int num;
int suma = 0;
while(num!=0){
printf("\nIngrese un numero: ");
scanf("%d", &num);
suma = suma + num;
}
printf("\n//--------------------------------... | ALGO | 0.994822 | 3.090208 |
b8a38a23-aee6-4e83-a568-615d89dd5e43 | ncreech1/Class-Projects | cs494/lab5/AP-Flow-Main.cpp | #include "AP-Flow.h"
#include "MOA.h"
#include <string.h>
#include <signal.h>
#include <unistd.h>
void alarm_handler(int dummy)
{
fprintf(stderr, "Timed Out!\n");
exit(0);
}
unsigned int djb_hash(uint8_t *buf, int size)
{
size_t i;
unsigned int h;
h = 5381;
for (i = 0; i < size; i++) {
h = (h << 5) ... | ALGO | 0.997944 | 4.638798 |
3645407c-0287-4c2e-97b4-5904813074b7 | meherunnesaenta/Placement-problem-solving- | Recursion/fibonacci.cpp | #include<bits/stdc++.h>
using namespace std;
int fib(int n){
if(n==0|| n==1)
return n;
return fib(n-1)+fib(n-2);
}
int main(){
int n;
cin>>n;
cout<< fib(n);
} | ALGO | 0.999992 | 4.617424 |
3afc3ba9-055d-49c9-9b5f-9a232d069c62 | MonteCarloClub/COMP130188 | lab1-2/lab1-2_cpp/lab1-2.cpp | #include <iostream>
#include <fstream>
#include <string>
#include <vector>
using namespace std;
vector<string> CreateMatrix(string key);
string Decrypt(string ciphertext,string key);
int main()
{
string ciphertext;
ifstream input("lab1-2_input.txt");
if (input)
{
//将文件input的第一行输入到ciphertext中
... | ALGO | 0.999927 | 3.341645 |
9573d598-4350-46c5-9e5e-50badfdfacf1 | kiliakis/blond-benchmark | fft-convolution/benches/bench6.cpp | #include <stdlib.h>
#include <stdio.h>
#include "utils.h"
#include <vector>
#include <random>
#include <chrono>
// #include <PAPIProf.h>
#include <omp.h>
#include "fft.h"
#include <iostream>
#include <mkl_vsl.h>
#include <algorithm>
using namespace std;
template <typename T>
void print_vector(vector<T> &v) {
for ... | ALGO | 0.998507 | 5.250502 |
4e191a34-6ea6-4974-ac55-36ad9c2b16d2 | PatrikPrit15/kod | ksp/2021zima1.cast/4uloha/main.cpp | #include <iostream>
#include <queue>
#include <algorithm>
#include <array>
using namespace std;
int main (int argc, char *argv[])
{
int pocetpolicn;
int dlzkapolices;
int vysledok = 1000000000;
int vys = 0;
cin >> pocetpolicn >> dlzkapolices;
int knihapos[pocetpolicn];
int vysledkypn=0;
for (int i = 0; ... | ALGO | 0.999327 | 3.531255 |
974d28a9-447e-4ed8-87eb-0935590b6b87 | xulihang/Inpainting | inpaint_9/l1_norm_patch_distance.cpp | #include "l1_norm_patch_distance.h"
L1NormPatchDistance::L1NormPatchDistance()
: APatchDistance() { }
L1NormPatchDistance::L1NormPatchDistance(Shape &patch_size, float gaussian_sigma)
: APatchDistance(patch_size, gaussian_sigma) { }
float L1NormPatchDistance::calculate(const Point &source_point,
co... | ALGO | 0.930352 | 6.425892 |
c51c1417-a782-48bd-8478-ceef9edbca05 | turtlegold-nation/TurtleGold | src/Miner/MiningConfig.cpp | #include "MiningConfig.h"
#include <iostream>
#include <thread>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <cxxopts.hpp>
#include <config/CliHeader.h>
#include <config/CryptoNoteConfig.h>
#include "Common/StringTools.h"
#include <Common/Util.h>
#include ... | CONFIG | 0.956306 | 6.794294 |
81358448-96f8-4777-b345-8b7ba1199963 | jhavishesh/100DaysOfCodes | Day-49/Subset Sum Problem.cpp | /* https://practice.geeksforgeeks.org/problems/subset-sum-problem-1611555638/1/ */
//Solution:
//TOP-DOWN Approach
int dp[101][100001];
class Solution{
public:
bool helper(int N,int arr[],int sum)
{
if(N==0 || sum<=0)
return dp[N][sum];
if(dp[N][sum]!=-1)
... | ALGO | 0.999996 | 5.576215 |
6921511c-20a1-4d29-984a-09886c53fb96 | rilianx/BeamSearchCLP | bullet-2.80-rev2531/src/BulletCollision/NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp | #include "btMinkowskiPenetrationDepthSolver.h"
#include "BulletCollision/NarrowPhaseCollision/btSubSimplexConvexCast.h"
#include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h"
#include "BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h"
#include "BulletCollision/CollisionShapes/btConvexShape.h"
... | ALGO | 0.999679 | 5.929208 |
9dba3c4d-bf2d-4d9e-9bc4-51369e7eaed5 | nguyenkimdao1998/Contest_D19 | Contest/Contest D18/Contest 4/d_Bai22_Timkiemso.cpp | /* BAI 22: TIM KIEM NHI PHAN*/
#include<iostream>
using namespace std;
void check(long n, long k, long a[]){
int id=0;
for(int i=1; i<=n; i++){
if(a[i]==k) id = i;
}
if(id>0) cout << id;
else cout << "NO";
}
int main(){
int t;
long a[100000];
cin >> t;
while(t--){
long n,k;
cin >> n >> k;
for(int ... | ALGO | 0.999839 | 3.521945 |
b03f755a-83c7-4a24-a3ee-b571196c78da | radinakazakova/SDA_2024_2025 | Practice/Kontrolno1/FindAllDuplicatesInArr.cpp | //O(n*logn) reshenie
class Solution {
public:
vector<int> findDuplicates(vector<int>& nums) {
vector<int> output;
sort(nums.begin(), nums.end());
int prev = nums[0];
for(int i = 1; i<nums.size(); i++)
{
if(prev == nums[i])
{
output.p... | ALGO | 0.999994 | 5.668857 |
5f9a1482-6fd0-41c6-877c-7f47f2af2d97 | AdarshNandanwar/DSA-and-Competitive-Programming | CodeForces/CodeTON Round 1 (Div. 1 + Div. 2, Rated, Prizes!)/C.cpp | #include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
void solve(){
ll n, val;
cin>>n;
set<ll> s;
for(ll i=0; i<n; i++){
cin>>val;
s.insert(val);
}
if(s.count(1)){
ll prev = -2;
for(auto &i:s){
if(i-prev == 1){
... | ALGO | 0.999752 | 4.3124 |
8694a67a-b939-44e1-a56b-55c28dd06316 | Sa2003hil/DSA | Introdunction to CPP/Recursion/Striver Questions/Types of Recursion/Functional Recursion/FuncRec.cpp | #include <bits/stdc++.h>
using namespace std;
int summ(int n)
{
// Base case
if (n == 0)
{
return 0;
}
return n + summ(n - 1); // Here we are using a function call inside a function call this is the functional recursion
}
int main(int argc, char const *argv[])
{
/* code */
int n;
... | ALGO | 0.999963 | 5.508981 |
ef867363-c65a-489c-96bb-1f37a1b2ed92 | taotaoafk/moba | system/core/libmeminfo/tools/procmem.cpp | #include <errno.h>
#include <inttypes.h>
#include <stdlib.h>
#include <unistd.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <android-base/stringprintf.h>
#include <meminfo/procmeminfo.h>
using Vma = ::android::meminfo::Vma;
using ProcMemInfo = ::android::meminfo::ProcMemInfo;... | TOOL | 0.883919 | 6.80511 |
b8738f16-e799-4792-beaa-4c37da26210d | persefonades/cs_grad_ultra | DSAlgo/IntroToAlgoCormen_3rdEdition/chapter2/insertionSort.cpp | #include <iostream>
using namespace std;
void insertionSort(int *a, int n) {
for (int j = 1; j < n; ++j)
{
int key = a[j];
int i = j - 1;
while (i >= 0 && a[i] > key) {
a[i + 1] = a[i];
i--;
}
a[i + 1] = key;
}
}
int main(int argc, char const *argv[])
{
int a[10] = {5, 9, 6, 3, 7, 1, 6, 0, 8, 10}... | ALGO | 0.999905 | 4.530944 |
1bb5f865-1242-4a4b-b135-096ccb71251b | hitenSharm/LeetCode | 01-matrix/Time Limit Exceeded/7-24-2021, 11_51_04 AM/Solution.cpp | // https://leetcode.com/problems/01-matrix
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
static auto _ = []() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
return 0;
}();
class Solution {
public:
vector<vector<int>>dp;
bool isSafe(vector<vector<int>>... | ALGO | 0.999985 | 5.905476 |
37302cb7-6691-4fbd-b1a8-ca6421b97a45 | nafiz512/Codeforces | A_cAPS_lOCK.cpp | #include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define f first
#define s second
#define endl '\n'
#define pb push_back
#define all(v) (v).begin(),(v).end()
const int mod =1e9+7;
const int N=1e6+2;
#define Pi 2.0 * acos(0.0);
const string ... | ALGO | 0.999916 | 4.726369 |
288e0e32-d4f7-45f5-9cfb-9817ef0090f1 | zeeshan941983/e-commerce | windows/runner/utils.cpp | #include "utils.h"
#include <flutter_windows.h>
#include <io.h>
#include <stdio.h>
#include <windows.h>
#include <iostream>
void CreateAndAttachConsole() {
if (::AllocConsole()) {
FILE *unused;
if (freopen_s(&unused, "CONOUT$", "w", stdout)) {
_dup2(_fileno(stdout), 1);
}
if (freopen_s(&unuse... | TOOL | 0.9988 | 6.76073 |
95505d78-678a-462c-928a-b1db02e39e49 | shiqiabi/Algorithem | 215_KthLargestElementInAry/215_KthLargestElementInAry.cpp | // 215_KthLargestElementInAry.cpp : Defines the entry point for the console application.
//
/*
寻找第K大的问题,这是一个典型的问题,同时也有典型的解法。
1. 分治法。类似于快速排序。该解法的时间复杂度是O(n),空间复杂度为O(n)
2. 堆排序法。它的时间复杂度可以按照下面进行分析:
a. 创建一个大小为k的小顶堆。O(klogk)
b. 将剩余元素依次插入到小顶堆中,如果小于堆顶元素,则丢弃该元素。如果大于堆顶元素则将该元素替换堆顶元素,整理堆 (nlogk)
c. 在b步骤结束后,堆顶元素就是第k大元素
... | ALGO | 0.999932 | 4.842628 |
59ede31f-c4b5-411b-afd6-645b93e638f4 | beerabbit/safestack | libcxx/test/std/numerics/rand/rand.dist/rand.dist.samp/rand.dist.samp.discrete/eval_param.pass.cpp | // <random>
// template<class IntType = int>
// class discrete_distribution
// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
#include <cassert>
#include <cstdlib>
#include <random>
#include <vector>
int main(int, char**)
{
{
typedef std::discrete_distribution<> D;
... | TEST | 0.956632 | 4.099044 |
edf85d82-f040-46d3-82ff-3d47b3af23cc | PuneetSharma52/basics | SumProDiff.cpp | #include<iostream>
using namespace std;
int main()
{
int sum = 0, product = 1, n;
cin>>n;
cout<<endl;
while(n!=0){
int digit = 0;
digit = n%10;
product*=digit;
sum+=digit;
n/=10;
}
cout<<product-sum<<endl;
return 0;
}
| ALGO | 0.999931 | 4.300415 |
7c42418a-647e-4cd8-9a6d-232dad9ad4aa | 1Rayquaza/InterviewBit | Tree Data Structure/Reverse Level Order.cpp | vector<int> Solution::solve(TreeNode* A) {
queue<TreeNode*> q;
stack<int> s;
vector<int> ans;
q.push(A);
if(A==NULL) return ans;
while(!q.empty()){
TreeNode* tmp = q.front();
q.pop();
s.push(tmp->val);
if(tmp->right) q.push(tmp->right);
... | ALGO | 0.99998 | 5.836493 |
a463b3d9-763a-4fe3-973c-01772d3d42a8 | nobi-nata/LeetCode-Problems | 34-find-first-and-last-position-of-element-in-sorted-array/find-first-and-last-position-of-element-in-sorted-array.cpp | class Solution {
public:
vector<int> searchRange(vector<int>& nums, int target) {
//TC: O(n);
// int n = nums.size();
// vector<int> ans;
// for(int i = 0; i < n; i++){
// if(nums[i] == target && ans.size() == 0) ans = {i, i};
// else if(nums[i] == ta... | ALGO | 0.999931 | 6.582041 |
4381cbff-0dc6-416a-bbcd-6cdb8c6b79bd | RoshanChef/DSA-2.0 | 6 LinkList/A singly/merge_sort.cpp | #include <iostream>
using namespace std;
class node
{
public:
int val;
node *next = 0;
node()
{
this->val = 0;
this->next = 0;
}
node(int val)
{
this->val = val;
this->next = 0;
}
};
// insertion
void insertTail(node *&head, node *&tail, int data)
{
... | ALGO | 0.999997 | 4.792276 |
db260041-63ef-4efc-b019-ac54a347da52 | fafa1899/BuildCppDependency | Source/geos-3.12.2/src/algorithm/HCoordinate.cpp | #include <geos/algorithm/HCoordinate.h>
#include <geos/algorithm/NotRepresentableException.h>
#include <geos/geom/Coordinate.h>
#include <memory>
#include <cmath>
#include <limits>
#include <iostream>
#include <iomanip>
#ifndef GEOS_DEBUG
#define GEOS_DEBUG 0
#endif
using namespace geos::geom;
namespace geos {
name... | ALGO | 0.99843 | 5.052065 |
342d742a-8a35-47f5-ba26-387540749bf1 | abhishek18124/PPCPPFeb2025 | Lecture 06/001IncrementAndDecrement.cpp | #include<iostream>
using namespace std;
int main() {
int x = 10;
// x++; // or ++x
++x;
cout << "x = " << x << endl;
int y = 20;
// y--; // or --y
--y;
cout << "y = " << y << endl;
return 0;
} | TOOL | 0.957252 | 3.450924 |
52a816c3-2b9c-424b-8137-924222889738 | mingc39/BOJ | 1000/1927_newPQ3.cpp | #include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#define PQSIZE 1048576
// ========< 켱 ť >========
char *a;
char *tmp1 = NULL, *tmp2 = NULL;
int memSize, memUnit = 1048576;
int s = sizeof(int);
int l = 0;
int (*cmp)(const void *, const void *); //
void swap(void *x, void *y, int size) {
memcpy(tmp2, y... | ALGO | 0.999931 | 4.269653 |
2860e5b0-9cba-4cb7-b1f0-7ea391ebb81c | Md-EmranHossen/Leetcode-Practice | 1944-truncate-sentence/truncate-sentence.cpp | class Solution {
public:
string truncateSentence(string s, int k) {
stringstream ss(s);
string word;
string ans;
int cnt = 1;
while (ss >> word) {
if(cnt <= k){
ans += word;
cnt++;
if(cnt <= k){
ans += " ";
}
... | ALGO | 0.999911 | 6.118995 |
9c09eca3-0f6d-4592-9ebb-aa08e20ccd9c | gaonK/AlgorithmStudy | Session 2/chws/Sort/11651_2.cpp | //11651 좌표 정렬하기 2
//cmp 함수 만들어서 짜보기
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
bool cmp(const pair<int, int> &a, const pair<int, int> &b){
if(a.second < b.second){
return true;
}else if(a.second == b.second){
return (a.first < b.first);
}else if(a.second... | ALGO | 0.999945 | 5.014478 |
7fd1887b-4a46-408b-a4d9-207602a90e9a | kyle-nguyennn/cp | Hackerrank/Prim/main.cpp | #include <iostream>
#include <bits/stdc++.h>
#define ii pair<int,int>
#define iii pair<int, ii>
#define vii vector<ii>
#define ff first
#define ss second
using namespace std;
int main()
{
int n, m;
cin >> n >> m;
vector<vii> g = vector<vii>(n+1, vii()); //from, to, weight
for (int i=0; i<m; i++){
... | ALGO | 0.999764 | 3.935087 |
f1b080fe-8efa-4c13-942f-1ca60c4c7bc9 | limjh5699/BOJ | C++/10773 - Zero.cpp | #include<iostream>
#include<stack>
using namespace std;
stack<int> s;
void solve()
{
int n;
cin >> n;
if(n != 0) s.push(n);
else s.pop();
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, temp=0;
cin >> n;
for(int i = 0; i < n; i++)
{
solve();
}
while (s.siz... | ALGO | 0.999948 | 4.061261 |
8cf97b63-f029-484e-949c-aa6673470403 | duzaao/3-Semestre-BCC-IME-USP | Desafios/L1 e L2/L2-d.cpp | #include<bits/stdc++.h>
using namespace std;
int main(){
string s;
cin >> s;//Leitura
map<vector<int>,long long> mp;
vector<int> cnt(10,0);
mp[cnt]++;
// Percorre a string s
for(auto &nx : s) {
int y = nx-'0';
cnt[y]++;//Incrementa o contador correspondente ao dígito atual
cnt[y]%=2;//Faz o módulo 2 do ... | ALGO | 0.999918 | 4.734428 |
adc4b0a9-9cca-4522-af5f-d2de2de4e54d | abestard/Code | find a primitive root of a prime number.cpp | // Algorithm to find a primitive root of a prime number
// Assuming the Riemnan Hypothesis it runs in O( log^6(p) * sqrt(p) )
//using: powmod()
int generator (int p){
vector<int> fact;
int phi = p-1, n = phi;
for (int i=2; i*i<=n; ++i)
if (n % i == 0){
fact.push_back (i);
whi... | ALGO | 0.999801 | 3.469625 |
3480dbe0-13d2-4764-92b7-f4d03ee1235b | freeway348/code | luogu/p1774.cpp | #include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 500010;
int a[N];
int n;
int b[N];
int tr[N];
int lowbit(int x)
{
return x & -x;
}
void add(int x, int c)
{
for (int i = x; i <= n; i += lowbit(i))
tr[i] += c;
}
int query(int x)
{
int ans = 0;
fo... | ALGO | 0.999978 | 4.072694 |
ea8237f2-4ca6-49f7-b6a9-238777da850a | Medea-Di-Wu/PigCode | Copy_List_with_Random_Pointer.cpp | /**
* Definition for singly-linked list with a random pointer.
* struct RandomListNode {
* int label;
* RandomListNode *next, *random;
* RandomListNode(int x) : label(x), next(NULL), random(NULL) {}
* };
*/
class Solution {
public:
RandomListNode *copyRandomList(RandomListNode *head) {
if... | ALGO | 0.999345 | 4.828248 |
92d53d7c-287f-4e53-81d9-9f70f4636b8a | voe09/CPPPlayGround | 2024/priorityqueue/1845.cpp | class SeatManager {
public:
SeatManager(int n) {
for (int i = 1; i <= n; i++) q.push(i);
}
int reserve() {
int t = q.top();
q.pop();
return t;
}
void unreserve(int seatNumber) {
q.push(seatNumber);
}
private:
priority_queue<int, vector<int>,... | ALGO | 0.998682 | 6.595291 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.