uuid string | repo_name string | relative_path string | content string | category string | algo_rel_score float64 | quality_score float64 |
|---|---|---|---|---|---|---|
3135ba28-c0d3-4d2d-b8dd-0c7f9c8a6932 | leverimmy/Codes | 比赛/学校/2019-11-7测试/source/PC15_Polaris_Dane/15.cpp | #include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdlib>
#define int long long
using namespace std;
const int M=100000;
const int inf=0x7f7f7f7f;
const int mod=1e9+7;
const double eps=1e-6;
in... | ALGO | 0.999731 | 3.572831 |
24e7967d-2f9f-4cbb-8305-bb939fc62f17 | VladislavLemesh/PP_N | Лаб_4/mod_ops.cpp | #include "mod_ops.h"
#include <climits>
#if defined(__GNUC__) && INTWORD_MAX == 0xffffffffffffffffu
IntegerWord add_mod(IntegerWord a, IntegerWord b, IntegerWord mod)
{
return (IntegerWord) (((unsigned __int128) a + b) % mod);
}
IntegerWord mul_mod(IntegerWord a, IntegerWord b, IntegerWord mod)
{
return (IntegerWord... | ALGO | 0.908943 | 6.288298 |
a1137eaa-e3d9-4b52-8fc9-dfa729830f2d | doocs/leetcode | solution/0700-0799/0746.Min Cost Climbing Stairs/Solution.cpp | class Solution {
public:
int minCostClimbingStairs(vector<int>& cost) {
int n = cost.size();
int f[n];
memset(f, -1, sizeof(f));
auto dfs = [&](this auto&& dfs, int i) -> int {
if (i >= n) {
return 0;
}
if (f[i] < 0) {
... | ALGO | 0.999972 | 6.372787 |
9bb0af96-a283-4e8a-bde3-60bc31e8c96d | tsorren/UTN | 2023/Algoritmos_y_estructuras_de_datos/1er_Cuatrimestre/Practica_1/7.cpp | /*
Calcular la velocidad (m/s) de los participantes de una carrera de 1500mts, dado el tiempo en segundos que le llevó a cada participante completarla y determinar el nombre del más veloz.
Y si el tiempo fuera en minutos + segundos?
MRU
x = X0 + V * (t - t0) -> x = V * t
-> 1500 = V * t -> 1500... | ALGO | 0.998786 | 4.317271 |
01894eda-0d06-4c09-a531-b061adbdabf2 | antops/Util | eigen/doc/examples/class_CwiseUnaryOp_ptrfun.cpp | #include <Eigen/Core>
#include <iostream>
using namespace Eigen;
using namespace std;
// define function to be applied coefficient-wise
double ramp(double x)
{
if (x > 0)
return x;
else
return 0;
}
int main(int, char**)
{
Matrix4d m1 = Matrix4d::Random();
cout << m1 << endl << "becomes: " << endl << ... | ALGO | 0.984114 | 4.120226 |
caaba57c-6451-44b8-803e-3ea22037ac16 | microsoftarchive/msdn-code-gallery-microsoft | Official Windows Platform Sample/Windows 8 app samples/[C++]-Windows 8 app samples/C++/Windows 8 app samples/Direct3D resource loading sample (Windows 8)/C++/texconv/DirectXTexNormalMaps.cpp | #include "directxtexp.h"
namespace DirectX
{
#pragma prefast(suppress : 25000, "FXMVECTOR is 16 bytes")
static inline float _EvaluateColor( _In_ FXMVECTOR val, _In_ DWORD flags )
{
XMFLOAT4A f;
static XMVECTORF32 lScale = { 0.2125f, 0.7154f, 0.0721f, 1.f };
static_assert( CNMAP_CHANNEL_RED == 0x1, "CNMA... | ALGO | 0.991922 | 7.22988 |
d3277869-d422-41f5-b1ad-12862aa222a0 | SteerSuite/steersuite-rutgers | kdtree/src/KdTreeDataBase.cpp | /*
* KdTreeDataBase.cpp
*
* Created on: 2014-11-27
* Author: gberseth
*/
#include "KdTreeDataBase.h"
#include "util/DrawLib.h"
using namespace SteerLib;
#include "obstacles/BoxObstacle.h"
#include "SteerLib.h"
#include "util/DrawLib.h"
#include <vector>
#include <cmath>
#include <ctime>
using namespace... | ALGO | 0.894182 | 3.876001 |
32e3f3fd-8429-4aee-8234-bc9adbbd4c8d | fightforhash/Interview-Prep | JungOl/3437.cpp | #include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int moveCounter(int n, string balls) {
int rc = 0, bc = 0, ans = n;
for (char ball : balls) {
if (ball == 'R') rc++;
else bc++;
}
ans = min(rc, bc);
int cnt = 0;
for (int i = 0; i < n; i++) { //왼쪽... | ALGO | 0.999674 | 5.004191 |
1d9ac97a-9ad7-4280-8681-ebfad7365229 | shatakshishukla17/Striver-DSA-A-TO-Z | Basics/Know Basic Maths/CountDigits.cpp | // Question link: https://www.geeksforgeeks.org/problems/count-digits5716/1
class Solution{
public:
int evenlyDivides(int N){
//code here
int count=0;
int temp=N;
while(N>0){
int lastdigit=N%10;
if(lastdigit!=0 && temp%lastdigit==0){
count++;
... | ALGO | 0.99979 | 5.044516 |
f724589e-8085-42d9-963f-ab67c89dea20 | Danziger/CarND-T2-Model-Predictive-Control-MPC-Quizzes | 002-Polyfit/src/Eigen-3.3/failtest/qr_int.cpp | #include "../Eigen/QR"
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
#define SCALAR int
#else
#define SCALAR float
#endif
using namespace Eigen;
int main()
{
HouseholderQR<Matrix<SCALAR,Dynamic,Dynamic> > qr(Matrix<SCALAR,Dynamic,Dynamic>::Random(10,10));
}
| TEST | 0.917301 | 3.076401 |
cec13a4a-9e4f-4020-ab1a-29982bc2f29e | bqmnhat/CompetitiveProgramming | TuyenThang7/EQUATION/EQUATION.cpp | #include <iostream>
#include <bits/stdc++.h>
#define MaxN 100000
using namespace std;
typedef long long ll;
int t;
ll a, b;
map<ll, int> Fac;
/*void MakeSieve() {
for (int i=2; i*i<= MaxN; i++)
if (Sieve[i] == 0)
for (int j=i; i*j <= MaxN; j++)
Sieve[i*j] = i;
}*/
void SingleFa... | ALGO | 0.999945 | 4.952471 |
0de7ec32-02d7-4115-b5ce-4abdb960cd52 | deepaktalwardt/interview-prep-cpp | LeetCode/743-network-delay-time.cpp | #include <unordered_map>
#include <queue>
class Solution {
public:
int networkDelayTime(vector<vector<int>>& times, int N, int K) {
unordered_map<int, vector<vector<int>>> graph;
for (auto& t : times) {
auto it = graph.find(t[0]);
if (it != graph.end()) {
(it... | ALGO | 0.999979 | 6.307593 |
d50c53d8-f2d7-425d-a5e8-260d1a6d990b | M-Ayushi/competitive-programming | codeforces/1987/A..cpp | #include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x.size())
using namespace std;
void solve() {
int n, k;
cin >> n >> k;
cout << ((n-1)*k + 1) << "\n";
return;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--) solve();
return 0;
}
| ALGO | 0.999846 | 3.897303 |
a9840484-3ab1-45f2-b890-c0e7fa4cd1ca | Sudhir769/leetcode-solutions | 539-minimum-time-difference/minimum-time-difference.cpp | class Solution {
public:
int findMinDifference(vector<string>& timePoints) {
int n = timePoints.size();
vector<int> minTime(n);
int result = INT_MAX;
for(int i=0; i<n; i++){
string time = timePoints[i];
int timeInMin = stoi(time.substr(0... | ALGO | 0.999726 | 6.157961 |
6323177f-d4d8-4bb0-8bec-9a44f68281b1 | chetan7020/CP | cses/TrafficLights.cpp | /*
Build | ..... | Peace
cpy mat kar bc
*/
#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define int long long
#define srt(a) sort(a.begin(), a.end())
#define fore(i, a, b) for(int i = (a); i < (b); i++)
#define fori(i, a, b) for(int i = (a); i <= (b); i++)
using... | ALGO | 0.999631 | 3.158514 |
9c3335d1-5217-4397-a17f-82b2e6de0a89 | iiicp/llvm | lib/Support/SmallPtrSet.cpp | #include "llvm/ADT/SmallPtrSet.h"
#include "llvm/Support/MathExtras.h"
#include <cstdlib>
using namespace llvm;
void SmallPtrSetImpl::shrink_and_clear() {
assert(!isSmall() && "Can't shrink a small set!");
free(CurArray);
// Reduce the number of buckets.
CurArraySize = NumElements > 16 ? 1 << (Log2_32_Ceil(N... | ALGO | 0.922971 | 7.560139 |
8e2e015d-e01e-4d52-b207-7e173a7f41cd | gopar-citus/android_spatialite_5 | static_libs/proj-9.2.1/src/projections/wink2.cpp | #define PJ_LIB_
#include <errno.h>
#include <math.h>
#include "proj.h"
#include "proj_internal.h"
PROJ_HEAD(wink2, "Winkel II") "\n\tPCyl, Sph\n\tlat_1=";
namespace { // anonymous namespace
struct pj_opaque {
double cosphi1;
};
} // anonymous namespace
#define MAX_ITER 10
#define LOOP_TOL 1e-7
static PJ_XY wi... | ALGO | 0.983131 | 4.920115 |
c483ad5c-fb68-4bc0-857e-0cbc9ae9c949 | ritik6207/Cpp-Programming | 2. Variable&DataType/5_compound_interst.cpp | #include<iostream>
#include<math.h>
using namespace std;
int main()
{
float ci,p,r,t,a;
cout<<"Enter Principle , Rate of Insterst and time:\n";
cin>>p>>r>>t;
a=p*pow((1+(r/100)),t);
ci=a-p;
cout<<"compound interst = Rs. "<<ci;
return 0;
} | ALGO | 0.999716 | 3.533 |
192a65e7-0a22-4fb9-9afe-cdc713897839 | Fengdalu/acm-icpc | CF/377/d.cpp | #include <bits/stdc++.h>
typedef long long ll;
#define cmin(x, y) x = std::min(x, y)
const int N = 1e5+100;
int d[N];
int a[N];
int q[N];
bool vis[N];
int n, m;
bool check(int up) {
std::fill(vis, vis + m + 1, 0);
int cnt = 0;
int has = 0;
while(up) {
if(d[up] != 0) {
if(!vis[d[u... | ALGO | 0.999985 | 3.917291 |
cf0d386d-8613-4031-be5e-6098149edcf7 | colinsenner/SimpleInjector | SimpleInjector/ProcessUtilities.cpp | #include "ProcessUtilities.h"
#include <Windows.h>
#include <stdio.h>
#include <tlhelp32.h>
#include <vector>
std::vector<DWORD> PidFromProcessName(const wchar_t* processName)
{
std::vector<DWORD> pids;
HANDLE snapshot;
PROCESSENTRY32 pe32;
snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (... | TOOL | 0.943271 | 5.431304 |
5f3d9b4f-d8d5-4fc5-a4a3-67e66e5e9d6d | xnmng/LeetCode | 3151-special-array-i/3151-special-array-i.cpp | class Solution {
public:
bool isArraySpecial(vector<int>& nums) {
for (int i = 1; i < nums.size(); ++i) {
if ((nums[i] + nums[i-1]) % 2 == 0) return false;
}
return true;
}
}; | ALGO | 0.99972 | 5.707594 |
b91b5d4c-115f-4bd5-8a02-8c7f1595ad31 | 1103r74t8g/Leetcode | CPP/2558. Take Gifts From the Richest Pile.cpp | class Solution {
public:
long long pickGifts(vector<int>& gifts, int k) {
long long sum = 0;
make_heap(gifts.begin(), gifts.end());
for(int i = 0; i < k; i++){
int max = gifts.front();
pop_heap(gifts.begin(),gifts.end());
gifts.pop_back();
gif... | ALGO | 0.99997 | 5.585754 |
5c2aed33-8678-40a1-9132-afa3e7844f75 | ChristianSiebke/DReaM-Driver-Reaction-Model | sim/src/components/Algorithm_Longitudinal/src/longCalcs.cpp | //-----------------------------------------------------------------------------
/** @file longCalcs.cpp */
//-----------------------------------------------------------------------------
#include <cassert>
#include <array>
#include <limits>
#include <map>
#include <iostream>
#include "longCalcs.h"
#include "common/co... | ALGO | 0.982241 | 5.661982 |
f12fdcc3-5c4a-4273-8bfa-160a271a1d9d | siddhantb99/LeetCode-Solutions | 30DaysLeetcodeChallenge_May/207. Course Schedule.cpp | /*
Course Schedule
Solution
There are a total of numCourses courses you have to take, labeled from 0 to numCourses-1.
Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair: [0,1]
Given the total number of courses and a list of prerequisite pairs,... | ALGO | 0.999939 | 6.648324 |
b4f1f63c-2a72-4043-a549-20dbad9276ff | jlmmox/leetcode-hot100 | 118.cpp | class Solution {
public:
vector<vector<int>> generate(int numRows) {
vector<vector<int>> yanghui(numRows);//5行
for(int i=0;i<numRows;++i)
{
yanghui[i].resize(i+1);//创建i+1列,[i]不能忘
yanghui[i][0]=yanghui[i][i]=1;
for(int j=1;j<i;++j)
yanghui[i... | ALGO | 0.999959 | 5.397184 |
b255d166-069c-4c9c-b922-91f118349a0c | perchuts/CompetitiveProgramming | cf/2005/e2.cpp | #include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ii = pair<int,int>;
using iii = tuple<int,int,int>;
co... | ALGO | 0.998771 | 3.475444 |
b6cbe11a-b4b2-4f5e-88b5-3c46967fcbe8 | jemin0619/PS | Algorithm/SCC/2207 가위바위보.cpp | //가위 true, 바위 false로 모델링
//양수 -> 가위 -> true
//음수 -> 바위 -> false
#include <bits/stdc++.h>
using namespace std;
#define fastio cin.tie(NULL)->sync_with_stdio(false)
int N,M;
vector<int> adj[20'003];
vector<int> order(20'003, -1);
vector<int> SccNum(20'003, -1);
stack<int> stk;
int oppose(int n){
if(n <= N) return ... | ALGO | 0.999991 | 4.059094 |
89eb7f32-460c-4d5a-817b-efba10bce8a0 | manishgoyal30/Data_Structure | GFG/Lecture_Searching/L5_lastoccurence.cpp | #include <bits/stdc++.h>
using namespace std;
int bSearch(int arr[],int n, int x){
int low =0, high=n-1;
while(low<=high){
int mid = (low+high)/2;
if(arr[mid]>x)
high = mid-1;
else if(arr[mid]<x)
low = mid+1;
else
{
if(mid==0 || arr[mid]!=arr... | ALGO | 0.999602 | 6.00106 |
79fea771-b7b3-4cf3-b6cc-8a5f5891ef30 | Djokovic0311/LeetCode | problems/missing_number/solution.cpp | class Solution {
public:
int missingNumber(vector<int>& nums) {
int sum = 0; // sum of all numbers initially 0
int total = nums.size()*(nums.size() + 1)/2; // total is the sum of all numbers in the array
for (auto number : nums) { // iterate through the array
sum += number; // ad... | ALGO | 0.999881 | 6.12991 |
0e16b60e-e4a9-496d-918e-d4ca4e72fca0 | AbhijitShaw09/Sde-Sheet-Challenge | singleElementInSortedArray.cpp | int uniqueElement(vector<int> arr, int n)
{
// Write your code here
int low = 0, high = arr.size()-1;
while(low < high) {
int mid = low + ((high - low) / 2);
if((mid % 2 == 0 && arr[mid] == arr[mid + 1]) || ((mid % 2 == 1 && arr[mid] == arr[mid - 1])))
low = mid + 1;
else
... | ALGO | 0.999767 | 5.085872 |
85cf3037-efae-4c7d-a484-822b8530bd07 | tmusale/Coding | Array/kth_smallest_element.cpp | /*
Kth smallest element
Given an array arr[] and a number K where K is smaller than size of array, the task is to find the Kth smallest element
in the given array. It is given that all array elements are distinct.
Expected Time Complexity: O(n)
Input:
The first line of input contains an integer T, denoting the numb... | ALGO | 0.999951 | 5.701302 |
3d242472-7916-4b6c-a862-7a1d4de6b09d | ishandutta2007/codeforces | tiramister/normal/1180/A.cpp | #include <iostream>
using namespace std;
int main() {
int N;
cin >> N;
int ans = 1;
for (int i = 1; i < N; ++i) {
ans += i * 4;
}
cout << ans << endl;
return 0;
} | ALGO | 0.999703 | 3.902803 |
86ecf75c-0d6e-44d2-bc67-df4679b32176 | tmusale/Coding | sp-bit-magic/bleak_number.cpp | /*
Bleak Numbers
Given an integer, check whether it is Bleak or not.
A number ‘n’ is called Bleak if it cannot be represented as sum of
a positive number x and set bit count in x, i.e., x + countSetBits(x)
is not equal to n for any non-negative number x.
Examples :
3 is not Bleak as it can be represented
as 2 + co... | ALGO | 0.999642 | 5.867938 |
ec2f8f36-02bf-44ef-b425-9476cb8ebd83 | joshuaneelyCS/Cpp | longest_line.cpp |
#include <iostream>
using namespace std;
#include <fstream>
using namespace std;
#include <sstream>
using std::istringstream;
#include <string>
using std::string;
// function that counts the word in a stream
int count_words(string line) {
stringstream ss(line);
int count = 0;
string token;
while (s... | TOOL | 0.969362 | 4.346709 |
4bcdc8d2-5ec5-4e72-87e6-e88a132b7397 | lammps/lammps | src/MOLECULE/angle_harmonic.cpp | #include "angle_harmonic.h"
#include "atom.h"
#include "comm.h"
#include "domain.h"
#include "error.h"
#include "force.h"
#include "math_const.h"
#include "memory.h"
#include "neighbor.h"
#include <cmath>
#include <cstring>
using namespace LAMMPS_NS;
using MathConst::DEG2RAD;
using MathConst::RAD2DEG;
static conste... | ALGO | 0.992298 | 6.146228 |
e5bc2ed3-4f0c-4965-bd8f-d02a6a1e0037 | divyanshusharma3031/leetcode | 380-insert-delete-getrandom-o1/380-insert-delete-getrandom-o1.cpp | class RandomizedSet {
public:
unordered_map<int,int> mpp;
vector<int> v;
unordered_map<int,int> key;
RandomizedSet() {
}
bool insert(int val) {
if(mpp.find(val)==mpp.end())
{
v.push_back(val);
mpp[val]=v.size()-1;
return true;
... | ALGO | 0.999012 | 6.050307 |
2c1e62ae-8eb9-42f2-ba88-79ed1ec8ab68 | QianQNanami/JSOI-WC25 | TG/judger/source/WC25-524/matrix.cpp | #include <bits/stdc++.h>
// #define int long long
// #define int __int128
#define lop(n,s,e) for (int n = s; n <= e; ++n)
#define ril(n,s,e) for (int n = s; n >= e; --n)
#define nem(n,c) while (!n.empty() && (c))
namespace IO {
template<class T>
T &read(T &x) {
char f = 1;
int c = getchar();
... | ALGO | 0.999994 | 3.034616 |
778b164d-2507-49b8-a33a-e06ea3c7cc20 | PatriChou/Final_prj | Catapult_HLS/hls_c/src/EdgeDetect_tb.cpp | #include <stdio.h>
#include <stdlib.h>
using namespace std;
#include "EdgeDetect_Algorithm.h"
#include "EdgeDetect.h"
#include "bmpUtil/bmp_io.hpp"
#include <fstream>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <mc_scverify.h>
CCS_MAIN(int argc, char *argv[])
{
/*
const int iW = 4;
const ... | TOOL | 0.86257 | 4.134311 |
fc5d8be3-530f-4b43-b669-e2c2c5e03e1a | 113bommy/deepmind_codecontests_refine | cpp_gold_filter_file/cpp_train_11111_0.cpp | #include <bits/stdc++.h>
using namespace std;
double a, b, l;
double w;
inline double f(double x) {
return (a * cos(x) + b * sin(x) - l * cos(x) * sin(x));
}
void solve() {
double r1 = 0, r2 = acos(0.0);
for (int i = 0; i < 1000; i++) {
double r11 = (2.0 / 3.0) * r1 + (1.0 / 3.0) * r2;
double r22 = (1.0 /... | ALGO | 0.999981 | 3.467468 |
45da8cb9-258c-4e23-9d63-882d0b31d3c1 | KazuakiTokunaga/competitive-programming | library/C++_stl/chmin.cpp | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false;}
template<cl... | ALGO | 0.997607 | 3.473882 |
536f66ae-cf81-4c47-9e53-5fe36391780e | ycui1984/booster | topcoder/SRM/subseq.cpp | #include <iostream>
#include <string>
using namespace std;
class IdentifyingWood {
public:
bool getCheckResult(string s, int sstart, string t, int tstart) {
if (tstart >= t.size() && sstart <= s.size()) return true;
bool res;
for (int i = sstart; i<s.size(); i++) {
if (s[i] == t[tstart]) {
res = getCheckR... | ALGO | 0.997114 | 4.362242 |
7dc24ded-afc0-4af8-972f-900c5d489a0e | Dhruv385/LeetType | Paths to reach origin - GFG/paths-to-reach-origin.cpp | //{ Driver Code Starts
//Initial Template for C++
#include<bits/stdc++.h>
using namespace std;
// } Driver Code Ends
//User function Template for C++
class Solution
{
public:
int mod=1000000007;
int solve(int x,int y,vector<vector<int>> &dp){
if(x==0 && y==0)
return 1;
else if(x<0 ... | ALGO | 0.999962 | 5.974113 |
96067944-7f57-4cac-9ce6-62f7559bdf43 | l3v11/Codeforces | 1093B. Letters Rearranging.cpp | #include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
using str = string;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define mp make_pair
#define f first
#define s second
usi... | ALGO | 0.999093 | 5.712237 |
f96680a8-fde3-4f4e-be3a-bf3b74a817a6 | lubna0501/Analysis_and_algo_design | ada10.cpp | //PROGRAM NO.-10
//Write a PROGRAM TO IMPLEMENT NAIVE STRING MATCHING
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdio.h>
void naive_string_matcher(char text[],char pat[])
{
char temp[100];
int n=strlen(text);
int m=strlen(pat);
int i,j,s,k;
for(s=0;s<=n;s++)
{
for(j... | ALGO | 0.991099 | 4.467473 |
c0d690d3-25bc-4fae-bc86-9cab7dfb02ed | n0xemn/OKT-Prog | juizV/juizV_brick_wall_patter.cpp | #include <bits/stdc++.h>
using namespace std;
int brick(int N){
if (N == 1 || N == 0)
{
return 1;
}
/*
else if (N == 2)
{
return 2;
}
else if (N == 3)
{
return 3;
}
*/
else
{
return brick(N - 1) + brick(N - 2);
}
}
int main(){
... | ALGO | 0.999959 | 5.119874 |
f6951956-e25b-4693-b916-9cba2207cbaf | ishandutta2007/codeforces | bench0310/normal/1328/E.cpp | #include <bits/stdc++.h>
using namespace std;
const int N=200005;
vector<int> v[N];
vector<int> depth(N,0);
vector<int> tin(N);
vector<int> tout(N);
vector<int> p(N);
int tcnt=1;
void dfs(int a)
{
depth[a]=depth[p[a]]+1;
tin[a]=tcnt++;
for(int to:v[a])
{
if(to==p[a]) continue;
p[to]=a... | ALGO | 0.999982 | 4.214739 |
ea914bbc-6330-4f55-8ef4-44e5fc7402ad | shubhamk730/OOPS-CPP | Polymorphism/polymorphism1.cpp | #include<bits/stdc++.h>
using namespace std;
class A{
public:
int a;
int b;
A(){
cout << "A created "<< endl;
}
void sayHello(){
cout << "Hello Shubham " << endl;
}
void sayHello(string name){
cout << "Hello " << name << endl;
}
// valid -> different s... | TOOL | 0.890863 | 4.579646 |
eaa2e8d8-5862-448b-ac3a-3101c9ce8aa7 | kamilszymczak1/my_solutions | poi/XXII/kolekcjoner_bajtemonow.cpp | #include "ckollib.h"
using namespace std;
int firstCard = 0, firstCardCount = 1;
int secondCard = 0, secondCardCount = 0;
int bitcnt[32];
void AddBits(int x) {
for(int i = 0; i < 32; i++) {
if(x & 1)
bitcnt[i]++;
x >>= 1;
}
}
int NextCard() {
int k = karta();
AddBits(k);... | ALGO | 0.999968 | 3.830401 |
0ea6ddb0-d3a6-44d6-9760-fc177fd1fe74 | Coach-Academy/Winter-2-2023 | Level 1/Class 1/Practice G1/Week 06/H-Is your horseshoe on the other hoof.cpp | #include <bits/stdc++.h>
using namespace std;
int main()
{
int a[4];
for (int i = 0; i < 4; ++i) {
cin >> a[i];
}
sort(a, a + 4);
int dis = unique(a, a + 4) - a;
cout << 4 - dis;
}
| ALGO | 0.999604 | 3.608012 |
e410a1bf-f4ce-439a-ad6d-4f13da336f39 | jryxxx/ChangeDetection-OmInference | src/ChangeDetection.cpp | #include <memory>
#include <chrono>
#include <iostream>
#include <vector>
#include <onnxruntime_cxx_api.h>
#include <opencv2/opencv.hpp>
#include "ChangeDetection.h"
#include "AclLiteUtils.h"
#include "AclLiteImageProc.h"
#include "AclLiteResource.h"
#include "AclLiteError.h"
#include "AclLiteModel.h"
cv::Mat imgRes... | DATA | 0.946268 | 5.915792 |
82d99ee1-fdf5-45c5-b613-0ac6223c3cc2 | nillmishra/A2Z-DSA | basic/hashing/frequency.cpp | #include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
void frequencyCount(vector<int>& arr, int N, int P) {
unordered_map<int, int> hash;
// Count frequencies of numbers in arr
for (int num : arr) {
hash[num]++;
}
// Update arr to store frequency coun... | ALGO | 0.999947 | 6.567991 |
b40421c4-c8d4-4693-8330-89a3c7247476 | anhoangphuc/CP | leetcode/add_two_number.cpp | #include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b, step) for (auto i = a; i < b; i += step)
#define repr(i, a, b, step) for (auto i = a; i > b; i -= step)
typedef pair<int, int> pii;
struct ListNode {
int val;
ListNode *next;
ListNode(): val(0), next(nullptr) {}
ListNode(int x): val(x... | ALGO | 0.999969 | 5.584521 |
c45f0771-62d4-4d1f-9c96-3938bbc8636c | zurikz/algoprog | lvl2/2b/dynamic_programming/Without 111.cpp | #include <iostream>
#include <vector>
using namespace std;
int solve(int n) {
vector<int> ans(n + 1);
ans[0] = 1;
ans[1] = 2;
ans[2] = 4;
for (size_t i = 3; i < ans.size(); i++) {
ans[i] = ans[i - 1] + ans[i - 2] + ans[i - 3];
}
return ans[n];
}
int main() {
int n;
cin >> ... | ALGO | 0.999994 | 5.101944 |
bdc6ff30-8789-4b51-9406-800051823dc3 | foxtroat09/cp | Hackerrank/mark&toys.cpp | #include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
ll solve(ll *p, ll n, ll k) {
sort(p,p+n);
ll i = 0;
while(k>0) k-=p[i++];
return i-1;
}
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ll n,k;
cin>>n>>k;
ll... | ALGO | 0.999847 | 4.430566 |
b1ee7096-9cbf-4e6d-9040-f267224d44d0 | cechallenge/2025 | llvm/libcxx/test/std/numerics/rand/rand.dist/rand.dist.norm/rand.dist.norm.f/eval.pass.cpp | // <random>
// template<class RealType = double>
// class fisher_f_distribution
// template<class _URNG> result_type operator()(_URNG& g);
#include <random>
#include <cassert>
#include <vector>
#include <algorithm>
#include <cmath>
#include "test_macros.h"
double fac(double x)
{
double r = 1;
for (; x > 1;... | TEST | 0.976256 | 4.507369 |
38df3f8f-3441-4cb6-8789-465337b5004a | zhouzhonghe/leetcode | 字符串/字符串中的所有变位词.cpp | #include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
//给定两个字符串 s 和 p,找到 s 中所有 p
//的 变位词 的子串,返回这些子串的起始索引。不考虑答案输出的顺序。
//变位词 指字母相同,但排列不同的字符串。
class Solution {
public:
vector<int> findA... | ALGO | 0.999795 | 5.614864 |
afa39cd2-2bc7-41b4-8017-546d11ed48b6 | Shrutikabansal/DataStructureandAlgoritms | 0033-search-in-rotated-sorted-array/0033-search-in-rotated-sorted-array.cpp | class Solution {
public:
int search(vector<int>& nums, int target) {
int n = nums.size();
int left = 0, right = n-1, mid = (left+right)/2;
int answer = -1;
while(left<=right){
mid = (left+right)/2;
cout<< left << " " << right << " " << mid << endl;
... | ALGO | 0.999968 | 6.08357 |
12e1e293-2037-467a-88b4-1249fd788d5e | harrypotter0/algorithms-in-python | CP/Tessellathon/p1.cpp | #include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
const int N = 5000;
vll graph[N+1];
int num[N+1];
bool four = false;
void dfs(int u,int c = 0)
{
num[u] = c;
for(int v : graph[u])
{
if(num[v] !... | ALGO | 0.99999 | 4.156123 |
80ceed15-6525-4d3c-a41c-cb9970e7bcab | HaZem-Osama911/Problem-Solving | Codeforces/B. Interesting drink/B. Interesting drink.cpp | // problem link
// https://codeforces.com/contest/706/problem/B
/*
*
*
# { I have no choice }
# { I only have a dream }
{ * Remimber Me * }
=============================
██╗░░██╗░█████╗░███████╗███████╗███╗░░░███╗
██║░░██║██╔══██╗╚════██║██╔════╝██... | ALGO | 0.999931 | 4.846534 |
7b5eb1b2-9b67-4433-92fd-4327ebbd570f | Vanilla-chan-nya/Contest_Code | CodeForces/1389/B.cpp | /**************************************************************
* Problem:
* Author: Vanilla_chan
* Date:
* E-Mail: <EMAIL>
**************************************************************/
#include<bits/stdc++.h>
#define IL inline
#define re register
#define LL long long
#define ll long long
#define ULL unsigned ... | ALGO | 0.99972 | 3.486477 |
dde67502-1dab-4c4e-98b3-1a62358fa7ec | vimalvk9/CompetitiveProgrammingCodes | CPP_projects/GRID01/main.cpp | #include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
int n,m;
while(t--){
scanf("%d %d",&n,&m);//we have a matrix with dimensions n X m
int ans;
if(n>m){
int temp=n;
n=m;
m=temp;
}
if(n==1 && m==1){... | ALGO | 0.999619 | 4.271057 |
ef2a9cc5-458f-481d-82a4-b7cfceb98e2f | matk86/spparks | examples/COUPLE/library/one2many.cpp | #include "mpi.h"
#include "one2many.h"
#include "memory.h"
#include <map>
/* ---------------------------------------------------------------------- */
One2Many::One2Many(MPI_Comm caller_comm)
{
comm = caller_comm;
MPI_Comm_rank(comm,&me);
MPI_Comm_size(comm,&nprocs);
memory = new Memory(comm);
hash = ne... | ALGO | 0.982425 | 4.548226 |
cc964dec-56f4-4b35-904e-c852db14914e | vedantpatil25/Geeks-for-Geeks-Problems-Solutions | Medium/Find anagrams in linked list/find-anagrams-in-linked-list.cpp | //{ Driver Code Starts
#include <bits/stdc++.h>
using namespace std;
struct Node {
char data;
struct Node *next;
Node(char x) {
data = x;
next = NULL;
}
};
void printList(Node *node) {
while (node != NULL) {
cout << node->data << " ";
node = node->next;
}
c... | ALGO | 0.999594 | 5.333318 |
92d06ab4-af9a-4bca-aa18-f20c11ad93ae | man0045/Data_Structure_with_Cpp | Bitsmanipulation/check.cpp | // #Another code for decimal to binary conversion with finding out
// how many set bits are present in a particular sets;
#include<iostream>
using namespace std;
void decimal_to_binary(int n){
int i =0;
int binarynum[32];
while(n>0){
binarynum[i] = n%2;
n = n/2;
i++;
}
for(int j = i-1; j>=0; j--){
cou... | ALGO | 0.998315 | 5.733712 |
71145f65-23c1-4200-9918-92d75fac10d4 | prprprpony/oj | poj/3580.cpp | #include <cstdio>
#include <algorithm>
#include <stack>
#include <ctime>
#include <cstdlib>
#include <queue>
#define MAXN 800000
#define INF 2147483647
using namespace std;
struct treap
{
int v;
int sz;
int p;
int mn;
int rev;
int add;
treap *l, *r;
treap() {}
treap(int k) : v(k), sz... | ALGO | 0.999899 | 4.484985 |
391fcff0-d33e-4562-b481-b9f6f4f50a9e | mertturkmenoglu/cpp | src/stl/algorithm/NonModifying/E010_FindFirstOf/main.cpp | /**
* find_first_of() example
* "g++ main.cpp -std=c++17 -Wall -Wextra -Wnon-virtual-dtor -pedantic -g -o main"
* valgrind --leak-check=yes -v ./main
*/
#include <iostream>
#include <algorithm>
#include <vector>
int main () {
std::string quote = "To be or not to be.";
std::string charSet = { 'a', 'A', 'e'... | ALGO | 0.98013 | 5.761124 |
406804d9-87d3-4280-aca7-251c09803a78 | flakelolz/dsa | cpp/algorithms/Factorial.cpp | #include <iostream>
int factorial(int n) {
if (n == 1) return 1;
return n * factorial(n - 1);
}
int main(int argc, char* argv[]) {
int n = 4;
std::cout << factorial(n) << std::endl;
return 0;
}
// clang++ -std=c++20 Factorial.cpp -o Factorial ; ./Factorial
| ALGO | 0.999184 | 6.181992 |
a59de103-3359-46c1-9dee-4a4c54d12a9f | aissat/frust | 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.998809 | 6.763549 |
83fe7fc9-156b-4791-a100-0a85499ea163 | upesacm/21DaysOfCode-2024 | DSA/Aarohi-Sharma/Day13_q2.cpp | #include<iostream>
using namespace std;
int check(int n, int rev){
if (n==0){
return rev;
}
rev=(rev*10)+(n%10);
check(n/10, rev);
}
bool pall(int n){
int rev= check(n, 0);
return rev==n;
}
int main(){
int n;
cin>>n;
if (pall(n)){
cout<<"yes";
}
else{
... | ALGO | 0.999951 | 4.603315 |
ef0c1647-75fb-4ad9-80b2-ee653e811af7 | ShahidYasin03/DSA | Leetcode/1957.cpp |
#include <iostream>
using namespace std;
class Solution
{
public:
string makeFancyString(string s)
{
if (s.length() < 3)
return s;
string st = "";
int count = 1;
char c = s[0];
st += c;
for (int i = 1; i < s.length(); i++)
{
if (... | ALGO | 0.999966 | 6.445872 |
119ad2bb-406a-448a-9c24-3c907a490285 | kavya006/Projects | LMC_P1/check_string/exprtonfa.cpp | #include "iostream"
#include "string"
#include "vector"
#include "algorithm"
using namespace std;
/*
This file contains the class for creating a NFA from a regular expression
and struct construct for an edge in the NFA
*/
struct edge
{
int v1;
int v2;
char weight = '0';
};
/*
This class contains the methods for... | ALGO | 0.998638 | 3.879258 |
b40f7924-b0f9-4e27-80b5-ee23cc038358 | IS220165-SuvigyaShrivastava/Algolution- | Set1.cpp |
// 1. Program to count total number of negative numbers in an array.
#include <iostream>
using namespace std;
int main() {
int n;
cout << "Enter the size of the array: ";
cin >> n;
int arr[n];
cout << "Enter the elements of the array:" << endl;
for (int i = 0; i < n; i++) {
c... | ALGO | 0.999411 | 4.571597 |
dd3f98c5-0894-4a19-a29e-992ac1e4e837 | rcg4u/gitlab-wxqt | src/util/UtilityMath.cpp | #include "util/UtilityMath.h"
#include <cmath>
#include <numbers>
#include "util/To.h"
double UtilityMath::distanceOfLine(double x1, double y1, double x2, double y2) {
return sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
}
vector<double> UtilityMath::computeTipPoint(double x0, double y0, double x1, double y1, bool rig... | ALGO | 0.989808 | 6.626894 |
5cd73dc0-7e0e-448f-ab53-8d5802fd767b | benami171/System_Programming2_Exe1 | Demo.cpp | // NAME: GAL BEN AMI
#include "Graph.hpp"
#include "Algorithms.hpp"
#include <iostream>
#include <stdexcept>
#include <vector>
#include <climits>
using ariel::Algorithms;
using namespace std;
int main()
{
ariel::Graph g1;
vector<vector<int>> graph1 = {
{0, 1, 0},
{1, 0, 0},
{0, 0, 0}}... | ALGO | 0.993866 | 5.352519 |
b414a79f-af2f-4c28-b2ce-1db1f9e18737 | ShubhamGoswami-1/My_Journey | Sorting_Counting_Sort_0_to_K_GFG.cpp | /*
Range of k is from 0 to k-1
*/
#include<bits/stdc++.h>
using namespace std;
vector<int> Solve(vector<int> v,int k){
vector<int>count1(k),res(v.size());
for(int i=0;i<v.size();i++){
count1[v[i]]++;
}
for(int i=1;i<count1.size();i++){
count1[i]=count1[i-1]+count1[i];
}
for(int ... | ALGO | 0.999998 | 3.810239 |
9971d933-506a-4bd9-be83-005438cd3298 | pbilwanikar/DSA-basic-to-advanced | SwitchCase and Functions/Calculator.cpp | #include<bits/stdc++.h>
using namespace std;
int main(){
int a, b;
cout<<"Enter the value of a: "<<endl;
cin >> a;
cout<<"Enter the value of b: "<<endl;
cin >> b;
char op;
cout <<"Enter the operation, you want to perform: "<<endl;
cin >> op;
switch(op){
case '+': cout ... | ALGO | 0.954901 | 3.232613 |
7cb2a66e-d6b5-4024-b335-b0519e1952e7 | SaranshBangar/GeeksforGeeks-Solutions | Difficulty: Hard/Fixing Two nodes of a BST/fixing-two-nodes-of-a-bst.cpp | //{ Driver Code Starts
//
#include <bits/stdc++.h>
using namespace std;
class Node {
public:
int data;
Node *left, *right;
Node(int val) {
data = val;
left = right = NULL;
}
};
Node* buildTree(string str) {
// Corner Case
if (str.length() == 0 || str[0] == 'N')
retu... | ALGO | 0.999454 | 5.797327 |
269cef14-3def-4fc0-af3a-01a9279ddc54 | MOHIT-IITP/Leetcode | 322_another.cpp | #define ll long long
class Solution {
public:
ll recur(int amount, vector<int>& coins, vector<int> & dp ){
if(amount == 0) return 0;
ll res = INT_MAX;
if(dp[amount] != -1) return dp[amount];
for(auto it : coins){
if(amount - it >= 0){
... | ALGO | 0.999984 | 5.658887 |
957fd6a4-d577-4fe4-a566-c1e9b86cdc6e | facebookarchive/BOLT | clang/test/SemaCXX/constexpr-turing-cxx2a.cpp | // RUN: %clang_cc1 -verify -std=c++2a %s
// expected-no-diagnostics
const unsigned halt = (unsigned)-1;
enum Dir { L, R };
struct Action {
bool tape;
Dir dir;
unsigned next;
};
using State = Action[2];
// An infinite tape!
struct Tape {
constexpr Tape() = default;
constexpr ~Tape() {
if (l) { l->r = nu... | TEST | 0.956574 | 7.801661 |
674013d4-67d3-4b2e-b9dd-59273f385d03 | abdul-rozzaq/tastic | windows/runner/utils.cpp | #include "utils.h"
#include <flutter_windows.h>
#include <io.h>
#include <stdio.h>
#include <windows.h>
#include <iostream>
void CreateAndAttachConsole() {
if (::AllocConsole()) {
FILE *unused;
if (freopen_s(&unused, "CONOUT$", "w", stdout)) {
_dup2(_fileno(stdout), 1);
}
if (freopen_s(&unuse... | TOOL | 0.9988 | 6.76073 |
3fe9382a-39b5-4b4d-b9ee-65d2be4de0ab | karimali03/Competitive-programming | templetes/Graph/SP/flyod.cpp | /*
Time Complexity: O(n^3)
- You need **all-pairs shortest paths**
- Graph is dense (many edges: m ≈ n^2)
- Graph size is small (n ≤ 500)
- Graph has negative weights (but no negative cycles)
- You want to **detect negative cycles** (check dist[i][i] < 0)
-> DON'T use Floyd-Warshall when:
- Graph is **spars... | ALGO | 0.999984 | 4.967921 |
100f4f7a-8f92-48b1-97aa-451199056784 | ishandutta2007/codeforces | littlebeetle/normal/1228/C.cpp | #include<cstdio>
typedef long long ll;
const int M=1000000007;
ll x,i,n,ans=1;
ll ksm(ll x,ll p){
ll s=1;
while(p){
if(p%2)
s=s*x%M;
p/=2;
x=x*x%M;
}
return s;
}
ll d(ll p){
ll m=n,sum=0;
while(m)
sum+=m/=p;
return ksm(p,sum);
}
int main(){
scanf("%lld%lld",&x,&n);
for(i=2;i*i<=x;i++)
if(x%i==0){
... | ALGO | 0.999971 | 4.662869 |
ead7691d-6ee0-4ccc-86cb-f601af0ccca4 | reo0105/atcoder | contest/2024_03_23_beginner/F.cpp | // #include <bits/stdc++.h>
// using namespace std;
// typedef long long ll;
// int main() {
// ll n;
// string s, t;
// cin >> n >> s >> t;
// vector<vector<int>> cnt(26);
// for (int i = 0; i < (int)s.size(); i++) {
// cnt[s[i]-'a'].push_back(i);
// }
// ll ac = 0, wa = 1e18;
... | ALGO | 0.99999 | 5.258129 |
fd135522-f50f-42a1-92f7-b15ece27ca01 | mariaaktermukti/CodeForces | Hamburgers.cpp | #include <iostream>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
string recipe;
cin >> recipe;
ll nb, ns, nc;
cin >> nb >> ns >> nc;
ll pb, ps, pc;
cin >> pb >> ps >> pc;
ll r;
cin >> r;
ll reqB = 0, reqS = 0, reqC = 0;
for (c... | ALGO | 0.999445 | 4.164586 |
f89702b9-a7df-47f7-a266-df6759a0c9af | ishandutta2007/codeforces | krk/normal/65/E.cpp | #include <bits/stdc++.h>
using namespace std;
typedef pair <int, int> ii;
const int Maxn = 200005;
int n, m;
int A[Maxn], B[Maxn];
int par[Maxn], siz[Maxn];
vector <ii> neigh[Maxn];
bool tk[Maxn];
vector <int> rem;
deque <ii> seq;
int lst = 1;
vector <int> cur = {1};
vector <vector <int> > res;
int getPar(int x) { ... | ALGO | 0.999992 | 4.122238 |
095c34a7-b6f4-4d58-a7b8-44a6480ad05c | drawal001/D5RC_VS | CameraBot.cpp | /**
* @file CameraBot.cpp
* @author drawal (<EMAIL>)
* @brief
* @version 0.1
* @date 2024-11-28
*
* @copyright Copyright (c) 2024
*
*/
#include "CameraBot.h"
namespace D5R {
/**
* @brief 캯
*
* @param id MACַ
*/
CameraBot::CameraBot(std::string id) : GxCamera(id) {
// ģ
... | TOOL | 0.901653 | 3.462276 |
74679e63-bf27-4dd2-97c0-296e829ccdb2 | forfel-norfel/rocket-build | source/llvm-15.0.6/mlir/lib/Dialect/Vector/Transforms/VectorDistribute.cpp | #include "mlir/Dialect/Affine/IR/AffineOps.h"
#include "mlir/Dialect/Arithmetic/IR/Arithmetic.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/Dialect/Vector/Transforms/VectorDistribution.h"
#include "mlir/Dialect/Vector/Utils/VectorUtils.h"
#include "mlir/IR/BlockAndVal... | TOOL | 0.953099 | 7.208427 |
82c9683d-5cc2-4e28-9c8a-34c05c2af07b | AbhJ/some-cp-files-1 | codeforces1324E.cpp | #include <bits/stdc++.h>
#include <numeric>
#define ll long long int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb push_back
using namespace std;//coded by abhijay mitra
const int N=2e5+3;
// const int N=300;
const ll M = 998244353; // modulo
#define MAX ... | ALGO | 0.999846 | 3.659484 |
a46e60d7-58e5-41b5-aaf6-a97e136924d6 | shrey12mehrotra/Data-Structures-And-Algorithms | MATRIX/Boundary_Traversal_Of_Matrix.cpp | /*
You are given a matrix of dimensions n x m. The task is to perform boundary traversal on the matrix in a clockwise manner.
Input:
n = 4, m = 4
matrix[][] = {{1, 2, 3, 4},
{5, 6, 7, 8},
{9, 10, 11, 12},
{13, 14, 15,16}}
Output: 1 2 3 4 8 12 16 15 14 13 9 5
Time Complexity = O(n+m)
... | ALGO | 0.999993 | 4.999525 |
5752ca02-4e75-407d-ae2a-92926d3d8662 | 4141amitkumar/Leetcode-DSA-Problems | 58-length-of-last-word/length-of-last-word.cpp | class Solution {
public:
int lengthOfLastWord(string s) {
int n = s.size()-1;
while(n>=0 && s[n]==' '){
n--;
}
int count=0;
while(n>=0 && s[n]!=' '){
count++;
n--;
}
return count;
}
}; | ALGO | 0.999489 | 5.586839 |
9e9c02be-aa40-48d3-9894-7817de881fbc | mohit701473/cpp | Lecture 85-101 Graphs/L 88-89 Cycle Detection in Graph/Que3_detectCycleInDirectedGraph_Dfs.cpp |
// Approch 1
// Expected Time Complexity: O(V + E)
// Expected Auxiliary Space: O(V)
#include<list>
#include<unordered_map>
bool checkCycleDfs(int node, unordered_map<int, bool> &visited, unordered_map<int, bool> &dfsVisited, unordered_map<int, list<int>> &adj){
visited[node] = true ;
dfsVisited[node] = true ;
... | ALGO | 0.999913 | 6.495392 |
20ddd5e2-d3a0-4a8e-a4ee-c9cd09d393c7 | Bungmint/competitiveprogramming | contest/codeforces/segtree part2/SEG_PART2_3C.cpp | #pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using pi = pair<int, int>;
using vpi = vector<pair<int, int>>;
using pl = pair<ll, ll>;
using vl = vector<ll>;
using vpl = vector<pl>;
using ld = long double;
#define all(v... | ALGO | 0.999909 | 5.282635 |
083f63f2-bcc8-413f-87b9-693834b64d4d | phillipteng/CodingPractice17 | Solved/10170/main.cpp | #include <iostream>
using namespace std;
int main(){
long long S, D;
// where S is the initial size of the group
// D is the group size staying in the hotel at Dth day starting from 1
while(cin>> S >> D){
while (D > 0){
D = D-S;
++S;
}
cout << --S << en... | ALGO | 0.999604 | 3.182041 |
d5c04663-7081-4cb3-9156-f8f4b860d508 | Next-Gen-UI/Code-Dynamics | Leetcode/0030. Substring with Concatenation of All Words/0030.cpp | class Solution {
public:
vector<int> findSubstring(string s, vector<string>& words) {
if (s.empty() || words.empty())
return {};
const int k = words.size();
const int n = words[0].length();
vector<int> ans;
unordered_map<string, int> count;
for (const string& word : words)
++cou... | ALGO | 0.999817 | 6.606162 |
88326133-90b4-403b-8703-8e91d9c5b153 | ManthanSharma298/DSA-Problems-Arsh-Goyal | Trie/implement-trie-prefix-tree.cpp |
// insert("life")
// (l, false) -> (i, false) -> (f, false) -> (e, false) -> (empty, true)
class TrieNode {
public:
TrieNode* node[26];
bool isWord;
TrieNode(){
for(int i=0; i<26; ++i){
node[i] = NULL;
}
isWord = false;
}
};
class Trie {
TrieNode* root;
p... | ALGO | 0.999644 | 4.738895 |
211b803a-90da-4e9a-92ab-326368c66656 | ShashiShekharDixit/Interview-150 | TwoSum.cpp | class Solution {
public:
vector<int> twoSum(vector<int>& nums, int target) {
int n = nums.size();
for(int i = 0; i < n - 1; i++) {
for(int j = i + 1; j < n; j++){
if(nums[i] + nums[j] == target) {
return {i, j};
}
}
}
return {};
... | ALGO | 0.99991 | 6.249857 |
2955c839-f12c-404f-a4b8-d14db4de6bc3 | satyam184/Pattern_problems_Cpp | pattern_7.cpp | #include<iostream>
using namespace std;
int main(){
int n=5;
for(int i=0;i<=n;i++){
for (int j = 0; j <=i; j++)
{
cout<<" ";
}
for (int j = i; j <= n; j++)
{
cout<<"* ";
}
cout<<endl;
}
return 0;
} | ALGO | 0.999781 | 3.493469 |
a39179e4-29d8-4d85-90f7-f1455aa77b2c | raincross7/code-similarity | codes/train_code/problem073/problem073_126.cpp |
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
#include <deque>
#include <set>
#include <climits>
#include <memory>
#include <numeric>
#include <utility>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a... | ALGO | 0.999714 | 3.39345 |
6d26ace5-8bd3-445b-a276-f9fe028ec296 | Sri-dhar/test | codes_DSA/CodeHelp-DSA-Busted-Series-main/Lecture032 Recursion Day2/SayDigits.cpp | #include<iostream>
using namespace std;
void sayDigit(int n, string arr[]) {
//base case
if(n == 0)
return ;
//processing
int digit = n % 10;
n = n / 10;
//recursive call
sayDigit(n, arr);
cout << arr[digit] << " ";
}
int main() {
string arr[10] = {"zero", "one", "t... | ALGO | 0.999511 | 5.469999 |
2fc31ad1-f992-4090-b6ea-90623dc34e12 | ishmeetkohli/SketchBasedImplicitBlending | lib/libigl/include/igl/copyleft/cgal/subdivide_segments.cpp | template <
typename DerivedV,
typename DerivedE,
typename Kernel,
typename DerivedVI,
typename DerivedEI,
typename DerivedJ,
typename DerivedIM>
IGL_INLINE void igl::copyleft::cgal::subdivide_segments(
const Eigen::PlainObjectBase<DerivedV> & V,
const Eigen::PlainObjectBase<DerivedE> & E,
const s... | ALGO | 0.99882 | 4.176644 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.