uuid string | repo_name string | relative_path string | content string | category string | algo_rel_score float64 | quality_score float64 |
|---|---|---|---|---|---|---|
af19abb2-9a03-46a5-88f0-701d5daad212 | NTMyDung/Demo | 199/main.cpp | #include <iostream>
using namespace std;
int kttoanchan ( int a[], int n){ //kiem tra mang co toan so chan khong neu co tra ve 1
int ketqua=1;
for( int i=1; i<=n; i++){
if(a[i]%2!=0){ //neu ton tai so le thi tra ve 0
ketqua=0;
break;
... | ALGO | 0.999861 | 4.296089 |
bf270003-c060-4206-97d0-842c5d4eaa29 | dmkz/competitive-programming | mirea/cources/middle/greedy-1/f.cpp | #include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n; cin >> n;
vvi next(1+n);
for (int u = 2, parent; u <= n; ++u) {
cin >> parent;
next[pa... | ALGO | 0.999945 | 4.065922 |
1eab6545-74d9-4cd7-91a4-c3cb85b1e680 | QWERx29/My-Codes-and-Docs_OLD | OnlineJudge/Luogu/P2385.cpp | #include<bits/stdc++.h>
using namespace std;
int a[10000][10000];
struct node
{
int x;
int y;
int s;
}q[1000000];
int main()
{
int n,m,m1,m2;
int head=1,tail=0;
int endx,endy;
cin>>n>>m>>m1>>m2;
int fx[8]={m2,m2,-m2,-m2,m1,m1,-m1,-m1};
int fy[8]={m1,-m1,m1,-m1,m2,-m2,m2,-m2};
for(int i=1;i<=n;i++)
{
for(in... | ALGO | 0.999936 | 3.889833 |
3fad94f4-4339-475e-83cf-dcd6c9cf0892 | Rashed357/CP-stuffs | Big_integer.cpp | string add(string a, string b) {
string res = "";
int carry = 0;
int n = max(a.size(), b.size());
while (a.size() < n) a = '0' + a;
while (b.size() < n) b = '0' + b;
for (int i = n - 1; i >= 0; i--) {
int sum = (a[i]-'0') + (b[i]-'0') + carry;
carry = sum / 10;
res += (s... | ALGO | 0.999558 | 5.592193 |
cb818574-83cd-4a4a-b102-4e64c3046932 | wazenmai/Leetcode | Medium/1481_least_number_of_unique_integers_after_k_removals/solution1.cpp | /**
* Title: Least Number of Unique Integers after K Removals (Leetcode Medium 1481)
* Author: Bronwin Chen <<EMAIL>>
* Date: 16, February, 2024
* Method: Use unordered_map to count the number occurence, then use map to sort the occurence and decrease k by traversing the cnt.
* Result: Time complexity O(nlogn),... | ALGO | 0.999932 | 6.317533 |
b97550bc-5bc5-44b9-9939-9ccb0e091f57 | ishandutta2007/codeforces | wzyyn/normal/1486/B.cpp | #include<bits/stdc++.h>
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define pii pair<int,int>
#define fi first
#define se second
#define PB push_back
#define ll long long
#define ull unsigned long long
#define pll pair<ll,ll>
#define y1 orzkcz
using n... | ALGO | 0.999958 | 4.151599 |
f6ac07b4-711d-4cd5-a9e0-8b96d9cf7540 | VanshTyagi05/cpp-bsics-notes | kapil.cpp | #include<iostream>
using namespace std;
int binarySearch(int arr[][10], int row, int col, int target){
for(int i = 0; i < row; i++){
int start = 0, end = col - 1;
if(arr[i][start] <= target && target <= arr[i][end]){
while(start <= end){
int mid = start + (end - start) /... | ALGO | 0.999949 | 5.638901 |
94bf1988-ad85-4b37-b3ed-7ff1614a3734 | boostorg/graph | example/r_c_shortest_paths_example.cpp | // Example use of the resource-constrained shortest paths algorithm.
#include <boost/config.hpp>
#ifdef BOOST_MSVC
#pragma warning(disable : 4267)
#endif
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/r_c_shortest_paths.hpp>
#include <iostream>
using namespace boost;
struct SPPRC_Example_Graph_Ver... | ALGO | 0.999922 | 3.783796 |
53c861f6-7d5f-4ea9-849a-48e0ecbac40b | A1-mamun/CP-Problem | queuq_at_school.cpp | #include <iostream>
using namespace std;
int main()
{
int n, t;
cin >> n >> t;
string s;
cin >> s;
while (t--)
{
for (int i = 0; i < n - 1; i++)
if (s[i] == 'B' && s[i + 1] == 'G')
{
s[i] = 'G';
s[i + 1] = 'B';
i++;
... | ALGO | 0.998943 | 3.860747 |
776eca3c-93e3-476e-9f86-6b69e2700578 | kiruxa999/ITMP.CPLUSPLUS.Labs | ITMO.CPLUSPLUS.Ex2.Laba3/ITMO.CPLUSPLUS.Ex2.Laba3.cpp | // ITMO.CPLUSPLUS.Ex2.Laba3.cpp : Этот файл содержит функцию "main". Здесь начинается и заканчивается выполнение программы.
//
#include <iostream>
#include<cmath>
using namespace std;
int main()
{
system("chcp 1251");
int s;
int a(10), b(5), c(2), d(1);
cout << "Введите кол-во денег: ";
cin >> s;
... | ALGO | 0.997607 | 3.607861 |
91ea1e8c-9749-43e9-94d6-177a4b4dc88c | MdNayimIslam/SortingAlgorithom | MargSort.cpp | #include <bits/stdc++.h>
using namespace std;
void Conquer(int array[], int f, int m, int l)
{
int temp [l-f+1], i = f, j = m+1, k = 0;
while (i<=m && j<=l)
{
if(array[i]<=array[j])
{
temp[k++] = array[i++];
}else{
temp[k++] = array[j++];
}
}
... | ALGO | 0.999979 | 4.110911 |
4dcd7519-08c5-478e-9025-6827a224c611 | Amitesh-tiwari/Interview_prep_DSA | Trees.cpp/ValidateBST.cpp | Given the root of a binary tree, determine if it is a
valid binary search tree (BST).
//code
class Solution {
public:
bool isValidBST(TreeNode* root) {
return isValidBST(root, LONG_MIN, LONG_MAX);
}
bool isValidBST(TreeNode* root, long min, long max) {
if (!root) return true;
... | ALGO | 0.999993 | 6.508231 |
4117116b-132a-49e1-b948-ed392d73745b | sophgo/libsophon | bmvid/bmcv/src/bmcv_faiss_indexflatIP.cpp | #include "bmcv_api_ext.h"
#include "bmcv_internal.h"
#pragma pack(push, 1)
typedef struct {
unsigned long long input_query_global_addr;
unsigned long long database_global_addr;
unsigned long long buffer_global_addr;
unsigned long long output_sorted_similarity_global_addr;
unsigned long long output_... | ALGO | 0.985836 | 5.771553 |
8143e9d7-40c1-4799-a7d5-50019bd5e40b | neverac/codes | HDOJ2019_multi_t1/solution/1007.cpp | #include <bits/stdc++.h>
typedef std::pair<long long,long long> Frac;
Frac operator + (Frac a,Frac b) {
long long y=a.second/std::__gcd(a.second,b.second)*b.second,
x=a.first*(y/a.second)+b.first*(y/b.second);
return {x,y};
}
Frac operator /(Frac a,int b) {
long long x=a.first,y=a.second*b... | ALGO | 0.99985 | 4.62572 |
c7d32fdf-f9bb-465d-9cef-9ae5ea5be2c8 | Shakti184/LEETCODE | Medium/Count the subarrays having product less than k/count-the-subarrays-having-product-less-than-k.cpp | //{ Driver Code Starts
#include <bits/stdc++.h>
using namespace std;
// } Driver Code Ends
class Solution{
public:
int countSubArrayProductLessThanK(const vector<int>& a, int n, long long k) {
int count = 0;
long prod = 1;
int start = 0 ;
int end = 0;
for(;end<n;end++){
... | ALGO | 0.999497 | 5.650734 |
ff983867-d892-4262-8e76-4f1965b5360b | kshitij7890/DSA-Practice-Questions | Searching and Sorting/GFG Searching/Floor in a Sorted Array.cpp | /*
Given a sorted array arr[] of size N without duplicates, and given a value x.
Floor of x is defined as the largest element K in arr[] such that K is smaller than or equal to x.
Find the index of K(0-based indexing).
Example 1:
Input:
N = 7, x = 0
arr[] = {1,2,8,10,11,12,19}
Output: -1
Explanation: No element l... | ALGO | 0.999982 | 6.04169 |
491d35b4-2d14-408a-bc38-e90d51ad9ee6 | vitorguidi/Competitive-Programming | codeforces/rounds/Educational 47/a.cpp | #include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fr(i,n) for(int i=0;i<n;i++)
#define frr(i,n) for(int i=1;i<=n;i++)
#define ms(x,i) memset(x,i,sizeof(x))
#define dbg(x) cout << #x << " = " << x << endl
#define all(x) x.begin(),x.en... | ALGO | 0.999853 | 3.119357 |
f5060408-0c76-4857-84e1-b3e86ed8e676 | blur-network/dpow-blur | src/crypto/crypto.cpp | #include <unistd.h>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <memory>
#include <boost/thread/mutex.hpp>
#include <boost/thread/lock_guard.hpp>
#include <boost/shared_ptr.hpp>
#include "common/varint.h"
#include "warnings.h"
#include "crypto.h"
#include "ha... | ALGO | 0.992408 | 7.382486 |
2cedd2c2-5973-4427-ad7c-d2d05635c886 | veprbl/es40 | src/AlphaCPU_vaxfloat.cpp | #include "StdAfx.h"
#include "AlphaCPU.h"
#include "cpu_debug.h"
#define IPMAX U64(0x7FFFFFFFFFFFFFFF) /* plus MAX (int) */
#define IMMAX U64(0x8000000000000000) /* minus MAX (int) */
/* Unpacked rounding constants */
#define UF_FRND U64(0x0000008000000000) /* F round */
#define UF_DRND U64(0x0000000000000080) /*... | ALGO | 0.919113 | 6.417661 |
ba931723-4996-4c10-b665-3a2fa4a8b9e4 | andrewei1316/OJSubmit | DATASOURCE_POJSubmit/1006/1006_20140801-233024_360K_297MS_AC.cpp | #include<cstdio>
#include<algorithm>
#include<string.h>
using namespace std;
int main(){
int i;
int k = 0;
int p, e, n, d;
while(scanf("%d%d%d%d", &p, &e, &n, &d) != EOF){
if(p == -1 && e == -1 && n == -1 && d == -1)
break;
int v = p > e ? p : e;
i = v > n ? v : n;
... | ALGO | 0.999735 | 3.145947 |
a4f5793e-8b14-48f0-87e5-28696fc99a18 | kishanrajput23/Love-Babbar-CPP-DSA-Course | Lectures/Lecture_40/Lecture_Codes/rat_in_a_maze_problem_I.cpp | class Solution{
public:
bool isSafe(int x, int y, int n, vector<vector<int>>visited, vector<vector<int>>&m){
if( (x>=0 && x<n) && (y>=0 && y<n) && visited[x][y]==0 && m[x][y]==1) {
return true;
}
else {
return false;
}
}
void solve(vector<vector<in... | ALGO | 0.999994 | 6.121593 |
da2c45b0-5b05-4a86-bb88-e2456e9e857d | pyakureljenish/College_Lab_Codes | Theory of Computation/NFA/nfasubstr.cpp | #include <iostream>
#include <set>
using namespace std;
set<int> currentStates; // Set to store multiple possible current states
bool isAccepted(string input);
int main(){
string input;
cout << "Enter any string of 'a' and 'b': " << endl;
cin >> input;
if (isAccepted(input)) {
cout << "STRING... | ALGO | 0.999619 | 7.283578 |
186d6865-05c5-47c7-9172-fba8c34abf1e | sedihub/project_euler | problems_001-050/euler_35.cpp | /*
PROBLEM:
The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and
719, are themselves prime.
There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79, and 97.
How many circular primes are there below one million?
SOLUTION:
Find all primes... | ALGO | 0.999705 | 6.548814 |
da1273bf-22b3-4587-80d4-4218094a4cda | maheshmahajanplk/CppPractice | Study/STL/min_max_compare.cpp | #include<iostream>
#include<vector>
#include<iterator>
#include<algorithm>
int main()
{
int max_count;
std::vector<int> vec1 = {11,12,13,14,15,16};
std::vector<int> vec2 = {19,20,21,22,23};
std::vector<int>::iterator itr;
itr = max_element(vec1.begin(),vec1.end());
itr = max_element(vec2.begin(),vec2.end(),[](... | ALGO | 0.983648 | 4.451725 |
dc314774-076b-4e06-9f5d-83991352cffe | sumonstr12/CODE | Problem_Solution_Online/Leetcode/Reverse_Nodes_in_k_Group.cpp | #include <bits/stdc++.h>
using namespace std;
struct ListNode{
int val;
ListNode *next;
ListNode(): val(0), next(nullptr){}
ListNode(int x): val(x), next(nullptr){}
};
class Solution{
public:
ListNode * createNode(){
ListNode *head = new ListNode();
ListNode *current = head;
... | ALGO | 0.99997 | 4.58988 |
a72fc499-44ae-44ef-8b76-167ffb4e7086 | a3X3k/B-Tech | S3/Advance Programming/Lab/10/4.cpp | #include<iostream>
#include<algorithm>
using namespace std;
class Point{
private:
int x, y;
public:
Point(int x = 0, int y = 0){
this->x = x;
this->y = y;
}
void display(){
cout << "("<<x<<", "<<y<<")";
}
friend bool comparePoints(Point &p1, Point &p2);
};
bool comparePoints(Po... | ALGO | 0.999889 | 4.599228 |
e2b6de2a-e4ca-4c26-8777-fd0b2ca733c5 | Shubham-9798/competitive-programming | greeksOfgreek/countNumberOfOccurenceOfNumber.cpp | // C++ program to count of index pairs with
// equal elements in an array.
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
// Driven Program
int main()
{
int arr[] = {1, 1, 2,2,1,3,4,100,4,3,44,91,44,33,91,22,44,0,0,5,-1,91,0,5};
int n=sizeof(arr)/sizeof(*arr);
cout<<n;
sort(arr,arr+n... | ALGO | 0.997246 | 4.056519 |
92d4fc64-c91f-4fcb-bb74-5899830334c9 | ishandutta2007/codeforces | huangxiaohua/normal/1500/B.cpp | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int i,j,n,m,a[500500],b[500500],c[1005000],d[1005000],no;
ll k,sb,sb1,chk,res,ans,tmp;
vector<ll> v;
ll A[10],B[10],SB=1,r;
ll x,y;
void exgcd(ll a,ll b,ll c){
if(!b){
if(c%a){no=1;}
else{x=c/a,y=0;no=0;}return;
}
exgcd(b,a%b,c);
ll xx=y,yy=x... | ALGO | 0.999975 | 3.186315 |
a2a4c201-240a-4462-8297-925653aff9ce | occidere/leetcode | Algorithms/922_Sort_Array_By_Parity_II/Solution.cpp | #include <cstdio>
#include <vector>
using namespace std;
class Solution {
public:
vector<int> sortArrayByParityII(vector<int>& A) {
int i = 0, j = 1, n = A.size();
vector<int> ans(n);
for (int& a : A) {
if (a % 2) {
ans[j] = a;
j += 2;
... | ALGO | 0.999965 | 5.290878 |
670feb26-03ce-4f47-a535-94a0622a409a | DJMAXJOAA/baekjoon | baekjoon/10809 알파벳 찾기.cpp | #include <iostream>
#include <cstring>
#include <string>
using namespace std;
int main()
{
char alphabet[26];
int alphabet_count[26];
char str[105];
char* pstr = str;
for (int i = 0; i < 26; i++)
{
alphabet[i] = 97 + i;
alphabet_count[i] = { -1 };
}
cin >> str;
int count = 0;
while (*pstr)
{
for (... | ALGO | 0.999945 | 3.687921 |
66b1ffb2-648e-4e52-aad4-ae1af80f17f3 | hl037/ljsoncppp | ljsonp.cpp | #include "ljsonp.hpp"
#include <utility>
#include <limits>
#include <climits>
namespace ljsoncpp
{
using namespace std;
#define UCHAR_MIN 0
#define USHRT_MIN 0
#define UINT_MIN 0
#define ULONG_MIN 0
#define ULLONG_MIN 0
#define Value__get(ty,u) \
template<>\
ty Value::get<ty>(bool * ok)\
{\
if(ok) *ok = true;\
... | TOOL | 0.879934 | 5.468161 |
e1b5fa04-f627-41b1-922c-63d4cb1b37fb | markd2/AdventOfCode | 2022/day-10-1.cpp | #import <iostream>
#import <vector>
// https://adventofcode.com/2022/day/10
// Cathode Ray Tuba
// clang++ -g -std=c++20 -o day-10-1 day-10-1.cpp
// ./day-10-1 < day-10-example.txt
// ./day-10-1 < day-10-prod.txt
using namespace std;
vector<string> instructions;
int main() {
string line;
// Slurp instruc... | ALGO | 0.987294 | 4.344121 |
6b621ddf-14f8-4789-b344-fd83e902e6bf | callsvc/plusnx | src/core/configs.cpp | #include <string>
#include <iostream>
#include <boost/container/small_vector.hpp>
#include <boost/unordered/unordered_flat_map.hpp>
#include <toml.hpp>
#include <sys_fs/fsys/regular_file.h>
#include <core/configs.h>
namespace Plusnx::Core {
// https://github.com/ToruNiina/toml11/blob/main/examples/boost_container... | CONFIG | 0.936644 | 6.796825 |
ecc87ef7-7d8a-497b-8e1c-b86854003db7 | Rage-Fox/LeetCode | 2411-smallest-subarrays-with-maximum-bitwise-or/2411-smallest-subarrays-with-maximum-bitwise-or.cpp | class Solution {
public:
vector<int> smallestSubarrays(vector<int>& nums) {
int n=nums.size();
vector<int> pos(31,-1);
vector<int> ans(n);
for(int i=n-1;i>=0;i--){
int j=i;
for(int bit=0;bit<31;bit++){
if(!(nums[i] & (1<<bit))){
... | ALGO | 0.999897 | 5.943195 |
37b1c334-4592-4031-83ff-0d60f42f1bef | ixza/image_dupe_checker | SSIM.cpp | //credits go to https://gist.github.com/Bibimaw/8873663
// i just added compare_image() resizer
#include "SSIM.hpp"
using namespace std;
using namespace cv;
// quality-metric
namespace qm
{
#define C1 (float) (0.01 * 255 * 0.01 * 255)
#define C2 (float) (0.03 * 255 * 0.03 * 255)
// sigma on block_size
double ... | ALGO | 0.984066 | 5.29249 |
5182d82b-355a-4b03-8514-788be5ac1d67 | yang48699997/code | atc/abc290/E_Make_it_Palindrome.cpp | #include <bits/stdc++.h>
using namespace std;
#define endl '\n'
using ll = long long;
void solve(){
int n;
cin>>n;
vector<vector<int>> e(n);
for(int i=0;i<n;i++){
int x;
cin>>x;
x--;
e[x].push_back(i);
}
ll ans=0;
for(int i=1;i<=n;i++){
ll cnt=n-i+1;
... | ALGO | 0.999868 | 3.69523 |
951e3e3f-31b7-4629-b2df-6bc12ffec352 | girldickenergy/Maple-Loader | Maple Loader/Dependencies/CryptoPP/crc_simd.cpp | // crc_simd.cpp - written and placed in the public domain by
// Jeffrey Walton, Uri Blumenthal and Marcel Raad.
//
// This source file uses intrinsics to gain access to SSE4.2 and
// ARMv8a CRC-32 and CRC-32C instructions. A separate source file
// is needed because additional CXXFLAGS are requi... | ALGO | 0.94984 | 6.669001 |
2d40e479-fc0e-4146-8730-c6a7448154dd | Ritax2003/DSA | Lecture3-conditions&loops/assignment-Find power of a number.cpp | #include<iostream>
using namespace std;
int main() {
int x,n,result=1;
cin>>x>>n;
while(n!=0){
result = result*x;
n=n-1;
}
cout<<result;
}
| ALGO | 0.999993 | 4.20805 |
a4e193d1-ae4d-423e-80f2-eb7818a72908 | sarvex/leetcode-fish | solution/1400-1499/1462.Course Schedule IV/Solution.cpp | class Solution {
public:
vector<bool> checkIfPrerequisite(int numCourses, vector<vector<int>>& prerequisites, vector<vector<int>>& queries) {
vector<vector<int>> g(numCourses, vector<int>(numCourses, -1));
for (auto& e : prerequisites) {
int a = e[0], b = e[1];
g[a][b] = 1;
... | ALGO | 0.999916 | 5.963184 |
f0298d18-cdbe-4bfe-8b28-9df3b9a5befe | steam7763/ICPC- | cscの板/板题/树剖线段树.cpp | #include<bits/stdc++.h>
#define rg register
#define Ls(x) x<<1
#define Rs(x) x<<1|1
#define int long long
using namespace std;
const int MAXN=200100;
int n,m,p,tot,num,root;
int Rank[MAXN],dep[MAXN],Size[MAXN]\
,dfn[MAXN],son[MAXN],fa[MAXN],\
top[MAXN],a[MAXN],head[MAXN];
struct Edge
{
int u,v,w,nex;
}E[MAXN<<2];
stru... | ALGO | 0.99995 | 3.520314 |
cfa035f4-c4b8-41c9-93cc-da1e60f2f68c | ishandutta2007/codeforces | nishant403/normal/1301/C.cpp | #include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int getRand(int l, int r)
{
uniform_int_distribution<int> uid(l, r);
return uid(rng);... | ALGO | 0.99996 | 4.840574 |
990652b8-f527-4bd9-97c8-922d1d28199c | Kenny3Shen/MyLeetcode | leetcode_by_cpp/2352.相等行列对.cpp | /*
* @lc app=leetcode.cn id=2352 lang=cpp
*
* [2352] 相等行列对
*
* https://leetcode.cn/problems/equal-row-and-column-pairs/description/
*
* algorithms
* Medium (71.90%)
* Likes: 28
* Dislikes: 0
* Total Accepted: 14.3K
* Total Submissions: 19.7K
* Testcase Example: '[[3,2,1],[1,7,6],[2,7,7]]'
*
* 给你一个... | ALGO | 0.999902 | 6.305786 |
d455d995-01cd-4b4d-b647-34ddda860d2f | Saiyangodgoku1/start-450 | Step-12(Binary Trees)/3.hard/10.serialize_deserialize.cpp | /*
QUESTION:
Write a function to serialize a binary tree to a single string and a function to deserialize that string back to a binary tree. The serialized format should be such that it allows for easy reconstruction of the original tree.
EXAMPLE:
Input:
Tree:
1
/ \
2 3
/ \
4 5... | ALGO | 0.99993 | 7.711832 |
9053909f-0edf-4dfa-8a06-8a71433c0e8c | ameyjain99/LeetCode | Solutions/0105. Construct Binary Tree from Preorder and Inorder Traversal/0105.cpp | class Solution {
public:
TreeNode* buildTree(vector<int>& preorder, vector<int>& inorder) {
unordered_map<int, int> inToIndex;
for (int i = 0; i < inorder.size(); ++i)
inToIndex[inorder[i]] = i;
return build(preorder, 0, preorder.size() - 1, inorder, 0,
inorder.size() - 1, inToIn... | ALGO | 0.999937 | 7.07441 |
75de7225-7a5b-4244-a88f-75690fa6d763 | ankushgarg1998/Competitive_Coding | practice-websites/interviewbit/Stacks and Queues/Nearest Smaller Element.cpp | vector<int> Solution::prevSmaller(vector<int> &A) {
vector<int> G;
stack<int> s;
for(int x: A) {
while(true) {
if(s.empty()) {
G.push_back(-1);
break;
}
if(s.top() < x) {
G.push_back(s.top());
break;
... | ALGO | 0.999992 | 5.418202 |
a2a0442a-473d-4b92-b0fe-623d18df7317 | Basel-3mk/Competitive-Programming | Range Queries/2D Segment Tree (Without Lazy Propagation).cpp | // You are given an n * n grid representing the map of a forest.
// Each square is either empty '.' or contains a tree '*'.
// The upper-left square has coordinates (1,1), and the lower-right square has coordinates (n,n).
// Your task is to process q queries of the form: how many trees are inside a given rectangle in ... | ALGO | 0.999248 | 4.482529 |
d8c2c655-78cc-4d2a-9f06-a6029b3f2247 | immiscible-blade/COL333_A3 | src/inputmaker.cpp | #include "../include/inputmaker.hpp"
using namespace std;
inputmaker::inputmaker(std::string filename, std::string outfile)
{
std::ifstream myfile;
myfile.open(filename);
int m;
myfile >> graphsize >> m >> k1 >> k2;
graph = (bool*)malloc((graphsize*graphsize) * sizeof(bool));
for (int i = ... | ALGO | 0.964281 | 4.069659 |
16ba4d03-91b9-4ccf-aef5-2fdb09856d8d | apawloski/miniMD-omp | output.cpp | #include "stdlib.h"
#include "stdio.h"
#include "math.h"
#include "mpi.h"
#include "ljs.h"
#include "atom.h"
#include "integrate.h"
#include "force.h"
#include "neighbor.h"
#include "comm.h"
#include "thermo.h"
#include "timer.h"
void stats(int, double *, double *, double *, double *, int, int *);
void output(In &in,... | ALGO | 0.968691 | 4.498982 |
4f6e7784-c39a-448d-ab2a-f5300e19be1a | krishna4040/DSA | gfg_practice/Hashing/winner_election.cpp | # include "bits/stdc++.h"
using namespace std;
vector<string> winner(string arr[],int n)
{
unordered_map<string,int> m;
for (int i = 0; i < n; i++)
m[arr[i]]++;
vector<string> ans;
int res = 0;
for (auto &&x : m)
res = max(res,x.second);
for (auto &&x : m)
{
if (x.se... | ALGO | 0.999947 | 4.612653 |
74b4b945-ad09-47b9-844b-9aa17b7175e8 | PikminGuts92/ExodusGame | Player.cpp | #include "Player.h"
// Main constructor
Player::Player(string inName, int inStart, int inEnd, bool inHuman)
{
for (int i = 0; i < NUM_PEGS; i++)
{
// Sets each to home position
peg[i] = -1;
}
name = inName;
startPosition = inStart;
endPosition = inEnd;
human = inHuman;
}
/... | TOOL | 0.922913 | 4.529177 |
30ebb8aa-c928-4688-8e36-39ecbb7709be | ACyming/OI | c++/DFS/DFS/【搜索与回溯算法】装箱问题.cpp | #include <iostream>
#include <algorithm>
using namespace std;
int v, n;
int a[40];
int sum = 0;
int main() {
cin >> v;
cin >> n;
for (int i = 0 ; i < n ; i++) {
cin >> a[i];
sum += a[i];
}
if (v == 10) {
cout << "1" << endl;
return 0;
}
if (sum <= v) {
cout << v - sum;
} else {
if (sum > v) {
sor... | ALGO | 0.999951 | 3.27189 |
aaea38e1-a229-4079-899e-53f112682d79 | 100RAV-AGGARWAL/Final-450 | matrix/Find specific pair in a matrix.cpp | #include <bits/stdc++.h>
using namespace std;
#define N 5
int findMaxValue(int mat[][N])
{
int maxDiff = INT_MIN;
int maxArr[N][N];
maxArr[N-1][N-1] = mat[N-1][N-1];
int maxD = mat[N-1][N-1];
for(int i=N-2; i>=0; i--) {
if(mat[N-1][i] > maxD)
maxD = mat[N-1][i];
maxAr... | ALGO | 0.999989 | 4.118407 |
5b771645-1615-40be-9c84-52a0a7c93db2 | tanaychaturvedi/-6Companies30days | Milestone 6 - Walmart/stone game.cpp | class Solution {
public:
int n;
int t[501][501];
int solve(vector<int>& piles, int left, int right) {
if(left > right)
return 0;
if(left == right)
return piles[left];
if(t[left][right] != -1)
return t[left][right];
... | ALGO | 0.999988 | 5.462974 |
c4d990ef-aa32-446e-907e-cd48bf8cfd54 | ziming-liu/leecode_start_from_12-2020 | string/6. ZigZag Conversion.cpp | /*
6. ZigZag Conversion
Medium
2065
5306
Add to List
Share
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)
P A H N
A P L S I I G
Y I R
And then read line by line: "PAHNAPLSIIGYIR"... | ALGO | 0.999982 | 6.334741 |
bede46d7-8501-4659-950f-d1fcedc4ea14 | prajjwals-stack/CODE_DAILY | 429-n-ary-tree-level-order-traversal/429-n-ary-tree-level-order-traversal.cpp | /*
// Definition for a Node.
class Node {
public:
int val;
vector<Node*> children;
Node() {}
Node(int _val) {
val = _val;
}
Node(int _val, vector<Node*> _children) {
val = _val;
children = _children;
}
};
*/
class Solution {
public:
vector<vector<int>> levelOr... | ALGO | 0.999961 | 6.001018 |
96c14f5f-19cf-463d-8746-19d4c759af77 | liuxiaocs7/AlgorithmLearn | LeetCode_C++/0143.重排链表.cpp | /*
* @lc app=leetcode.cn id=143 lang=cpp
*
* [143] 重排链表
*/
// @lc code=start
/**
* 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) : ... | ALGO | 0.999957 | 5.989883 |
36c1c8bf-7385-42b2-90a1-de5bf8be2532 | shiivamkumar027/BOOTCAMP9-jan-feb- | movezeros.cpp | #include<iostream>
using namespace std;
void moveZeros(int arr[],int n)
{
int count=0;
for( int i=0;i<n;i++)
{
if(arr[i] != 0)
{
int temp=arr[i];
arr[i]=arr[count];
arr[count]=temp;
count++;
}
}
}
int main()
{
int arr[5]={0,1,9,8,3};
i... | ALGO | 0.999921 | 4.107569 |
b9fd1db0-bd1b-422f-8a43-747a44b0b7f6 | XiaoyiLin-code/WHU-2024-DBanalysis | duckdb/extension/tpch/dbgen/text.cpp | /*
* text.c --- pseaudo text generator for use in DBGEN 2.0
*
* Defined Routines:
* dbg_text() -- select and translate a sentance form
*/
#ifdef TEXT_TEST
#define DECLARER
#endif /* TEST */
#include "dbgen/config.h"
#include <stdlib.h>
#ifndef WIN32
/* Change for Windows NT */
#include <unistd.h>
#endif /* WI... | TOOL | 0.860752 | 5.108446 |
5388080c-ff23-44da-9ada-b2c663d82bac | vevdokimovm/Computer-Science | C++/First-Works/Round-1/C. Лимонад для вечеринки/main.cpp | #include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
long long n, l, index;
cin >> n >> l;
vector <long long> cost(n);
vector <long long> v(n);
vector <long long> ans(n);
vector <long long> count_litrov(n);
for (long long i = 0; i < n... | ALGO | 0.999937 | 3.420887 |
1e06337c-196e-4108-81e9-03db827087c1 | mori399/old-lab | сем 2/ПнЯВУ/лаба 19/192.cpp | #include <iostream>
using namespace std;
class Double
{
public:
Double() : val(0)
{
}
Double(int d) : val(d)
{
}
void print() const
{
cout << val;
cout << endl;
}
operator int() const
{
return val;
}
Double& operator=(const double numb)
{... | TOOL | 0.869006 | 4.45263 |
fdd4b870-0959-40e2-981b-da50df2d1856 | ehnryx/acm | codeforces/1207/g-lca.cpp | #include <bits/stdc++.h>
using namespace std;
#define _USE_MATH_DEFINES
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// DON'T USE THESE MA... | ALGO | 0.999917 | 4.608224 |
2fe61c1b-45bb-499a-882d-e904fa251862 | hanish-hm/Leetcode | 0767-prime-number-of-set-bits-in-binary-representation/0767-prime-number-of-set-bits-in-binary-representation.cpp | class Solution {
public:
int totalsetbits(int n){
int setbits = 0;
while(n>1){
if(n%2!=0){
setbits++;
}
n=n/2;
}
setbits++;
return setbits;
}
bool isprime(int n){
if(n<2){
return false;
}
... | ALGO | 0.999996 | 5.432189 |
227a19ac-e669-4f50-a5f5-a1f88d158b5f | SANTHOSH-MAMIDISETTI/my-leet-code | 0026-remove-duplicates-from-sorted-array/0026-remove-duplicates-from-sorted-array.cpp | class Solution {
public:
int removeDuplicates(vector<int>& nums) {
int uniq=1;
for(int i=1;i<nums.size();i++)
{
if(nums[i]!=nums[i-1])
{
nums[uniq]=nums[i];
uniq++;
}
}
return uniq;
}
}; | ALGO | 0.999771 | 6.188612 |
9d663bff-455d-4860-91be-6d39fc927974 | ARC-Lab-UF/intel-training-modules | SYCL/examples/saxpy/saxpy_correct.cpp | // Greg Stitt
// University of Florida
//
// saxpy_correct.cpp
//
// This SYCL program will create a parallel (vectorized) version of the following
// sequential code:
//
// for (int i=0; i < VECTOR_SIZE; i++)
// z[i] = a * x[i] + y[i];
//
// This code implements a vectorized SAXPY operation (single-precesion AX + Y)... | ALGO | 0.926613 | 6.181338 |
e07243a2-3cb0-4b04-aa44-4d1d400490ca | shibh308/library | lib/classes/binarylifting.cpp | struct BinaryLifting{
int n;
vector<vector<int>> next;
vector<int> par;
vector<vector<int>> childs;
vector<int> depth;
BinaryLifting(vector<vector<int>>& edges, int root = 0) : n(edges.size()), depth(n, -1), par(n, -1), childs(n){
function<void(int)> dfs = [&](int x){
for(au... | ALGO | 0.999869 | 4.639669 |
bd4ebd75-0585-4fb0-ada5-906cb6f8a08a | Kaloyan-Nikolov/Data-Structures-and-Algorithms | Homeworks/Homework 4/Insert a node at a specific position in a linked list.cpp | /*
* For your reference:
*
* SinglyLinkedListNode {
* int data;
* SinglyLinkedListNode* next;
* };
*
*/
SinglyLinkedListNode* addTail(SinglyLinkedListNode* head, int data)
{
SinglyLinkedListNode* tail = head;
while(tail->next != nullptr)
{
tail = tail->next;
... | ALGO | 0.999539 | 4.444785 |
c124dffd-e7b2-4d8c-a471-c5752e32197b | Nanfengzhiwo1/UE5_2_L | Engine/Plugins/Experimental/GeometryScripting/Source/GeometryScriptingCore/Private/MeshDeformFunctions.cpp | #include "GeometryScript/MeshDeformFunctions.h"
#include "DynamicMesh/DynamicMesh3.h"
#include "DynamicMesh/DynamicMeshAttributeSet.h"
#include "EngineDefines.h"
#include "SpaceDeformerOps/BendMeshOp.h"
#include "SpaceDeformerOps/TwistMeshOp.h"
#include "SpaceDeformerOps/FlareMeshOp.h"
#include "DynamicMesh/MeshNormal... | TOOL | 0.931776 | 6.982234 |
7ad26f18-6cab-4d1e-9267-4302284b92d9 | tomn2804/Kanalysis | External Dependencies/boost_1_74_0/libs/math/example/neumann_zeros_example_1.cpp | #ifdef _MSC_VER
# pragma warning (disable : 4512) // assignment operator could not be generated.
# pragma warning (disable : 4996) // assignment operator could not be generated.
#endif
#include <iostream>
#include <limits>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <iterator>
//[neumann_zero... | ALGO | 0.998709 | 6.265656 |
2c0c2260-13d2-4e09-aebe-a68d8e8a8602 | oganaa/algorithms_and_solve_problem | leetcode/Greedy/arrayPairSum.cpp | class Solution
{
public:
int arrayPairSum(vector<int> &nums)
{
sort(nums.begin(), nums.end());
int ans = 0;
int n = nums.size();
for (int i = 0; i < n; i = i + 2)
{
ans = ans + nums[i];
}
return ans;
}
}; | ALGO | 0.999787 | 5.624521 |
618adeef-a785-44df-b0cc-e1589ac516b6 | wpn-zju/LeetCode-Dump | dump-cn/1061.lexicographically-smallest-equivalent-string.cpp | class Solution {
public:
class UnionFindEP2 {
public:
vector<int> nodes;
UnionFindEP2() {
nodes = vector<int>(26);
for (int i = 0; i < 26; ++i)
nodes[i] = i;
}
int find(int x) {
if (nodes[x] == x)
return x;
return nodes[x] = find(nodes[x]);
}
void unionEle(int a, int b) {
int pa ... | ALGO | 0.999989 | 6.066169 |
8eb7af51-5cc2-4376-a197-d4f79f705b35 | xyliu-cs/ParaProg | project4/src/simple_ml_ext.cpp | #include "simple_ml_ext.hpp"
DataSet::DataSet(size_t images_num, size_t input_dim)
: images_num(images_num), input_dim(input_dim)
{
images_matrix = new float[images_num * input_dim];
labels_array = new unsigned char[images_num];
}
DataSet::~DataSet()
{
delete[] images_matrix;
delete[] labels_array... | DATA | 0.983533 | 5.629651 |
e3914a5c-4336-4a08-bbb4-8bd6c681d42a | vinniapr/tugas-c-praktikum-sabtu | modul 6/tugas no 3 modul 6.cpp | #include <stdio.h>
int main()
{
int i;
int angka = 1;
for (i = 0; i < 11; i++) {
printf("%d ", angka);
angka *=2;
}
return 0;
}
| ALGO | 0.997874 | 3.871238 |
2e384b35-a730-480f-8ffc-330f1e19e612 | utkarsh-gith/Leetcode | LeetCodeProblems-CPP/33. Search in Rotated Sorted Array.cpp | // Idea: Rotated Sorted Array, so binary search
// First search the mid element if it matches with the target
// Thrn if mid elemnt is less than last element, we know pivot element is in first half,
// so check if the target lies in second half, if yes l=m+1 else h=m-1
// else the pivot element ... | ALGO | 0.999971 | 5.948298 |
d6107875-bc19-4239-bd20-df4cd1ecf378 | cran/binsegRcpp | src/interface.cpp | #include <Rcpp.h>
#include "depth_first.h"
#include "binseg.h"
#include "cum_median.h"
#include <stdio.h>
//' Efficient log-linear cumulative median.
// [[Rcpp::export]]
Rcpp::NumericVector cum_median_interface
(Rcpp::NumericVector data_vec, Rcpp::NumericVector weight_vec){
int n_data = data_vec.size();
if(weight_... | ALGO | 0.999538 | 5.919129 |
a8fd33f4-2fc3-44a2-968d-4262af6ea097 | ruddhirani/LeetCode | 1465-maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts/1465-maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts.cpp | class Solution {
public:
int MOD = 1e9 + 7;
int maxArea(int h, int w, vector<int>& horizontalCuts, vector<int>& verticalCuts) {
horizontalCuts.push_back(h);
sort(horizontalCuts.begin(), horizontalCuts.end());
verticalCuts.push_back(w);
sort(verticalCuts.begin(), vertical... | ALGO | 0.999967 | 5.824917 |
ec35e259-e00b-43de-aadd-a6e3c8506da4 | ucsrl/r2c-benchmarking | infra/llvm-passes/3.8.0/Common.cpp | #include "Common.h"
using namespace llvm;
/*
* Get the insert point after the specified instruction. For non-terminators
* this is the next instruction. For `invoke` intructions, create a new
* fallthrough block that jumps to the default return target, and return the
* jump instruction.
*/
Instruction *getInsert... | TOOL | 0.927001 | 7.333833 |
7e1cc297-eadc-481d-9d7f-1f402bb259da | Adnanbd/fcm-config | 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 |
f9ca86f7-79c7-4ad7-b9d1-cbc3a79bfada | mdeasinkhandokar/Data-Structures-Algorithms | STL/Map/Twice Counter.cpp |
///https://www.geeksforgeeks.org/problems/twice-counter4236/1
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long int
#define optimize() ios_base ::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main(){
optimize();
int t;
cin>>t;
while(t--){
int n;
cin>>n;
map<string ,in... | ALGO | 0.999055 | 5.05723 |
f22d0663-b409-495d-8403-970b3f05c51c | asar689/ds | 6.BST with Node Deletion.cpp | // Problem 6: Insert, all traversals (recursive and non-recursive), delete a node
#include <iostream>
#include <queue>
#include <stack>
using namespace std;
struct Node {
int data;
Node *left, *right;
Node(int val) : data(val), left(nullptr), right(nullptr) {}
};
Node* insert(Node* root, int val) {
if... | ALGO | 0.999708 | 6.760983 |
3fcd3308-2a80-4b42-b59f-0322c7ce532b | arjunatapadkar/Data-Structures-Algorithms | week 4 Searching and Sorting/Class 1 Searching and Sorting/binary-search.cpp |
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int bin_search(vector<int> arr, int target){
int start = 0;
int end = arr.size() -1;
int mid = start + (end - start)/2;
while(start <= end){
if(arr[mid]==target){
return mid;
}
else if(a... | ALGO | 0.999555 | 5.420122 |
4e3d4a18-9c8e-459d-aaa5-57b90b1c238e | brkdnmz/advent-of-code | 2024/day17/day17-2-wrong-solution.cpp | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
// this took way too long
// this solution fails because it's greedily choosing the smallest byte each time,
// instead of considering other candidates
// this ends up finding no valid solution! (the assertion byte != 7 fails)
int main() {
freop... | ALGO | 0.999879 | 4.388483 |
468ff22e-39be-4b51-9a5d-7e00dcc407f0 | lechenyu/Arbalest-Vec | libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp | // <vector>
// template <class InputIter> vector(InputIter first, InputIter last);
#include <vector>
#include <cassert>
#include <cstddef>
#include "test_macros.h"
#include "test_iterators.h"
#include "test_allocator.h"
#include "min_allocator.h"
#include "asan_testing.h"
#if TEST_STD_VER >= 11
#include "emplace_con... | TEST | 0.942179 | 7.472707 |
26fd6801-7edb-4537-82c9-51a5cef54083 | osama-mahmoud-h/Leetcode_solutions | 1292-maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold/1292-maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold.cpp | class Solution {
public:
bool squreSum(vector<vector<int>>& mat,int side,int threshold){
if(side ==0)return 0;
int rows = mat.size();
int cols = mat[0].size();
// cout<<"rows: "<<rows-side+1 <<"\n";
for (int i = 0; i <rows-side+1 ; ++i) {
for (int j = 0; j < cols-side+1; ++j) {
... | ALGO | 0.999835 | 5.805052 |
a3b7d699-6afb-4662-9dac-0835d52f9df0 | tamirgrBGU/EngineForAnimationCourse | igl/normalize_row_sums.cpp | template <typename DerivedA, typename DerivedB>
IGL_INLINE void igl::normalize_row_sums(
const Eigen::MatrixBase<DerivedA>& A,
Eigen::MatrixBase<DerivedB> & B)
{
#ifndef NDEBUG
// loop over rows
for(int i = 0; i < A.rows();i++)
{
typename DerivedB::Scalar sum = A.row(i).sum();
assert(sum != 0);
}
#e... | ALGO | 0.992041 | 3.82338 |
cc86e67c-5df6-4f81-b4c7-323edd59f33d | MohamedElabd2001/Alyosr_online | 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 |
a406491e-41a0-4115-9360-31d7d69ea8a1 | ishandutta2007/codeforces | 300iq/normal/978/A.cpp | #include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#includ... | ALGO | 0.999976 | 3.726318 |
2ad3ec35-d1eb-4cf1-b331-2138f812985f | demo-1111/solutions-leetcode | 0141-linked-list-cycle/0141-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)
{
ListNode* s=head, *f=head;
while(s!=NULL && f!=NULL && f->next!=NULL)
{
s=s->next;
... | ALGO | 0.9996 | 4.850609 |
c9b9b968-7cd6-4f76-acb2-4c183b2e9465 | NguyenHongSon4/taskapi | 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 |
d263dfe0-18d5-4773-aca2-b4c659d70d0b | DomoFox06/CSC134 | Module_7/M7Lab1.cpp | /*Domonic Yarnall
CSC 134
M7Lab1
5/7/25
*/
#include <iostream>
#include <vector>
#include <random>
#include <ctime>
using namespace std;
// TODO: Add better comments
// Direction constants
enum Direction {
NORTH = 1,
SOUTH = 2,
EAST = 4,
WEST = 8
};
// Mapping of direction to cell offset
const std::p... | ALGO | 0.999053 | 7.441264 |
fba96575-fb79-4062-b66a-4b0d106ee203 | jaewonlee16/data_structure | stack/util.cpp | #include <iostream>
#include <utility>
#include <vector>
#include <string>
#include "stack.hpp"
using namespace std;
bool checkParentheses(const string& line, const vector<pair<char,char>>& pairs){
//TODO
Stack<char> parentheses;
for (int i = 0; i < line.size(); i++){
char x = (char)line[i];
... | ALGO | 0.999358 | 4.221194 |
b66f3cc1-1d39-41ba-995f-f1a6d84d3c2f | SriGanesh-73/ADS | avl_tree.cpp | #include <iostream>
#include <algorithm>
using namespace std;
class AVLTreeNode {
public:
int data;
AVLTreeNode* left;
AVLTreeNode* right;
int height;
AVLTreeNode(int val) {
data = val;
left = nullptr;
right = nullptr;
height = 1;
}
};
class AVLTree {
public:
... | ALGO | 0.999626 | 6.347899 |
b7654c94-9c5d-4260-859d-de304a59cd23 | rgoliveira/USACO-tp | solutions/section-1.1/beads.cpp | /*
ID: ricardo39
PROG: beads
LANG: C++
*/
#include <iostream>
#include <fstream>
using namespace std;
int main(){
ofstream fout ( "beads.out" );
ifstream fin ( "beads.in" );
int n;
fin >> n;
string beads;
fin >> beads;
int i, j;
int p, q;
int count;
count = 0;
int... | ALGO | 0.999902 | 3.658843 |
fc7b9242-f29d-4342-963e-193a446ec1b8 | Altu-Bitu/Altu-Bitu_minjae | 1008/sample_16401.cpp | #include <iostream> //입출력 사용
#include <vector> //벡터 사용
#include <algorithm> //sort 사용
using namespace std;
int childNum(vector<int> &snacks, int len) { //&snacks: 과자 길이 정보 벡터, len: 과자 길이
int cnt = 0; //몇 명에게 나누어주는지
for (int i = snacks.size() - 1; i >= 0; i--) { //가장 긴 과자부터 검사
if (snacks[i] < len) //나누... | ALGO | 0.999963 | 5.508651 |
de6b7945-0519-432b-86c8-f05557a7576f | Housseem-Kouki/flutter_app | first_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.998481 | 6.76073 |
fd41bbeb-08a8-4951-ab8d-a2d10b6269a2 | MPSLab-ASU/CCF-20.04 | gem5/src/systemc/tests/systemc/misc/user_guide/chpt4.1/stage3.cpp | /*****************************************************************************
stage3.cpp --
Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15
*****************************************************************************/
/*****************************************************************************... | ALGO | 0.999455 | 4.191345 |
73312f10-4d9b-4d69-9441-1598783bf670 | swooploler/DAA | Rabin_Karp.cpp | // Rabin_Karp
#include <iostream>
#include <string>
using namespace std;
#define d 256
#define q 101
void search(const string& pat, const string& txt) {
int M = pat.length();
int N = txt.length();
int i, j;
int p = 0;
int t = 0;
int h = 1;
for (i = 0; i < M - 1; i++)
h = (h * ... | ALGO | 0.999974 | 6.315392 |
a2d102c3-aa21-47f2-94ae-ef0b20d88d10 | ouening/bouncescope | collision.cpp | #include "collision.h"
#include "vector2d.h"
#include "walls.h"
#include "ball.h"
#include <cmath>
using namespace std;
// Utility function to compute x squared
inline double square(double x) { return x * x; }
Collision findTimeUntilTwoBallsCollide(const Ball &b1, const Ball &b2) {
Collision clsn;
// Compute part... | ALGO | 0.999572 | 6.187687 |
aef8b4c4-d31f-4c38-a06f-734ee992069e | wujysh/2014_ACM_Summer_Training | 动态规划/四边形不等式优化/HDU_4374_One_hundred_layer.cpp | #include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN = 110;
const int MAXM = 10010;
const int INF = 0x3f3f3f3f;
int N, M, X, T, sum[MAXN][MAXM], ans;
int dp[MAXN][MAXM], q[MAXM][2], head, tail;
void init() {
ans = -INF;
}
void input() {
for (int i = 1; i <= N; i++) {
... | ALGO | 0.999941 | 3.858428 |
cd9b77ac-5fd3-47d4-b7d6-d61217841e7e | Alicia-Moraes/lista-12 | ex3.cpp | #include <stdio.h>
#include <stdlib.h>
typedef struct NoMatriz {
int valorElemento;
int indiceLinha;
int indiceColuna;
struct NoMatriz* proximoNo;
} NoMatriz;
typedef struct { //estrutura principal da matriz
NoMatriz* inicioListaElementos;
int numeroTotalLinhas;
int numeroTotalColunas;
... | ALGO | 0.976225 | 4.046115 |
bad8f69b-ed41-4fbe-81e2-2e4d312867cb | Tomuus/Zadanka | szkola/potegi.cpp | #include <iostream>
using namespace std;
int main()
{
long long n,i=1;
cin>>n;
while(i<=n)
{
cout<<i<<endl;
i*=2;
}
} | ALGO | 0.999831 | 3.655776 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.