doc_id
stringlengths
36
36
metadata
dict
input
stringlengths
28
4.3k
output
stringlengths
11
5.45k
f065454c-8b5c-4159-96bf-52e8fbd86522
{ "language": "C++" }
```c++ ``` Add wrapper for user tuto 01
```c++ #include "Halide.h" #include "wrapper_tutorial_01.h" #include "tiramisu/utils.h" #include <cstdlib> #include <iostream> int main(int, char **) { int N = 10; Halide::Buffer<int32_t> output(N); init_buffer(output, (int32_t)9); std::cout << "Array (after initialization)" << std::endl; print_b...
a71641df-12b1-41ac-bc28-7a2574480666
{ "language": "C++" }
```c++ ``` Add a new SkMemory implementation that uses mozalloc instead of malloc
```c++ /* * Copyright 2011 Google Inc. * Copyright 2012 Mozilla Foundation * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "SkTypes.h" #include "mozilla/mozalloc.h" #include "mozilla/mozalloc_abort.h" #include "mozilla/mozalloc_oom.h" void sk_...
1c878666-b133-431c-a8e8-bd4ee3ca5400
{ "language": "C++" }
```c++ ``` Print all paths from root to node separately.
```c++ // Print all root to leaf paths of a binary tree /* Algorithm: initialize: pathlen = 0, path[1000] // 1000 is some max limit for paths, it can change // printPathsRecur traverses nodes of tree in preorder printPathsRecur(tree, path[], pathlen) 1) If node is not NULL then a) push data to path arra...
31bebfc8-261e-4e94-bea3-82bae132a4f8
{ "language": "C++" }
```c++ ``` Add Chapter 26, exercise 12
```c++ // Chapter 26, exercise 12: generate random floating point numbers and sort them // using std::sort(). Measure time used to sort 500,000 doubles and 5,000,000 // doubles. #include<ctime> #include<cstdlib> #include<iostream> #include<exception> #include<vector> #include<limits> #include<algorithm> using namespa...
cb70bc31-4867-4fc8-9bfe-0806c49b1ab9
{ "language": "C++" }
```c++ ``` Add solution 412. Fizz Buzz
```c++ /* * https://leetcode.com/problems/fizz-buzz/ * Write a program that outputs the string representation of numbers from 1 to n. * But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”. * For numbers which are multiples of both three and five outp...
59e9c266-7daa-49cb-978b-d7be483c5086
{ "language": "C++" }
```c++ // Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "base/path_service.h" #include "chrome/test/remoting/qunit_browser_test_runner.h" #if defined(OS_MACOSX) #include "base/mac/foundation_ut...
```c++ // Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "base/path_service.h" #include "chrome/test/remoting/qunit_browser_test_runner.h" #if defined(OS_MACOSX) #include "base/mac/foundation_ut...
bf7c2012-4b4b-417a-9b14-e12270fa8500
{ "language": "C++" }
```c++ ``` Add an example of Kiss FFT in C++.
```c++ #include "kiss_fft.h" #include <complex> #include <iostream> #include <vector> using namespace std; int main() { const int nfft = 256; kiss_fft_cfg fwd = kiss_fft_alloc(nfft, 0, NULL, NULL); kiss_fft_cfg inv = kiss_fft_alloc(nfft, 1, NULL, NULL); vector<std::complex<float>> x(nfft, 0.0); vector<std::...
33d10aae-1cb4-456e-80bc-d9f84cf8fbe7
{ "language": "C++" }
```c++ ``` Add test for gpu assertions
```c++ #include "Halide.h" using namespace Halide; bool errored = false; void my_error(void *, const char *msg) { printf("Expected error: %s\n", msg); errored = true; } void my_print(void *, const char *msg) { // Empty to neuter debug message spew } int main(int argc, char **argv) { Target t = get_j...
e9df2491-1653-4792-a7ca-2a7072e9421c
{ "language": "C++" }
```c++ ``` Implement Boundary traversal of tree.
```c++ #include <stdio.h> typedef struct _NODE { int data; _NODE* left; _NODE* right; } NODE; NODE* newNode(int data) { NODE* node = new NODE(); node->data = data; node->left = nullptr; node->right = nullptr; return node; } void printBoundaryLeft(NODE* root) { if (root) { if (root->left) { ...
76867ea1-9339-461d-867a-526e0b18352d
{ "language": "C++" }
```c++ ``` Add library (Range Minimum Query)
```c++ // Verified: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_A struct RMQ { int size; ll default_value; vector<ll> tree; RMQ (int n, ll def) { default_value = def; size = 1; while(size < n)size *= 2; tree = vector<ll>(size * 2 - 1, default_value); } void update(int x,...
cd7ecbb0-ceef-467d-8bae-c7c3aa9c25fa
{ "language": "C++" }
```c++ #include <string> #include "configuration.hh" int from_visual(const std::string& cont, int x) { if(cont.size() == 0) return 0; int count = 0, til = 0; int numTab = 0; for(unsigned int i = 0; i < cont.length(); i++) { unsigned int len; if(cont[i] == '\t') { le...
```c++ #include <string> #include "configuration.hh" int from_visual(const std::string& cont, int x) { if(cont.size() == 0) return 0; int count = 0, til = 0; int numTab = 0; for(unsigned int i = 0; i < cont.length(); i++) { unsigned int len; if(cont[i] == '\t') { le...
cb9df4a4-98ad-43e2-bc94-9f7827892070
{ "language": "C++" }
```c++ ``` Add solution of prob 4
```c++ #include <stdio.h> #include <stdlib.h> /* rand(), srand() */ #include <time.h> /* time() */ #include <math.h> /* abs() */ int main(void) { srand(time(NULL)); int N, T; printf("Enter N= "); scanf("%d", &N); printf("Enter T= "); scanf("%d", &T); int step = 0; for(int count = 0; count < T...
a322eeb3-0f4b-4122-a078-ba1119997fd9
{ "language": "C++" }
```c++ ``` Print max right element in array.
```c++ #include <stdio.h> void PrintNextGreatest(int arr[], int size) { int temp[size]; int max = -1; temp[size - 1] = max; for (int count = size - 2; count >= 0; count--) { if (arr[count] > max) { max = arr[count]; } temp[count] = max; } printf("Original array \n"); for (int i = 0; i ...
a98a14d2-2bf3-469f-b3bf-dafcdc07e8eb
{ "language": "C++" }
```c++ ``` Insert Delete GetRandom O(1) - Duplicates allowed
```c++ class RandomizedCollection { public: map<int,vector<int>> index; vector<int> nums; /** Initialize your data structure here. */ RandomizedCollection() { } /** Inserts a value to the collection. Returns true if the collection did not already contain the specified element. */ bool inse...
17e25f50-a86e-4855-af55-020213017d27
{ "language": "C++" }
```c++ ``` Add Chapter 21, exercise 5
```c++ // Chapter 21, Exercise 5: redesign and reimplement find() and count() to take // iterators to first and last elements (no end()), compare results to the // standard versions - can't return iterator to end() if not found #include "../lib_files/std_lib_facilities.h" //------------------------------------------...
64f448d9-bd7c-4c18-be7e-34185014087c
{ "language": "C++" }
```c++ ``` Add missing test for warning added in r310803.
```c++ // RUN: %clang_cc1 %s -verify -fsyntax-only -Wc++2a-compat -std=c++17 #define concept constexpr bool template<typename T> concept x = 0; #undef concept int concept = 0; // expected-warning {{'concept' is a keyword in C++2a}} int requires = 0; // expected-warning {{'requires' is a keyword in C++2a}} ```
79b653f4-4134-48ab-b1a6-c840d4438813
{ "language": "C++" }
```c++ ``` Trim a Binary Search Tree
```c++ /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Solution { public: TreeNode* trimBST(TreeNode* root, int L, int R) { if(!root) return NULL; ...
121228bf-ba57-4cd8-bd9d-bf6287b152ee
{ "language": "C++" }
```c++ ``` Add a test to verify the x86 intrinsic headers compile cleanly with no warnings or errors.
```c++ // Make sure the intrinsic headers compile cleanly with no warnings or errors. // RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wsystem-headers \ // RUN: -fsyntax-only -x c++ -Wno-ignored-attributes -verify %s // RUN: %clang_cc1 -triple x86_64-unknown-unknown -Wsystem-headers \ // RUN: -fsyntax-only -x c+...
e59fc785-5d6a-4077-85bc-ceebb2b4c0b4
{ "language": "C++" }
```c++ ``` Add the solution to "Student Scheduling".
```c++ #include <iostream> #include <algorithm> using namespace std; typedef struct node { int time; int due; }task_node; bool cmp(task_node a, task_node b) { return a.due < b.due; } bool is_possible(task_node *a, int n) { sort(a, a + n, cmp); int sum = 0; for (int i = 0; i < n; i++) { if (a[i].time > a[i].d...
fa0d6909-44de-4352-9a27-cb70e46f50a2
{ "language": "C++" }
```c++ ``` Add body skeleton for cache simulation program
```c++ #include <stdio.h> #include <time.h> #include <stdlib.h> #include <deque> #define MEM_SIZE (1<<20) #define CACHE_SIZE (1<<8) #define DATA_SIZE (1<<8) using namespace std; int main() { // Variables used int dir, cmd, op; unsigned char dat, wait; // Plant the seed srand(time(0)); // Infinit Loop while...
0a4023cb-472b-4131-aa4e-9e44bc22a670
{ "language": "C++" }
```c++ ``` Test case for my last fix.
```c++ // RUN: %clang_cc1 -verify -fsyntax-only %s template<typename T> struct Node { int lhs; void splay( ) { Node<T> n[1]; (void)n->lhs; } }; void f() { Node<int> n; return n.splay(); } ```
8e1e924b-e2ac-4ba5-8ff0-15c390e719b0
{ "language": "C++" }
```c++ ``` Add arm_id_baesd_node without callback function
```c++ #include"ros/ros.h" #include"arm_msgs/ArmAnglesDegree.h" #include"servo_msgs/IdBased.h" #include<vector> void armMsgCb(const arm_msgs::ArmAnglesDegree::ConstPtr& msg); ros::Publisher pub; int main(int argc, char* argv[]) { ros::init(argc, argv, "arm_id_based_node"); ros::NodeHandle pnh("~"); std::vecto...
4a8d4e5c-b455-4a54-8171-5c2d18b71bd7
{ "language": "C++" }
```c++ ``` Add a test for PR40977
```c++ //===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===--------------------...
98335736-5df2-4404-b3e1-d55b29a481d8
{ "language": "C++" }
```c++ ``` Add the solution to "Preceding Palindrome".
```c++ #include <iostream> #include <sstream> #include <string> #include <cstdlib> using namespace std; int reverse(int x) { int r = 0; while (x > 0) { r = r * 10 + x % 10; x /= 10; } return r; } bool is_palindrome(int x) { if (reverse(x) == x) { return true; } return false; } int main() { int T; cin ...
55b36014-d95f-4493-abe4-b2debed6cf84
{ "language": "C++" }
```c++ ``` Add a test file missed from r199782.
```c++ // RUN: %clang_cc1 -verify %s -pedantic-errors // RUN: %clang_cc1 -verify %s -pedantic-errors -DINLINE // RUN: %clang_cc1 -verify %s -pedantic-errors -DSTATIC // RUN: %clang_cc1 -verify %s -pedantic-errors -std=c++11 -DCONSTEXPR // RUN: %clang_cc1 -verify %s -std=c++11 -DDELETED #if INLINE inline // expected-er...
6aee4020-a754-491a-9da4-9425039a7c6e
{ "language": "C++" }
```c++ ``` Add solution for chapter 19, test 18
```c++ #include <iostream> #include <algorithm> #include <functional> #include <vector> #include <string> using namespace std; using std::placeholders::_1; int main() { vector<string> svec = {"", "a", "", "b", "c"}; //use mem_fn cout << count_if(svec.cbegin(), svec.cend(), mem_fn(&string::empt...
de0085c8-6930-45ab-8922-f41473d3f53d
{ "language": "C++" }
```c++ ``` Add a test application for the get_pointer methods. This should really be in a unittest framework...
```c++ #include <OpenSG/OSGBaseInitFunctions.h> #include <OpenSG/OSGNode.h> #include <OpenSG/OSGNodeCore.h> #include <OpenSG/OSGRefPtr.h> int main (int argc, char **argv) { OSG::osgInit(argc, argv); // Test getting pointers OSG::NodePtr node_ptr = OSG::Node::create(); OSG::Node* node_cptr = get_poi...
4ad298b2-9df8-459d-a4f8-6beb65292932
{ "language": "C++" }
```c++ ``` Add one more type unit test
```c++ // Test that we can jump from a type unit in one dwo file into a type unit in a // different dwo file. // REQUIRES: lld // RUN: %clang %s -target x86_64-pc-linux -fno-standalone-debug -g \ // RUN: -fdebug-types-section -gsplit-dwarf -c -o %t1.o -DONE // RUN: %clang %s -target x86_64-pc-linux -fno-standalone-...
6240057a-c7bf-4d77-a62a-13c467e65c37
{ "language": "C++" }
```c++ ``` Add Solution for 415 Add Strings
```c++ // 415. Add Strings /** * Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2. * * Note: * * 1. The length of both num1 and num2 is < 5100. * 2. Both num1 and num2 contains only digits 0-9. * 3. Both num1 and num2 does not contain any leading zero. * 4. ...
2edd0223-de72-465a-919c-949eb88829ad
{ "language": "C++" }
```c++ ``` Add the solution to "Counting Sort 1".
```c++ #include <iostream> #include <cstring> using namespace std; const int maxn = 100; int main() { int n; cin >> n; int *c = new int[maxn]; memset(c, 0, sizeof(c)); while (n--) { int x; cin >> x; c[x]++; } for (int i = 0; i < maxn; i++) { cout << c[i] << " "; } delete [] c; return 0; }```
422ea39b-8c7c-46be-85a0-0fab1d0e3627
{ "language": "C++" }
```c++ ``` Add the aggregate test file.
```c++ #include "test/test_main.h" int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); // what ever initialization you need here // invode the test return RUN_ALL_TESTS(); } ```
3dede6c0-75e3-4ab4-91b8-85a2f407d68a
{ "language": "C++" }
```c++ ``` Add Solution for 5. Longest Palindromic Substring
```c++ // 5. Longest Palindromic Substring /** * Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. * * Example: * * Input: "babad" * Output: "bab" * Note: "aba" is also a valid answer. * * Example: * * Input: "cbbd" * Output: "bb" * * ...
4fbaa2e1-afbb-40b8-bcb3-6818b9d77d2e
{ "language": "C++" }
```c++ ``` Test jumps which bypass variables declaration
```c++ // RUN: %clangxx_asan -O0 -fsanitize-address-use-after-scope %s -o %t && %run %t // Function jumps over variable initialization making lifetime analysis // ambiguous. Asan should ignore such variable and program must not fail. #include <stdlib.h> int *ptr; void f1(int cond) { if (cond) goto label; in...
ec7cb3c7-3347-441b-a2fd-cf6f82d278c5
{ "language": "C++" }
```c++ ``` Add Chapter 21, Try This 4
```c++ // Chapter 21, Try This 4: get Dow Jones map example to work #include "../lib_files/std_lib_facilities.h" #include<map> #include<numeric> //------------------------------------------------------------------------------ double weighted_value(const pair<string,double>& a, const pair<string,double>& b) { ...
8d65d64d-5215-46be-aa5c-cfb58515102b
{ "language": "C++" }
```c++ ``` Add missing pgmspace test file
```c++ /* test_pgmspace.cpp - pgmspace tests Copyright © 2016 Ivan Grokhotkov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to ...
b6199db1-3df9-4163-9d66-72f5c8e06794
{ "language": "C++" }
```c++ ``` Add new track to memory
```c++ #include <libdariadb/storage/memstorage/memstorage.h> #include <libdariadb/storage/settings.h> #include <libdariadb/utils/async/thread_manager.h> #include <libdariadb/utils/logger.h> #include <benchmark/benchmark_api.h> class BenchmarkLogger : public dariadb::utils::ILogger { public: BenchmarkLogger() {} ~...
4922b711-de95-45d7-a1de-1ce0b7022475
{ "language": "C++" }
```c++ ``` Add the class 'CMDLINE'. So the user is able to change default setting.
```c++ #include <iostream> #include <cstring> #include "cmdline.h" CMDLINE::CMDLINE(int argC, char **argV) { argc = argC; for (int i = 0; i < argc; i++) argv[i] = argV[i]; } int CMDLINE::help() { std::cout << "Help! (coming soon)" << std::endl; return 0; } int CMDLINE::version() { std::cout << "Versio...
84d04655-3a58-4051-a570-936c44c11cb4
{ "language": "C++" }
```c++ ``` Add the solution to "Preorder Perusal".
```c++ #include <iostream> #include <string> using namespace std; struct Node { string s; Node *left; Node *right; }; Node *new_node(string s) { Node *temp = new Node(); temp->s = s; temp->left = NULL; temp->right = NULL; return temp; } bool add_edge(Node *root, Node *father, Node *child) { if (root == NULL...
0a6e3a11-f586-46d7-8206-d0dcf8bbcd83
{ "language": "C++" }
```c++ ``` Add solution of prob 1
```c++ #include <stdio.h> int main(void) { const double r = 100; int count = 1; /* Include (0, 0) which makes denominator to zero */ for(double x = 1; x <= r; ++x) for(double y = 1 / (3 * x); x * x + y * y <= r * r && y <= 2 / (3 * x); ++y, ++count); printf("Result: %d\n", count); return...
be3c6ca5-cef4-4709-91cb-34ff8c4a3c7c
{ "language": "C++" }
```c++ ``` Fix build. Forgot to explictly add file while patching. BUG=none TEST=none TBR=rsleevi
```c++ // Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/test/webdriver/commands/response.h" #include "base/json/json_writer.h" #include "base/logging.h" #include "base/values.h" na...
ebd0759e-6bb4-4b86-85ad-72aa64d7d040
{ "language": "C++" }
```c++ ``` Add accidentally forgotten testcase from r262881.
```c++ // RUN: %clang_cc1 -std=c++1z -verify %s void f(int n) { switch (n) { case 0: n += 1; [[fallthrough]]; // ok case 1: if (n) { [[fallthrough]]; // ok } else { return; } case 2: for (int n = 0; n != 10; ++n) [[fallthrough]]; // expected-error {{does not directly p...
c7c343f3-de3f-4151-88f3-1fd36b27b1e1
{ "language": "C++" }
```c++ ``` Add Solution for Problem 108
```c++ // 108. Convert Sorted Array to Binary Search Tree /** * Given an array where elements are sorted in ascending order, convert it to a height balanced BST. * * Tags: Tree, Depth-first Search * * Similar Problems: (M) Convert Sorted List to Binary Search Tree * * Author: Kuang Qin */ #include "stdafx.h" #...
3dd96470-9fe6-4929-8076-34aa789e4054
{ "language": "C++" }
```c++ ``` Add UnitTests for Timer class.
```c++ // This file is a part of the OpenSurgSim project. // Copyright 2013, SimQuest Solutions Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licens...
873faa65-32e0-447a-be2b-340fc1ab0c0c
{ "language": "C++" }
```c++ ``` Convert a Number to Hexadecimal
```c++ class Solution { public: string toHex(int num) { if(num==0) return "0"; string ans; char hexa[16]={'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; int cnt=0; while(num!=0 && cnt<8){ ans=hexa[(num&15)]+ans; num=num>>4; ...
9f0e90f8-05e8-4e23-bd8e-9b65b4388c76
{ "language": "C++" }
```c++ ``` Add missing GN test file.
```c++ // Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "testing/gtest/include/gtest/gtest.h" #include "tools/gn/value.h" TEST(Value, ToString) { Value strval(NULL, "hi\" $me\\you\\$\\\""); ...
1d540fe3-dc66-4c36-aefe-4fb0830b4d2b
{ "language": "C++" }
```c++ ``` Add a test program that writes and reads a non-ASCII character.
```c++ #include <windows.h> #include <assert.h> #include <stdlib.h> #include <stdio.h> int main(int argc, char *argv[]) { system("cls"); // Write character. wchar_t ch = 0x754C; // U+754C (CJK UNIFIED IDEOGRAPH-754C) DWORD actual = 0; BOOL ret = WriteConsoleW( GetStdHandle(STD_OUTPUT_HANDL...
af256b23-f6a1-4bbf-8e16-4a4830df3bfd
{ "language": "C++" }
```c++ ``` Add convexity test for polygon
```c++ /* * Copyright (C) 2015-2016 Pavel Dolgov * * See the LICENSE file for terms of use. */ #include <bits/stdc++.h> typedef std::pair<int, int> IntPair; typedef std::deque<IntPair> IntPairs; IntPairs vertices; // make vector from two points IntPair makeVector(IntPair p0, IntPair p1) { IntPair vect(p1.fi...
025f20e1-0148-4971-b2c3-c3937b02f204
{ "language": "C++" }
```c++ ``` Add a test for the MultipathAlignmentGraph that just explodes
```c++ /// \file multipath_alignment_graph.cpp /// /// unit tests for the multipath mapper's MultipathAlignmentGraph #include <iostream> #include "json2pb.h" #include "vg.pb.h" #include "../multipath_mapper.hpp" #include "../build_index.hpp" #include "catch.hpp" namespace vg { namespace unittest { TEST_CASE( "Mult...
ec430ab1-ae24-41f0-99b6-5a8358f09c62
{ "language": "C++" }
```c++ // Return multiple values // C++11 #include <tuple> std::tuple<int, bool, float> foo() { return std::make_tuple(128, true, 1.5f); } int main() { int obj1; bool obj2; float obj3; std::tie(obj1, obj2, obj3) = foo(); } // Return multiple values of different types from a function. // // The `foo` function...
```c++ // Return multiple values // C++11 #include <tuple> std::tuple<int, bool, float> foo() { return std::make_tuple(128, true, 1.5f); } int main() { std::tuple<int, bool, float> result = foo(); int value = std::get<0>(result); int obj1; bool obj2; float obj3; std::tie(obj1, obj2, obj3) = foo(); } // Retu...
177a03ea-1578-4822-8a82-f11bc443bdb9
{ "language": "C++" }
```c++ ``` Add a test for a crash with unnamed NamedDecls
```c++ // Makes sure it doesn't crash. // XFAIL: linux // RUN: rm -rf %t // RUN: not %clang_cc1 %s -index-store-path %t/idx -std=c++14 // RUN: c-index-test core -print-record %t/idx | FileCheck %s namespace rdar32474406 { void foo(); typedef void (*Func_t)(); // CHECK: [[@LINE+4]]:1 | type-alias/C | c:record-hash-cr...
74aca3cc-c524-4976-bd74-d374c8f54968
{ "language": "C++" }
```c++ ``` Add solutons that count all permutations.
```c++ #include "boost/unordered_map.hpp" #include <iostream> #include <vector> #include "utils/Timer.hpp" using Bucket = std::vector<int>; void print(Bucket &buckets) { std::for_each(buckets.begin(), buckets.end(), [](auto item) { std::cout << item << " "; }); std::cout << "\n"; } class CountAllPermutation...
e4d448f2-5ab7-4f48-9108-f0a0ac1787d1
{ "language": "C++" }
```c++ ``` Add cpp program which created the LCG64ShiftRandom test data.
```c++ #include <cstdlib> #include <iostream> #include <iomanip> #include <vector> #include <trng/lcg64_shift.hpp> unsigned long long pow(unsigned long long x, unsigned long long n) { unsigned long long result=1; while (n > 0) { if ((n&1) > 0) { result=result*x; } x = x*x; n >>= 1; } return result; } u...
dcb2ef05-12ce-4cb2-9c17-7636c043d61c
{ "language": "C++" }
```c++ ``` Add a test for proper handling of locations in scratch space.
```c++ // RUN: grep -Ev "// *[A-Z-]+:" %s > %t-input.cpp // RUN: clang-tidy %t-input.cpp -checks='-*,google-explicit-constructor,clang-diagnostic-missing-prototypes' -export-fixes=%t.yaml -- -Wmissing-prototypes > %t.msg 2>&1 // RUN: FileCheck -input-file=%t.msg -check-prefix=CHECK-MESSAGES %s -implicit-check-not='{{wa...
1f341d55-c580-46d9-bea0-e20e39cc7a08
{ "language": "C++" }
```c++ ``` Remove Nth Node From End of List
```c++ /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNode* removeNthFromEnd(ListNode* head, int n) { ListNode *fast = head, *slow = head; for(int i=0;fast && ...
d04eaacb-5bf8-4afc-b9ea-06a44f6d0f01
{ "language": "C++" }
```c++ ``` Add stub for the starting point
```c++ // This is the starting point // #include <iostream> int main() { std::string testString("This is a sample string"); std::cout << testString << std::endl; return 0; } ```
b4e01b5b-31f5-4ef6-aa93-23419aa694b8
{ "language": "C++" }
```c++ ``` Add test case verifying PA convection
```c++ #include "mfem.hpp" #include "catch.hpp" #include <fstream> #include <iostream> using namespace mfem; namespace pa_kernels { double test_nl_convection_nd(int dim) { Mesh *mesh; if (dim == 2) { mesh = new Mesh(2, 2, Element::QUADRILATERAL, 0, 1.0, 1.0); } if (dim == 3) { mesh = ne...
6ea01d43-29aa-428f-826f-947c6672f3d1
{ "language": "C++" }
```c++ ``` Add the forgotten file. splice is only a stub.
```c++ //////////////////////////////////////////////////////////////////////////////// /// @brief fundamental types for the optimisation and execution of AQL /// /// @file arangod/Aql/Types.cpp /// /// DISCLAIMER /// /// Copyright 2010-2014 triagens GmbH, Cologne, Germany /// /// Licensed under the Apache License, Ver...
a64a3719-c359-459d-b263-ccafa3b2e47b
{ "language": "C++" }
```c++ #include <iostream> #include <interpreter.h> #include <gui.h> #include <easylogging++.h> #include <SFML/Graphics.hpp> INITIALIZE_EASYLOGGINGPP int main(int argc, char *argv[]) { START_EASYLOGGINGPP(argc, argv); std::cout << "Who am I ? where am I ? Lei" << std::endl; int i = foo(); std::co...
```c++ #include <iostream> #include <interpreter.h> #include <gui.h> #include <easylogging++.h> #include <SFML/Graphics.hpp> INITIALIZE_EASYLOGGINGPP int main(int argc, char *argv[]) { START_EASYLOGGINGPP(argc, argv); int i = foo(); std::cout << str() + 1 << std::endl << i << std::endl; LOG(INFO) << ...
3de473d8-caf0-4968-a24b-af672c83ee82
{ "language": "C++" }
```c++ ``` Add code to insert a node in circular linked list
```c++ #include<iostream> using namespace std; class Node{ public: int data; Node *next; Node(){} Node(int d){ data=d; next=this; } Node *insertNode(Node *head, int d){ Node *np=new Node(d); Node *t=head; if(head==NULL) return np; while(t->next!=head) t=t->next; t->next...
1269484e-6f02-4bb7-9845-6ff7b640b8b5
{ "language": "C++" }
```c++ ``` Add slow solution to `easy1` example problem
```c++ #include <cstdio> volatile int x[40000000]; int main() { //#ifdef EVAL // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); //#endif int N, max; scanf("%d", &N); for (long long i=0; i < 40000000; i++) { x[i] = 1; } for (long long i=0; i < 10000000; i++...
35993e34-1000-4e0d-a790-105739f907ad
{ "language": "C++" }
```c++ ``` Add test for invalid geometry encoding
```c++ #include "catch.hpp" // mapnik vector tile #include "vector_tile_geometry_feature.hpp" #include "vector_tile_layer.hpp" // mapnik #include <mapnik/geometry.hpp> #include <mapnik/feature.hpp> #include <mapnik/feature_factory.hpp> #include <mapnik/util/variant.hpp> // protozero #include <protozero/pbf_writer.hp...
4dab27d2-2328-4ce6-bc5e-343b5181d3d1
{ "language": "C++" }
```c++ ``` Add file with comments to be used in the file
```c++ /* \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ ------------------------------------------------------------------------------- CLASS ------------------------------------------------------------------------------- //////////////////////...
9b098056-8481-46f3-8ffd-97d8ec45dfbc
{ "language": "C++" }
```c++ ``` Add test to ensure that the converting constructor in N4089 is present and working
```c++ //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===---------------------------------...
9940be52-5134-47ee-94e6-68e8a6c68591
{ "language": "C++" }
```c++ ``` Add "class templates SFINAE" sample
```c++ // Conditionally instantiate class templates #include <type_traits> #include <limits> template <typename T, typename Enable = void> class foo; template <typename T> class foo<T, typename std::enable_if<std::is_integral<T>::value>::type> { }; template <typename T> class foo<T, typename std::enable_if<std::is_...
637c2b37-ec86-45b5-97ad-2aa5cc7331ee
{ "language": "C++" }
```c++ ``` Remove duplicates from a sorted array
```c++ #include <iostream> using namespace std; int removeDuplicates(int A[], int n) { if (n == 0) { return 0; } int prev = 0; int length = 1; for (int i = 1; i < n; ++i) { if (A[i] == A[prev]) { continue; } else { ++length; ++prev; ...
53a8c7da-8430-4360-b2be-9c538ee63c8e
{ "language": "C++" }
```c++ ``` Add specific test for P0138R2, direct-list-init of fixed enums from integers, part 3/3.
```c++ //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===---------------------------------...
07976497-8632-4ba3-9a5f-258bc07275cd
{ "language": "C++" }
```c++ ``` Add Matthieu's coroutines test program to the repository.
```c++ #include <iostream> #include <scheduler/coroutine.hh> Coro* mc; Coro* c1, *c2; void start2(void*) { int x=1; int y = 12; std::cerr <<"c2 start " << std::endl; std::cerr <<"c2->c1 " << std::endl; x++; coroutine_switch_to(c2, c1); assert(x==2); x++; std::cerr <<"c2->main " << std::endl; asser...
0f6be85f-693f-4e81-b29f-5bacd88c7dbc
{ "language": "C++" }
```c++ // Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // A basic testrunner that supports JavaScript unittests. // This lives in src/chrome/test/base so that it can include chrome_paths.h // (requi...
```c++ // Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // A basic testrunner that supports JavaScript unittests. // This lives in src/chrome/test/base so that it can include chrome_paths.h // (requi...
f6dcfad7-6af6-4e20-9e40-709ec5d85faa
{ "language": "C++" }
```c++ #include <gmi_mesh.h> #include <gmi_null.h> #include <apfMDS.h> #include <apfMesh2.h> #include <apfConvert.h> #include <apf.h> #include <PCU.h> int main(int argc, char** argv) { assert(argc==3); MPI_Init(&argc,&argv); PCU_Comm_Init(); PCU_Protect(); gmi_register_mesh(); gmi_register_null(); int* c...
```c++ #include <gmi_mesh.h> #include <gmi_null.h> #include <apfMDS.h> #include <apfMesh2.h> #include <apfConvert.h> #include <apf.h> #include <PCU.h> int main(int argc, char** argv) { assert(argc==3); MPI_Init(&argc,&argv); PCU_Comm_Init(); PCU_Protect(); gmi_register_mesh(); gmi_register_null(); int* c...
e3ed0189-7055-4fb2-9e53-80dca48e8485
{ "language": "C++" }
```c++ ``` Add ARMv{6,7}-M implementation of architecture::isInInterruptContext()
```c++ /** * \file * \brief isInInterruptContext() implementation for ARMv6-M and ARMv7-M * * \author Copyright (C) 2016 Kamil Szczygiel http://www.distortec.com http://www.freddiechopin.info * * \par License * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the ...
f9d02f75-3f54-4b08-a403-3fa27495abe4
{ "language": "C++" }
```c++ // Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "webkit/support/test_webplugin_page_delegate.h" #include "third_party/WebKit/Source/Platform/chromium/public/Platform.h" #include "th...
```c++ // Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "webkit/support/test_webplugin_page_delegate.h" #include "third_party/WebKit/Source/Platform/chromium/public/Platform.h" #include "th...
cea76b12-e82c-47c2-9008-845adb407029
{ "language": "C++" }
```c++ ``` Add the solution to "Reverse a doubly linked list".
```c++ #include<iostream> using namespace std; struct Node { int data; Node* next; Node* prev; };/* Reverse a doubly linked list, input list may also be empty Node is defined as struct Node { int data; Node *next; Node *prev } */ Node* Reverse(Node *head) { if (head == NULL || head-...
c0cc5f21-dcdf-4198-8247-d02776f85def
{ "language": "C++" }
```c++ ``` Work on KQUERY on spoj
```c++ #include <cstdio> #include <cstdlib> #include <algorithm> using namespace std; struct query { int l, r; int id; } queries[200000]; int s; int cmp(const void* a, const void* b) { struct query* x = (struct query *) a; struct query* y = (struct query *) b; if ( (x->l) / s == (y->l) / s) { ...
f5c762bf-e9d1-4a7b-bd49-ffe3eb3f3333
{ "language": "C++" }
```c++ ``` Add unit test for LayerRegistry::CreateLayer
```c++ #include <map> #include <string> #include "gtest/gtest.h" #include "caffe/common.hpp" #include "caffe/layer.hpp" #include "caffe/layer_factory.hpp" #include "caffe/test/test_caffe_main.hpp" namespace caffe { template <typename TypeParam> class LayerFactoryTest : public MultiDeviceTest<TypeParam> {}; TYPED_...
af8f451d-627a-4133-a58b-0b8bad660482
{ "language": "C++" }
```c++ ``` Test for my last patch.
```c++ // RUN: clang-cc %s -emit-llvm -o - | FileCheck %s struct basic_ios{~basic_ios(); }; template<typename _CharT> struct basic_istream : virtual public basic_ios { virtual ~basic_istream(){} }; template<typename _CharT> struct basic_iostream : public basic_istream<_CharT> { virtual ~basic_iostream(){} }; ba...
95511bd3-5466-42dd-af35-88755861ed1f
{ "language": "C++" }
```c++ ``` Add a simple cert validation example
```c++ /* * Simple example of a certificate validation * (C) 2010 Jack Lloyd * * Distributed under the terms of the Botan license */ #include <botan/botan.h> #include <botan/x509cert.h> #include <botan/x509stor.h> #include <stdio.h> using namespace Botan; int main() { LibraryInitializer init; X509_Certifi...
96b2a086-c37a-4a36-80d0-4ef502d2fe34
{ "language": "C++" }
```c++ ``` Add a test for cprepp.
```c++ #include "config.h" #include <stdlib.h> #include <string.h> #include <string> #include "pcrepp.hh" int main(int argc, char *argv[]) { pcre_context_static<30> context; int retval = EXIT_SUCCESS; { pcrepp nomatch("nothing-to-match"); pcre_input pi("dummy"); assert(!nomatch.match(context,...
36fd7114-a6ae-4215-a80a-f4aa06dd51d7
{ "language": "C++" }
```c++ ``` Add Solution for Problem 172
```c++ // 172. Factorial Trailing Zeroes /** * Given an integer n, return the number of trailing zeroes in n!. * * Note: Your solution should be in logarithmic time complexity. * * Tags: Math * * Similar Problems: (H) Number of Digit One */ #include "stdafx.h" // in the factorial, there are many 2s, so it is...
af25f5ed-048a-45a4-9f34-83f02c691aca
{ "language": "C++" }
```c++ ``` Add set of test for geospatial
```c++ /* * Copyright (C) 2017 deipi.com LLC and contributors. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to * deal in the Software without restriction, including without limitation th...
8dc6e831-8bed-4665-ac22-9197741dd105
{ "language": "C++" }
```c++ ``` Check if an input string matches the pattern
```c++ #include <iostream> #include <unordered_map> #include <vector> #include <string> #include <ctime> #include <set> #include <utility> #include <algorithm> #include <map> using namespace std; bool isPatternMatched(string& str, string& pattern) { if (pattern.size() < 1) { return true; } vector<vector<map...
3fb00c8e-5ea9-4b6a-927f-4300b73e4d7e
{ "language": "C++" }
```c++ ``` Check whether given tree is sub tree of other.
```c++ #include <stdio.h> typedef struct _NODE { int data; _NODE* left; _NODE* right; } NODE; NODE* newNode(int data) { NODE* node = new NODE(); node->data = data; node->left = nullptr; node->right = nullptr; return node; } bool isIdentical(NODE* T, NODE* S) { if (T == nullptr && S == nullptr) ret...
73e9de61-b734-4dbd-96e8-f60e493b24ae
{ "language": "C++" }
```c++ /* Copyright 2018 The TensorFlow Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable l...
```c++ /* Copyright 2018 The TensorFlow Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable l...
02848f9a-1a0e-4802-adb8-a46566a4d364
{ "language": "C++" }
```c++ ``` Update branch chapter3 and resolve conflicts.
```c++ #include"Game.h" int main(int argc, char **args) { Game *game = new Game(); const char windowTitle[] = "Chapter 1: Setting up SDL"; game->init(windowTitle, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, false); while (game->isRunning()) { game->handleEvents(); game->update(); game->ren...
423b8bc8-fe97-43e0-b8f6-47ca92d58e3c
{ "language": "C++" }
```c++ /* * Copyright 2011 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "GrGLConfig.h" #include "GrGLInterface.h" void GrGLClearErr(const GrGLInterface* gl) { while (GR_GL_NO_ERROR != gl->fGetError()) {} } void GrGLCheckErr...
```c++ /* * Copyright 2011 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "GrGLConfig.h" #include "GrGLInterface.h" void GrGLClearErr(const GrGLInterface* gl) { while (GR_GL_NO_ERROR != gl->fGetError()) {} } void GrGLCheckErr...
933e2174-335d-484c-97f2-7d82ca448302
{ "language": "C++" }
```c++ ``` Add ability to peek registers through USB, beautify code.
```c++ #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <dpcdecl.h> #include <dmgr.h> #include <depp.h> uint8_t peek(int reg) { HIF deviceHandle; int status; char deviceName[32] = "Cr2s2"; uint8_t data; status = DmgrOpen(&deviceHandle, deviceName); if (!status) { printf("Problem opening...
34c3ea63-445f-4f9f-b2e8-79f1ba954ed1
{ "language": "C++" }
```c++ ``` Add a sample C++ file.
```c++ #include <sys/types.h> /* size_t, ssize_t */ #include <stdarg.h> /* va_list */ #include <stddef.h> /* NULL */ #include <stdint.h> /* int64_t */ #include "kcgi.h" #include <iostream> int main(int argc, char *argv[]) { enum kcgi_err er; struct kreq r; const char *const pages[1] = { "index" }; /* Set ...
7ccfe613-ae42-4282-b327-aa1ecaadfd8a
{ "language": "C++" }
```c++ ``` Add tiny test for Error::Message().
```c++ // This file is part of playd. // playd is licensed under the MIT licence: see LICENSE.txt. /** * @file * Tests for command results. */ #include <sstream> #include "catch.hpp" #include "../cmd_result.hpp" #include "dummy_response_sink.hpp" // This file is part of playd. // playd is licensed under the MIT l...
9d77b72d-50ff-412d-8f0e-1ad8ca3c78ae
{ "language": "C++" }
```c++ ``` Add test case to check that implicit downcasting when a Func returns float (32 bits) but the buffer has type float16_t (16 bits) is an error.
```c++ #include "Halide.h" #include <stdio.h> #include <cmath> using namespace Halide; // FIXME: We should use a proper framework for this. See issue #898 void h_assert(bool condition, const char *msg) { if (!condition) { printf("FAIL: %s\n", msg); abort(); } } int main() { Halide::Func f...
8638054c-48d8-425f-ab44-ad4abcd64c4c
{ "language": "C++" }
```c++ ``` Add a very dumb echo repl.
```c++ #include <iostream> namespace { class Repl { std::istream& in_; std::ostream& out_; std::string prompt_ = "mclisp> "; public: Repl(std::istream& in=std::cin, std::ostream& out=std::cout) : in_(in), out_(out) {}; int loop(); }; int Repl::loop() { std::string val; while (val != "quit") {...
34b791b9-b70e-43ad-ba31-9fcf2640eb4d
{ "language": "C++" }
```c++ ``` Add example file to create event dump manually
```c++ #include <stdio.h> #include "../include/AliHLTTPCGeometry.h" //We use this to convert from row number to X struct ClusterData { int fId; int fRow; float fX; float fY; float fZ; float fAmp; }; int main(int argc, char** argv) { for (int iEvent = 0;iEvent < 2;iEvent++) //Multiple events go to multiple file...
a86e496a-3ed4-4c48-8de8-0071e3f301b1
{ "language": "C++" }
```c++ ``` Add unit test for DamageTask
```c++ // Copyright (c) 2018 Chris Ohk, Youngjoong Kim, SeungHyun Jeon // We are making my contributions/submissions to this project solely in our // personal capacity and are not conveying any rights to any intellectual // property of any third parties. #include <Utils/TestUtils.hpp> #include "gtest/gtest.h" #inclu...
9c1bd179-6030-412d-bb60-b88205907445
{ "language": "C++" }
```c++ ``` Add Breadth First Search in Cpp
```c++ #include<bits/stdc++.h> using namespace std; vector<int> BreadthFirstSearch(int vertex,vector<int> adjacent[],int start_vertex,int destination){ queue<int> que; //bfsPath will store the path vector<int> bfsPath; //this array will take care of duplicate traversing bool visited[vertex]; vector<int>...
8e5ae918-90f2-4dc6-94b4-096c9e968b0c
{ "language": "C++" }
```c++ ``` Add a test case for r251476.
```c++ // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -stack-protector 2 -emit-llvm -o - %s | FileCheck %s // Check that function attributes are added to the OpenMP runtime functions. template <class T> struct S { T f; S(T a) : f(a) {} S() : f() {} operator T() { return T(); } ~S() {} }; ...
cbafa4cc-07c5-4171-aafa-56f404f0b04b
{ "language": "C++" }
```c++ ``` Add basic unit test for StreamingDenseFeatures reading
```c++ /* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * Written (W) 2013 Viktor Gal */ #include <shogun/fe...
b73365ed-54b6-466e-af1c-0f1a94240a33
{ "language": "C++" }
```c++ ``` Add example for UpdateFolder operation
```c++ // Copyright 2016 otris software AG // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by appli...
44ca0278-500c-4403-9249-32ba0a91ae1b
{ "language": "C++" }
```c++ ``` Merge point of two lists
```c++ /* * Problem: Find Merge Point of Two Lists * Author: Anirudha Bose <ani07nov@gmail.com> Find merge point of two linked lists Node is defined as struct Node { int data; Node* next; } */ int lengthOfList(Node* head) { int l=0; while(head != NULL) { h...
f0ee790d-5032-4d60-947b-0dac40bcbd8b
{ "language": "C++" }
```c++ ``` Create tests for base cpu
```c++ #include <cassert> #include <gtest/gtest.h> #include <system.h> #include <basecpu.h> #define TEST_CLASS BaseCPUTest class BaseTestCPU : public BaseCPU { public: BaseTestCPU(int maxTicks, const System &sys) : maxTicks(maxTicks), ticks(0), resets(0), BaseCPU(sys) { } void reset() { resets++; } void t...
a341ce88-d6da-4f97-94d5-4a3ad9761a27
{ "language": "C++" }
```c++ // Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "content/renderer/pepper/usb_key_code_conversion.h" #include "base/basictypes.h" #include "third_party/WebKit/public/web/WebInputEven...
```c++ // Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "content/renderer/pepper/usb_key_code_conversion.h" #include "base/basictypes.h" #include "third_party/WebKit/public/web/WebInputEven...
96309205-c0d5-448e-88ea-f9292414309d
{ "language": "C++" }
```c++ ``` Add Solution for 083 Remove Duplicates from Sorted List
```c++ // 83. Remove Duplicates from Sorted List /** * Given a sorted linked list, delete all duplicates such that each element appear only once. * * For example, * Given 1->1->2, return 1->2. * Given 1->1->2->3->3, return 1->2->3. * * Tags: Linked List * * Author: Kuang Qin */ #include <iostream> using ...
93f3173b-08dd-4bce-98ce-ba5d9562ea48
{ "language": "C++" }
```c++ ``` Add capture stack trace benchmark
```c++ // // Created by Ivan Shynkarenka on 15.02.2016. // #include "cppbenchmark.h" #include "debug/stack_trace.h" const uint64_t iterations = 1000000; BENCHMARK("Stack trace") { uint64_t crc = 0; for (uint64_t i = 0; i < iterations; ++i) crc += CppCommon::StackTrace().frames().size(); // Upd...