uuid stringlengths 36 36 | repo_name stringlengths 5 133 | relative_path stringlengths 3 3.76k | content stringlengths 282 4.03M | category stringclasses 6
values | algo_rel_score float32 0.9 1 | quality_score float32 3 8.13 | source_meta dict |
|---|---|---|---|---|---|---|---|
9fcf4eaa-13e6-4470-b816-475b3cbbe591 | djwoun/2020-2021-Personal-and-School-Projects | lab - bit controller/lab2.cpp | // lab.cpp
// The program takes in a string and up to two integers for commands.
//The user can manipulate an extremely large number of bits with the program.
// <NAME>
// 02/04/2021
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <math.h>
#include <limits>
using namespace std;
clas... | ALGO | 0.931183 | 5.24652 | {
"github_metadata": {
"branch": "main",
"commit_count": 11,
"repo_created_at": "2021-06-01T23:17:35.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "10cc5c817ec... |
11d239fc-7a8a-462c-a525-758b2bcd520c | ML-UCV/ML-CodeBert-DistinctSolutions | Raw Dataset/party/kosaraju/test/576800cd-02b2-11ec-b426-2cf05d84bfc2.cpp | #include <bits/stdc++.h>
using namespace std;
ifstream fin ("party.in");
ofstream fout ("party.out");
const int Nmax = 300;
int x, y, tip, n, m, i, nrc, where[Nmax];
vector<int> v[Nmax], vt[Nmax], ord, come;
bool used[Nmax];
int no(int x) {return x + n;}
void add_edge(int x, int y)
{
v[x].pus... | ALGO | 0.999939 | 3.907181 | {
"github_metadata": {
"branch": "main",
"commit_count": 3,
"repo_created_at": "2022-03-06T17:44:46.000Z",
"is_fork": false,
"is_org_owned": true,
"forked_from": null,
"stars": 1,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "42b99fee3866c... |
984932fe-40fc-4f9e-a861-7d3800302e36 | ems1203/Programiranje-3 | Zadaca_5.cpp | #include <iostream>
#include <map>
#include <queue>
using namespace std;
int main()
{
int n;
cin>>n;
map <string,tuple<int,int,int>> m;
tuple <int,int,int> t;
string ime,prezime;
int l,p,v;
queue <string> licna,pasos,vozacka;
for(int i=0;i<n;i++)
{
cin>>ime>>prezime;
... | ALGO | 0.999254 | 3.314465 | {
"github_metadata": {
"branch": "main",
"commit_count": 10,
"repo_created_at": "2023-04-03T07:14:43.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "8469beacd7d... |
4896f1c5-b97b-4895-a4bd-9e893db66ee2 | hackybacky/my-leet | Kadane's Algorithm - GFG/kadanes-algorithm.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 find the sum of contiguous subarray with maximum sum.
long long maxSubarraySum(int a[], int n){
// Your code here... | ALGO | 0.999728 | 5.943627 | {
"github_metadata": {
"branch": "main",
"commit_count": 4070,
"repo_created_at": "2022-01-08T16:47:02.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 1,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "ec076a727... |
f74969eb-3061-429d-b2fb-154e0ac207dc | wsyunine/ACM | 2025/001/CF2072/B.cpp |
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <mutex>
#include <queue>
#include <set>
#include <stack>
#include <thread>
#include <vector>
using namespace... | ALGO | 0.999906 | 3.941989 | {
"github_metadata": {
"branch": "master",
"commit_count": 17,
"repo_created_at": "2025-01-13T06:58:17.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 1,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "8187fd656... |
9f597f66-6667-4a92-ad1f-3372e4d1d1c4 | RoboticsClubIITK/2020_rover | rover_voxblox_planner/src/voxblox_planner.cpp | #include <voxblox_planner/voxblox_planner.hpp>
namespace rover::planner {
PlannerNode::PlannerNode(ros::NodeHandle& nh, ros::NodeHandle& nh_private)
: sampler_()
, server_(nh, nh_private)
, p_sample_(10) {
planner_server_ = nh_private.advertiseService("plan", &PlannerNode::plannerServiceCallback, this... | ALGO | 0.995957 | 4.108037 | {
"github_metadata": {
"branch": "master",
"commit_count": 101,
"repo_created_at": "2020-05-20T16:31:30.000Z",
"is_fork": false,
"is_org_owned": true,
"forked_from": null,
"stars": 4,
"forks": 16,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "43677dc8... |
9fee1337-974e-44fe-825f-cafccc83f946 | WeiJenLee/final | fraig/src/cir/cirOpt.cpp | /****************************************************************************
FileName [ cirSim.cpp ]
PackageName [ cir ]
Synopsis [ Define cir optimization functions ]
Author [ Chung-Yang (<NAME> ]
Copyright [ Copyleft(c) 2008-present LaDs(III), GIEE, NTU, Taiwan ]
*************************... | ALGO | 0.998539 | 5.331186 | {
"github_metadata": {
"branch": "master",
"commit_count": 14,
"repo_created_at": "2017-01-13T10:12:53.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 1,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "1ea01909d... |
cdb1bf57-c5a4-48c4-9cb0-8d42db2fd33c | abdull-ah-med/PF | Week5/PF-LAB-WEEK-5/evenishoddish.cpp | #include <iostream>
#include <iostream>
using namespace std;
string evenishoddish(int num);
main()
{
int num;
string eo;
cout << "Enter a number: ";
cin >> num;
eo = evenishoddish(num);
if (eo == "even")
{
cout << "The given number " << num << " is evenish." << endl;
}
if (eo == "odd")
{
cout << "The... | ALGO | 0.996512 | 3.850859 | {
"github_metadata": {
"branch": "main",
"commit_count": 2,
"repo_created_at": "2023-05-28T13:40:50.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "3f9e785bd597... |
716467fb-e474-41eb-87fb-c7c4768bc2e2 | BqdrEss/AlgoDataStruct | a9/a9/a9_2_a_b.cpp | #include <iostream>
using namespace std;
#include <bits/stdc++.h>
template<class T>
class Linkedlist{
protected:
struct list { // linked list
T data;
list * next;
};
list * top; // top of stack
public:
Linkedlist()
{
this->top = NULL;
}
void push(T x){ // if size set, check for over... | ALGO | 0.999848 | 5.031454 | {
"github_metadata": {
"branch": "main",
"commit_count": 1,
"repo_created_at": "2021-12-03T01:15:23.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "12b9b6de1b96... |
dffcb673-2696-40b0-93a7-7461823319fe | NeoYY/Leetcode-Solution | 283. Move Zeroes.cpp | /*
Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.
Example:
Input: [0,1,0,3,12]
Output: [1,3,12,0,0]
Note:
You must do this in-place without making a copy of the array.
Minimize the total number of operations.
Solution one using i... | ALGO | 0.999972 | 6.747005 | {
"github_metadata": {
"branch": "master",
"commit_count": 49,
"repo_created_at": "2020-01-28T21:23:38.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "234d85c30... |
e66c0361-b425-4ed1-87eb-0e2909e0c021 | wantonsolutions/RemoteDataStructres | rcuckoo_rdma/search.cpp | #include "search.h"
#include <string>
#include <vector>
#include <set>
#include "tables.h"
#include "hash.h"
#include "log.h"
#include <unordered_map>
#include <iostream>
#include <assert.h>
#include <algorithm>
namespace cuckoo_search {
using namespace std;
using namespace cuckoo_tables;
unsigned int get... | ALGO | 0.999735 | 3.779887 | {
"github_metadata": {
"branch": "master",
"commit_count": 749,
"repo_created_at": "2022-10-20T17:45:24.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 2,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "b8436108... |
2ff2cc1e-0ff7-4a09-b691-20505bdb357a | Mi022/camel-code-raisim-cpp | src/CAMEL-Quad-SingleLeg/SingleLeggedIDController.cpp | //
// Created by jaehoon on 22. 6. 6.
//
#include "SingleLeggedIDController.h"
void SingleLeggedIDController::setPDGain(double PGain, double DGain) {
this->PGain = PGain;
this->DGain = DGain;
}
void SingleLeggedIDController::doControl() {
updateState();
setTrajectory();
// IKsolve();
computeCo... | ALGO | 0.960935 | 4.442612 | {
"github_metadata": {
"branch": "main",
"commit_count": 130,
"repo_created_at": "2022-10-17T05:40:46.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "260ab3ed18... |
6ece4e32-b1c9-43ac-8377-00c3c035e7b3 | arnavinator/codingtank | remove-sorted-list-duplicates/iterative-deletion.cpp | /**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode() : val(0), next(nullptr) {}
* ListNode(int x) : val(x), next(nullptr) {}
* ListNode(int x, ListNode *next) : val(x), next(next) {}
* };
*/
class Solution {
public:
ListNode* deleteDupli... | ALGO | 0.9999 | 5.831103 | {
"github_metadata": {
"branch": "main",
"commit_count": 23,
"repo_created_at": "2021-12-17T19:17:28.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "88c3e4f9f41... |
5170d490-e8c9-45eb-a3ae-c194882fb930 | hirakuni45/glfw3_app | glfw3_app/dx7emu/src/fir.h | /*
* Copyright 2013 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed... | TOOL | 0.955751 | 6.525015 | {
"github_metadata": {
"branch": "master",
"commit_count": 2564,
"repo_created_at": "2013-07-04T20:09:51.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 13,
"forks": 1,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "40b515... |
3109fb15-a8e5-4268-b97d-5a42919f3c59 | tyeasmino/XPSC_Batch_4 | Week 01/Day 03/O_Traffic_Light.cpp | #include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
while (t--)
{
int n;
char start;
cin >> n >> start;
string s;
cin >> s;
s += s;
int cnt = 0, result = 0;
if(start == 'g') {
cout << 0 << endl... | ALGO | 0.999557 | 3.411259 | {
"github_metadata": {
"branch": "main",
"commit_count": 87,
"repo_created_at": "2024-03-15T16:28:09.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "61ba30b6e79... |
a75de7a3-b327-43fd-8260-173bda9f9575 | FabricadeAlgoritmos/.cpp | Classificacao/MenuSort/main.cpp | #include <iostream>
#include "sort.h"
using namespace std;
int vetor[10];
void opcoes(char);
void menu();
int main(){
menu();
return 0;
}
void menu(){
setlocale(LC_ALL, "Portuguese");
gerarVetor(vetor);
system("cls");
char r = ' ';
while(r != 's'){
cout << "\n\tMétodos de Ordenação\n" << endl;
cout << "... | ALGO | 0.9984 | 3.928884 | {
"github_metadata": {
"branch": "master",
"commit_count": 11,
"repo_created_at": "2017-07-24T03:05:39.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 1,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "434368c78... |
df2ad135-d88b-4669-8c39-65de3cbbc734 | konstantinAriel/myTest | myLib/Lapackpp1.1a/matrix/src/utgmd.cc | //
// LAPACK++ 1.1 Linear Algebra Package 1.1
// University of Tennessee, Knoxvilee, TN.
// Oak Ridge National Laboratory, Oak Ridge, TN.
// Authors: <NAME>, <NAME>, <NAME>, <NAME>
// (C) 1992-1996 All Rights Reserved
//
// NOTICE
... | ALGO | 0.949142 | 4.242782 | {
"github_metadata": {
"branch": "master",
"commit_count": 1,
"repo_created_at": "2017-01-24T09:06:21.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "503acdb605... |
7bc46b3b-e178-4944-943c-fe82d2d3d1a1 | korytkinn/CPP-programming-MAI-2021 | Practice/Подготовка к зачету/Zachet_1/main.cpp | #include <iostream>
using namespace std;
class Dynmas
{
int* massiv;
int razmer;
public:
static int kolvo;
Dynmas()
{
massiv = nullptr;
razmer = 0;
kolvo++;
}
~Dynmas()
{
delete[] massiv;
kolvo--;
}
Dynmas(const Dynmas& ob); // копирование запрещено
Dynmas& operator=(const Dynmas& ob); // прис... | TOOL | 0.98992 | 3.779378 | {
"github_metadata": {
"branch": "main",
"commit_count": 4,
"repo_created_at": "2023-02-02T11:27:35.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "6dada37be36d... |
a7c2107d-9934-43dc-b6b2-154cbf5072fa | bulletphysics/bullet3 | examples/SharedMemory/plugins/stablePDPlugin/SpAlg.cpp | #include "SpAlg.h"
#include <iostream>
cSpAlg::tSpVec cSpAlg::ConvertCoordM(const tSpVec& m0, const tVector& origin0, const tVector& origin1)
{
return ConvertCoordM(m0, origin0, origin1, tMatrix::Identity());
}
cSpAlg::tSpVec cSpAlg::ConvertCoordM(const tSpVec& m0, const tVector& origin0, const tMatrix& R0,
... | ALGO | 0.98094 | 5.816405 | {
"github_metadata": {
"branch": "master",
"commit_count": 9404,
"repo_created_at": "2011-04-12T18:45:08.000Z",
"is_fork": false,
"is_org_owned": true,
"forked_from": null,
"stars": 13557,
"forks": 2973,
"issues": 238,
"pull_requests": 141
},
"file_meta": {
"content_id"... |
6e846796-892e-4e35-ab2b-947b305b15a4 | hasib9963/DS-Module-24-Last- | unique_sorted.cpp | #include <bits/stdc++.h>
using namespace std;
// Function to sort an array in descending order and remove duplicates
void sortArray(vector<int> &arr)
{
// Sort the array in descending order
sort(arr.begin(), arr.end(), greater<int>());
// Remove duplicates from the sorted array
arr.erase(unique(arr.be... | ALGO | 0.999934 | 6.317483 | {
"github_metadata": {
"branch": "main",
"commit_count": 5,
"repo_created_at": "2024-07-11T18:11:50.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "23ebb0f338e0... |
c96a957c-8f9e-4751-9549-9b937e385a64 | shaihitdin/CP | Olymp/Sbory_12_2015/8/I.cpp | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 1000, sz = 1 << 18;
const ll oo = 1e16;
struct node {
ll mx, as1, as2;
node () {
mx = as1 = as2 = -oo;
}
node (node Tl, node Tr) {
mx = as1 = as2 = -oo;
mx = max (mx, Tl.mx);
mx = max (mx, Tr.mx);
mx = max (mx, Tl.... | ALGO | 0.999981 | 3.413398 | {
"github_metadata": {
"branch": "master",
"commit_count": 18,
"repo_created_at": "2017-01-22T16:38:32.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 1,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "b1942745e... |
7db6959c-55b7-4aac-aa88-0419c46de5ab | mhj980411/code | coding_test/불안한 무빙워크.cpp | #include <iostream>
#include <deque>
using namespace std;
int n, k;
deque<pair<int, bool>> movingwork_dq; // 안정성, 사람이 있는지 없는지 표현
deque<int> person_index_dq;
int answer;
void Input() {
cin >> n >> k;
int stable;
for (int i = 0; i < 2 * n; i++) {
cin >> stable;
movingwork_dq.push_back({ stable,false });
}
}
... | ALGO | 0.999944 | 3.520867 | {
"github_metadata": {
"branch": "main",
"commit_count": 13,
"repo_created_at": "2025-02-23T11:31:36.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "9b43d30820c... |
aa8bcdb3-f896-472e-83ca-d25b33b91b21 | VictorGordan/opengl-tutorials | Tessellation Shaders/libraries/include/GLA/mat/mat2/mat2.cpp | #include "mat2.hpp"
const mat2 mat2::identity = mat2(
1.0f, 0.0f,
0.0f, 1.0f);
const mat2 mat2::zero = mat2(
0.0f, 0.0f,
0.0f, 0.0f);
mat2::mat2(float val)
{
a00 = val; a01 = 0.0f;
a10 = 0.0f; a11 = val;
}
mat2::mat2(const float matrix[2][2])
{
a00 = matrix[0][0]; a01 = matrix[1][0];
a10 = ma... | TOOL | 0.969363 | 5.851762 | {
"github_metadata": {
"branch": "main",
"commit_count": 77,
"repo_created_at": "2021-03-11T20:59:46.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 1217,
"forks": 456,
"issues": 18,
"pull_requests": 0
},
"file_meta": {
"content_id": "be499... |
613458c2-0448-4d44-89d4-562ba72d96d3 | Jinyon92/Backjoon | Backjoon5052/Backjoon5052/main.cpp | #include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int TrieNode = 10;
struct Trie{
Trie *next[TrieNode];
bool nextChild;
bool finish;
Trie(){
fill(next, next+TrieNode, nullptr);
finish = nextChild = false;
}
~Trie(){
for(in... | ALGO | 0.999793 | 4.103231 | {
"github_metadata": {
"branch": "master",
"commit_count": 217,
"repo_created_at": "2019-03-19T06:11:31.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 1,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "b90a3162... |
98146363-8759-4205-93c9-ecaa818deafc | PointCloudLibrary/pcl | surface/include/pcl/surface/3rdparty/opennurbs/opennurbs_hsort_template.h | #if !defined(ON_COMPILING_OPENNURBS_HSORT_FUNCTIONS)
/*
See opennurbs_sort.cpp for examples of using openurbs_hsort_template.c
to define type specific heap sort functions.
*/
#error Do not compile openurbs_hsort_template.c directly.
#endif
// ON_SORT_TEMPLATE_TYPE -> double, int, ....
#if !defined(ON_SORT_TEMPLATE_TYP... | ALGO | 0.999903 | 5.404157 | {
"github_metadata": {
"branch": "master",
"commit_count": 14566,
"repo_created_at": "2013-02-12T16:40:25.000Z",
"is_fork": false,
"is_org_owned": true,
"forked_from": null,
"stars": 10495,
"forks": 4656,
"issues": 432,
"pull_requests": 147
},
"file_meta": {
"content_id... |
ca7de562-f4da-47d0-b143-7386f716f29a | LutzGross/esys-escript.github.io | trilinos_source15/packages/rol/adapters/sacado/test/HS/HS_Problem_011.hpp | // @HEADER
// ************************************************************************
//
// Rapid Optimization Library (ROL) Package
// Copyright (2014) Sandia Corporation
//
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
// license for use of this work by or on be... | ALGO | 0.996856 | 4.602505 | {
"github_metadata": {
"branch": "master",
"commit_count": 5724,
"repo_created_at": "2020-08-10T02:31:18.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 34,
"forks": 15,
"issues": 63,
"pull_requests": 0
},
"file_meta": {
"content_id": "83c9... |
a53ae35c-510c-4742-be6f-9c7db4c2da26 | hyeon-BL/Coding-problem | Gold/Gold5/Fly me to the Alpha Centauri.cpp | #include <iostream>
#include <vector>
using namespace std;
int main()
{
cin.tie(0);
ios::sync_with_stdio(0);
int T;
cin >> T; // 테스트 케이스
while (T--)
{
long long x, y;
cin >> x >> y; // x: 시작점, y: 도착점
long long dist = y - x; // 거리
// steps: 이동 횟수, move... | ALGO | 0.99992 | 4.340745 | {
"github_metadata": {
"branch": "main",
"commit_count": 473,
"repo_created_at": "2024-02-15T05:15:04.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "0692a3c48a... |
f0abfce9-ec8f-4b4c-8432-de0ead7dabef | alibaba-edu/mpc4j | mpc4j-native-tool/ntl_poly/edu_alibaba_mpc4j_common_tool_polynomial_gf2e_NtlNativeGf2ePoly.cpp | /*
* Created by <NAME> on 2021/12/11.
*
* 2022/10/19 updates:
* Thanks the anonymous USENIX Security 2023 AE reviewer for the suggestion.
* In setTojByteArray and jByteArrayToSet, we need to free the memory (in set) allocated in the interpolation function.
* All heap allocations (e.g., auto *p = new uint8_t[]) ar... | ALGO | 0.995909 | 5.75001 | {
"github_metadata": {
"branch": "main",
"commit_count": 49,
"repo_created_at": "2022-08-01T06:39:38.000Z",
"is_fork": false,
"is_org_owned": true,
"forked_from": null,
"stars": 235,
"forks": 54,
"issues": 4,
"pull_requests": 0
},
"file_meta": {
"content_id": "c4234f76b... |
4a1ce143-d880-4712-8392-870d9cda156a | andy-liuu/personal-DMOJ-Solutions | ECOO/ECOO '14 R3 P4 - Baby Talk.cpp | #include <bits/stdc++.h>
using namespace std;
int main(){
for ( int x = 0;x<10;x++){
string word;
cin>>word;
int len = word.size();
int dp[len+2];
for(int q = 0;q<len+2;q++){
dp[q] = 0;
}
int ans = 0;
for (int i = 1;i<len+1;i++){
... | ALGO | 0.999881 | 3.898172 | {
"github_metadata": {
"branch": "master",
"commit_count": 103,
"repo_created_at": "2020-09-08T03:51:05.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "7befdf86... |
3f1efe6c-31ad-4c29-8029-36802f0fff39 | amanpatel23/mya2oj_repo | DynamicProgramming/Alphacode_Iteravtive.cpp | /*
Created By: <NAME>
Date: 08-07-2021
*/
#include <iostream>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstring>
#include <cmath>
#include <bitset>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <cstdli... | ALGO | 0.999865 | 4.169402 | {
"github_metadata": {
"branch": "main",
"commit_count": 29,
"repo_created_at": "2021-07-06T18:54:24.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "5293e591b9b... |
5d64902a-45b2-489f-a36d-c4dcc2b40941 | SBidaibek/acm | opencup_moscode/g.cpp | #include <bits/stdc++.h>
using namespace std;
#define forn(i, x, n) for (int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for (int i = int(n); i >= int(x); --i)
#define F first
#define S second
#define pb push_back
typedef long long ll;
typedef pair <int, int> pii;
typedef long double ld;
typedef vector <int>... | ALGO | 0.999985 | 3.226097 | {
"github_metadata": {
"branch": "master",
"commit_count": 3,
"repo_created_at": "2019-02-13T16:09:18.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 1,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "44f3f033a1... |
99884694-5af7-4993-895d-aecf3d831f9f | Xilinx/Vitis_Libraries | dsp/L1/src/hw/ifft_front_transpose/ifft_front_transpose.cpp | /*
* Copyright (C) 2019-2022, Xilinx, Inc.
* Copyright (C) 2022-2025, Advanced Micro Devices, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licens... | ALGO | 0.985598 | 6.92592 | {
"github_metadata": {
"branch": "main",
"commit_count": 471,
"repo_created_at": "2019-09-23T19:13:46.000Z",
"is_fork": false,
"is_org_owned": true,
"forked_from": null,
"stars": 988,
"forks": 381,
"issues": 0,
"pull_requests": 12
},
"file_meta": {
"content_id": "628dc3... |
1598484f-6757-4658-bbb1-c3e1c9b28084 | joy-roy-swe/Leetcode | intersection-of-two-linked-lists/intersection-of-two-linked-lists.cpp | /**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode *getIntersectionNode(ListNode *headA, ListNode *headB) {
// Initialize two pointers, ptr1 and ptr2, to the heads of... | ALGO | 0.999546 | 5.605939 | {
"github_metadata": {
"branch": "main",
"commit_count": 231,
"repo_created_at": "2023-10-30T17:28:01.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "891fc4ce0e... |
dfdacc5f-e863-4ccf-80ad-a9d2b9d15f7c | janusboandersen/DSA | src/22_generate_parentheses_backtracking.cpp | /**
* @file src/22x_generate_parentheses_backtracking.cpp
* @author <NAME>
* @brief Solution to LeetCode prob. 22 using recursive backtracking.
* @version 1.0
* @date 2023-06-27
*
* @copyright Copyright (c) 2023
*
*/
#include <iostream>
#include <22/generate_parentheses_backtracking.hpp>
namespace p22_back... | ALGO | 0.998658 | 6.43753 | {
"github_metadata": {
"branch": "main",
"commit_count": 1,
"repo_created_at": "2023-07-02T11:20:12.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "50a1127d428c... |
f301b038-5347-4a2d-bad1-72e520aeee47 | jwseph/competitive-programming | alphastar/silver/advanced_a/turtle_hopping.cpp | #include <bits/stdc++.h>
using namespace std;
#define MAXN 30
int R, C, X, Y, A[MAXN][MAXN];
bool V[MAXN][MAXN];
queue<pair<int, int>> Q;
int main() {
cin >> R >> C >> X >> Y;
for (int r = 0; r < R; ++r) {
for (int c = 0; c < C; ++c) {
cin >> A[r][c];
if (A[r][c] == 3) {
... | ALGO | 0.99978 | 3.954075 | {
"github_metadata": {
"branch": "main",
"commit_count": 121,
"repo_created_at": "2023-02-23T23:41:03.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 2,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "b56a842372... |
9b03d896-d635-4c9b-a538-544ac8caca95 | Matistjati/Competitive-programming-solutions | open/litagreining.cpp | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> p2;
#define rep(i, high) for (int i = 0; i < (high); i++)
#define repp(i, lo, high) for (int i = (lo); i < (high); i++)
#define repe(i, container) for (auto& i ... | ALGO | 0.999732 | 3.873993 | {
"github_metadata": {
"branch": "master",
"commit_count": 870,
"repo_created_at": "2021-09-14T12:27:55.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "5df60384... |
d2fdcc58-7918-4915-bb1a-45b9a0454338 | myoun/algorithm | 6086.cpp | #include <iostream>
#include <vector>
#include <queue>
#define MAX 701
#define INF 1000000
using namespace std;
int n, result;
int c[MAX][MAX], f[MAX][MAX], d[MAX];
vector<int> a[MAX];
void maxFlow(int start, int end) {
while (1) {
fill(d, d + MAX, -1);
queue<int> q;
q.push(start);
... | ALGO | 0.999826 | 4.200122 | {
"github_metadata": {
"branch": "master",
"commit_count": 32,
"repo_created_at": "2023-01-11T12:28:37.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 1,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "a80bd70d5... |
24da5195-6396-4b64-a2cf-25c9f5b643d7 | ABRG-Models/morphologica | standalone_examples/recurrentnet/RecurrentNetworkTools.h | /*!
* \file
*
* \brief Some utility code relevant to RecurrentNetworkModel
*
* \author <NAME>
* \date 2020
*/
#include <vector>
#include <array>
namespace recurrentnet {
namespace tools {
template <class T>
std::vector<T> getUnique(std::vector<T> x){
std::vector<T> unique;
... | TOOL | 0.980045 | 5.897126 | {
"github_metadata": {
"branch": "main",
"commit_count": 4360,
"repo_created_at": "2018-06-19T08:32:21.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 307,
"forks": 36,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "ac2a9a... |
148e0169-68af-4010-849f-e033f501b788 | justbeingamei/CS-303-Assignment-3 | CS-303-Assignment-3/Assignment3.h | #ifndef ASSIGNMENT3_H
#define ASSIGNMENT3_H
#include <iostream>
#include <vector>
using namespace std;
//////////////////////////////////////////////////////////
// Question 1: Template Queue Class Implementation
//////////////////////////////////////////////////////////
template <typename T>
class Queue {
private:
... | ALGO | 0.99779 | 6.447712 | {
"github_metadata": {
"branch": "master",
"commit_count": 3,
"repo_created_at": "2024-11-08T00:41:17.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "2412b1a00f... |
33937592-af51-4183-ba16-382fbe11feb1 | WillGreen98/LeetCode | Cpp/Medium/1443-MinimumTimeToCollectAllApplesInATree.cpp | /*
* @lc app=leetcode id=1443 lang=cpp
*
* [1443] Minimum Time to Collect All Apples in a Tree
*/
// @lc code=start
class Solution {
public:
int dfs(int n, int r, vector<vector<int>> &edges, vector<bool> &hasApple) {
int seconds = 0;
for(int leaf : edges[n]) {
i... | ALGO | 0.999819 | 5.761798 | {
"github_metadata": {
"branch": "main",
"commit_count": 169,
"repo_created_at": "2021-07-16T05:54:49.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "63a556e051... |
18432ec4-470a-40d2-9ea4-17702e71b77b | Louis-tiany/Cpp_learn | algorithm/data_struct/graph/connective/scc.cpp | #include<iostream>
#include<list>
#include<stack>
using namespace std;
class Graph
{
private:
int V;
list<int>* adj;
void dfsUtil(int v,bool visited[]);
public:
Graph(int V){this->V=V;adj=new list<int>[V];}
// ~Graph(){delete [] adj;}
void addEdge(int v,int w);
Graph getTranspose();
bool isSC();
};
... | ALGO | 0.999942 | 5.342763 | {
"github_metadata": {
"branch": "master",
"commit_count": 19,
"repo_created_at": "2019-08-28T11:26:41.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "bf07aeafd... |
6def4322-abb8-4ce8-a36e-7b320dde5435 | Shikhar-S/Analysis-of-Competitive-Codebase | Data/Contest1236/all/29086653_62791017.cpp | #include <bits/stdc++.h>
using namespace std;
#define long long long int
int main() {
ios::sync_with_stdio(false);
int n;
cin >> n;
vector <vector<int>> ans(n, vector<int>(n));
int cur = 1;
for (int j = 0; j < n; ++j) {
if (j % 2 == 0) {
for (int i = n - 1; i > -1; --i... | ALGO | 0.999974 | 3.908213 | {
"github_metadata": {
"branch": "master",
"commit_count": 74,
"repo_created_at": "2019-11-22T14:40:44.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "f40f18b86... |
8f3d928d-8695-4b5e-bfb2-5f21a17c43df | stonne-simulator/stonne | pytorch-frontend/third_party/ideep/mkl-dnn/tests/benchdnn/rnn/rnn_cell.cpp | /*******************************************************************************
* Copyright 2019-2020 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apa... | ALGO | 0.964333 | 5.848589 | {
"github_metadata": {
"branch": "master",
"commit_count": 90,
"repo_created_at": "2020-12-01T17:24:14.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 134,
"forks": 30,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "9aea83... |
78915272-d889-4213-a248-a81931bd1949 | civctp2/civctp2 | ctp2_code/ui/aui_common/aui_rectangle.cpp | #include "c3.h"
#include "aui_rectangle.h"
BOOL Rectangle_Clip( RECT *clipee, RECT *clipper )
{
BOOL hasNonzeroArea = TRUE;
if ( clipee->right < clipper->left )
{
clipee->left = clipee->right = clipper->left;
hasNonzeroArea = FALSE;
}
else
{
if ( clipee->left > clipper->right )
{
clipee->left =... | TOOL | 0.976358 | 5.979725 | {
"github_metadata": {
"branch": "master",
"commit_count": 3056,
"repo_created_at": "2018-10-11T00:20:01.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 84,
"forks": 29,
"issues": 81,
"pull_requests": 13
},
"file_meta": {
"content_id": "884... |
6508306c-8cc4-4f89-adeb-288e916d7a87 | mhcrnl/1000ProgrameC | 037F22Cprog/C_cursuri/PhoneBook-master (2)/PhoneBook.cpp | #include "PhoneBook.h"
#include "PhoneBookItem.h"
#include "algorithm"
#include <string.h>
//#define _AFXDLL
//#include <afxwin.h>
//#define new DEBUG_NEW
PhoneBook::PhoneBook(){
length = 0;
m_head = new PhoneBookItem("",-99,"");
m_num = 0;
}
PhoneBook::PhoneBook(const PhoneBook& pb){
Copy(pb);
}
Ph... | TOOL | 0.939654 | 4.131773 | {
"github_metadata": {
"branch": "master",
"commit_count": 26,
"repo_created_at": "2016-09-27T19:12:24.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 6,
"forks": 1,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "6b329c887... |
c40c5448-230f-4087-8b6c-31f597ae55a4 | Sushantchaudhary1/DSA-with-C | Linked_List/LINKLIST.CPP | //single linear linked list
#include<stdio.h>
#Include<alloc.h>
#include<conio.h>
#include<process.h>
//Declaration of Structure
typedef struct simplelink{
int data;
struct simplelink *next;
}node;
//Fun of Create first node
node *create(node *p){
p=(node *)malloc(sizeof(node));
}
{
int a; printf("\n\n");
node *brr[25... | ALGO | 0.999693 | 4.411917 | {
"github_metadata": {
"branch": "main",
"commit_count": 28,
"repo_created_at": "2023-04-06T05:10:34.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "3b2a8354b9d... |
4a5b0822-469e-4b3a-97eb-8588825066f7 | oliver-anh-nguyen/algorithm_cp | Algorithmic Complexity/SquareTiles/SquareTiles/main.cpp | //
// main.cpp
// SquareTiles
//
// Created by AnhNguyen on 23/11/2023.
//
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int r, c;
string a[60];
void solve() {
for (int i = 0; i < r - 1; i++) {
for (int j = 0; j < c - 1; j++) {
if (a[i][j] == '#' && a[i][j+1] == '#' &&... | ALGO | 0.999849 | 4.777147 | {
"github_metadata": {
"branch": "main",
"commit_count": 62,
"repo_created_at": "2023-12-21T23:16:14.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "839f09e34bf... |
70905566-7804-4e99-ad40-0e74fdca154d | HPCSYSPROS/Workshop20 | Application_performance_in_frontera_acceptance_process/artifacts/namd/code/NAMD_2.12_Source/src/GlobalMasterSymmetry.h | /**
*** Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000 by
*** The Board of Trustees of the University of Illinois.
*** All rights reserved.
**/
#ifndef GLOBALMASTERSYMMETRY_H
#define GLOBALMASTERSYMMETRY_H
#include "GlobalMaster.h"
#include "PDBData.h"
#include <map>
#include <vector>
#include "Matrix4Symmetry.h... | TOOL | 0.972945 | 4.385462 | {
"github_metadata": {
"branch": "master",
"commit_count": 28,
"repo_created_at": "2020-12-10T22:00:26.000Z",
"is_fork": false,
"is_org_owned": true,
"forked_from": null,
"stars": 6,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "462c7240ac... |
e24faafd-e2ee-4038-8ab0-8870aad7d870 | HERECJ/FINISH | 1068.cpp | #include <iostream>
using namespace std;
int these[40]={0};//不超过20,最多包含40个字符
int NumOfCases;
int len,LEN;
int those[40]={0};
int WInvert(){
int s = 1;
while(1){
if(these[len]==0)
{
len++;
s += WInvert();
}
else
{
those[LEN++]=s;
... | ALGO | 0.999967 | 3.337867 | {
"github_metadata": {
"branch": "master",
"commit_count": 3,
"repo_created_at": "2017-08-08T13:16:23.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "fda9c08e77... |
3f3767bd-14d1-4c6d-b5e9-9ccde7b39d31 | davidea97/MEMROC | src/MobileHandEyeCalibrator.cpp | //
// Created by davide on 11/12/23.
//
#include "MobileHandEyeCalibrator.h"
MobileHandEyeCalibrator::MobileHandEyeCalibrator(const int number_of_waypoints, const int sens_quantity, const std::vector<cv::Mat> h2e_initial_guess_vec,
const std::vector<std::vector<int>> cr... | ALGO | 0.998372 | 5.68766 | {
"github_metadata": {
"branch": "main",
"commit_count": 16,
"repo_created_at": "2024-03-15T09:23:14.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 6,
"forks": 1,
"issues": 1,
"pull_requests": 0
},
"file_meta": {
"content_id": "cabe50c3b87... |
8995e3d1-c449-4e52-a197-18129235d063 | windcry1/My-ACM-ICPC | NowCoder/3004 F.cpp | /*************************************************************************
>>> Author: WindCry1
>>> Mail: <EMAIL>
>>> Website: https://windcry1.com
>>> Date: 12/30/2019 11:03:37 PM
*************************************************************************/
//#pragma GCC optimize(3)
//#pragma GCC diagnostic error "-std=c... | ALGO | 0.999991 | 4.011615 | {
"github_metadata": {
"branch": "master",
"commit_count": 125,
"repo_created_at": "2020-01-03T16:13:26.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 1,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "02d00db4... |
d27f6364-6271-49b0-b528-53d88ebcaaa3 | rcedgar/regammon | src/pubeval.cpp | #include "myutils.h"
#include "bgboard.h"
#include "pubeval.h"
void PubEval::Setx()
{
for (int i = 0; i < 122; ++i)
m_x[i] = 0.0f;
for (int j = 1; j <= 24; ++j)
{
int jm1 = j - 1;
int n = m_Pos[25-j];
if (n != 0)
{
if (n == -1) m_x[5*jm1 + 0] = 1.0f;
if ... | ALGO | 0.998693 | 4.66924 | {
"github_metadata": {
"branch": "main",
"commit_count": 8,
"repo_created_at": "2023-10-10T21:41:24.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "4e82fdc8d08a... |
5688422a-a865-479d-8edd-bb92339c28eb | lnkkerst/oj-codes | src/luogu/P1004/26911837_ac_100_12ms_672k_noO2.cpp | #include <cctype>
#include <cstdio>
int e[10][10];
int f[10][10][10][10];
int n;
int read() {
int ret, f = 1;
char ch;
while (!isdigit(ch = getchar())) {
(ch == '-') && (f = -1);
}
for (ret = ch - '0'; isdigit(ch = getchar()); ret *= 10, ret += ch - '0')
;
return ret * f;
}
void print(int x) {
... | ALGO | 0.999836 | 3.487986 | {
"github_metadata": {
"branch": "main",
"commit_count": 56,
"repo_created_at": "2022-03-23T15:37:28.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 5,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "4cc8a0a8c39... |
d76b8263-6b9e-482d-8194-3700d437eeef | detectivemark7/aprg | AprgAlgorithm/AprgAlgorithm/tst/AlgorithmTests/Sort/RadixSorter/RadixSorterUsingQuickSortWith3WayPartitioning_unit.cpp | #include <Algorithm/Sort/RadixSorter/RadixSorterUsingQuickSortWith3WayPartitioning.hpp>
#include <AlgorithmTests/Sort/Utilities/CommonTestsWithSorter.hpp>
#include <AlgorithmTests/Sort/Utilities/StabilityCheckObject.hpp>
#include <gtest/gtest.h>
using namespace alba::algorithm::CommonTestsWithSorter;
using namespace ... | TEST | 0.995255 | 7.367303 | {
"github_metadata": {
"branch": "main",
"commit_count": 687,
"repo_created_at": "2021-08-07T08:34:54.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "d997cc9b56... |
89b49c72-ebfe-43a7-a8a8-10305645be27 | shanerbo/leetcode | C++(1st)/212.word-search-ii.cpp | /*
* @lc app=leetcode id=212 lang=cpp
*
* [212] Word Search II
*
* https://leetcode.com/problems/word-search-ii/description/
*
* algorithms
* Hard (30.62%)
* Likes: 1568
* Dislikes: 84
* Total Accepted: 146K
* Total Submissions: 471K
* Testcase Example: '[["o","a","a","n"],["e","t","a","e"],["i","h"... | ALGO | 0.999557 | 6.634362 | {
"github_metadata": {
"branch": "master",
"commit_count": 398,
"repo_created_at": "2019-09-27T03:03:50.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 1,
"forks": 0,
"issues": 2,
"pull_requests": 0
},
"file_meta": {
"content_id": "ea84f465... |
e94f8623-cb11-4009-948a-9b3b253953b1 | IshanGarg123/Love-Babbar-Coding-Course | Love Babbar/DP2/Lec-116/C++2.cpp | // Leet Code 1039
// Minimum Score Triangulation of Polygon
// Recursion + memorization
// T.C. = O(N^2) S.C = O(N^2);
#include <iostream>
using namespace std;
#include <limits.h>
#include <vector>
int solve(vector<int> &values, int i, int j, vector<vector<int>> &dp)
{
if (i + 1 == j)
{
return 0;
... | ALGO | 0.999987 | 5.275677 | {
"github_metadata": {
"branch": "main",
"commit_count": 5,
"repo_created_at": "2023-10-03T09:44:53.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "65b148e2b1c3... |
2b0a83ba-7237-4c58-b9f8-fd084fc39b79 | wassimalharaki/Codeforces | 1000/PolycarpRecoversthePermutation.cpp | #include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define nl << '\n'
#define pii pair<int, int>
#define v vector
#define vi v<int>
#define vvi v<vi>
#define vpii ... | ALGO | 0.999831 | 4.092708 | {
"github_metadata": {
"branch": "main",
"commit_count": 160,
"repo_created_at": "2023-09-19T17:56:25.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "23ebb3e4ef... |
198e40e3-cb79-45ee-af01-dc143ab96847 | ishandutta2007/codeforces-b | burunduk1/normal/335/A.cpp | /**
* Author: <NAME> (<EMAIL>)
* Date: 2013.08.03
*/
#include <cstdio>
#include <cassert>
#include <algorithm>
using namespace std;
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
const int N = 1010;
const int inf = (int)1e9;
int n, cnt[26];
char s[N];
int main()
{
scanf("%s%d", s, &n);
for (int i = ... | ALGO | 0.999847 | 3.346289 | {
"github_metadata": {
"branch": "main",
"commit_count": 2,
"repo_created_at": "2024-04-11T01:05:31.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 1,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "c37439346ac7... |
e81af87b-ad3b-4a25-9f2d-f9b8ffd77bb3 | WhatTheNathan/n-Algorithm | Introduction to Algorithms/Chapter10/DoubleLinkedList/DoubleLinkedList.h | #include <iostream>
#include "ListNode.h"
#ifndef _Nathan_DOUBLELINKEDLIST_H
#define _Nathan_DOUBLELINKEDLIST_H
namespace Nathan {
template <class T>
class DoubleLinkedList {
public:
DoubleLinkedList(ListNode<T>* first = nullptr);
bool isEmpty() const;
int getSize() const;
... | ALGO | 0.961801 | 5.997616 | {
"github_metadata": {
"branch": "master",
"commit_count": 138,
"repo_created_at": "2018-01-27T05:35:07.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "d0fa9b38... |
f228f3d5-025f-495e-a886-3e613a5af43f | paranumal/hipBone | libs/primitives/select.cpp | /*
The MIT License (MIT)
Copyright (c) 2017-2023 <NAME>, <NAME>, <NAME>, <NAME>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to us... | ALGO | 0.998397 | 5.263782 | {
"github_metadata": {
"branch": "main",
"commit_count": 148,
"repo_created_at": "2021-05-04T16:57:41.000Z",
"is_fork": false,
"is_org_owned": true,
"forked_from": null,
"stars": 17,
"forks": 7,
"issues": 2,
"pull_requests": 2
},
"file_meta": {
"content_id": "4708c6363b... |
2ccc53ee-0809-475c-9852-e36081dc311e | tsw303005/Coding-Practice | NTHU/13182 - Twenty One /function.cpp | #include "function.h"
#include <iostream>
using namespace std;
// casino
Casino::Casino() {
this->fee = 0;
this->guest_num = 0;
this->income = 0;
this->list_num = 0;
}
Casino::~Casino() {
for (int i = 0; i < this->guest_num; i++) delete this->guest[i];
}
void Casino::Enterance(int f) {
this->fee = f;
}
... | ALGO | 0.967358 | 3.428688 | {
"github_metadata": {
"branch": "master",
"commit_count": 56,
"repo_created_at": "2021-11-10T09:09:21.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "0c284ea9d... |
2fc79590-ca61-4256-b26b-8a44d0a99aca | yizhiweimengxiangfendoudefeifei/cell | src/Sample/pure_puresuit_control.cpp | #include "pure_puresuit_control.h"
purePursuit::purePursuit(const double kp, const double ki, const double kd) : control(kp, ki, kd){ }
double purePursuit::calculateCmd(const std::vector<RefPoint>& targetPath, PanoSimSensorBus::Lidar_ObjList_G* pLidar,
PanoSimBasicsBus::Ego* pEgo) {
(void)pEgo;
int index = 0;
in... | ALGO | 0.999873 | 4.816818 | {
"github_metadata": {
"branch": "master",
"commit_count": 61,
"repo_created_at": "2022-10-31T12:10:20.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 11,
"forks": 10,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "69c1a9b... |
472de247-4925-412d-97d7-54bc336f3458 | Salah-Tamer/Algorithms | 05 Depth First Search (DFS)/HW 01 - 3 Easy Challenges/03_Number Of Connected Components.cpp | #include <iostream>
#include <vector>
using namespace std;
typedef vector<vector<int>> GRAPH;
void AddUnDirectedEdge(GRAPH &graph, int from, int to){
graph[from].push_back(to);
graph[to].push_back(from);
}
void BuildGraphFromEdgeList(GRAPH &graph, vector<vector<int>> &edges){
for(int i = 0; i < edges.siz... | ALGO | 0.999957 | 5.71694 | {
"github_metadata": {
"branch": "main",
"commit_count": 69,
"repo_created_at": "2024-06-24T16:07:56.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "8b50f47e601... |
62b9d906-353b-4c3a-9107-1b9c76f7dbbe | vllm-project/vllm | csrc/cpu/sgl-kernels/gemm_int8.cpp | // Adapted from
// https://github.com/sgl-project/sglang/tree/main/sgl-kernel/csrc/cpu
#include "common.h"
#include "vec.h"
#include "gemm.h"
// clang-format off
namespace {
template <typename scalar_t, bool has_bias, int BLOCK_M, int BLOCK_N>
struct tinygemm_kernel_nn {
static inline void apply(
const uint... | ALGO | 0.90173 | 4.939289 | {
"github_metadata": {
"branch": "main",
"commit_count": 7842,
"repo_created_at": "2023-02-09T11:23:20.000Z",
"is_fork": false,
"is_org_owned": true,
"forked_from": null,
"stars": 52761,
"forks": 8817,
"issues": 1824,
"pull_requests": 832
},
"file_meta": {
"content_id":... |
ba8869b3-8eab-4640-89b4-d44d0bccd892 | Giantpizzahead/comp-programming | Other/Templates/data-structs/segment-tree/segmentTreeBaseLazy.cpp | template <class T, int N=100005>
class SegmentTree {
public:
T arr[N*4+1], delta[N*4+1];
// Change if needed
const T NULL_VALUE = 0;
void propagate(int n, int lb, int ub) {
// Fill this in
}
T merge(T a, T b) {
// Fill this in
}
void lazyTag(int n, int lb, int ub, T v)... | ALGO | 0.999833 | 6.169935 | {
"github_metadata": {
"branch": "master",
"commit_count": 25,
"repo_created_at": "2020-04-04T04:04:46.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 2,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "4fd997984... |
51defca0-faec-4384-96f7-1bed67714c25 | iseol/CP | CF/1747b.cpp | #include <iostream>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int tc;
cin >> tc;
while (tc--) {
int n;
cin >> n;
if (n % 2 == 0) {
cout << n/2 << '\n';
for (int i = 1; i <= n/2; i++) {
cout << ... | ALGO | 0.999791 | 4.023078 | {
"github_metadata": {
"branch": "master",
"commit_count": 19,
"repo_created_at": "2020-12-22T04:45:53.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "aa23db360... |
084ab8b1-e8ba-449f-916f-0b2b80ab95e9 | pforprogrammer/DSA | Graphs && Trees/Basics of tree.cpp | //creates nodes of tree and travers in pre , in & post order
#include <iostream>
using namespace std;
class node{
public:
int data;
node* left;
node* right;
node(int val){
this->data = val;
this->left = NULL;
this->right = NULL;
}
... | ALGO | 0.999979 | 4.726906 | {
"github_metadata": {
"branch": "main",
"commit_count": 97,
"repo_created_at": "2023-07-19T11:38:58.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 1,
"forks": 1,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "656fd2a4499... |
d9460d8e-9b96-4f38-92cb-83a4343233b7 | luyuncheng/Exercise | OJ_Problem/LeetCode_Wiggle Sort II.cpp | //#include <iostream>
//#include <vector>
//#include <algorithm>
//using namespace std;
//class Solution {
//public:
// void wiggleSort(vector<int>& nums) {
// int len=nums.size();
// //O(n) time to find the mid_val
// int mid = len/2;
// nth_element(nums.begin(), nums.begin()+len/2, nums... | ALGO | 0.999981 | 5.101628 | {
"github_metadata": {
"branch": "master",
"commit_count": 31,
"repo_created_at": "2016-03-24T05:22:06.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "05d186ce9... |
44edc6c3-e83b-4a37-b9b5-4a31f4d12b5b | jiun0507/Interview-prep | Baekjoon/LEETCODE]compareversionnumbers.cpp | class Solution {
public:
int compareVersion(string version1, string version2) {
int pos = 0;
string token;
vector<string> v1;
while ((pos = version1.find(".")) != string::npos) {
token = version1.substr(0, pos);
v1.push_back(token);
version1.erase(... | ALGO | 0.999959 | 5.625312 | {
"github_metadata": {
"branch": "master",
"commit_count": 584,
"repo_created_at": "2019-10-12T12:44:57.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "c8974f63... |
d59aa8d6-4ae2-4c27-ab8f-547e51d28b6b | ishandutta2007/codeforces-i | -imc-/normal/412/B.cpp | #include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> a;
int getMaxEqual(int maxSpeed)
{
int answer = 0;
vector<int> now = a;
for (auto& it: now)
{
it = min(it, maxSpeed);
if (it == maxSpeed)
answer++;
}
return answer;
... | ALGO | 0.999937 | 3.964982 | {
"github_metadata": {
"branch": "main",
"commit_count": 1,
"repo_created_at": "2024-04-11T05:39:30.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "316c32a8684d... |
8439106d-7eee-40cb-8d41-6a5d2a4a32b4 | CompPhysics/ComputationalPhysics | doc/Programs/LecturePrograms/programs/LinAlgebra/cpp/lib.h | /*
* The definition module
* lib.h
* for the library function common for all C programs.
*/
// Standard ANSI-C++ include files
#include <iostream>
#include <new>
#include <cstdio>
#include <cstdlib>
#include <cmath>
... | TOOL | 0.990368 | 3.351805 | {
"github_metadata": {
"branch": "master",
"commit_count": 887,
"repo_created_at": "2016-01-04T09:01:24.000Z",
"is_fork": false,
"is_org_owned": true,
"forked_from": null,
"stars": 390,
"forks": 137,
"issues": 2,
"pull_requests": 6
},
"file_meta": {
"content_id": "0f411... |
1d7f28e7-172a-4a55-b23e-9dc1f04bd8fa | seshWCS/Archiver | Decode.cpp | //
// Created by <NAME> on 16.10.2021.
//
#include "Decode.h"
void Decode(const string& archive_name) {
std::ifstream fin(archive_name);
vector<int32_t> archive;
unsigned char c;
while (fin.read(reinterpret_cast<char*>(&c), 1)) {
archive.push_back(c);
}
vector<int8_t> archive_code;
... | TOOL | 0.903145 | 3.723382 | {
"github_metadata": {
"branch": "main",
"commit_count": 2,
"repo_created_at": "2022-02-27T20:34:15.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 2,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "b1317539b034... |
033fec87-ed28-4c0f-9699-4265e4f44f4b | dougshidong/PHiLiP | tests/unit_tests/operator_tests/weight_adjusted_mass_inverse_test.cpp | #include <iomanip>
#include <cmath>
#include <limits>
#include <type_traits>
#include <math.h>
#include <iostream>
#include <stdlib.h>
//#include <ctime>
#include <time.h>
#include <deal.II/distributed/solution_transfer.h>
#include "testing/tests.h"
#include<fstream>
#include <deal.II/base/parameter_handler.h>
#incl... | ALGO | 0.940163 | 3.963734 | {
"github_metadata": {
"branch": "master",
"commit_count": 1502,
"repo_created_at": "2018-12-17T20:30:39.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 49,
"forks": 40,
"issues": 80,
"pull_requests": 14
},
"file_meta": {
"content_id": "d7c... |
7a6b91c7-ab36-4fa8-b40b-5957bfa02d97 | xcf1992/leetcode | C++/invert_binary_tree.cpp | /*
226. Invert Binary Tree
https://leetcode.com/problems/invert-binary-tree/
Invert a binary tree.
Example:
Input:
4
/ \
2 7
/ \ / \
1 3 6 9
Output:
4
/ \
7 2
/ \ / \
9 6 3 1
Trivia:
This problem was inspired by this original tweet by <NAME>:
Google: 90% of our engineer... | ALGO | 0.999805 | 6.106511 | {
"github_metadata": {
"branch": "master",
"commit_count": 1784,
"repo_created_at": "2017-12-26T04:19:33.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 1,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "cec41aa... |
260c5c03-7a0a-4f49-9a4b-6f01b2b143f5 | articblue/PoseProject | C/Kalman.cpp | #include "Kalman.h"
static const float identity[6][6] = { {1, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0},
{0, 0, 1, 0, 0, 0},
{0, 0, 0, 1, 0, 0},
{0, 0, 0, 0, 1, 0},
{0, 0, 0, 0, 0, 1} };
static const float identity_3[3][3] = { {1, 0, 0}, {0, 1, 0}, {0, 0, 1} };
float kalman_A[6][6] = { {1, 0, ... | ALGO | 0.98411 | 5.642749 | {
"github_metadata": {
"branch": "master",
"commit_count": 1,
"repo_created_at": "2015-11-06T03:31:57.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "b262170dac... |
97cbb0e0-70a2-4e55-858e-adb4fb7ec3fe | nonnnz/noneCode | Contests/Codeforces/339/339-a.cpp | #include<bits/stdc++.h>
using namespace std;
void solve2() {
string s;
cin >> s;
vector<int> v;
for (int i = 0; i < s.size(); ++i) {
if (s[i] != '+') {
v.push_back(s[i] - '0');
}
}
sort(v.begin(), v.end());
for (int i = 0; i < v.size(); ++i) {
cout << v[... | ALGO | 0.999966 | 4.143876 | {
"github_metadata": {
"branch": "main",
"commit_count": 20,
"repo_created_at": "2024-09-08T15:15:09.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "b2e80892434... |
e3c2d2ff-d858-49b2-b472-7811d2ff2bd3 | tanvirtareq/precode | algorithm shafayet/graph theory/array compression.cpp | #include<bits/stdc++.h>
using namespace std;
void x()
{
int ar[]={1, 4, 2, 6, 8, 4, 6, 3, 6,9, 0, 3, 4, 3, 4, 5,6};
vector<int>v[101];
int n=sizeof(ar)/sizeof(int);
int position=0;
for(int i=0;i<n;i++)
{
int x=ar[i];
v[x].push_back(i);
}
for(int i=0;i<=100;i++)
... | ALGO | 0.999239 | 3.861769 | {
"github_metadata": {
"branch": "master",
"commit_count": 13,
"repo_created_at": "2019-10-24T11:02:25.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 1,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "634ce7983... |
dc5ac0a6-b94e-408a-9a8b-2e60220eeb3c | oxygen-hunter/Flashboom | data/big-vul-100/add_attention_code/Phi/top0-100/count-all-possible-routes-Solution.countRoutes/177875_Exec_Code_Overflow.cpp | s_aes_process(stream_state * ss, stream_cursor_read * pr,
stream_cursor_write * pw, bool last)
{
stream_aes_state *const state = (stream_aes_state *) ss;
const unsigned char *limit;
const long in_size = pr->limit - pr->ptr;
const long out_size = pw->limit - pw->ptr;
unsigned char t... | ALGO | 0.996661 | 3.123661 | {
"github_metadata": {
"branch": "main",
"commit_count": 4,
"repo_created_at": "2025-03-22T14:39:20.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 4,
"forks": 1,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "c94b0aa1a8a6... |
6eda2bc4-7aee-45a0-a506-bb3c8d80f9aa | salmonfishycooked/CP | sharkie/datastructure/rmq/SparseTable.cpp | /**
* 区间最值查询 - RMQ
* Sparse Table
* 数组编号从 0 开始,即 [0, n)
* 建立 ST 的时间复杂度 O(nlogn),查询最值操作的时间复杂度 O(1)
*
* 方法说明:
* 1. SparseTable 构造函数应该传入需要被建立 ST 表的数组
* 2. int query(int from, int to) 查询 [from, to] 上的信息
*
* 下面给出的模板中,f[i][j] 表示区间 [j, j + 2^i - 1] 上的最大值,故 query 返回的信息是区间最大值
*/
#include <bits/stdc++.h>
class Spars... | ALGO | 0.999872 | 5.447604 | {
"github_metadata": {
"branch": "main",
"commit_count": 306,
"repo_created_at": "2024-04-01T02:21:54.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 1,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "5c59482948... |
8cf741db-4d5f-4b72-b8eb-0b1d4bd547a0 | VittorioDL/Scuola-C- | perfezionamento_simulazione_risiko.cpp | #include <iostream>
#include <ctime>
#include <stdlib.h>
using namespace std;
void scambio(int &a, int &b)
{
int c = a;
a = b;
b = c;
}
bool vincitore(int a, int d)
{
if(a > d) return false;
if(a <= d) return true;
}
void ordinamento(int &v1, int &v2, int &v3)
{
if(v1 > v2) scambio(v1, v2);
... | ALGO | 0.997705 | 3.57423 | {
"github_metadata": {
"branch": "main",
"commit_count": 3,
"repo_created_at": "2021-04-03T15:31:26.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "24c1c70e506a... |
5a65a027-9d48-421f-ae36-5b53720a8a44 | SunWeb07/c--work | tempCodeRunnerFile.cpp | #include<iostream>
using namespace std;
template <class t>
class sort{
private:
t a[10];
t element;
public:
void readarray(t );
void selectsort(t);
void display(t);
};
template <class t>
void sort<t>::readarray(t n){
int i ;
for(i=0;i<n;i++)
cin>>a[i];
}
template <class t>
void ... | ALGO | 0.998977 | 3.763285 | {
"github_metadata": {
"branch": "main",
"commit_count": 3,
"repo_created_at": "2022-05-15T11:03:32.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "c3d6053aa69f... |
7748b38a-3203-49df-af69-a62e1b09f991 | biginnings/codetree-TILs | 240426/코드트리 오마카세/codetree-omakase.cpp | #include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#include <unordered_map>
#include <cmath>
using namespace std;
struct t_x {
int t, x;
};
struct Point {
queue<t_x> q;
};
struct Guest {
int x, n, now_time;
string name;
bool operator<(Guest other) const {
return n... | ALGO | 0.998582 | 4.129369 | {
"github_metadata": {
"branch": "main",
"commit_count": 54,
"repo_created_at": "2024-04-22T08:32:14.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "8b451f9933e... |
f899ef11-6ebf-451e-adc1-316e2451b97c | rahul799/leetcode_problems | Binary Search/Discrete Binary Search/1760. Minimum Limit of Balls in a Bag.cpp | ERROR: type should be string, got "\n\n\n\n\n\nhttps://leetcode.com/problems/minimum-limit-of-balls-in-a-bag/discuss/1064497/Unravel-it-Layer-by-Layer\n\n\n\n\nWe can apply Binary Search on the Answer Space. The minimum lower bound after all operations have been performed is 1 while the maximum is 10^9. Suppose that the all the elements are less than or equal to max_allowed. Let's find out the minimum number of operations required to satisfy this constraint.\n\nLet's solve for each array element individually. Say, we are solving for ele. By Euclid's Division Lemma, we have\n\nele = quotient*max_allowed + remainder\nSuppose remainder is zero, implying ele = quotient*max_allowed. In other words, the element is made up of quotient blocks, where each block is of size max_allowed. Hence, at each step, we can unravel one layer of the box, resulting in a total of (quotient - 1) steps to completion.\n\nNow, assume remainder is non-zero. Hence, in the first step of unraveling, we can split remainder in one half and quotient*remainder in other and then follow the steps in the previous paragraph for the second part.\n\nTo conclude, if rem == 0, the minimum operations required is quotient - 1, else, the minimum operations required is (quotient).\n\nOnce we are certain that a series of steps exist which can lead to every element being less than or equal to mid, we can simply discard \nthe right half of the search space. If not, we can discard the left half.\n\nThe time complexity is O(N log(N)).\n\nExtended Discussion : Why are we not splitting in half at each stage?\n\nA simple counter example is an element with value 8, where the maximum allowed value is 3. If we split it into half, we get 4 and 4. Hence, we need 3 steps. However, if we split it into 6 + 2, we can be done in 2 steps.\n\nBut that was a counter example, what's the intuition? We have to realize that even if we split into 2 at each stage, we have to eventually make a cut which partitions it into sizes less than max_allowed. Hence, we'd have just wasted the split by 2 cuts. Hence, it's optimal to peel one layer as soon as possible.\n\nAnother way to look at it is, if you divide it into 2 equal halves at each stage, the tree would be a binary tree, hence, cost is counted for each node in the tree, which can be huge. However, if you follow the above algorithm, the tree would be linear (so, in other words, you only have to travel (roughly) one height, rather than all nodes of the old tree).\n\nA yet another perspective : Visualize each box as a set of people. Suppose we want to ensure sizes of atmost max_allowed. We can interpret this situation as : You need to seat n people in benches, such that each bench has capacity atmost max_allowed. What is the minimum number of benches required? Now, it seems rather intuitive that you'd fill each bench to its full capacity, except possibly the last one. In other words\n \n \n \n\n\n1760. Minimum Limit of Balls in a Bag\nMedium\n\n353\n\n19\n\nAdd to List\n\nShare\nYou are given an integer array nums where the ith bag contains nums[i] balls. You are also given an integer maxOperations.\n\nYou can perform the following operation at most maxOperations times:\n\nTake any bag of balls and divide it into two new bags with a positive number of balls.\nFor example, a bag of 5 balls can become two new bags of 1 and 4 balls, or two new bags of 2 and 3 balls.\nYour penalty is the maximum number of balls in a bag. You want to minimize your penalty after the operations.\n\nReturn the minimum possible penalty after performing the operations.\n\n \n\nExample 1:\n\nInput: nums = [9], maxOperations = 2\nOutput: 3\nExplanation: \n- Divide the bag with 9 balls into two bags of sizes 6 and 3. [9] -> [6,3].\n- Divide the bag with 6 balls into two bags of sizes 3 and 3. [6,3] -> [3,3,3].\nThe bag with the most number of balls has 3 balls, so your penalty is 3 and you should return 3.\nExample 2:\n\nInput: nums = [2,4,8,2], maxOperations = 4\nOutput: 2\nExplanation:\n- Divide the bag with 8 balls into two bags of sizes 4 and 4. [2,4,8,2] -> [2,4,4,4,2].\n- Divide the bag with 4 balls into two bags of sizes 2 and 2. [2,4,4,4,2] -> [2,2,2,4,4,2].\n- Divide the bag with 4 balls into two bags of sizes 2 and 2. [2,2,2,4,4,2] -> [2,2,2,2,2,4,2].\n- Divide the bag with 4 balls into two bags of sizes 2 and 2. [2,2,2,2,2,4,2] -> [2,2,2,2,2,2,2,2].\nThe bag with the most number of balls has 2 balls, so your penalty is 2 an you should return 2.\nExample 3:\n\nInput: nums = [7,17], maxOperations = 2\nOutput: 7\n \n\nConstraints:\n\n1 <= nums.length <= 105\n1 <= maxOperations, nums[i] <= 109\n\n\n\n\n\n\n\n\nint get_cost(int val, int max_allow) {\n int quotient = val/max_allow;\n int rem = val % max_allow;\n return quotient + (rem == 0 ? -1 : 0);\n}\n\nclass Solution {\npublic:\n int minimumSize(vector<int>& a, int max_op) {\n int low = 1, high = 1e9,res = -1;\n \n while(low <= high) {\n int mid = (low + high)/2;\n long long need = 0;\n for(auto &ele : a)\n need += get_cost(ele, mid);\n \n if(need <= max_op) {\n res = mid;\n high = mid - 1;\n }\n else {\n low = mid + 1;\n }\n }\n \n return res;\n }\n};\n" | ALGO | 0.999988 | 6.080535 | {
"github_metadata": {
"branch": "main",
"commit_count": 1,
"repo_created_at": "2021-04-20T19:46:21.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 2,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "da1c2172533b... |
b38b2d14-5f04-48bd-8d27-c5dc9f6a31cb | zjsxzy/algo | Spoj/P3579_DISJPATH.cpp | #include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <vector>
#include <cstdio>
#include <string>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define th(x) this->x = x
const... | ALGO | 0.999806 | 3.387843 | {
"github_metadata": {
"branch": "master",
"commit_count": 1296,
"repo_created_at": "2013-05-18T10:52:16.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 2,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "282716f... |
77dcb838-1417-48cd-831f-39f8f09f6543 | IslamAmr155/Problem-Solving | LeetCode/Hard/85. Maximal Rectangle.cpp | class Solution {
public:
int maximalRectangle(vector<vector<char>>& matrix) {
int m = matrix.size(), n = matrix[0].size(), ans = 0;
vector<int> left (n,0), height (n,0), right (n,n);
for (int i = 0;i<m;i++)
{
int l = 0, r = n;
for (int j = 0;j<n;j++)
... | ALGO | 0.999973 | 6.133327 | {
"github_metadata": {
"branch": "main",
"commit_count": 424,
"repo_created_at": "2023-09-09T00:52:54.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "9cfefdf569... |
be821c5c-806a-456f-abe9-7377cc3e19c5 | devangi2000/InterviewBit | Trees/BST Traversal/2SumBinaryTree.cpp | // Given a binary search tree A, where each node contains a positive integer, and an integer B,
// you have to find whether or not there exist two different nodes X and Y such that X.value + Y.value = B.
// Return 1 to denote that two such nodes exist. Return 0, otherwise.
// Problem Constraints
// 1 <= size of tree ... | ALGO | 0.999992 | 4.929564 | {
"github_metadata": {
"branch": "master",
"commit_count": 77,
"repo_created_at": "2021-07-23T07:09:08.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 5,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "374fd7e06... |
fb77582a-a75d-4134-bbc8-3cd343d871a2 | JuanPabloRN30/Competitive_Programming | Campamento2017/01 SegmentTree/g.cpp | #include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <bits/stdc++.h>
using namespace std;
using namespace __gnu_pbds;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
s... | ALGO | 0.999977 | 4.044409 | {
"github_metadata": {
"branch": "master",
"commit_count": 9,
"repo_created_at": "2016-08-21T17:34:45.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "3b826d7962... |
70216bb1-18f3-411c-b425-b300c617848a | hassaanch23/Programming-Fundamentals-Labs-Cpp | Lab Solutions/Pf Lab 10/Pf Lab 10/Task2.cpp | //#include <iostream>
//using namespace std;
//
//bool IndexNumber(int arr[],int size, int Key) {
// int Start = 0;
// int End = size;
// while (Start <= End){
// int Middle_Entry = (Start + End) / 2;
// if (arr[Middle_Entry] == Key) {
// cout << "Yes, given number is present in the array." << endl;
// return 1;
... | ALGO | 0.999767 | 4.042798 | {
"github_metadata": {
"branch": "main",
"commit_count": 5,
"repo_created_at": "2024-12-08T18:01:43.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "140ea702cbf5... |
7ee44ef0-1f74-4ee0-b61d-b5be94d48696 | hwanzar/Code | LAB/inLab 4/color.cpp | #include <iostream>
#include <string.h>
using namespace std;
template <class T>
class Cell
{
protected:
T infor;
public:
void set(T _infor) { this->infor = _infor; };
T get() { return this->infor; };
};
enum Color
{
White,
Yellow,
Black,
Red,
Blue
};
// TODO
template <class T>
class... | ALGO | 0.933245 | 3.136772 | {
"github_metadata": {
"branch": "main",
"commit_count": 81,
"repo_created_at": "2021-10-30T04:37:43.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 1,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "b090961559f... |
bf64af90-7480-41a9-955f-10b4bcffbd89 | aleung-c/Gomoku | src/IA.cpp | #include "../includes/Gomoku.hpp"
IA::IA()
{
}
IA::~IA()
{
}
// ------------------------------------------------------------------ //
// The main method for the IA Class. This will send back the //
// ia's decided move. //
// //
// -------------------------------------------------... | ALGO | 0.998199 | 4.190593 | {
"github_metadata": {
"branch": "master",
"commit_count": 95,
"repo_created_at": "2017-04-06T14:46:55.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "3ddc4e9cb... |
6efee5d5-9377-481c-bdd3-e7d1f3b755e8 | RoundofThree/competitive-programming | google/organization.cpp | /*
After Apricot Rules LLC went through a reorganization, a new large team was formed containing M managers and N non-managers. Since many people within the team do not know each other, a number of introduction sessions are to be scheduled. We know exactly which pairs of members already know each other.
The introducti... | ALGO | 0.999769 | 4.781517 | {
"github_metadata": {
"branch": "main",
"commit_count": 37,
"repo_created_at": "2021-01-28T23:27:06.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 1,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "1c2da21c579... |
bf6b4c83-d237-4019-bd94-a3ac2c758431 | mdfahimhosen79/phitron3 | Introduction To Algorithm/Module_6.5/code.cpp | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
vector<int> adjlist[N];
bool visited[N];
int depth[N];
int Height[N];
void dfs(int u)
{
//section 1: actions just after entering node u
visited[u] = true;
//cout<<"visiting Node: "<<u<<endl;
for(int v:adjlist[u])
{
//secti... | ALGO | 0.999959 | 4.030078 | {
"github_metadata": {
"branch": "main",
"commit_count": 29,
"repo_created_at": "2023-09-15T12:48:17.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "e61462c39eb... |
1f350d76-a981-4133-8cc5-02b7e8c01bae | kendallmccar/CodePuzzles | max_profit.cpp | // <NAME> 2022
#include <algorithm>
#include <iostream>
#include <vector>
// https://leetcode.com/problems/best-time-to-buy-and-sell-stock/
// You are given an array prices where prices[i] is the price of a given stock on the i-th day.
// You want to maximize your profit by choosing a single day to buy one stockand c... | ALGO | 0.996209 | 6.118651 | {
"github_metadata": {
"branch": "main",
"commit_count": 8,
"repo_created_at": "2022-02-28T11:50:31.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "3ae8b69cb507... |
7be939e6-af48-4cd2-bbea-ab1d88709fc5 | cyendra/ACM_Training_Chapter_One | poj 1054 The Troublesome Frog/main.cpp | #include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int r,c,n;
short map[5001][5001];
short f[5001][5001];
struct node{
short x;
short y;
};
node a[5001];
bool cmp( node a, node b )
{
if ( a.x==b.x ) return a.y<b.y;
else return a.x<b.x;
}
bool check( int x , int y )
{... | ALGO | 0.999981 | 3.807361 | {
"github_metadata": {
"branch": "master",
"commit_count": 2,
"repo_created_at": "2013-11-17T08:33:05.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "4d5579c119... |
db1f4c54-84dd-457f-9dd9-8f9354b94f3c | hieule22/contests | codechef/JulyChallenge16/workchef2.cpp | #include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <unordered_map>
using namespace std;
constexpr int TOTAL = 362880;
int k;
string sL, sR;
int64_t dp[19][2][2][TOTAL][512];
inline bool HasDigit(int mask, int digit) {
return mask & (1 << (digit - 1));
}
void GetMod(int mod, int r... | ALGO | 0.999824 | 4.517552 | {
"github_metadata": {
"branch": "master",
"commit_count": 112,
"repo_created_at": "2016-03-21T03:00:50.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "e052e078... |
9f9d0a92-804d-41a0-b394-a597787fb180 | xuzhg/DayDayUp | Leetcode/94_BinaryTreeInorderTraversal/PreAndPostOrder_Iteratorly.cpp | // copyright @<NAME> 3/21/2022
// Given the root of a binary tree, return the inorder traversal of its nodes' values.
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
struct BinaryTreeNode{
int m_value;
BinaryTreeNode* m_left;
BinaryTreeNode* m_right;
BinaryTreeNode(int val... | ALGO | 0.999988 | 6.30219 | {
"github_metadata": {
"branch": "main",
"commit_count": 23,
"repo_created_at": "2022-02-12T05:50:50.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "992336c083c... |
eebf73f1-fe49-4b4a-8a55-f81d94121b72 | micheeeeell/codeforces | Round/642/F.cpp | #define LOCAL
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define all(x... | ALGO | 0.999964 | 3.950439 | {
"github_metadata": {
"branch": "master",
"commit_count": 6,
"repo_created_at": "2020-05-05T10:21:09.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "1caedc030b... |
3ce4501b-9589-4503-b296-86bc1b60401b | erwan-reinders/ProbaStat | src/ppm_blur.cpp | // blur.cpp : Floute une image en couleur
#include <stdio.h>
#include "image_ppm.h"
int main(int argc, char* argv[]){
char cNomImgLue[250], cNomImgEcrite[250];
int nH, nW, nTaille;
int som[3];
if (argc != 3) {
printf("Usage: ImageIn.ppm ImageOut.ppm\n");
exit (1) ;
}
sscanf (argv[1]... | ALGO | 0.989207 | 4.278063 | {
"github_metadata": {
"branch": "main",
"commit_count": 6,
"repo_created_at": "2021-12-16T15:41:19.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "816be16de3de... |
b27115a2-3a7b-4bed-81c3-371e49b5f9e4 | imoverflow/mycode | GdutRank4J/main.cpp | #include <iostream>
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
char s1[100][2000];
char s2[2000][100];
int d1[100][2000];
int d2[2000][100];
int dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
int n,m;
pair<int ,int>num1;
pair<int ,int>num2;
int bfs1() //n<100
{
queue<pair<int ,int> > que... | ALGO | 0.999949 | 3.775557 | {
"github_metadata": {
"branch": "master",
"commit_count": 2,
"repo_created_at": "2018-10-19T07:20:12.000Z",
"is_fork": false,
"is_org_owned": false,
"forked_from": null,
"stars": 0,
"forks": 0,
"issues": 0,
"pull_requests": 0
},
"file_meta": {
"content_id": "7f67a2cf4b... |
4058e5e9-a800-46d4-bfd3-69735a73c9a7 | SJAlgorithm/SJAlgorithm | jerry0339/2020/20201226/BOJ_9426.cpp | // <중앙값 측정> - BOJ_9426
// 세그먼트 트리, 역추적(query)
#include<bits/stdc++.h>
#define MAX_N 65536
using namespace std;
typedef long long ll;
ll arr[250001]{}, tree[MAX_N<<2]{};
ll N,M;
void modify(ll n, ll s, ll e, ll idx, ll diff){
if(idx<s || idx>e) return;
tree[n] += diff;
if(s==e) return;
ll mid = (s+e)>... | ALGO | 0.999993 | 4.368928 | {
"github_metadata": {
"branch": "master",
"commit_count": 721,
"repo_created_at": "2020-03-18T13:38:57.000Z",
"is_fork": false,
"is_org_owned": true,
"forked_from": null,
"stars": 4,
"forks": 2,
"issues": 0,
"pull_requests": 2
},
"file_meta": {
"content_id": "18092f247... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.