uuid string | repo_name string | relative_path string | content string | category string | algo_rel_score float64 | quality_score float64 |
|---|---|---|---|---|---|---|
90e56dde-f0f7-43a4-a944-a85d053f8b9e | SpadeZKyu/schedule-brute | test.cpp | #include "schedule.h"
#include <bits/stdc++.h>
int main()
{
std::ifstream ifs("sample.txt");
std::string str;
std::getline(ifs, str, char(EOF));
unsigned cnt = 0;
Schedule schedule(str);
auto gen = schedule.solve();
while (gen.next())
{
std::cout << cnt++ << std::endl;
... | ALGO | 0.999222 | 3.89233 |
4b871200-610c-426f-868e-e91f6cac2ac5 | UmeshKumari-202128/ADA_Python_Assignments | pythonAssignment/knapsack.cpp | #include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define ff first
#define ss second
bool compare(pii a,pii b){
double d1 = (double)a.ff/a.ss;
double d2 = (double)b.... | ALGO | 0.999992 | 4.028853 |
880e3cd9-7ea8-48dc-9a26-42ca39676ce9 | DyogoBendo/cp | cf/981-div3/c.cpp | #include <bits/stdc++.h>
using namespace std;
void solve(){
int n;
cin >> n;
vector<int> v(n);
for (int i = 0; i < n; i++)
{
cin >> v[i];
}
for (int i = n/2 - 2; i >= 0; i--)
{
//cout << "i: " << i << " p: " << n - i - 1 << endl;
if(v[i] == v[i + 1] || v[n... | ALGO | 0.999954 | 4.451364 |
4a352c78-89ce-4397-9fd0-8696ac915f86 | pawan-nirpal-031/Algorithms-And-ProblemSolving | Active/CodeForces/Edu/BinarySearch/C_Closest_to_the_Right.cpp | // Problem Link :
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
#define Mod 1000000007
#define Infinity (ll)1e18
#define Append(a) push_back(a)
#define Pair(a,b) make_pair(a,b)
#define Clear(a) for(ll &x : a){x=0;}
#define Point(x) s... | ALGO | 0.999976 | 4.290849 |
ff216dcc-e0bb-46ca-adf3-4b3bb7efce96 | hjiang13/LLMs-in-IR | POJ-104/65/813.cpp | #include <iostream>
using namespace std;
int main()
{
int n,x,y;
int a[201];
int b[201];
a[201]=0;
b[201]=0;
x=0;
y=0;
cin >> "%d",&n);
for(int i=0; i<n; i++)
{
cin >> "%d%d",&a[i],&b[i]);
if(a[i]+1==b[i]||a[i]-2==b[i])
x++;
else if(a[i]!=b[i])
y++; }
if(x>y)
cout << "A");
else if(x<y)
cout << "B");
else cout << "Tie")... | ALGO | 0.99995 | 3.421144 |
ced98ef3-4b52-48f1-8d5f-718d2b318ccd | Yunuskngl/Leetcode_Hackerrank_Solutions | LEETCODE/Product_of_arr_except_self.cpp | //SOLUTION:
//https://leetcode.com/problems/product-of-array-except-self/
/*
class Solution {
public:
vector<int> productExceptSelf(vector<int>& nums) {
int n = nums.size();
vector<int> left(n), right(n);
left[0] = 1;
right[n - 1] = 1;
for (int i = 1; i < n; i++) {
... | ALGO | 0.999968 | 6.168959 |
481e5542-2556-4f12-80c3-1009b58cbe51 | Hassan-Ali-0316/DSA | Binary Search Tree.cpp | #include<bits/stdc++.h>
#define gb 10
using namespace std;
class Node
{
public:
int data;
Node* left;
Node* right;
Node()
{
data = 0;
left = NULL;
right = NULL;
}
Node(int d)
{
data = d;
left = NULL;
right = NULL;
}
};
class BST
{
public:
Node* root;
BST()
{
root = NULL;... | ALGO | 0.997927 | 3.336133 |
66e04e87-b510-46d2-8791-7316608c415b | ishandutta2007/codeforces | vercingetorix/normal/983/B.cpp | #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <deque>
#include <cstring>
#include <set>
#include <bitset>
#include <map>
#include <chrono>
#include <random>
#include <unordered_map>
#include <stdio.h>
using namespace std;
typedef long long ll;
typedef long do... | ALGO | 0.999977 | 4.499443 |
781bab23-bb83-40ab-99cb-ceb7d06c15c4 | ChoMinkyung/cplusbasic | cplusbasic/20230623_Q1.cpp | #include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <memory>
#include <vector>
#include <algorithm>
#include <iterator>
#include <list>
#include <set>
#include <map>
#include <ctime>
using namespace std;
vector<int> Lotto(int range, int n);
void Show(int v);
int main()
{
vector<int> wi... | ALGO | 0.990131 | 3.898613 |
177c22ec-0a4e-4f79-883c-8816f0ff3274 | ratelp/LawnMower | LawnMower/LawnMower/Player.cpp | #include "LawnMower.h"
#include "Player.h"
#include "Level1.h"
#include <algorithm> // Necessrio para std::min e std::max
#include <cmath>
#include <sstream>
#include "LawnMower.h"
// ---------------------------------------------------------------------------------
Player::Player()
{
spriteL = new Sprite("Resource... | TOOL | 0.883028 | 3.946916 |
3926db48-ac01-4855-80af-84444d527cfc | Infomaniak/desktop-kDrive | src/libsyncengine/db/syncdbreadonlycache.cpp | #include "syncdb.h"
#include "syncdbreadonlycache.h"
namespace KDC {
bool SyncDbReadOnlyCache::isCacheUpToDate() const {
if (_cachedRevision != _syncDb.revision()) {
LOG_INFO(Log::instance()->getLogger(), "SyncDbReadOnlyCache: cache is not up to date, cached revision="
... | TOOL | 0.865616 | 7.556606 |
c3c24f1c-f1e9-4823-8430-687cda57ee14 | tronganh0104/Leetcode | NumberOfWaysToSplitArray.cpp | #include <bits/stdc++.h>
using namespace std;
int waysToSplitArray(vector<int>& nums) {
if (nums.size() <= 1) {
return 0;
}
long long left = 0;
int n = nums.size();
long long right = 0;
for (int i = 0; i < n; i++) {
right += nums[i];
}
int count = 0;
for (int... | ALGO | 0.999412 | 5.016206 |
b97afc60-c425-4705-93b3-e4d5d336ac2a | raincross7/code-similarity | codes/train_code/problem058/problem058_286.cpp | #include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class... | ALGO | 0.999775 | 4.055076 |
f2d1a4a9-fd89-42e8-9a72-930952a0cfbc | luv2001/ds-algo | Dynamic Programming/Practise/nCrgfg.cpp | #include <bits/stdc++.h>
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);... | ALGO | 0.999934 | 4.246246 |
0b8c4b8e-4da9-43ca-b6ca-d1fe9b990fd2 | janyanb/LeetCode | 19151-772-152-maximum-product-subarray/19151-772-152-maximum-product-subarray.cpp | class Solution {
public:
int maxProduct(vector<int>& nums) {
int currMax = nums[0];
int maxProd = nums[0];
int currMin = nums[0]; //in case we encounter negative values
for(int i =1; i< nums.size(); i++){
if(nums[i] < 0){
swap(currMax, currMin); // cur... | ALGO | 0.999994 | 5.972278 |
d15d0e64-deb9-4d36-85f5-c12cc0bb265f | MartinaAshraf/cpp_my_notes | Structured programming/50 Problems/43.cpp | /*A sphere of mass m1 impinges obliquely on a stationary sphere of mass m2, the direction of
the blow making an angle α with the line of motion of the impinging sphere. If the coefficient
of restitution is e it can be shown that the impinging sphere is deflected through an angle β
such that
tan 𝛽 =(𝑚2(1 + 𝑒) tan a)/... | ALGO | 0.999466 | 4.040524 |
e337b527-cbb7-498d-8296-055b111ec961 | JaswanthKarangula/Leetcode | 2373-largest-local-values-in-a-matrix/2373-largest-local-values-in-a-matrix.cpp | class Solution {
public:
vector<vector<int>> largestLocal(vector<vector<int>>& grid) {
int m = grid.size(), n = grid[0].size();
vector<vector<int>> ans(m-2, vector<int>(n-2));
for (int i = 1; i < m-1; ++i)
for (int j = 1; j < n-1; ++j) {
int cand = 0;
for (int ii = i-1; ii <= i+1; ++ii)
... | ALGO | 0.99996 | 5.944557 |
9561f0dd-1675-425f-8690-552f960c1605 | ritesh5556/DSA_Workout | Stack/Stack1/insertAtBottom.cpp | #include<iostream>
#include<stack>
using namespace std;
void insertAtBottom(stack<int>&st, int val){
//base case
if(st.empty()){
st.push(val);
return;
}
int temp = st.top();
st.pop();
insertAtBottom(st, val);
st.push(temp);
}
//Reverse stack
// void reverseStack(stack<int... | ALGO | 0.999577 | 4.307553 |
3aae10fa-0dd7-4e71-88e3-f840880da66b | riz1-ali/Codeforces_Solutions | 1113A.cpp | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod=1000000007;
typedef long double ld;
typedef pair<ll,ll> pll;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define gcd(a,b) __gcd(a,b)
#define lp(n) for(ll i=0;i<n;i++)
int main()
{
ios_base::sync_with_std... | ALGO | 0.999872 | 3.864321 |
767f63bd-e29c-4ac6-b083-b9962b3bb701 | amanjha491/Leetcode_Solution | 2000-2099/2034.Stock Price Fluctuation/Solution.cpp | class StockPrice {
public:
int lastTs;
unordered_map<int, int> mp;
map<int, int> counter;
StockPrice() {
}
void update(int timestamp, int price) {
if (mp.count(timestamp)) {
int oldPrice = mp[timestamp];
--counter[oldPrice];
if (counter[oldPrice] == ... | ALGO | 0.997707 | 6.704871 |
bb57a1ae-9b42-483e-8e0b-f1fd7ca63d2f | inshayaqoob/AI-Code-Summarize | transcoder/transcoder/data/evaluation/geeks_for_geeks_successful_test_scripts/cpp/PRIMALITY_TEST_SET_1_INTRODUCTION_AND_SCHOOL_METHOD.cpp | #include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <fstream>
#include <iomanip>
#include <bits/stdc++.h>
using namespace std;
bool f_gold ( int n ) {
if ( n <= 1 ) return false;
for ( int i = 2;
i < n;
i ++ ) if ( n % i == 0 ) return false;
return true;
}
//TOFILL
int main()... | TEST | 0.986249 | 5.255602 |
c3453939-99f5-4163-994f-458320eddeca | 2261819266/Code | OI/others/NTSG/fuxi/AP75000.walk.cpp | #include <cstdio>
int a[10][10], n, m, t; // 0不能走 -1可以走 1走过了 2起点 3终点
void dfs(int x, int y, int k = 0) {
int c, d, e;
if (!a[x][y] || (a[x][y] == 2 && k == 0)||a[x][y]==1)
return;
if (a[x][y] == 3) {
t++;
return;
}
a[x][y] = 1;
dfs(x + 1, y);
dfs(x - 1, y);
... | ALGO | 0.999667 | 3.5028 |
2c3c62e0-b989-4286-a852-5a83c4c19235 | minhphu102003/cph | reivsion/bai14.cpp | #include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
freopen("B008.inp","r",stdin);
freopen("B008.out","w",stdout);
string s;
cin>>s;
ll x = 0;
ll y = 0;;
int n = s.length();
for (int i = 0; i ... | ALGO | 0.999926 | 3.795122 |
cfaa2d88-223a-4b9e-ac1b-2e5f7218cf5e | Omair95/A_prototype_MPEG-G_encoder | boost_1_66_0/libs/graph/test/dfs_cc.cpp | #include <boost/concept_archetype.hpp>
#include <boost/graph/depth_first_search.hpp>
#include <boost/graph/graph_archetypes.hpp>
int main()
{
using namespace boost;
typedef default_constructible_archetype<
sgi_assignable_archetype<
equality_comparable_archetype<> > > vertex_t;
{
typedef incidence_gr... | ALGO | 0.918435 | 5.270398 |
57d7d8f6-8124-41b2-97f3-23e8e369456d | mooksys/algorithm | baekjoon/2806.cpp | #include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int N, a[1000005],b[1000005];
string s;
int main(){
scanf("%d", &N); getchar();
getline(cin, s);
//입력정리
if (s[0] == 'A') {
a[0] = 0;
b[0] = 1;
}
else {
a[0] = 1;
b[0] = 0;
}
for (int i = 1; i < N; i++) {
if (s[i] == ... | ALGO | 0.999765 | 3.511512 |
3b23b210-793c-47d7-b12f-f9621d297f8a | rafsan99/Problem-Solving | Supercentral Point.cpp | #include <iostream>
using namespace std;
int main()
{
int n,i=0,j=0,right,left,up,low,sum=0;
cin>>n;
int x[n],y[n];
for(i=0;i<n;i++){
cin>>x[i]>>y[i];
}
for(i=0;i<n;i++){
right=0;
left=0;
up=0;
low=0;
for(j=0;j<n;j++){
if(x[j]>x[... | ALGO | 0.999879 | 3.826175 |
2938b06d-58ab-4ad9-aab6-5b77f5d46839 | Shamsyyy/AlgoritmsITMO | 1 лаба/algos1.4.cpp | #include <iostream>
#include <fstream>
using namespace std;
int main() {
int ramzer;
ifstream file ("smallsort.in");
file >> ramzer;
long long mas[ramzer];
for (int i=0;i<ramzer;i++){
file >> mas[i];
}
int q;
for (int i=0;i<ramzer;i++){
for(int j=i;j<ramzer;j++){
... | ALGO | 0.999957 | 3.444077 |
3cfb0f88-16d1-493f-80de-102c219b9d9e | opsocket/json-schema-validator | src/string-format-check.cpp | #include <nlohmann/json-schema.hpp>
#include <algorithm>
#include <exception>
#include <iostream>
#include <regex>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
/**
* Many of the RegExes are from @see http://jmrware.com/articles/2009/uri_regexp/URI_regex.html
*/
namespace
{
template <ty... | TOOL | 0.944186 | 7.673835 |
3b0a92a6-a4c1-4395-81d4-2cb361a30492 | Hevedy/HevEn | Source/ThirdParty/NewtonDynamics/include/source/core/dgIntersections.cpp | #define USE_FLOAT_VERSION
#define DG_RAY_TOL_ERROR (dgFloat32 (-1.0e-3f))
#define DG_RAY_TOL_ADAPTIVE_ERROR (dgFloat32 (1.0e-1f))
/*
dgFloat32 dgFastRayTest::PolygonIntersectFallback (const dgVector& normal, dgFloat32 maxT, const dgFloat32* const polygon, dgInt32 strideInBytes, const dgInt32* const indexArray, dgInt3... | ALGO | 0.998757 | 5.847336 |
4e10bd88-1eca-40f3-9bb2-4c0da4884bb0 | BeamMyUp/ProjectEuler | 3.cpp | #include <algorithm>
#include <vector>
#include <iostream>
#include <inttypes.h>
using std::sqrt;
using std::vector;
uint64_t sieveEratosthene(const uint64_t maxNumber)
{
// Would be cleaner using a class than static
static uint64_t sqrtNumber = ceil(sqrt(maxNumber));
static std::vector<bool> numbers(sqrtNumber ... | ALGO | 0.999756 | 5.256126 |
a9f54f01-3a10-4aca-95ed-3633fca29070 | Atharva-Yawalkar/Solutions | Top View of Binary Tree - GFG/top-view-of-binary-tree.cpp | //{ Driver Code Starts
//Initial Template for C++
#include <bits/stdc++.h>
using namespace std;
// Tree Node
struct Node
{
int data;
Node* left;
Node* right;
};
// Utility function to create a new Tree Node
Node* newNode(int val)
{
Node* temp = new Node;
temp->data = val;
temp->left = NULL;
... | ALGO | 0.999666 | 6.963395 |
546ecf54-7e3d-4e58-83b5-5c7ca7cecd98 | paulobala/ofxCarveCSG | src/lib/intersect_half_classify_group.cpp | #if defined(HAVE_CONFIG_H)
# include <carve_config.h>
#endif
#include <csg.hpp>
#include <debug_hooks.hpp>
#include <list>
#include <set>
#include <iostream>
#include <algorithm>
#include "intersect_common.hpp"
#include "intersect_classify_common.hpp"
#include "intersect_classify_common_impl.hpp"
namespace carve ... | ALGO | 0.922372 | 6.555881 |
128c65d2-64a1-40f5-aa71-2b902c8dcfb0 | Credit-Smartchain/Credit-Classic-Core | src/libff/libff/algebra/curves/bn128/bn128_g2.cpp | /** @file
*****************************************************************************
* @author This file is part of libff, developed by SCIPR Lab
* and contributors (see AUTHORS).
* @copyright MIT license (see LICENSE file)
***********************************************************************... | ALGO | 0.958366 | 6.813828 |
f89a6ed2-5274-4788-a718-cd735f35dbbb | wdk59/Algorithm | 프로그래머스/2/12985. 예상 대진표/예상 대진표.cpp | #include <iostream>
using namespace std;
int solution(int n, int a, int b)
{
int answer = 0;
a--; b--; // 라운드가 1부터 시작하기 때문에, 2로 나눴을 때 같은 라운드인데도 엇갈릴 수 있다. => 1씩 빼줘서 시작 라운드를 0으로 맞춰줌.
while (a != b) {
a = a / 2;
b = b / 2;
answer++;
}
return answer;
} | ALGO | 0.999573 | 4.207183 |
8e86dd9c-b445-4f31-bed0-e36bf1aa1860 | aki-ph-chem/try_neetcode | neet_code_150_cpp/greedy/hand_of_straight.cpp | #include <iostream>
#include <vector>
#include <map>
// 模範解答
class SolutionAns {
public:
bool isNStraightHand(std::vector<int>& hand, int groupSize) {
int n = hand.size();
if (n % groupSize != 0) {
return false;
}
// map {card value -> count}
st... | ALGO | 0.999828 | 6.028791 |
8bfc76a3-4562-4458-b607-704d1a636d9d | kowshikRoy/code | cses/1633.cpp | /**
* Author: Repon Kumar Roy
* Date: 2021-02-22
* Task: 1633
*/
#include <bits/stdc++.h>
using namespace std;
int dp[1000005];
const int mod = 1e9 + 7;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
dp[0] = 1;
for (int i = 1; i <= n; i++) {
for (int j = 1; ... | ALGO | 0.999978 | 4.921337 |
aef38f64-7023-42d5-a611-702c83d1b12c | ishandutta2007/codeforces | wo_/normal/305/D.cpp | #include<cstdio>
#include<algorithm>
using namespace std;
const long long mod=1000000007;
int N,M,K;
int Ma=-1,mi=1<<29;
long long exp[1100100];
int main()
{
scanf("%d%d%d",&N,&M,&K);
bool ok=true;
int cnt=0;
for(int i=0;i<M;i++)
{
int a,b;
scanf("%d%d",&a,&b);
if(b-a!=1&&b-a!=K+1)
{
ok=false;
}... | ALGO | 0.999985 | 3.736346 |
eaa126f6-a9b4-44c0-b8f0-f1f9d101ca4e | biometric-technologies/nist-biometric-image-software-nbis | misc/nistmeshlab/meshlab/src/meshlabplugins/editrgbtri/interactiveEdit.cpp | /****************************************************************************
* The code of the class InteractiveEdit is based on the plugin editpaint, *
* developed by Gfrei Andreas. *
****************************************************************************/
#inc... | TOOL | 0.989858 | 3.420347 |
c35e4fc2-e597-4ab4-91e5-4fd6efc488ec | Sachin1801/DSA_CPP_Leetcode_-_GFG | 0019-remove-nth-node-from-end-of-list/0019-remove-nth-node-from-end-of-list.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 {
private:
int calc_length(Lis... | ALGO | 0.999935 | 5.820744 |
056790aa-06b5-49d4-b751-69754a518036 | RenosCoin/RenosCoin | src/checkpoints.cpp | #include <boost/assign/list_of.hpp> // for 'map_list_of()'
#include <boost/foreach.hpp>
#include "checkpoints.h"
#include "txdb.h"
#include "main.h"
#include "uint256.h"
static const int nCheckpointSpan = 500;
namespace Checkpoints
{
typedef std::map<int, uint256> MapCheckpoints;
//
// What makes a goo... | TOOL | 0.95941 | 7.076316 |
99b3a107-cb00-4739-9484-c48cbd68807d | Arshelle9912/Competitive-Programming | Combinatorics and Probability/57C.cpp | #include <bits/stdc++.h>
using namespace std;
int MOD = 1000000007;
long long factorial(int x) {
long long result = 1;
for (int i = 2; i<=x; i++) {
result = (result*i)%MOD;
}
return result;
}
long long binary_exponentiation(long long base, int power) {
long long result = 1;
while(power... | ALGO | 0.999989 | 4.818594 |
a30e2c46-7f87-49f6-907a-8085a008e904 | Alfeim/njuee_LeetCode_Solutions | Cpp/Submit Records/1011. Capacity To Ship Packages Within D Days.cpp | /********************************************
作者:Alfeim
题目:在D天内送达包裹的能力
时间消耗:52ms
解题思路:二分法
********************************************/
class Solution {
public:
int shipWithinDays(vector<int>& weights, int D) {
int low = 0,high = 0,n = weights.size();
int res = INT_MAX;
for(auto i :... | ALGO | 0.999992 | 5.613938 |
960530c6-de7b-446a-bc07-86137582a7dd | Ahmed-Mohmed-Sakr/Problem-Solving | CodeForces/266A/33124302_AC_30ms_3640kB.cpp | #include<bits/stdc++.h>
#define Sakr_ ios_base :: sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0)
#define ll long long int
using namespace std;
/*
by:Ahmed Sakr (sakr_) with AZA ;l
#ifndef ONLINE_JUDGE
freopen("c.in", "r", stdin);
#endif
*/
int main()
{Sakr_;
int n,i,c=0;
string s;
cin>>n>>s;
... | ALGO | 0.999955 | 3.632513 |
55097626-0552-4329-89a1-b5dbdadbb1d5 | huanggangfeng/Leetcode | Cpp/股票交易问题/714. 买卖股票的最佳时机含手续费.cpp | class Solution {
public:
int maxProfit(vector<int>& prices, int fee) {
int len = prices.size();
if (len <= 1)
return 0;
int ret = 0;
// 第i天有2种状态, 空仓或者满仓
int dp[len][2];
dp[0][0] = 0; // 第一天空仓
dp[0][1] = -prices[0] - fee; // 第一天满仓
for (int i... | ALGO | 0.999741 | 5.38726 |
478151a9-9b38-41bc-9e0d-db680a0944dc | pyrovski/scalasca | earl-2.0/src/tools/ApproxTimesMgr.cpp | #include "ApproxTimesMgr.h"
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <elg_error.h>
#include <elg_rw.h>
using namespace std;
#define EPSILON 0.000000001
/*
*---------------------------------------------------------------------------------
* Read trace records
*-------------------------... | ALGO | 0.979661 | 5.149632 |
23c163d6-bb79-4e74-bd15-268a877431ab | Ayush312003/DAA2022_AyushSingh-2016699- | Practical/Week 5/Code_1.cpp | //Given an unsorted array of alphabets, count duplicate elements and implement using program to find the alphabet with max no. of occurences.
#include <iostream>
using namespace std;
int main()
{
int c=0;
int n;
cout<<"Enter the size of array: ";
cin>>n;
int l=n;
char ch[n];
for(int i=0;i<... | ALGO | 0.999814 | 4.109385 |
df22f0c4-fbaa-42c0-b8ab-7f6d0aa121d7 | anis191/Phitron | Second Semester/Basic Data Structures/Week-05/Module-17/2_Pre_Order_Travers.cpp | #include<bits/stdc++.h>
using namespace std;
class Node{
public:
int val;
Node *left;
Node *right;
Node(int val){
this->val = val;
this->left = NULL;
this->right = NULL;
}
};
void pre_order(Node *root){
if(root == NULL){
return;
}
cout<<root->val<<" ";... | ALGO | 0.99954 | 4.387156 |
2b31aed6-bd84-4755-b4ef-4dff46b9016c | yennanliu/CS_basics | ref_code/leetcode/cpp/0606-construct-string-from-binary-tree.cpp | /*
0606-construct-string-from-binary-tree.cpp
Algorithm Used: Preorder
Time Complexity: O(n)
n is number of nodes
Space Complexity: O(h)
h is height of binary tree
*/
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val... | ALGO | 0.999955 | 6.831091 |
d8aa8a64-c177-433d-8fe6-26328593c13b | Minipoloalex/comp_prog | codeforces/problems/1536/C/C.cpp | #include <bits/stdc++.h>
using namespace std;
void solve() {
int n;
cin >> n;
string s;
cin >> s;
map<pair<int,int>, int> mp;
int d = 0, k = 0;
for (int i = 0; i < n; i++) {
if (s[i] == 'D') d++;
else k++;
int g = gcd(d, k);
cout << ++mp[{d / g, k / g}] << " ... | ALGO | 0.999545 | 4.500244 |
3fc889af-8530-4d1f-a923-3c0ec39eda59 | yashparmar15/Cpp-Codes | Populating_Next_Right_Pointers_in_Each_Node.cpp | // You are given a perfect binary tree where all leaves are on the same level, and every parent has two children. The binary tree has the following definition:
// struct Node {
// int val;
// Node *left;
// Node *right;
// Node *next;
// }
// Populate each next pointer to point to its next right node. If there... | ALGO | 0.999613 | 5.569767 |
f464cbb3-ff9b-46b8-a86b-3f7cdd7d1b9d | ProgrammerDATCH/UR-CS-Class-works | check_magic_square_matrix.cpp | //Group members:
// 222008524 TUYISHIME David
// 222006273 BYUKUSENGE Immaculee
// 222010802 NYODUSENGA Florence
#include <iostream>
#include <vector>
using namespace std;
bool isMagicSquare(const vector<vector<int>>& matrix) {
int n = matrix.size();
// Calculate the sum of the first row (and sum of all rows/... | ALGO | 0.999518 | 5.866802 |
8fcd6f14-6be1-47a1-b327-b703bdf0a423 | KostadinBundov/Introduction_to_Programming_2023_2024 | Seminar.03/08.Print_All_Common_Divisors/08.Print_All_Common_Divisors.cpp | #include <iostream>
int main()
{
int a, b;
std::cin >> a >> b;
int smallerNumber = a < b ? a : b;
for (int i = smallerNumber; i > 0; i--)
{
if (a % i == 0 && b % i == 0)
{
std::cout << i << " ";
}
}
} | ALGO | 0.999727 | 4.022357 |
b4c57f13-c7f4-489b-9aba-bb281d2b4ac6 | raincross7/code-similarity | codes/train_code/problem265/problem265_360.cpp | #include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define eb emplace_back
using na... | ALGO | 0.999979 | 3.130268 |
d28afe34-7759-48c7-8ffd-d10bcaf2b3f0 | nnguyendinh/gem5research | src/systemc/tests/systemc/examples/updown/updown.cpp | #include "systemc.h"
#include "specialized_signals/scx_signal_int.h"
#include "specialized_signals/scx_signal_signed.h"
#include "specialized_signals/scx_signal_uint.h"
#include "specialized_signals/scx_signal_unsigned.h"
SC_MODULE(up_down)
{
sc_in_clk clk;
sc_in<sc_uint<1> > up;
sc_in<sc_ui... | TOOL | 0.992548 | 4.042355 |
ab309142-890e-4330-b5fd-021128f61f85 | manikanta2901/ubuntu | .history/SRM/DAA/Algorithms/Backtracking/NqueenProblem_20210520202859.cpp | #include <bits/stdc++.h>
using namespace std;
vector<vector<int> > result;
bool isSafe(vector<vector<int> > board,int row, int col){
int size = board.size();
// column
for (int i = 0; i < col; i++){
if (board[row][i]){
return false;
}
}
// one diagonal
for (int i = row, j = col; i >= 0... | ALGO | 0.99992 | 5.768111 |
76c72ce5-258e-4342-a3d9-2944f5e57f4d | ddaniel45/binary-addition | main.cpp | #include "bin_calc.h"
using namespace std;
int main()
{
bin_calc calc;
calc.setDec(8520352,0,32);
calc.setDec(6425875,1,32);
cout << calc.add();
return 0;
}
| ALGO | 0.959138 | 5.736857 |
f170f758-239e-4e23-976c-bc94c404923c | hasw7569/Myhobby | Problem_solving/2848_위상정렬.cpp | #include <cstdio>
#include <vector>
#include <queue>
using namespace std;
int N, indegree[26];
vector<int> vt[26];
bool check[26];
int main()
{
char input[100][11];
scanf("%d", &N);
for (int i = 0; i<N; i++) {
scanf("%s", input[i]);
for (int j = 0; input[i][j]; j++)
check[input[i][j] - 'a'] = true;
... | ALGO | 0.999983 | 3.384063 |
2c41cd80-6b26-4622-9542-4d5dbd6e56e3 | noneclashofclans/Leetcode | 236-lowest-common-ancestor-of-a-binary-tree/lowest-common-ancestor-of-a-binary-tree.cpp | /**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
TreeNode* lowestCommonAncestor(TreeNode* root, TreeNode* p, TreeNode* q) {
// edge case... | ALGO | 0.999985 | 6.385279 |
9c1e0ad3-ba4a-4aa0-8a16-51ebee528301 | ardulat/coding-interview-prep | Problems/InterviewBit/Stacks and Queues/GenerateAllParentheses.cpp | // https://www.interviewbit.com/problems/generate-all-parentheses/
bool isPair(char a, char b) {
if (a == '(' && b == ')')
return true;
else if (a == '{' && b == '}')
return true;
else if (a == '[' && b == ']')
return true;
return false;
}
int Solution::isValid(string A) {
... | ALGO | 0.995105 | 4.24758 |
9c83445a-7d92-4215-bb81-24276b90d74f | MozaffarMotwakil/cpp-problem-solving | level-2/Ex4-SumEachColumnInMatrix/Ex_4-SumEachColumnInMatrix.cpp | #include <iostream>
#include <cstdlib>
#include <iomanip>
using namespace std;
int RandomNumber(int From, int To) {
return rand() % (To - From + 1) + From;
}
void FillMatrixWithRandomNumbers(int Matrix[3][3], int Rows, int Columns) {
for (short i = 0; i < Rows; i++)
{
for (short j = 0; j < Columns; j++)
{
... | ALGO | 0.95517 | 3.869546 |
90639f2e-e6ec-4b58-acf4-e4956803818f | Riano-Francesco/Multitool | Multitool/LeibnitzPi.cpp | #include <iostream>
#include <windows.h>
#include <iomanip>
#include "func.h"
using namespace std;
void Leibnitz() {
bool abbruch;
do {
Sleep(500);
double reihe;
cout << "Wie weit soll die Reihe gebildet werden: ";
cin >> reihe;
double pi = 0.0;
for (int i = 0; i < reihe; i++) {
double num1 =... | ALGO | 0.999914 | 3.144333 |
b7cbeddd-8231-4a5a-82c2-2f4f68c3e15d | bob11vrdp/CVE-2022-39425 | VirtualBox-6.1.38/src/VBox/Runtime/r3/posix/sched-posix.cpp | /* $Id: sched-posix.cpp $ */
/** @file
* IPRT - Scheduling, POSIX.
*/
/*
* !WARNING!
*
* When talking about lowering and raising priority, we do *NOT* refer to
* the common direction priority values takes on unix systems (lower means
* higher). So, when we raise the priority of a linux thread the nice
* value ... | TOOL | 0.947471 | 3.987793 |
aba77068-fc8a-43c4-9707-b8c1bd8e19f9 | raincross7/code-similarity | codes/train_code/problem281/problem281_466.cpp | #include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#define ll long long
using namespace std;
ll MAX=1e18;
int main(){
int N;
cin>>N;
ll A[N],ans=1;
for(int i=0;i<N;i++){
cin>>A[i];
if(A[i]==0){
cout<<"0"<<endl;
return 0;
}
}
... | ALGO | 0.999876 | 3.82952 |
2809d223-92ab-4594-800a-d823d608d35d | Ferdous-Jahan/Master-Thesis | RQ1-exp/parallel_sort/parallel_sort_execution_policy_par.cpp | #include <algorithm>
#include <execution>
#include <iostream>
#include <random>
#include <vector>
#include <chrono>
bool is_sorted(const std::vector<int>& data) {
return std::is_sorted(data.begin(), data.end());
}
int main() {
const size_t n = 1000000;
std::vector<int> data(n);
std::random_device rd;... | ALGO | 0.999427 | 6.564669 |
4ccd966b-a633-476d-8c38-ca76e2ee368e | JugalPatel01/CPPTutorial | 17-recursion/17-recursion07-FirstAndLastOccurenceInArray.cpp | #include <iostream>
using namespace std;
int firstoccu(int arr[], int n, int i, int key)
{
if (i == n)
{
return -1;
}
if (arr[i] == key)
{
return i;
}
return firstoccu(arr, n, i + 1, key);
}
int lastoccu(int arr[], int n, int i, int key)
{
if (i == n)
{
return... | ALGO | 0.999828 | 5.316869 |
01a58902-5cd5-4ea5-a87e-3d11a7ee2475 | ohb4/Computing-I | Assignments/Assignment 4/Problem6.cpp | #include <iostream>
using namespace std;
// function to check if variable is positive by true or false
bool isValidInput (int n)
{
if ( n > 0)
{
//returns true if the number is positive
return true;
}
else
{
//returns false if the number is negative
return false;
... | ALGO | 0.998022 | 3.831737 |
c4b06660-6e65-46b9-87bf-0b266aebfa8a | rxb8k/Algorithm | 백트래킹/15651_N과M_3.cpp | #include <iostream>
using namespace std;
int N, M;
int arr[8];
void backTracking (int depth) {
if (depth == M) {
for (int i=0; i<M; i++) {
cout<<arr[i]<<" ";
}
cout<<"\n";
}
else { // 아직 출력할 배열이 만들어지지 않았으면
for (int i=1; i<=N; i++) { // 전체 수를 돌면서
arr[... | ALGO | 0.999798 | 3.990764 |
4c132a27-a3c0-478b-9023-6d07c26d97e5 | xiechengsheng/leetcode | 053-maximum-subarray/maximum-subarray.cpp | //
// Find the contiguous subarray within an array (containing at least one number) which has the largest sum.
//
//
// For example, given the array [-2,1,-3,4,-1,2,1,-5,4],
// the contiguous subarray [4,-1,2,1] has the largest sum = 6.
//
//
// click to show more practice.
//
// More practice:
//
// If you have figure... | ALGO | 0.999767 | 5.48346 |
56e58a2c-bb89-4e43-816f-d3bd955e2ebb | ToLoveToFeel/LeetCode | Cplusplus/_0661_Image_Smoother/_0661_main.cpp | // Created by WXX on 2021/2/27 22:20
#include <iostream>
#include <vector>
using namespace std;
// 卷积操作,可以用二维前缀和
/**
* 执行用时:92 ms, 在所有 C++ 提交中击败了32.52%的用户
* 内存消耗:18.4 MB, 在所有 C++ 提交中击败了99.55%的用户
*/
class Solution {
public:
vector<vector<int>> imageSmoother(vector<vector<int>> &M) {
int n = M.size(), m... | ALGO | 0.99997 | 5.629301 |
17a85410-9830-4042-b08f-7c4a08d1ec51 | inastranets/acmp-Solutions | Решение олимпиадных задач/Теория Графов - 1/Базовые понятия/Светофорчики.cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, m;
cin >> n >> m;
int lights[101];
memset(lights,0x0,sizeof(lights));
for(int i = 0; i<2*m; ++i) {
int x;
cin >> x;
++ lights[x];
}
for(int i = 1; i <= n; ++ i)
cout << lights[i] << ' ';
ret... | ALGO | 0.999904 | 3.305308 |
a2559bb6-1cc2-439f-8e55-f989e166aa1f | hung1605/codeforce | problem_set/vlad_and_a_sum_of_sum_of_digits.cpp | #include <bits/stdc++.h>
using namespace std;
int sum_of_digit(int n) {
int sum = 0;
while (n > 0) {
sum += n % 10;
n /= 10;
}
return sum;
}
int main() {
int a[200005];
int dp[200005];
a[1] = 1;
for (int curr = 2; curr <= 200000; curr++) {
int prev = curr - 1;
int last_curr = curr % 10... | ALGO | 0.999701 | 5.488468 |
617fc777-610d-429c-8489-a01a42064c00 | SadiqVali786/DSA | 11.Recursion/07.addStringsAsIntegers.cpp | #include<iostream>
#include<chrono>
#include<algorithm>
using namespace std;
void add_integers(string &num1, int &idx1, string &num2, int &idx2, string &sum, int carry=0) {
if ((idx1 < 0) && (idx2 < 0)) {
if (carry) sum.push_back(carry+'0');
return;
}
int n1 = idx1>=0 ? num1[idx1]-'0' : 0;
... | ALGO | 0.997397 | 6.486653 |
697f1fe1-490f-48c4-bc7e-1e3f13a7c1bc | Fahadh4444/Coding_Mafia | Concepts/Methods/Dynamic Programming/Variations of Dynamic Programming/Unbounded Knapsack/Minimum Number of Coins Problem.cpp | #include <bits/stdc++.h>
using namespace std;
class Solution{
public:
int minCoins(int coins[], int M, int V) {
vector<vector<int>> DP(M+1,vector<int>(V+1,-1));
for(int i=0;i<=M;i++){
for(int j=0;j<=V;j++){
if(j == 0) DP[i][j] = 0;
else if(i == 0)... | ALGO | 0.999995 | 4.813994 |
0aaa1127-3b7d-4106-961b-9fad3be1df87 | lydsera/Solutions | codeforces/337A Puzzle.cpp | #include<iostream>
//#include<algorithm>ĺ
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
int* a=new int [m]; //̬
int i=0,j=0;
for(i=0;i<m;i++)
{
cin>>a[i];
}
for(i=0;i<m;i++) //ѡ ðһa[i]a[i+1]ȣдa[i]a[j]
{
int min=i;
for(j=i;j<m;j++)
{
if(a[j]<=a[min])min=j;
}
swap(a[i],a[min]);
}
... | ALGO | 0.999935 | 3.016946 |
9c33bed6-4409-4055-b5cc-9a90cf8cacfa | nikhilcse0427/Data-Structures-and-Algorithm | Sorting/BubbleSort.cpp | #include<iostream>
using namespace std;
int main(){
int arr[5];
cout<<"enter the element ooof array: ";
for(int i=0;i<5;i++){
cin>>arr[i];
}
for(int i=0;i<4;i++){
for(int j=0;j<4-i;j++){
if(arr[j]>arr[j+1]){
swap(arr[j],arr[j+1]);
}
}
... | ALGO | 0.999887 | 3.215635 |
63c1c031-1ea4-48da-9583-c3d3b4126a6a | brown0394/algorithm_practice | party.cpp | #include <iostream>
#include <vector>
#include <algorithm>
#define INF 2000000
class node {
public:
int to;
int* cost;
node(int p_to, int* p_cost) :to(p_to), cost(p_cost) {}
bool operator< (const node& other);
};
struct connect {
int to;
int cost;
};
bool node::operator<(const node& other) {
return *this->co... | ALGO | 0.999551 | 4.214143 |
a53b0d13-0b2d-46d3-9e2b-4c6e380e2f8d | kawloong/CppCloud | cpp_sdk/tcp_invoker_mgr.cpp | #include "tcp_invoker_mgr.h"
#include "tcp_invoker.h"
#include "svrconsumer.h"
#include "comm/strparse.h"
#include "comm/lock.h"
#include "cloud/msgid.h"
RWLock gLocker;
TcpInvokerMgr::TcpInvokerMgr( void )
{
m_eachLimitCount = 5;
}
TcpInvokerMgr::~TcpInvokerMgr( void )
{
//IOVOKER_POOLT::iterator it = m_poo... | TOOL | 0.913879 | 4.604734 |
33d26bd2-5154-425d-992b-2ffb82184651 | kmjp/procon | atcoder/abc151-200/abc161/b.cpp | #include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZER... | ALGO | 0.999991 | 3.353827 |
f2af06b1-3a64-4c6a-9850-a2b8b496fb78 | Mulab11/cntt2016-hw1 | TC-SRM-571-div1-500/lh.cpp | #include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
class MagicMolecule{
private:
static const int maxn=55;
int id[maxn],w[maxn],n;
bool map[maxn][maxn],chos[maxn];
int check(){
int num=0,ret=0;
for (int i=0;i<n;++i){
chos[... | ALGO | 0.999801 | 3.936373 |
64842c35-5554-4b82-8219-d79ce67b6569 | konnase/algorithm | AOJ/cgl_1_c_counter_clockwise.cpp | //
// Created by 李青坪 on 2018/12/1.
//
#include <cmath>
#include <cstdio>
#include <algorithm>
#define EPSLON 1e-10
#define equals(a, b) (fabs((a) - (b)) < EPSLON)
#define COUNTER_CLOCKWISE 1
#define CLOCKWISE -1
#define ONLINE_BACK -2
#define ONLINE_FRONT 2
#define ON_SEGMENT 0
using namespace std;
// 点
class Point... | ALGO | 0.999941 | 4.812299 |
47585281-e7e9-48ba-b31e-c5a71bf9ce10 | zhudisheng/The-Cplusplus-programming-language | arraytemplate/test.cpp | #include <iostream>
#include <string>
using namespace std;
template
<typename T,int N>
void func()
{
T a[N] = {0};
for(int i = 0;i < N;i++)
{
a[i] = i;
}
for(int i = 0;i < N;i++)
{
cout << a[i] << endl;
}
}
template
<int N>
class Sum
{
public:
static const int VALUE = Sum<N-1>::VALUE+N;
};
template
<>
cla... | ALGO | 0.990026 | 4.189579 |
ebcb6cd8-18cb-449d-9b73-a51c9789fbcc | mkej22/queue | main.cpp | #include <iostream>
#include "kolejka.h"
using namespace std;
void displayMenu() {
cout << "\nMenu:\n";
cout << "1 - Dodaj liczbe do kolejki (Push)\n";
cout << "2 - Sprawdz wartosc pierwszego elementu (Top)\n";
cout << "3 - Usun pierwszy element (Pop)\n";
cout << "4 - Czy kolejka jest pusta?\n";
... | ALGO | 0.936198 | 5.197553 |
63b2cc40-984f-4599-ac07-1c1943d0252d | zhangchunbao515/leetcode | leetcode-04/solutions/cpp/0980.cpp | class Solution {
public:
int uniquePathsIII(vector<vector<int>>& grid) {
const int m = grid.size();
const int n = grid[0].size();
int ans = 0;
int empty = 1;
int sx;
int sy;
for (int i = 0; i < m; i++)
for (int j = 0; j < n; j++) {
if (grid[i][j] == 0) {
empty++;... | ALGO | 0.999833 | 6.628614 |
d434b98a-8d12-40a7-9419-c7ae98f7a9b7 | reunanen/boost-prebuilt-windows-binaries | libs/compute/perf/perf_reduce_by_key.cpp | #include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <boost/compute/system.hpp>
#include <boost/compute/algorithm/fill.hpp>
#include <boost/compute/algorithm/reduce_by_key.hpp>
#include <boost/compute/container/vector.hpp>
#include "perf.hpp"
int rand_int()
{
return static_cast<... | ALGO | 0.998114 | 5.561597 |
3a01733e-b2d8-4840-916a-63d16619a0f6 | qf-offical/Frame | Frame/Source/ThirdParty/opencv/modules/objdetect/src/barcode.cpp | #include "precomp.hpp"
#include <opencv2/objdetect/barcode.hpp>
#include <opencv2/core/utils/filesystem.hpp>
#include "barcode_decoder/ean13_decoder.hpp"
#include "barcode_decoder/ean8_decoder.hpp"
#include "barcode_detector/bardetect.hpp"
#include "barcode_decoder/common/super_scale.hpp"
#include "barcode_decoder/comm... | TOOL | 0.959832 | 6.11158 |
439f8744-709f-4363-9693-55dd8c5fa424 | Tiemp-B/MyBox | acmicpc/2436.cpp | #include <iostream>
#include <vector>
#include <queue>
#include <set>
using namespace std;
int main()
{
int GSD, LCM;
cin >> GSD >> LCM;
int ans_sum = 200000000;
long long int A, B;
int gap = LCM / GSD;
vector<pair<int, int>> el; // {원소, 포함수수}
set<int> ordered_el;
vector<int> el2;
... | ALGO | 0.999845 | 4.731479 |
1a09a71c-64e1-46b7-9c31-8625f3df3989 | T-Shota/IDF-Autoware | ros/src/computing/perception/detection/lib/image/dpm_ttic/cpu/detect.cpp | /////detect.cpp Detect car from an image ///////////////////////////////////////////////////////////////////////
//OpenCV library
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <opencv/cxcore.h>
//C++ library
#include <cstdio>
#include <cstdlib>
#include <time.h>
//ORIGINAL header files
#include "MOD... | ALGO | 0.985047 | 5.019412 |
8f006893-537c-44d1-a3e0-5b60a83029bb | akash-1514/Contest_Prob_Techniques | 2369-check-if-there-is-a-valid-partition-for-the-array/2369-check-if-there-is-a-valid-partition-for-the-array.cpp | class Solution {
public:
int dp[100001];
bool helper(vector<int>&arr, int idx) {
int n = arr.size();
if(idx >= n) return true;
// check for memo
if(dp[idx] != -1) return dp[idx];
// check for two equal element
if(idx + 1 < n && arr[idx] == arr[id... | ALGO | 0.999982 | 5.770262 |
e4afc56b-8c0f-442c-a741-b356e785b5fc | AshutoshKumarPande/Discrete_Structure | Practical_1_6.cpp | // Write a c++ function to find whether a given number is prime or not.
// Use the Same to generate prime number less than 100.
// Created By :- Ashutosh Kumar Pandey
// Created on :- 23rd January, 2022
#include <iostream>
using namespace std;
void chkPrime();
int main()
{
chkPrime();
return 0;
}
void chkPrim... | ALGO | 0.999687 | 4.83846 |
31e2b76d-06ce-4e5b-a96a-2c24d97b5bab | Tieucuc2210/C-Basic | doitien.cpp | #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define MAX_SIZE 1e7
#define MIN_SIZE -1e7
const int MOD = (int) 1e9+7;
const int INF = (int) 1e9+1;
inline ll gcd(ll a,ll b){ll r;while(b){r=a%b;a=b;b=r;}return a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
int main(){
io... | ALGO | 0.999593 | 3.872163 |
bbfd9546-daa6-4583-8845-5fa8c4c27f5c | akashmodak97/Competitive-Coding-and-Interview-Problems | Leet Code/Find Peak Element.cpp | /* Leet Code */
/* Title - Find Peak Element */
/* Created By - Akash Modak */
/* Date - 30/06/2021 */
// A peak element is an element that is strictly greater than its neighbors.
// Given an integer array nums, find a peak element, and return its index. If the array contains multiple peaks, return the index to any o... | ALGO | 0.999963 | 5.405805 |
e738389d-175f-4d84-9e33-5fc50c7e5a10 | shuoli-robotics/testCmake | mathLib/eigen/doc/snippets/Tutorial_AdvancedInitialization_LinSpaced.cpp | ArrayXXf table(10, 4);
table.col(0) = ArrayXf::LinSpaced(10, 0, 90);
table.col(1) = M_PI / 180 * table.col(0);
table.col(2) = table.col(1).sin();
table.col(3) = table.col(1).cos();
std::cout << " Degrees Radians Sine Cosine\n";
std::cout << table << std::endl;
| ALGO | 0.959304 | 3.543272 |
e26d2cd2-289e-4f49-8906-7132653b75a7 | chubakueno/Chess | chess/Chess.cpp | #include <iostream>
#include <vector>
#include <algorithm>
#include <intrin.h>
#include <sstream>
using namespace std;
#pragma warning( disable : 4146 )
#include "types.h"
#include "util.h"
#include "search.h"
#include "string"
const char startBoard[2][8][9] = {
{
"........",
"........",
"........",
"........",
"... | ALGO | 0.9696 | 4.926261 |
a97215af-25c3-46ee-84f5-19578a59b666 | avneez/leetcode-gfg | Minimum Cost of ropes - GFG/minimum-cost-of-ropes.cpp | // { Driver Code Starts
#include <bits/stdc++.h>
using namespace std;
// } Driver Code Ends
class Solution
{
public:
//Function to return the minimum cost of connecting the ropes.
long long minCost(long long arr[], long long n) {
priority_queue<long long, vector<long long>, greater<long long>> min... | ALGO | 0.999919 | 5.825384 |
d7806572-877e-4049-b303-8639ba5e3bf9 | Mofazzal874/ObjectOrientedProgramming-CSE-2102 | OOP_LAB_TASK/LAB7Task.cpp |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
class student{
public:
string name ;
int roll ;
double cg ;
void setter(){
string s ;
int r ;
double c ;
cin>>s>>r>>c;
name = s;
roll = r ;
cg = c;
}
void g... | ALGO | 0.994872 | 3.962888 |
013ea3e9-1e21-4a60-8e96-2b116f9b0644 | strengthen/LeetCode | C++/199.cpp | __________________________________________________________________________________________________
sample 4 ms submission
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
cl... | ALGO | 0.999974 | 6.020988 |
cc149b89-8231-4b31-b196-3594f331562b | Fengdalu/acm-icpc | BJTU/Club-16/11.21/D.cpp | #include <algorithm>
#include <iostream>
#include <cstdio>
#define PII std::pair<int, int>
#define AA first
#define BB second
#define MP std::make_pair
using std::pair;
using std::string;
const int N = 500;
char buf[N];
pair<pair<int, int>, string> a[N];
pair<int, string> b[N];
int main() {
int n;
while(~scanf(... | ALGO | 0.999302 | 3.249865 |
74a1066e-0281-472f-94a0-4c76d0353782 | madhavm0706/DataStructure | binarysearch/bseleventh.cpp | // ceil of the element in soted array
#include<iostream>
using namespace std;
int ceil(int arr[],int l,int e,int x){
int result;
while(l<=e){
int mid = l+(e-l)/2 ;
if(arr[mid] == x){
return mid;
}else if(arr[mid]<x){
l=mid+1;
}else if(arr[mid]>x){
result = mid;
... | ALGO | 0.999916 | 4.264224 |
6d27d65f-c2c3-44a7-b778-9e9a9c184e7a | melonxi/jianzhioffer-Cpp | exercises_3.cpp | #include <iostream>
using namespace std;
bool found(int Mat[][4], int rows, int columns, int obj);
int main()
{
int matrix[4][4] = {{1, 2, 8, 9}, {2, 4, 9, 12}, {4, 7, 10, 13}, {6, 8, 11, 15}};
int num = 17;
bool res = found(matrix, 4, 4, num);
cout << res << endl;
return 0;
}
bool found(int Mat[... | ALGO | 0.995447 | 4.453207 |
4b21b2f8-a687-4af6-8866-c05c1b0365d0 | tanishq6818/DSA | POTD March 20th/GFG POTD.cpp | // Given a binary tree having n nodes. Find the sum of all nodes on the longest path from root to any leaf node. If two or more paths compete for the longest path, then the path having maximum sum of nodes will be considered.
// Example 1:
// Input:
// 4
// / \
// 2 5
// ... | ALGO | 0.999967 | 5.640418 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.