uuid string | repo_name string | relative_path string | content string | category string | algo_rel_score float64 | quality_score float64 |
|---|---|---|---|---|---|---|
6ba65635-ba34-4fa1-b8b7-e51608cd1e8b | harsh13579/CPP-Codeforces-Codes | 800/gold_rush.cpp | #include<bits/stdc++.h>
using namespace std;
map<int, int>p;
int comp(int n,int m)
{
if(n==m)
return 1;
else
{
if(n>m && n%3==0)
{
if(!p.count(n/3))
{
p[n/3]=comp(n/3,m);
}
if(!p.count((n/3)*2))
{
... | ALGO | 0.999974 | 4.853348 |
9c71c90b-da96-4c31-b27e-d9b49bd1ef3d | ongaeshi/rubykokuban-osx | examples/3d/advanced3dExample/src/Swarm.cpp | #include "Swarm.h"
// This 'swarm' object demonstrates a simple particle system
// with 'simple harmonic motion'
swarm::swarm(){
light.setAmbientColor(ofColor(0, 0, 0));
}
void swarm::init(int nParticles, float positionDispersion, float velocityDispersion){
// Check if we've already initialised
if(particles.siz... | ALGO | 0.987292 | 4.48087 |
82d06ada-fa68-46a3-a165-5e3dcdc477a1 | squaresLab/BatFix | results/transcoder/python/semantics/FIND_ROTATION_COUNT_ROTATED_SORTED_ARRAY_1.cpp | #include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <fstream>
#include <iomanip>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <numeric>
#include <algorithm>
using namespace std;
int f_gold ( int arr [ ], int low, int high ) {
... | ALGO | 0.999857 | 5.740166 |
d5ebd0b2-c190-4a1e-89df-60e296652284 | Yubraj-Git-P/1st_SEM_C_Programming | call by reference ex.cpp | #include <stdio.h>
void wrong_swap(int a, int b);// call by value example
void swap(int *a, int *b);// call by reference example
int main ()
{
// call by value means sending value of the variables to the argunments.
// call by reference means sending value of the adress to the argunments.
int x = 200;
... | TOOL | 0.9935 | 4.865632 |
20d089d5-f926-4272-9fb1-d906ebc7e375 | mitesh-200228/DS-Algo-Whole-Chapter | Strings/5.cpp | #include<unordered_set>
#include<stack>
#include<iostream>
#include<vector>
#include<string>
#include<numeric>
#include<algorithm>
#include<queue>
#include <stdio.h>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<climits>
#include<cmath>
#include<math.h>
#include<limits>
#define ll long lo... | ALGO | 0.999943 | 5.519148 |
c6acc42b-6b81-42bf-b480-3d774d3a20cf | ezhou2008/algorithm-basic | cpp2/551-Nested-List-Weight-Sum.cpp | /*Nested List Weight Sum
Description
Given a nested list of integers, return the sum of all integers
in the list weighted by their depth. Each element is either an integer,
or a list -- whose elements may also be integers or other lists.
Example
Given the list [[1,1],2,[1,1]], return 10.
(four 1's at depth 2, one 2 a... | ALGO | 0.99976 | 6.085695 |
10906d51-6930-4513-9f11-adcd7ab3e58d | Vidit-Ostwal-zz/DSA-Codes | 2210-count-hills-and-valleys-in-an-array/2210-count-hills-and-valleys-in-an-array.cpp | class Solution {
public:
int countHillValley(vector<int>& nums) {
vector<int> hills;
vector<int> valleys;
for (int i = 1; i < nums.size()-1; i++)
{
int st = i;
int ed = i;
while (st>=0 && nums[st] == nums[i])
st--;
while (e... | ALGO | 0.999876 | 4.827132 |
0792ccbb-045a-418a-9085-d8e3c1ab8732 | coder-Utkarsh/Practice | pattern/nums3.cpp | #include<stdio.h>
int main()
{
int n, k;
printf("Enter n: ");
scanf("%d", &n);
k = n-1;
int num = 1;
for(int i=1; i<=n; i++)
{
for(int j=0; j<k; j++)
{
printf(" ");
}
for(int j=0; j<i; j++)
{
printf("%d ", num);
num++;
}
printf("\n");
k--;
num = 1;
}
}
| ALGO | 0.999858 | 3.455225 |
cd16d38c-8d57-42f4-bcdd-cdc6d8d6e7d9 | HEMPYCOIN/HYC | src/chain.cpp | #include "chain.h"
#include "legacy/stakemodifier.h" // for ComputeNextStakeModifier
/**
* CChain implementation
*/
void CChain::SetTip(CBlockIndex* pindex)
{
if (pindex == NULL) {
vChain.clear();
return;
}
vChain.resize(pindex->nHeight + 1);
while (pindex && vChain[pindex->nHeight] ... | ALGO | 0.977567 | 7.408217 |
db67afa3-5abb-4123-8f86-c487dd2c9fee | osipyonok/Templates | Geometry/point_in_convex_polygon.cpp | #include <bits/stdc++.h>
using namespace std;
template <class F>
struct Point {
F x, y;
Point() : x(0), y(0) {}
Point(const F& x, const F& y) : x(x), y(y) {}
void swap(Point& other) { using std::swap; swap(x, other.x); swap(y, other.y); }
template <class F1> explicit operator Point<F1> () const {
retur... | ALGO | 0.999989 | 4.995358 |
3aaebe14-6dce-4ee6-a9a9-12f42e521040 | hztttt/Synergistic_Optimization | lammps_DeepSPIN/src/MANIFOLD/manifold_cylinder_dent.cpp | // clang-format off
#include "manifold_cylinder_dent.h"
#include "math_const.h"
#include <cmath>
using namespace LAMMPS_NS;
using namespace user_manifold;
manifold_cylinder_dent::manifold_cylinder_dent( LAMMPS *lmp, int /*argc*/,
char **/*argv*/ ) : manifold(lmp)
{}
... | ALGO | 0.869539 | 5.94189 |
740cafdf-aa70-4c08-95b3-d7784b000422 | Dsxv/Templates | compress.cpp | #include <bits/stdc++.h>
using namespace std ;
#define int long long
pair<vector<int>,vector<int>> compress(vector<int>& a){
int n = a.size() ;
map<int,vector<int>> mp;
for(int i = 0 ; i < n ; i++){
mp[a[i]].push_back(i) ;
}
vector<int> ans(n) , mapped(n) ;
int cnt = 0 ;
for(auto i : mp){
for(auto j : i.se... | ALGO | 0.99998 | 4.169879 |
8d4bacfa-a7dd-498b-ab3c-b5e9aeac8b8a | Surya-Kumar-03/Leetcode-and-GFG-Problems | 1451-minimum-number-of-taps-to-open-to-water-a-garden/minimum-number-of-taps-to-open-to-water-a-garden.cpp | class Solution {
public:
int minTaps(int n, vector<int>& ranges) {
vector<int> maxReach(n + 1);
for (int i = 0; i < ranges.size(); i++) {
int start = max(0, i - ranges[i]);
int end = min(n, i + ranges[i]);
// Update the maximum reach for the leftmost position
... | ALGO | 0.999989 | 6.391058 |
223a888f-ba7f-4f93-bfe5-26217b4c51ea | hnmali/Leetcode | 409.cpp | class Solution {
public:
int longestPalindrome(string s) {
if (s.length() == 1)
return 1;
int ans = 0;
vector<int> small(26), capital(26);
for (int i = 0; i < s.length(); i++) {
if (s[i] >= 'a' && s[i] <= 'z')
small[s[i]-'a']++;
els... | ALGO | 0.999922 | 5.884934 |
36fb220b-5a80-4f2e-b5f3-3472b1d1a15b | 870819621/test | src/堆棋子.cpp | #include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
struct Point
{
int x = 0;
int y = 0;
}A[55];
int n;
vector<vector<int> > vvec;
int dist(int x, int y, const Point& obj)
{
return abs(x - obj.x) + abs(y - obj.y);
}
int main()
{
cin >> n;
for (int i = 1; i <= n; ++i)
... | ALGO | 0.999955 | 3.340413 |
40f12a92-90c1-4dd9-a898-7e64d033dcd7 | arpitsri3/carND_Path_Planning | src/Eigen-3.3/bench/sparse_trisolver.cpp |
//g++ -O3 -g0 -DNDEBUG sparse_product.cpp -I.. -I/home/gael/Coding/LinearAlgebra/mtl4/ -DDENSITY=0.005 -DSIZE=10000 && ./a.out
//g++ -O3 -g0 -DNDEBUG sparse_product.cpp -I.. -I/home/gael/Coding/LinearAlgebra/mtl4/ -DDENSITY=0.05 -DSIZE=2000 && ./a.out
// -DNOGMM -DNOMTL
// -I /home/gael/Coding/LinearAlgebra/CSparse/... | ALGO | 0.995512 | 4.875646 |
813c5607-63e7-4408-b4a7-a4b8826304ff | elmasi2393/ICOM | Practicas/Practicas 5/ej_1.cpp | #include <iostream>
#include <chrono>
#define N 10
using namespace std;
int main(int argc, char **argv){
auto begin = chrono::high_resolution_clock::now();
int rep[N], limits[N+1];
limits[0] = 0;
//Inicializo los limites de manera generica
for (int i = 0; i<N; i++){
limits[i+1] = (i+1) ... | ALGO | 0.992021 | 3.876557 |
ece417bf-4898-487f-8e1e-0a3a3e34d1e0 | BHIVE/BHIVE | branches/load_balance_dev/src/util/nr/ludcmp.cpp | #include <cmath>
#include "nr.h"
using namespace std;
void NR::ludcmp(Mat_IO_DP &a, Vec_O_INT &indx, DP &d)
{
const DP TINY=1.0e-20;
int i,imax,j,k;
DP big,dum,sum,temp;
int n=a.nrows();
Vec_DP vv(n);
d=1.0;
for (i=0;i<n;i++) {
big=0.0;
for (j=0;j<n;j++)
if ((temp=fabs(a[i][j])) > big) big=temp;
if (b... | ALGO | 0.999806 | 3.327995 |
ca41e7a4-6b05-4559-aa90-81a54d1c24c8 | nojhan/eodev | eo/test/t-MGE-control.cpp | //-----------------------------------------------------------------------------
// t-eoMGE.cpp
//-----------------------------------------------------------------------------
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifndef __GNUG__
// to avoid long name warnings
#pragma warning(disable:4786)
#endif // __GNUG_... | ALGO | 0.998768 | 6.172404 |
2b2ff5c1-3a85-4f77-bb2a-d6608b0ca1f7 | WanenGao/OriginalDuckdb | extension/icu/third_party/icu/common/stringtriebuilder.cpp | #include "utypeinfo.h" // for 'typeid' to work
#include "unicode/utypes.h"
#include "unicode/stringtriebuilder.h"
#include "uassert.h"
#include "uhash.h"
U_CDECL_BEGIN
static int32_t U_CALLCONV
hashStringTrieNode(const UHashTok key) {
return icu::StringTrieBuilder::hashNode(key.pointer);
}
static UBool U_CALLCO... | ALGO | 0.993619 | 7.441104 |
07a8b420-383f-4fa7-832a-e334229e86d7 | BrandonJamesDemeritt/Assignment-4-IslandPerimeter | IslandPerimeter/DemerittIslandPerimeter.cpp | #include <iostream>
#include <vector>
#include <fstream>
using namespace std;
//declare function with prototype
int calc_perimeter(const vector<vector<unsigned int>>&);
int main() {
//declare variables
unsigned int rows;
unsigned int columns;
unsigned int i;
unsigned int j;
unsigned int tempNum;
vector<vecto... | ALGO | 0.998157 | 5.011569 |
c75ecfae-b527-40ad-956b-63e28c99a13d | Shaf3eii/Problem-Solving-Library | Leet_Code/611. Valid Triangle Number/main.cpp | #include <bits/stdc++.h>
using namespace std;
class Solution {
public:
static int triangleNumber(vector<int>& nums) {
int n = (int)nums.size();
sort(nums.begin(),nums.end());
int valid = 0;
for(int i = 0 ; i < n - 2; ++i)
{
for(int j = i + 1 ; j < n - 1; ++j)
... | ALGO | 0.999959 | 4.922266 |
a27b3fbb-f7c5-4235-be6f-70502b13b17e | Zemux1613/Rekursion | Aufgabe2.cpp | #include "stdio.h"
int quad(int x) {
if (x == 0) return 0;
return (x - 1) + x + quad(x - 1);
}
int main() {
int i = 0;
scanf_s("%d", &i);
printf("%d", quad(i));
return -1;
}
| ALGO | 0.999936 | 4.113332 |
1bf85ee3-1a8c-438e-8246-7859b4f59cc8 | xliuGeonx/AliceVision_Xin | src/aliceVision/sfm/pipeline/structureFromKnownPoses/StructureEstimationFromKnownPoses.cpp | #include "StructureEstimationFromKnownPoses.hpp"
#include <aliceVision/matching/IndMatch.hpp>
#include <aliceVision/matching/metric.hpp>
#include <aliceVision/robustEstimation/guidedMatching.hpp>
#include <aliceVision/multiview/fundamentalKernelSolver.hpp>
#include <aliceVision/multiview/triangulation/Triangulation.hpp... | ALGO | 0.991284 | 6.90062 |
d0358e90-3cda-48ef-bcad-9a03988e3f8e | NicholasFan235/Google-Kickstart | 2020/Round C/Perfect Subarray/Solution2.cpp | #include <bits/stdc++.h>
#define maxn 10000005
long N;
std::vector<int> squares;
std::array<int, 100000> A;
std::array<int, 100005> sA;
std::unordered_map<int, int> sActr;
void calculateSquares(){
int i = 0;
while (true){
int i2 = i*i;
if (i2 >= maxn) break;
squares.push_back(i2);
... | ALGO | 0.999306 | 4.585219 |
318aea08-501a-488a-ae94-3f93e9ea91d0 | raincross7/code-similarity | codes/train_code/problem441/problem441_310.cpp | #include <bits/stdc++.h>
using namespace std;
using ll=long long;
int count(ll n){
int digits=0;
while(n){
n/=10;
digits++;
}
return digits;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
... | ALGO | 0.999816 | 4.410341 |
e97a1fbe-0626-41eb-b8d2-5d97ce3698c2 | tadeo041/aplicacion_ios | 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.998784 | 6.761023 |
d7c4632c-eeb1-4c6e-920f-f4f8915102e6 | DivyankSisodia/DSA-Problem-set | Word Search - GFG/word-search.cpp | //{ Driver Code Starts
#include<bits/stdc++.h>
using namespace std;
// } Driver Code Ends
class Solution {
public:
bool solve(vector<vector<char>>& grid, string word, int i, int j, int ws, int n, int m){
if(word.size() == ws){
return true;
}
if(i >=n || i<0 || j<0 || j>=m || gr... | ALGO | 0.999983 | 5.976414 |
6d5a3ebe-3e9e-4bdb-84d9-3cd32974fc0a | strange-suraj/LeetCode-Susbmission | 387-first-unique-character-in-a-string/387-first-unique-character-in-a-string.cpp | class Solution {
public:
int firstUniqChar(string s) {
map<char,int> m;
for(int i=0;i<s.length();i++){
m[s[i]]++;
}
for(int i=0;i<s.length();i++){
if(m[s[i]]==1){
return i;
}
}
return -1;
}
}; | ALGO | 0.999793 | 5.850605 |
5d00b90d-b4dd-4e8a-a473-90de1ae2b5a4 | NewtonPP/MLIAP-RANN | src/angle_hybrid.cpp | #include "angle_hybrid.h"
#include "atom.h"
#include "comm.h"
#include "error.h"
#include "force.h"
#include "memory.h"
#include "neighbor.h"
#include <cstring>
using namespace LAMMPS_NS;
static constexpr int EXTRA = 1000;
/* ---------------------------------------------------------------------- */
AngleHybrid::A... | TOOL | 0.940459 | 7.225414 |
9201ef8e-78b0-4220-827a-543a358ea094 | flowprimedesign/CIS25 | 5_pointers_memory.cpp | /*
PROGRAM: Assignment 5 - Pointers and Memory Management
Written by Luis Ibarra
Description: A program that uses pointers and dynamic memory allocation to manage an array of structs representing students.
This program includes a binary search function to find a student by ID.
Last modified: 6/29/25... | TOOL | 0.997706 | 6.960968 |
8e95ae0f-984e-4fc4-aa49-a8eac3b8838d | DiveshChauhan123/Leetcode | 1586-longest-subarray-of-1s-after-deleting-one-element/1586-longest-subarray-of-1s-after-deleting-one-element.cpp | class Solution {
public:
int longestSubarray(vector<int>& nums) {
int i=0;
int j=0;
int count=0;
int maxval=-1;
int noofzeros=0;
while(j<nums.size()){
if(nums[j]==0)count++;
if(count>1){
if(nums[i]==0)count--;
i+... | ALGO | 0.999908 | 6.112182 |
cc697fdc-f514-4f8e-8919-e3d7b7c4916a | alexandraback/datacollection | solutions_5634697451274240_0/C++/qwertier/B.cpp | #include<stdio.h>
#include<algorithm>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<string>
#define REP(i,n) for(int i=0; i<n; i++)
#define FOR(i,n) for(int i=1; i<=n; i++)
typedef long long LL;
using namespace std;
typedef pair<int,int> pii;
#define MP make_pair
char s[100],n;
int main(){... | ALGO | 0.999464 | 3.715243 |
64bbe7d5-bc99-49ee-b622-8f1555dab7d7 | chinuhub/ProofTraPar | src/SCTransSystem/SCTransSystem.cpp | /*
* SCTransSystem.cpp
*
* Created on: 10-Jun-2015
* Author: jaganmohini
*/
#include "SCTransSystem.h"
#include <boost/foreach.hpp>
#include <boost/assert.hpp>
extern "C" {
#include <stdio.h>
}
typedef std::tuple<struct autstate* ,std::tuple<std::set<struct autstate*,newsetofstatescomparator>,bool>> newsta... | ALGO | 0.994865 | 3.287847 |
f61582b9-7fee-4552-a5db-c3745ae42e59 | yusufy1ld1z/BLG223E-Data-Structures-HWs | huffman_algorithm/code/src/structs.cpp | //--- 2022-2023 Fall Semester Data Structure Assignment 2 ---//
//--------------------------//
//---Name & Surname: Yusuf YILDIZ
//---Student Number: 150210006
//--------------------------//
//-------------Do Not Add New Libraries-------------//
//-------------All Libraries Needed Were Given-------------//
#include <i... | ALGO | 0.9991 | 3.803415 |
0d3cc174-8b2b-4233-97cf-165a2ccaac01 | Ahmedsabib/Problem_Solving | Light OJ/Harmonic Number.cpp | #include <bits/stdc++.h>
using namespace std;
const int maxn = (int)1e6 + 5;
const double G = 0.57721566490;
double a[maxn];
void precomp() {
double ans = 0.0;
for (int i = 1; i <= 1000000; ++i) {
ans += 1.0/i;
a[i] = ans;
}
}
int main(int argc, char const *argv[]) {
ios_base::sync_with_stdio(false), ci... | ALGO | 0.999496 | 4.000863 |
c5a411a1-2410-465a-80b4-e85b12812747 | rportocarrero/Dynamics_Control | src/StateSpace.cpp | /*
This file implements a generic state-space model.
*/
#include "stateSpace.hpp"
VectorXd StateSpace::step(VectorXd u, double t){
VectorXd x_dot = this->A*this->x+this->B*u;
VectorXd y = this->C*this->x+this->D*u;
this->x = this->I.step(this->x, x_dot, t);
return y;
}
| ALGO | 0.99822 | 5.291778 |
1e8afd1d-e7b6-4ea2-9dd9-4cc8ee0cf14f | ConnectNitish/cp_practice | src/codeforces/B. Working out.cpp | // https://codeforces.com/contest/429/problem/B
#include<bits/stdc++.h>
using namespace std;
void print_matrix(vector<vector<int>>& arr){
for(int i = 1;i<arr.size();i++){
for(int j = 1;j<arr.size();j++){
cout<<arr[i][j]<<" ";
}cout<<"\n";
}
cout<<"\n";
}
int solve(vector<vector<int>>& arr){
int n = arr.... | ALGO | 0.999927 | 4.337661 |
b6a56404-9736-48e9-8263-c6ff3e64fbd7 | praymeta/Code-Up-Algorithm | PRG0_StringGrouping.cpp | #include <string>
#include <vector>
#include <algorithm>
using namespace std;
int solution(vector<string> strArr) {
int answer = 0;
vector<int> len(31, 0);
for (int i = 0; i < strArr.size(); i++) {
int str_len = strArr[i].length();
++len[str_len];
}
int max_val = *max_element(len.b... | ALGO | 0.999188 | 5.115508 |
f18e065b-ea80-4ae2-aee5-6ab6a1e37523 | SINGHxTUSHAR/DSA-SINGHxTUSHAR | Leetcode-Solutions/Max Points on a Line.cpp | class Solution {
public:
int maxPoints(vector<vector<int>>& points) {
int n = points.size();
if(n == 1) return 1;
int ans{0};
/*brute force approach*/
// for(int i=0; i<n; i++){ //for pt_1
// for(int j=i+1; j<n; j++){ //for pt_2
// int cnt = 2;
... | ALGO | 0.99997 | 5.913546 |
a3e1bff7-b972-466a-8ee5-af711e756188 | jonh14lk/Competitive_Programming | Dynamic programming and common problems/cht.cpp | #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 ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long int
#define endl '\n'
#defin... | ALGO | 0.999915 | 4.828429 |
f33534c4-36fd-4db2-ae63-6b816a250800 | justog220/Practica-CAR | TP 2/EJ 3/modulos/funciones3.cpp | #include "funciones3.h"
#include <iostream>
#include <vector>
using namespace std;
void MostrarConMPI(const void *sendbuf, int sendcnt, MPI_Datatype tipoDeDatoEnv, void *recvbuf, const int *recvcnt, const int *displs, MPI_Datatype tipoDeDatoRecv, int raiz, MPI_Comm comm)
{
int rank;
MPI_Comm_rank(comm, &rank)... | TOOL | 0.865146 | 4.000718 |
2639178e-1dfc-4001-be6d-a854b9bbd53b | serendipityConfusion/leetcode-pracitce | robII.cpp | //打家劫舍 Ⅱ
/*
你是一个专业的小偷,计划偷窃沿街的房屋,每间房内都藏有一定的现金。这个地方所有的房屋都围成一圈,这意味着第一个房屋和最后一个房屋是紧挨着的。
同时,相邻的房屋装有相互连通的防盗系统,如果两间相邻的房屋在同一晚上被小偷闯入,系统会自动报警。
给定一个代表每个房屋存放金额的非负整数数组,计算你在不触动警报装置的情况下,能够偷窃到的最高金额。
分析:
将环形链表拆为两个单链表进行比较
一个包含头节点,不包含尾结点, 一个包含为尾结点,不含头节点;保证了头尾不同时被偷窃;
*/
int rob(vector<int> &nums)
{
if... | ALGO | 0.999904 | 5.100556 |
b10761a8-0208-4a1e-b036-d1f5a9a982d6 | micky387/android_frameworks_av | media/libstagefright/codecs/amrnb/common/src/add.cpp | /*
Filename: /audio/gsm_amr/c/src/add.c
------------------------------------------------------------------------------
REVISION HISTORY
Description: Created separate file for add function. Sync'ed up with the
current template and fixed tabs.
Description: Changed all occurrences of L_sum with sum.
De... | ALGO | 0.998173 | 6.72331 |
a3409ac0-d01b-4419-a3da-5246e4105801 | shivanshu877/Redis_in_c-cpp | heap.cpp | #include <stddef.h>
#include <stdint.h>
#include "heap.h"
static size_t heap_parent(size_t i) {
return (i + 1) / 2 - 1;
}
static size_t heap_left(size_t i) {
return i * 2 + 1;
}
static size_t heap_right(size_t i) {
return i * 2 + 2;
}
static void heap_up(HeapItem *a, size_t pos) {
HeapItem t = a[pos... | ALGO | 0.999097 | 4.593915 |
80e75bd8-6fb6-4d70-a92e-e857b73acb5d | Satyabrat-Ojha/6_Companies_30_Days_Challenge | 0692-top-k-frequent-words/0692-top-k-frequent-words.cpp | class Solution {
public:
vector<string> topKFrequent(vector<string>& words, int k) {
sort(words.begin(),words.end());
vector<pair<int,string>> v;
for(auto s:words) {
if(v.empty() || s != v.back().second) v.push_back({1,s});
else v.back().first++;
}
sor... | ALGO | 0.999994 | 6.357372 |
364ad9be-83ee-4d1b-b96b-4cd6a1315d62 | kanukolluGVT/CP-and-DSA | sas-15-BishuAndSoldiers.cpp | v#include<bits/stdc++.h>
#define REP(i,n) for (int i = 1; i <= n; i++)
#define REP_(i,n) for (int i=0;i<=n;i++)
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define ii pair<int,int>6
#define vi vector<int>
#define vii vector<ii>
#define lli long long int
#define INF 1000000000
#define ... | ALGO | 0.999957 | 3.891448 |
184f00fa-5b72-4035-a6e2-a4f1da07387e | huxingyi/autoremesher | thirdparty/cgal/CGAL-5.1-beta1/examples/Surface_mesh_simplification/edge_collapse_surface_mesh.cpp | #include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Surface_mesh_simplification/edge_collapse.h>
#include <CGAL/Surface_mesh_simplification/Policies/Edge_collapse/Count_ratio_stop_predicate.h>
#include <chrono>
#include <fstream>
#include <iostream>
typedef CGAL::Simple_cartesian<double>... | ALGO | 0.973881 | 6.236105 |
098d4f2d-dc38-46f5-9ed4-7c7cba6dac02 | Cold5nap/stringJenia | stringJenia.cpp | #include <iostream>
#include <fstream>
#include <string>
using namespace std;
//глобальные переменные
const int rows = 8;
const int cols = 7;
const int numCoord = 3;
//...\_*_*_/.\_*_*_/.\_*_*_/.\_*_*_/.....
string stringFromFile(const char* direct)
{
char buff[150]; // буфер промежуточного хранения считываемого из ... | TOOL | 0.937478 | 3.602867 |
57b32108-9785-492b-a6df-2c9edddaea37 | quyykk/editor | source/Dictionary.cpp | #include "Dictionary.h"
#include <cstring>
#include <mutex>
#include <set>
#include <string>
using namespace std;
namespace {
// Perform a binary search on a sorted vector. Return the key's location (or
// proper insertion spot) in the first element of the pair, and "true" in
// the second element if the key is a... | TOOL | 0.951817 | 6.329907 |
b0625f27-a183-4516-a927-8c5cc2dad945 | tathya1001/CodeforcesSolutions | 935A_FafaandhisCompany.cpp | #include <bits/stdc++.h>
using namespace std;
void solve()
{
int n;
cin >> n;
int c = 0;
for (int i = 1; i < n; i++)
{
if (n % (n - i) == 0)
c++;
}
cout << c << endl;
}
int main()
{
int t = 1;
while (t--)
solve();
return 0;
}
| ALGO | 0.999432 | 4.746416 |
ec1c934b-97bc-4a3d-bb65-b40a838184a5 | anurag-garg01/LeetcodeSolutions | 0036-valid-sudoku/0036-valid-sudoku.cpp | class Solution {
public:
bool isValidSudoku(vector<vector<char>>& board) {
// 9*9 max iteration
int n = board.size();
int m = board[0].size();
set<string> s;
for(int i =0;i<n;i++){
for(int j=0;j<m;j++){
if(board[i][j]!='.'){
if(s.find("row... | ALGO | 0.999289 | 6.776378 |
c8f4e714-3996-4249-8c95-33d4b65f5558 | raincross7/code-similarity | codes/train_code/problem085/problem085_77.cpp | //#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;
int main() {
set<int> prime;
prime.insert(2);
prime.insert(3);
prime.insert(5);
prime.insert(7);
prime.insert(11);
... | ALGO | 0.999861 | 3.871872 |
2fa0f33d-87b9-47c0-be57-3246256b718f | sbsumitpro/Practical_cpp | Practice/Array/subarray_sum.cpp | #include<iostream>
#include<climits>
using namespace std;
void printSubarray(int arr[], int n){
int count =0;
int max_sum = INT_MIN;
for(int i =0; i<n; i++){
for(int j= i;j<n;j++){
count++;
int sum =0;
cout<<"Count:"<<count<<endl;
for(int k = i; k... | ALGO | 0.999964 | 4.492816 |
a4b5d1c9-7afb-4a7b-9ad6-4ee7df44f9f2 | daniNya/comp-prog-solutions | Codeforces/800 Difficulty/1948A - Special Characters.cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
for (int i = 0; i < t; i++) {
int n;
cin >> n;
if (n < 2 || n % 2) {
cout << "NO" << endl;
continue;
}
string res = "";
for (int j = 0; j < (n / 2); j++) {... | ALGO | 0.999816 | 5.382605 |
a1240ff2-d2f1-493d-bb49-7a049d21392e | pcadl0196/c-backjoon | chap03/2438.cpp | #include <iostream>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
for(int j = 1; j <= t; j++)
{
for(int i = 1; i <= j; i++)
{
cout << "*" ;
}
cout << "\n";
}
return 0;
} | ALGO | 0.999942 | 3.799496 |
3c554334-8439-4ca0-939a-b5d1b160c445 | carmeAl/EA-minim2-repaso | FrontEnd-AppEA/flutter_application/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.998111 | 6.785645 |
d2ccdd9c-060b-4d3b-bfc5-54716ce1aa59 | sarvex/leetcode-tsh | solution/0700-0799/0757.Set Intersection Size At Least Two/Solution.cpp | class Solution {
public:
int intersectionSizeTwo(vector<vector<int>>& intervals) {
sort(intervals.begin(), intervals.end(), [&](vector<int>& a, vector<int>& b) {
return a[1] == b[1] ? a[0] > b[0] : a[1] < b[1];
});
int ans = 0;
int s = -1, e = -1;
for (auto& v : i... | ALGO | 0.99995 | 6.025138 |
a5c03bf6-555a-4e35-99a0-08fccea8c546 | hjiang13/LLMs-in-IR | POJ-104/85/102.cpp | #include <iostream>
using namespace std;
int main()
{
char a[20][20];
int n,i,j,b=1;
cin >> "%d",&n);
for(i=0; i<n; i++){
cin >> "%s",a[i]);
for(j=0; a[i][j]!='\0'; j++){
b=1;
if(a[i][0]<='9'&&a[i][0]>='0'){
b=0; break; }
else if((a[i][j]<='9'&&a[i][j]>='0')||(a[i][j]<='Z'&&a[i][j]>='A')||(a[i][j]<='z'&&a[i][j]>='a')||... | ALGO | 0.998651 | 3.230898 |
5a84a2a6-6441-4323-9dbe-53609ed096c1 | Vzenun/Codeforces-Problems-Solutions | K-divisible_Sum.cpp | //Vidur goel
#include<iostream>
#include<string>
#include<cmath>
#include<climits>
#include<algorithm>
#include<cstddef>
#include<cstdio>
#include<vector>
#include<stack>
# define ll long long int
# define vec vector<long long int>
# define ul unsigned long long int
using namespace std;
int main(){
ios::sync_wi... | ALGO | 0.999823 | 3.771887 |
83f13bcf-0eaa-45a7-ace4-c33ebc3eecbe | ZhikangLai/LiteGeometry | LiteGeometryTool/LiteGeometry.cpp | #include "LiteGeometry.h"
#include <execution>
#include <numeric>
static constexpr std::array<int, 8> reorderIndexForCGAL = { 0,1,2,3,5,6,7,4 };
static Eigen::MatrixXd computeCovarianceMatrix(
const Eigen::MatrixXd& data,
bool unbiased = true
) {
Eigen::MatrixXd centered = data.rowwise() - data.colwise()... | ALGO | 0.999154 | 5.035716 |
4b52e61b-0b70-462b-bcc5-63d54b214c93 | bengxy/LeetCode | cpp/332_ReconstructItinerary.cpp | class Solution {
public:
unordered_map<string, priority_queue<string, vector<string>, std::greater<string>>> G;
vector<string> res;
vector<string> findItinerary(vector<pair<string, string>> tickets) {
for(auto iter:tickets){
G[iter.first].push(iter.second);
}
dfs("JFK");
r... | ALGO | 0.999973 | 5.882417 |
a7dfbb15-43ae-4184-8c63-96af92d87994 | taniaban2712/dsaRepo | CodeForces problems/thestringhasatarget.cpp | #include<bits/stdc++.h>
#define ll long long int
using namespace std;
void solve(){
ll n;
cin>>n;
string s="",w="";
cin>>s;
//for the smallest character
char ch=*min_element(s.begin(), s.end());
w+=ch;
int ind=0;//for finding out the index of the string
for(int i=n-1;i>=0;i--){
if(s[i]==ch){
ind=i;
br... | ALGO | 0.999971 | 4.471069 |
3e1f3b0d-5410-4cb9-920f-7fe0453db7f8 | vidit-04/A2Z-DSA-SHEET-STRIVER | Graph/Shortest Path Algorithms and Problems/City With the Smallest Number of Neighbors at a Threshold Distance.cpp | #include<bits/stdc++.h>
using namespace std;
int findCity(int n, vector<vector<int>>& edges, int distanceThreshold) {
vector<vector<int>> adjList(n,vector<int>(n,INT_MAX));
for(auto it:edges){
adjList[it[0]][it[1]]=it[2];
adjList[it[1]][it[0]]=it[2];
}
for(int i=0;i<n;i++){
adjL... | ALGO | 0.999988 | 4.972987 |
a82dfeb4-10df-48de-aad7-2a2c52a14485 | paulo-vc/poo-faculdade | POO 1 - C++/Lista de exercicios/Nível 2/Exercicio4.cpp | #include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
cout << " TROCA DE VALORES "<<endl<<endl;
float x,y,troca;
cout<<"Primeiro valor: "<<endl;
cin >> x;
cout<<"Segundo valor: "<<endl;
cin >>y;
troca=x;
x=y;
y=troca;
cout<<"Valor x: "... | ALGO | 0.980762 | 3.645432 |
9cbe0251-ee51-4882-9979-e1a282d01833 | technojam/Ultimate_Algorithms_Repository | Array ADT/Array_ADT_Basic_Functions.cpp | #include<stdio.h>
struct Array //structure Array Definition
{
int A[10];
int length;
int size;
};
void Display(struct Array arr) // Display() displays the elements in the array
{
printf("\n");
for(int i=0;i<arr.length;i++)
{
printf("%d ",arr.A[i]);
}
}
... | TOOL | 0.956382 | 3.645411 |
9fd86cfc-d7cc-4f93-9604-7ea17e0f1aba | ishandutta2007/codeforces | kostia244/normal/1285/B.cpp | #pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-opti... | ALGO | 0.999956 | 3.794778 |
6d885958-8d7c-4234-ae1b-049f9e3711ed | occidere/leetcode | Algorithms/94_Binary_Tree_Inorder_Traversal/Solution.cpp | #include <cstdio>
#include <vector>
#include <stack>
#include <set>
using namespace std;
/**
* 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:
vecto... | ALGO | 1 | 6.519254 |
12ca9a75-0cc1-42fb-9455-d2b29bec09ec | Katsudon10/Competitive-programming | Atcoder/競技プログラミングの鉄則/B64.cpp | #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
const int inf = INT_MAX;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
vector<int>dxs={1,0,-1,0};
vector<int>dys={0,1,0,-1};
//fixed << setprecision(10)
//A[i].... | ALGO | 0.999998 | 3.879583 |
c99b04ab-77a2-4d2a-a049-93a394c7b188 | Dice101mahi/CP | Walking Master.cpp | #include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define llu long long unsigned
#define ld double
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define pb push_back
#define bp pop_back
#define pf push_front
#define fp pop_front
#define pp pop_up
#define mp mak... | ALGO | 0.999502 | 3.699536 |
ec1b7ba3-1275-43dc-8078-6c66ac658962 | fmof/unified-probabilistic-frames | ferrum/ferrum/dmc.cpp | #include "ferrum/dmc.hpp"
#include "ferrum/mathops.hpp"
#include "ferrum/logging.hpp"
#include "ferrum/util.hpp"
#include "ferrum/mathops.hpp"
#include <cmath>
#include <gsl/gsl_sf_gamma.h>
#include <gsl/gsl_sf_log.h>
#include <gsl/gsl_sf_psi.h>
#include <gsl/gsl_randist.h>
#include <Eigen/Dense>
#include <vector>
... | ALGO | 0.997916 | 3.271829 |
922de530-9028-44dc-8116-81cdf3d09d68 | saikatcodec/CP | Codeforces/B_Permutation_Value.cpp | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define nl "\n"
#define ll long long
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define p... | ALGO | 0.999885 | 5.103461 |
58d38ef8-a5f7-46bc-bca5-c99cc9c4e092 | Aledo-Jun/BOJ | MyAnswers/1948.cpp | //
// Created by june0 on 2024-02-23.
//
#include <bits/stdc++.h>
#include <bits/extc++.h>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define endl '\n'
using namespace std;
using namespace __gnu_cxx;
using ll [[maybe_unused]] = long long;
using ull [[maybe_unused]] = unsigned long long;
us... | ALGO | 0.99997 | 5.209033 |
29d4613e-24b6-4564-9da3-5198e4ccda7c | limon2009/ACM-UVA-Online-Judge-solution | 694.cpp | #include<stdio.h>
long long start,limit,n;
int cycle() {
long long p = start;
n = 0;
while(p <= limit && p != 1) {
if(p % 2 == 0)
p = p / 2;
else
p = 3 * p + 1;
n ++;
}
if(p == 1) n ++;
return 0;
}
int main() {
long long kase = 0;
while(1) {
scanf("%lld%lld",&start,&limit);
i... | ALGO | 0.999601 | 3.873837 |
4fbe2fc5-2137-4160-85b8-bdd724b5698d | Taya666/gem5_LAD | src/systemc/tests/systemc/misc/user_guide/chpt11.5/mean.cpp | /*****************************************************************************
mean.cpp --
Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15
*****************************************************************************/
/*****************************************************************************
... | ALGO | 0.999382 | 4.605412 |
3db2820a-b2c3-4c1d-9cea-db4fee7a4a40 | JawwadUmar/Coding | Codeforces/B_Points_and_Minimum_Distance.cpp | #include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = 1e9+7;
#define endl '\n'
int binaryExponentiation(int x, int p){
int res = 1;
while(p){
if(p%2){
res = (res * x)%MOD;
}
x = (x*x)%MOD;
p = p/2;
}
return re... | ALGO | 0.999274 | 3.989026 |
126bd75f-1f0d-4768-b8ce-1eb1589273a9 | amarnath-nitt/cpp-application | fundamentals/practice/medium/Sorting_Questions/Frequency sorting of an array/code.cpp | #include<iostream>
#include<vector>
#include<bits/stdc++.h>
#include<stdlib.h>
#define ll long long int
using namespace std;
void frequencySort(vector<int>v, int n){
map<int,int>m;
for(int i=0; i<n; i++){
m[v[i]]+=1;
}
vector<pair<int,int>>V;
for(auto &x:m){
V.push_back(x);
}
sort(V.begin(), V.end(),[](const... | ALGO | 0.999992 | 4.977902 |
3eff6722-5d77-438e-9023-a3861d6c4b64 | sandhiya1912/ComplaintVision | 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.998733 | 6.76775 |
aa5a751e-b41e-460e-ae78-58f46c6fd31f | RahulAdyaa/DSA_GITHUB | LC/LC:2410_Max_Match_of_Players_With_Trainers.cpp | #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class Solution {
public:
int matchPlayersAndTrainers(vector<int>& players, vector<int>& trainers) {
// Sort both arrays to use greedy matching
sort(players.begin(), players.end());
sort(trainers.begin(), trainer... | ALGO | 0.99993 | 6.498059 |
20959fc9-2996-4476-9874-3d639c2e183e | Joby-John/strivers_dsa_list | IBM/FIZZBUZZ.cpp | // ->from range 1 to n includive.
// ->if % by 3 and 5- fizzbuzz
// -> if% by 3 and not 5- fizz
// -> if % by 5 and 3 - buzz
#include<bits/stdc++.h>
using namespace std;
class Solution{
public:
void fizzBuzz(int n)
{
for(int i = 1; i<=n; i++)
{
if(i%15 == 0)
{
... | ALGO | 0.999791 | 5.692645 |
94e7faf1-374b-4b67-830a-a3f93b6144b8 | ketanprakash/Programming | DSA Learn Apna College/Deque/createDequeArray.cpp | //Program to create a deque using circular array
#include <bits/stdc++.h>
#define int long long
#define uint unsigned long long
#define SIZE 10
#define endl '\n'
using namespace std;
int DEQUE[10];
int front = -1;
int rear = -1;
bool empty(){
return front == -1;
}
bool full(){
return front == (rear + 1) % S... | ALGO | 0.999957 | 4.599276 |
c25a23bd-a19f-4a87-8625-aad111db9cf7 | Tahsin005/Leetcode | Leetcode daily challanges/41_most_common_words.cpp | #include<bits/stdc++.h>
#define ll long long
using namespace std;
/*
https://leetcode.com/problems/most-common-word/
*/
class Solution {
public:
string mostCommonWord(string paragraph, vector<string>& banned) {
for (auto &ch: paragraph) {
if(!isalpha(ch)) ch = ' ';
... | ALGO | 0.99997 | 5.952456 |
1f167863-5d28-47ff-994e-dc188d14a8eb | ishandutta2007/codeforces | peti1234/normal/1674/E.cpp | #include <bits/stdc++.h>
using namespace std;
long long n, t[200005], ans=2e9, pos=1;
int main()
{
ios_base::sync_with_stdio(false);
cin >> n;
for (int i=1; i<=n; i++) {
cin >> t[i];
if (t[i]<t[pos]) pos=i;
}
for (int i=1; i<=n; i++) {
if (i!=pos) {
ans=min(ans, ... | ALGO | 0.999883 | 3.95565 |
a88507db-54bb-4e44-9658-b0a4b5c3d57f | mrigank-iitkgp/Practice-Codes | InterestingXOR_MarchLong.cpp | /* Author: Mrigank
Science is what we understand well enough to explain to a computer,
Art is everything else we do - Donald E. Knuth */
/*
Problem Link - https://www.codechef.com/MARCH21C/problems/IRSTXOR */
#include <iostream>
#include <unordered_map>
#include <map>
#include <queue>
#include <stack>
#include <... | ALGO | 0.999955 | 4.266666 |
03f777cd-1a38-43cc-a800-4a1a6ed483c2 | KulwinderSingh04/Data-Structures | 99-recover-binary-search-tree/recover-binary-search-tree.cpp | /**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
* TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), l... | ALGO | 0.999995 | 6.149773 |
15adf8d6-406a-4387-a917-9885c3a3bdca | del10208102/Dijkstra-with-Heaps | fib.cpp | #include "fib.h"
#include <iostream>
node initialnode(int vertex, int dist)//初始化节点
{
node x = (node)malloc(sizeof(struct FibNode));
x->vertex = vertex;
x->dist = dist;
x->degree = 0;
x->left = x->right = x;
x->parent = x->child = NULL;
x->marked = 0;
return x;
}
heap initialheap()//初始化... | ALGO | 0.999991 | 3.847021 |
19d7c914-dd7b-40a3-8320-7d7ae9feb0f6 | LenovoTab2A7/android_system_core-mt8127 | libpixelflinger/fixed.cpp | #include <stdio.h>
#include <private/pixelflinger/ggl_context.h>
#include <private/pixelflinger/ggl_fixed.h>
// ------------------------------------------------------------------------
int32_t gglRecipQNormalized(int32_t x, int* exponent)
{
const int32_t s = x>>31;
uint32_t a = s ? -x : x;
// the result... | ALGO | 0.999324 | 5.276729 |
cc2bbd0c-921a-4094-bc65-ecf04fe36a85 | GGoMak/Algorithm | baekjoon/19238.cpp | #include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
/*
* 백준 19238번 : 스타트 택시(18%)
*
* BFS
*/
typedef struct Node {
int startX, startY;
int desX, desY;
}Node;
typedef struct Node2 {
int x, y, cnt;
}Node2;
typedef struct Node3 {
int n, x, y, cnt;
}Node3;
using namespace std... | ALGO | 0.999951 | 5.264471 |
bc1d21e9-4945-44ba-b78b-f7ee9f382b6d | ColinWu0403/Leetcode | Leetcode 75/215_KthLargestElementInAnArray.cpp | /**
Given an integer array nums and an integer k, return the kth largest element in the array.
Note that it is the kth largest element in the sorted order, not the kth distinct element.
Can you solve it without sorting?
Note: I used quickselect which solves in O(n) average time but for some reason,
leetcode adds a t... | ALGO | 0.999991 | 6.124871 |
7be5a328-5486-40f7-844f-2761b67237a0 | Nikhileshs19/DSA | leetcode/recursion/1922_CountGoodNumbers.cpp | class Solution {
public:
const int m = 1000000007;
long long f(long long x, long long y) {
if (y==0) return 1;
if (y==1) return x;
long long s = f(x, y/2);
if (y & 1) {
return s * s % m * x % m;
} else {
return s * s % m;
}
}
... | ALGO | 0.999984 | 5.854092 |
d08c7ddc-32b6-4ff9-a011-7eaa8d7925e6 | ishandutta2007/codeforces | dingdingsb/normal/1411/G.cpp | // Problem: CF1411G No Game No Life
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/CF1411G
// Memory Limit: 250 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define chkmx(a,b) ((a)=max((a),(b)))
#define chkmn(... | ALGO | 0.999948 | 4.592201 |
a2b898fa-6033-4f23-87fe-63e131803961 | sebastienmeyer2/mst-clustering | src/union_find.cpp | #include "union_find.hpp"
// Constructor(s) / Destructor(s)
UnionFind::UnionFind(std::vector<Node*> nodes)
{
/*!
* @brief Builds the Union-Find data structure from a vector
* of nodes
*
* @param nodes Nodes of the graph
*
*/
this->num_classes = nodes.size();
for(Node* n :... | ALGO | 0.986758 | 5.496087 |
c171bb3d-0607-40f1-9ad4-c930226b5e86 | evanzhaaa/coding_projects | C++/CCC 2000/CCC 2000 - Problem J3S1 - Slot Machines.cpp | #include <iostream>
using namespace std;
int main()
{
int quarters, slot1, slot2, slot3;
int count = 0;
cout << "How many quarters does Martha have in the jar?" << endl;
cin >> quarters;
cout << endl << "How many times has the first machine been played since paying out?" << endl;
cin >> slot1... | ALGO | 0.998808 | 3.608686 |
85f2e26a-5545-40cd-8fdb-81ee3e8815b3 | Ayuzh0/BasicProgramming | 2ndsem/C++ (3rd sem)/sample.cpp | #include<iostream>
using namespace std;
class sum
{
private:
int a,b,s;
public:
sum(int x,int y)
{
a=x;
b=y;
}
sum(sum &ob)
{
a=ob.a;
b=ob.b;
}
void output()
{
s=a+b;
c... | TOOL | 0.914124 | 4.58166 |
fa28f6dc-369c-43eb-8ba4-8002a79d007b | deprecated-armory3d/blender_chromium | extern/carve/lib/pointset.cpp | #if defined(HAVE_CONFIG_H)
# include <carve_config.h>
#endif
#include <carve/geom.hpp>
#include <carve/pointset.hpp>
namespace carve {
namespace point {
PointSet::PointSet(const std::vector<carve::geom3d::Vector> &points) {
vertices.resize(points.size());
for (size_t i = 0; i < points.size(); ++i)... | ALGO | 0.959366 | 6.86426 |
8d0b2c7b-c329-47ae-a9da-551267c9f941 | baojinchang/PAT | The Missing Number.cpp | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int n;
cin >> n;
vector<int> flag(n+1);
for (int i = 0; i < n; i++)
{
int temp;
cin >> temp;
if (temp>0&&temp<=n)
{
flag[temp] = 1;
}
}
int i;
... | ALGO | 0.999949 | 3.473567 |
57b84907-988f-434a-b5e7-822ad2689418 | yeon-kyu/algorithm_exercise | 백준/1399 단어 수학.cpp | #include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
int N;
vector<string> v;
map<char, int> m;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
//N ܾ. 빮ڷθ
// ĺ 빮ڸ 0 9 ڷ ٲ N ϴ
int answer = 0;
cin >> N;
... | ALGO | 0.99992 | 4.434122 |
28ba2f49-90ad-4a5b-a07b-7b0852f5991d | ishandutta2007/codeforces | nantf/normal/1251/A.cpp | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=100010;
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) me... | ALGO | 0.999965 | 4.008972 |
e8b1b317-792e-4ab5-88b7-136f6a37f384 | yuguoshao/boost | libs/sort/example/parallelint.cpp | // See http://www.boost.org/libs/sort for library home page.
#include <boost/sort/spreadsort/spreadsort.hpp>
#include <boost/thread.hpp>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <sstream>
#include <iostream>
using nam... | ALGO | 0.998542 | 4.560397 |
cc697a78-a6c6-4205-a857-3860deabae55 | LiYifei1218/ursaworks-control | taproot/src/tap/algorithms/contiguous_float.cpp | #include "contiguous_float.hpp"
#include <cmath>
namespace tap
{
namespace algorithms
{
ContiguousFloat::ContiguousFloat(const float value, const float lowerBound, const float upperBound)
{
this->value = value;
this->lowerBound = lowerBound;
this->upperBound = upperBound;
this->validateBounds();
... | ALGO | 0.995387 | 6.605609 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.