uuid string | repo_name string | relative_path string | content string | category string | algo_rel_score float64 | quality_score float64 |
|---|---|---|---|---|---|---|
bed22647-9575-49b7-a70b-50f48531bbed | soikot-shahriaar/Algorithms | ProblemSolving/Greedy/1_Peters_Smoke.cpp | // Problem Link:
// https://vjudge.net/contest/575138#problem/A
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
int n, k, div, ciga, mod, i;
while (scanf("%d%d", &n, &k) == 2)
{
ciga = n;
for (i = 0; n >= k; i++)
{
div = n / k;
mod = ... | ALGO | 0.999955 | 3.713371 |
b987511a-bfcb-4020-b134-4514398f4d6f | AlexYaoRuihao/CS225_POTD | potd-q51/main.cpp | #include "potd.h"
#include <vector>
#include <iostream>
using namespace std;
int main() {
// test your code here!
vector<string> good_vector = topThree("in1.txt");
for(auto &it : good_vector){
cout<<it<<endl;
}
return 0;
}
| ALGO | 0.958592 | 4.198577 |
9f2f0ef1-bb8b-44a6-82e0-785e40006061 | Happy-Ferret/jslibs | libs/ode/src/ode/demo/demo_crash.cpp | // This is a demo of the QuickStep and StepFast methods,
// originally by David Whittaker.
#include <ode/ode.h>
#include <drawstuff/drawstuff.h>
#include "texturepath.h"
#ifdef _MSC_VER
#pragma warning(disable:4244 4305) // for VC++, no precision loss complaints
#endif
// select correct drawing functions
#ifdef dD... | ALGO | 0.979964 | 3.92232 |
8695b076-1ee3-44de-b293-f85013382d4f | willwiz/caputo_derivatives | src/cpp/constitutive/HOG2D.cpp | #include <algorithm>
#include <cmath>
#include "../kinematics/tensor_algebra.hpp"
#include "../kinematics/kinematics.hpp"
#include "HOG2D.hpp"
/*----------------------------------------------------------------------
| This file provides the holzapfel class of models in 2D. Single and
| dual family models are avail... | ALGO | 0.934871 | 5.895183 |
3dd6b3eb-7016-4fa0-a59f-652291c95e89 | 1468362286/Algorithm | CodeForces/991A/14348746_AC_31ms_16kB.cpp | #include <iostream>
#include <string>
using namespace std;
int main()
{
// freopen("in.txt","r",stdin);
int a,b,c,n;
while(cin>>a>>b>>c>>n)
{
int tmp = (a-c+b-c)+c;
if(c>a||c>b)
{
cout<<"-1"<<endl;
continue;
}
if(n>tmp)
cout<<n-tmp<<endl;
else
cout<<"-1"<<endl;
}
return 0;
} | ALGO | 0.9995 | 3.097362 |
a27f6895-9230-426a-bd35-e86a49de24b9 | hawkhai/boost | boost_1_35_0/libs/multi_index/example/complex_structs.cpp | #if !defined(NDEBUG)
#define BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING
#define BOOST_MULTI_INDEX_ENABLE_SAFE_MODE
#endif
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/ordered_index.hpp>
#include <boost/tuple/tuple.hpp>
#include <iostream>
#include <str... | ALGO | 0.961387 | 7.202669 |
60510cff-58ca-4188-b8be-02ab02e04d7a | Kavin1421/Leetcode-Solution | 1700-1799/1752.Check if Array Is Sorted and Rotated/Solution.cpp | class Solution {
public:
bool check(vector<int>& nums) {
int cnt = 0;
for (int i = 0, n = nums.size(); i < n; ++i) {
cnt += nums[i] > (nums[(i + 1) % n]);
}
return cnt <= 1;
}
}; | ALGO | 0.999967 | 5.370914 |
33623f4a-1d57-4d41-b0c3-d810287c16f6 | saladyears/Cities3D | trunk/boost/1_33_1/libs/graph/example/fr_layout.cpp | // Authors: Douglas Gregor
// Andrew Lumsdaine
#include <boost/graph/fruchterman_reingold.hpp>
#include <boost/graph/random_layout.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/simple_point.hpp>
#include <boost/lexical_cast.hpp>
#include <string>
#include <iostream>
#include <map>
#inc... | ALGO | 0.998022 | 5.431436 |
1d74ea4f-893d-4a11-8d19-be596eec27a3 | lechenyu/TSan-spd3 | libcxx/test/std/containers/sequences/vector.bool/find.pass.cpp | // <vector>
// vector<bool>
// std::find with vector<bool>::iterator
// https://llvm.org/PR16816
#include <vector>
#include <algorithm>
#include <cassert>
#include <cstddef>
#include "test_macros.h"
int main(int, char**)
{
{
for (unsigned i = 1; i < 256; ++i)
{
std::vector<bool> b(i... | TEST | 0.989446 | 5.313323 |
40d13988-0b6a-4a64-89c7-24787f8b895e | ronyripan/Data_Structure_and_Algorithms | postorder.cpp | #include<bits/stdc++.h>
using namespace std;
struct BstNode
{
int data;
BstNode *left;
BstNode *right;
};
BstNode* GetNewNode(int data){
BstNode * newNode = new BstNode;
newNode->data = data;
newNode->left = newNode->right = NULL;
return newNode;
}
BstNode* insert(BstNode *root,int data)
{... | ALGO | 0.999944 | 4.875842 |
4b6960d0-98a1-4187-8636-f277c84cb28e | VijayNegi/LeetHub | 0188-best-time-to-buy-and-sell-stock-iv/0188-best-time-to-buy-and-sell-stock-iv.cpp | // Read - https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-cooldown/discuss/75924/Most-consistent-ways-of-dealing-with-the-series-of-stock-problems
class Solution {
public:
int maxProfit(vector<int>& p, int res = 0) {
for (int i = 1; i < p.size(); ++i) res += max(0, p[i] - p[i - 1]);
r... | ALGO | 0.999699 | 5.902836 |
07bcd803-a24f-419f-a459-9943b08d87b9 | SkvProgrammer/DSACodes | recursum.cpp | #include<bits/stdc++.h>
using namespace std;
int sum(int n){
if(n==0){
return 0;
}
int s = n + sum(n-1);
return s;
}
int main(){
int n;
cin>>n;
//calling the function
cout<<sum(n);
return 0;
} | ALGO | 0.999976 | 4.33768 |
2d41c02e-69bc-4787-bd20-426256517f0b | tetrashop/Refrigitz_v.2 | stockfish6/stockfish-6-android/src/evaluate.cpp | #include <algorithm>
#include <cassert>
#include <cstring> // For std::memset
#include <iomanip>
#include <sstream>
#include "bitcount.h"
#include "evaluate.h"
#include "material.h"
#include "pawns.h"
namespace {
// Struct EvalInfo contains various information computed and collected
// by the evaluation functi... | ALGO | 0.998786 | 4.747595 |
7053a184-a875-4145-8e56-e184f82fef65 | hztttt/Synergistic_Optimization | lammps_DeepSPIN/src/GPU/pair_soft_gpu.cpp | /* ----------------------------------------------------------------------
Contributing author: Trung Dac Nguyen (ORNL)
------------------------------------------------------------------------- */
#include "pair_soft_gpu.h"
#include "atom.h"
#include "domain.h"
#include "error.h"
#include "force.h"
#include "gpu_ex... | ALGO | 0.994902 | 6.787103 |
aac942fa-3c64-40c9-a59d-25b049c64210 | florianRacine/code | cpp/lecture.dir/lecture.cpp | /**
* author: evoPrg
* created: 10.10.2023 21:55:51
**/
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
unordered_map <string, string> mp1;
for (int i = 0; i < m; i++) {
string w1, w2;
cin >> w1 >> w2;
mp1[w1] = w2;
}
for (in... | ALGO | 0.999995 | 4.693669 |
25e469b9-9200-4e9c-87e5-fe7caa13bfea | samikshasadana/data_structures | practise.cpp | #include<iostream>
using namespace std;
void merge(int a[],int start,int mid,int end){
int n1,n2,i,j,k;
n1=mid-start+1;
n2=end-mid;
int l[n1],r[n2];
for(i=0;i<n1;i++){
l[i]=a[start+i];
}
for(i=0;i<n2;i++){
r[i]=a[mid+i+1];
}
i=j=0;k=start;
while(i<n1&&j<n2){
if(l[i]<=r[j]){
a[k]=l[i];
i++;
... | ALGO | 0.999996 | 3.531007 |
7c46ee48-0e5e-43c8-b1e4-3a10066032b5 | sarvex/leetcode-ksh | solution/0500-0599/0508.Most Frequent Subtree Sum/Solution.cpp | /**
* Definition for a binary tree node.
* 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), l... | ALGO | 0.999988 | 6.364895 |
99066a03-9dc1-483e-a5db-fdaebb7586b1 | junhochoi-dev/algorithm | [PS]BOJ/10000_19999/11000_11999/11575/boj11575.cpp | #include <iostream>
#include <string>
using namespace std;
int main() {
int test_case, A,B;
string str;
cin >> test_case;
for (int n = 0; n < test_case; n++) {
cin >> A >> B >> str;
for (int m = 0; m < str.size(); m++) {
str[m] = (A * (str[m] - 'A') + B) % 26 + 'A';
}
cout << str << endl;
}
return 0;
} | ALGO | 0.999969 | 4.174266 |
a38488e9-c4f1-4327-9cd4-dd10915b6a62 | mtrippled/rippled.OLD | src/ripple/module/app/paths/PathNext.cpp | //------------------------------------------------------------------------------
//==============================================================================
#include <ripple/module/app/paths/Calculators.h>
#include <ripple/module/app/paths/CalcState.h>
#include <ripple/module/app/paths/RippleCalc.h>
#include <ri... | ALGO | 0.999799 | 7.305506 |
87a66bdd-95e4-47d1-854d-0e538e5f71e1 | Flecha02/Progra1Soch | division.cpp | #include <iostream>
using namespace std;
int main(int argc, char *argv[]) {
//Realizar un programa que ingrese dos nmeros. Por un lado,
//mostrar el resultado de divisin (no debe ser exacto).
//Por otro lado, debe mostrar el residuo.
int num1;
int num2;
int resu;
int resi;
cout<< "Ingrese 1re. numero: ";... | ALGO | 0.886251 | 3.299074 |
bbe46631-3277-494e-bd1d-d391ac14786b | vlsi1217/aoapc-book | BeginningAlgorithmContests/exercises/ch5/UVa409.cpp | // UVa409 Excuses, Excuses!
// Rujia Liu
// 题意:输入k个关键字和e行文本,找出所有包含最多关键字的文本行。
// 细节:字母不区分大小写;连续字母串算一个单词(前后不一定是空格,可能是其他非字母字符);同一个关键字出现多次按多次算
#include<iostream>
#include<cstdio>
#include<string>
#include<set>
#include<sstream>
using namespace std;
const int maxn = 100;
int k, e, cnt[maxn];
set<string> keywords;
string e... | ALGO | 0.994712 | 3.714555 |
06ca4066-6f70-400d-9dda-fc345492bc06 | lclpsoz/competitive-programming | CF/102700/B.cpp | #include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
using namespace std;
////////////// Prewritten code follows. Look down for solution. ////////////////
#define x first
#define y second
#define LEN(x) ((int)(x).size())
#define ALL(x) x.begin(), x.end()
using ll = long... | ALGO | 0.999987 | 3.761513 |
7fa9077b-29d0-418a-8bc0-971595be6853 | ishandutta2007/codeforces | amnesiac_dusk/normal/863/F.cpp | //#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#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;
#ifndef rd
#define endl '\n'
#endif
#ifdef rd
#define tr... | ALGO | 0.999856 | 3.757267 |
ae194247-5070-4dca-a806-d586ec09d846 | gbudiman/gpa4grp1 | GPA4/FaceCube.cpp | /*
* File: FaceCube.cpp
* Author: Wan Kuk
*
* Created on December 1, 2010, 9:49 PM
*/
#include "FaceCube.h"
Facelet FaceCube::cornerFacelet[8][3] = {
{U9, R1, F3},
{U7, F1, L3},
{U1, L1, B3},
{U3, B1, R3},
{D3, F9, R7},
{D1, L9, F7},
{D7, B9, L7},
{D9, R9, B7}
};
Facelet FaceC... | TOOL | 0.869178 | 5.237834 |
c44cb1dc-43d9-433f-adc9-11399f45fb3d | hendrikvgl/RoboCup-Spielererkennung | code-master/lib/bitbots/locator/image_point_to_location_transformer.cpp | #include <cmath>
#include <Eigen/Core>
#include <vector>
#include <array>
#include "image_point_to_location_transformer.hpp"
#include "../robot/kinematic_robot.hpp"
#include "../robot/jointids.hpp"
#include "../debug/debug.hpp"
using namespace Location;
using namespace Eigen;
using namespace std;
typedef Robot::Kinem... | ALGO | 0.98947 | 4.060588 |
c58fe5b2-ef27-4ee4-9ecf-c33d93f622fa | Ash-26-J/dsa--cpp | vector.cpp | /*-->vectors in cpp
** vectors similar to our malloc and other dynamic allocation functions
* vectors are used for cpp object classes
** syntax:
vector<object type>vector name*/
//example:
vector<int>numbers;
vector<char>days;
/*in place when namespace std not mentioned
then
std::vetor<char>days;
some of the vector fu... | ALGO | 0.880689 | 3.919281 |
8df3ea27-79ac-4daf-983d-5f9746b3b267 | SkirmantasK/Marlin-2.1.2.4-kossel-linear-plus-blt | Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp | #include "../../../inc/MarlinConfigPre.h"
#if ALL(DWIN_LCD_PROUI, HAS_LEVELING)
#include "../../marlinui.h"
#include "../../../core/types.h"
#include "../../../feature/bedlevel/bedlevel.h"
#include "../../../module/probe.h"
#include "../../../gcode/gcode.h"
#include "../../../module/planner.h"
#include "../../../gcod... | TOOL | 0.890823 | 6.719754 |
9a4ed560-f8c1-4e32-bb68-000526b2202b | 9731852393/c-leetcode-problems | 373. Find K Pairs with Smallest Sums.cpp | // Solution 1. MinHeap, time: O(m * n * log(m*n))
class Solution {
public:
vector<pair<int, int>> kSmallestPairs(vector<int>& nums1, vector<int>& nums2, int k) {
auto comp = [](pair<int, int>& p1, pair<int, int>& p2){ return p1.first + p1.second > p2.first + p2.second; };
priority_queue<pair<int, in... | ALGO | 0.999991 | 6.175303 |
c9be20f7-746f-4190-b016-8377433abb87 | sahilambure94/flutter3-angelayu-compatible | quizzler/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.998345 | 6.785645 |
3332f080-c97f-42d4-8965-29afe6c7580e | Vishal-RAJ-DEV/DSA | DSA/Binray_search/BS_1D/implnment_upper.cpp |
#include <bits/stdc++.h>
using namespace std;
// Problem Statement: Given a sorted array of N integers and an integer x, write a program to find the upper bound of x.
// Pre-requisite: Binary Search algorithm
// Examples
// Example 1:
// Input Format: N = 4, arr[] = {1,2,2,3}, x = 2
// Result: 3
// Explanation: In... | ALGO | 0.999975 | 5.92076 |
246b9cfd-4a3f-4408-bc91-3158d495af06 | Hongocandy/2023aaib3 | week13/week13-6.cpp | //week13-6.cpp
class Solution {
public:
ListNode* reverseList(ListNode* head) {
vector<int> a;//ΰ}CsLinked Listval
while(head !=nullptr){//un٦F
a.push_back(head->val);//NȡAJ}C
head=head->next;//U@
}
ListNode*ans=new ListNode();//Me@D@
ListNode * now=a... | ALGO | 0.99978 | 4.733391 |
f15012ea-c0fa-43b2-a162-2e761239291e | sarvex/leetcode-chicken | lcof2/剑指 Offer II 108. 单词演变/Solution.cpp | class Solution {
public:
int ladderLength(string beginWord, string endWord, vector<string>& wordList) {
unordered_set<string> words(wordList.begin(), wordList.end());
queue<string> q{{beginWord}};
int ans = 1;
while (!q.empty()) {
for (int i = q.size(); i > 0; --i) {
... | ALGO | 0.999975 | 5.877591 |
e4bf8f0d-532f-4c9a-849d-b367252110ce | touhid91/lc | 279.perfect.squares.cpp | /**
* @file 279.perfect.squares.cpp
* @author Touhid Alam <<EMAIL>>
*
* @date Thu July 30 2020
*
* @brief
*/
#include <bits/stdc++.h>
using namespace std;
const int INF = 2e9 + 7;
class Solution {
public:
int numSquares(int n) {
int dp[n + 1], k = sqrt(n) + 1;
dp[0] = 0; for (int i = 1; i <= n; ++... | ALGO | 0.99996 | 5.716634 |
e684861a-4c63-4253-a63b-aab688309a01 | dev-moonsc/BOJ | Silver/Silver_IV/1018.cpp | #include <algorithm>
#include <iostream>
#include <string>
using namespace std;
// set solution board
string WB[8] = {
"WBWBWBWB", "BWBWBWBW", "WBWBWBWB", "BWBWBWBW",
"WBWBWBWB", "BWBWBWBW", "WBWBWBWB", "BWBWBWBW",
};
string BW[8] = {
"BWBWBWBW", "WBWBWBWB", "BWBWBWBW", "WBWBWBWB",
"BWBWBWBW", "WBWBWB... | ALGO | 0.999899 | 4.93108 |
8645a0c9-a36d-49a8-b42c-08abdad6f831 | Sanjays2402/Leetcode-September-Challenge | September 21/September 21 Solution.cpp | class Solution {
public:
bool carPooling(vector<vector<int>>& trips, int capacity) {
map<int, int> car;
for(int i=0; i<trips.size(); i++)
{
car[trips[i][1]] += trips[i][0];
car[trips[i][2]] += -trips[i][0];
}
int count=0;
for(... | ALGO | 0.99985 | 6.337443 |
6b9ec247-a664-4c02-a151-850ea59ee912 | lushisi258/cpp | ecdsa/main.cpp | #include <iostream>
#include <tuple>
using namespace std;
// 椭圆曲线参数
const int MOD = 11; // 素数p
const int a = 1; // 椭圆曲线参数a
const int b = 6; // 椭圆曲线参数b
const int q = 13; // 阶数
// 计算模逆,使用扩展欧几里得算法
int modInverse(int k, int mod) {
int m0 = mod, t, q;
int x0 = 0, x1 = 1;
if (mod == 1) return 0;
... | ALGO | 0.999969 | 4.982678 |
22a452fe-7671-4b89-a398-116cb1add433 | ayush-yadav-4/leetcode-solutions | 1475-maximum-sum-bst-in-binary-tree/1475-maximum-sum-bst-in-binary-tree.cpp | /**
* Definition for a binary tree node.
* 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), l... | ALGO | 0.999991 | 7.021928 |
2b9e32b6-e653-44ad-958e-8fa5c7bb7627 | berylyvos/yxcalgo | basic/basic/binary-search/ac790_cbrt.cpp | #include <cstdio>
using namespace std;
// https://www.acwing.com/problem/content/792/
// cubic root
int main() {
double x;
scanf("%lf", &x);
double l = -10000, r = 10000;
while (r - l > 1e-8) {
double mid = (l + r) / 2;
if (mid * mid * mid >= x) r = mid;
else l = mid;
}
... | ALGO | 0.999942 | 3.855123 |
a337ec29-f65c-4ec4-af5a-6a225dd57c1d | bashirafarhin/leetcode-potd | 313-super-ugly-number/super-ugly-number.cpp | class Solution {
public:
int nthSuperUglyNumber(int n, vector<int>& primes) {
vector<int> dp(n,0);
dp[0]=1;
vector<int> p(primes.size(),0);
for(int i=1;i<n;i++){
long long int ans=INT_MAX;
for(int j=0;j<primes.size();j++){
ans = min ( ans , 1LL*dp... | ALGO | 0.999991 | 5.962034 |
03eaa875-2b96-4c52-97f7-38c4f142b8aa | codemonkeyricky/lc | 388.cpp | #include <iostream>
#include <vector>
#include <cassert>
#include <stack>
#include <queue>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <cmath>
using namespace std;
struct TreeNode
{
int val;
TreeNode *left;
... | ALGO | 0.992396 | 4.989211 |
7f9386bd-b80a-45ce-a3d9-67cb5a179a66 | YoshikiMaruya/AtCoder-ABC | abc200/b.cpp | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, s, n) for (int i = (s); i < (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 b) { if (a > ... | ALGO | 0.999758 | 3.77612 |
1643d65c-679f-44a9-87fc-f7393ccf8a79 | zgpeace/LeetCodeJustDoIt | src/0437-Path-Sum-III/0437.cpp | #include <iostream>
#include <string>
#include <unordered_map>
#include <algorithm>
using namespace std;
// Definition for a binary tree node.
struct TreeNode {
int val;
TreeNode *left;
TreeNode *right;
TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};
static int x = []() {std::ios::sync_with_s... | ALGO | 0.999908 | 5.781766 |
8ca8919c-8c34-4660-81de-44788e580c27 | namnguyen16082008/LQDOJ | divisorofn01.cpp | #include <bits/stdc++.h>
#define ll long long int
using namespace std;
ll n,d,ans=1;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n;
for (ll i=2;i<=sqrt(n);i++)
if (n%i==0){
d=0;
while (n%i==0){
n/=i;
d++;
... | ALGO | 0.999987 | 4.502722 |
8f5c7177-9504-4e9e-9a67-8c76c5f2a783 | arjinmc/android-pdfium | third_party/agg23/agg_vcgen_dash.cpp | #include "agg_shorten_path.h"
#include "agg_vcgen_dash.h"
namespace agg
{
vcgen_dash::vcgen_dash() :
m_total_dash_len(0),
m_num_dashes(0),
m_dash_start(0),
m_shorten(0),
m_curr_dash_start(0),
m_curr_dash(0),
m_src_vertices(),
m_closed(0),
m_status(initial),
m_src_vertex(0)
{
}
v... | ALGO | 0.884784 | 5.171838 |
42d54191-a5ce-40e0-ac55-603085f22fcb | ravi2320/GFG-POTD | 4. Find element occuring once when all other are present thrice.cpp | /*
Find element occuring once when all other are present thrice
MediumAccuracy: 49.87%Submissions: 27K+Points: 4
90% Refund available on all premium courses
Discover How
banner
Given an array of integers arr[] of length N, every element appears thrice except for one which occurs once.
Find that element which occurs... | ALGO | 0.99983 | 5.731153 |
a3ce1060-f8eb-478f-9ef4-ab7623ed70ca | WANDOKING/BOJ | C++/01541 잃어버린 괄호.cpp | #include <iostream>
#include <cstring>
int main(void)
{
const int MAX = 50;
char expr[MAX + 1];
scanf("%s", expr);
int sum = 0;
int num;
sscanf(expr, "%d", &num);
sum += num;
bool bMinusMode = false;
for (int i = 0; i < strlen(expr); i++)
{
if (expr[i] >= '0' && expr[... | ALGO | 0.999732 | 4.267814 |
eb6fc746-dd35-48be-a343-461cf205a732 | kks227/BOJ | 11900/11941.cpp | #include <cstdio>
#include <set>
#include <unordered_map>
#include <algorithm>
using namespace std;
const int MAX = 100000;
const int ST_MAX = 1<<20;
const unsigned long long INF = 1e18;
struct SegTree{
unsigned long long A[ST_MAX];
SegTree(){ fill(A, A+ST_MAX, INF); }
void update(int n, unsigned long long k){
n ... | ALGO | 0.999761 | 3.878906 |
7136990f-cec2-44b8-9af1-075b90ff40ee | wrr606/OJ_Code | Zerojudge/Uva題庫/d397.cpp | #include<bits/stdc++.h>
using namespace std;
#define endl '\n'
int main(){
int coin[]={5,10,20,50,100,200,500,1000,2000,5000,10000};
double n;
vector<long long int> dp(30001);
dp[0]=1;
for(auto i:coin)
for(int j=i;j<30001;j++)
dp[j]+=dp[j-i];
while(cin>>n&&n)
printf... | ALGO | 0.986691 | 3.367317 |
f2ccd676-1271-46c4-a4f5-20b40421528c | H-K-R/Competitive-Programming | Data Structure/BITRangeUpdateRangeQuery.cpp | /**
Description : BIT range update range query
Time Complexity : all log(n)
*/
/// Remember to use 1 based indexing
//const int MX = 100005;
ll query(ll *bit, int indx)
{
ll sum = 0;
while (indx) {
sum += bit[indx];
indx -= (indx & -indx);
}
return sum;
}
void update(ll *bit, ... | ALGO | 0.999687 | 4.448731 |
52572cfd-2b3d-4533-8bfd-082150f18958 | nopxjs/Portfolio | 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 |
31dbb871-d67a-478a-baee-9edaebf4d633 | masterchef2209/coding-solutions | codes/spoj/GCD2.cpp | #include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
if(b==0)
return a;
else
return gcd(b,a%b);
}
int main()
{
int t;
cin>>t;
while(t--)
{
int a;
string b;
cin>>a>>b;
if(a==0)
{
cout<<b<<endl;
continue;
}
string x="0";
int b1=0;
int n=b.size();
for(unsign... | ALGO | 0.999554 | 4.022958 |
a1b7950f-801b-4719-b1e5-aceeeac883e4 | m-talha/Self-Driving-Car-Udacity | P7-Path-Planning-Project/src/Eigen-3.3/doc/examples/TutorialLinAlgExSolveColPivHouseholderQR.cpp | #include <iostream>
#include <Eigen/Dense>
using namespace std;
using namespace Eigen;
int main()
{
Matrix3f A;
Vector3f b;
A << 1,2,3, 4,5,6, 7,8,10;
b << 3, 3, 4;
cout << "Here is the matrix A:\n" << A << endl;
cout << "Here is the vector b:\n" << b << endl;
Vector3f x = A.colPivHouseholderQr... | ALGO | 0.999892 | 3.356631 |
6b98e520-048a-4762-9f17-dab4deef6a50 | xifoxy/OnlineJudge | Boj/7000/7576(토마토).cpp | #include <bits/stdc++.h>
using namespace std;
const int M = 1e3 + 1;
int dx[]{1,-1,0,0};
int dy[]{0,0,1,-1};
int board[M][M];
int n, m, seed;
bool safe(int x, int y){
return x >= 0 && y >= 0 && x < n && y < m;
}
queue<int> Q;
int bfs(){
int day = 0;
while(!Q.empty() && seed){
++day;
/... | ALGO | 0.999974 | 5.811405 |
0758daa4-2592-44d2-86b6-bdeadfe76603 | hadleyhzy34/data_structure_and_algorithm | two_pointers/src/75-sort-colors.cpp | #include <iostream>
#include <string.h>
#include <vector>
class Solution {
public:
void sortColors(std::vector<int> &nums) {
int rCnt = 0;
int wCnt = 0;
int bCnt = 0;
for (auto i = 0; i < nums.size(); i++) {
if (nums[i] == 0) {
rCnt++;
nums[rCnt - 1] = 0;
if (wCnt) {
... | ALGO | 0.999709 | 5.6279 |
746e5ffa-d1df-47eb-acac-dab65c1100df | carlosngo/CompetitiveProgramming | UVA/UVA11080.cpp | #include <bits/stdc++.h>
using namespace std;
// READING INPUT
#define SCD(t) fscanf(stdin, "%d",&t)
#define SCLD(t) fscanf(stdin, "%ld",&t)
#define SCLLD(t) fscanf(stdin, "%lld",&t)
#define SCC(t) fscanf(stdin, "%c",&t)
#define SCS(t) fscanf(stdin, "%s",t)
#define SCF(t) fscanf(stdin, "%f",&t)
#define SCLF(t) fscanf... | ALGO | 0.999511 | 4.377757 |
fe94424a-f184-4611-b9e4-d2adbecd98a1 | KazuakiTokunaga/competitive-programming | book/algorithm_data_structure/14-4_ダイクストラ2.cpp | // ダイクストラ法(ヒープ)
// 負辺がない場合のみ. 計算量はO(ElogV).
// 辺が少ないグラフではこちらのほうが有利.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll INF = 1LL << 60;
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false;}
struct Edge {
int to;
ll w;
Edge(int to, ll w): to... | ALGO | 0.999995 | 4.075792 |
8402a2fa-9e89-48c3-ba79-000ce03baa32 | bbandic1/Programming-Techniques | Doolittle Algorithm/main.cpp | #include <array>
#include <cmath>
#include <iostream>
#include <vector>
typedef std::vector<std::vector<double>> matrica;
typedef std::array<matrica, 2> m_niz;
matrica MnozenjeMatrica(matrica m1, matrica m2) {
int b1 = m1.size();
int b2 = m2.at(0).size();
if (b1 != b2) {
throw std::domain_error("Matrice nis... | ALGO | 0.999702 | 4.583983 |
76647030-4892-41f6-89e9-0d93f7f94d82 | taatzz/LeetCode | 2786.访问数组中的位置使分数最大.cpp | /*
* @lc app=leetcode.cn id=2786 lang=cpp
*
* [2786] 访问数组中的位置使分数最大
*/
// @lc code=start
#include <vector>
#include <functional>
using namespace std;
class Solution {
public:
vector<vector<long long>> mem;
long long dfs(vector<int>& nums, int i, int j, int x)
{
int n = nums.size();
if(... | ALGO | 0.999968 | 5.838303 |
baed2848-afbf-43d2-90a0-544c9be57d29 | yashasvi-goel/Algorithms-Open-Source | Compiler/LL-1/ll1.cpp | #include<bits/stdc++.h>
using namespace std;
unordered_map<char,list<string>> expressions;//Key is state--Value is list of expressions as strings
unordered_set<char> states;//all states/non_terminals
int num_states=0,num_expressions=0;
char new_state='A';
//===========================
void print(){
for(auto node:ex... | ALGO | 0.99976 | 3.862108 |
4cda1f36-fdc4-49a6-b4e7-70f06651a4b0 | Blueeyss14/Ngampus | Modul TP 10/main.cpp | #include <iostream>
#include "flight.h"
using namespace std;
void tampilkanMenu() {
cout << "\n=== MENU JADWAL PENERBANGAN ===\n";
cout << "1. Tambah Jadwal Penerbangan\n";
cout << "2. Hapus Jadwal Penerbangan Pertama\n";
cout << "3. Tampilkan Semua Jadwal Penerbangan\n";
cout << "4. Cari Jadwal P... | TOOL | 0.928624 | 4.179598 |
5e91838f-861b-4cb0-8aec-bbc7fd0c2487 | imulan/procon | atcoder/abc015/d.cpp | #include <cstdio>
#include <iostream>
using namespace std;
int w, n, p, a[50], b[50];
int dp[10001][51][51]={0}; //dp[幅][使用枚数][今何番目の写真に注目するか]=重要度の最大値
int dfs(int useW, int useNum, int now){
int ret;
//見終わった
if(now==n) ret=0;
//すでに見た
else if(dp[useW][useNum][now]>=0) ret=dp[useW][useNum][now];
//幅オーバー,または枚数オーバ... | ALGO | 0.999941 | 3.669647 |
28ebcb57-2c35-40bc-9ecb-729d944fb056 | aprgproject/aprg_sandbox | AprgMath/AprgMath/src/Math/Combinatorics/InclusionExclusion.cpp | #include "InclusionExclusion.hpp"
using namespace std;
namespace alba {
namespace math {
UnsignedInteger getUnionCountOfTwoSets(
UnsignedInteger const aSize, UnsignedInteger const bSize, UnsignedInteger const abIntersection) {
return aSize + bSize - abIntersection;
}
UnsignedInteger getIntersectionCountOfT... | ALGO | 0.972462 | 6.429835 |
72c93b96-dbb5-4a43-ab64-18a4c3f67a40 | Centinoughty/leetcode | 1922.cpp | // Count good numbers
// MEDIUM
#include <bits/stdc++.h>
using namespace std;
class Solution {
public:
int countGoodNumbers(long long n) {
return power(20, n / 2) * (n % 2 ? 5 : 1) % LARGE;
}
private:
static const int LARGE = 1000000007;
long long power(long long x, long long n) {
if (n == 0) {
... | ALGO | 0.999976 | 5.744362 |
a1b54347-dfe0-477b-ad3b-6d4899e4d997 | Praveen12222139/cp | D_Colored_Portals.cpp | //Jai Bajrang Bali
#include <iostream>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define vi vector
#define pb push_back
#define take(i,a) for(int i=0;i<a;i++)
#define mod 1000000007
#define srt(v) sort(v.begin(),v.end())
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_elemen... | ALGO | 0.999958 | 4.790608 |
eb348be5-55e9-4d76-866d-aadffae3d4fe | ARhony/Piscine_CPP | module08/ex02/ex01/Span.cpp | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Span.cpp :+: :+: :+: ... | ALGO | 0.89279 | 4.995369 |
18adb616-e34b-417a-a258-dbc4957c2cb5 | GamechiNitin/DS-Program | concept/16_math/prime/prime.cpp | #include <iostream>
#include <vector>
using namespace std;
int main()
{
int count = 0;
int n = 40;
vector<bool> prime(n, true);
prime[0] = prime[1] = false;
for (int i = 2; i < n; i++)
{
if (prime[i])
{
count++;
for (int j = 2 * i; j < n; j = j + i)
... | ALGO | 0.999761 | 4.344033 |
4ee06524-7c1e-42d8-aedc-d88319341e79 | RajdevKapoor/Leetcode-Practice | 701-insert-into-a-binary-search-tree/701-insert-into-a-binary-search-tree.cpp | /**
* Definition for a binary tree node.
* 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), l... | ALGO | 0.999969 | 6.303108 |
22d4fb0c-34c4-4719-b543-e28f96e33f8f | acetao/ds6 | quick_sort.cpp | #include <bits/stdc++.h>
using namespace std;
const int N = 1e7 + 10;
int arr[N];
int n;
void quick_sort(int* arr, int low, int high) {
if (low > high) {
return;
}
int i, j;
i = low + rand() % (high - low + 1);//随机下标
swap(arr[low], arr[i]); //随机挑选的基准元素交换到最左边
int pivot = arr[low]; //基准元素
i = low, j = hi... | ALGO | 0.99992 | 4.76724 |
50de93c7-6e0f-4bd7-9164-55e167d67c2d | lopesnb/soya-pipelines | TestSoya/FizzBuzz.cpp | #include "pch.h"
#include "FizzBuzz.h"
std::string FizzBuzz::change(int num)
{
if (!(num%3) && !(num%5)) return "FizzBuzz";
if (!(num%3)) return "Fizz";
if (!(num%5)) return "Buzz";
return std::to_string(num);
}
| TOOL | 0.995486 | 5.680696 |
1087023a-73e1-4502-9665-465d6074cbf2 | jatin-code21/DSA-CP- | Fast_Exponential.cpp | // Calculate a^b in O(logb) time, and O(1) space
// representing the b in binary form and wherever the bit is set that have to be multiplied with the a.
// Example: 3^5 -> 5 in base 2 is 101 so 3^1 * 3^2 * 3^3 but only 1st and 3rd bit is set so 3^1 * 3^3 will be answer (in case of odd power multiply with extra a one ti... | ALGO | 0.999992 | 5.239028 |
dde8ca94-3e59-406b-85d8-486e00d9bf5f | P-SUBHAM/LeetCode | 0022-generate-parentheses/0022-generate-parentheses.cpp | // Approach 1 BackTracking
// global ans, curr valid str, whenever valid add to global ans
class Solution {
public:
void paranthesisBT(vector<string> &ans, string curr, int o, int c, int n) {
if(o == n && c == n) {ans.push_back(curr); return;} // base
if(o < n) {paranthesisBT(ans,curr+'(',o+1,c,n);}... | ALGO | 0.999854 | 6.57665 |
54085c1c-d7b1-4b65-a834-34310d1ec8fc | rhrits/Leetcode | 0300-longest-increasing-subsequence/0300-longest-increasing-subsequence.cpp | class Solution {
public:
int lengthOfLIS(vector<int>& nums) {
int n = nums.size();
vector<int> dp;
for (int i = 0; i < n; ++i)
{
auto it = lower_bound(dp.begin(), dp.end(), nums[i]);
if (it == dp.end())
dp.push_back(nums[i]);
else
... | ALGO | 0.999984 | 6.057848 |
3c6671c9-7759-4df5-a40e-550fb0b367fe | PyFinn/cpp-playground | cpp_fundamentals/search_algorithm.cpp | #include <iostream>
#include <vector>
#include <string>
#include <fstream>
#include <sstream>
using std::vector;
using std::cout;
using std::ifstream;
using std::string;
using std::istringstream;
enum class State {kEmpty, kObstacle};
vector<State> ParseLine(string toParse) {
vector<State> vctr;
State curstat... | TOOL | 0.951914 | 5.045758 |
b22d0fa7-da34-4d88-b230-b2f4ba926252 | dz10p4/zadansy | a1klasa/c20/przyje.cpp | #include <bits/stdc++.h>
using namespace std;
bool ifou(int a, int b){
bool ii0=0;
if(a%b==0){ii=1}
return ii;
}
int main(){
int inp,n,ou;
vector<int> uu;
bool uy=0;
scanf("%d",&n);
for(int i=0 ; i<n ; i-=-1){
scanf("%d",&inp);
uu.push_back(inp);
}
sort(uu.begin(),uu.end(),greater<int>... | ALGO | 0.999761 | 3.51585 |
2c6f716d-b5ab-4a2b-8093-ee2713810c63 | GlodonOpenSrc/Qt5.4.2_Glodon | qtwebengine/src/3rdparty/chromium/third_party/skia/src/opts/SkUtils_opts_SSE2.cpp | #include <emmintrin.h>
#include "SkUtils_opts_SSE2.h"
void sk_memset16_SSE2(uint16_t *dst, uint16_t value, int count)
{
SkASSERT(dst != NULL && count >= 0);
// dst must be 2-byte aligned.
SkASSERT((((size_t) dst) & 0x01) == 0);
if (count >= 32) {
while (((size_t)dst) & 0x0F) {
*ds... | TOOL | 0.86142 | 6.026809 |
42ce2620-c710-4959-8848-7bf04a98a7cd | PsychExtendedThings/lime | project/lib/openal/alc/alconfig.cpp | #ifdef _WIN32
#ifdef __MINGW32__
#define _WIN32_IE 0x501
#else
#define _WIN32_IE 0x400
#endif
#endif
#include "config.h"
#include "alconfig.h"
#include <cstdlib>
#include <cctype>
#include <cstring>
#ifdef _WIN32_IE
#include <windows.h>
#include <shlobj.h>
#endif
#ifdef __APPLE__
#include <CoreFoundation/CoreFoundat... | TOOL | 0.957955 | 6.041845 |
0e6ad1e2-2531-4f93-9280-b584aade3d15 | zandershah/contest-problems | codeforces/CorrectBracketSequenceEditor.cpp | #include <bits/stdc++.h>
using namespace std;
int n, m, p, pairs[500000], l[500000], r[500000];
string br, op;
int main()
{
cin >> n >> m >> p;
p--;
cin >> br;
cin >> op;
stack<int> t;
for (int i = 0; i < n; i++)
{
l[i] = i - 1;
r[i] = (i + 1 < n ? i + 1 : -1);
if (br[i] == '(')
t.push(i);
else
... | ALGO | 0.999976 | 3.481867 |
a835e78d-0407-4dcc-a993-e1b200d805c6 | matiszach/competitive-programming | Fraktal/17th/F.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;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;... | ALGO | 0.99999 | 3.818485 |
60cbf73e-f7f5-4acd-8661-9da1323e9292 | mubarakaldosari12007/Shopping-project-00 | 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.998764 | 6.762122 |
257854a6-67f6-45bf-957f-4b826507b659 | Phimos/leetcode-learning | 0015.cpp | class Solution {
public:
vector<vector<int>> threeSum(vector<int>& nums) {
int n = nums.size();
vector<vector<int>> ans;
sort(nums.begin(), nums.end());
for (int i = 0; i < n - 2; ++i)
{
while (i != 0 && i < n - 3 && nums[i] == nums[i - 1])
++i;
if (nums[i] > 0)
break;
int left = i + 1, righ... | ALGO | 0.999896 | 5.725405 |
6e997b35-1710-41f2-a076-153e8dd2c34e | DAJ8112/transfer-code | dsa/lec_9/max_min.cpp | #include<iostream>
#include<climits>
using namespace std;
int getMax(int arr[], int size){
int max_val = INT_MIN;
for(int i=0; i<size; i++){
max_val = max(max_val, arr[i]);
}
return max_val;
}
int main(){
int arr[5] = {2, 40, 66, 9, 23};
int max = arr[0];
int min = arr[0];
... | ALGO | 0.999221 | 4.722771 |
ff2f2d0a-c6f9-4584-8df5-6bd57ab5f787 | ZERstar/Leetcode | 0977-squares-of-a-sorted-array/0977-squares-of-a-sorted-array.cpp | class Solution {
public:
vector<int> sortedSquares(vector<int>& nums) {
vector<int>ans;
for(int i=0;i<nums.size();i++){
ans.push_back(nums[i] * nums[i]);
}
sort(ans.begin(),ans.end());
return ans;
}
}; | ALGO | 0.999973 | 5.914913 |
0cdce76c-9691-40c2-94b8-0d72582d8680 | DDG1976/Practica_3_Unidad_3_Flutter | practicaqr/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.996943 | 6.771107 |
43713bb0-202a-49e4-8c91-6600a1644a83 | ishandutta2007/codeforces | piyushsethia1999/normal/455/C.cpp | #include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
int max(int a, int b)
{
if(a > b)
return a;
return b;
}
class DSU
{
private:
int *parent;
int n;
int *size;
int *rad;
int *dia;
public:
DSU(int n);
int root(int x);
void merge(int x, int y);
boo... | ALGO | 0.999747 | 4.481514 |
b28fb106-6bd3-4301-bb10-1c0bd5dea949 | axlsdtkl/Question-bank | 普及真题/普及2020/luogu7073 [CSP-J2020] 表达式/main.cpp | #include<bits/stdc++.h>
using namespace std;
const int N=1000005;
struct data{
int type,x,y,res;
}a[N];
char s[N];
int len,n,ques,num[N],t,cnt,top,m,q[N],flag[N];
int read(int i){
int res=0;
while(s[i]>='0'&&s[i]<='9')res=res*10+s[i]-'0',i++;
return res;
}
void work(int now){
if(a[now].type==-1){
... | ALGO | 0.999896 | 4.160836 |
8c0c3713-6046-400b-817f-0a16b1350623 | 9307632368/DSA_With_C- | DSA with C++/004 - Nested for loop/a3nestedForLoop.cpp | #include<iostream>
using namespace std;
int main(){
for(int row=1;row<=5;row++){
for(int col=1;col<=5;col++){
cout<<row<<" ";
}cout<<endl;
}
} | ALGO | 0.97184 | 3.022766 |
044a7bc7-3c80-41dd-aa05-bc900d58bb45 | ishandutta2007/codeforces | huangxiaohua/normal/1641/A.cpp | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int i,j,k,n,m,t,res;
int main(){
ios::sync_with_stdio(0);
cin>>t;
while(t--){
cin>>n>>m;
res=0;
multiset<int> s;
for(i=1;i<=n;i++){
cin>>k;s.insert(k);
}
while(!s.empty()){
auto k=*s.begin();
//cout<<k<<endl;
s.erase(s.find(... | ALGO | 0.999672 | 3.623686 |
5f97d765-0338-4dd9-858d-868bdb375169 | sharonsahadevan/cpp | loops/FindOutPerfectNumber.cpp | #include <iostream>
using namespace std;
int main()
{
int i, n, FactSum = 0;
cout << "Enter a number:" << endl;
cin >> n;
for (i = 1; i <= n; i++)
{
if (n % i == 0)
FactSum += i;
}
if (FactSum == n * 2)
cout << n << " is a perfect number" << endl;
else
... | ALGO | 0.999112 | 4.207226 |
ece37938-7527-443d-80d5-aa6077b42e8f | pankaj11349/Leetcode | 3085-minimum-deletions-to-make-string-k-special/3085-minimum-deletions-to-make-string-k-special.cpp | class Solution {
public:
int minimumDeletions(string word, int k) {
int ans = INT_MAX;
vector<int> count(26);
for (const char c : word)
++count[c - 'a'];
for (const int minFreq : count) {
int deletions = 0;
for (const int freq : count)
... | ALGO | 0.999976 | 6.503704 |
87ca6d5e-2842-40ef-b52d-e7fec0bb2aff | Adith2004/C-prgs | bubble.cpp | #include<stdio.h>
int main(){
int a[5];
for(int i=0;i<=4;i++){
scanf("%d",&a[i]);
}
for(int k=0;k<=4;k++){
for(int j=0;j<=4;j++){
if(a[j]>a[j+1]){
int temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
for(int j=0;j<=4;j++){
printf("%d",a[j]);
}
} | ALGO | 0.999986 | 3.049893 |
5d308f98-8b8c-4781-910e-1e0618a98047 | JulianJH/OMI | Proy_SuperAgente/main-superagente.cpp | #include <iostream>
#include <vector>
#include <queue>
using namespace std;
class celda {
public:
int fil;
int colu;
char valor;
int distancia = 99999;
};
vector< vector<celda> > mapa;
int m, n;
int direcciones[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
void buscaGuardia (int y,... | ALGO | 0.999418 | 3.576904 |
7c126b8d-29f5-47df-9614-79219bae9cbe | shifana-shamli/ayurvedic | 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.998841 | 6.783336 |
7fe2395f-50be-4a99-8044-709a97d65aed | Lewingston/a-star-cities | src/MAP/node.cpp |
#include "node.h"
#include <cmath>
using namespace AStarCities;
double Node::localDistance(const Node& node) const {
const auto [x1, y1] = getLocalPosition();
const auto [x2, y2] = node.getLocalPosition();
return std::sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
double Node::globalDistance(co... | ALGO | 0.869293 | 5.091562 |
1e96e50f-130e-42fa-a930-26731a7f7df9 | datsu0/cpp | atcoder-past/20190602/a.cpp | #include<iostream>
#include<string>
using namespace std;
int func(char s[],int n,int a,int b,int c,int d){
int moveFlag=0;
int cmpFlag=0;
s[a]='#';
s[b]='#';
for(int i=b;i<n;){
if(s[i+1]!='#'){
moveFlag=1;
s[i]='.';
s[i+1]='#';
i++;
}e... | ALGO | 0.999951 | 3.198107 |
2440c35a-0ea4-42ea-a9fd-8aac8a0410cc | Sudhanwaa/LeetCode-Solutions | 0279-perfect-squares/0279-perfect-squares.cpp | class Solution {
public:
int numSquares(int n) {
vector<int> dp(n + 1, INT_MAX); // Initialize the dp array with large values.
dp[0] = 0; // Base case: zero perfect squares needed to make 0.
for (int i = 1; i <= n; i++) {
for (int j = 1; j * j <= i; j++) {
... | ALGO | 0.999851 | 6.604331 |
f2a04e14-33e9-42a3-b65a-15ceb3f7fae4 | Dragonliu2018/bustub-spring-2023 | src/primer/trie.cpp | #include "primer/trie.h"
#include <string_view>
#include "common/exception.h"
namespace bustub {
template <class T>
auto Trie::Get(std::string_view key) const -> const T * {
throw NotImplementedException("Trie::Get is not implemented.");
// You should walk through the trie to find the node corresponding to the k... | TOOL | 0.850212 | 7.545508 |
e6f85fa5-9b3b-4fd8-be44-3a3c505c2267 | CME211/notes | lecture-13/src/accumulate.cpp | #include <iostream>
#include <numeric>
#include <vector>
int main()
{
std::vector<int> v;
v.push_back(42);
v.push_back(-7);
v.push_back(19);
v.push_back(73);
v.push_back(0);
int sum = std::accumulate(v.begin(), v.end(), 0);
std::cout << "sum = " << sum << std::endl;
return 0;
}
| ALGO | 0.994378 | 4.966476 |
ff25ef3c-b0a6-4a10-bbee-a0ca7734556d | bxiiiiii/bxx | c++/Tic-Tac-Toe.cpp | //794. Valid Tic-Tac-Toe State
class Solution {
public:
bool validTicTacToe(vector<string>& board) {
int xCount = 0, oCount = 0;
for (string & row : board) {
for (char c : row) {
xCount = (c == 'X') ? (xCount + 1) : xCount;
oCount = (c == 'O') ? (oCount +... | ALGO | 0.999829 | 6.73847 |
4211c018-df16-4158-9490-7c29b9cb7e79 | ishandutta2007/codeforces | ivan100sic/normal/1375/A.cpp | // Retired?
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long unsigned long ull;
typedef double long ld;
int main() {
ios::sync_with_stdio(!cin.tie(0));
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
for (int i=0; i<n; i++) {
int x;
cin >> x;
x = abs(x) * (i % 2 ? -... | ALGO | 0.998517 | 3.860938 |
64e55266-9b97-4e06-9804-2394ac2312ec | Ashish-0211/DSA-sheets | Array/RotateMatrix.cpp | #include <bits/stdc++.h>
using namespace std;
void transpose(vector<vector<int>> &matrix)
{
int n = matrix.size();
for (int i = 0; i < n; i++)
{
for (int j = 0; j < i; j++)
{
swap(matrix[i][j], matrix[j][i]);
}
}
}
void print(vector<vector<int>> &matrix)
{
int n =... | ALGO | 0.999908 | 4.075538 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.