Two problems, two containers
set answers "have I seen this before?" It stores unique values with no duplicates.
map answers "what value goes with this key?" It stores key-value pairs, keys unique.
Both come in two flavours, and choosing wrongly is a common reason a correct solution times out.
set: unique values
#include <iostream>
#include <set>
using namespace std;
int main() {
set<int> s;
s.insert(40);
s.insert(10);
s.insert(30);
s.insert(10); // duplicate, ignored
cout << s.size() << "\n"; // 3
for (int x : s) cout << x << " ";
cout << "\n"; // 10 30 40, always sorted