uuid string | repo_name string | relative_path string | content string | category string | algo_rel_score float64 | quality_score float64 |
|---|---|---|---|---|---|---|
63a36994-f684-4fa0-9f0e-927df2cf6db6 | tinatiansjz/algorithm-learning-2019 | codeforces/877A_4.cpp | //kangba
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int brute_force(char* s, char* t, int tn){
int i = 0, j = 0, k = 0;
while(s[i] != 0 && j < tn){
if(s[i] == t[j]){
i++;j++;
}else{
i = i-j+1;
j = 0;
}
if(j == t... | ALGO | 0.999862 | 3.543598 |
464b276d-195d-4408-a3c9-7eee090d8038 | llvm-mirror/llvm | lib/IR/Dominators.cpp | #include "llvm/IR/Dominators.h"
#include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/IR/CFG.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/PassManager.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/... | TOOL | 0.998059 | 7.941995 |
878a95da-c2ae-407c-8681-bfe19fa38fba | mrcsparker/timber | packrat/lib/x86_64-apple-darwin15.0.0/3.2.2/Rcpp/examples/ConvolveBenchmarks/convolve14_cpp.cpp | // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
// This is a rewrite of the 'Writing R Extensions' section 5.10.1 example
#include <Rcpp.h>
using namespace Rcpp ;
RcppExport SEXP convolve14cpp(SEXP a, SEXP b){
NumericVector xa(a), xb(b);
int n_xa = xa.size() ;
int n_xb = xb.size(... | ALGO | 0.935922 | 6.087545 |
755c8265-9f40-4af1-920d-6494333d81be | RudeusGL/Programacion1FYo | MenuCajero.cpp | /*Realizar un menú de cajero automático, que permita hacer las siguientes opciones:
Cambio de pin, donde debe ingresar el pin original (1234) y luego ingresar 2 veces el nuevo pin de la tarjeta para continuar.
Retiro de dinero, donde debe ingresar una cantidad a retirar que sea divisible entre 100, e indicar cuantos bi... | TOOL | 0.917481 | 4.242023 |
b017357d-938a-428a-8795-b38f0aba51e3 | moongerim/ur5_mpc_vrep | src/mpc_high/solver/acado_qpoases_interface.cpp | extern "C"
{
#include "acado_common.h"
}
#include "INCLUDE/QProblem.hpp"
#if ACADO_COMPUTE_COVARIANCE_MATRIX == 1
#include "INCLUDE/EXTRAS/SolutionAnalysis.hpp"
#endif /* ACADO_COMPUTE_COVARIANCE_MATRIX */
static int acado_nWSR;
#if ACADO_COMPUTE_COVARIANCE_MATRIX == 1
static SolutionAnalysis acado_sa;
#endif /* AC... | ALGO | 0.999685 | 4.085229 |
0d4d40ab-3293-457e-9fb8-e1d96fcb799d | ugeneunipro/ugene-old | src/plugins_3rdparty/hmm3/src/hmmer3/easel/esl_minimizer.cpp | /* Multidimensional optimization using conjugate gradient descent.
*
* Can be used even without derivative information; falls back to
* a numeric gradient if analytic gradient is unavailable.
*
* SRE, Wed Jun 22 11:37:29 2005
* SVN $Id: esl_minimizer.c 438 2009-11-12 22:29:50Z wheelert $
*/
#include "esl_confi... | ALGO | 0.99999 | 7.06152 |
06e2e1c7-d55c-43df-a2ee-d710a1fb7107 | Nivedagaspar/Programs-on-Data-structures- | Data structures programs/hash search.cpp | #include<iostream>
using namespace std;
struct Node
{int data;
Node* link;
}*arr[101];
void createlist(int sze)
{for(int i=0;i<sze;i++)
{arr[i]=NULL;
}
}
void insert(int datain,int sze)
{Node* pnew=new Node;
pnew->data=datain;
pnew->link=NULL;
int loc=datain%sze;
if (arr[loc]==NULL)
{arr[loc]=pnew;
}
else
{p... | ALGO | 0.999766 | 3.428481 |
7db12fd6-d372-41a7-ad93-4dc19b840181 | guoliqiang/coding | third_part/boost/boost_1_53_0/tools/quickbook/src/syntax_highlight.cpp | #include <boost/spirit/include/classic_core.hpp>
#include <boost/spirit/include/classic_confix.hpp>
#include <boost/spirit/include/classic_chset.hpp>
#include <boost/spirit/include/classic_symbols.hpp>
#include <boost/spirit/include/classic_loops.hpp>
#include "grammar.hpp"
#include "grammar_impl.hpp" // Just for conte... | TOOL | 0.886357 | 6.569137 |
00a6585a-dbbb-4cb7-be49-c250787c466b | InukChoi/KWandKids | Baekjoon/P17822 (원판 돌리기)/lkw.cpp | #include<iostream>
using namespace std;
int circle[51][51]; // 1 ~ 1000
int dy[4] = { -1, 1, 0, 0 };
int dx[4] = { 0, 0, -1, 1 };
void shift(int idx, int d, int k, int M) { // idx , d , k ŭ ȸ. M
// d:0 clock, d : 1 anticlock
int c_t[51]; // ٷ ٰ ϱ س
for (int i = 1; i <= M; i++)
c_t[i] = circle[idx][i];... | ALGO | 0.999934 | 4.167518 |
2df60ac0-0236-4c65-b030-c3af15d1ef32 | mostafa-cse/Most-Used-Templates-from-Various-Sources | Data Structures/Dynamic Connectivity Problem.cpp | #include<bits/stdc++.h>
using namespace std;
const int N = 3e5 + 9;
struct persistent_dsu {
struct state {
int u, v, rnku, rnkv;
state() {
u = -1;
v = -1;
rnkv = -1;
rnku = -1;
}
state(int _u, int _rnku, int _v, int _rnkv) {
u = _u;
rnku = _rnku;
v = _v;
... | ALGO | 0.99994 | 4.518868 |
75472e6f-38f0-427a-8742-ec322279ed66 | Brdly777/flutter-ejemplo2 | windows/runner/utils.cpp | #include "utils.h"
#include <flutter_windows.h>
#include <io.h>
#include <stdio.h>
#include <windows.h>
#include <iostream>
void CreateAndAttachConsole() {
if (::AllocConsole()) {
FILE *unused;
if (freopen_s(&unused, "CONOUT$", "w", stdout)) {
_dup2(_fileno(stdout), 1);
}
if (freopen_s(&unuse... | TOOL | 0.998733 | 6.76775 |
d2dbda06-a51c-4785-a79a-9941cb83cbda | subsub-e/PS | 프로그래머스/3/42892. 길 찾기 게임/길 찾기 게임.cpp | #include <string>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
struct Node
{
int data;
int x, y;
Node* left;
Node* right;
};
bool comp(Node a, Node b){
if(a.y == b.y){
return a.x < b.x;
}
return a.y > b.y;
}
void setParent(Node* parent, Node... | ALGO | 0.999972 | 4.71549 |
7ad59b5d-24a2-43a5-80a0-b862c1d4c427 | Rohankhokhar/assignment-module-4 | topics-4/que-13.cpp | #include <iostream>
using namespace std;
class Max{
int a, b;
public:
Max(int x, int y) {
a =x;
b =y;
}
friend int fmax( const Max& mf);
void display()const {
cout << "a = " << a << " b = " << b << endl;
}
};
int fmax( const Max& mf){
return (mf.a > mf.b) ? mf.a : mf... | ALGO | 0.997662 | 4.326296 |
6b048834-b67c-4fca-8ff3-fcbd53a0ea03 | Ahamed-Rashad/Calculator-App-Flutter | windows/runner/utils.cpp | #include "utils.h"
#include <flutter_windows.h>
#include <io.h>
#include <stdio.h>
#include <windows.h>
#include <iostream>
void CreateAndAttachConsole() {
if (::AllocConsole()) {
FILE *unused;
if (freopen_s(&unused, "CONOUT$", "w", stdout)) {
_dup2(_fileno(stdout), 1);
}
if (freopen_s(&unuse... | TOOL | 0.998809 | 6.763549 |
98451cb1-2f0c-4995-885f-222ca5a711ec | shamkharyan/LeetCode | Hash Table/451_Sort_Characters_By_Frequency.cpp | class Solution {
public:
string frequencySort(string s) {
unordered_map<char, int> freq;
string ans;
for (char c : s)
++freq[c];
vector<pair<char, int>> vec(freq.begin(), freq.end());
sort(vec.begin(), vec.end(), [](const auto& a, const auto& b)
{
... | ALGO | 0.999988 | 6.292712 |
4871cf66-cb5b-4f8d-9a33-7348ecde7885 | AngelCase/leetcode | problems/139_Word_Break/solution.cpp | /*
* @lc app=leetcode id=139 lang=cpp
*
* [139] Word Break
*/
#include <string>
#include <vector>
#include <unordered_set>
#include <queue>
using namespace std;
// @lc code=start
class Solution
{
public:
bool wordBreak(string s, vector<string> &wordDict)
{
vector<bool> dp(s.length() + 1, false);
... | ALGO | 0.998012 | 6.442527 |
4b492dd9-5572-4f73-b0c8-f59ccf158799 | nvt0610/QuanLyChiTieu | 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 |
a401f024-487c-4fb9-97c2-90c2210311d6 | nabobery/PROJECT-MADS | LeetCode/1501 - 1600/1598.cpp | // 1598. Crawler Log Folder
// Simple and Straightforward Approach
// Time Complexity: O(n)
// Space Complexity: O(1)
class Solution {
public:
int minOperations(vector<string>& logs) {
int count = 0;
for(string log: logs){
if(log == "../") count--;
else if(log != "./") count... | ALGO | 0.997225 | 5.141384 |
a0f83249-a8fc-4a3f-baae-e6a41acd2b0e | Utkarsh-Dyundi/Competitive-Programming | A_Sum_of_Round_Numbers.cpp | #include<bits/stdc++.h>
using namespace std;
#define tr(c,it) for(typeof(c.begin()) it=c.begin();it!=c.end();++it)
#define all(c) c.begin(),c.end()
#define mod 1000000007
#define itor(c) typeof(c.begin())
#define ll long long
#define vi vector<int>
#define si set<int>
#define msi multiset<int>
#define ii pair<int,int>
... | ALGO | 0.999967 | 4.005796 |
7eb239f0-ef25-4ca0-9b69-45302285eae6 | vadz/extrema | src/Functions/FCN_eigen.cpp | #include "FCN_eigen.h"
#include "Workspace.h"
#include "ExprCodes.h"
#include "NumericVariable.h"
#include "EExpressionError.h"
#include "UsefulFunctions.h"
FCN_eigen *FCN_eigen::fcn_eigen_ = 0;
void FCN_eigen::ProcessArgument( bool firstArgument, int ndmEff, int &nLoop )
{
if( firstArgument )
{
if( ndmEff !=... | ALGO | 0.998459 | 4.48088 |
bd3aafbb-07ed-4778-9ef2-571a83f4975d | SheharyarDaym/C-Cpp-Program | Loops/Hollow triangle.cpp | /*Hollow triangle
****
* *
* *
****
*/
#include<iostream>
using namespace std;
int main(){
int row,col;
cout<<"Enter row and column! ";
cin>>row>>col;
for (int i=1; i<=row; i++){
for (int j=1; j<=col; j++){
if (i==1 || i==row || j==1 || j==col){
cout<<"*";
... | ALGO | 0.99937 | 3.739771 |
81413ef3-52ac-4e6a-8b4e-8fb239c5a766 | jmondi/libcamera | src/libcamera/device_enumerator.cpp | #include "libcamera/internal/device_enumerator.h"
#include <string.h>
#include <libcamera/base/log.h>
#include "libcamera/internal/device_enumerator_sysfs.h"
#include "libcamera/internal/device_enumerator_udev.h"
#include "libcamera/internal/media_device.h"
/**
* \file device_enumerator.h
* \brief Enumeration and... | TOOL | 0.872588 | 7.80978 |
fead2990-0a04-4da8-a607-6442384daee1 | ApexOS/android_frameworks_av | media/module/codecs/amrnb/common/src/az_lsp.cpp | /*
Pathname: ./audio/gsm-amr/c/src/az_lsp.c
Funtions: Chebps
Chebps_Wrapper
Az_lsp
------------------------------------------------------------------------------
REVISION HISTORY
Description: Finished first pass of optimization.
Description: Made changes based on review comments.
Descri... | ALGO | 0.999646 | 6.191792 |
39e46c90-6ea5-4f54-a916-bdd0c4fb91f5 | saikiranboga/Coding | Codeforces/Round#259/B.cpp | #include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
#define PI 3.1415926
#define inf 1000000000
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz size()
#define ln length()
#define rep(i,n) for(int i=0;i... | ALGO | 0.999971 | 4.042474 |
18a395ed-43c5-401d-824d-bb1f8d5da15d | minseonkkim/Algorithm_Programmers | Lv2/42586.cpp | #include <string>
#include <vector>
using namespace std;
vector<int> solution(vector<int> progresses, vector<int> speeds) {
vector<int> finish;
for(int i = 0; i < progresses.size(); i++){
int left = 100 - progresses[i];
int fns = left / speeds[i];
if(left % speeds[i] != 0) fns ... | ALGO | 0.999904 | 5.384215 |
84f0ada1-99a1-42c9-a5d6-cee085e6bc76 | the-hyp0cr1t3/advent-of-code | 2024/day13_p2.cpp | #include <bits/stdc++.h>
using i64 = long long;
bool read(i64 &a, i64 &b, i64 &c, i64 &f, i64 &g, i64 &h) {
std::string line;
do {
if (!std::getline(std::cin, line)) return false;
} while (line.empty());
std::sscanf(line.c_str(), "Button A: X%lld, Y%lld", &a, &f);
do {
if (!std::... | ALGO | 0.99863 | 4.111837 |
306ed40b-a89b-4089-bdbe-8b32b56080c9 | chinmayajha/Code | Total_Components.cpp | // Author : Chinmay Jha
// @chinmayajha on Codeforces, Codechef, USACO, AtCoder and CSES.fi
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define ll long long int
clock_t startTime;
inline namespace chinmayajha {
#define vi vector<int>
#define vli vector<lli>
#define vii vector<pair<int, int>>... | ALGO | 0.999979 | 4.344833 |
84c4e442-b0f6-4457-8770-797aa2655295 | aminjonshermatov/competitive_programming | stepik/199929/1/1.7.1.cpp | //
// Created by aminjon on 11/5/22.
//
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
auto solve() {
ll N, ans = 0;
cin >> N;
for (ll i = 0; i < N; ++i) {
ll x;
cin >> x;
ans ^= x;
}
cout << ans;
}
int main() {
solve();
} | ALGO | 0.999984 | 4.965825 |
1da42177-ba49-417e-b301-2880547b97aa | roytam1/mypal68-changes | other-licenses/nsis/Contrib/CityHash/cityhash/city.cpp | #include "city.h"
#include <algorithm>
using namespace std;
#if __sparc__
#include <string.h>
static inline uint64 UNALIGNED_LOAD64(const char *p) {
uint64 val;
memcpy(&val, p, sizeof(uint64));
return val;
}
static inline uint32 UNALIGNED_LOAD32(const char *p) {
uint32 val;
memcpy(&val, p, sizeof(uint32))... | ALGO | 0.997813 | 6.427271 |
a663ef9a-0a49-4091-a482-cabe967f478b | Cmessere/Cpp-practice | Online Coding/HackerRank/Problem Solving/Easy/Mini-Max Sum.cpp | //Shiro23
//https://www.hackerrank.com/challenges/mini-max-sum/problem
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
vector<string> split_string(string);
void miniMaxSum(vector<int> &arr) {
long long min = 10000000000, max = 0;
for(auto it = arr.begin(); it < arr.end(); it++){
l... | ALGO | 0.999942 | 4.460774 |
b34a889e-75a1-48a8-bd21-07be9a1b9f7b | bidulgicode/PS | Algorithm_Basic_1_BOJ/300_Mathematics_1/1934.cpp | /**
* BOJ_1934_최소공배수
* https://www.acmicpc.net/problem/1934
*/
#include <iostream>
int gcd(int x, int y){
while(y != 0){
int r = x % y;
x = y;
y = r;
}
return x;
}
int main()
{
using namespace std;
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin ... | ALGO | 0.999972 | 5.673109 |
c37f6322-4f10-4abe-94de-fc42facc26a9 | namnguyen215/CTDLGT | minhminh-main/bubble sort.cpp | #include<bits/stdc++.h>
using namespace std;
//sap xep noi bot(bubble sort)
void bubble_sort(int a[],int n){
int d=1;
for(int i=0;i<n-1;i++){
int t=0;
for(int j=0;j<n-1-i;j++){
if(a[j]>a[j+1]){
swap(a[j],a[j+1]);
t=1;
}
}
if(t==0) break;
cout<<"Buoc "<<d<<": ";
for(int i=0;i<n;i+... | ALGO | 0.999829 | 4.182498 |
ceafaded-8a92-4ce1-84e3-579490b03c07 | twoo0220/algorithm | BOJ/C++/19698.cpp | #include <iostream>
#include <math.h>
int main()
{
std::ios_base::sync_with_stdio(0);
std::cout.tie(0);
std::cin.tie(0);
int n(0), w(0), h(0), l(0);
std::cin >> n >> w >> h >> l;
std::cout << std::min(n, (w / l) * (h / l));
return 0;
}
| ALGO | 0.990284 | 4.001643 |
9f74c3d3-1ae5-4d83-8451-dde167194777 | ahemon369/XPSC | Week 4 Topicwise Two Pointers & Slidinig Window - 1/C_Ski_Resort.cpp | /* Author: Md Amran Hossin Emon
Created: 2025-04-23 11:00:00*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
int t; cin>>t;
while(t--)
{
int n,k,q; cin>>n>>k>>q;
int cnt=0; ll ... | ALGO | 0.999816 | 3.479762 |
71d99355-01de-4576-9c03-8d040a58db45 | gerstrong/Commander-Genius-Archive | src/engine/core/CObjectCollision.cpp | /*
* CSpriteObjectCollision.cpp
*
* Created on: 01.11.2010
* Author: gerstrong
*
* This is the second cpp file for the CSpriteObject Class
* It is only meant to be used for collisions
*/
#include "CSpriteObject.h"
#include "engine/core/spritedefines.h"
#include <base/GsTimer.h>
int episode = 0;
int gB... | ALGO | 0.964387 | 4.360157 |
f9935e4b-31db-4f0b-8cda-e9b5afdc87a2 | akshita2703/DSA | Assignment/02_week3/02_findPivot.cpp | #include<bits/stdc++.h>
#include <utility>
using namespace std;
int bruteForce(vector<int>& nums){
for(int i =0;i<nums.size();i++){
int lsum = 0;
int rsum = 0;
// find lsum excluding current index
for(int j = 0; j<i;++j){
lsum +=nums[j];
}
//find rsum exc... | ALGO | 0.999947 | 6.126766 |
67b20053-138d-4c9a-8664-d775c9decebf | evertheylen/MachinesEnBerekenbaarheid | code/libs/boost/libs/msm/doc/PDF/examples/SimpleWithFunctors2.cpp | #include <vector>
#include <iostream>
// back-end
#include <boost/msm/back/state_machine.hpp>
//front-end
#include <boost/msm/front/state_machine_def.hpp>
// functors
#include <boost/msm/front/functor_row.hpp>
#include <boost/msm/front/euml/common.hpp>
// for And_ operator
#include <boost/msm/front/euml/operator.hpp>
/... | TOOL | 0.861359 | 6.600179 |
d0c675ab-c97b-44cf-9064-231ef66e1cd4 | bogus/findik | playground/shelta/0.2-04/src/main/protocols/http/domain_filter.cpp | #include "domain_filter.hpp"
namespace findik
{
namespace protocols
{
namespace http
{
// initialization of logger
log4cxx::LoggerPtr domain_filter::debug_logger_(log4cxx::Logger::getLogger("findik.protocols.http.domain_filter"));
int domain_filter::filter_code_ = 401;
// constructor definition of... | WEB | 0.878617 | 4.966649 |
2a5f6472-ca03-43ff-ab36-0994f075f901 | SvyatoslavShypka/KonkursAGC | AGChallenge/CIndividual.cpp | #include "CIndividual.h"
#include <random>
using namespace std;
CIndividual::CIndividual(vector<int> genotyp, CLFLnetEvaluator* evaluatorPointer)
{
this->genotyp = genotyp;
this->evaluatorPointer = evaluatorPointer;
this->fitness = NULL;
}
string CIndividual::toString() const {
string result = "*";
for (int i ... | ALGO | 0.994847 | 4.299026 |
e32c75d5-8bae-46fc-8756-7619e02122b6 | stefdasca/CompetitiveProgramming | Codeforces/CF1073-D2-D.cpp | #include<bits/stdc++.h>
#pragma GCC optimize("O3")
#define mod 1000000007
using namespace std;
long long n, t;
long long v[200002];
struct arr
{
int pos, nr;
};
arr vv[200002];
bool cmp(arr a, arr b)
{
return a.nr < b.nr;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
mt19937 rng(ch... | ALGO | 0.999981 | 3.878494 |
4ad53b69-8b97-4b6b-9b37-d5b12cf9be74 | 0-jij-0/CompetitiveProgramming | Problems Archive/0000 - 0999/0478 - Industrial Nim.cpp | #include <iostream>
using namespace std;
typedef long long ll;
ll pref_xor(ll n) {
if (n <= 0) { return 0; }
int x = n % 4;
if (x == 0) { return n; }
if (x == 1) { return 1; }
if (x == 2) { return n + 1; }
return 0;
}
ll range_xor(ll a, ll b) {
return pref_xor(b) ^ pref_xor(a - 1);
}
int main() {
int n; cin... | ALGO | 0.999835 | 4.448349 |
3f958238-62eb-4c07-8a81-48f2ea283ee2 | oudream/RobWork | RobWork/src/rwlibs/proximitystrategies/ProximityStrategyBullet.cpp | #include "ProximityStrategyBullet.hpp"
#include <rw/common/Exception.hpp>
#include <rw/core/macros.hpp>
#include <rw/geometry/TriMesh.hpp>
#include <rw/geometry/TriangleUtil.hpp>
#include <rw/kinematics/Frame.hpp>
#include <rw/loaders/GeometryFactory.hpp>
#include <BulletCollision/Gimpact/btGImpactCollisionAlgorithm.... | TOOL | 0.942192 | 6.968518 |
46f85762-e642-4682-b29f-f8273bbe3b03 | YB73/DSA-QUES | 1361-validate-binary-tree-nodes/1361-validate-binary-tree-nodes.cpp | class Solution {
public:
bool validateBinaryTreeNodes(int n, vector<int>& leftChild, vector<int>& rightChild) {
// map to keep count of no. of parent for each node
vector<int> parentFreq(n);
for (int i = 0; i < n; i++)
if ((leftChild[i] >= 0 and ++parentFreq[leftChild[i]] > 1) o... | ALGO | 0.999896 | 6.246374 |
7b646f82-d2e2-4f56-8b48-87e0f0a34a96 | superwhd/LeetCode | 38 Count and Say.cpp | class Solution {
public:
string countAndSay(int n) {
if (n == 1)
return "1";
string str = countAndSay(n - 1);
string res = "";
for (int i = 0; i < str.size(); i++ ) {
int j;
for (j = i; j < str.size() && str[i] == str[j]; j++ );
... | ALGO | 0.999982 | 6.85124 |
ad1c0a12-e2b4-4105-8270-96c590bc5523 | Aquib-Nawaz/CP4-Book | UVa/1262.cpp | #include <iostream>
#include <set>
using namespace std;
char A[6][6],B[6][6];
set<char>st[5];
int main(){
int T,k;
scanf("%d",&T);
while (T--){
scanf("%d",&k);
for(int i=0;i<6;i++)scanf("%s",A[i]);
for(int i=0;i<6;i++)scanf("%s",B[i]);
for(int i=0;i<5;i++){
st[i... | ALGO | 0.999869 | 3.068711 |
90dbecfe-5e39-4235-8b14-25bf3333d907 | th3bill1/cpp-learning | cpp learning/Ecosystem.cpp | #include "Ecosystem.h"
#include <iostream>
int Ecosystem::isAnimalOrPlant(const std::string& s, int pos) const
{
string animal = "animal";
string plant = "plant";
if (pos + 5 < s.length() && s[pos] == animal[0] && s[pos + 1] == animal[1] && s[pos + 2] == animal[2] && s[pos + 3] == animal[3] && s[pos + 4] =... | TOOL | 0.928398 | 3.642564 |
99c84a81-cf7c-4951-a147-938ebb62d27e | cavanj-pats/Exercises_CPP | leet 144BinaryTreePreorder.cpp | //leet 144. Binary Tree Preorder traversal
#include <iostream>
#include <vector>
//for math library some people in discussion are saying
//the define, and two includes
//perhaps it depends on the compiler
/* #define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
*/
using namespace std;
//*
//* Definition for... | ALGO | 0.99998 | 6.155266 |
5b1e2a1d-2293-4c87-a3e7-83c3ab4a341d | KausBoss/CP-SubGrouped | LeetCode/July Challenge/14.cpp | class Solution {
public:
double angleClock(int hour, int minutes) {
int hr = hour*60 + minutes;
hr %= 720;
double hrAngle = (double)(hr)/2;
double minAngle = (double)minutes*6;
double angA = hrAngle - minAngle;
if(angA < 0){
angA *= -1;
}
d... | ALGO | 0.999794 | 5.328495 |
7b49553f-f129-4318-b82a-61b9f46b0cfb | duccom0123/jx1-vs2022 | SwordOnline/Sources/KMp3LibClass/src/KMp3HufClass.cpp | //---------------------------------------------------------------------------
// max bits required for any lookup - change if htable changes
// quad required 10 bit w/signs must have (MAXBITS + 2) >= 10
#define MAXBITS 9
//---------------------------------------------------------------------------
// 6 bit lookup (pur... | ALGO | 0.995461 | 4.539399 |
66792d34-a7ac-418b-acd9-9771a79cb4e1 | GYPpro/GYP-s-STL | Dev/04/_PRIV_TEST.cpp | #define DS_TOBE_TEST deque
#define _PRIVATE_DEBUG
// #define __DETIL_DEBUG_OUTPUT
#include "Dev\04\deque.h"
#include <time.h>
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
using TBT = myDS::deque<int>;
void accuracyTest() {//结构正确性测试
TBT tc = TBT();
for(;;)
{
str... | TEST | 0.961977 | 3.828822 |
c615defc-a4b5-40ec-9adb-d454247a63f6 | tttt1314/Proj5_lesson3_2 | example_3.cpp | #include <iostream>
#include <thread>
#include <mutex>
std::mutex mutex1, mutex2;
void ThreadA()
{
// Creates deadlock problem
std::lock_guard<std::mutex> lock2(mutex2);
std::cout << "Thread A" << std::endl;
std::lock_guard<std::mutex> lock1(mutex1);
}
void ThreadB()
{
// Creates deadlock... | ALGO | 0.941546 | 5.794434 |
876a85bd-b9e9-4fda-8b01-e12326e367b8 | agrawalkunal2001/Amazon | 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.998762 | 6.786404 |
71110d46-c932-43e5-a1c8-90987bdce5b3 | PouyaRahimpour/problem-solving | cf/153/C.cpp | /**
* created by: poconut(MPouya)
*/
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define MOD1 998244353
#define nl "\n"
#define INF 2e9
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ff first
#define ss second
#define PI 3.14... | ALGO | 0.999676 | 5.127319 |
79552b29-0b7f-4c0e-81eb-ee3b96845a03 | HaochiBai1998/Leetcode | 496. Next Greater Element I.cpp | //
// Created by bhc on 2022/2/20.
//
#include<vector>
#include<unordered_map>
#include<queue>
using namespace std;
class Solution {
public:
vector<int> nextGreaterElement(vector<int>& nums1, vector<int>& nums2) {
deque<int> que;
int n2=nums2.size();
unordered_map<int,int> hashtable;
... | ALGO | 0.999963 | 5.776073 |
934f5dbe-0fa9-40ac-a922-2ea34571b5cc | CassieLu0/AD688-employability-sp25A3-group2 | .venv/lib/python3.11/site-packages/sklearn/svm/src/liblinear/tron.cpp | #include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include "tron.h"
#ifndef min
template <class T> static inline T min(T x,T y) { return (x<y)?x:y; }
#endif
#ifndef max
template <class T> static inline T max(T x,T y) { return (x>y)?x:y; }
#endif
static void default_print(const char *buf)
{... | ALGO | 0.999648 | 5.836969 |
9d1e646d-f7ea-4b8b-9669-2d2853c429d4 | Taha-Adeel/CP | Hard-75/F_Rudolph_and_Mimic.cpp | #include <bits/stdc++.h>
using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0)
template<class T> struct V: vector<T>{using vector<T>::vector;
void sort() { std::sort(this->begin(), this->end()); }
void sort_dsc() { std::sort(this->begin(), this->end(), greater<T>()); }
auto sum()... | ALGO | 0.999814 | 3.985106 |
f5c8e8ba-cb05-4e62-a207-6d74ddc46a54 | bodasadallah/problem-solving | codeforces/Last degit of the sum of fib/main.cpp | #include <iostream>
#include <iostream>
#include<bits/stdc++.h>
std::vector <int> v;
int main() {
long long n, m;
std::cin >> n ;
bool found=1;
m=10;
v.resize(10*m);
int st=0;
for(int i=0;i<=10*m;i++){
if(i<=1)v[i]=i;
else
{
long long t1,t2,t3;
t1=v[i-1];
t2=v[i-2];
t3=((t1)+(t2));
v[i]=(t3)%60;... | ALGO | 0.999654 | 3.015513 |
56a55a07-0319-475c-967a-26f4a2767a72 | mitempo/problems | trees/binary_tree_dfs_iterative.cpp | #include <functional>
#include <iostream>
#include <stack>
using namespace std;
// Iterative inorder DFS traversal of a binary tree.
// BinaryTree must be a (possibly smart) pointer to a struct with 'value', 'left', and 'right'
// members.
template <typename BinaryTree> void dfs_in(BinaryTree t, function<void(declty... | ALGO | 0.999985 | 6.764959 |
50f455c8-4a19-4b51-a721-7423082434fb | SwindleA/LLMCodeObfuscation | O10/O10_B4.cpp | #include <iostream>
#include <vector>
int main(){
std::vector<int> factors;
int number = 10;
for(int i = number; i > 0; i--){
if(i > 5) {
if(number % i == 0){
factors.push_back(i);
}
} else if (i <= 5) {
if(number % i == 0){... | ALGO | 0.999815 | 4.122063 |
f267fe25-82ea-41bf-bdb7-1fb1b861b7b0 | YichenZhou113/CS225-Data-Structure | lab_graphs/lab_graphs_random.cpp | /**
* @file random.cpp
* Random library implementation.
*/
/**
* Constructor.
* @param seed - seed to initialize the RNG
*/
Random::Random(unsigned long seed)
{
shiftRegister = (seed == 0) ? 1 : seed;
}
/**
* @return a random integer
*/
int Random::nextInt()
{
int ret = 0;
for (int pos = 0; pos < ... | TOOL | 0.996246 | 6.175946 |
d4a12dc5-77ed-4c45-906b-23db9f9b7d1c | Ahmede1407/Problem-Solving | LeetCode/412. Fizz Buzz/412. Fizz Buzz.cpp | class Solution {
public:
vector<string> fizzBuzz(int n) {
vector<string> result;
for (int i=1; i<=n; i++) {
if ( i%3 == 0 && i%5 ==0 ) {
result.push_back("FizzBuzz");
}else if (i%3 == 0) {
result.push_back("Fizz");
}else if (i%5 == ... | ALGO | 0.99992 | 6.642488 |
40eebb89-d3a3-4011-9e50-c1bdbd861989 | TranHuuChien/Data-Structures-And-Algorithm | leetcode/tuan4/baicogiaoFake.cpp | #include<iostream>
#include<vector>
#include<regex>
using namespace std;
struct ngaysinh
{
int ngay,thang, nam;
};
struct sinhvien
{
string mssv, lop,hoten, gioitinh;
int diemtb;
ngaysinh ngaySinh;
};
void nhap1Sinhvien( vector<sinhvien>&danhsach)
{
sinhvien sv;
regex mssvRegex("^[b|n][0-9]{2}dc... | TOOL | 0.921755 | 3.510821 |
d7f32787-2748-4e2e-83ab-75a48066c5f5 | thebesttv/00.ACM | 03.CodeForces/653_3/e2.cpp | #include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<ctime>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<algorithm>
using namespace std;
#define FOR(i,a,b) for(register int i=(a);i<(b... | ALGO | 0.999977 | 3.312379 |
3e9a8600-d8c2-474c-aabd-32b06a17c807 | namanmodi65/DSA-Algorithms | DP/DP on strings/Edit_distance.cpp | int solve(string &a,string &b,int i,int j,vector<vector<int>>&dp){
if(i == a.length()) return b.length()-j;
if(j == b.length()) return a.length()-i;
if(dp[i][j] != -1) return dp[i][j];
int ans = 0;
if(a[i] == b[j]){
ans = solve(a,b,i+1,j+1,dp);
}
el... | ALGO | 0.999997 | 5.62816 |
bbb4016a-f915-4d24-8a6f-f592d65c91fc | fpolica91/Leetcode-challenges | binary_search/rotate_array_by_k.cpp |
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
void rotate(vector<int> &nums, int k) {
for (int i = 0; i < k; i++) {
int last = nums[nums.size() - 1];
for (int j = nums.size() - 2; j >= 0; j--) {
nums[j + 1] = nums[j];
}
... | ALGO | 0.999954 | 5.420691 |
828b6122-5a83-4f6b-a463-4b29b0734f88 | Nayeem10/CP-templates | StressTest/generator.cpp | #include <bits/stdc++.h>
using namespace std;
using LL = long long;
mt19937 rng(random_device{}());
// Generate a random integer in the range [low, high]
LL randomInt(LL low, LL high) {
uniform_int_distribution<LL> dist(low, high);
return dist(rng);
}
// Generates unique (vi, pi) pairs
set<pair<int, int>> ge... | ALGO | 0.984728 | 4.053683 |
54f6981d-7f91-48bd-b040-917dd3cb4836 | telematixsw/eigen | doc/snippets/SelfAdjointEigenSolver_SelfAdjointEigenSolver_MatrixType.cpp | MatrixXd X = MatrixXd::Random(5,5);
MatrixXd A = X + X.transpose();
cout << "Here is a random symmetric 5x5 matrix, A:" << endl << A << endl << endl;
SelfAdjointEigenSolver<MatrixXd> es(A);
cout << "The eigenvalues of A are:" << endl << es.eigenvalues() << endl;
cout << "The matrix of eigenvectors, V, is:" << endl << ... | ALGO | 0.999756 | 3.06305 |
0b249a33-5023-40f5-bb8d-7d622148e01c | pinkshirt/Codechef | sep14/CHEFLR.cpp | #include"stdio.h"
#include"stdlib.h"
#include"string.h"
#define MOD 1000000007
int main(){
int T;
char* str = (char*) malloc( sizeof(char)*100000 );
scanf( "%d", &T );
for( int i=0;i<T;i++ ){
scanf( "%s", str );
int length = strlen(str), retVal =0;
for( int i=0;i<length;i++ ){
... | ALGO | 0.999718 | 3.313898 |
f1186bc4-9e3a-4261-8759-f701753f3a1f | Niladree60/LeetCodeSolutions | LeetCode752.cpp | class Solution {
public:
int openLock(vector<string>& deadends, string target) {
string start = "0000";
unordered_set<string> st(deadends.begin(),deadends.end()) , seen;
queue<string> q;
q.push(start);
int level = 0;
while(!q.empty()) {
int n = q.size();
... | ALGO | 0.999925 | 6.295888 |
fb9b7071-6485-48d3-ad01-50e4e99212b4 | hasnain2808/convai2-using-mbt | tt.cpp | #include "matrix_addition_improved.h"
using namespace std;
vector < vector <int> > matrix_addition_improved (vector < vector <int> > matrixa, vector < vector <int> > matrixb) {
// store the number of rows and columns in the matrices
vector<int>::size_type rows_a = matrixa.size();
vector<int>::size_ty... | ALGO | 0.999579 | 5.780105 |
0f515039-00ca-42d6-9737-5321fb7fc8d7 | yokotech/competitive_programming | AtCoder/agc/agc_033/1_agc033_a.cpp | // 1_agc033_a
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#inclu... | ALGO | 0.999813 | 3.982487 |
4169b0b0-aa3a-4a14-b7d9-218839823ab4 | CaptainJang316/codetree-TILs | 240621/왕실의 기사 대결/royal-knight-duel.cpp | // 9:50 ~ ....., 11:40 ~ 12:10
//왕실의 기사들은 L×L 크기의 체스판 위에서 대결을 준비하고 있습니다.
//체스판의 왼쪽 상단은(1, 1)로 시작하며, 각 칸은 빈칸, 함정, 또는 벽으로 구성되어 있습니다.
//체스판 밖도 벽으로 간주합니다.
//
//기사들은 자신의 마력으로 상대방을 밀쳐낼 수 있습니다.
//각 기사의 초기위치는(r, c)로 주어지며,
//그들은 방패를 들고 있기 때문에(r, c)를 좌측 상단으로 하며 h(높이)×w(너비) 크기의 직사각형 형태를 띄고 있습니다.각 기사의 체력은 k로 주어집니다.
//(1) 기사 이동
... | ALGO | 0.999058 | 3.646782 |
32185f02-b766-4e16-9844-489da4b4f2fa | GitJuliohub06/Clases-ejercicios | clase-29-05-2024/par-impar-arreglos.cpp | #include <iostream>
using namespace std;
int main(){
int numero = 0;
int indicepar = 0;
int indiceimpar = 0;
int pares[100]={};
int impares[100]={};
do
{
cout<<"Ingrese un numero: (digite 0 para salir)";
cin>>numero;
if ((numero%2==0) && numero !=0){
pares[indicepar]=numero;
indicepar++;
}
... | ALGO | 0.998499 | 3.640653 |
491cf886-37b0-487d-b5ad-d7eed004d2ec | prashanthr11/Leetcode | practice/Trees/Binary Tree Inorder Traversal.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.999982 | 6.41743 |
9178bae0-5345-4805-9a05-c4b7cc0ceed8 | sys-bio/libsbml-draw | src/cpp/box.cpp | //== BEGINNING OF CODE ===============================================================
//== INCLUDES ========================================================================
#include "SagittariusCore.h"
#include "box.h"
#include "sign_mag.h"
#include "allen.h"
namespace LibsbmlDraw {
std::ostream& operator<... | TOOL | 0.969074 | 5.500807 |
6b1862e5-4c3e-4f2b-87a2-cd4e942eb76a | BioDataAnalysis/blaze | blazemark/src/clike/SMatDVecMult.cpp | //=================================================================================================
//=================================================================================================
//*************************************************************************************************
// Includes
//****... | ALGO | 0.999387 | 5.498642 |
38b5b9ed-4edf-4bca-8ed7-4df37a0aab0e | HimanshuJo/HackerRank-CPP-Algorithms-Solutions | GradingStudents.cpp | /*
https://www.hackerrank.com/challenges/grading/problem
*/
#include <bits/stdc++.h>
using namespace std;
string ltrim(const string &);
string rtrim(const string &);
/*
* Complete the 'gradingStudents' function below.
*
* The function is expected to return an INTEGER_ARRAY.
* The function accepts INTEGER_ARRAY ... | ALGO | 0.999204 | 5.105844 |
bf2c48d0-b0ac-4987-b428-6b18e82a07ee | dzharlaksl/mlops_eroshin | lib/python3.12/site-packages/sklearn/utils/src/MurmurHash3.cpp | // Note - The x86 and x64 versions do _not_ produce the same results, as the
// algorithms are optimized for their respective platforms. You can still
// compile and run any of them on any platform, but your performance with the
// non-native version will be less than optimal.
#include "MurmurHash3.h"
//-------------... | ALGO | 0.998049 | 7.200464 |
7d74d2fc-59a6-4c1d-b985-a7295a481053 | prithvijitbasak/LeetCode-Solutions | 472. Concatenated Words.cpp | //Editorial: https://leetcode.com/problems/concatenated-words/solutions/2822170/concatenated-words/?orderBy=most_votes
class Solution {
public:
vector<string> findAllConcatenatedWordsInADict(vector<string>& words) {
vector<string> ans;
unordered_set<string> ust(words.begin(),words.end());
fo... | ALGO | 0.999723 | 6.184791 |
75ee7a4c-dcd4-4602-afd6-a0690eb9386f | AngelGMV/CSES | IntroductoryProblems/TrailingZeros.cpp | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
#define pb push_back
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define FOR(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define ROF(i, a, b) for (int i = (int)a - 1; i >= (int)... | ALGO | 0.99991 | 5.349668 |
96cac5d4-9c68-4fed-befe-085c42dece08 | Wonderuj/codes | Codeforces/round 965/c.cpp | #include <bits/stdc++.h>
using namespace std;
void solve()
{
int x, y, k;
cin >> x >> y >> k;
int stepX = (x + k - 1) / k;
int stepY = (y + k - 1) / k;
// cout << stepX << " " << stepY << " " << stepX - stepY << endl;
cout<< stepX + stepY + abs(stepX - stepY) - (stepX > stepY) << endl;
}
sign... | ALGO | 0.999589 | 3.982087 |
55d31e1a-a3d8-442a-be7a-ce305b6d68c5 | Mohamed-A-Badr/Algorithms-and-Data-Structures-training---IEEE-CS-ZSB | CS21-Science-Week-7/Steps/main.cpp | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast_ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_in freopen("input.txt", "r", stdin);
#define file_out freopen("output.txt", "w", stdout);
#define el "\n"
#define mod 1000000007
#define pb push_back
#define pp pop_back... | ALGO | 0.999617 | 3.58819 |
f1ff1877-4dce-4075-aca0-dff266819387 | WeiHe999/dmoj_cpp_level_2 | COCI '18 Contest 4 #2 Wand.cpp | #include <bits/stdc++.h>
using namespace std;
void dfs(unordered_map <int, unordered_set <int> > &graph, int cur_node, vector <bool> &vec1)
{
for (auto x : graph[cur_node])
{
if (!vec1[x - 1])
{
vec1[x - 1] = true;
dfs(graph, x, vec1);
}
}
}
int main()
{
... | ALGO | 0.999919 | 4.140067 |
9072d3de-4801-4528-abc0-2e5b112c50c2 | albertorobles2000/Ejercicios-sobre-la-STL-conjuntos-y-listas | src/ejercicio16.cpp | #include <list>
#include <iostream>
using namespace std;
template<typename T>
list<pair<T,int>> comprimir (const list<T> & lista){
list<pair<T,int>> nueva;
typename list<T>::const_iterator it = lista.begin();
T elemento;
int apariciones;
while(it != lista.end()){
elemento = *it;
apariciones = 1;
it++;
wh... | ALGO | 0.99913 | 3.903484 |
98dd3fe7-84ed-4ad5-846d-c41612f23b1a | bitmingw/LintcodeSolution | 517UglyNumber/main.cpp | #include <iostream>
using namespace std;
class Solution {
public:
/**
* @param num an integer
* @return true if num is an ugly number or false
*/
bool isUgly(int num) {
if (num < 1) return false;
if (num == 1) return true;
if (num == 2) return true;
if (num == 3)... | ALGO | 0.998761 | 5.443562 |
39093cb1-caa6-48a9-8268-54da04e097f1 | HarshChaturvedi19/DSA-Practice | Array/twosum.cpp | #include <iostream>
#include <vector>
using namespace std;
class Solution {
public:
vector<int> twoSum(vector<int>& nums, int target) {
int size = nums.size();
for (int i = 0; i < size; i++) {
for (int j = i + 1; j < size; j++) {
if (nums[i] + nums[j] == target) {
... | ALGO | 0.999898 | 6.684932 |
b9a494d2-12ac-49a4-ad62-e648537da356 | 21-aakash/Data-Structures-Problems- | strings/excelsheet.cpp | #include<bits/stdc++.h>
using namespace std ;
int titleToNumber(string columnTitle) {
int n =columnTitle.size();
long int ans =0;
for(int i=0 ; i<n ; i++)
{
ans =26*ans+ columnTitle[i]-'A'+1;
}
return ans ;
}
int main()
{
string s="AAA";
cout<<ti... | ALGO | 0.999819 | 4.979552 |
b3e3222f-5da5-47b6-81fc-db337a4fc821 | zhongjianhua163/BlackMoonKernelStaticLib | krnln/krnln_RTrim.cpp | #include "stdafx.h"
#include "Myfunctions.h"
//ı - ɾβ
/*
øʽ ı͡ ɾβ ı ɾոı - ϵͳֿ֧->ı
ӢƣRTrim
һıаɾβȫǻǿոָıΪ
<1>ΪɾոıΪıͣtext
*/
LIBAPI(char*, krnln_RTrim)
{// ߺ
PMDATA_INF pArgInf = &ArgInf;
char* pSrc = pArgInf[0].m_pText;
register char *str1 = pSrc;
register char* pLastNS = NULL;
while ( *str1 )
{
... | TOOL | 0.979646 | 3.027485 |
3bd5ed74-2e18-4fd9-9842-57f7f6f5dd0e | tajshuvoo/TLE_CP_31_SHEET | 900/16.cpp | #include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <string>
#include <numeric>
#include <cmath>
using namespace std;
int gcd(int a, int b) {
while(b != 0) {
int temp = b;
b = a % b;
a = temp;
}
return a;
}
#define rtn return 0;
#define vctr(n, name) ... | ALGO | 0.999914 | 4.149172 |
bd0282a6-a606-4ff5-80e1-205e7c62c29d | nimec77/cpp_yandex | src/tutorial/tutorial_3_3_d.cpp | #include <algorithm>
#include <iostream>
#include <iterator>
#include <vector>
int Approx(const std::vector<int>& v, int x) {
auto iter = std::lower_bound(v.begin(), v.end(), x);
if (iter == v.end()) {
return *std::prev(iter);
} else if (iter == v.begin()) {
return *iter;
} else if (*it... | ALGO | 0.999988 | 4.70131 |
7cb5d246-f527-486c-a211-c1a0ca7d2221 | MarkKim1/Leetcode | 525-contiguous-array/525-contiguous-array.cpp | class Solution {
public:
int findMaxLength(vector<int>& nums) {
unordered_map<int,int> map;
map[0] = -1;
int count = 0;
int result = 0;
for(int i = 0; i < nums.size(); i++){
count = count + (nums[i] == 1 ? 1 : -1);
if(map.find(count) != map.end()){
... | ALGO | 0.999912 | 5.924544 |
9f4a8820-1ceb-4c66-bb63-5d9cda1eac5b | Sup3rFire/CP | loaling/A_Wasted_Time.cpp | #include <bits/stdc++.h>
using namespace std;
#define pow2(x) (x)*(x)
pair<int, int> pre;
long double getDist(int x, int y) {
long long ans = pow2(x-pre.first) + pow2(y-pre.second);
pre = {x, y};
return sqrtl(ans);
}
int main() {
int n, k;
cin >> n >> k;
cout << fixed << setprecision(9);
long double an... | ALGO | 0.999879 | 4.207777 |
e6ad0745-faa1-4fea-a0f1-c305db0895c6 | Next-Gen-UI/Hacktober | Leetcode/0554. Brick Wall/0554.cpp | class Solution {
public:
int leastBricks(vector<vector<int>>& wall) {
int maxCount = 0;
unordered_map<int, int> count;
for (const auto& row : wall) {
int prefix = 0;
for (int i = 0; i < row.size() - 1; ++i) {
prefix += row[i];
maxCount = max(maxCount, ++count[prefix]);
... | ALGO | 0.99978 | 6.532728 |
87fb6027-4a07-4dd9-a3c3-01dcd9b02457 | chishiya2309/DSA | DoThi/Disjoint_set.cpp | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, m;
int parent[1005], sz[1005];
void init(){
for(int i = 1; i <= n; i++){
parent[i] = i;
sz[i] = 1;
}
}
int Find(int u){
if(u == parent[u])
return u;
return parent[u] = Find(parent[u]);
}
bool Union(int x, int y){
x = Find(x); /... | ALGO | 0.999795 | 4.773996 |
8a3ce4ee-bdf8-4876-bac1-16647cdecd0a | lamphanviet/competitive-programming | uva-online-judge/accepted-solutions/11797.cpp | #include <stdio.h>
#include <iostream>
#include <string.h>
char name[7][5];
int n,m,list[7][30],who,ttime[7];
void Khoitao()
{
strcpy(name[1],"Ja");
strcpy(name[2],"Sam");
strcpy(name[3],"Sha");
strcpy(name[4],"Sid");
strcpy(name[5],"Tan");
}
void Reset()
{
for (int i=1;i<=5;i++)
ttim... | ALGO | 0.999762 | 3.044491 |
bcf9eee4-797e-4bb3-845b-8ae90b4ebca4 | Saeed11b95/C-For-Computer-Vison | homework_2/task_1/src/programs.cpp | #include <iostream>
#include <random>
int Random_Number_Generator(){
std::random_device number;
std:: uniform_int_distribution<int> rnge(0, 99);
int random_number{0};
random_number = rnge(number);
return random_number;
}
std::string Check_Smaller_Larger(int generated_number, int entered_number){
... | TOOL | 0.955531 | 3.318381 |
38aa189e-7e07-4743-817b-58a56ecf2429 | takashin9/AtCoder | ABC/abc332/abc332_d.cpp | #include <bits/stdc++.h>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
using ll = long long;
int bsort (vector<int> v) {
int n = v.size();
int cnt = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n - i - 1; j++) {
... | ALGO | 0.999933 | 4.070317 |
e43de1ab-e921-43d5-aec5-47658464b442 | PriyanshK09/Leetcode-Discord-Bot | solutions/split-array-into-consecutive-subsequences.cpp | // Time: O(n)
// Space: O(1)
class Solution {
public:
bool isPossible(vector<int>& nums) {
auto pre = numeric_limits<int>::min(), cur = 0;
auto cnt1 = 0, cnt2 = 0, cnt3 = 0; // count of each length ending at cur
for (int i = 0; i < nums.size(); pre = cur) {
auto cnt = 0;
... | ALGO | 0.999957 | 5.82217 |
f6147fc6-06cd-4df5-aabc-56293befb93a | RinCloud/TrickCatcher | Datasets/TrickyBugs/GenProgs/dpp_generated_progs_cpp/p02718/p02718_num9_parsed.cpp | #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
vector<int> A(N);
for (int i = 0; i < N; i++) {
cin >> A[i];
}
sort(A.begin(), A.end(), greater<int>());
int totalVotes = 0;
for (int i = 0; i < M; i++) {
... | ALGO | 0.999997 | 4.797036 |
3381a93b-d7f4-4e74-9807-59e7fe685064 | ynonenull/Leetcode | Merge_Two_Sorted_Lists_23ms.cpp | #include <iostream>
#include <vector>
using namespace std;
struct ListNode {
int val;
ListNode *next;
ListNode( int x ) : val( x ), next( NULL ) {}
};
class Solution
{
public:
ListNode *mergeTwoLists( ListNode *l1, ListNode *l2 )
{
ListNode *head = new ListNode( 0 );
ListNode *cur = head;
while ( l1 != NU... | ALGO | 0.999871 | 5.443363 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.