submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s810517577
p03778
C++
3 1 3
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 3 1 3 | ^
s884291073
p03778
C++
#include <iostream> #include <string> #include <math.h> #include <vector> #include <algorithm> #include <iomanip> #include <set> #include <queue> #define mod 1000000007 #define ten5 100005 #define PI 3.1415926 using namespace std; int main() { //int m,n,o=0,i,j,k; long long int sum=0,sum2=0,n1=0,n2=0,n3; double ans=0.0,half; long long int m,n,o,i,j,k=1,now=1; long long int a,b; //float f,g,h; //char now,pre; string s; cin>>m>>a>>b; if(a<b) { if(a+w<b) cout<<b-a-w; else cout<<0; } else if(a==b) cout<<0; else { if(b+w<a) cout<<a-b-w; else cout<<0; } return 0; }
a.cc: In function 'int main()': a.cc:28:14: error: 'w' was not declared in this scope 28 | if(a+w<b) cout<<b-a-w; | ^ a.cc:34:14: error: 'w' was not declared in this scope 34 | if(b+w<a) cout<<a-b-w; | ^
s318072171
p03778
C++
#include<bits/stdc++.h> using namesapce std; main(){ int h ,a ,b; cin >> h >> a >> b; int ans = h - abs((a - b)); if(ans <= 0){cout << 0;}else{cout << ans;} }
a.cc:4:7: error: expected nested-name-specifier before 'namesapce' 4 | using namesapce std; | ^~~~~~~~~ a.cc:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 6 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:8:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 8 | cin >> h >> a >> b; | ^~~ | std::cin In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146, from a.cc:1: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:10:16: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 10 | if(ans <= 0){cout << 0;}else{cout << ans;} | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ a.cc:10:32: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 10 | if(ans <= 0){cout << 0;}else{cout << ans;} | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~
s303732957
p03778
C++
#include<bits/stdc++.h> using namesapce std; main(){ int h ,a ,b; cin >> h >> a >> b; int ans = h - abs(a - b); if(ans <= 0){cout << 0;}else{cout << ans} }
a.cc:4:7: error: expected nested-name-specifier before 'namesapce' 4 | using namesapce std; | ^~~~~~~~~ a.cc:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 6 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:8:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 8 | cin >> h >> a >> b; | ^~~ | std::cin In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146, from a.cc:1: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:10:16: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 10 | if(ans <= 0){cout << 0;}else{cout << ans} | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ a.cc:10:32: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 10 | if(ans <= 0){cout << 0;}else{cout << ans} | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~
s059763286
p03778
C++
#include<bits/stdc++.h> using namespace std; int main(){ int w, a, b; cin >> w >> a >> b; //The lower rectangle goes before int dif; if(a+w<=b)dif = b-(a+w); else if(b+w<=a)if = a-(b+w); cout << dif << endl; return 0; }
a.cc: In function 'int main()': a.cc:10:27: error: expected '(' before '=' token 10 | else if(b+w<=a)if = a-(b+w); | ^ | (
s258816226
p03778
C++
#include <bits/stdc++.h> using namespace std; #define ALL(a) (a).begin(),(a).end() #define rALL(a) (a).rbegin(),(a).rend() typedef pair<int, int> Pint; typedef pair<int64_t, int64_t> Pll; int main() { int W, a, b; cin >> W >> a >> b; cout << max({0, b - a - W, a - b - W) << endl; }
a.cc: In function 'int main()': a.cc:11:41: error: expected '}' before ')' token 11 | cout << max({0, b - a - W, a - b - W) << endl; | ~ ^
s950916722
p03778
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1LL << 40; #define FOR(i,k,n) for(int i=(k);i<(n);++i) int main(){ int a.b.W;cin >> W >> a >> b; if(b>=a+W) cout << b-a-W << endl; else if(b+W<=a) cout << a-b-W << endl; else cout << 0 << endl; return 0; }
a.cc: In function 'int main()': a.cc:8:10: error: expected initializer before '.' token 8 | int a.b.W;cin >> W >> a >> b; | ^ a.cc:8:22: error: 'W' was not declared in this scope 8 | int a.b.W;cin >> W >> a >> b; | ^ a.cc:8:27: error: 'a' was not declared in this scope 8 | int a.b.W;cin >> W >> a >> b; | ^ a.cc:8:32: error: 'b' was not declared in this scope 8 | int a.b.W;cin >> W >> a >> b; | ^
s033196020
p03778
C++
#include<bits/stdc++.h> using namespace std ; int main(){ int w , a . b ; cout << max(0,max(a,b)-min(a,b)-w) << endl ; }
a.cc: In function 'int main()': a.cc:5:13: error: expected initializer before '.' token 5 | int w , a . b ; | ^ a.cc:6:21: error: 'a' was not declared in this scope 6 | cout << max(0,max(a,b)-min(a,b)-w) << endl ; | ^ a.cc:6:23: error: 'b' was not declared in this scope 6 | cout << max(0,max(a,b)-min(a,b)-w) << endl ; | ^
s060939389
p03778
C++
#include <stdio.h> using namespace std; int main() { long long a,b,w, int result,first,secod; scanf("%ld %ld %ld",&w,&a,&b); first=a+w; secod=b+w; if(a<b) { result=b-(first); printf("%d\n",result); } else if(b<a) { result=a-(secod); printf("%d\n",result); } else if(a<secod) { result=0; printf("%d\n",result); } return 0; }
a.cc: In function 'int main()': a.cc:7:1: error: expected unqualified-id before 'int' 7 | int result,first,secod; | ^~~ a.cc:10:1: error: 'first' was not declared in this scope 10 | first=a+w; | ^~~~~ a.cc:11:1: error: 'secod' was not declared in this scope 11 | secod=b+w; | ^~~~~ a.cc:15:7: error: 'result' was not declared in this scope 15 | result=b-(first); | ^~~~~~ a.cc:20:5: error: 'result' was not declared in this scope 20 | result=a-(secod); | ^~~~~~ a.cc:28:5: error: 'result' was not declared in this scope 28 | result=0; | ^~~~~~
s762356606
p03778
C++
#include <stdio.h> using namespace std; int main() { int a,b,w,result,first,secod; scanf("%d %d %d",&w,&a,&b); first=a+w; secod=b+w; if(a<b) { result=b-(first); printf("%d\n",result); } else if(b<a) { result=a-(secod); printf("%d\n",result); } else if(first<=secod || b<=first)) { result=0; printf("%d\n",result); } return 0; }
a.cc: In function 'int main()': a.cc:24:34: error: expected primary-expression before ')' token 24 | else if(first<=secod || b<=first)) | ^
s775962857
p03778
C++
#include <stdio.h> using namespace std; int main() { int a,b,w,result,first,secod; scanf("%d %d %d",&w,&a,&b); first=a+w; secod=b+w; if(a<b) { result=b-(first); printf("%d\n",result); } else if(b<a) { result=a-(secod); printf("%d\n",result); } else if(first<=secod && b<=first)) { result=0; printf("%d\n",result); } return 0; }
a.cc: In function 'int main()': a.cc:24:34: error: expected primary-expression before ')' token 24 | else if(first<=secod && b<=first)) | ^
s192340989
p03778
C++
#include <stdio.h> using namespace std; int main() { int a,b,w,result,first,secod; scanf("%d %d %d",&w,&a,&b); first=a+w; secod=b+w; if(a>b); a=a+b; b=a-b; a=a-b; else if(b<=first && first<=secod) { result=0; printf("%d\n",result); } else printf("%d\n",b-(first)); return 0; }
a.cc: In function 'int main()': a.cc:21:1: error: 'else' without a previous 'if' 21 | else if(b<=first && first<=secod) | ^~~~
s930354109
p03778
C++
#include <stdio.h> using namespace std; int main() { int a,b,w,result,first,secod; scanf("%d %d %d",&w,&a,&b); first=a+w; secod=b+w; if(a>b) a=a+b; b=a-b; a=a-b; else if(b<=first && first<=secod) { result=0; printf("%d\n",result); } else printf("%d\n",b-(first)); return 0; }
a.cc: In function 'int main()': a.cc:20:1: error: 'else' without a previous 'if' 20 | else if(b<=first && first<=secod) | ^~~~
s171906527
p03778
C++
#include <stdio.h> using namespace std; int main() { int a,b,w,result,first,secod; scanf("%d %d %d",&w,&a,&b); first=a+w; secod=b+w; if(a>b) a=a+b; b=a-b; a=a-b; else if(b<=first && first<=secod) { result=0; printf("%d\n",result); } else result=b-(first); printf("%d\n",result); return 0; }
a.cc: In function 'int main()': a.cc:20:1: error: 'else' without a previous 'if' 20 | else if(b<=first && first<=secod) | ^~~~
s208854082
p03778
C++
#include <stdio.h> using namespace std; int main() { int a,b,w,result,first,secod; scanf("%d %d %d",&w,&a,&b); first=a+w; secod=b+w; if(a>b) a=a+b; b=a-b; a=a-b; else if(secod<=first && first<=secod) { result=0; printf("%d\n",result); } else result=b-(first); printf("%d\n",result); return 0; }
a.cc: In function 'int main()': a.cc:20:1: error: 'else' without a previous 'if' 20 | else if(secod<=first && first<=secod) | ^~~~
s525669979
p03778
C++
#include <stdio.h> using namespace std; int main() { int a,b,w,result,first,secod; scanf("%d %d %d",&w,&a,&b); first=a+w; secod=b+w; if(a<b) a=a+b; b=a-b; a=a-b; else if(secod<=first && first<=secod) { result=0; printf("%d\n",result); } else result=b-first; printf("%d\n",result); return 0; }
a.cc: In function 'int main()': a.cc:17:1: error: 'else' without a previous 'if' 17 | else if(secod<=first | ^~~~
s958395934
p03778
C++
#include<bits/stdc++.h> using namespace std; int main(){ int w, a, b, temp; cin>>w>>a>>b; if(b<a){ temp=a; a=b; b=temp; } temp=b-(a+w); if(temp<0){ temp=0; } cout<<temp<<endl;
a.cc: In function 'int main()': a.cc:16:26: error: expected '}' at end of input 16 | cout<<temp<<endl; | ^ a.cc:4:11: note: to match this '{' 4 | int main(){ | ^
s555234133
p03778
C++
#include <iostream> using namespace std; int main() { int w{}; int a{}; int b{}; cin >> w >> a >> b; int ans{max(a,b)-(min(a,b)+w)} if (ans<=0) cout << 0<< endl; else cout << ans; return 0; }
a.cc: In function 'int main()': a.cc:12:5: error: expected ',' or ';' before 'if' 12 | if (ans<=0) | ^~ a.cc:14:5: error: 'else' without a previous 'if' 14 | else | ^~~~
s319259205
p03778
C++
//////////////////////////////////////////////////////////////// // // YatCoder Library // https://github.com/Reputeless/YatCoder // # define YAT_WITH_FEATURE(X) YAT_WITH_FEATURE_PRIVATE_DEFINITION_##X() # define YAT_WITH_FEATURE_PRIVATE_DEFINITION_INT128() 0 # if defined(__SIZEOF_INT128__) // 組み込み 128-bit 整数型の有無 # undef YAT_WITH_FEATURE_PRIVATE_DEFINITION_INT128 # define YAT_WITH_FEATURE_PRIVATE_DEFINITION_INT128() 1 # endif # if defined(_WIN32) // MSVC での警告抑制 # pragma warning(disable : 26444) # endif //////////////////////////////// // // 1. インクルードされるヘッダ // //////////////////////////////// # include <bits/stdc++.h> namespace yat { //////////////////////////////// // // 2. 数値型 // //////////////////////////////// // 数値型 using int8 = std::int8_t; using int16 = std::int16_t; using int32 = std::int32_t; using int64 = std::int64_t; using uint8 = std::uint8_t; using uint16 = std::uint16_t; using uint32 = std::uint32_t; using uint64 = std::uint64_t; # if YAT_WITH_FEATURE(INT128) using int128 = __int128; using uint128 = unsigned __int128; # endif using float32 = float; using float64 = double; using float128 = long double; //////////////////////////////// // // X. 内部実装 // //////////////////////////////// namespace detail { struct Id_impl{ template <class Type> constexpr decltype(auto) operator()(Type&& x) const noexcept { return std::forward<Type>(x); }}; } constexpr auto Id = detail::Id_impl(); template <class Type = void> inline constexpr auto Plus() noexcept { return std::plus<Type>(); } //////////////////////////////// // // 3. 文字列型 // //////////////////////////////// class String; class StringView { public: using traits_type = std::char_traits<char>; using value_type = char; using pointer = const char*; using const_pointer = const char*; using reference = const char&; using const_reference = const char&; using const_iterator = pointer; using iterator = const_iterator; using const_reverse_iterator = std::reverse_iterator<const_iterator>; using reverse_iterator = const_reverse_iterator; using size_type = size_t; using difference_type = ptrdiff_t; private: const char* m_ptr = nullptr; size_t m_length = 0; public: static constexpr size_type npos = size_type{ static_cast<size_type>(-1) }; StringView() = default; StringView(const StringView&) = default; StringView(StringView&&) = default; StringView(const std::string& str) noexcept : m_ptr(str.data()), m_length(str.length()) {} constexpr StringView(const value_type* text, size_type count) : m_ptr(text), m_length(count) {} constexpr StringView(const value_type* text) : m_ptr(text), m_length(text ? traits_type::length(text) : 0) {} StringView& operator =(const StringView&) = default; StringView& operator =(StringView&&) = default; constexpr const_iterator begin() const noexcept { return m_ptr; } constexpr const_iterator end() const noexcept { return m_ptr + m_length; } constexpr const_iterator cbegin() const noexcept { return m_ptr; } constexpr const_iterator cend() const noexcept { return m_ptr + m_length; } const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } constexpr const_reference operator[](size_type offset) const { return m_ptr[offset]; } const_reference at(size_t offset) const { if (offset >= m_length) throw std::out_of_range("StringView::at"); return m_ptr[offset]; } constexpr const_reference front() const { return m_ptr[0]; } constexpr const_reference back() const { return m_ptr[m_length - 1]; } constexpr const_pointer data() const noexcept { return m_ptr; } constexpr size_type size() const noexcept { return m_length; } constexpr size_type size_bytes() const noexcept { return m_length * sizeof(value_type); } constexpr size_type length() const noexcept { return m_length; } constexpr size_type max_size() const noexcept { return m_length; } constexpr bool empty() const noexcept { return m_length == 0; } constexpr bool isEmpty() const noexcept { return m_length == 0; } constexpr explicit operator bool() const noexcept { return (!isEmpty()); } constexpr void remove_prefix(size_type n) noexcept { if (n > m_length) n = m_length; m_ptr += n; m_length -= n; } constexpr void remove_suffix(size_type n) noexcept { if (n > m_length) n = m_length; m_length -= n; } void swap(StringView& other) noexcept { std::swap(m_length, other.m_length); std::swap(m_ptr, other.m_ptr); } constexpr void clear() noexcept { *this = StringView(); } size_type copy(value_type* dst, const size_type n, const size_type pos = 0) const { if (pos > m_length) throw std::out_of_range("StringView::copy"); const size_type rlen = std::min(n, m_length - pos); for (auto it = m_ptr + pos, end = it + rlen; it != end;) *dst++ = *it++; return rlen; } StringView substr(const size_type pos = 0, const size_type n = npos) const { if (pos > size()) throw std::out_of_range("StringView::substr"); return StringView(m_ptr + pos, std::min(n, m_length - pos)); } int compare(StringView str) const { const int cmp = traits_type::compare(m_ptr, str.m_ptr, std::min(m_length, str.m_length)); return cmp != 0 ? cmp : (m_length == str.m_length ? 0 : m_length < str.m_length ? -1 : 1); } }; inline bool operator ==(const StringView a, const StringView b) noexcept { return a.compare(b) == 0; } inline bool operator !=(const StringView a, const StringView b) noexcept { return !(a == b); } inline bool operator <(const StringView a, const StringView b) noexcept { return a.compare(b) < 0; } inline bool operator >(const StringView a, const StringView b) noexcept { return a.compare(b) > 0; } inline bool operator <=(const StringView a, const StringView b) noexcept { return a.compare(b) <= 0; } inline bool operator >=(const StringView a, const StringView b) noexcept { return a.compare(b) >= 0; } // 文字列型 class String { public: using string_type = std::string; using traits_type = typename string_type::traits_type; using allocator_type = typename string_type::allocator_type; using value_type = typename string_type::value_type; using size_type = typename string_type::size_type; using difference_type = typename string_type::difference_type; using pointer = typename string_type::pointer; using const_pointer = typename string_type::const_pointer; using reference = typename string_type::reference; using const_reference = typename string_type::const_reference; using iterator = typename string_type::iterator; using const_iterator = typename string_type::const_iterator; using reverse_iterator = typename string_type::reverse_iterator; using const_reverse_iterator = typename string_type::const_reverse_iterator; private: string_type m_string; public: template <class StringViewIsh> using IsStringViewIsh = std::enable_if_t< std::is_convertible<const StringViewIsh&, StringView>::value && !std::is_convertible<const StringViewIsh&, const char*>::value>; static constexpr size_type npos = size_type{ static_cast<size_type>(-1) }; String() = default; String(const String& text) = default; String(String&& text) = default; template <class StringViewIsh, class = IsStringViewIsh<StringViewIsh>> explicit String(const StringViewIsh& viewish) : m_string(viewish.data(), viewish.size()) {} operator StringView() const noexcept { return StringView(m_string.data(), m_string.size()); } String(const string_type& text) : m_string(text) {} String(string_type&& text) noexcept : m_string(std::move(text)) {} String(const String& text, size_type pos) : m_string(text.m_string, pos) {} String(const String& text, size_type pos, size_type count) : m_string(text.m_string, pos, count) {} String(const value_type* text) : m_string(text) {} String(const value_type* text, size_type count) : m_string(text, count) {} String(std::initializer_list<value_type> ilist) : m_string(ilist) {} String(size_t count, value_type ch) : m_string(count, ch) {} String& operator =(const String& text) = default; String& operator =(String&& text) = default; String& operator =(const string_type& text) { return assign(text); } String& operator =(string_type&& text) noexcept { return assign(std::move(text)); } String& operator =(const value_type* text) { return assign(text); } String& operator =(std::initializer_list<value_type> ilist) { return assign(ilist); } template <class StringViewIsh, class = IsStringViewIsh<StringViewIsh>> String& operator =(const StringViewIsh& viewish) { return assign(viewish); } String& assign(const String& text) { m_string.assign(text.m_string); return *this; } String& assign(String&& text) { m_string.assign(std::move(text.m_string)); return *this; } String& assign(const string_type& text) { m_string.assign(text); return *this; } String& assign(string_type&& text) { m_string.assign(std::move(text)); return *this; } String& assign(const value_type* text) { m_string.assign(text); return *this; } String& assign(std::initializer_list<value_type> ilist) { m_string.assign(ilist); return *this; } template <class StringViewIsh, class = IsStringViewIsh<StringViewIsh>> String& assign(const StringViewIsh& viewish) { m_string.assign(viewish.data(), viewish.size()); return *this; } template <class Iterator> String& assign(Iterator first, Iterator last) { m_string.assign(first, last); return *this; } String& operator +=(const String& text) { return append(text); } String& operator +=(const string_type& text) { return append(text); } String& operator +=(value_type ch) { return append(ch); } String& operator +=(const value_type* text) { return append(text); } String& operator +=(std::initializer_list<value_type> ilist) { return append(ilist); } String& operator <<(const value_type ch) { return append(ch); } template <class StringViewIsh, class = IsStringViewIsh<StringViewIsh>> String& operator +=(const StringViewIsh& viewish) { return append(viewish); } String& append(const String& text) { m_string.append(text.m_string); return *this; } String& append(const string_type& text) { m_string.append(text); return *this; } String& append(value_type ch) { m_string.push_back(ch); return *this; } String& append(const value_type* text) { m_string.append(text); return *this; } String& append(const value_type* text, size_t count) { m_string.append(text, count); return *this; } String& append(std::initializer_list<value_type> ilist) { m_string.append(ilist); return *this; } String& append(size_t count, value_type ch) { m_string.append(count, ch); return *this; } template <class StringViewIsh, class = IsStringViewIsh<StringViewIsh>> String& append(const StringViewIsh& viewish) { m_string.append(viewish.data(), viewish.size()); return *this; } template <class Iterator> String& append(Iterator first, Iterator last) { m_string.append(first, last); return *this; } String& insert(size_t offset, const String& str) { m_string.insert(offset, str.m_string); return *this; } String& insert(size_t offset, std::initializer_list<value_type> ilist) { m_string.insert(offset, ilist); return *this; } String& insert(size_t offset, const value_type* str) { m_string.insert(offset, str); return *this; } template <class StringViewIsh, class = String::IsStringViewIsh<StringViewIsh>> String& insert(size_t offset, const StringViewIsh& text) { m_string.insert(offset, text.data(), text.size()); return *this; } String& insert(const size_t offset, size_t count, value_type ch) { m_string.insert(offset, count, ch); return *this; } iterator insert(const_iterator where, value_type ch) { return insert(where, 1, ch); } iterator insert(const_iterator where, size_t count, value_type ch) { const size_type off = std::distance(cbegin(), where); m_string.insert(off, count, ch); return begin() + static_cast<difference_type>(off); } template <class Iterator> iterator insert(const_iterator where, Iterator first, Iterator last) { return m_string.insert(where, first, last); } template <class Iterator> String& insert(const_iterator first1, const_iterator last1, Iterator first2, Iterator last2) { m_string.insert(first1, last1, first2, last2); return *this; } String& erase(size_t offset, size_t count = npos) { m_string.erase(offset, count); return *this; } iterator erase(const_iterator where) { return erase(where, where + 1); } iterator erase(const_iterator first, const_iterator last) { const size_type off = std::distance(cbegin(), first); erase(off, static_cast<size_type>(last - first)); return begin() + static_cast<difference_type>(off); } void clear() noexcept { m_string.clear(); } iterator begin() noexcept { return m_string.begin(); } const_iterator begin() const noexcept { return m_string.begin(); } const_iterator cbegin() const noexcept { return m_string.cbegin(); } iterator end() noexcept { return m_string.end(); } const_iterator end() const noexcept { return m_string.end(); } const_iterator cend() const noexcept { return m_string.cend(); } reverse_iterator rbegin() noexcept { return m_string.rbegin(); } const_reverse_iterator rbegin() const noexcept { return m_string.rbegin(); } const_reverse_iterator crbegin() const noexcept { return m_string.crbegin(); } reverse_iterator rend() noexcept { return m_string.rend(); } const_reverse_iterator rend() const noexcept { return m_string.rend(); } const_reverse_iterator crend() const noexcept { return m_string.crend(); } void shrink_to_fit() { m_string.shrink_to_fit(); } void release() { clear(); shrink_to_fit(); } value_type& at(size_t offset)& { return m_string.at(offset); } const value_type& at(size_t offset) const& { return m_string.at(offset); } value_type at(size_t offset)&& { return m_string.at(offset); } value_type& operator[](size_t offset)& { return m_string[offset]; } const value_type& operator[](size_t offset) const& { return m_string[offset]; } value_type operator[](size_t offset)&& { return std::move(m_string[offset]); } void push_front(value_type ch) { insert(begin(), ch); } void push_back(value_type ch) { m_string.push_back(ch); } void pop_front() { m_string.erase(m_string.begin()); } void pop_back() { m_string.pop_back(); } value_type& front() { return m_string.front(); } const value_type& front() const { return m_string.front(); } value_type& back() { return m_string.back(); } const value_type& back() const { return m_string.back(); } const value_type* c_str() const noexcept { return m_string.c_str(); } const value_type* data() const noexcept { return m_string.data(); } value_type* data() noexcept { return &m_string[0]; } string_type& str() { return m_string; } const string_type& str() const noexcept { return m_string; } size_t length() const noexcept { return m_string.length(); } size_t size() const noexcept { return m_string.size(); } size_t size_bytes() const noexcept { return m_string.size() * sizeof(value_type); } bool empty() const noexcept { return m_string.empty(); } bool isEmpty() const noexcept { return m_string.empty(); } explicit operator bool() const noexcept { return !m_string.empty(); } size_t maxSize() const noexcept { return m_string.max_size(); } size_t capacity() const noexcept { return m_string.capacity(); } void resize(size_t newSize) { m_string.resize(newSize); } void resize(size_t newSize, value_type ch) { m_string.resize(newSize, ch); } void reserve(size_t newCapacity) { m_string.reserve(newCapacity); } void swap(String& text) noexcept { m_string.swap(text.m_string); } String substr(size_t offset = 0, size_t count = npos) const { return m_string.substr(offset, count); } //size_t indexOf(const String& text, size_t offset = 0) const noexcept; //size_t indexOf(const value_type* text, size_t offset = 0) const; //size_t indexOf(value_type ch, size_t offset = 0) const; //size_t indexOfNot(value_type ch, size_t offset = 0) const; //size_t lastIndexOf(const String& text, size_t offset = npos) const; //size_t lastIndexOf(const value_type* text, size_t offset = npos) const; //size_t lastIndexOf(value_type ch, size_t offset = npos) const; //size_t lastIndexNotOf(value_type ch, size_t offset = npos) const; //size_t indexOfAny(const String& anyof, size_t offset = 0) const; //size_t indexOfAny(const value_type* anyof, size_t offset = 0) const; //size_t lastIndexOfAny(const String& anyof, size_t offset = npos) const; //size_t lastIndexOfAny(const value_type* anyof, size_t offset = npos) const; //size_t indexNotOfAny(const String& anyof, size_t offset = 0) const; //size_t indexNotOfAny(const value_type* anyof, size_t offset = 0) const; //size_t lastIndexNotOfAny(const String& anyof, size_t offset = npos) const; //size_t lastIndexNotOfAny(const value_type* anyof, size_t offset = npos) const; int32 compare(const String& text) const noexcept { return m_string.compare(text.m_string); } int32 compare(const value_type* text) const { return m_string.compare(text); } bool operator ==(const String& text) const { return m_string == text.m_string; } bool operator !=(const String& text) const { return m_string != text.m_string; } bool operator <(const String& text) const { return m_string < text.m_string; } bool operator >(const String& text) const { return m_string > text.m_string; } bool operator <=(const String& text) const { return m_string <= text.m_string; } bool operator >=(const String& text) const { return m_string >= text.m_string; } size_t count(value_type ch) const noexcept { return std::count(begin(), end(), ch); } size_t count(StringView view) const { size_t count = 0; for (auto it = begin();; ++it, ++count) { it = std::search(it, end(), view.begin(), view.end()); if (it == end()) return count; } } }; template <class StringViewIsh, class = String::IsStringViewIsh<StringViewIsh>> inline String operator +(const String::value_type a, const StringViewIsh& b) { String result; result.reserve(1 + b.size()); result.append(a); result.append(b); return result; } String operator +(const String::value_type a, const String& b) { String result; result.reserve(1 + b.size()); result.append(a); result.append(b); return result; } String operator +(const String::value_type a, String&& b) { b.push_front(a); return std::move(b); } template <class StringViewIsh, class = String::IsStringViewIsh<StringViewIsh>> inline String operator +(const String::value_type* a, const StringViewIsh& b) { const size_t len = std::char_traits<String::value_type>::length(a); String result; result.reserve(len + b.size()); result.append(a, len); result.append(b); return result; } String operator +(const String::value_type* a, const String& b) { const size_t len = std::char_traits<String::value_type>::length(a); String result; result.reserve(len + b.size()); result.append(a, len); result.append(b); return result; } String operator +(const String::value_type* a, String&& b) { return std::move(b.insert(0, a)); } template <class StringViewIsh, class = String::IsStringViewIsh<StringViewIsh>> inline String operator +(const StringViewIsh& a, const String::value_type b) { String result; result.reserve(a.size() + 1); result.append(a); result.append(b); return result; } template <class StringViewIsh, class = String::IsStringViewIsh<StringViewIsh>> inline String operator +(const StringViewIsh& a, const String::value_type* b) { const size_t len = std::char_traits<String::value_type>::length(b); String result; result.reserve(a.size() + len); result.append(a); result.append(b, len); return result; } template <class StringViewIshT, class StringViewIshU, class = String::IsStringViewIsh<StringViewIshT>, class = String::IsStringViewIsh<StringViewIshU>> inline String operator +(const StringViewIshT& a, const StringViewIshU& b) { String result; result.reserve(a.size() + b.size()); result.append(a); result.append(b); return result; } template <class StringViewIsh, class = String::IsStringViewIsh<StringViewIsh>> inline String operator +(const StringViewIsh& a, const String& b) { String result; result.reserve(a.size() + b.size()); result.append(a); result.append(b); return result; } template <class StringViewIsh, class = String::IsStringViewIsh<StringViewIsh>> inline String operator +(const StringViewIsh& a, String&& b) { return std::move(b.insert(0, a)); } String operator +(const String& a, const String::value_type b) { String result; result.reserve(a.size() + 1); result.append(a); result.append(b); return result; } String operator +(const String& a, const String::value_type* b) { const size_t len = std::char_traits<String::value_type>::length(b); String result; result.reserve(a.size() + len); result.append(a); result.append(b, len); return result; } template <class StringViewIsh, class = String::IsStringViewIsh<StringViewIsh>> inline String operator +(const String& a, const StringViewIsh& b) { String result; result.reserve(a.size() + b.size()); result.append(a); result.append(b); return result; } String operator +(const String& a, const String& b) { String result; result.reserve(a.size() + b.size()); result.append(a); result.append(b); return result; } String operator +(const String& a, String&& b) { return std::move(b.insert(0, a)); } String operator +(String&& a, const String::value_type b) { return std::move(a << b); } String operator +(String&& a, const String::value_type* b) { return std::move(a.append(b)); } template <class StringViewIsh, class = String::IsStringViewIsh<StringViewIsh>> inline String operator +(String&& a, const StringViewIsh& b) { return std::move(a.append(b)); } String operator +(String&& a, const String& b) { return std::move(a.append(b)); } String operator +(String&& a, String&& b) { if (b.size() <= a.capacity() - a.size() || b.capacity() - b.size() < a.size()) return std::move(a.append(b)); else return std::move(b.insert(0, a)); } bool operator ==(const String::value_type* a, const String& b) { return a == b.str(); } bool operator ==(const String& a, const String::value_type* b) { return a.str() == b; } bool operator !=(const String::value_type* a, const String& b) { return a != b.str(); } bool operator !=(const String& a, const String::value_type* b) { return a.str() != b; } bool operator <(const String::value_type* a, const String& b) { return a < b.str(); } bool operator <(const String& a, const String::value_type* b) { return a.str() < b; } bool operator >(const String::value_type* a, const String& b) { return a > b.str(); } bool operator >(const String& a, const String::value_type* b) { return a.str() > b; } bool operator <=(const String::value_type* a, const String& b) { return a <= b.str(); } bool operator <=(const String& a, const String::value_type* b) { return a.str() <= b; } bool operator >=(const String::value_type* a, const String& b) { return a >= b.str(); } bool operator >=(const String& a, const String::value_type* b) { return a.str() >= b; } std::ostream& operator <<(std::ostream& os, const String& x) { return os << x.str(); } std::istream& operator >>(std::istream& is, String& x) { return is >> x.str(); } //////////////////////////////// // // 4. 動的配列型 // //////////////////////////////// // 動的配列型 template <class Type, class Allocator = std::allocator<Type>> class Array : protected std::vector<Type, Allocator> { private: using base_type = std::vector<Type, Allocator>; public: using typename base_type::value_type; using typename base_type::pointer; using typename base_type::const_pointer; using typename base_type::reference; using typename base_type::const_reference; using typename base_type::iterator; using typename base_type::const_iterator; using typename base_type::reverse_iterator; using typename base_type::const_reverse_iterator; using typename base_type::size_type; using typename base_type::difference_type; using typename base_type::allocator_type; using base_type::vector; using base_type::operator=; using base_type::assign; using base_type::get_allocator; using base_type::front; using base_type::back; using base_type::data; using base_type::begin; using base_type::cbegin; using base_type::end; using base_type::cend; using base_type::rbegin; using base_type::crbegin; using base_type::rend; using base_type::crend; using base_type::empty; using base_type::size; using base_type::max_size; using base_type::reserve; using base_type::capacity; using base_type::shrink_to_fit; using base_type::clear; using base_type::insert; using base_type::emplace; using base_type::erase; using base_type::push_back; using base_type::emplace_back; using base_type::pop_back; using base_type::resize; Array(): base_type() {} Array(const Array&) = default; Array(Array &&) = default; Array& operator =(const Array&) = default; Array& operator =(Array &&) = default; void swap(Array& other) noexcept { base_type::swap(other); } bool isEmpty() const noexcept { return empty(); } explicit operator bool() const noexcept { return !empty(); } void release() { clear(); shrink_to_fit(); } size_t size_bytes() const noexcept { static_assert(std::is_trivially_copyable<value_type>::value, "Array::size_bytes() value_type must be trivially copyable."); return size() * sizeof(value_type); } void push_front(const value_type& value) { insert(begin(), value); } void push_front(value_type&& value) { insert(begin(), std::move(value)); } void pop_front() { erase(begin()); } const value_type& operator[](size_t index) const& { return base_type::operator[](index); } value_type& operator[](size_t index)& { return base_type::operator[](index); } value_type operator[](size_t index)&& { return std::move(base_type::operator[](index)); } const value_type& at(size_t index) const& { return base_type::at(index); } value_type& at(size_t index)& { return base_type::at(index); } value_type at(size_t index)&& { return std::move(base_type::at(index)); } Array& operator <<(const value_type& value) { push_back(value); return *this; } Array& operator <<(value_type&& value) { push_back(std::forward<value_type>(value)); return *this; } template <class Fty = decltype(Id), std::enable_if_t<std::is_convertible<std::result_of_t<Fty(Type)>, bool>::value>* = nullptr> bool all(Fty f = Id) const { return std::all_of(begin(), end(), f); } template <class Fty = decltype(Id), std::enable_if_t<std::is_convertible<std::result_of_t<Fty(Type)>, bool>::value> * = nullptr> bool any(Fty f = Id) const { return std::any_of(begin(), end(), f); } Array& append(const Array& other_array) { insert(end(), other_array.begin(), other_array.end()); return *this; } Array<Array<value_type>> chunk(const size_t n) const { Array<Array<value_type>> result; if (n == 0) { return result; } for (size_t i = 0; i < (size() + n - 1) / n; ++i) { result.push_back(slice(i * n, n)); } return result; } size_t count(const value_type& value) const { return std::count(begin(), end(), value); } template <class Fty> size_t count_if(Fty f) const { return std::count_if(begin(), end(), f); } Array& drop(size_t n) { erase(begin(), begin() + std::min(n, size())); return *this; } Array dropped(const size_t n) const { if (n >= size()) return Array(); return Array(begin() + n, end()); } template <class Fty> Array dropped_while(Fty f) const { return Array(std::find_if_not(begin(), end(), f), end()); } template <class Fty> Array& each(Fty f) { std::for_each(begin(), end(), f); return *this; } template <class Fty> const Array& each(Fty f) const { std::for_each(begin(), end(), f); return *this; } template <class Fty> Array& each_index(Fty f) { size_t i = 0; for (auto& v : *this) f(i++, v); return *this; } template <class Fty> const Array& each_index(Fty f) const { size_t i = 0; for (const auto& v : *this) f(i++, v); return *this; } const value_type& fetch(const size_t index, const value_type& defaultValue) const { if (index >= size()) return defaultValue; return operator[](index); } Array& fill(const value_type& value) { std::fill(begin(), end(), value); return *this; } template <class Fty> Array filter(Fty f) const { Array new_array; for (const auto& v : *this) { if (f(v)) { new_array.push_back(v); } } return new_array; } Array<Array<value_type>> in_groups(const size_t group) const { Array<Array<value_type>> result; if (group == 0) { return result; } const size_t div = size() / group; const size_t mod = size() % group; size_t index = 0; for (size_t i = 0; i < group; ++i) { const size_t length = div + (mod > 0 && mod > i); result.push_back(slice(index, length)); index += length; } return result; } bool includes(const value_type& value) const { for (const auto& v : *this) { if (v == value) { return true; } } return false; } template <class Fty> bool includes_if(Fty f) const { return any(f); } template <class T = Type> bool isSorted() const { const size_t size_ = size(); if (size_ <= 1) { return true; } const value_type* p = data(); for (size_t i = 0; i < size_ - 1; ++i) { if (p[i] > p[i + 1]) { return false; } } return true; } String join(StringView sep = ", ", StringView begin = "{", StringView end = "}") const { String s; s.append(begin); bool isFirst = true; for (const auto& v : *this) { if (isFirst) { isFirst = false; } else { s.append(sep); } s.append(Format(v)); } s.append(end); return s; } template <class Fty> Array& keep_if(Fty f) { erase(std::remove_if(begin(), end(), std::not1(f)), end()); return *this; } template <class Fty> auto map(Fty f) const { Array<std::decay_t<std::result_of_t<Fty(Type)>>> new_array; new_array.reserve(size()); for (const auto& v : *this) { new_array.push_back(f(v)); } return new_array; } template <class Fty = decltype(Id), std::enable_if_t<std::is_convertible<std::result_of_t<Fty(Type)>, bool>::value> * = nullptr> bool none(Fty f = Id) const { return std::none_of(begin(), end(), f); } template <class Fty, class R = std::decay_t<std::result_of_t<Fty(Type, Type)>>> auto reduce(Fty f, R init) const { auto value = init; for (const auto& v : *this) { value = f(value, v); } return value; } template <class Fty> auto reduce1(Fty f) const { if (empty()) { throw std::out_of_range("Array::reduce1() reduce from empty Array"); } auto it = begin(); const auto itEnd = end(); std::result_of_t<Fty(value_type, value_type)> value = *it++; while (it != itEnd) { value = f(value, *it++); } return value; } Array& remove(const value_type& value) { erase(std::remove(begin(), end(), value), end()); return *this; } Array removed(const value_type& value) const& { Array new_array; for (const auto& v : *this) { if (v != value) { new_array.push_back(v); } } return new_array; } Array removed(const value_type& value)&& { erase(std::remove(begin(), end(), value), end()); shrink_to_fit(); return std::move(*this); } Array& remove_at(const size_t index) { if (index >= size()) { throw std::out_of_range("Array::remove_at() index out of range"); } erase(begin() + index); return *this; } Array removed_at(const size_t index) const { if (index >= size()) { throw std::out_of_range("Array::removed_at() index out of range"); } Array new_array; new_array.reserve(size() - 1); new_array.insert(new_array.end(), begin(), begin() + index); new_array.insert(new_array.end(), begin() + index + 1, end()); return new_array; } template <class Fty> Array& remove_if(Fty f) { erase(std::remove_if(begin(), end(), f), end()); return *this; } template <class Fty> Array removed_if(Fty f) const& { Array new_array; for (const auto& v : *this) { if (!f(v)) { new_array.push_back(v); } } return new_array; } template <class Fty> Array removed_if(Fty f)&& { erase(std::remove_if(begin(), end(), f), end()); shrink_to_fit(); return std::move(*this); } Array& replace(const value_type& oldValue, const value_type& newValue) { for (auto& v : *this) { if (v == oldValue) { v = newValue; } } return *this; } Array replaced(const value_type& oldValue, const value_type& newValue) const& { Array new_array; new_array.reserve(size()); for (const auto& v : *this) { if (v == oldValue) { new_array.push_back(newValue); } else { new_array.push_back(v); } } return new_array; } Array replaced(const value_type& oldValue, const value_type& newValue)&& { replace(oldValue, newValue); return std::move(*this); } template <class Fty> Array& replace_if(Fty f, const value_type& newValue) { for (auto& v : *this) { if (f(v)) { v = newValue; } } return *this; } template <class Fty> Array replaced_if(Fty f, const value_type& newValue) const& { Array new_array; new_array.reserve(size()); for (const auto& v : *this) { if (f(v)) { new_array.push_back(newValue); } else { new_array.push_back(v); } } return new_array; } template <class Fty> Array replaced_if(Fty f, const value_type& newValue)&& { replace_if(f, newValue); return std::move(*this); } Array& reverse() { std::reverse(begin(), end()); return *this; } Array reversed() const& { return Array(rbegin(), rend()); } Array reversed()&& { reverse(); return std::move(*this); } template <class Fty> Array& reverse_each(Fty f) { for (auto it = rbegin(); it != rend(); ++it) { f(*it); } return *this; } template <class Fty> const Array& reverse_each(Fty f) const { for (auto it = rbegin(); it != rend(); ++it) { f(*it); } return *this; } Array& rotate(std::ptrdiff_t count = 1) { if (empty()) { ; } else if (count > 0) // rotation to the left { if (static_cast<size_t>(count) > size()) { count %= size(); } std::rotate(begin(), begin() + count, end()); } else if (count < 0) // rotation to the right { count = -count; if (static_cast<size_t>(count) > size()) { count %= size(); } std::rotate(rbegin(), rbegin() + count, rend()); } return *this; } Array rotated(const std::ptrdiff_t count = 1) const& { return Array(*this).rotate(count); } Array rotated(const std::ptrdiff_t count = 1)&& { rotate(count); return std::move(*this); } template <class T = Type> Array& rsort() { std::sort(begin(), end(), std::greater<>()); return *this; } template <class T = Type> Array rsorted() const& { return Array(*this).rsort(); } template <class T = Type> Array rsorted()&& { rsort(); return std::move(*this); } Array slice(const size_t index) const { if (index >= size()) { return Array(); } return Array(begin() + index, end()); } Array slice(const size_t index, const size_t length) const { if (index >= size()) { return Array(); } return Array(begin() + index, begin() + std::min(index + length, size())); } template <class T = Type> Array& sort() { std::sort(begin(), end()); return *this; } template <class T = Type> Array& stable_sort() { std::stable_sort(begin(), end()); return *this; } template <class Fty> Array& sort_by(Fty f) { std::sort(begin(), end(), f); return *this; } template <class Fty> Array& stable_sort_by(Fty f) { std::stable_sort(begin(), end(), f); return *this; } template <class T = Type> Array sorted() const& { return Array(*this).sort(); } template <class T = Type> Array stable_sorted() const& { return Array(*this).stable_sort(); } template <class T = Type> Array sorted()&& { sort(); return std::move(*this); } template <class T = Type> Array stable_sorted()&& { stable_sort(); return std::move(*this); } template <class Fty> Array sorted_by(Fty f) const& { return Array(*this).sort_by(f); } template <class Fty> Array stable_sorted_by(Fty f) const& { return Array(*this).stable_sort_by(f); } template <class Fty> Array sorted_by(Fty f)&& { sort_by(f); return std::move(*this); } template <class Fty> Array stable_sorted_by(Fty f)&& { stable_sort_by(f); return std::move(*this); } template <class T = Type> auto sum() const { decltype(std::declval<T>() + std::declval<T>()) result{}; for (const auto& v : *this) { result += v; } return result; } //template <class T = Type, std::enable_if_t<Meta::HasPlus_v<T> && !Meta::HasPlusAssign_v<T>> * = nullptr> //auto sum() const //{ // decltype(std::declval<T>() + std::declval<T>()) result{}; // for (const auto& v : *this) // { // result = result + v; // } // return result; //} template <class T = Type, std::enable_if_t<std::is_floating_point<T>::value> * = nullptr> auto sumF() const& { T s = 0.0; T err = 0.0; for (const auto& v : *this) { const T y = v - err; const T t = s + y; err = (t - s) - y; s = t; } return static_cast<T>(s); } template <class T = Type, std::enable_if_t<!std::is_floating_point<T>::value> * = nullptr> auto sumF() const& = delete; Array take(const size_t n) const { return Array(begin(), begin() + std::min(n, size())); } template <class Fty> Array take_while(Fty f) const { return Array(begin(), std::find_if_not(begin(), end(), f)); } Array& unique() { sort(); erase(std::unique(begin(), end()), end()); return *this; } Array uniqued() const& { return Array(*this).unique(); } Array uniqued()&& { sort(); erase(std::unique(begin(), end()), end()); shrink_to_fit(); return std::move(*this); } Array values_at(std::initializer_list<size_t> indices) const { Array new_array; new_array.reserve(indices.size()); for (auto index : indices) { if (index >= size()) { throw std::out_of_range("Array::values_at() index out of range"); } new_array.push_back(operator[](index)); } return new_array; } }; template <class Type, class Allocator> inline bool operator ==(const Array<Type, Allocator>& a, const Array<Type, Allocator>& b) { return ((a.size() == b.size()) && std::equal(a.begin(), a.end(), b.begin())); } template <class Type, class Allocator> inline bool operator !=(const Array<Type, Allocator>& a, const Array<Type, Allocator>& b) { return ((a.size() != b.size()) || !std::equal(a.begin(), a.end(), b.begin())); } template <class Type, class Allocator> inline bool operator <(const Array<Type, Allocator>& a, const Array<Type, Allocator>& b) { return std::lexicographical_compare(a.begin(), a.end(), b.begin(), b.end()); } template <class Type, class Allocator> inline bool operator >(const Array<Type, Allocator>& a, const Array<Type, Allocator>& b) { return b < a; } template <class Type, class Allocator> inline bool operator <=(const Array<Type, Allocator>& a, const Array<Type, Allocator>& b) { return !(b < a); } template <class Type, class Allocator> inline bool operator >=(const Array<Type, Allocator>& a, const Array<Type, Allocator>& b) { return !(a < b); } //////////////////////////////// // // 5. 文字列フォーマット // //////////////////////////////// // 文字列フォーマット用内部データ struct FormatData { String string; // 文字列バッファ struct DecimalPlaces { explicit constexpr DecimalPlaces(int32 v = 10) : value(v) {} int32 value; // 小数点以下の桁数 } decimalPlaces; }; // 小数点数以下の桁数指定 // * Format や Print に渡す inline constexpr FormatData::DecimalPlaces operator ""_dp(unsigned long long width) { return FormatData::DecimalPlaces(static_cast<int32>(width)); } namespace detail { struct Format_impl { private: static void format(const FormatData&) {} template <class Type, class... Args> static void format(FormatData& f, const Type& x, const Args&... args) { Formatter(f, x); format(f, args...); } public: template <class... Args> String operator ()(const Args&... args) const { FormatData formatData; format(formatData, args...); return std::move(formatData.string); } String operator ()(const char c) const { return String(1, c); } String operator ()(const char* text) const { return String(text); } const String& operator ()(const String& text) const { return text; } String operator ()(String&& text) const noexcept { return std::move(text); } }; template <class Float> inline void FloatFormatter_impl(FormatData& f, Float x) { std::ostringstream os; os.precision(f.decimalPlaces.value); os << std::fixed << x; f.string.append(os.str()); } } # if YAT_WITH_FEATURE(INT128) // 128-bit 整数のフォーマット namespace detail { class Int128Formatter { private: static constexpr size_t BufferSize = 40; char m_buffer[BufferSize]; char* m_str; char* format(uint128 value) { char* bufferEnd = m_buffer + BufferSize; while (value) { *(--bufferEnd) = static_cast<char>('0' + (value % 10)); value /= 10; } return bufferEnd; } public: explicit Int128Formatter(int128 value) { uint128 absValue = static_cast<uint128>(value); const bool negative = (value < 0); if (negative) absValue = (0 - absValue); m_str = format(absValue); if (negative) *--m_str = '-'; } explicit Int128Formatter(uint128 value) : m_str(format(value)) {} const char* data() const { return m_str; } size_t size() const { return m_buffer - m_str + BufferSize; } }; } # endif inline void Formatter(FormatData& f, const FormatData::DecimalPlaces x) { f.decimalPlaces = x; } inline void Formatter(FormatData& f, int8 x) { f.string.append(std::to_string(x)); } inline void Formatter(FormatData& f, int16 x) { f.string.append(std::to_string(x)); } inline void Formatter(FormatData& f, int32 x) { f.string.append(std::to_string(x)); } inline void Formatter(FormatData& f, int64 x) { f.string.append(std::to_string(x)); } inline void Formatter(FormatData& f, uint8 x) { f.string.append(std::to_string(x)); } inline void Formatter(FormatData& f, uint16 x) { f.string.append(std::to_string(x)); } inline void Formatter(FormatData& f, uint32 x) { f.string.append(std::to_string(x)); } inline void Formatter(FormatData& f, uint64 x) { f.string.append(std::to_string(x)); } # if YAT_WITH_FEATURE(INT128) inline void Formatter(FormatData& f, int128 x) { detail::Int128Formatter fmt(x); f.string.append(fmt.data(), fmt.size()); } inline void Formatter(FormatData& f, uint128 x) { detail::Int128Formatter fmt(x); f.string.append(fmt.data(), fmt.size()); } # endif inline void Formatter(FormatData& f, float32 x) { detail::FloatFormatter_impl(f, x); } inline void Formatter(FormatData& f, float64 x) { detail::FloatFormatter_impl(f, x); } inline void Formatter(FormatData& f, float128 x) { detail::FloatFormatter_impl(f, x); } inline void Formatter(FormatData& f, bool b) { f.string.append(b ? "true" : "false"); } inline void Formatter(FormatData& f, char c) { f.string.push_back(c); } inline void Formatter(FormatData& f, const char* text) { f.string.append(text); } inline void Formatter(FormatData& f, const String& text) { f.string.append(text); } template <class Iterator> inline void Formatter(FormatData& f, Iterator begin, Iterator end) { f.string.push_back('{'); for (bool isFirst = true; begin != end; ++begin) { if (isFirst) isFirst = false; else f.string.append(", "); Formatter(f, *begin); } f.string.push_back('}'); } template <class Type, size_t N> inline void Formatter(FormatData& f, const Type(&v)[N]) { Formatter(f, std::begin(v), std::end(v)); } template <class Type, size_t N> inline void Formatter(FormatData& f, const std::array<Type, N>& v) { Formatter(f, v.begin(), v.end()); } template <class Type, class Allocator = std::allocator<Type>> inline void Formatter(FormatData& f, const std::vector<Type, Allocator>& v) { Formatter(f, v.begin(), v.end()); } template <class Type> inline void Formatter(FormatData& f, const std::initializer_list<Type>& ilist) { Formatter(f, ilist.begin(), ilist.end()); } template <class Fitrst, class Second> inline void Formatter(FormatData& f, const std::pair<Fitrst, Second>& pair) { f.string.push_back('{'); Formatter(f, pair.first); f.string.append(", "); Formatter(f, pair.second); f.string.push_back('}'); } template <class Type> inline void Formatter(FormatData& f, const Array<Type>& v) { Formatter(f, v.begin(), v.end()); } // フォーマット可能な型の値を文字列に変換 // Format(...) constexpr auto Format = detail::Format_impl(); //////////////////////////////// // // 6. 標準出力 // //////////////////////////////// // 標準出力 namespace detail { struct PrintBuffer { std::unique_ptr<FormatData> formatData; PrintBuffer() : formatData(std::make_unique<FormatData>()) {} PrintBuffer(PrintBuffer&& o) noexcept : formatData(std::move(o.formatData)) {} ~PrintBuffer() { if (formatData) std::cout << formatData->string << '\n'; } template <class Type> PrintBuffer& operator <<(const Type& x) { Formatter(*formatData, x); return *this; } }; struct Print_impl { void operator()(const String& text) const { std::cout << text << '\n'; } template <class... Args> void operator()(const Args&... args) const { operator()(Format(args...)); } template <class Type, class = decltype(Formatter(std::declval<FormatData&>(), std::declval<Type>()))> PrintBuffer operator <<(const Type& x) const { PrintBuffer b; Formatter(*b.formatData, x); return b; } }; } constexpr auto Print = detail::Print_impl(); //////////////////////////////// // // 7. 標準入力 // //////////////////////////////// // 標準入力 template <class Type> inline Type Read_impl() { Type t; std::cin >> t; return t; } template <class Type> inline bool Read_impl(Type& t) { return !!(std::cin >> t); } // 標準入力から数値を 1 つ読み込む inline int8 ReadInt8() { return Read_impl<int8>(); } inline int16 ReadInt16() { return Read_impl<int16>(); } inline int32 ReadInt32() { return Read_impl<int32>(); } inline int64 ReadInt64() { return Read_impl<int64>(); } inline int8 ReadUint8() { return Read_impl<uint8>(); } inline int16 ReadUint16() { return Read_impl<uint16>(); } inline int32 ReadUint32() { return Read_impl<uint32>(); } inline int64 ReadUint64() { return Read_impl<uint64>(); } # if YAT_WITH_FEATURE(INT128) // [ToDo] inline int128 ReadInt128() { ... } // [ToDo] inline uint128 ReadUint128() { ... } # endif inline float32 ReadFloat32() { return Read_impl<float32>(); } inline float64 ReadFloat64() { return Read_impl<float64>(); } inline float128 ReadFloat128() { return Read_impl<float128>(); } inline int32 ReadInt() { return ReadInt32(); } inline uint32 ReadUint() { return ReadUint32(); } inline float32 ReadFloat() { return ReadFloat32();} inline float64 ReadDouble() { return ReadFloat64(); } // 標準入力から数値を 1 つ読み込む // * 入力の終わりに達していた場合 `false` を返す inline bool ReadInt8(int8& x) { return Read_impl<int8>(x); } inline bool ReadInt16(int16& x) { return Read_impl<int16>(x); } inline bool ReadInt32(int32& x) { return Read_impl<int32>(x); } inline bool ReadInt64(int64& x) { return Read_impl<int64>(x); } inline bool ReadUint8(uint8& x) { return Read_impl<uint8>(x); } inline bool ReadUint16(uint16& x) { return Read_impl<uint16>(x); } inline bool ReadUint32(uint32& x) { return Read_impl<uint32>(x); } inline bool ReadUint64(uint64& x) { return Read_impl<uint64>(x); } # if YAT_WITH_FEATURE(INT128) // [ToDo] inline bool ReadInt128(int128& x) { ... } // [ToDo] inline bool ReadUint128(uint128& x) { ... } # endif inline bool ReadFloat32(float32& x) { return Read_impl<float32>(x); } inline bool ReadFloat64(float64& x) { return Read_impl<float64>(x); } inline bool ReadFloat128(float128& x) { return Read_impl<float128>(x); } inline bool ReadInt(int32& x) { return ReadInt32(x); } inline bool ReadUint(uint32& x) { return ReadUint32(x); } inline bool ReadFloat(float32& x) { return Read_impl<float32>(x); } inline bool ReadDouble(float64& x) { return Read_impl<float64>(x); } // 標準入力から、文字を 1 つ読み込む // * 空白や改行の場合は無視して次の空白や改行でない文字を読み込む inline char ReadChar() { return Read_impl<char>(); } // 標準入力から、文字を 1 つ読み込む // * 空白や改行の場合は無視して次の空白や改行でない文字を読み込む // * 入力の終わりに達していた場合 `false` を返す inline bool ReadChar(char& c) { return Read_impl<char>(c); } // 標準入力から、空白や改行を含む文字を 1 つ読み込む inline char ReadCodePoint() { return static_cast<char>(std::getchar()); } // 標準入力から、空白や改行を含む文字を 1 つ読み込む // * 入力の終わりに達していた場合 `false` を返す inline bool ReadCodePoint(char& c) { c = static_cast<char>(std::getchar()); return (c != EOF); } // 標準入力から、空白を含まない 1 単語を読み込む inline String ReadWord() { String s; std::cin >> s; return s; } // 標準入力から、空白も含んで 1 行を読み込む // * 空白行の場合は無視して次の空白でない行を読み込む inline String ReadLine() { String s; do { std::getline(std::cin, s.str()); } while (s.empty()); return s; } // 標準入力から、空白を含まない 1 単語を読み込む // * 入力の終わりに達していた場合 `false` を返す inline bool ReadWord(String& s) { return !!(std::cin >> s); } // 標準入力から、空白も含んで 1 行を読み込む // * 空白行の場合は無視して次の空白でない行を読み込む // * 入力の終わりに達していた場合 `false` を返す inline bool ReadLine(String& s) { do { std::getline(std::cin, s.str()); if (!std::cin) return false; } while (s.empty()); return true; } template <class Type> inline Array<Type> ReadArray_impl(size_t n) { Array<Type> as(n); for (auto& a : as) std::cin >> a; return as; } inline Array<int8> ReadInt8Array(size_t n) { return ReadArray_impl<int8>(n); } inline Array<int16> ReadInt16Array(size_t n) { return ReadArray_impl<int16>(n); } inline Array<int32> ReadInt32Array(size_t n) { return ReadArray_impl<int32>(n); } inline Array<int64> ReadInt64Array(size_t n) { return ReadArray_impl<int64>(n); } inline Array<uint8> ReadUint8Array(size_t n) { return ReadArray_impl<uint8>(n); } inline Array<uint16> ReadUint16Array(size_t n) { return ReadArray_impl<uint16>(n); } inline Array<uint32> ReadUint32Array(size_t n) { return ReadArray_impl<uint32>(n); } inline Array<uint64> ReadUint64Array(size_t n) { return ReadArray_impl<uint64>(n); } # if YAT_WITH_FEATURE(INT128) // [ToDo] inline Array<int128 ReadInt128Array(size_t n) { ... } // [ToDo] inline Array<uint128 ReadUint128Array(size_t n) { ... } # endif inline Array<float32> ReadFloat32Array(size_t n) { return ReadArray_impl<float32>(n); } inline Array<float64> ReadFloat64Array(size_t n) { return ReadArray_impl<float64>(n); } inline Array<float128> ReadFloat128Array(size_t n) { return ReadArray_impl<float128>(n); } inline Array<int32> ReadIntArray(size_t n) { return ReadInt32Array(n); } inline Array<uint32> ReadUintArray(size_t n) { return ReadUint32Array(n); } inline Array<float32> ReadFloatArray(size_t n) { return ReadFloat32Array(n); } inline Array<float64> ReadDoubleArray(size_t n) { return ReadFloat64Array(n); } //////////////////////////////// // // 8. ループ // //////////////////////////////// template <class T, class N, class S> class Step { public: class Iterator { private: T m_currentValue; N m_count; S m_step; public: constexpr Iterator() noexcept : m_currentValue(T()), m_count(N()), m_step(S()) {} constexpr Iterator(T startValue, N count, S step) noexcept : m_currentValue(startValue), m_count(count), m_step(step) {} constexpr Iterator& operator ++() noexcept { --m_count; m_currentValue += m_step; return *this; } constexpr Iterator operator ++(int) noexcept { Iterator tmp = *this; --m_count; m_currentValue += m_step; return tmp; } constexpr const T& operator *() const noexcept { return m_currentValue; } constexpr const T* operator ->() const noexcept { return &m_currentValue; } constexpr bool operator ==(const Iterator& other) const noexcept { return m_count == other.m_count; } constexpr bool operator !=(const Iterator& other) const noexcept { return !(m_count == other.m_count); } constexpr T currentValue() const noexcept { return m_currentValue; } constexpr N size() const noexcept { return m_count; } constexpr S step() const noexcept { return m_step; } }; using value_type = T; using iterator = Iterator; constexpr Step(T startValue, N count, S step) noexcept : m_start_iterator(startValue, count, step) {} constexpr iterator begin() const noexcept { return m_start_iterator; } constexpr iterator end() const noexcept { return m_end_iterator; } constexpr value_type startValue() const noexcept { return m_start_iterator.currentValue(); } constexpr N size() const noexcept { return m_start_iterator.size(); } constexpr S step() const noexcept { return m_start_iterator.step(); } constexpr bool isEmpty() const noexcept { return size() == 0; } operator Array<value_type>() const { return asArray(); } Array<value_type> asArray() const { Array<value_type> new_array; if (isEmpty()) return new_array; new_array.reserve(static_cast<size_t>(size())); auto count_ = size(); auto value = startValue(); const auto step_ = step(); for (;;) { new_array.push_back(value); if (--count_) value += step_; else break; } return new_array; } template <class Fty> constexpr N count_if(Fty f) const { if (isEmpty()) return 0; N result = 0; auto count_ = size(); auto value = startValue(); const auto step_ = step(); for (;;) { if (f(value)) ++result; if (--count_) value += step_; else break; } return result; } template <class Fty> void each(Fty f) const { if (isEmpty()) return; auto count_ = size(); auto value = startValue(); const auto step_ = step(); for (;;) { f(value); if (--count_) value += step_; else break; } } template <class Fty> void each_index(Fty f) const { if (isEmpty()) return; auto count_ = size(); auto value = startValue(); const auto step_ = step(); size_t index = 0; for (;;) { f(index++, value); if (--count_) value += step_; else break; } } template <class Fty> constexpr auto filter(Fty f) const; constexpr bool include(const value_type& x) const { if (isEmpty()) return false; auto count_ = size(); auto value = startValue(); const auto step_ = step(); for (;;) { if (x == value) return true; if (--count_) value += step_; else break; } return false; } template <class Fty> constexpr bool include_if(Fty f) const { if (isEmpty()) return false; auto count_ = size(); auto value = startValue(); const auto step_ = step(); for (;;) { if (f(value)) return true; if (--count_) value += step_; else break; } return false; } String join(StringView sep = U", ", StringView begin = U"{", StringView end = U"}") const { String s; s.append(begin); if (isEmpty()) { s.append(end); return s; } bool isFirst = true; auto count_ = size(); auto value = startValue(); const auto step_ = step(); for (;;) { if (isFirst) isFirst = false; else s.append(sep); s.append(Format(value)); if (--count_) value += step_; else break; } s.append(end); return s; } template <class Fty> constexpr auto map(Fty f) const; template <class Fty, class R = std::decay_t<std::result_of_t<Fty(T, T)>>> constexpr auto reduce(Fty f, R init) const { if (isEmpty()) return init; auto count_ = size(); auto value = startValue(); const auto step_ = step(); for (;;) { init = f(init, value); if (--count_) value += step_; else return init; } } template <class Fty> constexpr auto reduce1(Fty f) const { if (isEmpty()) throw std::out_of_range("Step::reduce1() reduce from empty range"); auto count_ = size(); auto value = startValue(); const auto step_ = step(); std::result_of_t<Fty(value_type, value_type)> result = value; for (;;) { if (--count_) value += step_; else break; result = f(result, value); } return result; } constexpr auto sum() const { using result_type = decltype(std::declval<T>() + std::declval<S>()); if (std::is_scalar<result_type>::value) { const auto n = size(); const auto a = startValue(); const auto d = step(); return static_cast<result_type>(n * (2 * a + (n - 1) * d) / 2); } else return reduce(Plus<result_type>(), result_type{}); } Array<value_type> take(size_t n) const { Array<value_type> new_array; if (isEmpty() || n == 0) return new_array; auto count_ = size(); auto value = startValue(); const auto step_ = step(); for (;;) { new_array.push_back(value); if (--count_ && new_array.size() < n) value += step_; else break; } return new_array; } template <class Fty> Array<value_type> take_while(Fty f) const { Array<value_type> new_array; if (isEmpty()) return new_array; auto count_ = size(); auto value = startValue(); const auto step_ = step(); for (;;) { if (f(value)) new_array.push_back(value); else break; if (--count_) value += step_; else break; } return new_array; } private: iterator m_end_iterator; iterator m_start_iterator; }; template <class T, class N, class S = int32, std::enable_if_t<std::is_integral<N>::value> * = nullptr> inline constexpr auto step(T a, N n, S s = 1) { return Step<decltype(a + s), N, S>(a, n, s); } template <class N, std::enable_if_t<std::is_integral<N>::value> * = nullptr> inline constexpr auto step(N n) { return Step<N, N, int32>(N(0), n, 1); } template <class N, std::enable_if_t<std::is_integral<N>::value> * = nullptr> inline constexpr auto step_backward(N n) { return Step<N, N, int32>(n + int32(-1), n, int32(-1)); } template <class T, class U, class S = int32, class StartType = std::common_type_t<T, U>, class CounterType = std::common_type_t<std::size_t, StartType>, std::enable_if_t<std::is_integral<StartType>::value> * = nullptr> inline constexpr auto step_to(T a, U b, S s = 1) { CounterType n = 0; using DiffType = std::common_type_t<int64, StartType>; if (s == 0 || (b != a && (b < a) != (s < 0))) n = 0; else { S abs_s = s > 0 ? s : -s; CounterType diff = b > a ? DiffType(b) - DiffType(a) : DiffType(a) - DiffType(b); if (abs_s == 1) n = diff; else n = diff / abs_s; n++; } return Step<StartType, CounterType, S>(a, n, s); } template<class T, class U, class S = int32, class StartType = std::common_type_t<T, U>, class CounterType = std::common_type_t<std::size_t, StartType>, std::enable_if_t<std::is_integral<StartType>::value> * = nullptr> inline constexpr auto step_until(T a, U b, S s = 1) { CounterType n; using DiffType = std::common_type_t<int64, StartType>; if (b == a || s == 0 || (b < a) != (s < 0)) n = 0; else { S abs_s = s > 0 ? s : -s; CounterType diff = b > a ? DiffType(b) - DiffType(a) : DiffType(a) - DiffType(b); if (abs_s == 1) n = diff; else n = diff / abs_s; CounterType finish = a + n * s; if (finish != static_cast<CounterType>(b)) n++; } return Step<StartType, CounterType, S>(a, n, s); } template<class T, class U, class S = int32, class StartType = std::common_type_t<T, U>, class CounterType = std::common_type_t<std::size_t, StartType>, std::enable_if_t<std::is_integral<StartType>::value> * = nullptr> inline constexpr auto Range(T beg, U end, S step = 1) { return step_to(beg, end, step); } namespace detail { template <class Fty> struct FilterFunction { using isMap = std::false_type; Fty function; template <class T> constexpr auto operator() (const T& value) const { return function(value); } }; template <class Fty> struct MapFunction { using isMap = std::true_type; Fty function; template <class T> constexpr auto operator() (const T& value) const { return function(value); } }; template <class F> struct IsMap : std::conditional_t<F::isMap::value, std::true_type, std::false_type> {}; template <class Fty, class ValueType, size_t Index, class Tuple, class Next> constexpr void Apply_impl(Fty f, const ValueType& value, const Tuple& tuple) { if (IsMap<Next>::value) { if (Index + 1 == std::tuple_size<Tuple>::value) f(std::get<Index>(tuple)(value)); else Apply_impl<Fty, decltype(std::get<Index>(tuple)(value)), Index + 1, Tuple, std::decay_t<decltype(std::get<Index + 1>(std::declval<Tuple>()))>>(f, std::get<Index>(tuple)(value), tuple); } else { if (Index + 1 == std::tuple_size<Tuple>::value) { if (std::get<Index>(tuple)(value)) f(value); } else { if (std::get<Index>(tuple)(value)) Apply_impl<Fty, ValueType, Index + 1, Tuple, std::decay_t<decltype(std::get<Index + 1>(std::declval<Tuple>()))>>(f, value, tuple); } } } template <class Fty, class ValueType, class Tuple> constexpr void Apply(Fty f, const ValueType& value, const Tuple& tuple) { Apply_impl<Fty, ValueType, 0, Tuple, std::decay_t<decltype(std::get<0>(std::declval<Tuple>()))>>(f, value, tuple); } template <class Fty, class ResultType, class ValueType, size_t Index, class Tuple, class Next, std::enable_if_t<IsMap<Next>::value && (Index + 1 == std::tuple_size<Tuple>::value)> * = nullptr> constexpr void Reduce_impl(Fty f, ResultType& result, const ValueType& value, const Tuple& tuple) { result = f(result, std::get<Index>(tuple)(value)); } template <class Fty, class ResultType, class ValueType, size_t Index, class Tuple, class Next, std::enable_if_t<IsMap<Next>::value && (Index + 1 != std::tuple_size<Tuple>::value)> * = nullptr> constexpr void Reduce_impl(Fty f, ResultType& result, const ValueType& value, const Tuple& tuple) { Reduce_impl<Fty, ResultType, decltype(std::get<Index>(tuple)(value)), Index + 1, Tuple, std::decay_t<decltype(std::get<Index + 1>(std::declval<Tuple>()))>>(f, result, std::get<Index>(tuple)(value), tuple); } template <class Fty, class ResultType, class ValueType, size_t Index, class Tuple, class Next, std::enable_if_t<!IsMap<Next>::value>* = nullptr> constexpr void Reduce_impl(Fty f, ResultType& result, const ValueType& value, const Tuple& tuple) { if (Index + 1 == std::tuple_size<Tuple>::value) { if (std::get<Index>(tuple)(value)) result = f(result, value); } else { if (std::get<Index>(tuple)(value)) Reduce_impl<Fty, ResultType, ValueType, Index + 1, Tuple, std::decay_t<decltype(std::get<Index + 1>(std::declval<Tuple>()))>>(f, result, value, tuple); } } template <class Fty, class ResultType, class ValueType, class Tuple> constexpr void Reduce(Fty f, ResultType& result, const ValueType& value, const Tuple& tuple) { Reduce_impl<Fty, ResultType, ValueType, 0, Tuple, std::decay_t<decltype(std::get<0>(std::declval<Tuple>()))>>(f, result, value, tuple); } template <class StepClass, class ValueType, class Tuple> class F_Step { private: StepClass m_base; Tuple m_functions; public: using value_type = ValueType; using functions_type = Tuple; constexpr F_Step(StepClass stepClass, Tuple functions) : m_base(stepClass), m_functions(functions) {} operator Array<value_type>() const { return asArray(); } Array<value_type> asArray() const { Array<value_type> new_array; each([&new_array](const auto& value) { new_array.push_back(value); }); return new_array; } size_t size() const { size_t sum = 0; each([&sum](const auto) { ++sum; }); return sum; } template <class Fty> size_t count_if(Fty f) const { size_t sum = 0; each([&sum, f = f](const auto& value) { sum += f(value); }); return sum; } template <class Fty> void each(Fty f) const { m_base.each([f, functions = m_functions](const auto& value){ Apply(f, value, functions); }); } void evaluate() const { m_base.each([functions = m_functions](const auto& value){ Apply(Id, value, functions); }); } template <class Fty> constexpr auto filter(Fty f) const { const auto functions = std::tuple_cat(m_functions, std::make_tuple(FilterFunction<Fty>{ f })); return F_Step<StepClass, value_type, decltype(functions)>(m_base, functions); } bool include(const value_type& x) const { if (m_base.isEmpty()) return false; bool hasValue = false; auto count_ = m_base.size(); auto value = m_base.startValue(); const auto step_ = m_base.step(); const auto includeFunc = [&hasValue, x](const auto& value) { hasValue = (value == x); }; const auto functions = m_functions; for (;;) { Apply(includeFunc, value, functions); if (hasValue) return true; if (--count_) value += step_; else break; } return false; } template <class Fty> bool include_if(Fty f) const { if (m_base.isEmpty()) return false; bool hasValue = false; auto count_ = m_base.size(); auto value = m_base.startValue(); const auto step_ = m_base.step(); const auto includeFunc = [&hasValue, f](const auto& value) { hasValue = f(value); }; const auto functions = m_functions; for (;;) { Apply(includeFunc, value, functions); if (hasValue) return true; if (--count_) value += step_; else break; } return false; } String join(StringView sep = U", ", StringView begin = U"{", StringView end = U"}") const { String s; s.append(begin); bool isFirst = true; each([&s, &isFirst, sep = sep](const auto& value) { if (isFirst) isFirst = false; else s.append(sep); s.append(Format(value)); }); s.append(end); return s; } template <class Fty> constexpr auto map(Fty f) const { using Ret = std::decay_t<std::result_of_t<Fty(value_type)>>; const auto functions = std::tuple_cat(m_functions, std::make_tuple(MapFunction<Fty>{ f })); return F_Step<StepClass, Ret, decltype(functions)>(m_base, functions); } template <class Fty, class R = std::decay_t<std::result_of_t<Fty(ValueType, ValueType)>>> constexpr auto reduce(Fty f, R init) const { auto result = init; if (m_base.isEmpty()) return result; auto count_ = m_base.size(); auto value = m_base.startValue(); const auto step_ = m_base.step(); const auto functions = m_functions; for (;;) { Reduce(f, result, value, functions); if (--count_) value += step_; else break; } return result; } template <class Fty> auto reduce1(Fty f) const { if (m_base.isEmpty()) throw std::out_of_range("F_Step::reduce1() reduce from empty range"); auto count_ = m_base.size(); auto value = m_base.startValue(); const auto step_ = m_base.step(); const auto functions = m_functions; std::result_of_t<Fty(value_type, value_type)> result; Apply([&result](const auto& v) { result = v; }, value, functions); if (--count_ == 0) return result; value += step_; for (;;) { Reduce(f, result, value, functions); if (--count_) value += step_; else break; } return result; } template <class Type = value_type> Type sum() const { return reduce(Plus<Type>(), Type{}); } Array<value_type> take(size_t n) const { Array<value_type> new_array; if (m_base.isEmpty() || n == 0) return new_array; auto count_ = m_base.size(); auto value = m_base.startValue(); const auto step_ = m_base.step(); const auto pushFunc = [&new_array](const auto& value) { new_array.push_back(value); }; const auto functions = m_functions; for (;;) { Apply(pushFunc, value, functions); if (--count_ && new_array.size() < n) value += step_; else break; } return new_array; } template <class Fty> Array<value_type> take_while(Fty f) const { Array<value_type> new_array; if (m_base.isEmpty()) return new_array; bool finished = false; auto count_ = m_base.size(); auto value = m_base.startValue(); const auto step_ = m_base.step(); const auto pushFunc = [&new_array, &finished, f = f](const auto& value) { if (f(value)) new_array.push_back(value); else finished = true; }; const auto functions = m_functions; for (;;) { Apply(pushFunc, value, functions); if (--count_ && !finished) value += step_; else break; } return new_array; } }; } template <class T, class N, class S> template <class Fty> inline constexpr auto Step<T, N, S>::filter(Fty f) const { const auto tuple = std::make_tuple(detail::FilterFunction<Fty>{ f }); return detail::F_Step<Step, value_type, decltype(tuple)>(*this, tuple); } template <class T, class N, class S> template <class Fty> inline constexpr auto Step<T, N, S>::map(Fty f) const { using Ret = std::decay_t<std::result_of_t<Fty(value_type)>>; const auto tuple = std::make_tuple(detail::MapFunction<Fty>{ f }); return detail::F_Step<Step, Ret, decltype(tuple)>(*this, tuple); } template <class T, class N, class S> inline void Formatter(FormatData& f, const Step<T, N, S>& s) { Formatter(f, s.join()); } template <class StepClass, class ValueType, class Tuple> inline void Formatter(FormatData& f, const detail::F_Step<StepClass, ValueType, Tuple>& s) { Formatter(f, s.join()); } //////////////////////////////// // // 9. 便利関数 // //////////////////////////////// namespace detail { struct Odd_impl { template <class Type> constexpr bool operator()(const Type& x) const { return (x % 2) != 0; } }; struct Even_impl { template <class Type> constexpr bool operator()(const Type& x) const { return (x % 2) == 0; } }; } // x が min 以上 max 以下である場合に `true` を返す template <class Type> inline constexpr bool InRange(const Type& x, const Type& min, const Type& max) { return (min <= x) && (x <= max); } // 奇数の場合に `true` を返す constexpr auto IsOdd = detail::Odd_impl(); // 偶数の場合に `true` を返す constexpr auto IsEven = detail::Even_impl(); // 10 の n 乗を整数型で返す template <class Integer> inline constexpr Integer PowerOf10(size_t n) noexcept { Integer x = 1; for (size_t i = 0; i < n; ++i) x *= 10; return x; } // 整数の (1 + N) 桁目の数を返す template <class Integer> int32 GetDigit(Integer n, size_t index) noexcept { return static_cast<int32>((n / PowerOf10<Integer>(index)) % 10); } } namespace std { inline void swap(yat::StringView& a, yat::StringView& b) noexcept { a.swap(b); } inline void swap(yat::String& a, yat::String& b) noexcept { a.swap(b); } template <class Type, class Allocator> inline void swap(yat::Array<Type, Allocator>& a, yat::Array<Type, Allocator>& b) noexcept { a.swap(b); } } using namespace std; using namespace yat; // //////////////////////////////////////////////////////////////// int main() { const int32 W = ReadInt(); const int32 a = ReadInt(), b = ReadInt(); if (abs(a - B) <= W) { Print(0); } else { Print(abs(a - b) - W); } return 0; }
a.cc: In function 'int main()': a.cc:2212:17: error: 'B' was not declared in this scope 2212 | if (abs(a - B) <= W) | ^
s986650069
p03778
C++
#include <bits/stdc++.h> using namespace std; int w,a,b,aww; int main () { cin >> w >> a >> b; if (a > b) { aww= a - (b+w); } else { aww= b - (a+w); } if (dis <= 0) { cout << 0 << endl; } else { cout << aww << endl; }
a.cc: In function 'int main()': a.cc:12:13: error: 'dis' was not declared in this scope; did you mean 'div'? 12 | if (dis <= 0) { | ^~~ | div a.cc:17:10: error: expected '}' at end of input 17 | } | ^ a.cc:4:13: note: to match this '{' 4 | int main () { | ^
s830168556
p03778
C++
#include <bits/stdc++.h> using namespace std; int w,a,b,aww; int main () { cin >> w >> a >> b; if (a > b) { aww= a - (b+w); } else { aww= b - (a+w); } if (dis <= 0) { cout << 0 << endl; } else { cout << dis << endl; } }
a.cc: In function 'int main()': a.cc:12:13: error: 'dis' was not declared in this scope; did you mean 'div'? 12 | if (dis <= 0) { | ^~~ | div
s217903295
p03778
C++
#include <bits/stdc++.h> #include <math.h> using namespace std; int a,b,c,d,gede; int main () { cin>>a>>b>>c; d=c-(a+b)<<endl; if(d<=0){ cout<<0<<endl; }else{ cout<<c-(a+b)<<endl; } }
a.cc: In function 'int main()': a.cc:8:10: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<' 8 | d=c-(a+b)<<endl; | ~~~~~~~^~~~~~
s789708728
p03778
C++
#include <bits/stdc++.h> using namespace std; int main() { int W, a, b; cin >> W >> a >> b; if (a > b) swap(a, b); int ans = b - (a + W); if (ans > 0) cout << ans << endl; else }
a.cc: In function 'int main()': a.cc:16:1: error: expected primary-expression before '}' token 16 | } | ^
s489713736
p03778
C++
#include <bits/stdc++.h> using namespace std; int main() { int W, a, b; cin >> W >> a >> b; if (a > b) swap(a, b); int ans = b - (a + W); if (ans > 0) cout << ans << endl; else
a.cc: In function 'int main()': a.cc:15:7: error: expected statement at end of input 15 | else | ^ a.cc:15:7: error: expected '}' at end of input a.cc:4:12: note: to match this '{' 4 | int main() { | ^
s305993182
p03778
Java
import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { Scanner ss=new Scanner(System.in); long p,x,xx,c; p=ss.nextLong(); x=ss.nextLong(); xx=ss.nextLong(); if(x>xx){ c=xx; xx=x; x=c; } p+=x; xx-=p; if(xx<0) xx=0; System.out.println(xx); } }
Main.java:4: error: class Solution is public, should be declared in a file named Solution.java public class Solution { ^ 1 error
s017833691
p03778
C++
#include<bits/stdc++.h> #define ll long long #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; int main() { int w,a,b; cin>>w>>a>>b; if ((a<=b&&b<=a+w)||(b<=a&&a<=b+w)) cout<<0<<endl; else cout<<abs(a, b)-w<<endl; }
a.cc: In function 'int main()': a.cc:10:18: error: no matching function for call to 'abs(int&, int&)' 10 | else cout<<abs(a, b)-w<<endl; | ~~~^~~~~~ In file included from /usr/include/c++/14/valarray:605, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166, from a.cc:1: /usr/include/c++/14/bits/valarray_after.h:445:5: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_UnClos<std::_Abs, std::_ValArray, _Tp>, _Tp> std::abs(const valarray<_Tp>&)' 445 | _DEFINE_EXPR_UNARY_FUNCTION(abs, struct std::_Abs) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:445:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/valarray_after.h:445:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_UnClos<std::_Abs, std::_Expr, _Dom>, typename _Dom::value_type> std::abs(const _Expr<_Dom1, typename _Dom1::value_type>&)' 445 | _DEFINE_EXPR_UNARY_FUNCTION(abs, struct std::_Abs) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:445:5: note: candidate expects 1 argument, 2 provided In file included from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127: /usr/include/c++/14/complex:892:5: note: candidate: 'template<class _Tp> _Tp std::abs(const complex<_Tp>&)' 892 | abs(const complex<_Tp>& __z) { return __complex_abs(__z.__rep()); } | ^~~ /usr/include/c++/14/complex:892:5: note: candidate expects 1 argument, 2 provided In file included from /usr/include/c++/14/cstdlib:79, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:42: /usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)' 980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur; | ^~~ /usr/include/stdlib.h:980:12: note: candidate expects 1 argument, 2 provided In file included from /usr/include/c++/14/cstdlib:81: /usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)' 137 | abs(__float128 __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:137:3: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)' 85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; } | ^~~ /usr/include/c++/14/bits/std_abs.h:85:3: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)' 79 | abs(long double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:79:3: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)' 75 | abs(float __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:75:3: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)' 71 | abs(double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:71:3: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)' 61 | abs(long long __x) { return __builtin_llabs (__x); } | ^~~ /usr/include/c++/14/bits/std_abs.h:61:3: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)' 56 | abs(long __i) { return __builtin_labs(__i); } | ^~~ /usr/include/c++/14/bits/std_abs.h:56:3: note: candidate expects 1 argument, 2 provided
s469317098
p03778
C++
#include <bits/stdc++.h> #include <math.h> using namespace std; int main(){ int w,a,b; cin >> w>>a>>b; if(b + a < w) cout << 0 << endl; else cout << abs(a - b) - w }
a.cc: In function 'int main()': a.cc:8:30: error: expected ';' before '}' token 8 | else cout << abs(a - b) - w | ^ | ; 9 | } | ~
s561206061
p03778
C++
#include<iostream> using namespace std; int main(){ long int W; long int a,b; cin >> W >> a >>b; int x; if(a<=b && b<=a+W || a<=b+W && b+W>=a+W) {x=0; break; } if(a<b){ for(int i=0;i<W; ++i){ if(a+W==b-i){ x =i; break; } } } if(a>b){ for(int i=0;i<W; ++i){ if(a==b+W+i){ x=i; break; } } } cout << x <<endl; }
a.cc: In function 'int main()': a.cc:12:7: error: break statement not within loop or switch 12 | break; | ^~~~~
s655442427
p03778
C++
#include<iostream> using namespace std; int main(){ long int W; long int a,b; cin >> W >> a >>b; int x; if(a<=b && b<=a+W || a<=b+W && b+W>=a+W) {x=0; break; } if(a<b){ for(int i=0;i<W; ++i){ if(a+W==b-i){ x =i; break; } } } if(a>b){ for(int i=0;i<W; ++i){ if(a==b+W+i){ x=i; break; } } } } cout << x <<endl; }
a.cc: In function 'int main()': a.cc:12:7: error: break statement not within loop or switch 12 | break; | ^~~~~ a.cc: At global scope: a.cc:31:4: error: 'cout' does not name a type 31 | cout << x <<endl; | ^~~~ a.cc:32:1: error: expected declaration before '}' token 32 | } | ^
s669666808
p03778
C++
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) typedef long long ll; int main() { int W, a, b; cin >> W >> a >> b; cout << max(max(a,b) - (min(a,b) + W)), 0) << endl; }
a.cc: In function 'int main()': a.cc:10:16: error: no matching function for call to 'max(int)' 10 | cout << max(max(a,b) - (min(a,b) + W)), 0) << endl; | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 1 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: template argument deduction/substitution failed: a.cc:10:16: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 10 | cout << max(max(a,b) - (min(a,b) + W)), 0) << endl; | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate expects 2 arguments, 1 provided
s799673049
p03778
Java
public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int W = Integer.parseInt(sc.next()); int a = Integer.parseInt(sc.next()); int b = Integer.parseInt(sc.next()); System.out.println(Math.max(Math.abs(a-b)-W, 0)); } }
Main.java:3: error: cannot find symbol Scanner sc = new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:3: error: cannot find symbol Scanner sc = new Scanner(System.in); ^ symbol: class Scanner location: class Main 2 errors
s484753302
p03778
C++
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for (int (i)=0;(i)<(n);i++) #define INF 1001001001 #define LLINF 1001001001001001001 #define MOD 1000000007 template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } #define ALL(v) v.begin(), v.end() typedef long long ll; int main(){ int w,a,b; cin >> w>> a >> b; if(a>b){ if(b<a and a<b+w)cout << 0 << endl; else if (b+w<a)cout << a-b-w << endl; else(a==b+w)cout << 0 << endl; } else if (b>a){ swap(a,b); if(b<a and a<b+w)cout << 0 << endl; else if (b+w<a)cout << a-b-w << endl; else(a==b+w)cout << 0 << endl; } else cout << 0 << endl; return 0; }
a.cc: In function 'int main()': a.cc:21:17: error: expected ';' before 'cout' 21 | else(a==b+w)cout << 0 << endl; | ^~~~ | ; a.cc:27:17: error: expected ';' before 'cout' 27 | else(a==b+w)cout << 0 << endl; | ^~~~ | ;
s530427295
p03778
C++
#include <iostream> #include <iomanip> #include <vector> #include <cmath> #include <algorithm> #include <iomanip> #include <cstring> #define rep(i, N) for (int i = 0; i < (int)N; i++) using namespace std; typedef long long ll; const ll LLINF = 9223372036854775807; const int MOD = 1000000007; int main() { int W, a, b; cin >> W >> A >> B; int result = max(0, abs(a-b)-W); cout << result << endl; return 0; }
a.cc: In function 'int main()': a.cc:15:28: error: 'A' was not declared in this scope 15 | int W, a, b; cin >> W >> A >> B; | ^ a.cc:15:33: error: 'B' was not declared in this scope 15 | int W, a, b; cin >> W >> A >> B; | ^
s595478442
p03778
C++
#include <isotream> using namespace std; int main(){ int W, a, b; cin >> W >> a >> b; int ans; if(a+W < b){ ans = b - (a+W); }else if( b + W < a ){ ans = a - (b+W); }else{ ans = 0; } cout << ans; }
a.cc:1:10: fatal error: isotream: No such file or directory 1 | #include <isotream> | ^~~~~~~~~~ compilation terminated.
s645078573
p03778
C++
#include <bits/stdc++.h> using namespace std; int main() { int x,a,b; cin >> x >> a >> b; cout << max(abs(b - a) - w,0) << endl; }
a.cc: In function 'int main()': a.cc:6:28: error: 'w' was not declared in this scope 6 | cout << max(abs(b - a) - w,0) << endl; | ^
s540802156
p03778
C++
#include <bits/stdc++.h> using namespace std; int main() { int w, a, b; cin >> w >> a >> b; int ans = 0; if (a + w < b) { ans = b - (a + w) } else if (b + w < a) { ans = a - (b + w); } else { ans = 0; } cout << ans; }
a.cc: In function 'int main()': a.cc:10:26: error: expected ';' before '}' token 10 | ans = b - (a + w) | ^ | ; 11 | } else if (b + w < a) { | ~
s234743188
p03778
Java
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int W = sc.nextInt(); int b = sc.nextInt(); int b = sc.nextInt(); int ans = 0; if (a+W < b) { ans = b - (a+W); } else if (b+W < a) { ans = a - (b+W); } System.out.println(ans); } }
Main.java:8: error: variable b is already defined in method main(String[]) int b = sc.nextInt(); ^ Main.java:11: error: cannot find symbol if (a+W < b) { ^ symbol: variable a location: class Main Main.java:12: error: cannot find symbol ans = b - (a+W); ^ symbol: variable a location: class Main Main.java:13: error: cannot find symbol } else if (b+W < a) { ^ symbol: variable a location: class Main Main.java:14: error: cannot find symbol ans = a - (b+W); ^ symbol: variable a location: class Main 5 errors
s994978499
p03778
C++
#pragma GCC optimize ("O3") #pragma GCC target ("sse4") #include <bits/stdc++.h> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> #include <iomanip> using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef long double ld; typedef pair<int, int> pi; typedef pair<ll,ll> pl; typedef pair<ld,ld> pd; typedef vector<int> vi; typedef vector<ld> vd; typedef vector<ll> vl; typedef vector<pi> vpi; typedef vector<pl> vpl; #define rep(i, a, b) for (int i=a; i<(b); i++) #define rp(i, a) for (int i=0; i<(a); i++) #define repd(i,a,b) for (int i = (b)-1; i >= a; i--) #define rpd(i,a) for (int i = (a)-1; i >= 0; i--) #define sz(x) (int)(x).size() #define mp make_pair #define pb push_back #define f first #define s second #define lb lower_bound #define ub upper_bound #define all(x) x.begin(), x.end() #define shandom_ruffle random_shuffle const int MOD = 1000000007; const ll INF = 1e18; const int MX = 100001; //check the limits, dummy int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout << std::setprecision(9); cout << std::fixed; ll W,a,b; cin >> W >> a >> b; if(a > b) swap(a,b); cout << max(0,a+W-b)<<endl; return 0; } // read the question correctly (ll vs int) // template by super1 derived from bqi343
a.cc: In function 'int main()': a.cc:54:16: error: no matching function for call to 'max(int, ll)' 54 | cout << max(0,a+W-b)<<endl; | ~~~^~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:4: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:54:16: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 54 | cout << max(0,a+W-b)<<endl; | ~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:54:16: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 54 | cout << max(0,a+W-b)<<endl; | ~~~^~~~~~~~~
s857025627
p03778
C++
#include <iostream> #include <cstdlib> #include <algorithm> #include <vector> #include <string> #include <cmath> #include <cassert> #include <functional> #include <string> #include <sstream> #include <cctype> using namespace std; int main(){ int W, a, b; cin >> W >> a >> b: if(a + W < b) cout << b - (a + W) << endl; else if(b + W < a) cout << a - (b + W) << endl; else cout << 0 << endl; }
a.cc: In function 'int main()': a.cc:15:34: error: expected ';' before ':' token 15 | int W, a, b; cin >> W >> a >> b: | ^ | ; a.cc:17:3: error: 'else' without a previous 'if' 17 | else if(b + W < a) cout << a - (b + W) << endl; | ^~~~
s663223398
p03778
C++
#include <iostream> #include <cstdlib> #include <algorithm> #include <vector> #include <string> #include <cmath> #include <cassert> #include <functional> #include <string> #include <sstream> #include <cctype> using namespace std; int main(){ int W, a, b; cin >> W >> a >> b: if(a + W <= b) cout << b + 1 - (a + W) << endl; else if(b + W <= a) cout << a + 1 - (b + W) << endl; else cout << 0 << endl; }
a.cc: In function 'int main()': a.cc:15:34: error: expected ';' before ':' token 15 | int W, a, b; cin >> W >> a >> b: | ^ | ; a.cc:17:3: error: 'else' without a previous 'if' 17 | else if(b + W <= a) cout << a + 1 - (b + W) << endl; | ^~~~
s928856416
p03778
C++
#include <iostream> #include <vector> #include <cstring> #include <algorithm> // sort #define REP(i, n) for (long long i = 0; i < (n); i++) typedef long long ll; static const ll MOD = 1000000007; static const ll INF = 1000000000000000000LL; using namespace std; int main(){ int W,a,b; cin >> W >> a >> b; //(a < b) b - (a + W) (a > b)a - (b + W) if(a < b) { res = b - (a + W); } else { res = a - (b + W); } if(res < 0) res = 0; cout << res << endl; return 0; }
a.cc: In function 'int main()': a.cc:20:7: error: 'res' was not declared in this scope 20 | res = b - (a + W); | ^~~ a.cc:24:7: error: 'res' was not declared in this scope 24 | res = a - (b + W); | ^~~ a.cc:27:8: error: 'res' was not declared in this scope 27 | if(res < 0) res = 0; | ^~~ a.cc:29:13: error: 'res' was not declared in this scope 29 | cout << res << endl; | ^~~
s815970204
p03778
C++
#include <iostream> #include <vector> #include <cstring> #include <algorithm> // sort #define REP(i, n) for (long long i = 0; i < (n); i++) typedef long long ll; static const ll MOD = 1000000007; static const ll INF = 1000000000000000000LL; using namespace std; int main(){ int W,a,b; cin >> W >> a > b; //(a < b) b - (a + W) (a > b)a - (b + W) if(a < b) { res = b - (a + W); } else { res = a - (b + W); } if(res < 0) res = 0; cout << res << endl; return 0; }
a.cc: In function 'int main()': a.cc:14:19: error: no match for 'operator>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'int') 14 | cin >> W >> a > b; | ~~~~~~~~~~~~~ ^ ~ | | | | | int | std::basic_istream<char>::__istream_type {aka std::basic_istream<char>} a.cc:14:19: note: candidate: 'operator>(int, int)' (built-in) 14 | cin >> W >> a > b; | ~~~~~~~~~~~~~~^~~ a.cc:14:19: note: no known conversion for argument 1 from 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} to 'int' In file included from /usr/include/c++/14/string:48, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_iterator.h:462:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 462 | operator>(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:462:5: note: template argument deduction/substitution failed: a.cc:14:21: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 14 | cin >> W >> a > b; | ^ /usr/include/c++/14/bits/stl_iterator.h:507:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 507 | operator>(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:507:5: note: template argument deduction/substitution failed: a.cc:14:21: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 14 | cin >> W >> a > b; | ^ /usr/include/c++/14/bits/stl_iterator.h:1714:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1714 | operator>(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1714:5: note: template argument deduction/substitution failed: a.cc:14:21: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 14 | cin >> W >> a > b; | ^ /usr/include/c++/14/bits/stl_iterator.h:1774:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1774 | operator>(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1774:5: note: template argument deduction/substitution failed: a.cc:14:21: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 14 | cin >> W >> a > b; | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/string:51: /usr/include/c++/14/bits/stl_pair.h:1058:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator>(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1058 | operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1058:5: note: template argument deduction/substitution failed: a.cc:14:21: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::pair<_T1, _T2>' 14 | cin >> W >> a > b; | ^ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:695:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator>(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 695 | operator> (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:695:5: note: template argument deduction/substitution failed: a.cc:14:21: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 14 | cin >> W >> a > b; | ^ /usr/include/c++/14/string_view:702:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator>(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 702 | operator> (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:702:5: note: template argument deduction/substitution failed: a.cc:14:21: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 14 | cin >> W >> a > b; | ^ /usr/include/c++/14/string_view:710:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator>(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 710 | operator> (__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:710:5: note: template argument deduction/substitution failed: a.cc:14:21: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int' 14 | cin >> W >> a > b; | ^ /usr/include/c++/14/bits/basic_string.h:3915:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3915 | operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3915:5: note: template argument deduction/substitution failed: a.cc:14:21: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 14 | cin >> W >> a > b; | ^ /usr/include/c++/14/bits/basic_string.h:3929:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3929 | operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3929:5: note: template argument deduction/substitution failed: a.cc:14:21: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 14 | cin >> W >> a > b; | ^ /usr/include/c++/14/bits/basic_string.h:3942:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3942 | operator>(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3942:5: note: template argument deduction/substitution failed: a.cc:14:21: note: mismatched types 'const _CharT*' and 'std::basic_istream<char>' 14 | cin >> W >> a > b; | ^ In file included from /usr/include/c++/14/bits/memory_resource.h:47, from /usr/include/c++/14/string:68: /usr/include/c++/14/tuple:2619:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator>(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)' 2619 | operator>(const tuple<_TElements...>& __t, | ^~~~~~~~ /usr/include/c++/14/tuple:2619:5: note: template argument deduction/substitution failed: a.cc:14:21: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::tuple<_UTypes ...>' 14 | cin >> W >> a > b; | ^ In file included from /usr/include/c++/14/vector:66, from a.cc:2: /usr/include/c++/14/bits/stl_vector.h:2102:5: note: candidate: 'template<class _Tp, class _Alloc> bool std::operator>(const vector<_Tp, _Alloc>&, const vector<_Tp, _Alloc>&)' 2102 | operator>(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:2102:5: note: template argument deduction/substitution failed: a.cc:14:21: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::vector<_Tp, _Alloc>' 14 | cin >> W >> a > b; | ^ a.cc:20:7: error: 'res' was not declared in this scope 20 | res = b - (a + W); | ^~~ a.cc:24:7: error: 'res' was not declared in this scope 24 | res = a - (b + W); | ^~~ a.cc:27:8: error: 'res' was not declared in this scope 27 | if(res < 0) res = 0; | ^~~ a.cc:29:13: error: 'res' was not declared in this scope 29 | cout << res << endl; | ^~~
s789537214
p03778
C++
#include <stdio.h> #include <stdlib.h> #include <math.h> int main() { int w, a, b; scanf("%d%d%d", &w, &a, &b); printf("%d\n", max(0, max(a, b)-min(a, b)-w)); return 0; }
a.cc: In function 'int main()': a.cc:8:25: error: 'max' was not declared in this scope; did you mean 'std::max'? 8 | printf("%d\n", max(0, max(a, b)-min(a, b)-w)); | ^~~ | std::max In file included from /usr/include/c++/14/bits/specfun.h:43, from /usr/include/c++/14/cmath:3906, from /usr/include/c++/14/math.h:36, from a.cc:3: /usr/include/c++/14/bits/stl_algobase.h:303:5: note: 'std::max' declared here 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ a.cc:8:35: error: 'min' was not declared in this scope; did you mean 'std::min'? 8 | printf("%d\n", max(0, max(a, b)-min(a, b)-w)); | ^~~ | std::min /usr/include/c++/14/bits/stl_algobase.h:281:5: note: 'std::min' declared here 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ a.cc:8:18: error: 'max' was not declared in this scope; did you mean 'std::max'? 8 | printf("%d\n", max(0, max(a, b)-min(a, b)-w)); | ^~~ | std::max /usr/include/c++/14/bits/stl_algobase.h:303:5: note: 'std::max' declared here 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~
s721983430
p03778
C++
k#include <bits/stdc++.h> using namespace std; int main() { int W, a, b; cin >> W >> a >> b; if (a < b) { if (b - (a + W) <= 0) cout << 0 << endl; else cout << b - (a + W) << endl; } else { if (a - (b + W) <= 0) cout << 0 << endl; else cout << a - (b + W) << endl; } }
a.cc:1:2: error: stray '#' in program 1 | k#include <bits/stdc++.h> | ^ a.cc:1:1: error: 'k' does not name a type 1 | k#include <bits/stdc++.h> | ^ a.cc: In function 'int main()': a.cc:7:3: error: 'cin' was not declared in this scope 7 | cin >> W >> a >> b; | ^~~ a.cc:11:7: error: 'cout' was not declared in this scope 11 | cout << 0 << endl; | ^~~~ a.cc:11:20: error: 'endl' was not declared in this scope 11 | cout << 0 << endl; | ^~~~ a.cc:13:7: error: 'cout' was not declared in this scope 13 | cout << b - (a + W) << endl; | ^~~~ a.cc:13:30: error: 'endl' was not declared in this scope 13 | cout << b - (a + W) << endl; | ^~~~ a.cc:18:7: error: 'cout' was not declared in this scope 18 | cout << 0 << endl; | ^~~~ a.cc:18:20: error: 'endl' was not declared in this scope 18 | cout << 0 << endl; | ^~~~ a.cc:20:7: error: 'cout' was not declared in this scope 20 | cout << a - (b + W) << endl; | ^~~~ a.cc:20:30: error: 'endl' was not declared in this scope 20 | cout << a - (b + W) << endl; | ^~~~
s449918950
p03778
C++
#include <bits/stdc++.h> int main(void){ int w, a, b; cin >> w >> a >> b; cout << a + w - b << endl; return 0; }
a.cc: In function 'int main()': a.cc:5:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 5 | cin >> w >> a >> b; | ^~~ | std::cin In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146, from a.cc:1: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:6:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 6 | cout << a + w - b << endl; | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ a.cc:6:24: error: 'endl' was not declared in this scope; did you mean 'std::endl'? 6 | cout << a + w - b << endl; | ^~~~ | std::endl In file included from /usr/include/c++/14/istream:41, from /usr/include/c++/14/sstream:40, from /usr/include/c++/14/complex:45, from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127: /usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here 744 | endl(basic_ostream<_CharT, _Traits>& __os) | ^~~~
s693273623
p03778
C++
#include<bits/stdc++.h> using namespace std; int main(){ int w,a,b,d; cin>>w>>a>>b; if(w<b&&w<a){ d=b-(a+w); cout<<d; } else if(w>b&&w>a){ d=a-(b+w); cout<<d; else if(w==b) cout<<"0"; } else cout<<"0"; }
a.cc: In function 'int main()': a.cc:13:9: error: expected '}' before 'else' 13 | else if(w==b) | ^~~~ a.cc:10:26: note: to match this '{' 10 | else if(w>b&&w>a){ | ^ a.cc: At global scope: a.cc:16:1: error: expected unqualified-id before 'else' 16 | else | ^~~~ a.cc:18:9: error: expected declaration before '}' token 18 | } | ^
s931004638
p03778
C++
#include<iostream> using namespace std; int main(){ int w,a,b; cin>>w>>a>>b; if(b>a){ if(w>=b||w==a) cout<<"0"; else cout<<b-(a+w); } else if(a>b){ if(w>=a||W==b) cout<<"0"; else cout<<a-(b+w); } }
a.cc: In function 'int main()': a.cc:13:42: error: 'W' was not declared in this scope 13 | if(w>=a||W==b) | ^
s877784881
p03778
C++
#include<iostram> using namespace std; int main(){ int w,a,b; cin>>w>>a>>b; if(b>a+w) cout<<b-(a+w); else if(a+w>b) cout<<a-(b+w); else if (a=b) cout<<"0"; }
a.cc:1:9: fatal error: iostram: No such file or directory 1 | #include<iostram> | ^~~~~~~~~ compilation terminated.
s323044374
p03778
C++
#include<bits/stdc++.h> using namespace std; int main(){ int a,b,m,w; scanf("%d%d%d",&m,&a,&b); if(b>(a+m)){ w=b-(a+m); } else if(a>(b+m)){ w=a-(b+m); } else w=0; printf("%d",w)
a.cc: In function 'int main()': a.cc:14:22: error: expected ';' at end of input 14 | printf("%d",w) | ^ | ; a.cc:14:22: error: expected '}' at end of input a.cc:3:11: note: to match this '{' 3 | int main(){ | ^
s362828296
p03778
C++
#include<bits/stdc++.h> using namespace std; int main(){ int a,b,w,c=0; scanf("%d%d%d",&a,&w,&b); if(b>a+w)){ c=b-(a+w); printf("%d",c); } else if(a>(w+b)){ c=a-(w+b); printf("%D",c); } else printf("%d",c); }
a.cc: In function 'int main()': a.cc:7:10: error: expected primary-expression before ')' token 7 | if(b>a+w)){ | ^
s835561377
p03778
C++
#include <iostream> using namespace std; int main(){ int a,w,b; cin>>a>>w>>b; if((a>=0)&&(W>=0)&&(b>=0)){ if(b>(a+w)){ cout<<b-(a+w); } if((b<=(a+w))&&(b>=a)){ cout<<"0"; } if((b+w)<a) { cout<<a-(b+w); }}}
a.cc: In function 'int main()': a.cc:6:13: error: 'W' was not declared in this scope 6 | if((a>=0)&&(W>=0)&&(b>=0)){ | ^
s168694903
p03778
C++
#include <iostream> using namespace std; int main(){ int a,W,b; cin>>a>>W>>b; if((a>=0)&&(b>=0)&&(W>=0){ if(b>(a+w)){ cout<<b-(a+W); } if((b<=(a+W))&&(b>=a)){ cout<<"0"; } if((b+W)<a) { cout<<a-(b+W); }}}
a.cc: In function 'int main()': a.cc:6:26: error: expected ')' before '{' token 6 | if((a>=0)&&(b>=0)&&(W>=0){ | ~ ^ | ) a.cc:16:3: error: expected primary-expression before '}' token 16 | }}} | ^
s231459289
p03778
C++
#include <iostream> using namespace std; int main(){ int a,w,b; cin>>a>>w>>b; if((a<b)&&(b<(a+w))){ cout<<"0"; } if((b<a)&&((b<(a+w))) {cout<<a-b; } if(b>(a+w)) { cout<<b-(a+w); } }
a.cc: In function 'int main()': a.cc:10:22: error: expected ')' before '{' token 10 | if((b<a)&&((b<(a+w))) | ~ ^ | ) 11 | {cout<<a-b; | ~ a.cc:17:1: error: expected primary-expression before '}' token 17 | } | ^
s152314980
p03778
C++
#include <iostream> using namespace std; int main(){ int a,w,b; cin>>a>>w>>b; if((a<b)&&((b<(a+w))){ cout<<"0"; } if((b<a)&&((b<(a+w))) {cout<<a-b; } if(b>(a+w)) { cout<<b-(a+w); } }
a.cc: In function 'int main()': a.cc:6:22: error: expected ')' before '{' token 6 | if((a<b)&&((b<(a+w))){ | ~ ^ | ) a.cc:17:1: error: expected primary-expression before '}' token 17 | } | ^
s848561107
p03778
C++
#include <iostream> using namespace std; int main(){ int a,w,b; cin>>a>>w>>b; if(a==b){ cout<<"0"; } if(b<a) {cout<<a-b; } if(a<b) { cout<<b-(a+w); } } }
a.cc:21:2: error: expected declaration before '}' token 21 | } | ^
s966246324
p03778
C++
// o #include <iostream> using namespace std; int main(){ char a,b; cin>>a>>b; if((a=='H')&&(b=='H')) { cout<<"H"; } if((a=='D')&&(b=='D')){ cout<<"H"; } if(((a=='H')&&(b=='D'))|| ((a=='D')&&(b=='H'))){ cout<<"D"; } }
a.cc:2:21: warning: extra tokens at end of #include directive 2 | #include <iostream> using namespace std; int main(){ char a,b; cin>>a>>b; if((a=='H')&&(b=='H')) { cout<<"H"; } if((a=='D')&&(b=='D')){ cout<<"H"; } if(((a=='H')&&(b=='D'))|| ((a=='D')&&(b=='H'))){ cout<<"D"; } } | ^~~~~ /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s601215683
p03778
C++
#include<bits/stdc++.h> using namespace std; int main(){ int a; int b, , w ,d ; scanf("%d%d%d",&w,&a,&b); if(b>(a+w)) d=b-(a+w); else if(a>b+w) d=a-(b+w); else d=0; printf("%d",d); }
a.cc: In function 'int main()': a.cc:5:16: error: expected unqualified-id before ',' token 5 | int b, , w ,d ; | ^
s828888360
p03778
C++
#include<bits/stdc++.h> using namespace std; int main(){ int a; int b; , w ,d ; scanf("%d%d%d",&w,&a,&b); if(b>(a+w)) d=b-(a+w); else if(a>b+w) d=a-(b+w); else d=0; printf("%d",d); }
a.cc: In function 'int main()': a.cc:5:16: error: expected primary-expression before ',' token 5 | int b; , w ,d ; | ^ a.cc:5:18: error: 'w' was not declared in this scope 5 | int b; , w ,d ; | ^ a.cc:5:21: error: 'd' was not declared in this scope 5 | int b; , w ,d ; | ^
s848144480
p03778
C++
#include<bits/stdc++.h> #include<stdio.h> using namespace std; int main (){ int a,b,w; cin>>w>>a>>b; if (b>a) cout<<abs(b-(a+w))<<endl; else if (a==b) cout<<0<<endl; else if(a+w>=b&&b>a)) cout<<0<<endl; else if(b+w>=a&&b+w<a+w)) cout<<0<<endl; else cout<<abs(a-(b+w))<<endl; return 0; }
a.cc: In function 'int main()': a.cc:11:25: error: expected primary-expression before ')' token 11 | else if(a+w>=b&&b>a)) | ^ a.cc:13:29: error: expected primary-expression before ')' token 13 | else if(b+w>=a&&b+w<a+w)) | ^
s886228425
p03778
C++
AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure: AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.
a.cc:1:1: error: 'AtCoDeer' does not name a type 1 | AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of [0,1] and the horizontal range of [a,a+W], and the second rectangle covers the vertical range of [1,2] and the horizontal range of [b,b+W], as shown in the following figure: | ^~~~~~~~
s445717006
p03778
C++
#include <bits/stdc++.h> using namespace std; int main() { int w,l,a,b,d; scanf("%d %d %d",&w,&a,&b); if(a<b){ l=a+w; d=b-l; if(d>0) printf("%d",d); else printf("0"); } if(a>b){ b=b+w; d=a-b; if(d>0) printf("%d",d); else printf("0"); } if(a==b) printf("0"); return 0; } }
a.cc:28:1: error: expected declaration before '}' token 28 | } | ^
s369056756
p03778
C++
#include <iostream> #include <algorithm> int main(){ int n,a,b; cin >> n >> a >> b; cout << max(min(b-a-n,a-b-n),0) << endl; }
a.cc: In function 'int main()': a.cc:6:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 6 | cin >> n >> a >> b; | ^~~ | std::cin In file included from a.cc:1: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:7:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 7 | cout << max(min(b-a-n,a-b-n),0) << endl; | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ a.cc:7:15: error: 'min' was not declared in this scope; did you mean 'std::min'? 7 | cout << max(min(b-a-n,a-b-n),0) << endl; | ^~~ | std::min In file included from /usr/include/c++/14/algorithm:61, from a.cc:2: /usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ a.cc:7:11: error: 'max' was not declared in this scope; did you mean 'std::max'? 7 | cout << max(min(b-a-n,a-b-n),0) << endl; | ^~~ | std::max /usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ a.cc:7:38: error: 'endl' was not declared in this scope; did you mean 'std::endl'? 7 | cout << max(min(b-a-n,a-b-n),0) << endl; | ^~~~ | std::endl In file included from /usr/include/c++/14/iostream:41: /usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here 744 | endl(basic_ostream<_CharT, _Traits>& __os) | ^~~~
s658624159
p03778
C++
#include<bits/stdc++.h> using namespace std; int main(){ int w,a,b;cin>>w>>a>>b; if(a>b)swap(a,b); cout <<min(b-a-w,0)<<endl; }.
a.cc:8:2: error: expected unqualified-id before '.' token 8 | }. | ^
s943202030
p03778
C++
#include<bits/stdc++.h> using namespaced std; int main(){ int w,a,b;cin>>w>>a>>b; if(a>b)swap(a,b); cout <<min(b-a-w,0)<<endl; }.
a.cc:2:7: error: expected nested-name-specifier before 'namespaced' 2 | using namespaced std; | ^~~~~~~~~~ a.cc: In function 'int main()': a.cc:5:19: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 5 | int w,a,b;cin>>w>>a>>b; | ^~~ | std::cin In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146, from a.cc:1: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:6:10: error: 'swap' was not declared in this scope 6 | if(a>b)swap(a,b); | ^~~~ a.cc:6:10: note: suggested alternatives: In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181: /usr/include/c++/14/bits/regex.h:2230:5: note: 'std::__cxx11::swap' 2230 | swap(match_results<_Bi_iter, _Alloc>& __lhs, | ^~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:61, from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/move.h:226:5: note: 'std::swap' 226 | swap(_Tp& __a, _Tp& __b) | ^~~~ /usr/include/c++/14/bits/move.h:226:5: note: 'std::swap' In file included from /usr/include/c++/14/exception:166, from /usr/include/c++/14/stdexcept:38, from /usr/include/c++/14/system_error:43, from /usr/include/c++/14/bits/ios_base.h:46, from /usr/include/c++/14/streambuf:43, from /usr/include/c++/14/bits/streambuf_iterator.h:35, from /usr/include/c++/14/iterator:66, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54: /usr/include/c++/14/bits/exception_ptr.h:229:5: note: 'std::__exception_ptr::swap' 229 | swap(exception_ptr& __lhs, exception_ptr& __rhs) | ^~~~ In file included from /usr/include/c++/14/filesystem:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:200: /usr/include/c++/14/bits/fs_path.h:736:15: note: 'std::filesystem::__cxx11::swap' 736 | inline void swap(path& __lhs, path& __rhs) noexcept { __lhs.swap(__rhs); } | ^~~~ a.cc:7:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 7 | cout <<min(b-a-w,0)<<endl; | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ a.cc:7:10: error: 'min' was not declared in this scope; did you mean 'std::min'? 7 | cout <<min(b-a-w,0)<<endl; | ^~~ | std::min In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ a.cc:7:24: error: 'endl' was not declared in this scope; did you mean 'std::endl'? 7 | cout <<min(b-a-w,0)<<endl; | ^~~~ | std::endl In file included from /usr/include/c++/14/istream:41, from /usr/include/c++/14/sstream:40, from /usr/include/c++/14/complex:45, from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127: /usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here 744 | endl(basic_ostream<_CharT, _Traits>& __os) | ^~~~ a.cc: At global scope: a.cc:8:2: error: expected unqualified-id before '.' token 8 | }. | ^
s941355819
p03778
C++
#include <bits/stdc++.h> using namespace std; #define ll long long int main(){ cin.tie(0); ios::sync_with_stdio(false); ll w, a, b; cin >> w >> a >> b; cout << min(0, b-(a+w)) << endl; }
a.cc: In function 'int main()': a.cc:11:20: error: no matching function for call to 'min(int, long long int)' 11 | cout << min(0, b-(a+w)) << endl; | ~~~^~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:11:20: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 11 | cout << min(0, b-(a+w)) << endl; | ~~~^~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:11:20: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 11 | cout << min(0, b-(a+w)) << endl; | ~~~^~~~~~~~~~~~
s698909297
p03778
C++
#include <bits/stdc++.h> using namespace std; int main () { int W,a,b; cin>>w>>a>>b; int t=0; if(b>a+w) t=b-a-w; if(a-W<=b<=a+W) t=0; if(b<a-w) t=a-b-w; cout<<t<<endl; }
a.cc: In function 'int main()': a.cc:5:8: error: 'w' was not declared in this scope 5 | cin>>w>>a>>b; int t=0; | ^
s395540017
p03778
C++
#include <bits/stdc++.h> using namespace std; int main () { int W,a,b; cin>>W>>a>>b; int t; if(b>=a+W) t=b-a-W; if(a-W<=b<a+W) t=0; if(b<a-W) t=a-b-W; cout<<t<<endl;
a.cc: In function 'int main()': a.cc:9:17: error: expected '}' at end of input 9 | cout<<t<<endl; | ^ a.cc:3:13: note: to match this '{' 3 | int main () { | ^
s622895746
p03778
C++
#include <bits/stdc++.h> using namespace std; int main () { int W,a,b; cin>>W>>a>>b; int t; if(b>=a+W) t=b-a-W; if(a-W<=b<a+W) t=0; if(b<a-W) t=a-b-W; cout<<t<<endl;
a.cc: In function 'int main()': a.cc:9:17: error: expected '}' at end of input 9 | cout<<t<<endl; | ^ a.cc:3:13: note: to match this '{' 3 | int main () { | ^
s246268281
p03778
C++
#include<iostream> using namespace::std; int main(){ int w,a,b; cin>>w>>a>>b; if(a>b) swap(a,b); cout<<min(b-a-w,0)<<; }
a.cc: In function 'int main()': a.cc:9:23: error: expected primary-expression before ';' token 9 | cout<<min(b-a-w,0)<<; | ^
s209705968
p03778
C++
#include<iostream> using namespace::std; int main(){ int w,a,b; cin>>w>>a>>b; if(a>b) swap(a,b); cout<<min(b+1-a-w,0)<<; }
a.cc: In function 'int main()': a.cc:9:25: error: expected primary-expression before ';' token 9 | cout<<min(b+1-a-w,0)<<; | ^
s309162434
p03778
C++
#include<iostream> #include<algortihm> using namespace std; int main(){ int W,A,B; cin>>W>>A>>B; int a=min(A,B); int b=max(A,B); if(a+W>=b){ cout<<0<<endl; } else{ cout<<b-a-W<<endl; } return 0; }
a.cc:2:9: fatal error: algortihm: No such file or directory 2 | #include<algortihm> | ^~~~~~~~~~~ compilation terminated.
s114586125
p03778
C++
#include <bits/stdc++.h> #include<algorithm> #include<math.h> using namespace std; template <class T> using V = vector<T>; using ll = long long; using db = double; using st = string; using ch = char; using vll = V<ll>; using vpll =V<pair<ll,ll>>; using vst = V<st>; using vdb = V<db>; using vch = V<ch>; #define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++) #define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--) #define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2) #define bgn begin() #define en end() #define SORT(a) sort((a).bgn,(a).en) #define REV(a) reverse((a).bgn,(a).en) #define M(a,b) max(a,b) #define rM(a,b) min(a,b) #define fi first #define se second #define sz size() #define gcd(a,b) __gcd(a,b) #define co(a) cout<<a<<endl; #define ci(a) cin>>a; ll sum(ll n) { ll m=0; FOR(i,0,20){ m+=n%10; n/=10; if(n==0){ break; } } return m; } ll combi(ll n,ll m) { ll ans=1; rFOR(i,n,n-m){ ans*=i; } FOR(i,1,m+1){ ans/=i; } return ans; } ll lcm(ll a,ll b){ ll n; n=a/gcd(a,b)*b; return n; } /****************************************\ | Thank you for viewing my code:) | | Written by RedSpica a.k.a. RanseMirage | | Twitter:@asakaakasaka | \****************************************/ signed main() { ll n,a,b; ci(n>>a>>b); co(max(0,abs(a-b)-n)) }
a.cc: In function 'int main()': a.cc:78:9: error: no matching function for call to 'max(int, long long int)' 78 | co(max(0,abs(a-b)-n)) | ~~~^~~~~~~~~~~~~~ a.cc:32:21: note: in definition of macro 'co' 32 | #define co(a) cout<<a<<endl; | ^ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:78:9: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 78 | co(max(0,abs(a-b)-n)) | ~~~^~~~~~~~~~~~~~ a.cc:32:21: note: in definition of macro 'co' 32 | #define co(a) cout<<a<<endl; | ^ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:78:9: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 78 | co(max(0,abs(a-b)-n)) | ~~~^~~~~~~~~~~~~~ a.cc:32:21: note: in definition of macro 'co' 32 | #define co(a) cout<<a<<endl; | ^
s929216356
p03778
C++
#include <bits/stdc++.h> #include<algorithm> #include<math.h> using namespace std; template <class T> using V = vector<T>; using ll = long long; using db = double; using st = string; using ch = char; using vll = V<ll>; using vpll =V<pair<ll,ll>>; using vst = V<st>; using vdb = V<db>; using vch = V<ch>; #define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++) #define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--) #define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2) #define bgn begin() #define en end() #define SORT(a) sort((a).bgn,(a).en) #define REV(a) reverse((a).bgn,(a).en) #define M(a,b) max(a,b) #define rM(a,b) min(a,b) #define fi first #define se second #define sz size() #define gcd(a,b) __gcd(a,b) #define co(a) cout<<a<<endl; #define ci(a) cin>>a; ll sum(ll n) { ll m=0; FOR(i,0,20){ m+=n%10; n/=10; if(n==0){ break; } } return m; } ll combi(ll n,ll m) { ll ans=1; rFOR(i,n,n-m){ ans*=i; } FOR(i,1,m+1){ ans/=i; } return ans; } ll lcm(ll a,ll b){ ll n; n=a/gcd(a,b)*b; return n; } /****************************************\ | Thank you for viewing my code:) | | Written by RedSpica a.k.a. RanseMirage | | Twitter:@asakaakasaka | \****************************************/ signed main() { ll n,a,b; ci(n>>a>>b); co(M(0,abs(a-b)-n)) }
a.cc: In function 'int main()': a.cc:26:19: error: no matching function for call to 'max(int, long long int)' 26 | #define M(a,b) max(a,b) | ~~~^~~~~ a.cc:32:21: note: in definition of macro 'co' 32 | #define co(a) cout<<a<<endl; | ^ a.cc:78:6: note: in expansion of macro 'M' 78 | co(M(0,abs(a-b)-n)) | ^ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:26:19: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 26 | #define M(a,b) max(a,b) | ~~~^~~~~ a.cc:32:21: note: in definition of macro 'co' 32 | #define co(a) cout<<a<<endl; | ^ a.cc:78:6: note: in expansion of macro 'M' 78 | co(M(0,abs(a-b)-n)) | ^ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:26:19: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 26 | #define M(a,b) max(a,b) | ~~~^~~~~ a.cc:32:21: note: in definition of macro 'co' 32 | #define co(a) cout<<a<<endl; | ^ a.cc:78:6: note: in expansion of macro 'M' 78 | co(M(0,abs(a-b)-n)) | ^
s229026682
p03778
C++
#include <bits/stdc++.h> #include<algorithm> #include<math.h> using namespace std; template <class T> using V = vector<T>; using ll = long long; using db = double; using st = string; using ch = char; using vll = V<ll>; using vpll =V<pair<ll,ll>>; using vst = V<st>; using vdb = V<db>; using vch = V<ch>; #define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++) #define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--) #define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2) #define bgn begin() #define en end() #define SORT(a) sort((a).bgn,(a).en) #define REV(a) reverse((a).bgn,(a).en) #define M(a,b) max(a,b) #define rM(a,b) min(a,b) #define fi first #define se second #define sz size() #define gcd(a,b) __gcd(a,b) #define co(a) cout<<a<<endl; #define ci(a) cin>>a; ll sum(ll n) { ll m=0; FOR(i,0,20){ m+=n%10; n/=10; if(n==0){ break; } } return m; } ll combi(ll n,ll m) { ll ans=1; rFOR(i,n,n-m){ ans*=i; } FOR(i,1,m+1){ ans/=i; } return ans; } ll lcm(ll a,ll b){ ll n; n=a/gcd(a,b)*b; return n; } /****************************************\ | Thank you for viewing my code:) | | Written by RedSpica a.k.a. RanseMirage | | Twitter:@asakaakasaka | \****************************************/ signed main() { ll n,a,b; ci(n>>a>>b); co(M(0,abs(a-b)-n) }
a.cc:79:7: error: unterminated argument list invoking macro "co" 79 | } | ^ a.cc: In function 'int main()': a.cc:78:3: error: 'co' was not declared in this scope 78 | co(M(0,abs(a-b)-n) | ^~ a.cc:78:5: error: expected '}' at end of input 78 | co(M(0,abs(a-b)-n) | ^ a.cc:75:15: note: to match this '{' 75 | signed main() { | ^
s954417171
p03778
C++
#include <bits/stdc++.h> #include<algorithm> #include<math.h> using namespace std; template <class T> using V = vector<T>; using ll = long long; using db = double; using st = string; using ch = char; using vll = V<ll>; using vpll =V<pair<ll,ll>>; using vst = V<st>; using vdb = V<db>; using vch = V<ch>; #define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++) #define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--) #define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2) #define bgn begin() #define en end() #define SORT(a) sort((a).bgn,(a).en) #define REV(a) reverse((a).bgn,(a).en) #define M(a,b) max(a,b) #define rM(a,b) min(a,b) #define fi first #define se second #define sz size() #define gcd(a,b) __gcd(a,b) #define co(a) cout<<a<<endl; #define ci(a) cin>>a; ll sum(ll n) { ll m=0; FOR(i,0,20){ m+=n%10; n/=10; if(n==0){ break; } } return m; } ll combi(ll n,ll m) { ll ans=1; rFOR(i,n,n-m){ ans*=i; } FOR(i,1,m+1){ ans/=i; } return ans; } ll lcm(ll a,ll b){ ll n; n=a/gcd(a,b)*b; return n; } /****************************************\ | Thank you for viewing my code:) | | Written by RedSpica a.k.a. RanseMirage | | Twitter:@asakaakasaka | \****************************************/ signed main() { ll n,a,b; ci(n>>a>>b); co(M(0,M(a,b)-rM(a,b)+n)) }
a.cc: In function 'int main()': a.cc:26:19: error: no matching function for call to 'max(int, long long int)' 26 | #define M(a,b) max(a,b) | ~~~^~~~~ a.cc:32:21: note: in definition of macro 'co' 32 | #define co(a) cout<<a<<endl; | ^ a.cc:78:6: note: in expansion of macro 'M' 78 | co(M(0,M(a,b)-rM(a,b)+n)) | ^ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:26:19: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 26 | #define M(a,b) max(a,b) | ~~~^~~~~ a.cc:32:21: note: in definition of macro 'co' 32 | #define co(a) cout<<a<<endl; | ^ a.cc:78:6: note: in expansion of macro 'M' 78 | co(M(0,M(a,b)-rM(a,b)+n)) | ^ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:26:19: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 26 | #define M(a,b) max(a,b) | ~~~^~~~~ a.cc:32:21: note: in definition of macro 'co' 32 | #define co(a) cout<<a<<endl; | ^ a.cc:78:6: note: in expansion of macro 'M' 78 | co(M(0,M(a,b)-rM(a,b)+n)) | ^
s721667855
p03778
C++
#include <bits/stdc++.h> #include<algorithm> #include<math.h> using namespace std; template <class T> using V = vector<T>; using ll = long long; using db = double; using st = string; using ch = char; using vll = V<ll>; using vpll =V<pair<ll,ll>>; using vst = V<st>; using vdb = V<db>; using vch = V<ch>; #define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++) #define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--) #define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2) #define bgn begin() #define en end() #define SORT(a) sort((a).bgn,(a).en) #define REV(a) reverse((a).bgn,(a).en) #define M(a,b) max(a,b) #define rM(a,b) min(a,b) #define fi first #define se second #define sz size() #define gcd(a,b) __gcd(a,b) #define co(a) cout<<a<<endl; #define ci(a) cin>>a; ll sum(ll n) { ll m=0; FOR(i,0,20){ m+=n%10; n/=10; if(n==0){ break; } } return m; } ll combi(ll n,ll m) { ll ans=1; rFOR(i,n,n-m){ ans*=i; } FOR(i,1,m+1){ ans/=i; } return ans; } ll lcm(ll a,ll b){ ll n; n=a/gcd(a,b)*b; return n; } /****************************************\ | Thank you for viewing my code:) | | Written by RedSpica a.k.a. RanseMirage | | Twitter:@asakaakasaka | \****************************************/ signed main() { ll n,a,b; ci(n>>a>>b); co(M(0,M(a,b)-rM(a,b)+n) }
a.cc:79:7: error: unterminated argument list invoking macro "co" 79 | } | ^ a.cc: In function 'int main()': a.cc:78:3: error: 'co' was not declared in this scope 78 | co(M(0,M(a,b)-rM(a,b)+n) | ^~ a.cc:78:5: error: expected '}' at end of input 78 | co(M(0,M(a,b)-rM(a,b)+n) | ^ a.cc:75:15: note: to match this '{' 75 | signed main() { | ^
s157527862
p03778
C++
#include <iostrem> using namespace std; int main(void){ int w,a,b; cin >> w >> a >> b; if(a + w < b) cout << b - a - w << endl; else if(b + w < a) cout << a - b - w << endl; else cout << 0 << endl; return 0; }
a.cc:1:10: fatal error: iostrem: No such file or directory 1 | #include <iostrem> | ^~~~~~~~~ compilation terminated.
s767334384
p03778
C
#include<stdio.h> int main(){ int w,a,b; scanf("%d %d %d",&w,&a,&b); if(a+w<b){ printf("%d",b-(a+w)); } else if(a+w>=b&&a=<b){ printf("%d",0); } else{ printf("%d",a-(b+w)); } return 0; }
main.c: In function 'main': main.c:8:21: error: expected expression before '<' token 8 | else if(a+w>=b&&a=<b){ | ^
s297237198
p03778
C
#include<stdio.h> int main(){ int d,a,b; scanf("%d %d %d",&w,&a,&b); if(a+w<b){ printf("%d",b-(a+w)); } else if(a+w>b&&a<b){ printf("%d",0); } else{ printf("%d",a-(b+w)); } printf("%d "); }
main.c: In function 'main': main.c:4:23: error: 'w' undeclared (first use in this function) 4 | scanf("%d %d %d",&w,&a,&b); | ^ main.c:4:23: note: each undeclared identifier is reported only once for each function it appears in
s435356797
p03778
C
#include<stdio.h> int main(){ int d,a,b; scanf("%d %d %d",w,a,b); if(a+w<b){ printf("%d",b-(a+w)); } else if(a+w>b&&a<b){ printf("%d",0); } else{ printf("%d",a-(b+w)); } printf("%d "); }
main.c: In function 'main': main.c:4:22: error: 'w' undeclared (first use in this function) 4 | scanf("%d %d %d",w,a,b); | ^ main.c:4:22: note: each undeclared identifier is reported only once for each function it appears in
s620180130
p03778
C++
#include<bits/stdc++.h> using namespace std; int main(){ int w=0; int a=0; int b=0; scanf("%d %d %d", &w,&a,&b); int min=min(a, b); int max=max(a+w,b+w); if (max-min>2*w){ printf("%d", max-min-2*w); } else{ printf("0"); } }
a.cc: In function 'int main()': a.cc:8:16: error: 'min' cannot be used as a function 8 | int min=min(a, b); | ~~~^~~~~~ a.cc:9:16: error: 'max' cannot be used as a function 9 | int max=max(a+w,b+w); | ~~~^~~~~~~~~
s202862393
p03778
C++
#include<iostream> using namespace std; int main() { int W,A,B; cin << W << A << B; if(A < B) { cout << B - A <<endl; } else { cout << A - B << endl; } }
a.cc: In function 'int main()': a.cc:6:7: error: no match for 'operator<<' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'int') 6 | cin << W << A << B; | ~~~ ^~ ~ | | | | | int | std::istream {aka std::basic_istream<char>} a.cc:6:7: note: candidate: 'operator<<(int, int)' (built-in) 6 | cin << W << A << B; | ~~~~^~~~ a.cc:6:7: note: no known conversion for argument 1 from 'std::istream' {aka 'std::basic_istream<char>'} to 'int' In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/string_view:763:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, basic_string_view<_CharT, _Traits>)' 763 | operator<<(basic_ostream<_CharT, _Traits>& __os, | ^~~~~~~~ /usr/include/c++/14/string_view:763:5: note: template argument deduction/substitution failed: a.cc:6:10: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 6 | cin << W << A << B; | ^ /usr/include/c++/14/bits/basic_string.h:4077:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 4077 | operator<<(basic_ostream<_CharT, _Traits>& __os, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:4077:5: note: template argument deduction/substitution failed: a.cc:6:10: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 6 | cin << W << A << B; | ^ In file included from /usr/include/c++/14/bits/memory_resource.h:38, from /usr/include/c++/14/string:68: /usr/include/c++/14/cstddef:125:5: note: candidate: 'template<class _IntegerType> constexpr std::__byte_op_t<_IntegerType> std::operator<<(byte, _IntegerType)' 125 | operator<<(byte __b, _IntegerType __shift) noexcept | ^~~~~~~~ /usr/include/c++/14/cstddef:125:5: note: template argument deduction/substitution failed: a.cc:6:3: note: cannot convert 'std::cin' (type 'std::istream' {aka 'std::basic_istream<char>'}) to type 'std::byte' 6 | cin << W << A << B; | ^~~ In file included from /usr/include/c++/14/bits/ios_base.h:46: /usr/include/c++/14/system_error:339:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const error_code&)' 339 | operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e) | ^~~~~~~~ /usr/include/c++/14/system_error:339:5: note: template argument deduction/substitution failed: a.cc:6:10: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 6 | cin << W << A << B; | ^ /usr/include/c++/14/ostream:563:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, _CharT)' 563 | operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c) | ^~~~~~~~ /usr/include/c++/14/ostream:563:5: note: template argument deduction/substitution failed: a.cc:6:10: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 6 | cin << W << A << B; | ^ /usr/include/c++/14/ostream:573:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, char)' 573 | operator<<(basic_ostream<_CharT, _Traits>& __out, char __c) | ^~~~~~~~ /usr/include/c++/14/ostream:573:5: note: template argument deduction/substitution failed: a.cc:6:10: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 6 | cin << W << A << B; | ^ /usr/include/c++/14/ostream:579:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, char)' 579 | operator<<(basic_ostream<char, _Traits>& __out, char __c) | ^~~~~~~~ /usr/include/c++/14/ostream:579:5: note: template argument deduction/substitution failed: a.cc:6:10: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 6 | cin << W << A << B; | ^ /usr/include/c++/14/ostream:590:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, signed char)' 590 | operator<<(basic_ostream<char, _Traits>& __out, signed char __c) | ^~~~~~~~ /usr/include/c++/14/ostream:590:5: note: template argument deduction/substitution failed: a.cc:6:10: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 6 | cin << W << A << B; | ^ /usr/include/c++/14/ostream:595:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, unsigned char)' 595 | operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c) | ^~~~~~~~ /usr/include/c++/14/ostream:595:5: note: template argument deduction/substitution failed: a.cc:6:10: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 6 | cin << W << A << B; | ^ /usr/include/c++/14/ostream:654:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const _CharT*)' 654 | operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s) | ^~~~~~~~ /usr/include/c++/14/ostream:654:5: note: template argument deduction/substitution failed: a.cc:6:10: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 6 | cin << W << A << B; | ^ In file included from /usr/include/c++/14/ostream:1022: /usr/include/c++/14/bits/ostream.tcc:307:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const char*)' 307 | operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s) | ^~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:307:5: note: template argument deduction/substitution failed: a.cc:6:10: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 6 | cin << W << A << B; | ^ /usr/include/c++/14/ostream:671:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, const char*)' 671 | operator<<(basic_ostream<char, _Traits>& __out, const char* __s) | ^~~~~~~~ /usr/include/c++/14/ostream:671:5: note: template argument deduction/substitution failed: a.cc:6:10: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 6 | cin << W << A << B; | ^ /usr/include/c++/14/ostream:684:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, const signed char*)' 684 | operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s) | ^~~~~~~~ /usr/include/c++/14/ostream:684:5: note: template argument deduction/substitution failed: a.cc:6:10: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 6 | cin << W << A << B; | ^ /usr/include/c++/14/ostream:689:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, const unsigned char*)' 689 | operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s) | ^~~~~~~~ /usr/include/c++/14/ostream:689:5: note: template argument deduction/substitution failed: a.cc:6:10: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 6 | cin << W << A << B; | ^ /usr/include/c++/14/ostream:810:5: note: candidate: 'template<class _Ostream, class _Tp> _Ostream&& std::operator<<(_Ostream&&, const _Tp&)' 810 | operator<<(_Ostream&& __os, const _Tp& __x) | ^~~~~~~~ /usr/include/c++/14/ostream:810:5: note: template argument deduction/substitution failed: /usr/include/c++/14/ostream: In substitution of 'template<class _Ostream, class _Tp> _Ostream&& std::operator<<(_Ostream&&, const _Tp&) [with _Ostream = std::basic_istream<char>&; _Tp = int]': a.cc:6:10: required from here 6 | cin << W << A << B; | ^ /usr/include/c++/14/ostream:810:5: error: no type named 'type' in 'struct std::enable_if<false, void>' 810 | operator<<(_Ostream&& __os, const _Tp& __x) | ^~~~~~~~
s310726106
p03778
C++
#include <iostream> #include <sstream> #include <cstdio> #include <cstdlib> #include <cmath> #include <ctime> #include <cstring> #include <string> #include <vector> #include <stack> #include <queue> #include <deque> #include <map> #include <set> #include <bitset> #include <numeric> #include <utility> #include <iomanip> #include <algorithm> #include <functional> #include <unordered_map> using namespace std; #define REP(i, s) for (int i = 0; i < s; ++i) #define ALL(v) (v.begin(), v.end()) #define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl #define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i) template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) { return s << '<' << P.first << ", " << P.second << '>'; } template<class T> ostream& operator << (ostream &s, vector<T> P) { for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; } template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) { for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; } template<class T> ostream& operator << (ostream &s, set<T> P) { EACH(it, P) { s << "<" << *it << "> "; } return s << endl; } template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) { EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; } typedef long long ll; #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) int main() { int w,a,b; cin>>w>>a>>b; cout<<min(abs(b-(a+w)),abs(a-(b+w)),(abs(a-b)))<<endl; return 0; }
In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare) [with _Tp = int; _Compare = int]': a.cc:51:13: required from here 51 | cout<<min(abs(b-(a+w)),abs(a-(b+w)),(abs(a-b)))<<endl; | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:284:17: error: '__comp' cannot be used as a function 284 | if (__comp(__b, __a)) | ~~~~~~^~~~~~~~~~
s372105885
p03778
C++
#include <bits/stdc++.h> using namespace std; using llong = long long; using P = pair<llong, llong>; #define BE(x) x.begin(), x.end() const llong inf = llong(1e18)+7; const llong mod = 1e9+7; int main(){ int w,a,b; cin >> w >> a >> b; cout << min(max(inf, b-a-w), max(inf,a-b-w)) << endl; return 0; }
a.cc: In function 'int main()': a.cc:16:24: error: no matching function for call to 'max(const llong&, int)' 16 | cout << min(max(inf, b-a-w), max(inf,a-b-w)) << endl; | ~~~^~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:16:24: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 16 | cout << min(max(inf, b-a-w), max(inf,a-b-w)) << endl; | ~~~^~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:16:24: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 16 | cout << min(max(inf, b-a-w), max(inf,a-b-w)) << endl; | ~~~^~~~~~~~~~~~ a.cc:16:41: error: no matching function for call to 'max(const llong&, int)' 16 | cout << min(max(inf, b-a-w), max(inf,a-b-w)) << endl; | ~~~^~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:16:41: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 16 | cout << min(max(inf, b-a-w), max(inf,a-b-w)) << endl; | ~~~^~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:16:41: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 16 | cout << min(max(inf, b-a-w), max(inf,a-b-w)) << endl; | ~~~^~~~~~~~~~~
s271896213
p03778
C++
#include<iostream> using namespace std; //const int mod = 1e9 + 7; int main(){ long long w a,b; cin>>w>>a>>b; if(b>a+w) cout<<b-(a+w)<<endl; else if(b+w<a) cout<<a-(b+w)<<endl; else cout<<"0"<<endl; return 0; }
a.cc: In function 'int main()': a.cc:6:14: error: expected initializer before 'a' 6 | long long w a,b; | ^ a.cc:7:7: error: 'w' was not declared in this scope 7 | cin>>w>>a>>b; | ^ a.cc:7:10: error: 'a' was not declared in this scope 7 | cin>>w>>a>>b; | ^ a.cc:7:13: error: 'b' was not declared in this scope 7 | cin>>w>>a>>b; | ^
s876856448
p03778
C++
#include<iostream> #include<string> #include<vector> #include<iomanip> #include<algorithm> #include<queue> #include<stack> #include<map> using namespace std; #define ll long long int main(){ ll w,a,b; cin >> w >> a >> b; ll t; if(b<a){ t=a; a=b; b=t; } cout << max(b-a-w,0); return 0; }
a.cc: In function 'int main()': a.cc:20:16: error: no matching function for call to 'max(long long int, int)' 20 | cout << max(b-a-w,0); | ~~~^~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:20:16: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 20 | cout << max(b-a-w,0); | ~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:5: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:20:16: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 20 | cout << max(b-a-w,0); | ~~~^~~~~~~~~
s972940898
p03778
C
#include <stdio.h> int main(){ int w,a,b; scanf("%d %d %d",&w,&a,&b); if(b-(a+w)<=0&&a<=b){{ printf("0"); }else if(a>b){ printf("%d",a-(b+w)); }else{ printf("%d",b-(a+w)); } return 0; }
main.c: In function 'main': main.c:7:6: error: expected '}' before 'else' 7 | }else if(a>b){ | ^~~~
s448476438
p03778
C++
//============================================================================ #include<bits/stdc++.h> typedef long long ll; #define rep(i, n) for(ll i = 0; i < (n); i++) using namespace std; int main(){ int w,a,b; cout << a < b ? max(0,b - a - w) : max(0,a - b - w) << endl; }
a.cc: In function 'int main()': a.cc:9:19: error: no match for 'operator<' (operand types are 'std::basic_ostream<char>' and 'int') 9 | cout << a < b ? max(0,b - a - w) : max(0,a - b - w) << endl; | ~~~~~~~~~ ^ ~ | | | | | int | std::basic_ostream<char> a.cc:9:19: note: candidate: 'operator<(int, int)' (built-in) 9 | cout << a < b ? max(0,b - a - w) : max(0,a - b - w) << endl; | ~~~~~~~~~~^~~ a.cc:9:19: note: no known conversion for argument 1 from 'std::basic_ostream<char>' to 'int' In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181, from a.cc:2: /usr/include/c++/14/bits/regex.h:1143:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1143 | operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1143:5: note: template argument deduction/substitution failed: a.cc:9:21: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 9 | cout << a < b ? max(0,b - a - w) : max(0,a - b - w) << endl; | ^ /usr/include/c++/14/bits/regex.h:1224:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1224 | operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1224:5: note: template argument deduction/substitution failed: a.cc:9:21: note: 'std::basic_ostream<char>' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' 9 | cout << a < b ? max(0,b - a - w) : max(0,a - b - w) << endl; | ^ /usr/include/c++/14/bits/regex.h:1317:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1317 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1317:5: note: template argument deduction/substitution failed: a.cc:9:21: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 9 | cout << a < b ? max(0,b - a - w) : max(0,a - b - w) << endl; | ^ /usr/include/c++/14/bits/regex.h:1391:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1391 | operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1391:5: note: template argument deduction/substitution failed: a.cc:9:21: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int' 9 | cout << a < b ? max(0,b - a - w) : max(0,a - b - w) << endl; | ^ /usr/include/c++/14/bits/regex.h:1485:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1485 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1485:5: note: template argument deduction/substitution failed: a.cc:9:21: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 9 | cout << a < b ? max(0,b - a - w) : max(0,a - b - w) << endl; | ^ /usr/include/c++/14/bits/regex.h:1560:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1560 | operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1560:5: note: template argument deduction/substitution failed: a.cc:9:21: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int' 9 | cout << a < b ? max(0,b - a - w) : max(0,a - b - w) << endl; | ^ /usr/include/c++/14/bits/regex.h:1660:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1660 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1660:5: note: template argument deduction/substitution failed: a.cc:9:21: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 9 | cout << a < b ? max(0,b - a - w) : max(0,a - b - w) << endl; | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: a.cc:9:21: note: 'std::basic_ostream<char>' is not derived from 'const std::pair<_T1, _T2>' 9 | cout << a < b ? max(0,b - a - w) : max(0,a - b - w) << endl; | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: a.cc:9:21: note: 'std::basic_ostream<char>' is not derived from 'const std::reverse_iterator<_Iterator>' 9 | cout << a < b ? max(0,b - a - w) : max(0,a - b - w) << endl; | ^ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: a.cc:9:21: note: 'std::basic_ostream<char>' is not derived from 'const std::reverse_iterator<_Iterator>' 9 | cout << a < b ? max(0,b - a - w) : max(0,a - b - w) << endl; | ^ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed: a.cc:9:21: note: 'std::basic_ostream<char>' is not derived from 'const std::move_iterator<_IteratorL>' 9 | cout << a < b ? max(0,b - a - w) : max(0,a - b - w) << endl; | ^ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1760 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed: a.cc:9:21: note: 'std::basic_ostream<char>' is not derived from 'const std::move_iterator<_IteratorL>' 9 | cout << a < b ? max(0,b - a - w) : max(0,a - b - w) << endl; | ^ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 673 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed: a.cc:9:21: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 9 | cout << a < b ? max(0,b - a - w) : max(0,a - b - w) << endl; | ^ /usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 680 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed: a.cc:9:21: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 9 | cout << a < b ? max(0,b - a - w) : max(0,a - b - w) << endl; | ^ /usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:688:5: note: template argument deduction/substitution failed: a.cc:9:21: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int' 9 | cout <<
s802325987
p03778
C++
//============================================================================ #include<bits/stdc++.h> typedef long long ll; #define rep(i, n) for(ll i = 0; i < (n); i++) using namespace std; int main(){ int w,a,b; cout << a < b ? max(0,b - a + w) : max(0,a - b - w) << endl; }
a.cc: In function 'int main()': a.cc:9:19: error: no match for 'operator<' (operand types are 'std::basic_ostream<char>' and 'int') 9 | cout << a < b ? max(0,b - a + w) : max(0,a - b - w) << endl; | ~~~~~~~~~ ^ ~ | | | | | int | std::basic_ostream<char> a.cc:9:19: note: candidate: 'operator<(int, int)' (built-in) 9 | cout << a < b ? max(0,b - a + w) : max(0,a - b - w) << endl; | ~~~~~~~~~~^~~ a.cc:9:19: note: no known conversion for argument 1 from 'std::basic_ostream<char>' to 'int' In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181, from a.cc:2: /usr/include/c++/14/bits/regex.h:1143:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1143 | operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1143:5: note: template argument deduction/substitution failed: a.cc:9:21: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 9 | cout << a < b ? max(0,b - a + w) : max(0,a - b - w) << endl; | ^ /usr/include/c++/14/bits/regex.h:1224:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1224 | operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1224:5: note: template argument deduction/substitution failed: a.cc:9:21: note: 'std::basic_ostream<char>' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' 9 | cout << a < b ? max(0,b - a + w) : max(0,a - b - w) << endl; | ^ /usr/include/c++/14/bits/regex.h:1317:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1317 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1317:5: note: template argument deduction/substitution failed: a.cc:9:21: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 9 | cout << a < b ? max(0,b - a + w) : max(0,a - b - w) << endl; | ^ /usr/include/c++/14/bits/regex.h:1391:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1391 | operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1391:5: note: template argument deduction/substitution failed: a.cc:9:21: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int' 9 | cout << a < b ? max(0,b - a + w) : max(0,a - b - w) << endl; | ^ /usr/include/c++/14/bits/regex.h:1485:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1485 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1485:5: note: template argument deduction/substitution failed: a.cc:9:21: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 9 | cout << a < b ? max(0,b - a + w) : max(0,a - b - w) << endl; | ^ /usr/include/c++/14/bits/regex.h:1560:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1560 | operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1560:5: note: template argument deduction/substitution failed: a.cc:9:21: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int' 9 | cout << a < b ? max(0,b - a + w) : max(0,a - b - w) << endl; | ^ /usr/include/c++/14/bits/regex.h:1660:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1660 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1660:5: note: template argument deduction/substitution failed: a.cc:9:21: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 9 | cout << a < b ? max(0,b - a + w) : max(0,a - b - w) << endl; | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: a.cc:9:21: note: 'std::basic_ostream<char>' is not derived from 'const std::pair<_T1, _T2>' 9 | cout << a < b ? max(0,b - a + w) : max(0,a - b - w) << endl; | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: a.cc:9:21: note: 'std::basic_ostream<char>' is not derived from 'const std::reverse_iterator<_Iterator>' 9 | cout << a < b ? max(0,b - a + w) : max(0,a - b - w) << endl; | ^ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: a.cc:9:21: note: 'std::basic_ostream<char>' is not derived from 'const std::reverse_iterator<_Iterator>' 9 | cout << a < b ? max(0,b - a + w) : max(0,a - b - w) << endl; | ^ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed: a.cc:9:21: note: 'std::basic_ostream<char>' is not derived from 'const std::move_iterator<_IteratorL>' 9 | cout << a < b ? max(0,b - a + w) : max(0,a - b - w) << endl; | ^ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1760 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed: a.cc:9:21: note: 'std::basic_ostream<char>' is not derived from 'const std::move_iterator<_IteratorL>' 9 | cout << a < b ? max(0,b - a + w) : max(0,a - b - w) << endl; | ^ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 673 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed: a.cc:9:21: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 9 | cout << a < b ? max(0,b - a + w) : max(0,a - b - w) << endl; | ^ /usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 680 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed: a.cc:9:21: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 9 | cout << a < b ? max(0,b - a + w) : max(0,a - b - w) << endl; | ^ /usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:688:5: note: template argument deduction/substitution failed: a.cc:9:21: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int' 9 | cout <<
s530406797
p03778
C
#include <stdio.h> #include <stdlib.h> int main (){ int a,b,c; scanf ("%d%d%d",&a,&b,&c); k= abs( b-c ); if (a>k){ printf ("%d",a-k); } else{ printf ("0"); } return 0; }
main.c: In function 'main': main.c:6:1: error: 'k' undeclared (first use in this function) 6 | k= abs( b-c ); | ^ main.c:6:1: note: each undeclared identifier is reported only once for each function it appears in
s663594539
p03778
C
#include <stdio.h> #include <stdlib.h> int main (){ int a,b,c; scanf ("%d%d%d",&a,&b,&c); k= abs(b-c); if (a>k){ printf ("%d",a-k); } else{ printf ("0"); } return 0; }
main.c: In function 'main': main.c:6:1: error: 'k' undeclared (first use in this function) 6 | k= abs(b-c); | ^ main.c:6:1: note: each undeclared identifier is reported only once for each function it appears in
s407954163
p03778
C++
#inlude <bits/stdc++.h> using namespace std; int main(){ int w,a,b; cin >> w >> a >> b; if(a > b){ int temp = a; a = b; b = temp; } int answer = b -(a + w); if(answer < 0) answer = 0; cout << answer << endl; }
a.cc:1:2: error: invalid preprocessing directive #inlude; did you mean #include? 1 | #inlude <bits/stdc++.h> | ^~~~~~ | include a.cc: In function 'int main()': a.cc:5:3: error: 'cin' was not declared in this scope 5 | cin >> w >> a >> b; | ^~~ a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' +++ |+#include <iostream> 1 | #inlude <bits/stdc++.h> a.cc:13:3: error: 'cout' was not declared in this scope 13 | cout << answer << endl; | ^~~~ a.cc:13:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:13:21: error: 'endl' was not declared in this scope 13 | cout << answer << endl; | ^~~~ a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' +++ |+#include <ostream> 1 | #inlude <bits/stdc++.h>
s932156179
p03778
C++
#ifdef LOCAL #include <cstdio> #include <vector> #include <algorithm> #include <iostream> #include <cstring> #else #include <bits/stdc++.h> #endif using namespace std ; typedef long long ll ; #define rep(i , n ) for ( int i =0; i < n ; i++) #define _sort(arg) sort(begin(arg), end(arg)) #define MOD 1000000007 #define pb push_back #define DEBUG(x) cout << #x << ": " << x << endl; /* __attribute__((constructor)) void initial() { cin.tie(NULL); ios::sync_with_stdio(false); } */ int main() { cin.tie(NULL); ios::sync_with_stdio(false); int W, a, b; cin >> W >> a >> b; if (a >= b + W) { cout << a - b - W << endl; } else if (a + w <= b) { cout << b- a - w << endl; } else { cout << 0 << endl; } return 0; }
a.cc: In function 'int main()': a.cc:41:22: error: 'w' was not declared in this scope 41 | else if (a + w <= b) | ^
s429369993
p03778
C++
#include <bits/stdc++.h> using namespace std; #define int long long #define otp(n) cout << n; #define ct(n) cout << n << endl; #define cts(n) cout << n << " "; #define cte cout << endl; #define ctv(v) rep(i,(v).size()) otp(v[i]) cte #define rep(i,n) for(int i=0;i<n;i++) #define rep1(i,n) for(int i=1;i<=n;i++) #define repo(i,o,n) for(int i=o;i<n;i++) #define repm(i,n) for(int i=n-1;i>=0;i--) #define repv(i,v) for(int i=0;i<(v).size();i++) #define all(v) (v).begin(),(v).end() #define rall(v) (v).rbegin(),(v).rend() #define sperase(v,n) (v).erase(remove(all(v), n), (v).end()); #define vdelete(v) (v).erase(unique(all(v)), (v).end()); #define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2))); #define pb(n) push_back(n); int w,a,b; main() { cin >> w >> a >> b; if (a>w+b) { ct(a-w-b)1 } else { ct(max((long long)0,b-w-a)) } }
a.cc:24:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 24 | main() { | ^~~~ a.cc: In function 'int main()': a.cc:27:19: error: expected ';' before '}' token 27 | ct(a-w-b)1 | ^ | ; 28 | } else { | ~
s679317777
p03778
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define debug(x) cerr << x << "\n" #define all(x) (x).begin(),(x).end() #define exist(s, e)((s).find(e) != (s).end()) int main(){ cin.tie(0); ios::sync_with_stdio(false); int w, a, b; cin >> w >> a >> b; if (a+W < b) cout << b - (a+W) << '\n'; else if (b+W < a) cout << a - (b+W) << '\n';) else cout << "0\n"; return 0; }
a.cc: In function 'int main()': a.cc:17:11: error: 'W' was not declared in this scope 17 | if (a+W < b) cout << b - (a+W) << '\n'; | ^ a.cc:18:49: error: expected primary-expression before ')' token 18 | else if (b+W < a) cout << a - (b+W) << '\n';) | ^
s920964788
p03778
C++
#include<bits/stdc++.h> using namespace std; int main(){ int w,a,b; cin>>w>>a>>b; if(abs(b-a)<=w){ cout<<0; return 0; } cout<<abs(b-a)-w; return 0;
a.cc: In function 'int main()': a.cc:12:18: error: expected '}' at end of input 12 | return 0; | ^ a.cc:4:11: note: to match this '{' 4 | int main(){ | ^
s457989027
p03778
C++
#include<bits/stdc++.h> using namespace std; int main(){ int w,a,b; cin>>w>>a>>b; if(abs(b-a)<=w){ cout<<0; return 0; } cout<<abs(b-a)-w; return 0;
a.cc: In function 'int main()': a.cc:12:18: error: expected '}' at end of input 12 | return 0; | ^ a.cc:4:11: note: to match this '{' 4 | int main(){ | ^
s760272431
p03778
C++
#include<bits/stdc++.h> using namespace std; int main(){ int a,b,w; cin>>a>>b; if(abs(a-b)<=w) cout<<0<<endl; else cout<<abs(a-b)<=w<<endl; return 0; }
a.cc: In function 'int main()': a.cc:7:31: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<' 7 | else cout<<abs(a-b)<=w<<endl; | ~^~~~~~
s941890782
p03778
C++
#include<bits/stdc++.h> using namespace std; int main(){ int a,b,w; cin>>a>>b; if(abs(a-b)<=w) cout<<0<<endl; else cout<<abs(a-b)<=w<<endl; return 0; }
a.cc: In function 'int main()': a.cc:7:31: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<' 7 | else cout<<abs(a-b)<=w<<endl; | ~^~~~~~
s407429444
p03778
C++
#include<bits/stdc++.h> using namespace std; int main(){ int a,b,w; cin>>a>>b; if(abs(b-a)<=w) cout<<0<<endl; else cout<<abs(b-a)<=w<<endl; return 0; }
a.cc: In function 'int main()': a.cc:7:31: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<' 7 | else cout<<abs(b-a)<=w<<endl; | ~^~~~~~