Um_nik's blog

By Um_nik, history, 4 days ago, In English

I can sometimes see people doing some CP-related projects for their courses/portfolio/community, and I want to suggest an idea of such a project that would benefit me as a CodeChef Admin and all the problemsetters, I believe.

Issue: There are a lot of problems on different platforms, and it is really hard to check if some problem was already used somewhere or not. Sometimes googling works, but most of the time I have to rely on my own experience and memory, which are far from perfect. It's hard to search for problems, because they usually have some kind of story, and the same problem can be formulated in a lot of different ways.

Proposed solution: Create some kind of smart database, that will collect the problems from all known sources and will have some very smart search engine that would focus on the internal meaning of the problem, instead of how it is formulated.

I have no idea how to do any of that :) I would assume that it would require some kind of very smart ML and a lot of community effort. But I thought that it might be an interesting project for someone and I really hope that it will be done by some amazing person.

Just a database of problems from different sources with any kind of full-text search would also be nice.

I think I'm ready to pay some reasonable money ($1000? I understand that it's small money for a high-level ML person, but I'm not rich) for a well-done job, and maybe we can crowdfund it even more.

 
 
 
 
  • Vote: I like it
  • +443
  • Vote: I do not like it

»
4 days ago, # |
Rev. 3   Vote: I like it -82 Vote: I do not like it

Isn't that against Codeforces policies? Maybe not.

UPD: It seems I'm wrong.

  • »
    »
    4 days ago, # ^ |
      Vote: I like it +82 Vote: I do not like it

    Um... what here can be interpreted as against Codeforces policies? Proposing paid job?

    • »
      »
      »
      4 days ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      I think , It's just a nice project idea comprising of advanced ML & databases!!

»
4 days ago, # |
  Vote: I like it +115 Vote: I do not like it

I would say it's very hard. Even the subproblem to parse two statements and say if they are similar already requires shooting some state-of-the-art cannon at it. Not to mention the software engineering effort required to create such a database of problems...

The only way in which I see it remotely doable, is to manually categorize thousands of problems based on difficulty, algorithms / operations used and give the admin option to search through some problems which roughly fall in the same bucket.

Also, if this tool became publicly available it would have some serious implications for the entire competitive programming...

  • »
    »
    4 days ago, # ^ |
    Rev. 2   Vote: I like it +35 Vote: I do not like it

    Yes, but I thought "shooting some state-of-the-art cannon" is not that hard in ML world, but I know nothing about ML and very much might be wrong. There already were some attempts (actually, let's ping ItsNear) in SOLVING cp problems using ML, categorizing sounds much easier and much more ML-like for me, but again, I know nothing about this field.

    to manually categorize thousands of problems based on difficulty, algorithms / operations used

    We already have huge amounts of data — problemset of CodeForces and other platfroms with manually set tags and editorials.

    • »
      »
      »
      4 days ago, # ^ |
        Vote: I like it +77 Vote: I do not like it

      NEAR failed with that and pivoted. They are now yet another crypto startup.

      • »
        »
        »
        »
        4 days ago, # ^ |
          Vote: I like it +23 Vote: I do not like it

        I know that they are doing blockchain now, my point is that 3 years ago people with some real knowledge in ML tried to do something harder, so maybe it's not that impossible as one might think.

    • »
      »
      »
      4 days ago, # ^ |
        Vote: I like it +31 Vote: I do not like it

      It's a common misconception. Either you can use something fully out-of-the-box, or you're going to suffer some serious pain.

      In the world of transfer learning, you'd start with a huge pretrained model that's capable of doing something (like recognizing objects), and your goal as an ML engineer is to fine-tune it to your application. But this isn't easy in our case, as the ability of reading is insufficient to solve competitive programming problems as I demonstrate by not being red.

      Starting with Codeforces database and our tags, one could create a fairly simple system which searches in some range of problem difficulties for tasks which have the largest number of similar tags. But the sad truth is that 'DP + 2200' is probably not going to be useful to you as a contest admin, because you'd have to manually search through a ton of problems (so the problems would have to be more carefully categorized for it to be useful). For anything beyond that, the difficulty of creating such a system rises exponentially, I'm afraid :(

    • »
      »
      »
      4 days ago, # ^ |
        Vote: I like it -94 Vote: I do not like it

      if you dont know anything about ML then you might need to think twice before suggesting projects related to it

      • »
        »
        »
        »
        3 days ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        and you should think twice before commenting something

        • »
          »
          »
          »
          »
          3 days ago, # ^ |
            Vote: I like it -39 Vote: I do not like it

          oh really. my downvotes are from umnik idol worshippers, not from level headed people

          • »
            »
            »
            »
            »
            »
            2 days ago, # ^ |
              Vote: I like it +42 Vote: I do not like it

            Fun fact: almost every time I have seen someone saying "I got downvoted because X" it's fairly clearly at least partially wrong.

            • »
              »
              »
              »
              »
              »
              »
              2 days ago, # ^ |
                Vote: I like it -24 Vote: I do not like it

              cant resist the need to seek contribution at any opportunity can u

              • »
                »
                »
                »
                »
                »
                »
                »
                2 days ago, # ^ |
                Rev. 2   Vote: I like it +16 Vote: I do not like it

                case in point (more or less).

                A comment that gets about +15 points has basically zero effect on my contribution. So no, I write such comments only because I want to say something.

    • »
      »
      »
      36 hours ago, # ^ |
        Vote: I like it +56 Vote: I do not like it

      One thing we've done back then was pay people to rewrite statements into short mathematical form. I might be able to excavate that dataset.

      On the full descriptions with "Anna was given a string for her birthday" what you want is probably not possible. With short mathematical descriptions something like finding 10 most similar problems could be within reach.

      But to your point, back then we might have been somewhat dilusional about what's possible, so our attempts from 2017 are no indication of what is possible today.

  • »
    »
    4 days ago, # ^ |
    Rev. 3   Vote: I like it +69 Vote: I do not like it

    Maybe it should parse not statements, but solutions. This way no experts are required to manually label problems.

    When statements are similar, problems can still be quite different. However, similar solutions mean similar problems.

»
4 days ago, # |
Rev. 2   Vote: I like it +39 Vote: I do not like it

Something like OEIS for CP-Problems would be really cool!

The defining structure of a problem is some function $$$P$$$ with $$$P(input)=output$$$.

I imagine a database of problems and solutions. We feed it some $$$input$$$ and some $$$output$$$ and it checks and returns all problems $$$P$$$ for which $$$P(input)=output$$$.

Spoiler
  • »
    »
    4 days ago, # ^ |
    Rev. 2   Vote: I like it +11 Vote: I do not like it

    This has a fundamental problem of assuming that the equivalent tasks have the same input and output. I'd say only in few cases it will be true. But predominantly, only the idea to solve it will be the same.

    • »
      »
      »
      4 days ago, # ^ |
      Rev. 3   Vote: I like it +8 Vote: I do not like it

      How do you mean? Do you mean the general formatting of the input and output or do you mean the explicit content of some input and output? The former I agree, that's what I commented in the spoiler. For the latter, I don't propose matching the content of inputs and outputs in the database. I propose a database of functions $$$P$$$ and we check for each $$$P$$$ in the database whether it yields $$$P(input)=output$$$. (Which is of course computation-intensive. But after all, I'm just daydreaming.)

      Or maybe I just misunderstand your concern?

      • »
        »
        »
        »
        4 days ago, # ^ |
          Vote: I like it +5 Vote: I do not like it

        Ah, sorry, I didn't see your spoiler :)

      • »
        »
        »
        »
        4 days ago, # ^ |
          Vote: I like it +5 Vote: I do not like it

        Maybe this is where categorisation can help. You can reduce the computation by tag filtering. Also if someone is trying to steal a problem, they can always shuffle up the input variables. That will be hard to resolve.

  • »
    »
    3 days ago, # ^ |
    Rev. 2   Vote: I like it +34 Vote: I do not like it

    I believe this would be a good way to create the database, and not too difficult to implement well. Indeed, OEIS would be a good model for this project.

    To make the search more efficient, we could also have some canonical inputs, such as some fixed list of numbers for all problems whose input is a list of numbers.

»
4 days ago, # |
Rev. 3   Vote: I like it -114 Vote: I do not like it

are you joking? 1000$?

first of all the projects in nlp are pretty hard and that is why there are lots of companies which pay way way more to help them with nlp problems , and secondly if some one can create such thing why in the world he/she should waste it on CP? you can use such tool for way way more things and become rich. at this point and with the available methods doing this job with 1k$ is just a joke. also just considering required hardware make it even more like a dream.

  • »
    »
    4 days ago, # ^ |
      Vote: I like it +48 Vote: I do not like it

    he is not rich

    • »
      »
      »
      4 days ago, # ^ |
        Vote: I like it -54 Vote: I do not like it

      did i say he is? all i say is just if a person can do it he/she will sell it or use it to build a new platform rather than do it for nothing.

  • »
    »
    4 days ago, # ^ |
      Vote: I like it +51 Vote: I do not like it

    I'm saying that I'm ready to pay $1000 with my own money. Maybe platforms with more funds will also be willing to pay for such a project, I can't say for them.

  • »
    »
    4 days ago, # ^ |
      Vote: I like it +33 Vote: I do not like it

    You can start from simpler things. And no, no one will be doing this for 1k$, you can look at um_nik's offer as some indicator that people need it.

    • »
      »
      »
      4 days ago, # ^ |
        Vote: I like it -45 Vote: I do not like it

      ok i get it, but nlp things apart downloading all the problems and make them search able still worth 1K$ ?

  • »
    »
    4 days ago, # ^ |
      Vote: I like it +45 Vote: I do not like it

    Imaging registering a new account just to critize somebody.

»
4 days ago, # |
Rev. 2   Vote: I like it +17 Vote: I do not like it

If the solutions/submissions are publicly available, I'd bet it's much easier to detect isomorphic AC solutions than the texts. Do we have formal verification experts here?

  • »
    »
    4 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I would prefer not to implement model solution to a problem before approving it, and then I would prefer not to send it to open project for everyone to see.

    • »
      »
      »
      4 days ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      The first issue is a tough one :)

      The second issue can be solved by running the queries locally. Probably even without downloading the whole database, and probably even without having interpretable codes in the database in the first place.

    • »
      »
      »
      25 hours ago, # ^ |
        Vote: I like it +8 Vote: I do not like it

      Ask the problem proposer to write the model solution

»
4 days ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

If some machine can interpret the intrinsic meaning of the problem, then it almost equals to that machine will be able to solve the problem.

Comparing the solutions (source code of different problem statements), I think it will be more feasible.

»
4 days ago, # |
Rev. 2   Vote: I like it +138 Vote: I do not like it

I teach machine learning to undergrad students and I've actually worked in the ranking team of a search engine. I've had a lot of students with CP background, and naturally I tried to nudge them towards picking a CP-related ML course project like this one. This has never worked a single time in 3 years, but I don't lose hope :)

So I've thought about this problem for a while. For a search engine, there are three types of data that can be used:

  • Problem statements are freely available, but I'm fairly certain that using just them won't work, at least not with reasonable accuracy (maybe with a $10M budget for model development and data labeling it will).
  • Short atCoder-style formal statements and editorials may actually work, but they are not always available and in most cases need to be processed by hand.
  • Problem solutions are probably the best approach here as it is fairly easy to check if two programs solve the same or similar problems, and so the search can be done very accurately with the source code instead of the problem statement. I think it is possible to negotiate with main OJ admins to get them (on the terms that they become available to only a limited group of people developing the search engine and not become public).

Creating a model for searching by a solution source should be relatively easy, and what we can do to generalize it to search by a problem statement is to train a separate model that (inaccurately, because the data is scarce) turns a short problem statement into the same vector representation as the average source code of its solution.

In terms of funding, I think it's a bad idea to offer a small amount. In my opinion, the project should be either crowdfunded with a reasonable market-salary budget (in the 10-20k range) or fully crowdsourced (that is, nobody gets paid, but a lot of people need to help with data labeling and other maintenance stuff).

  • »
    »
    4 days ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    it is fairly easy to check if two programs solve the same or similar problems

    Can you point me to some resources or what keywords to google? I only found results that states that the problem is undecidable.

    • »
      »
      »
      32 hours ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      I believe sslotin meant that it's easy to check in a similar way to the plag checker. We're not checking that they do the exact same thing, just that the solutions are similar enough. For example, taking in input $$$K\ N$$$ instead of $$$N\ K$$$, the overall solution could be exactly the same, but with

      std::cin >> N >> K;
      

      vs

      std::cin >> K >> N;
      

      Also, there can be very different-looking problems that have very similar solutions. I remember this happened in a round a few months ago, but I can't recall which one. Other than the input/output format, one problem could be directly translated into the other. However, if you just look at the problem statement / input / output, you won't see any correlation.

»
4 days ago, # |
  Vote: I like it +19 Vote: I do not like it

You want to automate part of your work as cp admin. Understandable, but if you think, there are not a lot of other cp admins who would also benefit from this solution, for other people like coaches or teachers it might help, but wouldn't recude their work dramatically.
If you're determined with this idea, I'd suggest to look into more generic solution (for papers, patents, news?), with a custom application for cp problem search. In this case it would be possible to get founding and most likely such tech would worth millions.

»
4 days ago, # |
  Vote: I like it +13 Vote: I do not like it

It would most likely be a multi hop reasoning model, where each solution (algorithm) will be represented by a vector. Look into OpenAI GPT-3 model and its capabilities Link to GPT-3. Also It would be a good idea to check Neural Network Theorem solver Link to the article about theorem solver. Maybe a combination of the two would be suffice to represent each solution as a vector. Similar solutions would be closer in the vector space.

»
4 days ago, # |
  Vote: I like it +56 Vote: I do not like it

Reading some of the comments, I think any approach that involves making an AI that can read and understand problems is right out. That's simply not feasible.

The best that can be done is a respectable search engine with some domain-specific optimizations (modern search engines contain ML components of course but it is not really what I mean above). We have some advantages here. There is a lot of standard terminology and the search space is small, we can probably get hands on about 20k problems. If there is any more-or-less good open-source search toolkit (we don't need anything close to the state of the art), then this might actually be doable, but still require a dedicated team and a lot of time and money. But at this rate, I'm not sure if you'd actually get better results than googling and heavy filtering.

I think editorials are the best thing to search. Editorials often contain relatively formal and simple problem statements (i.e. no Vasya finding queries in the left pocket).

Here's the thing though. Very often we have problems that haven't exactly been proposed before, but you read it and you kind of have seen everything before. Here's an example of such a problem (and I felt the same way solving this problem). You'd want to avoid creating this feeling, but now you need to have some level of intelligence to be able to distill this problem to classical subproblems and somehow understand that the transition is simple enough for it to be considered a repeat of tha problem.

»
4 days ago, # |
  Vote: I like it +89 Vote: I do not like it

Creating a CP problem aggregator was one of my biggest personal projects, and one idea of mine was to do that as well (amongst others like problem recommender, contest creator, custom interesting contest formats like lockout, etc.)

Contrary to what others believe, I actually think it’s doable; however, my idea would be to use submissions instead of statements to infer similarity between problems. I have done some research work for the past years in that sense (which will hopefully be published some time), but nowadays I just don’t have the time to integrate it into the platform. I might do that once I free myself some time. In the mean time, if someone is willing to put effort in the project and wants to discuss ideas and implementation, feel free to PM me.

The platform at its current state is at https://binarylift.com (it has some bugs, so you might prefer to check out the old slower version at https://competitive.herokuapp.com)

  • »
    »
    3 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    where is the option to add CF handle in binarylift.com ?

    • »
      »
      »
      3 days ago, # ^ |
        Vote: I like it +8 Vote: I do not like it

      Once you’ve created an account, you can go to your profile and link your OJ accounts there. The submissions should be updated in some time (it might take a while nowadays as there are quite a few accounts on the platform and it doesn’t scale extraordinarily well).

»
4 days ago, # |
  Vote: I like it +30 Vote: I do not like it

I'm interested in supporting such a project as well (financially too!).

»
4 days ago, # |
  Vote: I like it -8 Vote: I do not like it

There is something called insights prediction**** in neural networks we could do that , using that we could know what the problem wants us to find but that wouldn't be too smart because a lot of problems could be solved using same method , but you know its one of the ways

»
3 days ago, # |
  Vote: I like it +5 Vote: I do not like it

I guess this might be possible to implement such a model only in a world, where authors don’t write problem legends… Of course, such a world doesn’t exist, as problem legends are great and essential.

»
2 days ago, # |
  Vote: I like it +18 Vote: I do not like it

Isn't that the type of problem that the tags are proposed to deal with? It is much easier to make better tags in, say, CF, than to make a full search engine of this kind.

Also, if you want just a full-text search engine, without the internal meaning thing, then in that case, you can use any search engine, like Google, really. Recall how search in cplusplus.com works, for example. If you want a full-text search over problems with some specific tag, which seems to be the main use case, it is also possible with proper database design and some search line magic.

And, tbh, I doubt that it is possible to do much more than that.

I also feel that we really need something like new e-maxx, with good modern algorithms, good reliable code in modern C++, where usability, extensibility and readability are preferred over brevity (not the case of e-maxx at all), and example problems on each topic (just like in e-maxx).

I think this is the thing that may be worth paying for, because it is clear for me that crowdsourcing is simply impossible here (well, except for some basic topics, but they are not the point), and that no one would really do it all by himself.

  • »
    »
    2 days ago, # ^ |
      Vote: I like it +22 Vote: I do not like it

    I think tags (even if significantly improved) still cover way too many problems to reasonably allow you to search if a problem has already been used. (On a side note, Codeforces tags are pretty bad and I'd love to see a revamp, but I'm out of ideas how to actually improve them).

    The latter thing could probably be reasonably achieved. After all, cp-algorithms is open for contributors as far as I can tell, and with enough support, you could start a campaign to rewrite code examples to have higher quality.

    • »
      »
      »
      2 days ago, # ^ |
        Vote: I like it +29 Vote: I do not like it

      Codeforces tags are pretty bad and I'd love to see a revamp

      It would be cool if there were user-defined tags. Tag editing is already gated to div 1, so spam shouldn't be an issue. The bigger problem might be getting people to agree on canonical names for various techniques or when certain tags are even appropriate. This will naturally force the community to make and maintain a "Ultimate Topic List"-like wiki for the tags, which would be an amazing side effect in itself.

      I would say image board sites like danbooru.donmai.us or e-hentai.org are good examples of these kinds of tagging system.

    • »
      »
      »
      46 hours ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      I think, tags + regular full text search on editorials should do the trick. However, I definitely agree that current CF tags are not really capable of dealing with anything.

      As for cp-algorithms, as far as I see, it is just a straightforward English translation of e-maxx (even not full), even with the same bugs (e.g. the well-known comparator that is not a comparator) and mostly the same problems with the code style. It also doesn't cover any more or less advanced topics, and even some not really complicated algorithms like halfplane intersection are out of scope.

      And even with all that, rewriting all code examples is simply too much work for one person. In fact, the moderators are needed to maintain the quality of articles and code. Another solution is to find someone (like, a big tech company?) who would sponsor such kind of campaign and new articles.

  • »
    »
    33 hours ago, # ^ |
    Rev. 3   Vote: I like it +16 Vote: I do not like it

    I know it's offtopic, but I'd be pleased to learn more about your (and others') ideas about improving the source code at e-maxx.ru. You're right that the original goal behind e-maxx.ru's snippets was brevity and, to the extent possible, the clarity of the original idea (i.e., not hiding the algorithm's core idea under 10 layers of abstraction — both because pre-written code was very uncommon 10-15 years ago, and also with the teaching aspect in mind).

    Do you mean to create a prewritten library that would provide, say, a generic "graph" primitive with all algorithms applicable to it? Is the main point the ease of reuse as a pre-written code or something else?

    P.S. I'm asking because I feel like there's a whole bunch of different directions in which one can go, and the aspects you mention seem contradicting at first glance. E.g., there's a good C++ algorithm library with great extensibility and flexibility — the Boost Graph Library — but the price is low readability (especially of the internal implementation) and complex usage (one really needs to sit down and learn it before being able to use it). I'm aware of several huge commercial projects that switched away from Boost because of these and other complexities caused by its flexibility, and I would definitely prefer e-maxx.ru/algo not going into that direction (I mean being a weak half-complete clone of Boost :D) But I probably misunderstood you.

»
46 hours ago, # |
  Vote: I like it +9 Vote: I do not like it

Maybe for each specific problem, the relationship between input and desired output can be described in some formal expression (for example), which is STRUCTRUED / HIERARCICAL / DETERMINATE by any chance. Then it can be stored and queried.

By the way since the expression is structrued, subtask (solved by common well-known algorithm template) may be identified, clustered, and queried as well.

»
44 hours ago, # |
  Vote: I like it +5 Vote: I do not like it

Um, some thinking problems without algorithms seems hard to check because it's hard to express the main idea with format expression that can match. For example, *1500- is hard to check.

However, a perfect tag system can provide a nice search engine for algorithmic problems, I think it will be helpful.

By the way, CF tags do need revamp.

»
28 hours ago, # |
Rev. 2   Vote: I like it +9 Vote: I do not like it

I suggest creating a competition in Kaggle (the codeforces of data scientists). It is worth emphasizing that what you propose is extremely difficult. There would be very noisy data with the statements of the problems, since problems with similar stories and different solutions can be confused as similar, perhaps a good idea would also be to use the solutions of the problems (and the code) to look for similarities between them.