uuid string | repo_name string | relative_path string | content string | category string | algo_rel_score float64 | quality_score float64 |
|---|---|---|---|---|---|---|
384f7229-ece2-4b10-a29f-bfd4df8985dc | pradeep-kumar-1705807/Data-structure-and-Algorithms | ConstructBinaryTreeFromParentArray.cpp | #include<iostream>
#include<bits/stdc++.h>
using namespace std;
struct Node
{
int data;
Node* left;
Node* right;
};
Node* newNode(int val)
{
Node * temp=(Node*)malloc(sizeof(Node));
temp->data=val;
temp->left=NULL;
temp->right=NULL;
return temp;
}
void inOrder(Node* root)
{
if(root=... | ALGO | 0.999984 | 4.541327 |
7cd40783-274b-489d-9142-4974385b813c | ishandutta2007/codeforces | yeongtree/normal/1361/B.cpp | #include <iostream>
#include <algorithm>
using namespace std;
const int Q = (int)1e9 + 7;
const int MAX = 2e6;
bool ex;
int __pow(long long a, int p)
{
long long ans = 1;
while(p)
{
if(p & 1)
{
ans *= a;
if(ans > MAX) ex = true;
ans %= Q;
}
... | ALGO | 0.999962 | 4.244297 |
122ce363-80db-4465-ab43-e297f3ef29c2 | trinhminhtriet/leetcode | solutions/1500-1599/1562.find-latest-group-of-size-m/Solution.cpp | class Solution {
public:
vector<int> p;
vector<int> size;
int findLatestStep(vector<int>& arr, int m) {
int n = arr.size();
if (m == n) return n;
p.resize(n);
size.assign(n, 1);
for (int i = 0; i < n; ++i) p[i] = i;
int ans = -1;
vector<int> vis(n);
... | ALGO | 0.999998 | 5.619872 |
bbd1c2d8-04db-40b6-bf5e-f2dcb48c976e | r0h1th/cnslab | extended_euclidian.cpp | #include <iostream>
using namespace std;
int gcdExtended(int a, int b, int *x, int *y)
{
if (a == 0)
{
*x = 0;
*y = 1;
return b;
}
int x1, y1;
int gcd = gcdExtended(b%a, a, &x1, &y1);
*x = y1 - (b/a) * x1;
*y = x1;
printf("%d %d %d %d \n",*x,*y,x1,y1);
return g... | ALGO | 0.999811 | 4.314141 |
67efafa3-d4fc-4042-849e-db42b10e9737 | 113bommy/deepmind_codecontests_refine | cpp_source_filter_file/cpp_train_11835_1.cpp | #include <bits/stdc++.h>
const int N = 100005;
using namespace std;
int ban[N], vis[N];
vector<int> e[N];
int tried[N], n, m;
bool dfs(int x) {
if (ban[x]) return 0;
vis[x] = 1;
for (int i = 0; i < e[x].size(); i++) {
int to = e[x][i];
if (vis[to] == 0) {
if (dfs(to)) return 1;
} else if (vis[to... | ALGO | 0.999974 | 3.990326 |
5afcf12a-abf2-4764-82f0-c777d27358f3 | Akash-Ingle/DSA_in_CPP | LinkedList/FindIntersectionPoint.cpp | #include <iostream>
using namespace std;
class node{
public:
int data;
node* next;
node(int val){
data=val;
next=NULL;
}
};
void insertAtTail(node* &head, int val){
node* n = new node(val);
if(head==NULL){
head=n;
return;
}
n... | ALGO | 0.999919 | 4.203637 |
69842304-ab3e-479f-9905-742823ee2017 | raincross7/code-similarity | codes/train_code/problem065/problem065_147.cpp | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define tie() ios_base :: sync_with_stdio(0); cin.tie(0) ; cout.tie(0)
#define err(x) cerr << #x << " is : " << x << endl
#define mem(a , v) memset(a , v , sizeof a)
#define all(v) v.begin() , v.end()
#define endl '\n'
int32_t main()
{
tie()... | ALGO | 0.999857 | 4.227945 |
8569f368-b654-4041-a255-eeef24238e44 | JNRMAT002/EEE4120F | Prac2/Prac2.2/multiplication.cpp |
//Author: Christopher Hill For the EEE4120F course at UCT
//Functionality added by Matthew January, Ben Connolly for EEE4120F course Practical at UCT
#include<stdio.h>
#include<CL/cl.h>
#include<iostream>
#include<fstream>
#include<string>
#include<cmath>
#include <tuple>
using namespace std;
//creates a square mat... | ALGO | 0.969449 | 3.857006 |
21cad458-4df7-4790-a00a-4471eba78c12 | DionysiosB/CodeForces | 0100-0199/119A-EpicGame.cpp | #include <cstdio>
using namespace std;
int gcd (int a, int b){return (b == 0) ? a : gcd (b, a%b);}
int main(){
int a, b, n; scanf("%d %d %d\n", &a , &b , &n);
while(1){
n -= gcd(a,n);
if(n <= 0){printf("0\n");break;}
n -= gcd(b,n);
if(n <= 0){printf("1\n");break;}
}
ret... | ALGO | 0.99997 | 3.503039 |
ac09bd7d-4be6-42a4-b6ef-de5a6185bf54 | DhruvTotala/Leetcode | 3685-count-subarrays-of-length-three-with-a-condition/count-subarrays-of-length-three-with-a-condition.cpp | class Solution {
public:
int countSubarrays(vector<int>& nums) {
int count = 0;
int n = nums.size();
for(int i = 0; i < n; i++) {
for(int j = i + 1; j < n; j++) {
for(int k = j + 1; k < n; k++) {
if((abs(i - j) == abs(j - k)) && (abs(i - k) == ... | ALGO | 0.999839 | 5.769013 |
a8f060d6-6fcf-44e8-b1b6-e56ed3eec210 | AndroidOpenDevelopment/android_external_skia | bench/MathBench.cpp | #include "Benchmark.h"
#include "SkColorPriv.h"
#include "SkMatrix.h"
#include "SkPaint.h"
#include "SkRandom.h"
#include "SkString.h"
static float sk_fsel(float pred, float result_ge, float result_lt) {
return pred >= 0 ? result_ge : result_lt;
}
static float fast_floor(float x) {
// float big = sk_fsel(x, 0x... | TEST | 0.875275 | 7.250434 |
3f0d2ce4-26d8-430d-b820-36752f844bd3 | lokesh1729/data-structures-and-algorithms | leetcode/160_intersection_of_two_linked_lists.cpp | /**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode *getIntersectionNode_naive(ListNode *headA, ListNode *headB) {
while (headA != NULL) {
ListNode* headTw... | ALGO | 0.999851 | 5.278604 |
42439295-6758-4140-b63f-f3475470eb8d | Inquisitor/mangos | dep/tbb/src/perf/fibonacci_cutoff.cpp | #include <cstdio>
#include <cstdlib>
#include "tbb/task_scheduler_init.h"
#include "tbb/task.h"
#include "tbb/tick_count.h"
long CutOff = 1;
long SerialFib( const long n );
long ParallelFib( const long n );
inline void dump_title() {
printf("Serial/Parallel, P, N, cutoff, repetitions, time, fib, speedup\n");
... | ALGO | 0.999878 | 5.347934 |
d5fb77d2-93d9-4c75-9b38-e47572e70a99 | Satosh1A/competitiveprogramming2 | Atcoder/Atcoder Beginners Selection/ABC081A - Placing Marbles.cpp | #include <bits/stdc++.h>
using namespace std;
int main(){
int a;
cin >> a;
if(a==111){
cout << 3 << endl;
}
else{
cout << a%3 << endl;
}
return 0;
}
| ALGO | 0.999321 | 3.192062 |
33b9840d-d263-40ca-8894-d00f7c8226b0 | tr1ten/DNA | Algos/prime_factors.cpp | #include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int sieve[N+1];
// find prime <sqrt(MAX)
// O(LlogL)
void preprocess(){
sieve[0] = 1;
sieve[1] = 1;
for(int x=2;x<=N;x++){
if(sieve[x]!=0) continue;
sieve[x] = x;
for(int u=x*x;u<=N;u +=x){
sieve[u] = ... | ALGO | 0.999591 | 3.77189 |
43cfb07e-7877-42fd-a16d-2f86523bc212 | yangxy01/School_Codes | DataStruct/实验09_图遍历与最小生成树/实验09_图遍历与最小生成树/E. DS图—最小生成树.cpp | //#include<iostream>
//#include<map>
//#include<vector>
//#include<string>
//#include<bitset>
//#include<queue>
//using namespace std;
//
//struct edge
//{
// int left;
// int right;
// int weight;
//};
//bool operator<(const edge& a, const edge& b)
//{
// return a.weight > b.weight;
//}
//
//class Graph
//{
//private:... | ALGO | 0.999925 | 3.91066 |
e06d4a4d-c582-4ed3-8489-b2b30ab43e4c | raincross7/code-similarity | codes/train_code/problem213/problem213_480.cpp | #include<bits/stdc++.h>
#define int long long
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
#define mod 1e9
int32_t main() {
int a,b,c,k;
cin>>a>>b>>c>>k;
if(k&1)
cout<<b-a;
else cout<<a-b;
}
| ALGO | 0.999937 | 3.341577 |
d69dbad7-9991-40a2-b762-a739e63cae99 | Shahin-Sheikh/Competitive-Programming | Contests/Educational Codeforces Round 111 (Rated for Div. 2)/D.cpp | //implement binary search
//AC
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define all(c) begin(c), end(c)
#define mem(... | ALGO | 0.999974 | 3.293007 |
26705e3e-9c48-4185-893c-ea7b76976ff2 | sonapraneeth-a/competitive-programming_submissions | platforms/leetcode/practice/non-premium/medium/146__lru-cache/solutions.cpp | // clang-format off
/**
* FILE DESCRIPTION
*
* Filename: 146__lru-cache/solutions.cpp
* Created on: 05 September 2021
* Last modified: 05 September 2021
* Author: sonapraneeth_a
* Description: LeetCode submission for 'LRU Cache' problem
*/
/**
* CHANGELOG
*
* Date (DD-MM-YYYY) ... | ALGO | 0.998591 | 6.640001 |
62b2cdfb-808a-4ec7-bfa8-9587affb17c2 | Cloyd-Castillo/midterm_lab_exam_cs121_CASTILLO_CLOYD_ROBIN_C. | mm.cpp | #include <iostream>
using namespace std;
int main()
{
int size;
cout << "Enter the array size: ";
cin >> size;
int arr[size];
cout << "Enter " << size << " elements:" << endl;
for (int i = 0; i < size; i++)
{
cin >> arr[i];
}
int sum = 0;
for (int i = 0; i ... | ALGO | 0.999372 | 5.667312 |
6f48eda9-3ae9-4584-812d-47dd88d0dd84 | tetrafolium/mapsme-omim | search/keyword_matcher.cpp | #include "search/keyword_matcher.hpp"
#include "indexer/search_delimiters.hpp"
#include "indexer/search_string_utils.hpp"
#include "base/assert.hpp"
#include "base/buffer_vector.hpp"
#include "base/stl_add.hpp"
#include <algorithm>
#include <sstream>
using namespace std;
namespace search
{
KeywordMatcher::KeywordM... | TOOL | 0.960463 | 6.424767 |
56ca79ee-2609-43a8-b735-a72b4d4b54ba | Utkarsh-876/Cpp-Program | Array_Reverse.cpp | //#include<iostream>
//using namespace std;
//
//int main()
//{
// int Arr[]={10,20,30,40,50,60,70,80};
// int size=8;
// int start=0;
// int end=size-1;
//
// while(start<end)
// {
// swap(Arr[start],Arr[end]);
// start++;
// end--;
// }
//
// for(int i=0;i<size;i++)
// {
// cout<<Arr[i]<<" ";
// }
//
//}
#... | ALGO | 0.995729 | 3.991496 |
fc0e6b71-2a5f-49ef-b632-9a4e2b42f5d3 | ishandutta2007/codeforces | gyh20/normal/1718/B.cpp | #include<bits/stdc++.h>
#define re register
#define int long long
using namespace std;
inline int read(){
re int t=0;re char v=getchar();
while(v<'0')v=getchar();
while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
return t;
}
const int M=998244353;
inline void add(re int &x,re int y){(x+=y)>=M?x-=M:x;}
inline int Mod(r... | ALGO | 0.999949 | 4.300434 |
787cd0c5-51da-4b0c-9b03-dbfc34b21f3a | arpitcodelab/cpp_codes | Basic C++/loopwhile.cpp | #include<iostream>
using namespace std;
int main()
{
int n , i=1; //for count;
cout << " enter n:-";
cin >> n;
while (i<=n){
cout << i<<endl;
i++;
}
return 0;
}
| ALGO | 0.997638 | 3.204499 |
2491afb6-0c21-4ccb-b44d-74dce7f6923d | YuvrajSahni/DSA-Practice | Recursion/tower_of_hanoi.cpp | #include <iostream>
using namespace std;
void toh(int n, char A, char B, char C)
{
if(n==1)
{
cout<<"Move 1 from "<<A<<" to "<<C<<endl;
return;
}
toh(n-1,A,C,B);
cout<<"Move "<<n<<" from "<<A<<" to "<<C<<endl;
toh(n-1,B,A,C);
}
int main()
{
toh(3,'A','B','C');
return 0;... | ALGO | 0.999974 | 4.658284 |
39e83fd5-8174-4aba-9028-a0b5a5fdde76 | MdMaruf-22/Codeforces-Solutions | A_Sakurako_s_Exam.cpp | #include<bits/stdc++.h>
using namespace std;
#define int long long
#define give_number_of_one_in_binary(x) __builtin_popcount(x)
#define count_trailing_zero_in_binary(x) __builtin_ctz(x)
#define count_leading_zero_in_binary(x) __builtin_clz(x)
void solve()
{
int a, b;
cin >> a >> b;
int sum = a + 2 * b;
... | ALGO | 0.999882 | 4.964322 |
9aaecfc9-3b78-40ed-b5ae-2c3b5e5cd228 | Khunsukkub/Lab12-660610743 | lab12_4.cpp | #include<iostream>
using namespace std;
template <typename AnyDiDi>
void mySwap(AnyDiDi &frist, AnyDiDi &sec);
int main(){
int x, y;
string a, b;
char p, q;
cin >> x >> y >> a >> b >> p >> q;
cout << "Before swapping:\n";
cout << "x = " << x << ", y = " << y << "\n";
mySwap(x,y);
cout << "After swapping:... | ALGO | 0.993389 | 3.042346 |
b1e08da8-c8c1-4fb7-b170-43ad829b4764 | Raunak1001/Competitive-Coding | SPOJ/ALTSEQ.cpp | #include<bits/stdc++.h>
using namespace std;
#define vi vector<long long int>
#define vp vector<pair<long long int,long long int > >
#define vc vector<char>
#define vvi vector<vector<long long int> >
#define vvp vector<vector<pair<long long int,long long int> > >
#define vvc vector<vector<char> >
#define ll long long... | ALGO | 0.999881 | 4.047903 |
fad54ab3-9136-49cb-bfb8-840575bd539f | GHLee96/baekjoon | 1916_최소비용구하기.cpp | #include <iostream>
#include <queue>
#include <vector>
using namespace std;
int N, M;
int start, dest;
vector<vector<pair<int, int>>> adj;
vector<int> dist;
int get_min_cost() {
priority_queue<pair<int, int>, vector<pair<int, int>>,
greater<pair<int, int>>>
q;
int min_cost = 0;
... | ALGO | 0.999598 | 5.202842 |
5eeaf399-e995-40c8-967f-022879a0a641 | sunbines/boost_demo | boost/libs/compute/perf/perf_bolt_count.cpp | #include <iostream>
#include <algorithm>
#include <vector>
#include <bolt/cl/count.h>
#include <bolt/cl/copy.h>
#include <bolt/cl/device_vector.h>
#include "perf.hpp"
int rand_int()
{
return static_cast<int>((rand() / double(RAND_MAX)) * 25.0);
}
int main(int argc, char *argv[])
{
perf_parse_args(argc, argv... | TOOL | 0.885169 | 4.983783 |
31a140fd-70aa-4546-b129-3769f8f32e9d | virajchandra51/LeetCode | Solved_Question_Set_1/0394-decode-string/0394-decode-string.cpp | class Solution {
public:
string decodeString(string s) {
stack<int> c;
stack<char> w;
int n = s.size();
for(int i=0;i<n;i++)
{
if(s[i]==']')
{
string t ="";
string a ="";
int num = c.top();
... | ALGO | 0.999061 | 5.90882 |
ca203327-654f-4d77-8c69-3f14b1ea4830 | bartosz-czekaj/cpp | codility/abs_numbers_cpp.cpp | // you can also use includes, for example:
#include <algorithm> // std::unique, std::distance
#include <vector> // std::vector
bool myfunction (int i,int j)
{
return (abs(i) < abs(j));
}
bool myfunction2 (int i,int j)
{
return (abs(i) == abs(j));
}
int solution(const std::vector<int> &A)
{
... | ALGO | 0.999739 | 5.196236 |
017ca5d4-176c-4511-a2a8-2717a85becff | zayanahmed04/DSA-Algos-Topic-wise | LinkedLists/Deletions_In_SinglyLL.cpp | #include<iostream>
#include<string>
using namespace std;
class Node {
public:
int data;
Node* next;
Node(int data): data(data), next(nullptr){}
};
class SinglyLL{
public:
void deleteAtHead(Node* &head){
Node* temp = head;
head = head->next;
temp->next = nullptr;
dele... | ALGO | 0.999683 | 4.47074 |
4ca7e143-2417-4a2e-8f40-5fd96f56673e | chinmoy-kumar/DSA-with-CPP | STL-01/map/map.cpp | #include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
// map always keeps unique key value pairs. Key will always unique and sorted.
map<int, int> mp;
mp.insert({10, 20});
// Here 1st one is key(10) and 2nd one is value(20). We can access the... | TOOL | 0.932259 | 4.715495 |
89389365-a3bf-47ba-af3e-ac20faeb04f5 | mohitpandey94/SPOJ-Solutions | spoj/MCOINS/MCOINS-13258724.cpp | #include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <cmath>
#include <bitset>
#include <algorithm>
#ifndef ONLINE_JUDGE
#define gc getchar
#else
#define gc getchar_unlocked
#endif
#define ll long long
#define nl() printf ("\n")
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
... | ALGO | 0.999908 | 3.511048 |
bb5eebc0-afcf-499e-83da-e1da52abea48 | ishandutta2007/codeforces | gediminas/normal/866/A.cpp | /*input
3
*/
#include <bits/stdc++.h>
using namespace std;
int main () {
int a;
cin >> a;
cout << 2 * a - 1 << " 2\n1 2";
return 0;
} | ALGO | 0.997787 | 3.151352 |
cbb0aeb1-1854-4938-b2c1-60a38b6c9fbd | aritra741/Competitive-Programming | UVa/a.cpp | #include <bits/stdc++.h>
using namespace std;
int main()
{
int tc;
cin>>tc;
while(tc--)
{
int a,b,c;
cin>>a>>b>>c;
if( a==7 or b==7 or c==7 )
cout<<"YES\n";
else
cout<<"NO\n";
}
} | ALGO | 0.999027 | 3.715695 |
fd251194-08a4-4c79-861e-e00c4cd9ded1 | YMDragon/OJ-code | codeforces/450/E.cpp | #include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#define LL long long
#define oo (1<<30)
using namespace std;
const int N=100000;
int n,m,prime[N+10],b[N+10],c[N+10],ans;
void pack(int x,int y){b[x]=y,b[y]=x,ans++;}
void work()
{
scanf("%d",&n);
fo... | ALGO | 0.998503 | 3.372307 |
296c4425-ec24-4a32-b283-118544c31589 | albertobarriga/CPP_Modules | CPP_module09/ex02/PmergeMe.cpp | #include "PmergeMe.hpp"
PmergeMe::PmergeMe() {
}
PmergeMe::~PmergeMe() {
}
PmergeMe::PmergeMe(PmergeMe const ©): _vector(copy._vector), _list(copy._list) {
}
PmergeMe &PmergeMe::operator=(PmergeMe const &input) {
if(this != &input)
{
_vector = input._vector;
_list = input._list;
}
return (*this);
}
... | ALGO | 0.996818 | 4.220595 |
6cd9436a-7b1f-4a97-a547-239d043a225c | GunadarmaIO-Community/Weekly-Class | introduction-c++/queue.cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
queue<int> antrian; // deklarasi queue
antrian.push(1); // fungsi push() untuk memasukkan elemen di akhir queue
antrian.push(2);
antrian.push(3);
cout << antrian.front() << endl; // fungsi front() untuk memanggil elemen paling depan queue
... | ALGO | 0.961574 | 4.197237 |
f2d0b79b-552f-4f80-b232-0d023603a0e6 | ung-steven/competitive_programming | dmopc 16 1 p3.cpp | #include <cstdio>
#include <algorithm>
#include <iostream>
#define For(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
using namespace std;
int n;
double bp[10001], pri[10001];
int main(){
scanf("%d", &n);
For(i,0,n){
cin>>pri[i+1];
}
For(i,0,n){
bp[i] = 0x3f3f3f3f;
}
bp[0] = 0;... | ALGO | 0.999847 | 3.394706 |
04706c9c-073b-4e15-a16b-fee7b3587124 | zabir-nabil/Competitive-Programming | LightOJ/Beginners Problems/1109.cpp | #include <bits/stdc++.h>
#define loop(i,s,e) for(int i = s;i<=e;i++) //including end point
#define pb(a) push_back(a)
#define sqr(x) ((x)*(x))
#define CIN ios_base::sync_with_stdio(0); cin.tie(0);
#define ll long long
#define ull unsigned long long
#define SZ(a) int(a.size())
#define read() freopen("inpu... | ALGO | 0.999807 | 4.058804 |
c32e24aa-a405-46f3-892b-590391e05afb | Ornzas/CPPstepik | 1.4/sorting.cpp | #include <iostream>
using namespace std;
int main() {
int a, b, c, swap;
cin >> a >> b >> c;
if(a > b) {
swap = a;
a = b;
b = swap;
}
if(a > c) {
swap = c;
c = a;
a = swap;
}
if(b > c) {
swap = b;
b = c;
c = swap;
}... | ALGO | 0.99979 | 3.738426 |
d0e80f05-2bf5-4e1d-8a3f-ff5c70386596 | yada2x/cppvector | Trie/Trie.cpp | #include <cctype>
#include "Trie.h"
void insertWord(TrieNode* root, const std::string& word) {
TrieNode* curr = root;
for (char ch : word) {
char c = tolower(ch);
if (curr->children[c - 'a'] == nullptr) {
curr->children[c - 'a'] = new TrieNode();
}
curr = curr->chil... | ALGO | 0.99944 | 5.543741 |
771292c6-a19a-4556-98d5-6e5f089d07ca | harryboi17/Tough-Questions | Wavlet_matrix.cpp | #include "bits/stdc++.h"
using namespace std;
struct bit_vector{
vector<unsigned long long> A;
vector<int> S;
bit_vector(){}
bit_vector(vector<bool> &a){
int N = a.size();
int M = (N + 64 - 1) >> 6;
A = vector<unsigned long long>(M, 0);
for (int i = 0; i < M; i++){
for (int j = i << 6; j ... | ALGO | 0.999885 | 4.171741 |
0855b5bf-c7c2-4f6b-b655-2263649e4520 | coderSomya/Competetive-Programming | expert CF sheet/Bonus Problems/guessKthZeroHard_Caching.cpp | /*
problem link->
https://codeforces.com/contest/1520/problem/F2
*/
//caching approach
#include <bits/stdc++.h>
using namespace std;
#define loop(i,l,r) for(int i=l; i<r; i++)
#define int long long
#define pb push_back
#define vi vector<int>
#define mkp make_pair<... | ALGO | 0.999972 | 3.864648 |
0abde75c-f6a5-46ea-9aa1-3302772ad702 | shivanibhat24/CPP-Programs | Leetcode Programs/monotoneincreasingdigits.cpp | class Solution {
public:
int monotoneIncreasingDigits(int N) {
if(N < 10){
return N;
}
string s = to_string(N);
int index = s.length();
int i;
for(i = index -1 ; i > 0; i--){
if(s[i-1] > s[i]){
s[i-1]--;
index = i;
}
}
for(i... | ALGO | 0.999915 | 6.564262 |
5e92de26-2340-419a-b6ea-2d5a15688033 | apetbrz/cs-club-competition-example-solutions | CPPExamples/Month2/app.cpp | /*
* Example Solution for Fall 2024 CS Club Coding Competition Problems Month 2
* ICPC Mid-Atlantic USA 2022 Division 2
* Problem A:
*
* Espresso!
*
*/
#include <string>
#include <iostream>
int main(){
//================Step 0================
//Input and Variables
std::cout << "enter input:" <<... | ALGO | 0.999338 | 4.224771 |
54092acc-3fd4-425b-90d4-9b4cc3353ade | Aayushi4537/100-Days-of-GeeksforGeeks | Difficulty: Medium/Merge two BST 's/merge-two-bst-s.cpp | //{ Driver Code Starts
#include <bits/stdc++.h>
using namespace std;
#define MAX_HEIGHT 100000
// Tree Node
struct Node {
int data;
Node* left;
Node* right;
Node(int val) {
data = val;
left = right = NULL;
}
};
// Function to Build Tree
Node* buildTree(string str) {
// Corner ... | ALGO | 0.999883 | 6.388755 |
52a2fd17-0ebd-483a-a1b7-7005d3470beb | Cobb-Yoo/Algorithms | BOJ/14659/14659.cpp | #include <iostream>
using namespace std;
int arr[30001];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n; cin >> n;
int ans = 0;
for(int i=0;i<n;i++) cin >> arr[i];
for(int i=0;i<n;i++){
int cnt = 0;
for(int j=i+1;j<n;j++){
if(arr[i] > arr[j]) cnt++;
else break;
}
ans = max(... | ALGO | 0.999889 | 3.869527 |
8674ba8d-8d4a-47a0-8896-f2fd8375080f | RaulCodando/Teoria-dos-Grafos | Algoritmos Oficiais/Floyd-Warshall/Floyd-Warshall.cpp | #include "Graph.hpp"
#include <climits>
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
vector<vector<int>> FloydWarshall(Graph g){
vector<vector<int>> D = g.getW();
int n = g.getN();
for(int k = 0; k < n; k++){
for(int i = 0; i < n; i++){
for(int j = 0; ... | ALGO | 0.999452 | 5.145031 |
c78f9833-e911-49a0-812d-8fa06c4f9d87 | TheAwesome98-Real/sourcesdk | sp/src/utils/vbsp/csg.cpp | #include "vbsp.h"
/*
tag all brushes with original contents
brushes may contain multiple contents
there will be no brush overlap after csg phase
each side has a count of the other sides it splits
the best split will be the one that minimizes the total split counts
of all remaining sides
precalc side on plane table... | ALGO | 0.993936 | 5.036877 |
1874387c-53d7-4c38-9a53-ee247a3a111c | monellz/oop | ObjRanking/Ranking.cpp | #include "Ranking.h"
#include <utility>
#include <vector>
void Ranking::pushData(BaseObject* _object){
rankings.push_back(_object);
}
void Ranking::sort(SortStrategy* _strategy){
_strategy->work(this);
}
void RDSortStrategy::work(Ranking* _rank){
int num = _rank->rankings.size();
std::vector<const Date*> t... | ALGO | 0.96022 | 4.341295 |
547fd575-b5ae-4329-9dc7-74721189f49f | harsh0620/DSA450 | Graph/graph27.cpp | #include <bits/stdc++.h>
using namespace std;
// } Driver Code Ends
class Solution
{
public:
// Function to find number of strongly connected components in the graph.
void topoLogicalDFS(int node, vector<int> adj[], vector<int> &vis, stack<int> &st)
{
vis[node] = 1;
for (auto it : adj[nod... | ALGO | 0.999937 | 6.133952 |
92c2250f-4a2b-4b59-aef1-40f725803528 | niharhEAVR/Cpp-codes | day-2/code/04_wiredIntType.cpp | #include <iostream>
int main()
{
short int var1{10}; // 2 bytes
short int var2{20};
char var3{40}; // 1 bytes
char var4{50};
std::cout << "size of var1 : " << sizeof(var1) << std::endl;
std::cout << "size of var2 : " << sizeof(var2) << std::endl;
std::cout << "size of var3 : " << sizeof(var3) << std::endl;
... | TOOL | 0.960649 | 3.563221 |
a31911d6-7dd0-402c-a391-f02cd5131341 | luv050/dsa-practice | MorrisPreorderBT.cpp | #include <bits/stdc++.h>
using namespace std;
// TreeNode structure
struct TreeNode {
int val;
TreeNode *left;
TreeNode *right;
TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
};
class Solution {
public:
// Function to perform iterative Morris
// preorder traversal of a binary tree
... | ALGO | 0.999996 | 6.953769 |
682ce45d-188c-4b89-83a3-89f0da966fce | Chaste/Old-Chaste-svn-mirror | crypt/src/boundary_conditions/CryptSimulationBoundaryCondition.cpp | #include "CryptSimulationBoundaryCondition.hpp"
#include "WntConcentration.hpp"
#include "AbstractCentreBasedCellPopulation.hpp"
#include "RandomNumberGenerator.hpp"
#include "StemCellProliferativeType.hpp"
template<unsigned DIM>
CryptSimulationBoundaryCondition<DIM>::CryptSimulationBoundaryCondition(AbstractCellPopul... | ALGO | 0.992971 | 7.534367 |
2929057a-aace-4e9a-9dee-731b3c9efb4b | WJ-self/algorithm | .history/acwing/basic/basic/845_八数码_20230624112354.cpp | #include<bits/stdc++.h>
using namespace std;
char ch;
string st;
unordered_map<string, int> dis;
int dx[4] = {-1,0,1,0}, dy[4]={0,-1,0,1};
void bfs(){
queue<string> qu;
qu.push(st);
dis[st] = 0;
while(qu.size()) {
string t = qu.front();
qu.pop();
int x = t.
}
}
int main()... | ALGO | 0.999609 | 3.461746 |
0ef78aa7-a81a-4f61-a963-08cbd9a77f69 | JosephAlves0/compras_flutter | 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 |
86a36b00-19c4-44d8-9000-eef4f289852b | Akshayp001/LeetSolutions | 141-linked-list-cycle/linked-list-cycle.cpp | /**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
bool hasCycle(ListNode *head) {
// Floyd Cycle Detection
if(head==NULL||head->next==NULL) return false;
Lis... | ALGO | 0.999812 | 5.168844 |
353a14de-e591-4faa-bcfa-b3324ddb84a2 | cudy789/MAPLE | lib/allwpilib/wpimath/src/test/native/cpp/DARETest_Inst_2x1.cpp | #include "frc/DARE.h"
template wpi::expected<Eigen::Matrix<double, 2, 2>, frc::DAREError>
frc::DARE<2, 1>(const Eigen::Matrix<double, 2, 2>& A,
const Eigen::Matrix<double, 2, 1>& B,
const Eigen::Matrix<double, 2, 2>& Q,
const Eigen::Matrix<double, 1, 1>& R, bool checkPre... | ALGO | 0.98989 | 6.759099 |
20c81bac-3f2f-4363-9a72-8c8d5860206d | Subzero-10/leetcode | .history/138.copy-list-with-random-pointer_20200907111455.cpp | /*
* @lc app=leetcode id=138 lang=cpp
*
* [138] Copy List with Random Pointer
*/
// @lc code=start
/*
// Definition for a Node.
class Node {
public:
int val;
Node* next;
Node* random;
Node(int _val) {
val = _val;
next = NULL;
random = NULL;
}
};
*/
class Solution {... | ALGO | 0.989906 | 4.978015 |
2b6b0e79-aad3-4b42-94f9-e404a3e70193 | jcmaes12333/Graphs-2 | adjacency_list.cpp | //NAME: JC Maes
// FILE: adjacency_list.cpp
// DATE: Spring 2021
// DESC: Adjacency list implementation of the graph interface
#ifndef ADJACENCY_LIST_CPP
#define ADJACENCY_LIST_CPP
#include "adjacency_list.h"
#include <iostream>
AdjacencyList::AdjacencyList(int vertex_count)
: number_of_vertices(vertex_count)
{
... | ALGO | 0.958498 | 6.505641 |
37e96b0a-5a71-4223-8188-15fe3e34f091 | psk001/Leetcode-Problems | 876-middle-of-the-linked-list/876-middle-of-the-linked-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 {
public:
ListNode* middleNode... | ALGO | 0.999893 | 5.842634 |
236c33e3-f4f4-4f8d-9f11-489f7abcd328 | xMOROx/Parallel-Programming-Methods | CUDA/lab2/4 Atomic Operations/reduction.cpp | #include <cstdio>
#include <cstdlib>
#include <vector>
#include <fstream>
#include <iostream>
#include <cmath> // For fabsf
#include <cuda_runtime.h>
#include "/content/helper_timer.h"
#include "/content/reduction.h"
struct BenchmarkResult {
float elapsed_time_ms;
float bandwidth_GBs;
};
// Function Prototy... | TOOL | 0.911927 | 6.303067 |
88b6ec7c-3d5b-40ea-801b-516069ca8d79 | lewissbaker/llvm | llvm/lib/CodeGen/LiveInterval.cpp | #include "llvm/CodeGen/LiveInterval.h"
#include "LiveRangeUtils.h"
#include "RegisterCoalescer.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/CodeGen/LiveIntervals.h"
#include "llvm... | TOOL | 0.996966 | 7.940732 |
987357f3-45bf-4800-8053-f60616547d39 | MJHamar/urss | oink/src/tools/nudge.cpp | #include <algorithm>
#include <iostream>
#include <fstream>
#include <random>
#include "cxxopts.hpp"
#include "game.hpp"
using namespace std;
using namespace pg;
int
rng(int low, int high)
{
static random_device rand_dev;
static mt19937 generator(rand_dev());
return uniform_int_distribution<int>(low, hig... | ALGO | 0.999915 | 4.834007 |
da43575d-2e04-4038-a22a-e82dd12b114d | mikhaeljonathan/online-judges | TLX/INC/INC 2020/REAL/F.cpp | #include <iostream>
using namespace std;
int main (){
int n, k;
cin >> n >> k;
string s;
cin >> s;
int left = 0;
int right = k - 1;
int container[30] = {0};
int maxx = 0;
for (int i = left; i <= right; i++){
int alphabet = s[i] - 'A';
container[alphabet]++;
if (container[alphabet] > maxx) {
maxx = co... | ALGO | 0.999966 | 3.94632 |
f6539d42-0827-45ae-8120-207801e1c9f7 | Adi3220/Data_Structures_and_Algorithms | Two Sum.cpp | // Two Sum
#include<bits/stdc++.h>
vector<pair<int,int>> twoSum(vector<int>& arr, int target, int n)
{
// Write your code here.
vector<pair<int,int>>a;
sort(arr.begin(),arr.end());
int s=0,e=arr.size()-1;
while(s<e){
if(arr[s]+arr[e]<target){
s++;
}
else if(arr[s]+arr[e]>target){
e--;
}
else if(a... | ALGO | 0.999935 | 5.821595 |
7df8da5e-56bb-40cf-b884-d3121dd334c7 | natural-jogi/af-algorithm | cpp/solved.ac/class/02/2869_snail-wants-to-go-up.cpp | #include <iostream>
#include <cmath>
using namespace std;
int main() {
cin.tie(NULL);
ios::sync_with_stdio(false);
double a, b, v;
cin >> a >> b >> v;
cout << (int)ceil((v-a)/(a-b))+1;
return 0;
} | ALGO | 0.999352 | 3.410689 |
59fcbe62-9874-4597-a149-88a52eb307e5 | morris821028/hw-BigData | program/Minhash/testinput/test_example/test.cpp | #include <bits/stdc++.h>
using namespace std;
vector< pair<int, string> > A;
vector< pair<int, vector<string> > > B;
int main(int argc, char* argv[]) {
assert(argc == 3);
fstream fin1(argv[1]), fin2(argv[2]);
string line;
while (getline(fin1, line)) {
for (int i = 0; i < line.length(); i++) {
... | ALGO | 0.992468 | 4.118169 |
8c0c74e3-8b93-429f-8f0c-59a6c69a65ec | sky-bro/AC | codeforces.com/Round 701 (Div. 2)/C/main.cpp | // =========== Template ========== //
#include <bits/stdc++.h>
using namespace std;
int __fastio = []() { ios_base::sync_with_stdio(false); cout << fixed << setprecision(10); cin.tie(nullptr); return 0; } ();
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p);
template<typename A> os... | ALGO | 0.999811 | 5.082224 |
6328f119-25f9-48bb-b057-2b6d5c690288 | Amar6de2/GeeksForGeeks | Difficulty: Medium/Search Pattern (KMP-Algorithm)/search-pattern-kmpalgorithm.cpp | //{ Driver Code Starts
#include <bits/stdc++.h>
using namespace std;
// } Driver Code Ends
class Solution {
public:
vector<int> search(string& pat, string& txt) {
// code here
//LPS is made for pattern!
int m=pat.size();
vector<int> LPS(m,0);
int j=1;
int len=0;
... | ALGO | 0.999249 | 6.392824 |
f76623a3-0824-4092-9999-92d3c5ace2a7 | srvvrma/My_c_codes | Chef and Strings/src/Chef and Strings.cpp | #include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
using namespace std;
int track[4][1000001];
int readint()
{
int cc = getc(stdin);
for (;cc < '0' || cc > '9';) cc = getc(stdin);
int ret = 0;
for (;cc >= '0' && cc <= '9';)
{
ret = ret * 10 + cc - '0';
cc = getc(stdin);
}
return ... | ALGO | 0.999381 | 3.43093 |
60d19221-0cca-475b-816f-57e9235cd6a1 | krishnashah122/DSA-Practice | 18. Dynamic Programming/5. Matrix Chain Multiplication (MCM)/Palindrome-Partitioning-II.cpp | // Palindrome Partitioning II (Leetcode)
// Leetcode Link : https://leetcode.com/problems/palindrome-partitioning-ii/description/
// Time Complexity : O(n^3)
// Space Complexity : O(n)
class Solution {
public:
// Function to check if substring s[i..j] is a palindrome or not
bool isPalindrome(string &s, int i,... | ALGO | 0.999986 | 6.587283 |
75e41954-b2cf-4537-856c-6637f00a3240 | plumonito/dtslam | 3rdparty/eigen-3.2.2/demos/mandelbrot/mandelbrot.cpp | #include "mandelbrot.h"
#include <iostream>
#include<QtGui/QPainter>
#include<QtGui/QImage>
#include<QtGui/QMouseEvent>
#include<QtCore/QTime>
void MandelbrotWidget::resizeEvent(QResizeEvent *)
{
if(size < width() * height())
{
std::cout << "reallocate buffer" << std::endl;
size = width() * height();
i... | ALGO | 0.854665 | 5.79494 |
cd5a2a72-09ff-4d5a-8472-cb6a6278a147 | ishandutta2007/codeforces | krk/normal/626/E.cpp | #include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair <int, int> ii;
typedef long long ll;
const int Maxn = 200005;
struct frac {
ll a, b;
frac(ll a = 0, ll b = 1): a(a), b(b) { }
bool operator >(const frac &u) const {
return a * u.b > u.a * b;
}
};
int n;
int x[Maxn];
ll ... | ALGO | 0.999996 | 3.681248 |
4139b3b3-9b5a-4a78-96bb-81941c1f9ad7 | maddieprasun17/CS210-FinalProject | BST/main.cpp | #include <iostream>
#include "queue"
using namespace std;
template<typename T>
struct TreeNode {
T data;
TreeNode* left;
TreeNode* right;
TreeNode(T val) : data(val), left(nullptr), right(nullptr) {}
};
template<typename T>
class BinarySearchTree {
private:
TreeNode<T>* root;
public:
BinaryS... | ALGO | 0.999847 | 6.240255 |
45a3ffc7-adf3-4990-ae41-ca742fbe299d | ishandutta2007/codeforces | hanbyeol_/normal/1338/D.cpp | #include<bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false); cin.tie(0);
int N; cin >> N;
vector<vector<int>> conn(N);
for(int i=0; i<N-1; ++i)
{
int u, v; cin >> u >> v; --u; --v;
conn[u].push_back(v); conn[v].push_back(u);
}
map<pair<int, int>, pair<int, int>> M;
vector<multiset... | ALGO | 0.999618 | 4.117044 |
9f8ac7e4-770a-4fbb-9135-0403254f6b1a | CSerxzm/datastructure-hfut | 试验一 顺序表/试验一.cpp | #include<stdio.h>
#include<stdlib.h>
#include<iostream>
using namespace std;
#include "seqList.h"
int inter()
{
int x;
printf(" <1>˳еiԪأڣ\n");
printf(" <2>ڵiǰֵΪxĽ㡣\n");
printf(" <3>ɾ˳еiԪؽ㡣\n");
printf(" <4>һ˳LвһֵΪxԪأԡ\n");
printf(" <5>˳еżֽԪֵΪżֱµ˳УȻԭ±ԪͬʱĻϣԱ\n");
printf(" <6>˳L1L2еĹԪأµ˳L3С\n");
printf(" <7>ɾ˳еظԪ... | ALGO | 0.999542 | 3.239853 |
29e50eea-42b3-4c45-ba4e-a75c6118b5f1 | ghts2110/competitive_programing | kattis/Popular Vote/Popular_Vote.cpp | #include <iostream>
using namespace std;
int main(){
int t;
cin >> t;
while(t--){
int n;
cin >> n;
int mx = -1, c, cont = 0;
for(int i = 0; i != n; i++){
int num;
cin >> num;
cont += num;
if(num >= mx){
... | ALGO | 0.999993 | 4.195934 |
cceca4e3-9f04-45d3-be61-79cacc7e4c35 | antdkfa/LeetCode-Challenge | 2022/August/18-Reduce Array Size to The Half.cpp | class Solution {
public:
int minSetSize(vector<int>& arr) {
int cnt[100005] = {};
for(int i=0;i<arr.size();i++) {
cnt[arr[i]]++;
}
sort(cnt, cnt+100005);
int erased = 0,ans=0;
for(int i=100004;i>=0;i--) {
erased+= cnt[i];
i... | ALGO | 0.999926 | 5.560625 |
2f34afef-8f07-412b-9aba-dbae5d8666a4 | Aquibshams786/Leetcode | 2359-find-closest-node-to-given-two-nodes/2359-find-closest-node-to-given-two-nodes.cpp | class Solution {
public:
void bfs(int src, vector<vector<int>>& adj, vector<int>& dist) {
queue<int>q;
vector<int>vis(adj.size(), 0);
dist[src] = 0;
q.push(src);
while(!q.empty()) {
auto node = q.front();
vis[node] = 1;
q.pop();
... | ALGO | 0.999987 | 5.555083 |
b1cefa92-eaad-421a-91f0-1c0c2887d111 | divyang9575/CP | implementation/Crushed_Apples_and_a_Balance_Scale.cpp | #include<bits/stdc++.h>
using namespace std;
#define PI 3.1415926535897932384626433832795
#define endl '\n'
#define int long long int
#define vi vector<int>
#define sort(a,all) sort(a.begin(), a.end())
#define vpi vector<pair<int,int>>
#define pb push_back
#define pi pair<int,int>
#define ff first
#define ss second
#d... | ALGO | 0.999892 | 5.369625 |
3f55709b-e323-4401-bdde-3cff5976cc59 | vishalsalgond/DSA | Graph/prims.cpp | #include<bits/stdc++.h>
using namespace std;
#define lp0(i,n) for(i=0;i<n;i++)
#define lp1(i,n) for(i=1;i<=n;i++)
#define lpr(i,n) for(i=n-1;i>=0;i--)
#define ll long long
#define nl "\n"
#define gcd __gcd
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0... | ALGO | 0.999936 | 4.544572 |
8bc58ca5-9940-4fb9-abb1-48ced8616aa0 | DenizIsikli/LeetCode-CPP | Problemsets/Problems/MoveZeroes.cpp | #include <vector>
class Solution {
public:
void moveZeroes(std::vector<int>& nums) {
std::vector<int> temp;
for(int i=0;i<nums.size();i++)
{
if(nums[i]!=0)
{
temp.push_back(nums[i]);
}
}
for(int i=temp.size();i<nums.size()... | ALGO | 0.999627 | 6.251214 |
d1a229cd-e070-4b24-8a1f-bf060e485252 | gerner/cvc | src/sarsa/sarsa_action_factories.cpp | #include <algorithm>
#include <vector>
#include <cassert>
#include <random>
#include <limits>
#include <cmath>
#include <cstring>
#include <memory>
#include "../core.h"
#include "../action.h"
#include "sarsa_learner.h"
#include "sarsa_action_factories.h"
namespace cvc::sarsa {
std::unique_ptr<Experience> EpsilonGree... | ALGO | 0.992264 | 6.626187 |
fb933037-f83b-4875-98e9-3564fec43776 | trevormatuszyk/cs375finalproject | main.cpp | #include <iostream>
#include <fstream>
#include <vector>
#include <cmath>
#include "HTHeader.h"
HashTable::HashTable(int b, int hash_method, int coll_res){
this->buckets = b;
table = new list<string>[buckets];
this->hash_method = hash_method;
this->coll_res = coll_res;
this->linear_mod_collisions = 0;
this->qua... | ALGO | 0.998244 | 4.278982 |
a3ba795c-8496-45dc-8a48-ba7c5c5c1182 | eshohag/leetcode | solution/1400-1499/1432.Max Difference You Can Get From Changing an Integer/Solution.cpp | class Solution {
public:
int maxDiff(int num) {
auto replace = [](string& s, char a, char b) {
for (auto& c : s) {
if (c == a) {
c = b;
}
}
};
string a = to_string(num);
string b = a;
for (int i = 0; ... | ALGO | 0.999804 | 5.870156 |
df67e2fc-3213-4699-911e-20f11a735713 | ishandutta2007/codeforces | sd0061/normal/234/G.cpp | #include <stdio.h>
#include <string.h>
#define N 1005
int n;
int ans[15][N];
void work(int d,int l,int r)
{
if (l == r)
return;
int m = (l + r) >> 1;
for (int i = l ; i <= m ;i ++)
ans[d][++ ans[d][0]] = i;
work(d + 1 , l , m);
work(d + 1 , m + 1 , r);
}
int main()
{
freopen("input.txt","r",... | ALGO | 0.99996 | 3.588311 |
3c433f6d-3674-4338-b2d5-5b9f5f2c9ce3 | zouyajing/FLVIS | 3rdPartLib/eigen-3.4-rc1/doc/special_examples/Tutorial_sparse_example_details.cpp | #include <Eigen/Sparse>
#include <vector>
#include <QImage>
typedef Eigen::SparseMatrix<double> SpMat; // declares a column-major sparse matrix type of double
typedef Eigen::Triplet<double> T;
void insertCoefficient(int id, int i, int j, double w, std::vector<T>& coeffs,
Eigen::VectorXd& b, con... | ALGO | 0.998923 | 5.388735 |
707d3e66-693b-4181-a8d2-dfa3516c156d | DrJamali/C- | negin.cpp | #include<iostream>
using namespace std;
int main (){
int n;
do
{
cin>>n;
cout<<n<<endl;
}
while (n >0);
{
}
return 0;
} | ALGO | 0.99714 | 3.03531 |
5bded2cd-b0c5-4fe5-994b-3d7b658bd161 | ishandutta2007/codeforces | kotatsugame/normal/1250/C.cpp | #include<iostream>
#include<algorithm>
using namespace std;
int T,N,A[100];
main()
{
cin>>T;
for(;T--;)
{
cin>>N;
for(int i=0;i<N;i++)cin>>A[i];
bool fn=false;
sort(A,A+N);
for(int i=1;i<N;i++)if(A[i-1]+1==A[i])fn=true;
puts(fn?"2":"1");
}
} | ALGO | 0.999422 | 3.557084 |
1d3be9de-4ea3-4644-af89-fd9d00fba1d7 | Murasya/atcoder | abc115/abc115c.cpp | #include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,j,k) for(int i=j; i<k; i++)
int main() {
int n,k;
cin >> n >> k;
vector<int> h(n);
REP(i,0,n) {
cin >> h[i];
}
sort(h.begin(), h.end());
int _min = 1e9;
REP(i,0,n-k+1) {
int hmax = h[i+k-1];
int hmin = h[i];
... | ALGO | 0.999946 | 3.735494 |
3effa7ac-fce9-4021-8581-e5431710968a | bear-zd/sj-Structure-origin-code- | Brute-Force/TestBruteForce.cpp |
#include "Brute-Force.h"
int main(void)
{ // ʽַģʽƥ㷨
String ob("this is a string");
String pat("is");
cout << "Ϊ" ;
Write(ob);
cout << "ӴΪ" ;
Write(pat);
cout << endl << "ʼλã0ַģʽ" ;
cout << BF_find(ob, pat) << endl;
cout << endl << "3ַʼģʽ" ;
cout << BF_find(ob, pat, 3) << endl;
pat="string";
cout << end... | ALGO | 0.998621 | 3.892633 |
9b968950-af6b-43cd-8d0d-3c9240edd8e3 | techboy-s/Code | 377-combination-sum-iv/377-combination-sum-iv.cpp | class Solution {
public:
int combinationSum4(vector<int>& N, int T) {
vector<unsigned int> dp(T+1, 0);
dp[0] = 1;
for (int i = 0; i < T; i++) {
if (!dp[i]) continue;
for (int num : N)
if (num + i <= T) dp[i+num] += dp[i];
}
return dp[T]... | ALGO | 0.99992 | 6.79933 |
71d41a38-5faf-4bde-acab-85367e64ca65 | raincross7/code-similarity | codes/train_code/problem288/problem288_481.cpp | #include<bits/stdc++.h>
using namespace std;
int main() {
int n, i;
long long same;
same = 0;
cin >> n;
vector<int> tall(n);
for(i=0;i<n;i++) {
cin >> tall.at(i);
}
for(i=0;i<n-1;i++) {
if(tall.at(i) > tall.at(i+1)) {
same += tall.at(i) - tall.at(i+1);
tall.at(i+1) = tall.at(i);
... | ALGO | 0.999956 | 3.636998 |
101e0e6c-6817-441c-9567-d1e3592d6fae | Rudolf-Gama/Striver-A2Z_DSASheet | Graphs/Topological sort/Kahnalgo.cpp | #include <bits/stdc++.h>
using namespace std;
class Solution {
public:
vector<int> topoSort(int V, vector<int> adj[]) {
vector<int> indegree(V, 0); // Array to store the in-degree of each node
queue<int> q; // Queue to store nodes with in-degree 0
vector<int> ans; // Vector to store the ... | ALGO | 1 | 6.683635 |
5897949a-16c0-48ad-8527-b97558e3d192 | alligatorYE/studyLinuxC | CppInOneHourAday9thEdt/7.5 Functions_Recursive_Fibonacci.cpp | #include <iostream>
using namespace std;
int GetFibNumber(int fibIndex)
{
if (fibIndex < 2)
return fibIndex;
else // recursion if fibIndex >= 2
return GetFibNumber(fibIndex - 1) + GetFibNumber(fibIndex - 2);
}
int main()
{
cout << "Enter 0-based index of desired Fibonacci Number: ";
int index ... | ALGO | 0.998919 | 5.453431 |
3656562a-8bf7-4008-83ea-bb79f8f83ba1 | WYK15/swift-Ollvm12 | libcxx/test/std/algorithms/alg.sorting/alg.min.max/max.pass.cpp | // <algorithm>
// template<LessThanComparable T>
// const T&
// max(const T& a, const T& b);
#include <algorithm>
#include <cassert>
#include "test_macros.h"
template <class T>
void
test(const T& a, const T& b, const T& x)
{
assert(&std::max(a, b) == &x);
}
int main(int, char**)
{
{
int x = 0;
... | TEST | 0.923127 | 5.800577 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.