uuid string | repo_name string | relative_path string | content string | category string | algo_rel_score float64 | quality_score float64 |
|---|---|---|---|---|---|---|
467676f5-1f91-46ed-ac6b-7a8b146a1206 | AshfaqueSami2/problem-solving | codeforce sheet 6/R.cpp | #include<iostream>
#include<math.h>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{
double x1,y1,x2,y2;
cin>>x1>>y1>>x2>>y2;
double a = (x2 - x1);
double b = (y2 - y1);
double result = sqrt((a*a)+(b*b)) ;
cout<<fixed<<setprecision(9)<<result<<endl;
} | ALGO | 0.999777 | 3.671104 |
fd6bf253-25a7-4f96-b2c1-10ac0d6e8997 | Anuj-S62/Interview-Bit-Solutions | distinct_number_in_window.cpp | #include<bits/stdc++.h>
using namespace std;
void show(vector<int> vec){
for(auto i:vec) cout<<i<<", ";
cout<<endl;
}
void disp_mp(unordered_map<int,int> mp){
for(auto i:mp){
cout<<i.first<<" "<<i.second<<endl;
}
cout<<endl;
}
vector<int> dNums(vector<int> &A, int B) {
vector<int> ans... | ALGO | 0.999956 | 4.649101 |
ac019ddf-2be9-4dfb-ae82-7afd0d23e0ca | 0xm4yo/compro | atcoder/virtual/att/abc327_f.cpp | #include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
template <class T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, a, b) for(ll i=a; i<b; i++)
#define rrep(i, a, b) for(ll i=a; i>=b;... | ALGO | 0.999978 | 4.618417 |
79cc0196-8103-4a34-8f6b-96d4bd0b35ff | ishandutta2007/codeforces | yogahmad77/normal/1185/E.cpp | // #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fbo find_by_order
#def... | ALGO | 0.999891 | 3.526384 |
89feffcc-5035-40a4-ae20-3bf0ebb1525e | P0L3NARUBA/roblox-2016-source-code | Contribs/boost_1_56_0/libs/msm/doc/HTML/examples/iPodSearchEuml.cpp | // same as iPodSearch.cpp but using eUML
// requires boost >= v1.40 because using mpl::string
#include <vector>
#include <iostream>
#include <boost/msm/back/state_machine.hpp>
#include <boost/msm/front/euml/euml.hpp>
#include <boost/msm/front/euml/stl.hpp>
using namespace std;
using namespace boost::msm::front::euml... | ALGO | 0.988234 | 5.712324 |
7329755b-1707-49e7-b81a-853d04164b95 | MarianaSnchez1/AlgoritmosYEstructuraDeDatos | Cositos de busqueda y ordenamiento/codigo1.cpp | //Problema de ordenamiento
#include <iostream>
#include <vector>
using namespace std;
void insertion_sort (vector<int> &v){
for (unsigned i=1; i<v.size(); i++){
int j=i-1, x= v[i];
while (j>= 0 && v[j]>x){
v[j+1] = v[j];
j--;
}
v[j+1]=x;
}
}
void selection_sort (vector <int> &v){
... | ALGO | 0.999531 | 4.276262 |
c90f9757-5d96-4cdb-88ef-b3ea69f8171a | rahulkr-24/gfg_problems | Easy/Winner of an election/winner-of-an-election.cpp | //{ Driver Code Starts
#include <iostream>
#include <map>
#include <algorithm>
#include <cstdlib>
#include<bits/stdc++.h>
using namespace std;
// } Driver Code Ends
class Solution{
public:
//Function to return the name of candidate that received maximum votes.
vector<string> winner(string arr[],int n)
... | ALGO | 0.999963 | 5.870765 |
65526342-ef7c-4f92-828d-0088b7626dc7 | sarvex/leetcode-c3 | solution/1900-1999/1983.Widest Pair of Indices With Equal Range Sum/Solution.cpp | class Solution {
public:
int widestPairOfIndices(vector<int>& nums1, vector<int>& nums2) {
unordered_map<int, int> d;
d[0] = -1;
int ans = 0, s = 0;
int n = nums1.size();
for (int i = 0; i < n; ++i) {
s += nums1[i] - nums2[i];
if (d.count(s)) {
... | ALGO | 0.999983 | 5.686088 |
e7246145-53e4-435c-8ee9-711e3f0f1284 | AkashItlogiko/Cpp_tutorial | Problem solving/C++ Program to Find Factorial.cpp | #include <iostream>
using namespace std;
int main()
{
int n,i,factorial;
cout<<"Enter a number:"<<endl;
cin>>n;
factorial=n;
for(i=1;i<n;i++)
{
factorial=factorial*i;
}
cout<<"factorial value is :"<<factorial;
return 0;
}
| ALGO | 0.999615 | 3.321135 |
fd993d1a-61e4-4f76-8985-9a8f932cea8f | moinulshaon/Light-OJ | vol10/1089__completed/1089.cpp | #include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
using namespace std;
#define SIZE 200000
int tree[SIZE];
int MaxVal;
int read(int idx){
int sum = 0;
while (idx > 0){
sum += tree[idx];
idx -= (idx & -idx);
}
return sum;
}
void update(int idx ,int val... | ALGO | 0.999955 | 3.864257 |
5f701a8b-d2f7-4672-bbef-7807b7605e1c | Fresh-up/leetcode | 剑指 Offer 65. 不用加减乘除做加法/位运算.cpp | class Solution {
public:
int add(int a, int b) {
while (b != 0) {// 当进位为0时跳出
// 要加unsigned int否则会溢出
int c = (unsigned int)(a & b) << 1;// c = 进位
a ^= b;// a = 非进位和
b = c;// b = 进位
}
return a;
}
};
// O(1) O(1) | ALGO | 0.999919 | 5.559485 |
0247c3f4-a2e5-45da-b052-13640b9395fc | Andwerpz/Competitive-Programming-Practice | - cpp -/binomialcoefficients.cpp | #include <bits/stdc++.h>
typedef long long ll;
using namespace std;
//ACPC Weekly Problemset 2F
//something to do with stacking prefix sums and pascal triangle.
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while(t-- > 0){
ll m;
cin >> m;
... | ALGO | 0.999733 | 4.216594 |
569a298a-84aa-4825-b184-2cea65494fda | randbatch-md/lammps-rbe | src/OPENMP/npair_full_bin_atomonly_omp.cpp | // clang-format off
#include "npair_full_bin_atomonly_omp.h"
#include "atom.h"
#include "error.h"
#include "my_page.h"
#include "neigh_list.h"
#include "npair_omp.h"
#include "omp_compat.h"
using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
NPairFullBinAtomonly... | ALGO | 0.983158 | 5.645906 |
dcb94ba6-0aa0-4b5c-8e09-76d1b383bc24 | i-am-himanshukansal/DATA_STRUCTURES_AND_ALGORITHMS | .cph/A_How_Much_Does_Daytona_Cost.cpp | #include <iostream>
#include <vector>
using namespace std;
int main()
{
int t;
cin >> t;
while(t--){
int size;
cin >> size;
int target;
cin >> target;
int arr[size];
for (int j = 0; j < size; j++)cin >> arr[j];
bool flag = false;
for (int k = ... | ALGO | 0.999739 | 4.021945 |
f5227e3d-bf8d-468d-b08c-9181f641c82f | trsteel/tools | codechef/IARCS OPC Judge Problems/NUMROUTE*.cpp | #include <iostream>
#include <vector>
#include <queue>
using namespace std;
void cal(vector<vector<int> >& a, vector<vector<int> >& b) {
long n = a.size(), mod = 42373;
vector<vector<int> > c(n, vector<int>(n, 0));
for(int i=0;i<n;i++) for(int j=0;j<n;j++) {
for(int k=0;k<n;k++) {
c[i][... | ALGO | 0.999975 | 4.054821 |
e137b21e-37ce-4215-a592-82d59666cf5c | RiweiPan/FileSystemSelfTest | fsst.cpp | #include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <deque>
#include <fstream>
#include <sstream>
#include <fcntl.h>
#include <unistd.h>
#include <stddef.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/ioctl.h>
#include <dirent.h>
#define MD5_BLOCK_SIZE 16... | TOOL | 0.909568 | 5.093062 |
40d142a6-bb7e-4092-9306-286572a13fc5 | sathishkottravel/skepu2-clang-win64 | skepu2-examples/examples/cma.cpp | #include <iostream>
#include <skepu2.hpp>
template<typename T>
T sum(T a, T b)
{
return a + b;
}
template<typename T, typename U>
U avg(skepu2::Index1D index, T sum)
{
return (U)sum / (index.i + 1);
}
auto prefix_sum = skepu2::Scan(sum<int>);
auto average = skepu2::Map<1>(avg<int, float>);
void cma(skepu2::Vector... | ALGO | 0.998117 | 6.11794 |
e66703ca-4f72-4a09-a003-eb10a3ff5d37 | AIDevMonster/gpt4all | gpt4all-backend/mpt.cpp | #define MPT_H_I_KNOW_WHAT_I_AM_DOING_WHEN_INCLUDING_THIS_FILE
#include "mpt_impl.h"
#include "utils.h"
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <map>
#include <random>
#include <string>
#include <vector>
#include <iostream>
#if defined(_WIN32) && defined(_MS... | DATA | 0.882061 | 5.813025 |
4322c2dc-ba4e-41ef-afd5-6098e17000dd | stormysun513/ParGMRES | src/dense_omp/mtxvec.cpp | #include "mtxvec.h"
#include <vector>
#include <cmath>
#include <cassert>
#include <tuple>
#include <algorithm>
#include <omp.h>
#include <iostream>
using namespace std;
#define OMP_N_BOUND 1000000
#define OMP_NN_BOUND 500
/*
* Vector member funciton
*/
Vector::Vector(){}
Vector::Vector(size_t size) {
... | TOOL | 0.985329 | 5.276273 |
01aea4aa-e526-4430-88b7-83b4e0f8eeb9 | Yaro2709/AlgoProblems | 9/935B.cpp | #include <iostream>
using namespace std;
int main() {
int l;
cin >> l;
string s;
cin >> s;
int x = 0, y = 0, pay = 0;
for (int i = 0; i < l; i++) {
if (s[i] == 'U') {
y++;
}
else if (s[i] == 'R') {
x++;
}
if (x == y && i + 1 != l) {
if (s[i] == 'R' && s[i + 1] == 'R') {
pay++;
}
e... | ALGO | 0.999742 | 3.58838 |
0973f1be-ad8d-4440-8952-d46c1fae8492 | premembeddedcodedev/CPP | Problems/DS/Graph/bipartite_bigraph.cpp | #include<iostream>
#include<set>
#include<vector>
#include<queue>
using namespace std;
void parition(int offset, vector<int> ctlist[], int edges)
{
queue<int> q;
q.push(offset);
#if 0
set<int> s, t;
//s.insert(10);
for(int i=1; i<n; i++) {
cout << i << "->";
for(auto j : ctlist[i]) {
cout << j << "->... | ALGO | 0.999778 | 4.074367 |
75dace67-826b-440f-98f5-c63e88df8da3 | rudrab06/Codechef-Solutions- | Dracula Eats.cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t--){
int n;
int count=0;
cin>>n;
if(n<2){
cout<<0<<endl;
}
else{
for(int i=2;i<=n;i=i+7){
count++;
}
cout<<count<<endl;
... | ALGO | 0.999425 | 3.867245 |
20eb1643-30b3-4ace-bc84-ab8c3bbf42cb | vfolunin/archives-solutions | MCCME/112611.cpp | #include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
using namespace std;
int main() {
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
int h, w;
cin >> h >> w;
const int MOD = 1e6 + 7;
vector<vector<int>> ways(h, vect... | ALGO | 0.999976 | 4.951641 |
cd08db5b-6032-4251-b6b1-63ca8ea68fc9 | jsh-me/cctv-detection | face_detect/modules/ml/src/lr.cpp | ///////////////////////////////////////////////////////////////////////////////////////
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
// This is a implementation of the Logistic Regression algorithm in C++ in OpenCV.
// AUTHOR:
// Rahul Kavi rahulkavi[at]live[at]com
// # You are free to use, c... | DATA | 0.996728 | 5.220704 |
5f245d74-7e1c-48a2-8637-b6a2d81754a5 | amit-gp/Competitive-Programming-Problems | CPP-Implementation/Cycle_detect_Undirected_Graph/Cycle_detect_Undirected_Graph.cpp | #include<iostream>
using namespace std;
struct Edge
{
int src;
int dest;
};
struct Graph
{
Edge *edge;
int V, E;
};
Graph* createGraph(int V, int E)
{
Graph *graph = new Graph;
Edge *edge = new Edge[E];
graph ->E = E;
graph ->V = V;
return graph;
}
bool isCycle(Graph *graph)
{
... | ALGO | 0.999661 | 4.818785 |
ffdbaee6-ae62-4a35-a0ac-e92fa8fc5afd | BGMer7/LeetCode | 713. Subarray Product Less Than K/subarrayProductLessThanK.cpp | #include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
int numSubarrayProductLessThanK(vector<int> &nums, int k) {
if (k <= 1) return 0;
int len = nums.size();
if (len == 0) return 0;
if (len == 1) return nums[0] < k ? 1 : 0;
int left = 0, right... | ALGO | 0.999888 | 4.598333 |
39bbdb3f-1aeb-4737-b53a-a70ea2f7def4 | n2cholas/Computer_Engineering_TEJ3M1_Coursework | Number to 2 Digit/VN_What.cpp | /*
Nicholas Vadivelu
TEJ3M1-05
November 3, 2014
*/
#include <iostream>
#include <conio.h>
#include <windows.h>
#include <string>
#include <stdio.h>
#include <iomanip>
using namespace std;
extern int n = 0;
extern string l = "";
//**********************************Converting an Integer into an integer for 7 Segment*... | ALGO | 0.897579 | 3.87301 |
d680b70e-ae1e-4455-b4a7-e7fa5d440b5b | y-shindoh/kd_search_array | main.cpp | /* -*- coding: utf-8; tab-width: 4 -*- */
/**
* @file main.cpp
* @brief kd_search_array.hppの動作確認用コマンド
* @author Yasutaka SHINDOH / 新堂 安孝
*/
#include <cstdio>
#include <array>
#include <vector>
#include "kd_search_array.hpp"
#define M 6
#define N 2
/**
* サンプル・コマンド
*/
int
main()
{
const std::array<int, 2> value... | ALGO | 0.978774 | 4.272847 |
9210e300-fac3-454f-a7f6-6815f4864476 | 2013612/CP-algorithm | AtCoder/joi/joi2014yoD.cpp | #include<iostream>
using namespace std;
int N, b[2000];
long long dp[2000][10], ans;
string s;
int main() {
cin >> N >> s;
s = " " + s;
for (int i = 1; i <= N; i++) {
if (s[i] == 'J') {
b[i] = 1;
} else if (s[i] == 'O') {
b[i] = 2;
} else {
b[i] = 4;
}
}
dp[0][1] = 1;
for (int i = 1; i <= N; i++... | ALGO | 0.999935 | 4.022844 |
b35cb442-2488-4642-b901-f6015fe9fab3 | sarvex/leetcode-clojure | solution/0500-0599/0582.Kill Process/Solution.cpp | class Solution {
public:
vector<int> killProcess(vector<int>& pid, vector<int>& ppid, int kill) {
unordered_map<int, vector<int>> g;
vector<int> ans;
int n = pid.size();
for (int i = 0; i < n; ++i) {
int c = pid[i], p = ppid[i];
g[p].push_back(c);
}
... | ALGO | 0.99998 | 6.186916 |
e9a245d4-4a26-4175-8fbb-6f46b44efc6e | ishandutta2007/codeforces | cescmentation_folch/normal/1252/G.cpp | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<vpi> vvpi;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vi V(n);
vi B... | ALGO | 0.999992 | 4.222207 |
42c651d1-2d2e-48e1-99e6-613c7df78ab6 | cccathygao/1230-final-project | terrain/ext/eigen/doc/examples/tut_arithmetic_redux_basic.cpp | #include <iostream>
#include <Eigen/Dense>
using namespace std;
int main()
{
Eigen::Matrix2d mat;
mat << 1, 2,
3, 4;
cout << "Here is mat.sum(): " << mat.sum() << endl;
cout << "Here is mat.prod(): " << mat.prod() << endl;
cout << "Here is mat.mean(): " << mat.mean() ... | ALGO | 0.999288 | 3.872858 |
69152162-98f9-4335-ae02-2bded14c4aef | DeepMangroliya/CodeChef-Problem-Solutions | Is_it_a_VOWEL_or_CONSONANT.cpp | #include<iostream>
using namespace std;
int main(){
char c;
cin >> c;
if(c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U'){
cout << "Vowel";
}
else cout << "Consonant";
}
| ALGO | 0.997558 | 4.092535 |
037323af-e022-467a-9c7d-3089474109fa | lzztt/cpp | leetcode/20_Valid_Parentheses.cpp | class Solution {
public:
bool isValid(string s) {
const int N = s.size();
if (N % 2 != 0) return false;
vector<char> stack;
stack.reserve(N / 2);
auto i = 0;
for (auto c : s) {
switch(c) {
case '(': { if (stack.size() > N - i) return fals... | ALGO | 0.999645 | 6.716058 |
b73c09ce-3536-4bc9-9e7a-f439ad477398 | Zartris/Drone-trajectory-tracking-and-replication | workspace/src/Kalibr/aslam_optimizer/aslam_backend/src/Optimizer.cpp | #include <aslam/backend/Optimizer.hpp>
// std::partial_sum
#include <numeric>
#include <aslam/backend/ErrorTerm.hpp>
// M.inverse()
#include <Eigen/Dense>
#include <sm/eigen/assert_macros.hpp>
#include <sparse_block_matrix/linear_solver_dense.h>
#include <sparse_block_matrix/linear_solver_cholmod.h>
#ifndef QRSOLVER_D... | ALGO | 0.996256 | 7.459508 |
4ea38c10-48c3-4510-8308-5f260d102fe4 | PopchainOrg/PopChain-Original | src/fork.cpp | #include "popsend.h"
#include "main.h"
#include "fork.h"
#include <boost/lexical_cast.hpp>
class CForkMessage;
class CForkManager;
CForkManager forkManager;
std::map<uint256, CForkMessage> mapForks;
void CForkManager::ProcessFork(CNode* pfrom, std::string& strCommand, CDataStream& vRecv)
{
if(fLiteMode) return... | TOOL | 0.955362 | 5.750851 |
b72e4220-6c93-4a61-bdb6-91202e85ce17 | anxkgrns/2023_MAT3008_numerical_analysis | NRs/cpp/recipes/gammp.cpp | #include "nr.h"
DP NR::gammp(const DP a, const DP x)
{
DP gamser,gammcf,gln;
if (x < 0.0 || a <= 0.0)
nrerror("Invalid arguments in routine gammp");
if (x < a+1.0) {
gser(gamser,a,x,gln);
return gamser;
} else {
gcf(gammcf,a,x,gln);
return 1.0-gammcf;
}
}
| TOOL | 0.978897 | 3.318868 |
4823d08a-ceea-4790-b85d-eb408d2a53e2 | developer-mohitsoni/DSA-A2Z | Step 03 - Solve Problems on Arrays Easy, Medium, Hard/#2 Medium/21. Majority Element/Better Approach/Majority_Element.cpp | //! Program to find majority element in an array.
#include <bits/stdc++.h>
using namespace std;
//?------------------(Better Approach)------------------------------
//* T.C = O(N logN) + O(N)
//* S.C = O(N)
int majorityElement(vector<int> &v)
{
unordered_map<int, int> mpp;
// N log N
for (int i = 0; i <... | ALGO | 0.999956 | 5.78587 |
7649889e-0f20-4540-94f8-83ac7178f5b0 | juarezpaulino/coderemite | problemsets/Codeforces/C++/B181.cpp | /**
*
* Author: Juarez Paulino(coderemite)
* Email: <EMAIL>
*
*/
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
#define... | ALGO | 0.99962 | 4.317467 |
3044aa57-9eb0-4b73-8201-d2312d3d18f7 | Faizalilham/Flutter-MovieApp-EZ | 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 |
cb7b3827-ac37-4641-9922-c8b45219d2bc | ishandutta2007/codeforces | posij118/normal/1352/E.cpp | #include <bits/stdc++.h>
using namespace std;
int main(){
int t;
cin >> t;
while(t--){
int n;
cin >> n;
int a[n], b[n + 1];
for(int i = 0; i<n; i++){
cin >> a[i];
b[i + 1] = 0;
}
for(int i = 0; i<n; i++){
int sum = 0;
... | ALGO | 0.999651 | 4.321817 |
0e4f240c-7eaa-4b50-afc4-26f51c7841ed | JunjieWang95/decision-making-CarND | CarND-test/src/Eigen-3.3/unsupported/doc/examples/MatrixSine.cpp | #include <unsupported/Eigen/MatrixFunctions>
#include <iostream>
using namespace Eigen;
int main()
{
MatrixXd A = MatrixXd::Random(3,3);
std::cout << "A = \n" << A << "\n\n";
MatrixXd sinA = A.sin();
std::cout << "sin(A) = \n" << sinA << "\n\n";
MatrixXd cosA = A.cos();
std::cout << "cos(A) = \n" << cos... | ALGO | 0.935688 | 5.878768 |
efa36387-99c8-46df-9f93-80a0f901b59d | sirwym/MkdocsNote | dp/code/plug/plug_2.cpp | #include <bits/stdc++.h>
using namespace std;
const int M = 10;
const int offset = 3, mask = (1 << offset) - 1;
int n, m;
long long ans, d;
const int MaxSZ = 16796, Prime = 9973;
struct hashTable {
int head[Prime], next[MaxSZ], sz;
int state[MaxSZ];
long long key[MaxSZ];
void clear() {
sz = 0;
memset(... | ALGO | 0.999987 | 3.399857 |
2cbb34ec-e5db-4ed2-b041-2a5593e5f9a8 | Vranjan7077/Var_Plat_Codes | GeeksForGeeks/dp/maximum-chain-length.cpp | /*
Please note that it's Function problem i.e.
you need to write your solution in the form Function(s) only.
Driver Code to call/invoke your function would be added by GfG's Online Judge.*/
/*
The structure to use is as follows
struct val{
int first;
int second;
};*/
/*You are required to complete this method*/
bool... | ALGO | 0.999825 | 4.350884 |
f353e2e9-ad63-45ed-9766-32497fdce4ad | elenaisnanocat/codetree-TILs | 231128/파스칼의 삼각형/pascal's-triangle.cpp | #include <iostream>
using namespace std;
int n;
int arr[15][15] = {};
int main() {
cin >> n;
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
if(i >= j) {
arr[i][0] = 1;
if(i == j) {
arr[i][j] = 1;
}
... | ALGO | 0.999947 | 3.613399 |
fbba4847-0e69-4ce5-8aa0-72e7cd3f54ac | ishandutta2007/codeforces | .tx/normal/632/B.cpp | #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <string>
#include <memory.h>
#define sci(a) scanf("%d", &a)
#define scii(a, b) scan... | ALGO | 0.999643 | 3.576167 |
8af55288-243e-4dd2-a90a-2c1c9e8f352f | corbynfang/SimCitySimulation | main.cpp | #include <array>
#include <fstream>
#include <iostream>
#include <queue>
#include <sstream>
#include <string>
#include <tuple>
#include <unistd.h>
#include <vector>
#include "Commercial.h"
#include "Enviroment.h"
#include "Hospital.h"
#include "Industrial.h"
#include "Landfill.h"
#include "Residential.h"
#include "Zon... | ALGO | 0.854745 | 3.755164 |
c924d31d-52cc-4981-833d-6274fbf8f5da | mishrabadal/data-structure-program | Linked_List/day_3_linked_list.cpp | #include <iostream>
using namespace std;
#include <bits/stdc++.h>
// default linked list
class listnode
{
public:
int val;
listnode *next;
listnode(int data)
{
val = data;
next = NULL;
}
};
void traverse(listnode *temp)
{
cout << endl;
while (temp != NULL)
{
cout... | ALGO | 0.999846 | 4.82163 |
51e8fb95-a417-46d1-9272-52d4f8a15951 | harshrastogi15/DSA-Questions | DPP1/Q1.cpp | // Harsh Rastogi
// Left Rotation of an array by d
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi(T) vector<T>
#define pr(i,j) pair<i,j>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define ppb pop_back
#define ff first
#define ss second
#define f(i,A,B) for(long long... | ALGO | 0.999837 | 3.556048 |
0c7781c5-6b40-4c81-89b7-3aaf95b6aaba | mdabarik/phitron-assignment | algorithms/assignment-final-week-04-dp/03--make-it.cpp | #include <bits/stdc++.h>
using namespace std;
int dp[100005];
bool recursion(int n, int curr)
{
if (curr > n)
return false;
if (curr == n)
return true;
if (dp[curr] != -1)
return dp[curr];
bool op1 = recursion(n, curr + 3);
bool op2 = recursion(n, curr * 2);
dp[curr]... | ALGO | 0.99983 | 5.360556 |
067dd7de-aa67-47fd-9e7a-9a891a54aa07 | saquib77/Code | imw.cpp | #include<bits/stdc++.h>
using namespace std;
int main(){
int t;cin>>t;
while(t--){
int n,i,j=0,k,m=0;
cin>>n>>k;
string s;
cin>>s;
int p=k+1,l,r,count=0;
queue<int>mag;
queue<int>iron;
for(i=0;i<n;i++){
if(s[i]=='M') mag.push(i);
if(s[i]=='I') iron.push(i);
if(s[i]=='X'||i==n-1){
int l,r,... | ALGO | 0.999293 | 3.631131 |
263401cf-d621-4d7b-aeb9-24359933487a | raincross7/code-similarity | codes/train_code/problem477/problem477_145.cpp | #include <bits/stdc++.h>
#include <vector>
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n-1,0)
#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9+5;
const int mo... | ALGO | 0.999694 | 4.805399 |
e107078e-7fe4-4cb6-82e7-0dcc6a8ebdae | prithvijitbasak/LeetCode-Solutions | 2373. Largest Local Values in a Matrix.cpp | //Editorial: Just loop through the matrix and find the largest for each 3x3 matrix.
class Solution {
public:
vector<vector<int>> largestLocal(vector<vector<int>>& grid) {
int n=grid.size();
vector<vector<int>> ans(n-2,vector<int> (n-2));
for(int k=0;k<n-2;k++)
{
for(int l... | ALGO | 0.999835 | 5.848263 |
c0c33141-2697-47cb-affd-58b9ddcbbbfb | Viraj0305/VIrajFDS | sum_even.cpp | #include<iostream>
using namespace std;
int main()
{
int n;
cout<<"Enter a number "<<endl;
cin>>n;
int sum=0;
for(int i=0;i<=n;i++)
{
if(i%2==0)
{
sum=sum+i;
}
}
cout<<"Sum of even number="<<sum<<endl;
} | ALGO | 0.997503 | 4.159126 |
d7e3914b-4586-4dac-8ba0-ba98f4bf8be9 | kai-wei-kfuse/daily-code | 2022/202207/20220719/acwing897.cpp | #include <algorithm>
#include <iostream>
using namespace std;
char a[1005], b[1005];
int dp[1005][1005];
int main() {
int n, m;
cin >> n >> m >> a + 1 >> b + 1;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
if (a[i... | ALGO | 0.999928 | 3.829278 |
75616d16-3b65-4df4-97cb-38338aa384c2 | lanzheng1113/cpp | others/prog38.cpp | #include <iostream>
#include <string>
#include <utility>
//pairʹþ
int main()
{
typedef std::pair<std::string,std::string> Author;
std::string first,second;
Author next_auth;
while(std::cin>>first>>second)
{
next_auth = std::make_pair(first,second);
std::cout<<"First Author: "<<next_auth.first
<<" Secon... | TOOL | 0.899411 | 3.700678 |
46c318b5-ef48-43c7-bbd7-bd3acd534c90 | seonyoung169/Algorithm | BOJ/10994_Implementation.cpp | #include <iostream>
#include <vector>
#include <string>
// boj 10994 별찍기-19, 실버 4
using namespace std;
void printEven(int row, int size) {
int edge = min(row, size+1-row);
for (int i = 1; i <=size ; ++i) {
if (i%2 == 0) cout<<' ';
else {
int left = size+1-i;
if (left<e... | ALGO | 0.99998 | 4.089396 |
1c9eaf85-4a99-46a6-a324-3b5c5c9b5af8 | jasonzzzzzzz/TailBench | moses/mert/kbmira.cpp | // $Id$
// vim:tabstop=2
#include <cmath>
#include <cstddef>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <boost/program_options.hpp>
#include <boost/scoped_ptr.hpp>
#include "BleuScorer.h"
#include "Hy... | ALGO | 0.983857 | 6.953052 |
1c050cef-0dda-4ef2-878e-e6320fdbfc6f | pengcuo/ACL | src/core/NEON/kernels/convolution/winograd/winograd_transforms/input_4x4_fp32_fp32_integers.cpp | #include "input.hpp"
#include "arm.hpp"
namespace winograd
{
template <>
void InputTransform<4, 4, float, float, WinogradRoots::Integers>::transform_tile(
const int n_channels,
const float* const input_base,
const int input_row_stride,
const int input_col_stride,
float* outptr,
const int matrix_stride
)
{... | ALGO | 0.941873 | 6.584013 |
93af5294-167d-4fdb-b375-27bd2c9a7011 | poojan010/CodeForces | COdeforces Round 780/C_Get_an_Even_String.cpp | #include <bits/stdc++.h>
using namespace std;
#define ll long long int
void solve(){
string str; cin >> str;
ll n = str.length();
ll ans = 0;
ll t = -1;
bool flag = false;
int i;
for(i=0; i<n-1; ++i){
if(!flag){
if(str[i] == str[i+1]) ++i;
else t = i, flag ... | ALGO | 0.999886 | 4.769172 |
7cda0656-f1a1-4522-af51-eaa1ea191c2a | 7cristovao/cpp | exercicios/capitulo08/08-00-1.cpp | #include <iostream>
#include <cmath>
using namespace std;
// 2 1 3 4
double soma(double a, double b)
{ // 5
double s; // 7
s = a+b; // 8
return s; // 9
} // 6
int main(int argc, char *argv[])
{
system("read -p 'Aperte Enter para continuar...' var");
return... | TOOL | 0.908151 | 4.488389 |
a7ed0d00-bf34-48b4-a76f-0bcaf0ab3a15 | bony2023/Competitive-Programming | Dynamic Programming/Non-Classical/030 TIMUS - 1073. Square Country.cpp | // Author : Bony Roopchandani
// 1073. Square Country
// DP
// INCLUDES
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector... | ALGO | 0.999847 | 3.718908 |
77f35772-745e-4bd2-afc4-4cfdeeb6c6a5 | Noob-coder-07/DeepAlgo | C++/Demonstrations/Input Output function - 01 Addition.cpp | using namespace std;
#include<iostream>
#include<conio.h>
int main()
{
int No1 = 10,No2 = 5,Sum = 0;
Sum = No1 + No2;
cout<<"\nAddition of "<<No1<<"&"<<No2<<"is="<<Sum<<"."<<endl;
cout<<"Thanks....";
getch();
}
| TOOL | 0.990715 | 3.317531 |
7a4128ae-7fdf-486a-a715-a23435981012 | alexandraback/datacollection | solutions_5690574640250880_0/C++/hgd/3.cpp | #include <cstdio>
#include <cstdlib>
char board[50][50];
bool possible;
int T, R, C, M, trans, n;
void setbd(int h, int w, char c = '.') {
for (int i = 0; i < h; ++i)
for (int j = 0; j < w; ++j)
board[i][j] = c;
}
/*int t[50][50];
bool revealed[50][50];
void reveal(int x, int y) {
if (revealed[x][y]) return;... | ALGO | 0.994802 | 3.782805 |
a1d0b2d5-dd00-4762-bbf8-ac3d7698b326 | ishandutta2007/codeforces | siganai/normal/1726/A.cpp | //#pragma GCC target("avx")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#ifdef LOCAL
# include <debug.hpp>
# define debug(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
# define debug(...) (static_cast<void>(0))
#endif
//#include "atcoder/convolution.h... | ALGO | 0.999958 | 5.269806 |
26f59f21-9c20-421b-baaa-2cf76cbdaa55 | Amarjeet264/DSA-problems | 119-pascals-triangle-ii/pascals-triangle-ii.cpp | class Solution {
public:
vector<int> getRow(int row) {
vector<int>ans;
ans.push_back(1);
for(int i=1;i<=row;i++){
vector<int>dup;
dup.push_back(ans[0]);
for(int j=0;j<ans.size()-1;j++){
dup.push_back(ans[j]+ans[j+1]);
}
... | ALGO | 0.999775 | 5.270648 |
e9f22b73-d976-4cae-82fd-b9ab1525998f | sonicNode/dsa | basics/primeFactorization.cpp | #include<iostream>
using namespace std;
bool isPrime(int n)
{
for(int i=2; i<n ; i++)
{
if(n%i==0)
return false;
else
return true;
}
}
void primeFactor(int n)
{
for(int i=2; i<=n; i++)
{
//if(isPrime(i))
while(n%i==0)
{ ... | ALGO | 0.999877 | 3.649599 |
0c57ccba-e198-4229-9261-50527b418a6e | ishandutta2007/codeforces | geniucos/normal/645/A.cpp | #include<cstdio>
#include<bitset>
#include<vector>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
using namespace std;
int code (char c)
{
if (c == 'X') return 0;
if (c == 'A') return 1;
if (c == 'B') return 2;
return... | ALGO | 0.999904 | 3.544831 |
bfa6414c-f4d7-4943-87b4-a3c4773a7819 | qNumezz71/tapi | llvm/tools/llvm-readtapi/DiffEngine.cpp | using namespace llvm;
using namespace MachO;
using namespace object;
StringRef setOrderIndicator(InterfaceInputOrder Order) {
return ((Order == lhs) ? "< " : "> ");
}
// The following template specialization implementations
// need to be explicitly placed into the llvm namespace
// to work around a GCC 4.8 bug.
nam... | TOOL | 0.897428 | 6.731928 |
706bd417-76b5-484f-9523-8222d3efb615 | Denuvo33/Master-FNB-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.9988 | 6.76073 |
a55054d7-7552-489a-b817-55792056ce53 | EliasSherem/Data-Structures | Estructuras de datos/medioTermino.cpp | #include <stdio.h>
#include <stdlib.h>
struct par{
int info;
struct par *sig;
};
struct impar{
int info;
struct impar *sig;
};
void insertar(struct par *,struct impar *, int);
void imprimir(struct par *, struct impar *);
void borrarlista(struct par *, struct impar *);
void eliminar(struct par *,struct impar *, in... | ALGO | 0.999181 | 3.263928 |
cb6b71c9-9e4b-411b-9477-863e3dec3200 | RouteSubwayMap/Data-Structure | Dev-C++/ExerciseBook/06.53/BiTree.cpp | /*=============================
* Ķ洢ṹ
*
* 㷨: 6.16.26.36.4
=============================*/
#include "BiTree.h"
#include "LinkQueue.h" //**03 ջͶ**//
/*
* ʼ
*
* ն
*/
Status InitBiTree(BiTree* T) {
if(T == NULL) {
return ERROR;
}
*T = NULL;
return OK;
}
/*
* ÿ
*
* еݣʹΪ
*/
S... | ALGO | 0.999855 | 3.896835 |
b1d884e0-24d1-4b54-8706-7466e73dad7c | prakharrai1609/Leetcode-submissions | 128-longest-consecutive-sequence/128-longest-consecutive-sequence.cpp | class Solution {
public:
int longestConsecutive(vector<int>& nums) {
unordered_set<int> s(begin(nums), end(nums));
int len = 0;
for (int num : s) {
int t = 0;
if (s.count(num - 1)) continue;
while (s.count(num + t)) t++;
len = max(t, len);
... | ALGO | 0.999923 | 5.706589 |
f5cabd41-59ae-426e-8385-76b9a0bdb52d | WhiteCells/code | algo/daily/24/03/20.cpp | #include "../../head_file.h"
/*
problme:
url: https://leetcode.cn/problems/minimum-non-zero-product-of-the-array-elements/
*/
class Solution {
public:
int minNonZeroProduct(int p) {
if (p == 1) {
return 1;
}
const long long mod = 1e9 + 7;
auto fastPow = [=](long long ... | ALGO | 0.999957 | 5.608917 |
e5c8290c-2e54-49ba-80ba-1faa36ca8f3e | ishandutta2007/codeforces | bohun/normal/622/C.cpp | #include <bits/stdc++.h>
#define pb push_back
#define ld long double
#define fi first
#define se second
#define ll long long
#define ss(x) (int) x.size()
#define mp make_pair
using namespace std;
int n, m, a, b, c, t[200005];
int id[200005];
pair < int, int> naj[2];
int main()
{
scanf("%d %d", &n, &m);
for(int i = 1;... | ALGO | 0.999977 | 3.654008 |
fb1efc2b-c7fa-4d43-9717-e2f31efdc96e | Laurent-Zhu/Data-Structure | BSTree.cpp | //
#include<iostream>
#include<vector>
#include<stack>
#include<queue>
using namespace std;
template<typename T1, typename T2>
struct BSTNode //
{
T1 key; //
T2 data; //ֵ
BSTNode* lchild; //
BSTNode* rchild; //Һ
BSTNode(T1 k, T2 d) //캯
{
key = k;
data = d;
lchild = rchild = NULL;
}
};
template<typena... | ALGO | 0.999598 | 3.894212 |
9174ca72-a056-4dd4-a418-09d49da52c4c | akhil1g/LC | 2572-append-characters-to-string-to-make-subsequence/append-characters-to-string-to-make-subsequence.cpp | class Solution {
public:
bool issub(string &s1,string &s2,int n,int m)
{
if(m==s2.size()) return true;
if(n==s1.size()&&m!=s2.size()) return false;
if(s1[n]==s2[m]) return issub(s1,s2,n+1,m+1);
return issub(s1,s2,n+1,m);
}
int appendCharacters(string s, string t) {
... | ALGO | 0.999972 | 5.67598 |
9d96422c-328a-4607-b82a-ce6b2e73ee8d | kbinani/dxrip | dll/common/Engine/Math/Plane.cpp | /*
Plane.cpp
Written by Matthew Fisher
A standard 3D plane (space plane.) Essentially just the surface defined by a*x + b*y + c*z + d = 0
See Plane.h for a description of these functions.
*/
Plane::Plane()
{
}
Plane::Plane(const Plane &P)
{
a = P.a;
b = P.b;
c = P.c;
d = P.d;
}
Plane::Plane(float ... | ALGO | 0.997431 | 4.122918 |
da6ba263-dcd3-4408-9953-9d6a81970914 | BrowserWorks/waterfox | gfx/skia/skia/src/core/SkEdgeClipper.cpp | #include "src/core/SkEdgeClipper.h"
#include "include/core/SkRect.h"
#include "include/core/SkTypes.h"
#include "include/private/base/SkMacros.h"
#include "src/core/SkGeometry.h"
#include "src/core/SkLineClipper.h"
#include "src/core/SkPathPriv.h"
#include <algorithm>
#include <cstring>
static bool quick_reject(cons... | ALGO | 0.999414 | 4.452363 |
7e17d167-ea83-4061-96db-018788a737f9 | rizqicahyaa/1_Praktikum | Rizqi Cahya Angelita_047_Praktikum3.4.cpp | #include <iostream>
using namespace std;
int main(){
cout<<"\t\t\tTabel Perkalian\n";
for(int i=1; i<=10; i++){
for(int j=1; j<=10; j++){
cout<<i*j<<"\t";
}
cout<<"\n";
cout<<"\n";
}
return 0;
}
| ALGO | 0.920615 | 3.639109 |
5be30bb4-9be8-4956-ad62-d49fa953789e | RomainBrault/OV2SGD | Eigen/doc/examples/TutorialLinAlgSetThreshold.cpp | #include <iostream>
#include <Eigen/Dense>
using namespace std;
using namespace Eigen;
int main()
{
Matrix2d A;
A << 2, 1,
2, 0.9999999999;
FullPivLU<Matrix2d> lu(A);
cout << "By default, the rank of A is found to be " << lu.rank() << endl;
lu.setThreshold(1e-5);
cout << "With threshold 1e-5... | ALGO | 0.99985 | 4.090376 |
fe0194a5-ab46-49fd-9331-f229caea6b0b | StarryFK/acmlearn | practice/poj/poj1456a.cpp | #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
#define LL long long
#define int LL
#define RLL(x) scanf("%lld", &x)
struct Pro{
LL p;
LL d;
Pro(LL x, LL y){
p=x;
d=y;
}
};
vector<Pro> v;
LL fa[10005];
bool operator < (const Pro &a, const Pro &b){
return a.p ... | ALGO | 0.999795 | 3.582694 |
bf737ee5-482f-46a0-a835-e49381058965 | 2395477683/ChatRoomPoint | Original_ChatRoom/ChatRoom_Client/src/structHeader.cpp | #include"structHeader.h"
#include<cstdlib>
#include<cstring>
#include<iostream>
#include <cstring>
bool parseMessage(const std::string &input,int *type,std::string &outbuffer){
auto pos=input.find_first_of(" ");
if(pos==std::string::npos||pos==0){
std::cout<<"输入格式错误"<<"\n";
return false;
... | WEB | 0.851613 | 3.256982 |
260f82a4-cd44-499a-83b8-f42745f86446 | phil1217/UnblockPuzzle | Solver.cpp | #include "Solver.h"
#include<deque>
#include<iostream>
using namespace std;
Solver::Solver(Board &board,Block &goal):initialBoard(board),goal(goal){}
void Solver::solve(){
deque<Board> boards;
boards.push_back(initialBoard);
Board board;
while(!boards.empty()){
board = boards.front();
... | ALGO | 0.999463 | 4.21793 |
6311844a-5d5c-4255-816f-98c20d59f0de | ColeFinance/Cole | src/policy/fees.cpp | #include <policy/fees.h>
#include <clientversion.h>
#include <primitives/transaction.h>
#include <streams.h>
#include <txmempool.h>
#include <util/system.h>
static constexpr double INF_FEERATE = 1e99;
std::string StringForFeeEstimateHorizon(FeeEstimateHorizon horizon) {
static const std::map<FeeEstimateHorizon, ... | ALGO | 0.99142 | 7.081033 |
0986ee09-1dde-46d7-b2aa-1008f114008e | kapoorz/cpptopics | dynamic/problem set0/a frog.cpp | #include <bits/stdc++.h>
using namespace std;
int main()
{
freopen("input.txt", "r", stdin);
int n;
cin >> n;
vector<int> h(n);
for (int i = 0; i < n; i++)
cin >> h[i];
int *dp = new int[n];
memset(dp, 0, sizeof(dp));
for (int i = 0; i < n; i++)
{
if (i == 0)
... | ALGO | 0.999961 | 4.112881 |
b677d64e-9ba6-4541-ae33-dfedac23e8f7 | flowersayo/Algorithm | leetCode/Grind 75 questions/Week2/ Add Binary.cpp | class Solution
{
public:
string padStart(string str, int target_length, char c)
{
int length = str.length();
for (int i = 0; i < target_length - length; i++)
{ // str.length()가 동적으로 변할 수 있음에 유의!
str = c + str;
}
return str;
}
string addBinary(string... | ALGO | 0.999961 | 5.509758 |
d0c77531-db93-452a-9157-a99bd378fcc9 | ishandutta2007/codeforces | mrkastep/normal/610/B.cpp | #include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <map>
#include <time.h>
#include <string>
#include <algorithm>
#include <queue>
#include <assert.h>
#include <math.h>
#include <cmath>
#include <complex>
using namespace std;
#define For(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b)... | ALGO | 0.99992 | 3.402191 |
066dd7f4-8244-4c56-83c6-6e94f1fa4619 | MissAashnaa1/DSA-Questions | Hard/Maximum Connected group/maximum-connected-group.cpp | //{ Driver Code Starts
// Initial Template for C++
#include <bits/stdc++.h>
using namespace std;
// } Driver Code Ends
// User function Template for C++
class Solution {
int findParent(vector<int>&parent,int u){
if(u==parent[u]){
return u;
}
return parent[u]=findParent(parent,... | ALGO | 0.999975 | 6.37345 |
4dcb49c0-f4dc-4c90-acb0-527f768ed097 | ArtemRotov/LeetCode | Algorithms/Easy/ConvertSortedArrayToBinarySearchTree.cpp | /*
108. Convert Sorted Array to Binary Search Tree
Given an integer array nums where the elements are sorted in
ascending order, convert it to a height-balanced binary search tree.
/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* Tree... | ALGO | 0.999984 | 6.806293 |
2e8b282e-97e7-4cb9-a5f1-02530093acc8 | 846754497THK/ACM-tools-and-skills | 程序板子/Math/Pollard-Rho.cpp | /*
Pollard_Rho
题目大意:
给出最大公约数和最小公倍数,满足要求的x和y,且x+y最小
题解:
我们发现,(x/gcd)*(y/gcd)=lcm/gcd,并且x/gcd和y/gcd互质
那么我们先利用把所有的质数求出来Pollard_Rho,将相同的质数合并
现在的问题转变成把合并后的质数分为两堆,使得x+y最小
我们考虑不等式a+b>=2sqrt(ab),在a趋向于sqrt(ab)的时候a+b越小
所以我们通过搜索求出最逼近sqrt(ab)的值即可。
*/
#include <algorithm>
... | ALGO | 0.999962 | 4.475927 |
c5f9be45-8250-437d-88ee-ca86755d2bf1 | ishandutta2007/codeforces | baluteshih/normal/894/C.cpp | #include <iostream>
#include <algorithm>
#define __ ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
int num[1050];
int main()
{
long long m,i;
cin >> m;
for(i=0;i<m;i++)
cin >> num[i];
sort(num,num+m);
for(i=1;i<m;i++)
if(num[i]%num[0]) break;
if(i<m) cout << "-1\n";
else
{
cout << ... | ALGO | 0.999857 | 3.003176 |
ababa860-31f7-4251-a2b2-5dc5be0f1712 | ishandutta2007/codeforces | abeker/normal/367/D.cpp | #include <cstdio>
#include <algorithm>
using namespace std;
const int MAXN = 100005;
const int MAXM = 21;
int N, M, D;
int sum[MAXN][MAXM];
bool bio[1 << MAXM];
void load() {
scanf("%d%d%d", &N, &M, &D);
for (int i = 0; i < M; i++) {
int sz;
scanf("%d", &sz);
while (sz--) {
... | ALGO | 0.999753 | 4.325076 |
cb089a58-64c5-4542-bf78-db86b8eab0e0 | righthand0521/LeetCode | src/2071.cpp | #include <algorithm>
#include <deque>
#include <iostream>
#include <vector>
using namespace std;
class Solution {
private:
bool check(vector<int>& tasks, vector<int>& workers, int pills, int strength, int middle) {
bool retVal = false;
int workersSize = workers.size();
int workersIdx =... | ALGO | 0.999972 | 5.344788 |
3e0b67ba-3973-46f1-a30b-1e04b83dd8f0 | sency90/boj | 1453.cpp | #include <stdio.h>
#include <string.h>
bool v[101];
int main() {
int d, cnt=0;
memset(v, false, sizeof(v));
int n; scanf("%d", &n);
while(n--) {
scanf("%d", &d);
if(v[d]) cnt++;
else v[d] = true;
}
printf("%d", cnt);
return 0;
}
| ALGO | 0.99959 | 3.61293 |
04349b04-270a-4c26-a228-0e8c7af47f91 | MakinoRuki/Codeforces | R626/1323E.cpp | #include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <cmath>
#define N 500005
using namespace std;
typedef long long ll;
ll mod = 1000000007;
int t,n,m;
ll c[N];
vector<in... | ALGO | 0.999753 | 3.44739 |
0385dc8a-924f-4991-bcdf-67266074b983 | crsullivan13/cache-replacement-simulator | src/cache.cpp | #include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include "cache.h"
// Takes user input string and converts to policy enum value
// Defaults to RANDOM if policy given is not valid
enum Policy cache_convert_policy(char* policy_string) {
enum Policy policy = RANDOM;
if ( strncmp("ra... | TOOL | 0.923269 | 5.28329 |
8b568d1b-e210-446c-84c7-03901b560a8c | hazelkimm/nonjasi | graph/BFT_graph.cpp | // undi_graph 클래스:
// - Undirected Graph (무방향 그래프)을 표현하는 클래스.
// - add_edge: 그래프에 간선을 추가하는 함수.
// - BFS: 주어진 root에서 시작하여 BFS 탐색을 수행하는 함수.
// - shortestPath: BFS로 최단 경로를 찾는 함수.
// - areAllConnected: 모든 노드가 연결되어 있는지 확인하는 함수.
// - countIslands: 그래프에서 연결되지 않은 부분(섬)의 개수를 세는 함수.
// - hasCycle: 그래프에 사이클이 존재하는지 탐지하는 함수
... | ALGO | 0.999559 | 6.446229 |
a7accc68-1df9-4006-a7d7-4a0310dd5d74 | MXFH-L/Algorithmic-experiments | experiment_forth/1D_Catch_the_cows.cpp | #include <iostream>
#include <vector>
#include <unordered_map>
#define int long long
using namespace std;
int findMaxSequence(int r, const vector<int>& tree) {
unordered_map<int, vector<int>> valueToIndices;//相同成绩的牛马位置
for (int i = 1; i <= r; i++) {
valueToIndices[tree[i]].push_back(i);
}
vect... | ALGO | 0.999887 | 4.696917 |
1cbaa8b4-730f-42ad-91cf-800322ea7ec8 | ishandutta2007/codeforces | andrew/normal/931/A.cpp | #include <bits/stdc++.h>
#define fi first
#define se second
#define p_b push_back
#define pll pair<ll,ll>
#define m_p make_pair
#define all(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
const ll MAXN = 1123456;
template <typename T>
T sqr(T x){
return x * x;
}
template <typename T>
void vout(T... | ALGO | 0.999789 | 4.21063 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.