uuid string | repo_name string | relative_path string | content string | category string | algo_rel_score float64 | quality_score float64 |
|---|---|---|---|---|---|---|
a511703e-37cb-45e5-857d-e5cde36cb7a7 | shajayb/alice_viewer_2017 | ALICE_PLATFORM/src/igl/per_vertex_attribute_smoothing.cpp | template <typename DerivedV, typename DerivedF>
IGL_INLINE void igl::per_vertex_attribute_smoothing(
const Eigen::PlainObjectBase<DerivedV>& Ain,
const Eigen::PlainObjectBase<DerivedF>& F,
Eigen::PlainObjectBase<DerivedV> & Aout)
{
std::vector<double> denominator(Ain.rows(), 0);
Aout = DerivedV::Zer... | ALGO | 0.993373 | 4.760436 |
2c1fc0c4-e7ff-475a-9a95-2bd11c6fe048 | ReiAccept/Algorithm | cf/1472C_Long_Jumps.cpp | #include<bits/stdc++.h>
#define int long long//__int128
#define mmst0(x) memset(x,0,sizeof(x))
#define mmst3f(x) memset(x,0x3f,sizeof(x))
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define mkp(x, y) make_pair(x, y)
#define fi first
#define se second
using namespace std;
typedef unsigned long long ull;
typ... | ALGO | 0.999742 | 3.639202 |
dbc06630-a1d1-419a-a320-d73c39ae51b9 | ankurkharb/Leetcode | 13-roman-to-integer/roman-to-integer.cpp | class Solution {
public:
int romanToInt(string s) {
unordered_map<char,int> mp;
mp['I'] = 1;
mp['V'] = 5;
mp['X'] = 10;
mp['L'] = 50;
mp['C'] = 100;
mp['D'] = 500;
mp['M'] = 1000;
int n = s.size();
int i=n-2;
int ans =mp[s[n-1]];
while(i>=0)
{
... | ALGO | 0.999856 | 6.219935 |
c7b6d460-2db8-47ee-99a4-2630310b7795 | ali10129/gem5FScim | src/systemc/tests/systemc/misc/cae_test/general/control/loop/while_fsm/while_fsm.cpp | /*****************************************************************************
while_fsm.cpp --
Original Author: Rocco Jonack, Synopsys, Inc., 1999-07-29
*****************************************************************************/
/****************************************************************************... | ALGO | 0.984224 | 3.464247 |
a0c78590-b49b-430c-9215-ada572657304 | URSec/SVA-Compiler | llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp | #include "llvm/CodeGen/GlobalISel/IRTranslator.h"
#include "llvm/ADT/PostOrderIterator.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Analysis/BranchProbabilityInfo.h"
#include "llvm/Analysis/OptimizationRemarkEmitter.h"... | TOOL | 0.936539 | 6.658412 |
4be9912a-f438-481b-9b3a-cd3cea87567f | Chandan017/Coder-s-Byte | 1004-max-consecutive-ones-iii/1004-max-consecutive-ones-iii.cpp | class Solution {
public:
int longestOnes(vector<int>& nums, int k) {
int prev = 0 , maxLen = 0 , zeroCnt = 0 , n = nums.size();
for(int i=0;i<n;i++)
{
if(nums[i] == 0)
zeroCnt++;
while(zeroCnt > k)
{
i... | ALGO | 0.999983 | 6.207677 |
88b89a93-b0f5-439e-9177-9a97f0d7d6fa | liangbbb/DOM_LOD | DOM_LOD/Simplification.cpp | #include "Simplification.h"
#include <fstream>
#include <iostream>
#include "Point.h"
#include <set>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include "Face.h"
#include <osgDB/ReadFile>
#include <osgDB/FileNameUtils>
#include <osgDB/FileUtils>
#include <osgDB/WriteFile>
#include <osg/Texture2D>
#include <... | ALGO | 0.986122 | 3.694923 |
ce51016d-aa01-4675-a540-007e4b2c5371 | ishandutta2007/codeforces | sonechko/normal/1000/D.cpp | #include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod %MOD
const int N = 1e5 + 11;
const int MOD = 998244353;
ll dp[N],fac[N],unfac[N],a[N];
ll step(ll x, ll y)
{
if (y==0) return 1;
if (y%2==1) return (x*step(x,y-1))mod;
ll p=step(x,y/2);
return (p*p)mod;
}
ll c(ll x, ll y)... | ALGO | 0.999984 | 4.394702 |
42065c58-988f-46a2-a390-516eda8e6b13 | VagrantTrack149/Programas-simples-c- | E15p49N_6A_20.cpp | /*Nombre del Programa: Calculo del area, perimetro y altura de un triangulo equilatero
Elabor: Neil Otniel Moreno Rivera No Lista: 20
Fecha: 3/10/2020
Descripcin: Problema PROGRAMA QUE CALCULA el area, perimetro y altura*/
#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include <math.h>
int main... | ALGO | 0.999352 | 3.400614 |
9cd62cec-70f2-4daa-887a-233b5986e3b8 | NXROBO/spark_humble | src/spark_app/spark_slam/slam_gmapping/openslam_gmapping/particlefilter/particlefilter_test.cpp | #include <stdlib.h>
#include <iostream>
#include <fstream>
#include "particlefilter.h"
using namespace std;
#define test(s) {cout << s << " " << flush;}
#define testOk() {cout << "OK" << endl;}
struct Particle{
double p;
double w;
inline operator double() const {return w;}
inline void setWeight(double _w) {w=_w... | ALGO | 0.9987 | 4.028717 |
966af38c-b3ed-48a0-a31a-1496e198d605 | g3x-gauransh/Competitive_Programming | cpp/BST.cpp | #include<bits/stdc++.h>
using namespace std;
struct node{
int data;
node* left;
node* right;
};
node * createNewNode(int item){
node * newNode = new node();
newNode->data = item;
newNode->left=NULL;
newNode->right = NULL;
return newNode;
}
node* insert(node* root,int item){
if(roo... | ALGO | 0.999943 | 4.246678 |
f4d05e2a-1232-4b3b-b571-374a071aae88 | upul/CarND-Capstone | ros/src/waypoint_follower/src/pure_pursuit.cpp | #include "pure_pursuit_core.h"
constexpr int LOOP_RATE = 30; //processing frequency
int main(int argc, char **argv)
{
// set up ros
ros::init(argc, argv, "pure_pursuit");
ros::NodeHandle nh;
ros::NodeHandle private_nh("~");
bool linear_interpolate_mode;
private_nh.param("linear_interpolate_mode", linea... | ALGO | 0.942994 | 4.900043 |
315abecc-d04e-43e5-9c84-d1548d4426cb | MicaelTargino/C_PLUS_PLUS | projects/soccer_championship/src/time_futebol.cpp | #include <string>
#include <memory>
#include <vector>
#include "time_futebol.h"
#include "tecnico.h"
#include "jogador.h"
using std::string;
using std::vector;
using std::shared_ptr;
using std::cout;
using std::endl;
const int PONTUACAO_VITORIA = 3;
const int PONTUACAO_EMPATE = 1;
const int PONTUACAO_DERROTA = 0;
/... | TOOL | 0.881388 | 6.233302 |
04d265db-d948-4eed-8874-e12acddf4b9b | ishandutta2007/codeforces | nuip/normal/717/G.cpp | #include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(... | ALGO | 0.999989 | 4.468562 |
57f3ea1a-d469-4e06-a9cb-5e056c3212ba | alamkhaan/ProgrammingResources | SegmentSeive.cpp | /*
Author: Alam Khan
AUST CSE 40th Batch
*/
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<ll,null_type,less_equal<ll>,r... | ALGO | 0.999839 | 3.630568 |
867d7e48-8d06-4dcf-9a50-0b5c1e9bfee6 | argyrosan/llvm-hy546 | libc/src/math/generic/ldexpf16.cpp | #include "src/math/ldexpf16.h"
#include "src/__support/FPUtil/ManipulationFunctions.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(float16, ldexpf16, (float16 x, int exp)) {
return fputil::ldexp(x, exp);
}
} // namespace LIBC_NAMESPA... | ALGO | 0.900468 | 6.394883 |
1dbc682b-da20-4493-ae1a-4134fb1e8ff3 | shishirRsiam/CSE-Fundamentals-With-Phitron | 3. Data Stracture/Module 9, Dubly Linked List/2.insert_pos.cpp | #include <bits/stdc++.h>
using namespace std;
class Node
{
public:
int val;
Node *next;
Node *prev;
Node(int val)
{
this->val = val;
this->next = NULL;
this->prev = NULL;
}
};
void insert_tail(Node *&head, Node *&tail, int val)
{
Node *newNode = new Node(val);
i... | ALGO | 0.999886 | 4.338562 |
8674fc31-cdfc-4bdc-83c8-6d875ba4d0f4 | Enolaalone/Sefl_C_Plus | 2024-3-31/strcspn.cpp | #include <string.h>
#include <stdint.h>
#include <libc-pointer-arith.h>
#undef strcspn
#ifndef STRCSPN
# define STRCSPN strcspn
#endif
/* Return the length of the maximum initial segment of S
which contains no characters from REJECT. */
size_t
STRCSPN (const char *str, const char *reject)//检索字符串 str 开头连续有几个字符都不含... | ALGO | 0.999486 | 5.765623 |
e6626571-dcd9-44b1-9089-f0081ea5e13c | TranDucKhiem14082005/studyC | so_SMITH.cpp | #include <stdio.h>
#include <math.h>
int tinhtong(int n){
int kq = 0;
for(int i = 1; i<=n;i++){
kq += n%10;
n/=10;
}
return kq;
}
int smith(int n){
int sum1 = tinhtong(n); // tinh tong cac chu so n
int sum2=0; //tinh tong cac thua so cua cac thua so nguyen to cua n
int temp = n;
for(int i = 2;i<=sqrt(n);i... | ALGO | 0.999952 | 5.037635 |
27766659-84a7-489f-b6c0-030935f7dcbd | tanveer-98/DSA_solved_questions | RandomlySolved/counting sort for charcters.cpp | #include<bits/stdc++.h>
#define RANGE 255
using namespace std;
void countingSort(string s, char b[], int n)
{
int i;
int count[RANGE +1];
memset(count, 0, sizeof(count));
for( i = 0; i< n; i++)
{
count[s[i]] = count[s[i]] + 1;
}
for(i = 1; i<RANGE; i++)
{
count[i] = co... | ALGO | 0.999821 | 4.439843 |
156dc4ce-42b7-43e2-a20c-cee2c540460f | A-aman123/DSA-main | Detailed Debugging Exercise Solution/Supreme-Batch-Debug-Exercise-C++ (Week-2)/4.cpp | // In Line-12, there were 2 spaces printing at a time but we just one space so I correct it to cout<<" " instead of cout<<" "; (Corrected Line - 12)
// In Line - 15, the formulae for finding stars in each row was incorrected and the corrected formulae would be 2*size - 2*i - 1 instead of 2*size - 1 (Corrected line - 1... | ALGO | 0.999843 | 4.892361 |
c0d2c2a4-86d0-4ae5-b75d-b8a39a24f0a9 | sunnyajit/My_Leetcode_sol | 3496-minimum-number-of-seconds-to-make-mountain-height-zero/3496-minimum-number-of-seconds-to-make-mountain-height-zero.cpp | class Solution {
public: // code written by sunny
long long minNumberOfSeconds(int mountainHeight, vector<int>& workerTimes) {
int n = workerTimes.size();
long long left = 0, right = 1e18;
while (left < right) {
long long mid = left + (right - left) / 2;
long long totalReduced = 0... | ALGO | 0.999997 | 5.611059 |
c4101503-0382-45ea-823a-a0ae2faf2d20 | ahmed-elsakka/algorithms | courses-schedule/c++/courses-schedule.cpp | #include <iostream>
#include <vector>
using namespace std;
#include <iostream>
#include <vector>
#include <map>
using namespace std;
bool isCyclic(int courseId, map<int, vector<int>>& coursesGraph, vector<bool>& graphPath, vector<bool>& visitedVertices)
{
// No need to continue if the vertix was visited in a pr... | ALGO | 0.999311 | 6.261213 |
f019bb0d-8a2b-47e3-8061-ea7353e435b9 | hetbhagatji09/Leetcode_Solution | 0142-linked-list-cycle-ii/0142-linked-list-cycle-ii.cpp | /**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode *detectCycle(ListNode *head) {
unordered_map<ListNode*,int>umap;
ListNode *temp=head;
while(temp!=n... | ALGO | 0.999893 | 5.354339 |
6045271d-a73e-4894-84d9-158a36da5325 | ishant9805/DSA-LearnAndPractice | leetCode/searchMatrixII.cpp | #include<bits/stdc++.h>
using namespace std;
// bool searchElement(vector<vector<int>> &mat, int target, int j) {
// int high = mat.size() - 1, low = 0;
// while (low <= high)
// {
// int mid = (low + high) >> 1;
// if (mat[mid][j] == target) return true;
// else if (mat[mid][j] < ... | ALGO | 0.999839 | 5.434172 |
06a5815b-9f47-432e-be06-a6cf67deb499 | ladesai123/DSA-in-Cpp | Last Moment Before All the Ants Fall.cpp | // Problem: Last Moment Before All Ants Fall Out
// Source: GeeksforGeeks
// Difficulty: Medium
/*
Problem Description:
--------------------
Given a wooden plank of length 'n' units, ants are walking on it. Some ants move left and others right.
Each ant moves at 1 unit/second. If two ants meet, they change direction i... | ALGO | 0.999898 | 6.931964 |
f1c7a9c8-ea93-4f76-aa4d-514b3d4bc9b4 | Amylo-jh/baekjoon | 2000s/2721.cpp | #include <iostream>
#include <vector>
using namespace std;
int main()
{
int tc;
cin >> tc;
vector <long long> arr(303);
for(int i = 1; i <= 302; i++)
{
arr[i] = arr[i-1] + i;
}
while(tc--)
{
int n;
cin >> n;
long long sum = 0;
for(int i = 1; i ... | ALGO | 0.999702 | 4.182606 |
ca47af34-f490-4d6b-b027-e2df8fb90ce5 | ShreyanshGolchha/daily | DSA/repeat1.cpp | #include <iostream>
using namespace std;
int count(int a[],int n)
{
int m = a[0],k = 0;
for (int i = 0; i < n; i++)
{
if (m>a[i])
{
m = a[i];
k = i;
}
}
return k;
}
int main()
{
int a[] = {7,4,1,7,3,2};
int n = sizeof(a)/sizeof(a[0]);
... | ALGO | 0.999717 | 4.229779 |
0b595478-4219-4050-bf9c-da00843e3cbb | Lchuxian/SLAM-Environment | OpenCV3_and_OpenCV4_coexist/opencv-4.5.5-build/modules/photo/src/hdr_common.cpp | #include "precomp.hpp"
#include "opencv2/photo.hpp"
#include "hdr_common.hpp"
namespace cv
{
void checkImageDimensions(const std::vector<Mat>& images)
{
CV_Assert(!images.empty());
int width = images[0].cols;
int height = images[0].rows;
int type = images[0].type();
for(size_t i = 0; i < images.s... | TOOL | 0.962317 | 5.91502 |
ae88204b-85d3-4a00-bbe4-acf500a60add | guduzhe777/Code-cpp | ACM/Acwing/TreeArray_Sement_Tree/1215/1215_1.cpp | #include<bits/stdc++.h>
using namespace std;
// const int N = 100010;
const int N = 1000010;
int w[N],tr[N];
//前缀和复杂度 ? o(1) but 修改复杂度 o(n)
//前缀和 查询 修改 都是o(logn) 懂不懂 含金量
// 暴力 存储 大于等于 ai 个数 == 求大于等于 ai 个数 == 小于等于最大 个数 - 小于等于ai个数
//就是 大于等于 ai 个数 --》》》求小于ai个数
//对 1 --- i序列 小于ai个数 小于 最大 个数 - 小于 ai个数
//--》》》<hi 数字 出... | ALGO | 0.999956 | 3.598092 |
ecdf4a7d-e2c5-4c07-9383-cdcfaae0aa93 | DeepanshuJha/interview_prep | Maximum_subarray_sum_l_to_r.cpp | #include <bits/stdc++.h>
#define ll long long
#define fprint(v) for(auto x : v) cout << x << ' ';
using namespace std;
const int M = 1e9 + 7;
const int N = 3e5 + 2;
struct yo{
ll prefMax, sufMax, sum, ans;
};
yo tree[N << 2];
ll a[N];
void build(int node, int st, int end){
if(st == end){
tree[node].pref... | ALGO | 0.999732 | 4.510602 |
27a1910c-8026-46f2-8a61-fc6f2881f8c7 | pprajap/boost | libs/ptr_container/test/view_example.cpp | //
// This example is intended to show you how to
// use the 'view_clone_manager'. The idea
// is that we have a container of non-polymorphic
// objects and want to keep then sorted by different
// criteria at the same time.
//
//
// We'll go for 'ptr_vector' here. Using a node-based
// container would be a waste of... | TOOL | 0.942978 | 6.078863 |
ebb0164b-72f3-42d9-97cf-a0431f338af1 | chandranshh/LeetCodePR | 1797-goal-parser-interpretation/goal-parser-interpretation.cpp | class Solution {
public:
string interpret(string command) {
int i = 0;
string ans = "";
while (i < command.size()) {
if (command[i] == 'G') {
ans += 'G';
i++;
} else if (command[i] == '(' && command[i + 1] == ')') {
ans ... | ALGO | 0.999104 | 4.95428 |
442f212c-e458-4ad2-a659-07cd881f2c9e | zarmars/letCode | Factor_Combinations_254.cpp | 整数可以被看作是其因子的乘积。
例如:
8 = 2 x 2 x 2;
= 2 x 4.
请实现一个函数,该函数接收一个整数 n 并返回该整数所有的因子组合。
注意:
你可以假定 n 为永远为正数。
因子必须大于 1 并且小于 n。
示例 1:
输入: 1
输出: []
示例 2:
输入: 37
输出: []
示例 3:
输入: 12
输出:
[
[2, 6],
[2, 2, 3],
[3, 4]
]
示例 4:
输入: 32
输出:
[
[2, 16],
[2, 2, 8],
[2, 2, 2, 4],
[2, 2, 2, 2, 2],
[2, 4, 4],
[4, 8]
]
... | ALGO | 0.999804 | 6.236467 |
c19ca0e3-474b-4bab-ad4f-4533ce81b055 | Tridib05/C-_Source-Code | 27. Convert decimal number to binary/using function prototype.cpp | #include <stdio.h>
#include <math.h>
long long convert(int);
int main()
{
int n;
long long bin;
printf("Enter a decimal number: ");
scanf("%d", &n);
bin = convert(n);
printf("%d in decimal = %lld in binary", n, bin);
return 0;
}
long long convert(int n)
{
long long bin = 0;
int rem, i = 1;
whi... | ALGO | 0.999436 | 5.203732 |
98099d60-5d63-4609-b099-2eea4b3e418d | vabtree/ngraph | sample.cpp | //To create a Graph, we call the insert_edge() function to build its edges:
using namespace NGraph;
Graph A;
A.insert_edge(3,4);
A.insert_edge(4,5);
A.insert_edge(0,1);
// We can see find out a graph's order and size by calling the num_vertices() and num_edges(). For example,
std::cout << "Graph has " << A.num_vert... | ALGO | 0.865334 | 5.834845 |
872459ff-0ce4-4932-9408-3d3cc494c7ce | wywhpsmaq/h | c++code/T7codes/[12]/[12]-4/BC405.cpp | #include <bits/stdc++.h>
using namespace std;
int n, m, p, x, y;
int fa[1000000];
int f (int x) {
if (x == fa[x]) return x;
return fa[x] = f (fa[x]);
}
void ff (int x, int y) {
int f1 = f (x), f2 = f (y);
if (f1 != f2) fa[f1] = f2;
}
int main () {
cin >> n >> m;
ios::sync_with_stdio (false);
cin.tie (nullptr);
... | ALGO | 0.999988 | 4.195296 |
54bda51d-164e-4482-8a23-1e9142e73368 | SungwookLE/PCCP | 5_8주차/boj2302.cpp | #include <bits/stdc++.h>
using namespace std;
// VIP 회원들의 좌석 번호들이 주어졌을 때, 사람들이 좌석에 앉는 서로 다른 방법의 가짓수를 구하는 프로그램
int N, M;
vector<int> VIP, visited;
map<vector<int>, int> mp;
int go(int id){
int& ret = mp[visited];
if(ret) return ret;
if (id == N+1){
return 1;
}
for(int val = 1 ; val <= N ... | ALGO | 0.999864 | 4.172707 |
38153809-52d6-4f43-ac23-069d4a67f612 | anbingxu666/WangDao-DataStructure | 考研算法真题/2010算法题.cpp | //
// Created by Newmor on 2019-10-23.
//
#include <cstdio>
/*
* 此问题相当于将数组的元素逆序问题的升级版
*
* 解法1:最优解
* 思想:若循环左移动p位,则在p的位置将数组分为两部分
* 将左边的一部分逆序
* 将有边的一部分逆序
* 最后将整个数组逆序
* 时间复杂度:O(n)
* 空间复杂度:O(1)
*
*
* 解法2:暴力算法
* 复制出一个数组,直接分成两部分,将左边的部分放到右边。右边的部分放到左边
* 时间复杂度:O(n)
* 空间复杂度:O(n)
* */
void reverse(int a... | ALGO | 0.999904 | 4.584104 |
4b2b2d8f-f4c5-4d73-ad23-24b00cc32556 | ttylinux/cppPrimer | chapter1/1_22.cpp | #include<iostream>
#include "Sales_item.h"
int main()
{
Sales_item val;
Sales_item cur;
int cnt;
if(std::cin>>val)
{
cnt = 1;
while(std::cin>>cur)
{
if(val.isbn() == cur.isbn())
{
cnt++;
}else
{... | TOOL | 0.905826 | 3.814704 |
3efab6f3-fe59-40ec-b9b9-bea6d4912121 | 113bommy/deepmind_codecontests_refine | cpp_source_filter_file/cpp_train_6276_13.cpp | #include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > v;
int ar1[2009];
int ar2[2009];
int ar3[2009];
int main() {
int xa, ya, xb, yb;
cin >> xa >> ya >> xb >> yb;
for (int i = min(xa, xb); i <= max(xb, xb); i++) {
for (int j = min(ya, yb); j <= max(ya, yb); j++) {
if (i == xa || i == xb... | ALGO | 0.999828 | 3.851688 |
5e52dd78-1c5c-4a96-a1cb-1be8b2ea5e20 | hg-ian-choi/coding-test | leetcode/algorithms/14_longest_common_prefix/main.cpp | #include <string>
#include <vector>
using namespace std;
class LongestCommonPrefix {
public:
string longestCommonPrefix(vector<string>& strs) {
for (int i = 0;; i++) {
if (strs[0][i] == '\0') {
return strs[0];
}
for (int j = 1; j < strs.size(); j++) {
... | ALGO | 0.999886 | 5.754486 |
8cf3d7a8-38b6-4c81-9136-ad82b1a95444 | mdmohsin212/phitron | week 2/Day 2/B_Segment_with_Big_Sum.cpp | #include<bits/stdc++.h>
#define ll long long
#define pi pair<int,int>
#define ln '\n'
using namespace std;
int main(int argc, char const *argv[])
{
ios::sync_with_stdio(false);
cin.tie(NULL);
ll n, s;
cin >> n >> s;
vector<int> v(n);
for (int i = 0; i < n; i++)
{
cin >> v[i];
}... | ALGO | 0.999963 | 3.688654 |
bce1e50d-5f89-4256-a9da-a87afa82d827 | jaysc5/Algorithm_study | 프로그래머스/2/87946. 피로도/피로도.cpp | #include <string>
#include <vector>
using namespace std;
int maxDepth = 0;
bool visited[8] = {false,};
void dfs(int depth, int k, vector<vector<int>> &dungeons) {
if (maxDepth < depth)
maxDepth = depth;
for (int i=0; i<dungeons.size(); i++) {
if (visited[i] or dungeons[i][0] > k)
... | ALGO | 0.999598 | 5.228562 |
21d51660-f276-4e8e-8b41-857191e3a795 | thinkover2022/espdroneflutter | 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.998733 | 6.76775 |
1164cd6e-d032-4501-a965-d03490ca9c65 | syscall00/obfuscation | llvm_based/lib/Transforms/Utils/CtorUtils.cpp | #include "llvm/Transforms/Utils/CtorUtils.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#define DEBUG... | TOOL | 0.898788 | 7.809954 |
7427d4db-f735-4bd1-b7e2-9ef13293d4f6 | J0ttaPM/checkpoint4-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.9988 | 6.76073 |
950f9b1f-528b-4759-a929-7ef3f6c4ad2e | Tprashant1/GFG-Problems | Difficulty: Medium/K Sum Paths/k-sum-paths.cpp | //{ Driver Code Starts
// Initial template for C++
#include <bits/stdc++.h>
using namespace std;
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 Case
i... | ALGO | 0.999601 | 6.645693 |
51eaa1ac-0900-4402-91d7-939ce84465c5 | vbonnici/grafe-sim | analysis/data/p02271/s890420648.cpp | #include <iostream>
using namespace std;
const int MAX_N = 20;
const int MAX_Q = 200;
int a[MAX_N];
int n, q, x;
bool func(int sum, int i) {
if (sum == x) return true;
if (i == n) return false;
return func(sum, i + 1) || func(sum + a[i], i + 1);
}
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a... | ALGO | 0.999917 | 4.885489 |
d2f00fc4-e383-49d0-97be-98470ee81237 | DavyYvad/UnrealEngine-release | Engine/Source/ThirdParty/CryptoPP/5.6.5/include/xtrcrypt.cpp | // xtrcrypt.cpp - written and placed in the public domain by Wei Dai
#include "pch.h"
#include "asn.h"
#include "integer.h"
#include "xtrcrypt.h"
#include "nbtheory.h"
#include "modarith.h"
#include "argnames.h"
NAMESPACE_BEGIN(CryptoPP)
XTR_DH::XTR_DH(const Integer &p, const Integer &q, const GFP2Element &g)
: m_... | ALGO | 0.994093 | 6.210129 |
ff18a427-b121-42da-bcba-62d1c75b6adf | rabeeadelbeabesh/Competitive-programming | codeforces/CodeForces 1061C-Multiplicity.cpp | #include<bits/stdc++.h>
using namespace std;
#define endl '\n'
const ll mod = 1e9 + 7;;
const int N = 1e6 + 9;
vector<vector<int>>divsor(N);
long long frq[N] = { 0 };
void clc_seive(){
for (int i = 1; i < N; ++i){
for (int j = i; j < N; j += i){
divsor[j].push_back(i);
}
}
for (int i = 1; i < N; ++i){
... | ALGO | 0.999875 | 5.263124 |
ee833ea0-36d5-4b59-a0f0-4967ba5de7bf | keyos7824s/miketmoore | Alphastar/CC35A/Prefix Sum Problems/fairphoto.cpp | #include <bits/stdc++.h>
#include <algorithm>
using namespace std;
bool cmp5(pair<int,int> a, pair<int,int> b){
return a.first < b.first;
}
int main(){
//observation 1 - if an interval starts on a S, it ends on a W. There is either a 0, 2, 4, etc. difference between white & spotted (in favor of white).
//sol idea: ... | ALGO | 0.99951 | 3.899571 |
ba4fe8c7-635f-4f83-be5b-51eeab9fb089 | kritikseth/Sorting-Algorithms | Quick Sort.cpp | #include <iostream>
using namespace std;
class QuickSort
{
private:
int size;
int * Array;
public:
QuickSort(int size)
{
this->size = size;
Array = new int[this->size];
}
void RandomArray()
{
int i;
for(i=0;i<=size;i++)
Array[i] = rand() % 100 + ... | ALGO | 0.99965 | 4.891193 |
5f2f868b-dc29-4a19-a6d3-5f8510aaf0d6 | ashrafmoid/cp | primesub.cpp | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
int t;cin>>t;
while(t--){
ll x,y;cin>>x>>y;
if(x-y>1)cout<<"Yes\n";
else cout<<"No\n";
}
return 0;
} | ALGO | 0.99985 | 3.97333 |
df33eac4-dfdd-4a49-ae22-fde57f89c774 | munh-orgil/leetcode | 2025/02. feb/(24) 2467. Most Profitable Path in a Tree.cpp | #include<bits/stdc++.h>
using namespace std;
class Solution {
public:
Solution() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
int mostProfitablePath(vector<vector<int>>& edges, int bob, vector<int>& amount) {
int n = edges.size() + 1;
vector<... | ALGO | 0.99992 | 4.629435 |
522b9449-b981-413e-9ea5-995ae03128a5 | Pannguyen/Polyn-mes-d-interoplaton-de-Lagrange | TPLagrange/main.cpp | #include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <cstdint>
#include <stdint.h>
#include <math.h>
// #include "matrix.hpp"
#include "util.hpp"
#include "lagrange.hpp"
/*Module: X22I050: Création Numérique & Algorithme numérique */
/* TP3: Polynôme d'interpolation de Lagrange*/
/* Anh NGUYEN - Aymen ... | ALGO | 0.998785 | 4.460783 |
649783e7-efdd-4138-b8f6-bd4f732725e2 | GMcode12/C-CPP-Code | Tic Tac Toe.cpp |
void turn()
{
}
int main()
{
int choice;
int count=1;
int i;
for(i=0;i<9;i++)
{
switch(count)
{
case 1:
block();
count++;
if(A[0][0] == A[0][1] and A[0][1]==A[0][2] )
{
cout<<"!!!!!!!! "<<name1<<" won the game !!!!!!!!!!!"<<endl;
exit(1);
}
else if(A[... | ALGO | 0.998691 | 3.518468 |
e575c564-7222-4b03-819a-39df660bcbd2 | Sahil-Rochlani/daily-code-journal | Day32/inorder_predecessor_of_a_node_in_bst.cpp | #include<bits/stdc++.h>
using namespace std;
struct TreeNode {
int val;
TreeNode *left;
TreeNode *right;
TreeNode() : val(0), left(nullptr), right(nullptr) {}
TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(r... | ALGO | 0.999999 | 5.386784 |
4c9f5ebd-dd68-4d2f-94b4-a1b5a9f7b131 | AniKouDev/CodeChef | 0-1000 Beginner Level/Audible_Range.cpp | #include <iostream>
using namespace std;
#define breakline cout<<endl;
int main(){
int t;
cin >> t;
while(t--){
int x;
cin >> x;
cout << ((x>=67 && x<=45000)?"Yes":"No");
breakline;
}
} | ALGO | 0.999665 | 3.744006 |
24268e4c-ddae-4d63-82d3-994649820394 | rodo-code/ICPC-UCB-2021 | SolucionesContest/Contest6/BeatTheSpread.cpp | #include <iostream>
#include <cstdio>
using namespace std;
int main(){
int n;
scanf("%d",&n);
while(n--){
int s,d;
scanf("%d %d",&s,&d);
if((s+d)%2==1 or (s-d)&2==1 or s<d){
printf("impossible\n");
}
else{
int a = (s+d)/2;
int b = ... | ALGO | 0.999883 | 3.5586 |
a42d23c2-d975-4bcc-86bb-147541735846 | chisun-joung/cs_algo | Week3(12~17)/primenumber.cpp | enum BOOL {FALSE, TRUE};
int solve(int n);
BOOL isPrime(int num);
int main() {
int n;
int res;
int startTime, endTime;
while(1){
printf("° Ҽ?: ");
scanf("%d",&n);
if(n==0)break;
startTime = clock();
res = solve(n);
endTime = clock();
printf("Ҽ : %d\n", res);
printf("˰ ҿð : %d(millisecond)\n", (en... | ALGO | 0.999796 | 4.11453 |
f45d856f-5fdf-49b0-bc59-25eb4d938ea6 | aayush2761/Leetcode_prob | 0151-reverse-words-in-a-string/0151-reverse-words-in-a-string-08-23-2025-17-15-21.cpp | class Solution {
public:
string reverseWords(string s) {
vector<string>store;
stringstream ss(s);
string token="";
while(getline(ss,token,' ')){
if(!token.empty())store.push_back(token);
}
int i=0,j= store.size()-1;
while(i<=j){
swap(st... | ALGO | 0.999968 | 6.216766 |
942a917b-526d-4245-b402-02444531d683 | asiradnan/CSES | Graph Algorithms/Road Reparation.cpp | #include<bits/stdc++.h>
using namespace std;
using ll = long long;
int dsu[100001];
void make(int n)
{
for (int i=1;i<=n;i++) dsu[i]=i;
}
int find_parent(int x)
{
if (dsu[x]==x) return x;
return dsu[x]=find_parent(dsu[x]);
}
void unite(int x, int y)
{
x = find_parent(x);
y = find_parent(y);
dsu[x]=y;
}
... | ALGO | 0.999918 | 4.889443 |
18867dcf-2531-46a3-8db5-7f1c66ac391f | DeLonghi/Parallel-programming-labs | lab14.cpp | #include <stdio.h>
#include <iostream>
#include "mpi.h"
#define n 1000
using namespace std;
void smod5(void *a, void *b, int *l, MPI_Datatype *type)
{
int i;
for (i = 0; i < *l; i++)
((int *)b)[i] = (((int *)a)[i] + ((int *)b)[i]) % 5;
}
void max(void *a, void *b, int *l, MPI_Datatype *type)
{
if ... | ALGO | 0.999768 | 3.35956 |
a6bedbc5-047d-43ea-8caa-e86b7b0c7498 | jeevankoiri10/practitioner_app | 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.998756 | 6.772262 |
b126d85b-ed01-4b20-a45a-84771321efdc | littlefish-Max/Data-Structure | chapter5/P141_3.cpp | //非递归的一个后序遍历二叉树
#include<bits/stdc++.h>
using namespace std;
typedef struct TreeNode{
char data;
struct TreeNode *lchild,*rchild;
int tag;
}TreeNode,*Tree;
void creattree(Tree &t)
{
char ch;
ch=getchar();
if(ch=='#') t=NULL;
else
{
t=(TreeNode *)malloc(sizeof(TreeNode));
... | ALGO | 0.999853 | 4.107604 |
28d27f28-9b57-45d8-9d26-8ea8b39cfc81 | ishandutta2007/codeforces | pyqe/normal/1216/E1.cpp | #include <bits/stdc++.h>
using namespace std;
long long a[100069],f[100069],p10[10];
int main()
{
long long t,rr,k,i,p,z,pp,ppp,zzz;
p10[0]=1;
for(i=1;i<10;i++)
{
p10[i]=p10[i-1]*10;
}
for(i=1;1;i++)
{
f[i]=f[i-1];
for(k=i;k>0;k/=10)
{
f[i]++;
}
a[i]=a[i-1]+f[i];
if(a[i]>1000000000)
{
... | ALGO | 0.999841 | 3.651578 |
a57c4b1b-1131-4e74-bc49-4e69d8c17454 | cepxuozab/YandexTrainingAlgorithms | Training1/Lesson5/B - Сумма номеров/main.cpp | #include "iostream"
#include "unordered_map"
#include "vector"
auto Read(unsigned n) -> std::vector<int>;
auto SumNumbers(std::vector<int> const& arr, int sum) -> int;
auto main() -> int
{
// freopen("input.txt", "r", stdin);
unsigned n;
int k;
std::cin >> n >> k;
std::cout << SumNumbers(Read(n),... | ALGO | 0.999876 | 4.830964 |
29462b33-8c63-41a6-ac2b-4f3a26d7824d | jgjonsson/jgj-variational-monte-carlo | src/harmonicoscillator.cpp | #include <memory>
#include <cassert>
#include <iostream>
#include "../include/harmonicoscillator.h"
#include "../include/particle.h"
#include "../include/wavefunction.h"
using std::cout;
using std::endl;
HarmonicOscillator::HarmonicOscillator(double omega)
{
assert(omega > 0);
m_omega = omega;
}
double Harm... | TOOL | 0.961733 | 5.139291 |
aa8dd796-7f0e-4507-ab51-f48ca8e44ec8 | nsmoooose/csp | csp/csplib/util/StringTools.cpp | /**
* @file StringTools.cpp
*
**/
#include <csp/csplib/util/StringTools.h>
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <ctype.h>
#include <iterator>
#include <limits>
#include <sstream>
#include <vector>
#if !defined(__GNUC__) && !defined(snprintf)
#define snprintf _snprintf
#endif
#if def... | TOOL | 0.900156 | 6.488576 |
7008d386-b615-4e34-9078-fc7dd0f0fa8f | diyagoyal98/Leetcode-Questions | 1207-unique-number-of-occurrences/1207-unique-number-of-occurrences.cpp | class Solution {
public:
bool uniqueOccurrences(vector<int>& arr)
{
map<int,int>mp;
int n=arr.size();
for(int i=0;i<n;i++)
{
mp[arr[i]]++;
}
set<int>s;
for(auto it=mp.begin();it!=mp.end();it++)
{
s.insert(it->second);
... | ALGO | 0.999973 | 6.059649 |
7847e984-3ca0-4f64-8684-f1768e2298e5 | vsuriya93/Coding-Practice | LeetCode/Medium/level_order_traversal.cpp | class Solution {
public:
vector<vector<int>> levelOrder(TreeNode* root) {
queue<TreeNode*> q;
vector<vector<int>> result;
if (root==NULL){
return result;
}
q.push(root);
TreeNode *temp = NULL;
vector<int> level_sum;
int s = 0;
while... | ALGO | 0.99998 | 5.922215 |
c476d01a-ab30-40ce-bc04-7cd11b875611 | NandeeshPuri/CSES | Graph Algorithm/planetsquieries2.cpp | #include<bits/stdc++.h>
using namespace std;
#define ar array
#define ll long long
const int MAX_N = 2e5 + 1;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const int MAX_L = 20;
int n,q,par[MAX_N][MAX_L],dep[MAX_N],cy[MAX_N];
void dfs(int u,int d=0){
cy[u]=--d;
int v=par[u][0];
if(!cy[v])dfs(v,d);
if(... | ALGO | 0.999933 | 4.441375 |
bd7b367b-adf0-4460-ba41-709480da364c | aminul-islam-niloy/Cpp-Programming-and-templates- | Data Structure Algorithm/Array_Operation/2D_spiralArray.cpp | #include <bits/stdc++.h>
using namespace std;
int main()
{
#ifndef RUN
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int n, m;
cin >> n >> m;
int arr[n][m];
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
cin >> arr[i]... | ALGO | 0.999984 | 4.09492 |
933d9ceb-3679-4f2f-abd9-da542360a492 | ishandutta2007/codeforces | yasugongshang/normal/1056/F.cpp | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define ld long double
#define PI pair<int,int>
inline char gc(){
static char buf[100000],*p1=buf,*p2=buf;
return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getcha... | ALGO | 0.999769 | 3.527758 |
469dc5b6-d7a6-443a-8d1d-f4f4b756a5f3 | SilviaAmAm/BXDinPlumed | src/tools/NeighborList.cpp | #include "NeighborList.h"
#include "Vector.h"
#include "Pbc.h"
#include "AtomNumber.h"
#include "Tools.h"
#include <vector>
#include <algorithm>
namespace PLMD{
using namespace std;
NeighborList::NeighborList(const vector<AtomNumber>& list0, const vector<AtomNumber>& list1,
const bool& do_p... | TOOL | 0.992615 | 5.956535 |
e506d927-1210-4b19-80d8-e50959508598 | shivachidurala370/practice1 | 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 |
5a176303-454a-4b21-ac11-fa872ca5708e | ganyfml/olegosa2 | src/seqan_api/backup/SeqFinder/main/find/main1.cpp | // vim: set noexpandtab tabstop=2:
#include "../../SeqFinder.hpp"
#include <iostream>
using namespace std;
int main(int, char* argv[])
{
SeqString ref(string("ATGCAT"));
SeqSuffixArray seq_SA(ref);
SeqFinder finder(seq_SA);
SeqString query_seq((string("AT")));
finder.clear();
while(finder.find(query_seq))
{
... | ALGO | 0.989716 | 4.642671 |
9bee5551-07f2-4a95-96cb-f497107981bc | Nguyenthithuhang0406/UDTT | Cau2_TH6_LT_ChiaDeTri_DeQuy_QuayLui.cpp | #include<bits/stdc++.h>
using namespace std;
void show(string s[], int a[], int k, int count){
cout << "Cach " << count << " : \n";
for(int i = 0; i < k; i++){
cout << s[a[i]] << " ";
}
cout << "\n";
}
void A4(string s[], int a[], int n, int k, int id, int pass, int &count){
for(int i = pass; i < n; i++){
a[i... | ALGO | 0.999316 | 3.650047 |
ab57d1c1-bd75-4802-b24e-073fc62240ac | yukikamome316/competition-archive | src/ABC/ABC334/D.cpp | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (int)s; i < (int)(n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T ... | ALGO | 0.999936 | 4.116107 |
a9874db7-3c6d-4d2e-854e-7682d7ed140c | Shlok2/DSA | Graphs/Graph Quesions/makingWiredConnections.cpp | #include <iostream>
#include <string.h>
#include <vector>
#include <unordered_map>
using namespace std;
void DFS(unordered_map<int, vector<int>> &adj, int curr, vector<bool> &visited)
{
visited[curr] = true;
for (auto i : adj[curr])
{
if (visited[i] == false)
{
DFS(adj, i, visit... | ALGO | 0.999832 | 5.556942 |
a5df4ea1-93a1-47df-9c9e-f90c2a7a9ee2 | Daniel-Pham831/Dictionary | Dictionary/Word.cpp | //#include "Word.h"
//
//void Word::addMeaning(ListOfMeanings& meanings, wstring meaning) {
// if (meanings == NULL) {
// meanings = new Node(meaning);
// pTail = meanings;
// return;
// }
// else {
// pTail->next = new Node(meaning);
// pTail = pTail->next;
// }
//}
//void Word::showListM(ListOfMeanings list) {
/... | TOOL | 0.938732 | 3.569008 |
84aa5c3f-008a-434c-bb4e-84303f3ecf2c | AdityaHegde02/Leetcode-Solved | 2869-minimum-operations-to-collect-elements/2869-minimum-operations-to-collect-elements.cpp | class Solution {
public:
int minOperations(vector<int>& nums, int k) {
unordered_set<int> s;
int n = nums.size();
for(int i = n - 1; i >= 0; i--){
s.insert(nums[i]);
bool ok = 1;
for(int j = 1; j <= k; j++){
if(s.find(j) == s.end()){
... | ALGO | 0.999959 | 5.776223 |
0cd81e18-634d-4bc4-ba91-5fa672876f3c | halleepham/CS304-Assignment-3 | Part 1/functions.cpp | //This file contains the function defintions of functions used to determine balanced parentheses
#include "functions.h"
//string variables used containing open and close parentheses
const string OPEN = "([{";
const string CLOSE = ")]}";
//PRE: takes in a character
//POST: returns true if the character is a opening p... | ALGO | 0.991949 | 5.255875 |
9571b0a6-5d2a-49bd-82b3-186721155c63 | ishandutta2007/codeforces | duality/normal/1553/A.cpp | #define DEBUG 0
#include <bits/stdc++.h>
using namespace std;
#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printA... | ALGO | 0.999124 | 3.825755 |
14318245-8ab2-48b7-9418-49a2f6d25fc5 | gefgu/clube_de_programacao | uri2018-Gustavo_Santos.cpp | #include <bits/stdc++.h>
using namespace std;
// 2 greater
// 1 equal
// 0 less
int compare(int a[3], int b[3])
{
int ans = 2;
if (a[0] < b[0])
ans = 0;
else if (a[0] == b[0])
{
if (a[1] < b[1])
ans = 0;
else if (a[1] == b[1])
{
if (a[2] < b[2])
ans = 0;
else if (a[2]... | ALGO | 0.999847 | 4.484133 |
d60bfc2a-5132-4017-942f-f7a4ecf88593 | black-shadows/LeetCode-Topicwise-Solutions | C++/best-time-to-buy-and-sell-stock-ii.cpp | // Time: O(n)
// Space: O(1)
class Solution {
public:
int maxProfit(vector<int>& prices) {
int result = 0;
for (int i = 1; i < prices.size(); ++i) {
result += max(0, prices[i] - prices[i - 1]);
}
return result;
}
};
| ALGO | 0.999505 | 6.275737 |
f401be5e-d4a8-42f3-8474-9b9a38db9324 | Show-Boo/CPP_Practices2 | lab 11/lab11_r02.cpp | #include <iostream>
using namespace std;
class Account {
private:
string name;
string id;
int balance;
public:
Account(string name, string id, int balance) : name(name), id(id), balance(balance) {}
string getID() {
return id;
}
int getBalance() {
return balance;
}
Account operator+(Account& account) {
... | ALGO | 0.994696 | 3.916636 |
621e01ac-2ec4-432b-a30a-3cda14248882 | gowsikamanavazhakan/day-2 | dq4.cpp | #include<iostream>
using namespace std;
void swap(int a,int b){
int c;
c=a;
a=b;
b=c;
cout<<a<<" "<<b;
}
int main()
{
int p,q;
cout<<"\nenter the num 1 : ";
cin>>p;
cout<<"\nenter the num 2 : ";
cin>>q;
swap(p,q);
return 0;
}
| ALGO | 0.997933 | 3.007806 |
a113d66e-5457-411c-b103-34d64fef4c43 | harshit779921/Leet_Code_Question | 349-intersection-of-two-arrays/intersection-of-two-arrays.cpp | class Solution {
public:
vector<int> intersection(vector<int>& nums1, vector<int>& nums2) {
int i = 0;
int j = 0;
sort(nums1.begin(), nums1.end());
sort(nums2.begin(), nums2.end());
vector<int> ans;
while (i < nums1.size() && j < nums2.size()) {
if (nums1... | ALGO | 0.99999 | 5.671891 |
72f6abd3-37df-49cd-b48f-b552af1f688a | RSB4760/apq8016_cts | suite/cts/deviceTests/opengl/jni/graphics/Matrix.cpp | #include "Matrix.h"
#include <string.h>
#include <cmath>
#define LOG_TAG "CTS_OPENGL"
#define LOG_NDEBUG 0
#include "utils/Log.h"
Matrix::Matrix() {
identity();
}
Matrix::Matrix(const Matrix& src) {
loadWith(src);
}
void Matrix::print(const char* label) {
ALOGI("%c", *label);
for (int i = 0; i < 4; ... | TOOL | 0.877764 | 6.461916 |
f658f026-d2e4-482c-bfaa-8725faeb55d4 | rachit77/DSA-solutions | 994-rotting-oranges/994-rotting-oranges.cpp | class Solution {
public:
struct Node{
int time;
int x;
int y;
};
int orangesRotting(vector<vector<int>>& grid) {
int n = grid.size();
int m = grid[0].size();
queue<Node> q;
for(int i = 0; i < n; i++)
{
for(int j = 0; ... | ALGO | 0.999949 | 6.19059 |
c3cae2e4-77c9-4a61-ac9d-4b244be36207 | llynn97/Algorithm | 백준/1647.cpp | #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n, m, ans;
int parent[100001];
vector <pair<int, pair<int, int>>> edge;
vector <int> v;
int find_parent(int x) {
if (x == parent[x]) {
return x;
}
else {
return parent[x] = find_parent(parent[x]);
}
}
void Union(int x, int y... | ALGO | 0.99998 | 4.373658 |
b7ee23c7-a2fc-4f89-a315-c234e40da890 | dloibl/AOC2020 | Day19/main.cpp | #include "../utils.cpp"
#include <map>
#include <regex>
using namespace std;
const regex unresolved(".*([0-9]+).*");
smatch base_match;
void parse(string &line, map<string, string> &rules)
{
if (line.size() == 0)
return;
vector<string> part = split(line, ':');
rules[part[0]] = trim(part[1]);
}
v... | ALGO | 0.940476 | 4.604614 |
c168d937-8796-4f2f-89e4-60f330ae5500 | Premkumar2312-pw/SkillRack | Daily Challenge/C++/Triplets - Same Difference 8.8.2025.cpp | #include <bits/stdc++.h>
using namespace std;
int main(){
int n,a[100],f=0;
cin>>n;
for(int i=0;i<n;i++)cin>>a[i];
for(int i=0;i<n-2;i++)
for(int j=i+1;j<n-1;j++)
for(int k=j+1;k<n;k++)
if(a[j]-a[i]==a[k]-a[j]){cout<<a[i]<<" "<<a[j]<<" "<<a[k]<<"\n";f=1;}
if(!f)co... | ALGO | 0.999865 | 3.40146 |
e0eb7f22-c495-48d3-ab9e-e8f73896b434 | prashantsharma9027/GFG_Question_Solution | Reverse a Stack.cpp | class Solution{
public:
void insertAtBottom(stack<int> &St,int x){
if(St.empty())
{
St.push(x);
return;
}
int num = St.top();
St.pop();
insertAtBottom(St , x);
St.push(num);
}
void Reverse(sta... | ALGO | 0.999887 | 5.391103 |
6035c5ab-7ca9-4c2e-8974-993a738848e5 | giongto35/CompetitveProgramming | AMSGAME2.cpp | #include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <que... | ALGO | 0.999703 | 3.242412 |
9b727328-d32f-4672-b96b-0c8076d53231 | sarthakawsthi7/Algorithms | 2215-finding-3-digit-even-numbers/finding-3-digit-even-numbers.cpp | class Solution {
public:
vector<int> findEvenNumbers(vector<int>& digits) {
int n = digits.size();
unordered_set<int> st;
vector<int> ans;
for(int i=0 ;i<n; i++){
for(int j=0; j<n; j++){
for(int k =0; k<n; k++){
if(i==j || j ==k || k == i ){
... | ALGO | 0.999879 | 5.792647 |
d8e2f57d-1e12-4e34-8c4a-07eb3c30b5f0 | manikanta2901/ubuntu | .history/practice/cpp/Codechef/ChefAndSteps_20200726124316.cpp | #include<bits/stdc++.h>
#include<vector>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<iterator>
#include<string>
#include<map>
#define vv vector
#define F first
#define S second
#define MP make_pair
#define EXECUTE_FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define printM... | ALGO | 0.999858 | 3.178555 |
c1cfb26a-d55b-4bca-9843-7d306e6cffa9 | hoangduongngg/C-Basic | tim so be nhat.cpp | #include <stdio.h>
long long findmin (long long a[], int n) {
long long min;
min=a[0];
int i=1;
while (i<n) { // for(int i=0; i<n; ++i)
if (a[i] < min)
min=a[i];
++i;
}
return min;
}
int main () {
int t, n, i;
long long a[100];
scanf("%d", &t);
while (t--) {
scanf("%d", &n);
i=1;
while (i<... | ALGO | 0.999491 | 3.106908 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.