uuid string | repo_name string | relative_path string | content string | category string | algo_rel_score float64 | quality_score float64 |
|---|---|---|---|---|---|---|
04ab3024-c756-407a-b90a-9337833b9218 | thearpitanand/Data-Structures-and-Algorithms-in-cpp | Sorting/03_Merge_Sort.cpp | #include <bits/stdc++.h>
using namespace std;
void merge(int arr[], int x[], int y[], int start, int end)
{
int arrayPointer = start;
int i = start;
int mid = (start + end) / 2;
int j = mid + 1;
// Assigning the value in array "arr" after sorting
while (i <= mid && j <= end)
{
if (x... | ALGO | 0.999969 | 5.261858 |
cd4ab66d-5fc9-4aa8-91af-08a7e1d94e33 | sumana2001/problems450 | janLongChallenge/retrieveBackTheArray.cpp | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5e5;
void solve()
{
ll n, k;
cin >> n >> k;
if (n == 1)
{
cout << k << "\n";
return;
}
if (n == 2)
{
cout << 0 << " " << k << "\n";
return;
}
vector<ll> result;
ll... | ALGO | 0.999904 | 4.052223 |
34b8e5bf-332d-4f81-98ed-b3ad6e1dbfd5 | iamkaniska/DSA | pattern/prac.cpp | /*
12345
12345
12345
12345
12345
*/
// #include<iostream>
// using namespace std;
// int main(){
// int n;
// cout<<"enter a Number: ";
// cin>>n;
// for (int i = 1; i <= n; i++)
// {
// for (int j = 1; j <= n; j++)
// {
// cout<<j;
// }
// cout<<endl;
//... | ALGO | 0.999499 | 3.748151 |
f28e83c1-5392-4dbb-a4ea-b51e4095d45a | desromech/beacon-lang | third-party/abstract-gpu/thirdparty/glslang/glslang/MachineIndependent/IntermTraverse.cpp | #include "../Include/intermediate.h"
namespace glslang {
//
// Traverse the intermediate representation tree, and
// call a node type specific function for each node.
// Done recursively through the member function Traverse().
// Node types can be skipped if their function to call is 0,
// but their subtree will stil... | TOOL | 0.889049 | 7.278227 |
beefcaa6-82db-486d-bc31-bc5a135f1740 | angel-quintanilla/f1tenth-autonomous-racecar | scan_matching/src/transform.cpp | #include "scan_matching_skeleton/transform.h"
#include <cmath>
#include <Eigen/Geometry>
#include <complex>
using namespace std;
void transformPoints(const vector<Point> &points, Transform &t, vector<Point> &transformed_points)
{
transformed_points.clear();
for (int i = 0; i < points.size(); i++)
{
transfor... | ALGO | 0.999796 | 3.324822 |
7028513f-43ae-4dda-bc36-2f22697cb49d | moungJae/Baekjoon | [Baekjoon 11501] 주식.cpp | #define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#define INF 1000000000
#define endl '\n'
#define ll long long
using namespace std;
int N;
ll A[1000001];
void test() {
ll sum, max_item, tmp, cnt;
cin >> N;
for (int i ... | ALGO | 0.999898 | 4.53306 |
e4cdadcb-b227-42b1-b0b4-3fa7914a7cac | Kaileshwaran13/CodeChef | 1000 - 1400 difficulty rating/Chef and Glove.cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int N;
cin >> N;
vector < int > arr1(N);
for (int i = 0; i < N; i++)
cin >> arr1[i];
vector < int > arr2(N);
for (int i = 0; i < N; i++)
cin >> ... | ALGO | 0.999985 | 4.162319 |
939be748-6e74-4e40-94d5-943dc1da6098 | raincross7/code-similarity | codes/train_code/problem302/problem302_211.cpp | #include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int l, r;
cin >> l >> r;
if (l * r < 2019)
cout << l*(l + 1);
else if ((l - 1) / 2019 != (r / 2019))
{
cout << 0;
}
else
{
int min = LONG_MAX;
fo... | ALGO | 0.999824 | 4.204076 |
80581941-7e7c-4d8b-a460-952bb9a4a42b | nereagallego/PACS | lab1/eigen-3.4.0/doc/examples/Tutorial_ArrayClass_mult.cpp | #include <Eigen/Dense>
#include <iostream>
using namespace Eigen;
using namespace std;
int main()
{
ArrayXXf a(2,2);
ArrayXXf b(2,2);
a << 1,2,
3,4;
b << 5,6,
7,8;
cout << "a * b = " << endl << a * b << endl;
}
| ALGO | 0.996758 | 3.527115 |
c737f737-c710-44eb-b6be-6b86217d1a1c | ryo-manba/AtCoder | ABC/ABC029/c/main.cpp | #include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const ll INFL = (ll)1e15;
const int MOD = 1e9 + 7;
int dx[]={0, 0, -1, 1};
int dy[]={1, -1, 0, 0};
template<class T> inline bool chmax(T& a, T b) { if (a... | ALGO | 0.999619 | 3.988938 |
227e6195-0edc-4446-894d-4a2a9d01934d | Avish04/C--Progarmming | 16.Heap/implement.cpp |
#include<iostream>
#include<queue>
using namespace std;
/*
Left node : 2*i where i is index
right node : 2*i+1
root node : i/2;
left node : n/2 + 1 to nth node
*/
class heap {
public:
int arr[100];
int size;
heap() {
arr[0] = -1;
size = 0;
}
void insert(int val) {
s... | ALGO | 0.999483 | 4.046788 |
bf8da1c9-c96a-459d-9488-a4537d70c932 | SHIVAM1422000/Competitive_Programming_Snippets | Number Theory/assignment/StrangeOrder.cpp | #include <bits/stdc++.h>
#include <stack>
using namespace std;
using ll = long long;
int main(){
int n;
cin >> n;
vector<bool> arr(n+1,true);
vector<int> ans(n);
for(int i=sqrt(n);i>=2;i--){
if(arr[i]==false) continue;
cout<<"Starting From: " << ... | ALGO | 0.999912 | 3.579815 |
d2a7de62-d638-432c-9b3f-e1971659392f | Sandip-Kr-Yadav/CrackYourPlacement | Day3/ValidParentheses.cpp | //https://leetcode.com/problems/valid-parentheses/description/
class Solution {
public:
bool isValid(string s)
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
stack<char> st;
for(int i=0;i<s.length();i++)
{
if(s[i]==']')
{
if(st... | ALGO | 0.999311 | 6.268453 |
cf116aed-1f40-4458-a6c5-09e65cedd817 | ZrjaK/algorithm | OJ/codeforces/gym/104090/K.cpp | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define i128 __int128
#define ld long double
#define ui unsigned int
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<ld, ld>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vll vector<l... | ALGO | 0.999926 | 4.525699 |
8bb1fccb-b13f-4d5f-9ca8-4c57d3d6def4 | Rohit-048/DSA | STL/PriorityQueue.cpp | #include <iostream>
#include <queue>
using namespace std;
int main()
{
priority_queue<int> maxi; // max heap
priority_queue< int, vector<int>, greater<int>> mini; // min heap
maxi.push(1);
maxi.push(2);
maxi.push(3);
maxi.push(5);
maxi.push(7);
int n=maxi.size();
for (int i = 0; i ... | ALGO | 0.990405 | 4.057748 |
232a3b20-48f2-49c6-99ee-1d440073330c | suryanshmanocha/kalman_filter | eigen/unsupported/doc/examples/FFT.cpp | // To use the simple FFT implementation
// g++ -o demofft -I.. -Wall -O3 FFT.cpp
// To use the FFTW implementation
// g++ -o demofft -I.. -DUSE_FFTW -Wall -O3 FFT.cpp -lfftw3 -lfftw3f -lfftw3l
#ifdef USE_FFTW
#include <fftw3.h>
#endif
#include <vector>
#include <complex>
#include <algorithm>
#include <iterator>... | ALGO | 0.992928 | 6.129515 |
3d20e379-07a9-41f4-a905-ded80beb0945 | abhishekraut1/DSA_Problems | is_subsequence.cpp | #include <bits/stdc++.h>
using namespace std;
bool isSubSeq(string s1, string s2, int n, int m){
int j = 0;
for(int i = 0; i < n && j < m; i++){
if(s1[i] == s2[j])
j++;
}
return j == m;
}
bool isSubSeq2(string s1, string s2, int n, int m){
if(m==0)
return true;
... | ALGO | 0.99998 | 4.351518 |
efc59091-673e-420f-8be2-3a1b385f1fbf | xinfeng1i/AlgorithmSolution | TopCoder/practise/div2_250/topcoder_srm597_250.cpp | #include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <limits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
// AC code: 229 pt
int getMin(vector <int> position)
{
int ans = numeric_l... | ALGO | 0.99964 | 4.433479 |
e21d4525-c7f7-4980-9f12-25fbe17596d2 | nka21/atcoder | abc/abc381/a/main.cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
string s;
cin >> n >> s;
bool flag = true;
if (n % 2 == 0) {
flag = false;
}
for (int i = 0; i < n; i++) {
if (i <= ((n+1) / 2) - 2) {
if (s[i] != '1') flag = false;
}
... | ALGO | 0.99983 | 3.52941 |
9986a8ae-dbb1-4948-8d5e-d2b67e532d43 | PatriceJiang/spidermonkey-69-ios-compile | media/mtransport/rlogconnector.cpp | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* Original author: <EMAIL> */
#include <cstdarg>
#include "rlogconnector.h"
#include <deque>
#include <string>
#include "logging.h"
#include "mozilla/Assertions.h"
#include "mozilla/Move.h" // Pinch ... | TOOL | 0.887514 | 7.077518 |
b363eb4a-1b99-4bca-be42-5f3256fd8870 | urmisen/OOP_Data_Structure_and_Algorithm | Ramanujan.cpp | #include<bits/stdc++.h>
using namespace std;
double arr1[100];
double arr2[100];
double DIV[100];
double find_B(int n)
{
double sum=0.0;
for(int i=1;i<n;i++)
{
sum = sum + (1.0*arr1[i]*arr2[n-i]);
}
return sum;
}
void div()
{
cout<<"\nConvergents\t Root Values"<<endl;
for(int ... | ALGO | 0.999909 | 3.268863 |
b190dce1-da4a-4032-921e-38355469f972 | luhenr/APS-2023.1 | CPP/Iterator.cpp | #include <iostream>
#include <vector>
using namespace std;
// Definindo a interface do Iterator
class Iterator {
public:
virtual int proximo() = 0;
virtual bool temProximo() = 0;
};
// Implementando o Iterator para percorrer um vetor de inteiros
class IteratorVetor : public Iterator {
private:
vector<int... | ALGO | 0.993512 | 5.50686 |
c0fd8713-dcbf-4d5b-8610-86693a7aa66b | mayankkaushik187/AlgoViser | BST/AllPathsinBT.cpp | //Leetcode 257
vector < string > binaryTreePaths(TreeNode * root) {
if (!root) return {};
vector < string > res;
queue < TreeNode * > q;
queue < string > qstr;
qstr.push("");
q.push(root);
while (!q.empty()) {
auto fr = q.front();
auto curr_path = qstr.front();
qstr.... | ALGO | 0.999851 | 5.419279 |
60b7629c-dc64-4d1d-abaa-e1f4b66163bd | wencanluo/LeetCode | CodeLeet/RotateList.cpp | /*Rotate ListMar 28 '123926 / 13178
Given a list, rotate the list to the right by k places, where k is non-negative.
For example:
Given 1->2->3->4->5->NULL and k = 2,
return 4->5->1->2->3->NULL.
Author: Wencan Luo
Language: C++
Date: 07/31/2013
*/
#include<iostream>
using namespace std;
#include<climits>
#include<v... | ALGO | 0.999959 | 5.334573 |
9a539a28-9ec7-4bfc-8b2f-ad97d82c74e7 | postech-dblab-iitp/turbograph-v3 | src/optimizer/orca/gporca/libgpopt/xforms/CXformLeftSemiApply2LeftSemiJoinNoCorrelations.cpp | #include "gpopt/xforms/CXformLeftSemiApply2LeftSemiJoinNoCorrelations.h"
#include "gpos/base.h"
using namespace gpopt;
//---------------------------------------------------------------------------
// @function:
// CXformLeftSemiApply2LeftSemiJoinNoCorrelations::Exfp
//
// @doc:
// Compute xform promise for a given... | ALGO | 0.988235 | 6.082303 |
6c84394c-ae60-4b05-9ff3-c0ffcf7da316 | tonyz74/CompetitiveProgramming | Problems/Codeforces/CF902/B_EffectsOfAntiPimples_BruteForce.cpp | #include <iostream>
using namespace std;
using i64 = long long;
const i64 MOD = 998244353;
int main(void) {
i64 n; cin >> n;
vector<i64> a(n + 1);
for (int i = 1; i <= n; i++) cin >> a[i];
i64 ans = 0;
for (int mask = 1; mask <= (1 << n) - 1; mask++) {
vector<int> idx;
for (int ... | ALGO | 0.99978 | 4.433317 |
dc1632fa-99aa-4fa0-a634-c0794860a327 | Khaled-Kamal/competitive-programming | Assiut University Training - Newcomers/sheets/Sheet #4 (Strings)/P. Count Words.cpp | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
bool is_can(char c)
{
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <='Z');
}
void solve() {
string s ;
getline(cin , s);
int cnt = 0 ;
bool dp = false;
for(char &c : s)
{
if(is_can(c... | ALGO | 0.999573 | 4.591791 |
8009bb23-285f-4152-a605-ed8d2f198f58 | yuanisbug/CarND-MPC-Project | src/Eigen-3.3/bench/sparse_randomsetter.cpp |
#define NOGMM
#define NOMTL
#include <map>
#include <ext/hash_map>
#include <google/dense_hash_map>
#include <google/sparse_hash_map>
#ifndef SIZE
#define SIZE 10000
#endif
#ifndef DENSITY
#define DENSITY 0.01
#endif
#ifndef REPEAT
#define REPEAT 1
#endif
#include "BenchSparseUtil.h"
#ifndef MINDENSITY
#define M... | TOOL | 0.864243 | 4.487392 |
664a41d9-80e4-4444-8701-96dc73ffaefc | harsh70568/Daily_Problems_Solution | First and last occurrences of x - GFG/first-and-last-occurrences-of-x.cpp | // { Driver Code Starts
#include<bits/stdc++.h>
using namespace std;
// } Driver Code Ends
int start(int nums[], int n, int x)
{
int low = 0;
int high = n-1;
while(low <= high)
{
int mid = (low + high) >> 1;
if(nums[mid] < x) low = mid + 1;
else if(nums[mid] > x)... | ALGO | 0.999881 | 6.174347 |
7af5bd19-bc35-43e6-b576-1a3e73863fae | asdcloud/ITSA | III/11.cpp | #include<iostream>
#include<string>
#include<sstream>
using namespace std;
int main()
{
int inputBus=0,inputLine=0;
cin>>inputBus>>inputLine;//J}Cjp
cin.ignore(1,'\n');//ƫŪrAݥé᪺"\n"
int reArray[inputLine][inputBus];//Ͱ}C
for(int bus=0;bus<inputBus;bus++)//ŪJƧYC
{
string nums;
getline(cin,nums);
istringstr... | ALGO | 0.997994 | 3.197149 |
250cb068-2f88-4da1-b961-d1d79f9307f2 | propulsion4swtest/JeongHae_CPP | JongMan/p620_Josephus.cpp | #include<iostream>
#include<list>
using namespace std;
list<int> players;
int N, K;
void Solve() {
players.clear();
for (int i = 1; i <= N; i++)
players.push_back(i);
list<int>::iterator it = players.begin();
int div;
while (players.size() > 2)
{
it = players.erase(it);
if (it == players.end())
it =... | ALGO | 0.999968 | 3.838032 |
3bed4da2-341a-4bee-b365-c8d7e3bdd269 | zaifee/Course_Codes | Queue/reverseKelementsofQueueAndinterleaveTheFirstHalfAndSecondHalf.cpp | #include <iostream>
#include <stack>
#include <queue>
using namespace std;
void reverseKElementsUsingQueue(queue<int>&q, int k){
stack<int>st;
int n = q.size();
//agar k number of elemets jitne queue unse zyada hai to nhi paiga
if(k > n || k == 0){
cout << "The size of k is very large " << endl;
... | ALGO | 0.999425 | 3.808789 |
9e33462d-f575-4e06-abbf-d2a081f8f40e | campy/P3Steel-MGN-V19 | P3Steel MGN BMG/Firmware/Marlin antiguo/SKR Titan/Marlin/src/feature/bedlevel/abl/abl.cpp | #include "../../../inc/MarlinConfig.h"
#if ENABLED(AUTO_BED_LEVELING_BILINEAR)
#include "abl.h"
#include "../bedlevel.h"
#include "../../../module/motion.h"
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../../../core/debug_out.h"
#if ENABLED(EXTENSIBLE_UI)
#include "../../../lcd/extensible_ui/ui_ap... | ALGO | 0.978172 | 6.224398 |
d414a30d-b312-4ea6-8c99-7f859f70ff82 | Scinc-L/Scinc | examples/geometry/circle.cpp | #include <stdio.h>
#include "graphics.h"
#define M_PI 3.141592654
float Fabs(float x)
{
if(x<0)
return -x;
else
return x;
}
Graph g;
void Circle(float x, float y, float r)
{
g.M(x,y-r);
g.a(1,1,0,0,0,0,r*2);
g.a(1,1,0,0,0,0,-r*2);
}
int irand(int& seed)
{
seed=(seed*1103515245+12345)&0x7ffffff;
return s... | ALGO | 0.927612 | 3.783929 |
f67f2051-f41e-4d1f-847c-ad662286de2e | chaudhariyash10/Algorithms | Dyanamic Programming/Knapsack/TopDown KnapSack.cpp | #include <bits/stdc++.h>
using namespace std;
//n < 1000 && w < 1000
int dp[1001][1001];
int knapsack(int val[], int wt[], int W, int n)
{
for (int i = 0; i < 1001; i++)
{
dp[i][0] = dp[0][i] = 0;
}
for (int i = 1; i < n+1; i++)
{
for (int j = 1; j < W+1; j++)
{
... | ALGO | 0.999987 | 4.929427 |
1f9cc22a-9fcc-4f8e-beb9-c79ea3744dd7 | sandeshsuryawanshi/sms-LeetCode | 1004-max-consecutive-ones-iii/1004-max-consecutive-ones-iii.cpp | class Solution {
public:
int longestOnes(vector<int>& nums, int k) {
int zero=0;
int ans = 0;
int l = 0;
for(int i=0;i<nums.size();i++){
if(nums[i]==0) zero++;
if(zero>k){
if(nums[l]==0) zero--;
l++;
}
else
ans = max(ans,i-l+1);... | ALGO | 0.999977 | 6.039003 |
1d0ae83f-5424-44b6-9f54-4d5eb1f8c9a2 | shekhrozz/easy_localization_myself | 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.998859 | 6.785645 |
7136880e-e3ea-4dcb-a029-de8a193c1d9c | Arif-Rahman-Sikder/Competitive-Programming | Maths/C_CatFoxandtheLonelyArrayCodeForces1973B.cpp | #include <bits/stdc++.h>
// [-(~TheHonestGuy~)-]
using namespace std;
typedef long long ll;
typedef double dl;
#define endl "\n"
#define optimize() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#defi... | ALGO | 0.999922 | 5.256735 |
e32d410b-31c8-48ae-ac6f-ad9472113f86 | conradsoon/competitive_programming | kattis/solving/dominos.cpp | #include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef long int l;
typedef unsigned long int ul;
typedef long long int ll;
typedef unsigned long long int ull;
t... | ALGO | 0.999935 | 5.491872 |
dbfa03fa-5fa8-4a56-b10f-6cbe113cba97 | SeonghyeonKim/FS_assign12 | testhash.cpp | // tsthash.cpp
/*
Page 563: Programming project
1. create a hashed index of the student record file
2. The student record file is the entry-sequenced file
3. For insertion of new appended records, insert key on hashed index
4. Using hashed index, search the corresponding record with the key
*/
#include "direct.h"
#incl... | TOOL | 0.943043 | 3.904034 |
6a4761e2-fdaf-437e-a47e-5e2cfbed7698 | adityaa30/programs | Dynamic Programming/BinomialCoefficient.cpp | #include <bits/stdc++.h>
#define uli unsigned long int
using namespace std;
uli nCr(uli n, uli r) {
uli C[n + 1][r + 1];
for (uli i = 0; i <= n; ++i)
for(uli j = 0; j <= min(i, r); ++j) {
if (j == 0 || j == i)
C[i][j] = 1;
else
C[i][j] = C[i - 1][... | ALGO | 0.999978 | 5.417784 |
57a1f509-cac7-4790-9eb8-8514f1de8f91 | acc-cosc-1337-spring-2020/acc-cosc-1337-spring-2020-artgonzalezacc | src/examples/12_module/04_arrays_pointers/arrays_pointers.cpp | //cpp
#include "arrays_pointers.h"
#include <iostream>
void use_hours_array_w_pointer()
{
const int SIZE = 5;
int hours[SIZE] = { 5, 10, 30, 20, 7 };
int* hours_ptr = hours;
std::cout << *hours_ptr << "\n";
*hours_ptr++;
std::cout << *hours_ptr << "\n";
*hours_ptr--;
std::cout << *hours_ptr << "\n";
}
void ... | TOOL | 0.933986 | 3.845876 |
f0df8157-fe9e-4b67-9c1e-529fcbb376db | jemcashproject/jemcash | src/libzerocoin/SerialNumberSignatureOfKnowledge.cpp | /**
* @file SerialNumberSignatureOfKnowledge.cpp
*
* @brief SerialNumberSignatureOfKnowledge class for the Zerocoin library.
*
* @author Ian Miers, Christina Garman and Matthew Green
* @date June 2013
*
* @copyright Copyright 2013 Ian Miers, Christina Garman and Matthew Green
* @license This pr... | ALGO | 0.980611 | 6.948277 |
4a41d1b3-0c24-4db2-a1d3-1f5b3510eecc | jasonhmx/Jason-leetcode | 1.two-sum.cpp | /*
* @lc app=leetcode id=1 lang=cpp
*
* [1] Two Sum
*/
// @lc code=start
/*
Note:
Different ways of doing it. Can use 2-pointer method which has O(NlogN); or
can't use the same number twice!!
*/
#include <unordered_map>
#include <vector>
using namespace std;
class Solution {
public:
vector<int> twoSum(vec... | ALGO | 0.999549 | 6.3724 |
5d1f6d1a-06a4-4327-bdaf-8458d31b5f12 | Aleshkev/algoritmika | archive/3/postanowienia_noworoczne.cpp | #include <bits/stdc++.h>
using namespace std;
typedef intmax_t I;
int main()
{
cout.sync_with_stdio(false);
cin.tie(nullptr);
I n, k;
cin >> n >> k;
vector<I> t(n);
for(I i = 0; i < n; ++i) {
cin >> t[i];
}
vector<I> original_pos(n + 1);
for(I i = 0; i < n; ++i) {
... | ALGO | 0.999998 | 4.134157 |
df8409b9-de82-4e57-9b61-65fdc48aea46 | ayyadevaraakash/leetcode | 0907-sum-of-subarray-minimums/0907-sum-of-subarray-minimums.cpp | class Solution {
public:
typedef long long ll;
int sumSubarrayMins(vector<int>& arr) {
int M = int(1e9) + 7;
stack<int> st;
ll res = 0;
for (int k = 0, n = arr.size(); k <= n; k++) {
while (!st.empty() && (k == n || arr[st.top()] > arr[k])) {
... | ALGO | 0.999995 | 5.968292 |
648060cc-ac82-4619-83d6-2890e3b4f514 | zfa07/Killyouss | Engine/Source/ThirdParty/PhysX3/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_OBBSweep.cpp | #include "GuBV4.h"
using namespace physx;
using namespace Gu;
#if PX_INTEL_FAMILY && !defined(PX_SIMD_DISABLED)
#include "PsVecMath.h"
using namespace physx::shdfnd::aos;
#include "GuBV4_BoxSweep_Internal.h"
Ps::IntBool Sweep_AABB_BV4(const Box& localBox, const PxVec3& localDir, float maxDist, const BV4Tree& tree, S... | ALGO | 0.998506 | 7.65999 |
093c4c3a-8e0a-403a-b05e-6ef2991b7604 | ngokhang/ctdl_gt | stack/stack.cpp | #include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<string.h>
typedef struct node {
int item;
struct node *next;
}stack_node;
typedef struct {
stack_node *top;
}stack;
bool is_empty(stack *s) {
if(s->top == NULL) {
return true;
}
return false;
}
void init(stack *s) {
... | ALGO | 0.999332 | 4.021393 |
4fe20746-23ab-4c1b-a545-33246de9742c | WilliamX1/leetcode | Solutions/Search-in-Rotated-Sorted-Array.cpp | #include <bits/stdc++.h>
using namespace std;
class Solution
{
public:
int search(vector<int> &nums, int target)
{
int n = nums.size();
int x = lower_bound(nums.begin() + 1, nums.end(), nums[0], greater<int>()) - nums.begin();
int find_left = lower_bound(nums.begin(), nums.begin() +... | ALGO | 0.99998 | 5.80607 |
5a30325b-7811-41f9-b293-21540e9e008b | sangmin7b/algorithm | problems/1078-2.cpp | #include<bits/stdc++.h>
#include <vector>
using namespace std;
using vi = vector<int>;
int pow_i(int x, int y){
int res = 1;
while(y--){
res *= x;
}
return res;
}
int rev(int x){
int res = 0;
while(x > 0){
res *= 10;
res += x % 10;
x /= 10;
}
return res;
... | ALGO | 0.99973 | 5.447708 |
16a10d39-f3ef-4374-a36f-78572c36dcd7 | SumitChawariya/-C-Programming | prog151.cpp | //recursive function
#include<iostream>
#include<stdio.h>
using namespace std;
int countcap(char *str)
{
static int icnt=0;
if (*str!='\0')
{
if((*str>='A') && (*str<='Z'))
{
icnt++;
}
str++;
countcap(str);
}
return icnt;
}
int main()
{
int ans=0;
char arr[20];
cout<<"enter... | ALGO | 0.999048 | 3.953623 |
00acfbca-6896-4cf3-a020-06027c6b7c98 | pponnuvel/cpp-algorithms | problem_sets/lists_strings/02.reverse.cpp | #include <iostream>
#include <random>
#include <algorithm>
#include <limits>
void reverse(std::vector<int>& list)
{
std::reverse(list.begin(), list.end());
}
int main(void)
{
std::random_device r;
std::default_random_engine e1(r());
std::uniform_int_distribution<int> uniform_dist(1, std::numeric_limit... | ALGO | 0.985879 | 4.805776 |
668c7ed9-68b6-43b2-9317-f14434af9a8b | YichenZhou113/CS225-Data-Structure | mp6/kdtree.cpp | /**
* @file kdtree.cpp
* Implementation of KDTree class.
*/
#include <cmath>
#include <iostream>
using namespace std;
template <int Dim>
bool KDTree<Dim>::smallerDimVal(const Point<Dim>& first,
const Point<Dim>& second, int curDim) const
{
/**
* This function returns a bo... | ALGO | 0.999968 | 7.082365 |
b09fb351-b0f3-40ff-a058-bd92ae94a519 | rofi93/Codeforces | C. Hometask.cpp | /* -------------------------------- */
/* Name: MD. Khairul Basar */
/* Institute: HSTU */
/* Dept: CSE */
/* Email: <EMAIL> */
/* -------------------------------- */
#include <bits/stdc++.h>
/* all header files */
#define fs first
#define sc seco... | ALGO | 0.999648 | 3.703915 |
d7d94d3a-50a8-43ca-a986-671090cd8944 | KUMARSANDIPROY/leetcode | 103-binary-tree-zigzag-level-order-traversal/103-binary-tree-zigzag-level-order-traversal.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.094989 |
3003f3ae-43ba-46fd-9d45-2a69da4f59af | alexandraback/datacollection | solutions_5765824346324992_0/C++/koyahi/sample.cpp | #include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define MAX_B 1050
#define MAX_N 100000005LL
#define MAX_M 100005LL
ll M[MAX_N];
int main()
{
int T;
scanf( "%d", &T );
for ( int i = 0; i < T; i++ ) {
int B, N;
int ans = 0;
... | ALGO | 0.999857 | 3.158429 |
98e853c9-2028-493f-b064-fa03030c72ff | Aosp-pure/platform_frameworks_av | media/libstagefright/codecs/amrwb/src/isp_az.cpp | /*
------------------------------------------------------------------------------
Filename: isp_az.cpp
Date: 05/08/2004
------------------------------------------------------------------------------
REVISION HISTORY
Description:
------------------------------------------------------------------------------... | ALGO | 0.999654 | 4.911168 |
2bd8b6e5-9f99-422a-8223-2532b3d48917 | 113bommy/deepmind_codecontests_refine | cpp_gold_filter_file/cpp_train_4817_9.cpp | #include <bits/stdc++.h>
using namespace std;
long long a[100010];
int main() {
long long tc, n, i, ans = 0;
scanf("%lld", &tc);
while (tc--) {
ans = 0;
scanf("%lld", &n);
for (i = 0; i < n; i++) {
scanf("%lld", a + i);
ans += a[i];
}
sort(a, a + n);
if (a[n - 1] > ans - a[n - ... | ALGO | 0.98985 | 3.096209 |
2f1d58c8-bfcf-4c32-895d-32110beac474 | carrybanana/Cpp_study | C++PrimerPlus/CodingExample/6.14/cingolf.cpp | #include <iostream>
const int Max = 5;
int main()
{
using namespace std;
int golf[Max];
cout << "Pls enter your golf scores.\n";
cout << "You must enter " << Max << " rounds.\n";
int i;
for (i = 0; i < Max; i++)
{
cout << "round #" << i+1 << ": ";
while (!(cin >> golf[i]))
... | TOOL | 0.856759 | 3.556006 |
9fad06bb-8ae3-4dbd-b637-22737b46885a | rostyaa/university-labs | TA-labs/laba2.cpp | #include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cstdlib>
#include<windows.h>
using namespace std;
//функція для генерації масиву випадкових чисел
vector<int> generateRandomArray(int size, int range) {
vector<int> arr(size);
for (int i = 0; i < size; i++) {
arr[i] ... | ALGO | 0.999856 | 4.518764 |
2df7b501-4e20-45cd-bfef-85b45ac8cbd1 | SJTU-IPADS/PowerInfer | smallthinker/examples/retrieval/retrieval.cpp | #include "arg.h"
#include "common.h"
#include "log.h"
#include "llama.h"
#include <algorithm>
#include <fstream>
#include <iostream> // TODO: remove me
static void print_usage(int, char ** argv) {
LOG("\nexample usage:\n");
LOG("\n %s --model ./models/bge-base-en-v1.5-f16.gguf --top-k 3 --context-file READ... | DATA | 0.938076 | 6.339208 |
4f9fa604-e5e6-4966-a682-6cbd3d68ed68 | sony-msm8996/android_device_sony_tone-common | gps/utils/loc_misc_utils.cpp | #define LOG_NDEBUG 0
#define LOG_TAG "LocSvc_misc_utils"
#include <stdio.h>
#include <string.h>
#include <log_util.h>
#include <loc_misc_utils.h>
#include <ctype.h>
int loc_util_split_string(char *raw_string, char **split_strings_ptr,
int max_num_substrings, char delimiter)
{
int raw_stri... | TOOL | 0.953462 | 5.317348 |
fa6c35d7-eaa0-482c-81e6-760727f8ef88 | Ankur8789/LC-my-solutions | 1690-stone-game-vii/1690-stone-game-vii.cpp | class Solution {
public:
int dp[1001][1001][2];
int f(int i,int j,int turn,vector<int>& st,vector<int>& pref,vector<int>& suff)
{
if(i==j)
return 0;
if(dp[i][j][turn]!=-1)
return dp[i][j][turn];
if(turn)
{
int pf=0,sf=0;
if(i==0)
... | ALGO | 0.99996 | 4.950579 |
5dcdcfdf-7a07-4adc-8eba-af8aadc02d35 | XT-Error406/Daily-Challenge---leetcode | 804. Unique Morse Code Words.cpp | class Solution {
public:
int uniqueMorseRepresentations(vector<string>& words) {
string arr[26]={".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.." };
set<string>ans;
... | ALGO | 0.999918 | 6.446265 |
92d93e35-e4e1-4c5d-b93f-f6ca5bb8c3df | notJAYanand/Leetcode | 1662-check-if-two-string-arrays-are-equivalent/1662-check-if-two-string-arrays-are-equivalent.cpp | class Solution {
public:
bool arrayStringsAreEqual(vector<string>& word1, vector<string>& word2) {
string s1="";
string s2="";
for(int i=0;i<word1.size();i++)
{
s1.append(word1[i]);
}
for(int i=0;i<word2.size();i++)
{
s2.appen... | ALGO | 0.998447 | 6.187977 |
04e8423d-4e6d-41bf-8ca5-f467868995cd | ytqkoala/aoapc-book | TrainingGuide/bookcodes/ch6/la3700.cpp | // LA3700 Interesting Yang Hui Triangle
// Rujia Liu
#include<cstdio>
int main() {
int kase = 0, n, p;
while(scanf("%d%d", &p, &n) == 2 && p) {
int ans = 1;
while(n > 0) {
ans = ans * (n%p+1) % 10000;
n /= p;
}
printf("Case %d: %04d\n", ++kase, ans);
}
return 0;
}
| ALGO | 0.999898 | 3.705648 |
0646a626-7f9f-410f-b35f-4a2eb7527cd9 | qijiarui2310/oceanbase-vldbss-2024 | src/storage/memtable/ob_row_compactor.cpp | #include "share/config/ob_server_config.h"
#include "lib/stat/ob_diagnose_info.h"
#include "ob_row_compactor.h"
#include "storage/memtable/mvcc/ob_mvcc_row.h"
#include "storage/memtable/ob_memtable.h"
#include "storage/memtable/ob_memtable_data.h"
#include "storage/memtable/ob_memtable_compact_writer.h"
#include "stora... | TOOL | 0.940515 | 6.924846 |
e5f22960-96bc-4106-ac3f-92da16ae2f0a | Alex-Shen1121/SZU_Learning_Resource | 计算机与软件学院/面向对象程序设计(荣誉)/大作业1/素材1/2018192014_1120_1.cpp | 2018192014:Problem1120:ȷ
#include<bits/stdc++.h>
using namespace std;
class Animal{
protected:
string name;
int age;
public:
Animal(string n,int a):
name(n),age(a){
}
virtual void speak()=0;
};
class Tiger:virtual public Animal{
protected:
public:
Tiger(string n,int a):Animal(n,a){
}
virtual void speak()
{
... | ALGO | 0.982251 | 4.430955 |
670675b0-54eb-45e7-aa20-c838718c0e5e | HiepF5/CTDLGT_PTIT | code/DSA06010.cpp | #include<bits/stdc++.h>
#define ll long long
using namespace std;
int cnt[11];
main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
string s;
cin.ignore();
getline(cin,s);
set<int>st;
//cout<<s[0];
for(int i=0;i<s.size();i++)
{
... | ALGO | 0.998496 | 4.133135 |
3a1680e2-6439-4b93-ac3d-ea698318343a | VladBermishev/BMSTU_Linear_Algebra | lib/Eigen/bench/sparse_cholesky.cpp | // #define EIGEN_TAUCS_SUPPORT
// #define EIGEN_CHOLMOD_SUPPORT
#include <iostream>
#include <Eigen/Sparse>
// g++ -DSIZE=10000 -DDENSITY=0.001 sparse_cholesky.cpp -I.. -DDENSEMATRI -O3 -g0 -DNDEBUG -DNBTRIES=1 -I /home/gael/Coding/LinearAlgebra/taucs_full/src/ -I/home/gael/Coding/LinearAlgebra/taucs_full/build/lin... | ALGO | 0.984123 | 4.147974 |
c246ee02-6357-4232-a963-17765eac7a97 | garimasinghgryffindor/DAA | DYNAMIC PROGRAMMING/LCS.cpp | //LONGEST COMMON SUBSEQUENCE
//DYNAMIC PROGRAMMING
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int max(int x,int y)
{
if(x>y)
{
return x;
}
return y;
}
int lcs(string X,string Y,int m,int n)
{
int sol[m+1][n+1];
int i,j;
for(i=0 ; i<=m ; i++)
{... | ALGO | 0.999631 | 4.546463 |
0cb08272-e79a-476e-96af-284a7cb8395f | guduzhe777/Code-cpp | ACM/PTA/L1Easy/7-2.cpp | #include<bits/stdc++.h>
using namespace std;
string str1,str2;
string s1, s2;
int main()
{
cin>>str1>>str2;
for(size_t i = 1;i<str1.length();i++)
{
if(str1[i]%2 == str1[i-1]%2) s1 += max(str1[i],str1[i-1]);
}
cout<<s1<<endl;
return 0;
}
| ALGO | 0.999995 | 3.803059 |
fe43b3ce-7fcd-491a-a39a-2aaff558f86c | apache/madlib | src/modules/convex/mlp_igd.cpp | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you ... | ALGO | 0.998617 | 4.153518 |
b791ea4a-4e2d-4f80-b7ee-749574efa85a | ADMoreau/Helicoide_GUI | C++_files/main.cpp | #include <iostream>
#include <chrono>
#include <cstdlib>
#include <tuple>
#include <math.h>
#include <Eigen/Dense>
#include <Eigen/Core>
#include <algorithm>
#include <vector>
#include <opencv2/video/tracking.hpp>
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <ope... | ALGO | 0.955088 | 5.493087 |
efb1a7c1-6105-4951-a519-d6ba409c7273 | HN026/CAlgo | BitManipulation/xorLtoR.cpp | #include <iostream>
using namespace std;
int XO(int n){
if(n%4==0) return n;
if(n%4==1) return 1;
if(n%4==2) return n+1;
return 0;
}
int main(){
int a = XO(4);
int b = XO(6);
int c = a^b;
cout<<c<<endl;
return 0;
} | ALGO | 0.99997 | 3.280948 |
72043e58-78dd-45eb-9dbc-518c22741f7b | nikela/llvm-epi | libcxx/test/std/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search_comp.pass.cpp | // <algorithm>
// template<ForwardIterator Iter, class T, CopyConstructible Compare>
// constexpr bool // constexpr after C++17
// binary_search(Iter first, Iter last, const T& value, Compare comp);
#include <algorithm>
#include <vector>
#include <functional>
#include <cassert>
#include <cstddef>
#include "... | TEST | 0.999065 | 7.337675 |
f6e04529-6f90-4854-9b07-729c7ba825b4 | tchomphoochan/cmutoi_codes | resources/o61_oct_problems_and_solutions/Day05 - 2015.10.27 (Permutation _ Combinatorics)/(4).Oct12_Permutation/Oct12_Permutation.cpp | #include <cstdio>
int idx = 0, L, out[15];
bool visited[15];
void nPr(int len, int N, int K){
if(idx == L)
return;
if(len == K){
idx++;
/*
printf("%d -> ", idx);
for(int i = 0; i < K; ++i)
printf("%d ", out[i]);
printf("\n");
//*/
if(idx =... | ALGO | 0.999974 | 3.134156 |
40bd71b2-233d-492f-a3ee-324075aece42 | jatincodes595/6Companies30days | Microsoft/13.Bridge edge in a graph.cpp | class Solution{
public:
int cnt1=0,cnt=0;
vector<int> vis,vis1;
// it is used to find the no of connected components
void dfs(int i,vector<int> adj[])
{
vis[i]=1;
for(auto x:adj[i])
{
if(vis[x]==0)
dfs(x,adj);
}
}
// it is used to find... | ALGO | 0.999726 | 5.421496 |
7dba9649-3027-4b2c-ba98-3ccd91777a44 | veyom001/Codeforces-Solutions- | cf r 726 div2/A.cpp | #include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ci(a) ll a; cin>>a;
#define fo(i,a,b) for(ll i=a;i<b;i++)
#define MOD 998244353
#define call(type,var) type var; cin>>var;
#define ci2(type,a,b) type a,b; cin>>a>>b;
#define ci3(type,a,b,c) type a,b,c; cin>>a>>b>>c;
#define pb1(arr,k) a... | ALGO | 0.999798 | 4.731911 |
b7ad6515-c43b-40eb-afa7-e4f258c6983f | mukesh567/ALL-DSA-PROBLEMS | Array/2-DArray/printArray.cpp |
#include <bits/stdc++.h>
using namespace std;
void printArray(int arr[][4], int m, int n)
{
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
cout << arr[i][j] << " ";
}
cout << endl;
}
}
int main()
{
int arr[3][4];
// int arr[3][4]={1,2,3,4,... | ALGO | 0.993374 | 3.858836 |
6a1915c6-9893-4c14-bfbf-9efb52962eaa | zhouyong1234/SLAM-All-In-One | SLAM多传感器融合定位/Multi-Sensor-Fusion-Frameworks/TinyGrapeKit/third_party/Pangolin/src/utils/file_utils.cpp | #include <pangolin/platform.h>
#include <pangolin/utils/file_utils.h>
#ifdef _WIN_
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# endif
# include <Windows.h>
# include <Shlobj.h>
# ifdef UNICODE
# include <codecvt>
# endif
#else
# include <dirent.h>
# include <sys/types.h>
# include <sys/s... | TOOL | 0.992547 | 3.430936 |
441824c0-9257-4079-905e-f62a3e4d18b6 | THE-DEEPDAS/CodeForces_Journey | Alternating_Strings.cpp | // length = even and numbers on even positions = same , odd positions = same
// we can choose an index and delete it from array, only 1 time
// replace s[i] with another letter
// min operations to make string alternating
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ll testcases =... | ALGO | 0.99996 | 4.801229 |
309ab2a9-f29f-49a7-ba00-03e751c814aa | kai336/atcoder | practice/bootcampforbeginners/easy100/67.cpp | #include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
vector<string> s(n);
for(int i=0; i<n; i++){
cin >> s.at(i);
}
sort(s.begin(), s.end());
vector<int> idx;
int max = 0;
int tmp = 0;
for(int i=1; i<n; i++){
if(s.at(i) == s.at(i-1)){
... | ALGO | 0.999997 | 3.835106 |
2866c31e-638b-4c69-817c-37ef1ce9479f | donbasta/leetcode-submissions | Easy/3206.cpp | class Solution {
public:
int numberOfAlternatingGroups(vector<int>& colors) {
int n = colors.size();
int ans = 0;
for (int i = 0; i < n; i++) {
int prv = (i + n - 1) % n;
int nx = (i + 1) % n;
if ((colors[prv] != colors[i]) && (colors[i] != colors[nx])) {
... | ALGO | 0.999816 | 5.775323 |
cb8103df-ae7c-48a1-a85c-b08af22e4422 | keijak/comp-pub | atcoder/abc227/D/main_D.cpp | #include <bits/stdc++.h>
#define REP_(i, a_, b_, a, b, ...) \
for (int i = (a), END_##i = (b); i < END_##i; ++i)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define ALL(x) std::begin(x), std::end(x)
//using Int = long long;
using Uint = unsigned long long;
using Real = long double;
template... | ALGO | 0.999804 | 4.347746 |
8d933d10-ce1c-452a-af21-65fe235b9019 | ambujtripathi988/Coding | LeetCode/Next Greater Element I.cpp |
// https://leetcode.com/problems/next-greater-element-i/
class Solution {
public:
vector<int> nextGreaterElement(vector<int>& nums1, vector<int>& nums2)
{
unordered_map<int,int> inde ;
for(int i = 0 ; i < nums2.size() ; i++)
inde.insert({nums2[i],i}) ;
ve... | ALGO | 0.999927 | 5.790298 |
f8340552-01f7-469a-8e3d-2deffc55022e | CIBC-Internal/boost | libs/math/src/tr1/fmin.cpp | extern "C" double BOOST_MATH_TR1_DECL boost_fmin BOOST_PREVENT_MACRO_SUBSTITUTION(double x, double y) BOOST_MATH_C99_THROW_SPEC
{
if((boost::math::isnan)(x))
return y;
if((boost::math::isnan)(y))
return x;
return (std::min)(x, y);
}
| ALGO | 0.961795 | 5.4431 |
cf2f9c7f-6685-41db-b568-a1d5e39f3516 | sanketdisale871/DSA | Contest/WeeklyContest335/Kth_Largest_Sum_Binary_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.99987 | 5.612939 |
13e76e4d-91ad-4926-8e7b-5cfb764d8954 | DivyamVJ0901/Love-Babbar-DSA-Youtube-Course-all-Codes | lecture12b.cpp | // FINDING FIRST AND LAST OCCURENCE OF AN ELEMENT IN AN ARRAY.
#include <iostream>
using namespace std;
int FirstOcc(int arr[], int n, int key)
{
int s = 0;
int e = n - 1;
int mid = s + (e - s) / 2;
int ans = -1;
while (s <= e)
{
if (arr[mid] == key)
{
ans = mid;
... | ALGO | 0.999916 | 5.080553 |
e093be93-b61b-481c-8958-49dc3852863c | Muskan-Nisar/cpp | singlelement.cpp | #include<iostream>
#include<vector>
using namespace std;
int singleElement(vector<int> &arr){
int n =arr.size();
if(n==1) return arr[0];
if(arr[0]!=arr[1]) return arr[0];
if(arr[n-1]!=arr[n-2]) return arr[n-1];
int low=1;
int high =n-2;
while(low<=high){
int mid= (low+high)/2;
... | ALGO | 0.999752 | 4.008238 |
5e9ef04c-e6ca-4a2e-8014-612fb9f275e8 | SMiles02/CompetitiveProgramming | Other Stuff/Bay Area PC/BAPC-B.cpp | #include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
#define a2 array<int,2>
using namespace std;
const int N = 501;
int n,m,x,y,k,a[N][N],ans[N][N];
bitset<N> done[N];
vector<int> dx = {0,0,-1,1};
vector<int> dy = {-1,1,0,0};
bool ok(int X, int Y, int p, int s, int t)
{
if (1<=X&&X<=n&&1<=... | ALGO | 0.999865 | 3.111823 |
3a6d1e1c-121f-49c5-95c8-012fb5b244da | bori00/FundamentalAlgorithms | Lab5_HashTable/main.cpp | #include <iostream>
#include "hash_table.h"
#include "hash_table_evaluator.h"
#include "gtest/gtest.h"
using namespace std;
void demo1();
void demo2();
int main(int argc, char *argv[]) {
demo1();
demo2();
HashTableEvaluator hash_table_evaluator;
hash_table_evaluator.Evaluate();
::testing::InitGoogleTest(&... | ALGO | 0.99669 | 6.697762 |
0a6a68c5-0f26-47e6-8093-c6f4d27186af | sakshamsomani2345/c-plus-plus-practice | final introduction c++/bindeconversion.cpp | #include <iostream>
using namespace std;
int main()
{
int m, p;
cin >> m;
int decimalsum=0,weight=1;
for (; m!=0 ; weight=weight*2)
{
int rem=m%10;
decimalsum=decimalsum+rem*weight;
m=m/10;
}
cout<<decimalsum;
// while (m!=0)
// {
// int rem=m%10;
... | ALGO | 0.999899 | 4.05883 |
58ac1a01-e1ce-44ed-8403-ce006988e1bd | Hnshlr/hpc-assignment | src/Graph.cpp | #include "Graph.h"
// CONSTRUCTORS/DESTRUCTORS:
Graph::Graph() = default;
Graph::Graph(const std::string &distFilename) {
// Open the distFile:
std::ifstream distFile(distFilename);
if (!distFile.is_open()) {
std::cout << "Could not open distFile: " << distFilename << ".\n";
exit(1);
}
... | ALGO | 0.890907 | 5.098052 |
8f75a36f-da55-4575-89bb-2d92f694b8d9 | fafa1899/BuildCppDependency | Source/boost-1.86.0/libs/contract/example/features/access.cpp | #include <boost/contract.hpp>
#include <vector>
#include <cassert>
template<typename T>
class pushable {
friend class boost::contract::access;
void invariant() const {
BOOST_CONTRACT_ASSERT(capacity() <= max_size());
}
public:
virtual void push_back(T const& value, boost::contract::virtual_* ... | TOOL | 0.945425 | 6.204287 |
b982768f-22b3-444b-9d70-7bacf1fae0ae | Garvit/code-backup | hackerearth/indiahacks2014/pawan/bear.cpp |
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
#define mod 100000007LL
/* Source of nlogn Suffix array : http://apps.topcoder.com/forums/?module=RevisionHistory&messageID=1171511*/
#define maxn 2000000
#define sd(x) scanf("%d", &x)
#define LL long long
char in[maxn];
int str[maxn];
int... | ALGO | 0.999876 | 3.839785 |
c73b7d95-3abc-46bf-bc63-62f8c326a1f8 | sehan2709-cmis/2022-3PPSWinterCamp | 권세한_20230114/A045_권세한_20230111.cpp | #include <iostream>
using namespace std;
int alpha[26], cnt = 0;
string input;
int main() {
int max = 0, max_indx = 0;
cin >> input;
for (int i = 0; i < input.length(); i++) {
if (input[i] < 97)
alpha[input[i] - 65]++;
else
alpha[input[i] - 97]++;
}
for (int i = 0; i < 26; i++) {
... | ALGO | 0.999981 | 3.581748 |
a1f4d857-d39e-4ee6-a21d-0f9ef3d824eb | Mwako/deps | boost/libs/math/example/students_t_example2.cpp | // students_t_example2.cpp
// Example 2 of using Student's t
// A general guide to Student's t is at
// http://en.wikipedia.org/wiki/Student's_t-test
// (and many other elementary and advanced statistics texts).
// It says:
// The t statistic was invented by William Sealy Gosset
// for cheaply monitoring the quality ... | ALGO | 0.996918 | 6.805 |
9229250d-1bb4-4eb0-9e9e-e46ba0c23854 | rohith2506/Algo-world | misc/leetcode/palindrome_3.cpp | #include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#define MAXI 1000000
using namespace std;
int func(string s){
int len = s.length();
bool p[len][len];
int c[len][len];
for(int i=0;i<len;i++){
p[i][i]=true;
c[i][i]=0;
}
for(int l = 2;l<=len;... | ALGO | 0.999955 | 3.965295 |
3c116f5f-ba3e-4edb-b64b-87b7eaa7784b | sultancodess/leetcode- | C++/sumNumbers.cpp | // Time Complexity: O(n)
// Space Complexity: O(logn)
/**
* Definition for binary tree
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
int dfs(TreeNode *root, int num) {
... | ALGO | 0.999976 | 5.868426 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.