#define PROBLEM "https://judge.yosupo.jp/problem/associative_array"
#include"../../../utilities/fast_io.hpp"#include<bits/stdc++.h>usingnamespacestd;usingll=longlong;#include"../../../ds/hash_table/hash_map.hpp"intmain(){m1une::utilities::FastInputfast_input;m1une::utilities::FastOutputfast_output;intQ;fast_input>>Q;m1une::ds::HashMap<ll,ll>mp;while(Q--){intt;fast_input>>t;if(t==0){llk,v;fast_input>>k>>v;mp[k]=v;}else{llk;fast_input>>k;fast_output<<mp[k]<<'\n';}}}
#line 1 "verify/ds/hash_table/hash_map_associative_array.test.cpp"
#define PROBLEM "https://judge.yosupo.jp/problem/associative_array"
#line 1 "utilities/fast_io.hpp"
#include<algorithm>
#include<array>
#include<cerrno>
#include<charconv>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstdint>
#include<cstring>
#include<iterator>
#include<string>
#include<sys/stat.h>
#include<type_traits>
#include<utility>
#include<unistd.h>
#include<vector>namespacem1une{namespaceutilities{structFastOutput;namespaceinternal{// Shared with the convenience helpers in template.hpp.inlineFastOutput*standard_output_instance=nullptr;// Detect std::begin(x), std::end(x).template<classT,class=void>structis_range:std::false_type{};template<classT>structis_range<T,std::void_t<decltype(std::begin(std::declval<T&>())),decltype(std::end(std::declval<T&>()))>>:std::true_type{};template<classT>inlineconstexprboolis_range_v=is_range<T>::value;template<classT>usingrange_reference_t=decltype(*std::begin(std::declval<T&>()));template<classT>usingrange_value_t=std::remove_cv_t<std::remove_reference_t<range_reference_t<T>>>;template<classT,class=void>structrange_stored_value{usingtype=range_value_t<T>;};template<classT>structrange_stored_value<T,std::void_t<typenamestd::remove_cv_t<std::remove_reference_t<T>>::value_type>>{usingtype=typenamestd::remove_cv_t<std::remove_reference_t<T>>::value_type;};template<classT>usingrange_stored_value_t=typenamerange_stored_value<T>::type;// Treat strings and C strings as scalar output objects, not as ranges.template<classT>structis_char_array:std::false_type{};template<classT,std::size_tN>structis_char_array<T[N]>:std::bool_constant<std::is_same_v<std::remove_cv_t<T>,char>>{};template<classT>structis_string_like:std::bool_constant<std::is_same_v<std::decay_t<T>,std::string>||std::is_same_v<std::decay_t<T>,constchar*>||std::is_same_v<std::decay_t<T>,char*>||is_char_array<std::remove_reference_t<T>>::value>{};template<classT>inlineconstexprboolis_string_like_v=is_string_like<T>::value;// ModInt-like type: x.val() is printable, and x can be assigned from long long.template<classT,class=void>structhas_val_method:std::false_type{};template<classT>structhas_val_method<T,std::void_t<decltype(std::declval<constT&>().val())>>:std::true_type{};template<classT>inlineconstexprboolhas_val_method_v=has_val_method<T>::value;template<classT,class=void>structhas_static_mod_raw:std::false_type{};template<classT>structhas_static_mod_raw<T,std::void_t<decltype(T::mod()),decltype(T::raw(std::declval<uint32_t>()))>>:std::true_type{};template<classT>inlineconstexprboolhas_static_mod_raw_v=has_static_mod_raw<T>::value;// libstdc++ before GCC 16 does not classify __int128 as an integral type in// strict ISO modes such as -std=c++23. Keep the fast-I/O interface independent// of that implementation detail.template<classT>inlineconstexprboolis_integral_v=std::is_integral_v<T>||std::is_same_v<std::remove_cv_t<T>,__int128_t>||std::is_same_v<std::remove_cv_t<T>,__uint128_t>;template<classT>inlineconstexprboolis_signed_v=std::is_signed_v<T>||std::is_same_v<std::remove_cv_t<T>,__int128_t>;template<classT>structmake_unsigned{usingtype=std::make_unsigned_t<T>;};template<>structmake_unsigned<__int128_t>{usingtype=__uint128_t;};template<>structmake_unsigned<__uint128_t>{usingtype=__uint128_t;};template<classT>usingmake_unsigned_t=typenamemake_unsigned<std::remove_cv_t<T>>::type;}// namespace internalstructFastInput{staticconstexprintbuffer_size=1<<20;private:std::FILE*_stream;char_buffer[buffer_size];int_position;int_length;int_file_descriptor;bool_streaming;boolrefill(){_position=0;if(_streaming){ssize_tlength;do{length=::read(_file_descriptor,_buffer,buffer_size);}while(length<0&&errno==EINTR);if(length<=0){_length=0;returnfalse;}_length=int(length);}else{_length=int(std::fread(_buffer,1,buffer_size,_stream));}return_length!=0;}template<classT>boolread_integer_from_stream(T&value){if(!skip_spaces())returnfalse;intc=read_char_raw();boolnegative=false;if(c=='-'){negative=true;c=read_char_raw();}ifconstexpr(internal::is_signed_v<T>){Tresult=0;while('0'<=c&&c<='9'){result=negative?result*10-(c-'0'):result*10+(c-'0');c=read_char_raw();}value=result;}else{Tresult=0;while('0'<=c&&c<='9'){result=result*10+T(c-'0');c=read_char_raw();}value=negative?T(0)-result:result;}returntrue;}boolprepare_number(){if(_length-_position>=64)returntrue;constintremaining=_length-_position;if(remaining>0)std::memmove(_buffer,_buffer+_position,remaining);constintadded=int(std::fread(_buffer+remaining,1,buffer_size-remaining,_stream));_position=0;_length=remaining+added;if(_length<buffer_size)_buffer[_length]='\0';return_length!=0;}public:explicitFastInput(std::FILE*stream=stdin):_stream(stream),_position(0),_length(0),_file_descriptor(::fileno(stream)),_streaming([&]{structstatstatus;return_file_descriptor>=0&&::fstat(_file_descriptor,&status)==0&&!S_ISREG(status.st_mode);}()){}FastInput(constFastInput&)=delete;FastInput&operator=(constFastInput&)=delete;intread_char_raw(){if(_position==_length&&!refill())returnEOF;return_buffer[_position++];}boolskip_spaces(){intc=read_char_raw();while(c!=EOF&&c<=' ')c=read_char_raw();if(c==EOF)returnfalse;--_position;returntrue;}boolread(char&value){if(!skip_spaces())returnfalse;value=char(read_char_raw());returntrue;}boolread(std::string&value){if(!skip_spaces())returnfalse;value.clear();while(true){constintbegin=_position;while(_position<_length&&static_cast<unsignedchar>(_buffer[_position])>' '){++_position;}value.append(_buffer+begin,_position-begin);if(_position<_length){++_position;returntrue;}if(!refill())returntrue;}}boolread(bool&value){intx;if(!read(x))returnfalse;value=x!=0;returntrue;}template<classT>std::enable_if_t<internal::is_integral_v<T>&&!std::is_same_v<std::remove_cv_t<T>,bool>&&!std::is_same_v<std::remove_cv_t<T>,char>,bool>read(T&value){if(_streaming)returnread_integer_from_stream(value);if(!prepare_number())returnfalse;intc=static_cast<unsignedchar>(_buffer[_position++]);while(c<=' ')c=static_cast<unsignedchar>(_buffer[_position++]);boolnegative=false;if(c=='-'){negative=true;c=static_cast<unsignedchar>(_buffer[_position++]);}ifconstexpr(internal::is_signed_v<T>){Tresult=0;while('0'<=c&&c<='9'){constintfirst=c-'0';constintsecond=static_cast<unsignedchar>(_buffer[_position])-'0';if(0<=second&&second<=9){result=negative?result*100-(first*10+second):result*100+(first*10+second);++_position;}else{result=negative?result*10-first:result*10+first;}c=static_cast<unsignedchar>(_buffer[_position++]);}value=result;}else{Tresult=0;while('0'<=c&&c<='9'){constunsignedfirst=unsigned(c-'0');constintsecond=static_cast<unsignedchar>(_buffer[_position])-'0';if(0<=second&&second<=9){result=result*100+T(first*10+unsigned(second));++_position;}else{result=result*10+T(first);}c=static_cast<unsignedchar>(_buffer[_position++]);}value=negative?T(0)-result:result;}if(_position>_length)_position=_length;returntrue;}template<classT>std::enable_if_t<std::is_floating_point_v<T>,bool>read(T&value){if(!skip_spaces())returnfalse;intc=read_char_raw();boolnegative=false;if(c=='-'||c=='+'){negative=c=='-';c=read_char_raw();}longdoubleresult=0;while('0'<=c&&c<='9'){result=result*10+(c-'0');c=read_char_raw();}if(c=='.'){longdoubleplace=0.1L;c=read_char_raw();while('0'<=c&&c<='9'){result+=(c-'0')*place;place*=0.1L;c=read_char_raw();}}if(c=='e'||c=='E'){c=read_char_raw();boolexponent_negative=false;if(c=='-'||c=='+'){exponent_negative=c=='-';c=read_char_raw();}intexponent=0;while('0'<=c&&c<='9'){exponent=exponent*10+(c-'0');c=read_char_raw();}longdoublescale=1;longdoublepower=10;while(exponent>0){if(exponent&1)scale*=power;power*=power;exponent>>=1;}result=exponent_negative?result/scale:result*scale;}value=static_cast<T>(negative?-result:result);returntrue;}template<classT>std::enable_if_t<internal::has_val_method_v<T>&&!internal::is_integral_v<T>&&!internal::is_range_v<T>,bool>read(T&value){longlongx;if(!read(x))returnfalse;ifconstexpr(internal::has_static_mod_raw_v<T>){if(x>=0&&uint64_t(x)<uint64_t(T::mod())){value=T::raw(uint32_t(x));}else{value=T(x);}}else{value=T(x);}returntrue;}template<classFirst,classSecond>boolread(std::pair<First,Second>&value){if(!read(value.first))returnfalse;returnread(value.second);}template<classRange>std::enable_if_t<internal::is_range_v<Range>&&!internal::is_string_like_v<Range>,bool>read(Range&range){usingStoredValue=internal::range_stored_value_t<Range>;constexprboolnested=internal::is_range_v<StoredValue>&&!internal::is_string_like_v<StoredValue>;for(auto&&value:range){ifconstexpr(std::is_same_v<StoredValue,bool>&&!nested){boolx;if(!read(x))returnfalse;value=x;}else{if(!read(value))returnfalse;}}returntrue;}template<classFirst,classSecond,class...Rest>boolread(First&first,Second&second,Rest&...rest){if(!read(first))returnfalse;returnread(second,rest...);}template<classT>FastInput&operator>>(T&value){if(!read(value))std::abort();return*this;}};structFastOutput{staticconstexprintbuffer_size=1<<20;private:inlinestaticconstautodigit_quads=[]{std::array<char,40000>result{};for(inti=0;i<10000;i++){intvalue=i;for(intj=3;j>=0;j--){result[4*i+j]=char('0'+value%10);value/=10;}}returnresult;}();std::FILE*_stream;char_buffer[buffer_size];int_position;int_precision;std::chars_format_float_format;char_range_separator;std::string*_capture=nullptr;template<classT>std::stringformat_cell(constT&value){std::stringresult;structCaptureGuard{std::string*⌖std::string*previous;~CaptureGuard(){target=previous;}}guard{_capture,_capture};_capture=&result;write(value);returnresult;}template<classMatrix>voidwrite_aligned_matrix(constMatrix&matrix){std::vector<std::vector<std::string>>rows;std::vector<std::size_t>widths;for(constauto&row:matrix){auto&cells=rows.emplace_back();std::size_tcolumn=0;for(constauto&value:row){cells.push_back(format_cell(value));if(column==widths.size())widths.push_back(0);widths[column]=std::max(widths[column],cells.back().size());++column;}}boolfirst=true;for(constauto&row:rows){if(!first)write_char('\n');first=false;for(std::size_tcolumn=0;column<row.size();++column){if(column!=0)write_char(_range_separator);for(std::size_tpadding=row[column].size();padding<widths[column];++padding){write_char(' ');}write(row[column]);}}}public:explicitFastOutput(std::FILE*stream=stdout):_stream(stream),_position(0),_precision(6),_float_format(std::chars_format::general),_range_separator(' '){if(_stream==stdout&&internal::standard_output_instance==nullptr){internal::standard_output_instance=this;}}FastOutput(constFastOutput&)=delete;FastOutput&operator=(constFastOutput&)=delete;~FastOutput(){flush();if(internal::standard_output_instance==this){internal::standard_output_instance=nullptr;}}voidflush(){if(_position!=0){std::fwrite(_buffer,1,_position,_stream);_position=0;}std::fflush(_stream);}voidwrite_char(charc){if(_capture!=nullptr){_capture->push_back(c);return;}if(_position==buffer_size)flush();_buffer[_position++]=c;}voidwrite(constchar*s){while(*s!='\0')write_char(*s++);}voidwrite(conststd::string&s){if(_capture!=nullptr){_capture->append(s);return;}std::size_tposition=0;while(position<s.size()){if(_position==buffer_size)flush();conststd::size_tcopied=std::min<std::size_t>(buffer_size-_position,s.size()-position);std::memcpy(_buffer+_position,s.data()+position,copied);_position+=int(copied);position+=copied;}}voidwrite(charc){write_char(c);}voidwrite(boolvalue){write_char(value?'1':'0');}template<classT>std::enable_if_t<std::is_floating_point_v<T>>write(Tvalue){chardigits[128];auto[end,error]=std::to_chars(digits,digits+sizeof(digits),value,_float_format,_precision);if(error!=std::errc())std::abort();for(constchar*pointer=digits;pointer!=end;pointer++){write_char(*pointer);}}template<classT>std::enable_if_t<internal::is_integral_v<T>&&!std::is_same_v<std::remove_cv_t<T>,bool>&&!std::is_same_v<std::remove_cv_t<T>,char>>write(Tvalue){usingRaw=std::remove_cv_t<T>;usingUnsigned=internal::make_unsigned_t<Raw>;Unsignedmagnitude;ifconstexpr(internal::is_signed_v<Raw>){if(value<0){write_char('-');magnitude=Unsigned(0)-Unsigned(value);}else{magnitude=Unsigned(value);}}else{magnitude=value;}if(magnitude==0){write_char('0');return;}unsignedchunks[16];intcount=0;while(magnitude>=10000){constUnsignedquotient=magnitude/10000;chunks[count++]=unsigned(magnitude-quotient*10000);magnitude=quotient;}if(_capture==nullptr&&_position>buffer_size-64)flush();charcaptured[64];char*constbegin=_capture!=nullptr?captured:_buffer+_position;char*destination=begin;constunsignedleading=unsigned(magnitude);constchar*first=digit_quads.data()+4*leading;intskip=leading<10?3:leading<100?2:leading<1000?1:0;for(;skip<4;skip++)*destination++=first[skip];while(count--){constchar*digits=digit_quads.data()+4*chunks[count];std::memcpy(destination,digits,4);destination+=4;}if(_capture!=nullptr){_capture->append(begin,destination-begin);}else{_position+=int(destination-begin);}}template<classT>std::enable_if_t<internal::has_val_method_v<T>&&!internal::is_integral_v<T>&&!internal::is_range_v<T>>write(constT&value){write(value.val());}template<classFirst,classSecond>voidwrite(conststd::pair<First,Second>&value){write(value.first);write_char(' ');write(value.second);}template<classRange>std::enable_if_t<internal::is_range_v<Range>&&!internal::is_string_like_v<Range>>write(constRange&range){usingStoredValue=internal::range_stored_value_t<constRange>;constexprboolnested=internal::is_range_v<StoredValue>&&!internal::is_string_like_v<StoredValue>;boolfirst=true;for(constauto&value:range){if(!first)write_char(nested?'\n':_range_separator);first=false;ifconstexpr(std::is_same_v<StoredValue,bool>&&!nested){write(static_cast<bool>(value));}else{write(value);}}}template<classFirst,class...Rest>voidprint(constFirst&first,constRest&...rest){write(first);((write_char(' '),write(rest)),...);}voidprintln(){write_char('\n');}voidset_precision(intprecision){_precision=precision;}voidset_fixed(intprecision=6){_float_format=std::chars_format::fixed;_precision=precision;}voidset_general(intprecision=6){_float_format=std::chars_format::general;_precision=precision;}voidset_range_separator(charseparator){_range_separator=separator;}template<classMatrix>voidwrite_aligned(constMatrix&matrix){usingRow=internal::range_stored_value_t<constMatrix>;usingCell=internal::range_stored_value_t<constRow>;static_assert(internal::is_range_v<Row>&&!internal::is_string_like_v<Row>,"write_aligned requires a two-dimensional range");static_assert(!internal::is_range_v<Cell>||internal::is_string_like_v<Cell>,"write_aligned requires scalar cells");write_aligned_matrix(matrix);}template<classMatrix>voidprintln_aligned(constMatrix&matrix){write_aligned(matrix);write_char('\n');}template<class...Args>voidprintln(constArgs&...args){print(args...);write_char('\n');}template<classT>FastOutput&operator<<(constT&value){write(value);return*this;}};}// namespace utilities}// namespace m1une#line 4 "verify/ds/hash_table/hash_map_associative_array.test.cpp"
#include<bits/stdc++.h>usingnamespacestd;usingll=longlong;#line 1 "ds/hash_table/hash_map.hpp"
#line 1 "ds/hash_table/hash_common.hpp"
#line 11 "ds/hash_table/hash_common.hpp"
namespacem1une{namespaceds{namespacedetail{inlinestd::uint64_tsplitmix64(std::uint64_tx){x+=0x9e3779b97f4a7c15;x=(x^(x>>30))*0xbf58476d1ce4e5b9;x=(x^(x>>27))*0x94d049bb133111eb;returnx^(x>>31);}template<typenameKey,typenameHash>std::size_tmixed_hash(constKey&key,constHash&hash){staticconststd::uint64_tfixed_random=std::chrono::steady_clock::now().time_since_epoch().count();returnstatic_cast<std::size_t>(splitmix64(static_cast<std::uint64_t>(hash(key))+fixed_random));}inlinestd::size_tbit_ceil(std::size_tn){std::size_tresult=1;while(result<n)result<<=1;returnresult;}inlinestd::size_tbucket_count_for(std::size_texpected_size){returnbit_ceil(std::max<std::size_t>(16,expected_size*10/7+1));}template<typenameT>structSlot{alignas(T)unsignedcharstorage[sizeof(T)];T*ptr(){returnstd::launder(reinterpret_cast<T*>(storage));}constT*ptr()const{returnstd::launder(reinterpret_cast<constT*>(storage));}template<typename...Args>voidconstruct(Args&&...args){::new(static_cast<void*>(storage))T(std::forward<Args>(args)...);}voiddestroy(){ifconstexpr(!std::is_trivially_destructible_v<T>){ptr()->~T();}}};}// namespace detail}// namespace ds}// namespace m1une#line 5 "ds/hash_table/hash_map.hpp"
#line 9 "ds/hash_table/hash_map.hpp"
#include<initializer_list>
#line 13 "ds/hash_table/hash_map.hpp"
namespacem1une{namespaceds{template<typenameKey,typenameT,typenameHash=std::hash<Key>,typenameKeyEqual=std::equal_to<Key>>structHashMap{private:structNode{Keykey;Tvalue;template<typenameK,typenameV>Node(K&&node_key,V&&node_value):key(std::forward<K>(node_key)),value(std::forward<V>(node_value)){}};staticconstexprunsignedcharEMPTY=0;staticconstexprunsignedcharDELETED=1;staticconstexprstd::size_tnpos=static_cast<std::size_t>(-1);std::vector<unsignedchar>ctrl;std::vector<detail::Slot<Node>>data;std::size_t_size=0;std::size_t_deleted=0;Hashhasher;KeyEqualkey_equal;std::size_tmask()const{returnctrl.size()-1;}std::size_tmake_hash(constKey&key)const{returndetail::mixed_hash(key,hasher);}staticunsignedcharfingerprint(std::size_th){returnstatic_cast<unsignedchar>(2+(h>>(sizeof(std::size_t)*8-7)));}staticbooloccupied(unsignedcharc){returnc>=2;}Node*node_at(std::size_ti){returndata[i].ptr();}constNode*node_at(std::size_ti)const{returndata[i].ptr();}voiddestroy_all(){for(std::size_ti=0;i<ctrl.size();i++){if(occupied(ctrl[i]))data[i].destroy();}}voidreset(std::size_tbucket_count){destroy_all();bucket_count=detail::bit_ceil(std::max<std::size_t>(16,bucket_count));ctrl.assign(bucket_count,EMPTY);data.clear();data.resize(bucket_count);_size=0;_deleted=0;}std::size_tfind_index_with_hash(constKey&key,std::size_th)const{constunsignedcharfp=fingerprint(h);std::size_ti=h&mask();while(true){constunsignedcharc=ctrl[i];if(c==EMPTY)returnnpos;if(c==fp&&key_equal(node_at(i)->key,key))returni;i=(i+1)&mask();}}std::size_tfind_index(constKey&key)const{returnfind_index_with_hash(key,make_hash(key));}voidinsert_existing(Node&&node,std::size_th){std::size_ti=h&mask();while(occupied(ctrl[i]))i=(i+1)&mask();ctrl[i]=fingerprint(h);data[i].construct(std::move(node));_size++;}voidrebuild(std::size_tbucket_count){std::vector<unsignedchar>old_ctrl=std::move(ctrl);std::vector<detail::Slot<Node>>old_data=std::move(data);ctrl.clear();data.clear();bucket_count=detail::bit_ceil(std::max<std::size_t>(16,bucket_count));ctrl.assign(bucket_count,EMPTY);data.resize(bucket_count);_size=0;_deleted=0;for(std::size_ti=0;i<old_ctrl.size();i++){if(occupied(old_ctrl[i])){Node*node=old_data[i].ptr();insert_existing(std::move(*node),make_hash(node->key));old_data[i].destroy();}}}voidensure_for_insert(){conststd::size_tused=_size+_deleted;if((used+1)*10>=ctrl.size()*7){rebuild(ctrl.size()*2);}elseif(_deleted>_size&&(_size+1)*10<ctrl.size()*7){rebuild(ctrl.size());}}template<typenameK,typenameV>std::pair<T*,bool>insert_impl(K&&key,V&&value){ensure_for_insert();conststd::size_th=make_hash(key);constunsignedcharfp=fingerprint(h);std::size_tfirst_deleted=npos;std::size_ti=h&mask();while(true){constunsignedcharc=ctrl[i];if(occupied(c)){Node*node=node_at(i);if(c==fp&&key_equal(node->key,key))return{&node->value,false};}elseif(c==DELETED){if(first_deleted==npos)first_deleted=i;}else{conststd::size_tpos=first_deleted==npos?i:first_deleted;if(first_deleted!=npos)_deleted--;ctrl[pos]=fp;data[pos].construct(std::forward<K>(key),std::forward<V>(value));_size++;return{&node_at(pos)->value,true};}i=(i+1)&mask();}}public:HashMap():hasher(Hash()),key_equal(KeyEqual()){reset(16);}explicitHashMap(std::size_treserve_count,Hashhash_fn=Hash(),KeyEqualequal_fn=KeyEqual()):hasher(std::move(hash_fn)),key_equal(std::move(equal_fn)){reset(detail::bucket_count_for(reserve_count));}HashMap(std::initializer_list<std::pair<Key,T>>init,Hashhash_fn=Hash(),KeyEqualequal_fn=KeyEqual()):HashMap(init.size(),std::move(hash_fn),std::move(equal_fn)){for(constauto&[key,value]:init)insert(key,value);}template<typenameIterator>HashMap(Iteratorfirst,Iteratorlast,Hashhash_fn=Hash(),KeyEqualequal_fn=KeyEqual()):HashMap(0,std::move(hash_fn),std::move(equal_fn)){while(first!=last){insert(first->first,first->second);++first;}}HashMap(constHashMap&other):hasher(other.hasher),key_equal(other.key_equal){ctrl.assign(other.ctrl.size(),EMPTY);data.resize(other.data.size());for(std::size_ti=0;i<other.ctrl.size();i++){ctrl[i]=other.ctrl[i];if(occupied(other.ctrl[i]))data[i].construct(other.node_at(i)->key,other.node_at(i)->value);}_size=other._size;_deleted=other._deleted;}HashMap(HashMap&&other)noexcept:ctrl(std::move(other.ctrl)),data(std::move(other.data)),_size(other._size),_deleted(other._deleted),hasher(std::move(other.hasher)),key_equal(std::move(other.key_equal)){other.ctrl.clear();other.data.clear();other._size=0;other._deleted=0;}HashMap&operator=(constHashMap&other){if(this==&other)return*this;HashMapcopy(other);*this=std::move(copy);return*this;}HashMap&operator=(HashMap&&other)noexcept{if(this==&other)return*this;destroy_all();ctrl=std::move(other.ctrl);data=std::move(other.data);_size=other._size;_deleted=other._deleted;hasher=std::move(other.hasher);key_equal=std::move(other.key_equal);other.ctrl.clear();other.data.clear();other._size=0;other._deleted=0;return*this;}~HashMap(){destroy_all();}intsize()const{returnstatic_cast<int>(_size);}boolempty()const{return_size==0;}std::size_tbucket_count()const{returnctrl.size();}doubleload_factor()const{returnstatic_cast<double>(_size)/static_cast<double>(ctrl.size());}voidclear(){reset(ctrl.size());}voidreserve(std::size_tcount){conststd::size_ttarget=detail::bucket_count_for(count);if(target>ctrl.size()||_deleted>0)rebuild(std::max(target,ctrl.size()));}std::pair<T*,bool>insert(constKey&key,constT&value){returninsert_impl(key,value);}std::pair<T*,bool>insert(Key&&key,T&&value){returninsert_impl(std::move(key),std::move(value));}std::pair<T*,bool>insert(conststd::pair<Key,T>&value){returninsert_impl(value.first,value.second);}std::pair<T*,bool>insert(std::pair<Key,T>&&value){returninsert_impl(std::move(value.first),std::move(value.second));}template<typenameV>T*insert_or_assign(constKey&key,V&&value){autoresult=insert_impl(key,std::forward<V>(value));if(!result.second)*result.first=std::forward<V>(value);returnresult.first;}template<typenameV>T*insert_or_assign(Key&&key,V&&value){autoresult=insert_impl(std::move(key),std::forward<V>(value));if(!result.second)*result.first=std::forward<V>(value);returnresult.first;}boolerase(constKey&key){conststd::size_th=make_hash(key);conststd::size_ti=find_index_with_hash(key,h);if(i==npos)returnfalse;data[i].destroy();ctrl[i]=DELETED;_size--;_deleted++;returntrue;}T*find(constKey&key){conststd::size_ti=find_index(key);returni==npos?nullptr:&node_at(i)->value;}constT*find(constKey&key)const{conststd::size_ti=find_index(key);returni==npos?nullptr:&node_at(i)->value;}boolcontains(constKey&key)const{returnfind_index(key)!=npos;}intcount(constKey&key)const{returncontains(key)?1:0;}T&at(constKey&key){T*p=find(key);if(p==nullptr)throwstd::out_of_range("HashMap::at");return*p;}constT&at(constKey&key)const{constT*p=find(key);if(p==nullptr)throwstd::out_of_range("HashMap::at");return*p;}T&operator[](constKey&key){return*insert_impl(key,T()).first;}T&operator[](Key&&key){return*insert_impl(std::move(key),T()).first;}std::vector<std::pair<Key,T>>to_vector()const{std::vector<std::pair<Key,T>>result;result.reserve(_size);for(std::size_ti=0;i<ctrl.size();i++){if(occupied(ctrl[i]))result.emplace_back(node_at(i)->key,node_at(i)->value);}returnresult;}};}// namespace ds}// namespace m1une#line 10 "verify/ds/hash_table/hash_map_associative_array.test.cpp"
intmain(){m1une::utilities::FastInputfast_input;m1une::utilities::FastOutputfast_output;intQ;fast_input>>Q;m1une::ds::HashMap<ll,ll>mp;while(Q--){intt;fast_input>>t;if(t==0){llk,v;fast_input>>k>>v;mp[k]=v;}else{llk;fast_input>>k;fast_output<<mp[k]<<'\n';}}}