fork download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <string>
  4. #include <cctype>
  5.  
  6. int main(void) {
  7. for (;;)
  8. {
  9. std::cout << "in < ";
  10. std::string number;
  11. if (!std::getline(std::cin, number) || number.empty() ||
  12. !std::all_of(std::begin(number), std::end(number), [](unsigned char c) { return std::isdigit(c); }))
  13. break;
  14.  
  15. std::cout << "out > ";
  16. std::string next = number;
  17. if (!std::next_permutation(std::begin(next), std::end(next)))
  18. std::cout << number;
  19. else
  20. {
  21. std::cout << next;
  22. while (std::next_permutation(std::begin(next), std::end(next)))
  23. std::cout << ',' << next;
  24. }
  25. std::cout << std::endl;
  26. }
  27. }
Success #stdin #stdout 0s 4288KB
stdin
123
921
133
5672391
stdout
in < out > 132,213,231,312,321
in < out > 921
in < out > 313,331
in < out > 5672913,5672931,5673129,5673192,5673219,5673291,5673912,5673921,5679123,5679132,5679213,5679231,5679312,5679321,5691237,5691273,5691327,5691372,5691723,5691732,5692137,5692173,5692317,5692371,5692713,5692731,5693127,5693172,5693217,5693271,5693712,5693721,5697123,5697132,5697213,5697231,5697312,5697321,5712369,5712396,5712639,5712693,5712936,5712963,5713269,5713296,5713629,5713692,5713926,5713962,5716239,5716293,5716329,5716392,5716923,5716932,5719236,5719263,5719326,5719362,5719623,5719632,5721369,5721396,5721639,5721693,5721936,5721963,5723169,5723196,5723619,5723691,5723916,5723961,5726139,5726193,5726319,5726391,5726913,5726931,5729136,5729163,5729316,5729361,5729613,5729631,5731269,5731296,5731629,5731692,5731926,5731962,5732169,5732196,5732619,5732691,5732916,5732961,5736129,5736192,5736219,5736291,5736912,5736921,5739126,5739162,5739216,5739261,5739612,5739621,5761239,5761293,5761329,5761392,5761923,5761932,5762139,5762193,5762319,5762391,5762913,5762931,5763129,5763192,5763219,5763291,5763912,5763921,5769123,5769132,5769213,5769231,5769312,5769321,5791236,5791263,5791326,5791362,5791623,5791632,5792136,5792163,5792316,5792361,5792613,5792631,5793126,5793162,5793216,5793261,5793612,5793621,5796123,5796132,5796213,5796231,5796312,5796321,5912367,5912376,5912637,5912673,5912736,5912763,5913267,5913276,5913627,5913672,5913726,5913762,5916237,5916273,5916327,5916372,5916723,5916732,5917236,5917263,5917326,5917362,5917623,5917632,5921367,5921376,5921637,5921673,5921736,5921763,5923167,5923176,5923617,5923671,5923716,5923761,5926137,5926173,5926317,5926371,5926713,5926731,5927136,5927163,5927316,5927361,5927613,5927631,5931267,5931276,5931627,5931672,5931726,5931762,5932167,5932176,5932617,5932671,5932716,5932761,5936127,5936172,5936217,5936271,5936712,5936721,5937126,5937162,5937216,5937261,5937612,5937621,5961237,5961273,5961327,5961372,5961723,5961732,5962137,5962173,5962317,5962371,5962713,5962731,5963127,5963172,5963217,5963271,5963712,5963721,5967123,5967132,5967213,5967231,5967312,5967321,5971236,5971263,5971326,5971362,5971623,5971632,5972136,5972163,5972316,5972361,5972613,5972631,5973126,5973162,5973216,5973261,5973612,5973621,5976123,5976132,5976213,5976231,5976312,5976321,6123579,6123597,6123759,6123795,6123957,6123975,6125379,6125397,6125739,6125793,6125937,6125973,6127359,6127395,6127539,6127593,6127935,6127953,6129357,6129375,6129537,6129573,6129735,6129753,6132579,6132597,6132759,6132795,6132957,6132975,6135279,6135297,6135729,6135792,6135927,6135972,6137259,6137295,6137529,6137592,6137925,6137952,6139257,6139275,6139527,6139572,6139725,6139752,6152379,6152397,6152739,6152793,6152937,6152973,6153279,6153297,6153729,6153792,6153927,6153972,6157239,6157293,6157329,6157392,6157923,6157932,6159237,6159273,6159327,6159372,6159723,6159732,6172359,6172395,6172539,6172593,6172935,6172953,6173259,6173295,6173529,6173592,6173925,6173952,6175239,6175293,6175329,6175392,6175923,6175932,6179235,6179253,6179325,6179352,6179523,6179532,6192357,6192375,6192537,6192573,6192735,6192753,6193257,6193275,6193527,6193572,6193725,6193752,6195237,6195273,6195327,6195372,6195723,6195732,6197235,6197253,6197325,6197352,6197523,6197532,6213579,6213597,6213759,6213795,6213957,6213975,6215379,6215397,6215739,6215793,6215937,6215973,6217359,6217395,6217539,6217593,6217935,6217953,6219357,6219375,6219537,6219573,6219735,6219753,6231579,6231597,6231759,6231795,6231957,6231975,6235179,6235197,6235719,6235791,6235917,6235971,6237159,6237195,6237519,6237591,6237915,6237951,6239157,6239175,6239517,6239571,6239715,6239751,6251379,6251397,6251739,6251793,6251937,6251973,6253179,6253197,6253719,6253791,6253917,6253971,6257139,6257193,6257319,6257391,6257913,6257931,6259137,6259173,6259317,6259371,6259713,6259731,6271359,6271395,6271539,6271593,6271935,6271953,6273159,6273195,6273519,6273591,6273915,6273951,6275139,6275193,6275319,6275391,6275913,6275931,6279135,6279153,6279315,6279351,6279513,6279531,6291357,6291375,6291537,6291573,6291735,6291753,6293157,6293175,6293517,6293571,6293715,6293751,6295137,6295173,6295317,6295371,6295713,6295731,6297135,6297153,6297315,6297351,6297513,6297531,6312579,6312597,6312759,6312795,6312957,6312975,6315279,6315297,6315729,6315792,6315927,6315972,6317259,6317295,6317529,6317592,6317925,6317952,6319257,6319275,6319527,6319572,6319725,6319752,6321579,6321597,6321759,6321795,6321957,6321975,6325179,6325197,6325719,6325791,6325917,6325971,6327159,6327195,6327519,6327591,6327915,6327951,6329157,6329175,6329517,6329571,6329715,6329751,6351279,6351297,6351729,6351792,6351927,6351972,6352179,6352197,6352719,6352791,6352917,6352971,6357129,6357192,6357219,6357291,6357912,6357921,6359127,6359172,6359217,6359271,6359712,6359721,6371259,6371295,6371529,6371592,6371925,6371952,6372159,6372195,6372519,6372591,6372915,6372951,6375129,6375192,6375219,6375291,6375912,6375921,6379125,6379152,6379215,6379251,6379512,6379521,6391257,6391275,6391527,6391572,6391725,6391752,6392157,6392175,6392517,6392571,6392715,6392751,6395127,6395172,6395217,6395271,6395712,6395721,6397125,6397152,6397215,6397251,6397512,6397521,6512379,6512397,6512739,6512793,6512937,6512973,6513279,6513297,6513729,6513792,6513927,6513972,6517239,6517293,6517329,6517392,6517923,6517932,6519237,6519273,6519327,6519372,6519723,6519732,6521379,6521397,6521739,6521793,6521937,6521973,6523179,6523197,6523719,6523791,6523917,6523971,6527139,6527193,6527319,6527391,6527913,6527931,6529137,6529173,6529317,6529371,6529713,6529731,6531279,6531297,6531729,6531792,6531927,6531972,6532179,6532197,6532719,6532791,6532917,6532971,6537129,6537192,6537219,6537291,6537912,6537921,6539127,6539172,6539217,6539271,6539712,6539721,6571239,6571293,6571329,6571392,6571923,6571932,6572139,6572193,6572319,6572391,6572913,6572931,6573129,6573192,6573219,6573291,6573912,6573921,6579123,6579132,6579213,6579231,6579312,6579321,6591237,6591273,6591327,6591372,6591723,6591732,6592137,6592173,6592317,6592371,6592713,6592731,6593127,6593172,6593217,6593271,6593712,6593721,6597123,6597132,6597213,6597231,6597312,6597321,6712359,6712395,6712539,6712593,6712935,6712953,6713259,6713295,6713529,6713592,6713925,6713952,6715239,6715293,6715329,6715392,6715923,6715932,6719235,6719253,6719325,6719352,6719523,6719532,6721359,6721395,6721539,6721593,6721935,6721953,6723159,6723195,6723519,6723591,6723915,6723951,6725139,6725193,6725319,6725391,6725913,6725931,6729135,6729153,6729315,6729351,6729513,6729531,6731259,6731295,6731529,6731592,6731925,6731952,6732159,6732195,6732519,6732591,6732915,6732951,6735129,6735192,6735219,6735291,6735912,6735921,6739125,6739152,6739215,6739251,6739512,6739521,6751239,6751293,6751329,6751392,6751923,6751932,6752139,6752193,6752319,6752391,6752913,6752931,6753129,6753192,6753219,6753291,6753912,6753921,6759123,6759132,6759213,6759231,6759312,6759321,6791235,6791253,6791325,6791352,6791523,6791532,6792135,6792153,6792315,6792351,6792513,6792531,6793125,6793152,6793215,6793251,6793512,6793521,6795123,6795132,6795213,6795231,6795312,6795321,6912357,6912375,6912537,6912573,6912735,6912753,6913257,6913275,6913527,6913572,6913725,6913752,6915237,6915273,6915327,6915372,6915723,6915732,6917235,6917253,6917325,6917352,6917523,6917532,6921357,6921375,6921537,6921573,6921735,6921753,6923157,6923175,6923517,6923571,6923715,6923751,6925137,6925173,6925317,6925371,6925713,6925731,6927135,6927153,6927315,6927351,6927513,6927531,6931257,6931275,6931527,6931572,6931725,6931752,6932157,6932175,6932517,6932571,6932715,6932751,6935127,6935172,6935217,6935271,6935712,6935721,6937125,6937152,6937215,6937251,6937512,6937521,6951237,6951273,6951327,6951372,6951723,6951732,6952137,6952173,6952317,6952371,6952713,6952731,6953127,6953172,6953217,6953271,6953712,6953721,6957123,6957132,6957213,6957231,6957312,6957321,6971235,6971253,6971325,6971352,6971523,6971532,6972135,6972153,6972315,6972351,6972513,6972531,6973125,6973152,6973215,6973251,6973512,6973521,6975123,6975132,6975213,6975231,6975312,6975321,7123569,7123596,7123659,7123695,7123956,7123965,7125369,7125396,7125639,7125693,7125936,7125963,7126359,7126395,7126539,7126593,7126935,7126953,7129356,7129365,7129536,7129563,7129635,7129653,7132569,7132596,7132659,7132695,7132956,7132965,7135269,7135296,7135629,7135692,7135926,7135962,7136259,7136295,7136529,7136592,7136925,7136952,7139256,7139265,7139526,7139562,7139625,7139652,7152369,7152396,7152639,7152693,7152936,7152963,7153269,7153296,7153629,7153692,7153926,7153962,7156239,7156293,7156329,7156392,7156923,7156932,7159236,7159263,7159326,7159362,7159623,7159632,7162359,7162395,7162539,7162593,7162935,7162953,7163259,7163295,7163529,7163592,7163925,7163952,7165239,7165293,7165329,7165392,7165923,7165932,7169235,7169253,7169325,7169352,7169523,7169532,7192356,7192365,7192536,7192563,7192635,7192653,7193256,7193265,7193526,7193562,7193625,7193652,7195236,7195263,7195326,7195362,7195623,7195632,7196235,7196253,7196325,7196352,7196523,7196532,7213569,7213596,7213659,7213695,7213956,7213965,7215369,7215396,7215639,7215693,7215936,7215963,7216359,7216395,7216539,7216593,7216935,7216953,7219356,7219365,7219536,7219563,7219635,7219653,7231569,7231596,7231659,7231695,7231956,7231965,7235169,7235196,7235619,7235691,7235916,7235961,7236159,7236195,7236519,7236591,7236915,7236951,7239156,7239165,7239516,7239561,7239615,7239651,7251369,7251396,7251639,7251693,7251936,7251963,7253169,7253196,7253619,7253691,7253916,7253961,7256139,7256193,7256319,7256391,7256913,7256931,7259136,7259163,7259316,7259361,7259613,7259631,7261359,7261395,7261539,7261593,7261935,7261953,7263159,7263195,7263519,7263591,7263915,7263951,7265139,7265193,7265319,7265391,7265913,7265931,7269135,7269153,7269315,7269351,7269513,7269531,7291356,7291365,7291536,7291563,7291635,7291653,7293156,7293165,7293516,7293561,7293615,7293651,7295136,7295163,7295316,7295361,7295613,7295631,7296135,7296153,7296315,7296351,7296513,7296531,7312569,7312596,7312659,7312695,7312956,7312965,7315269,7315296,7315629,7315692,7315926,7315962,7316259,7316295,7316529,7316592,7316925,7316952,7319256,7319265,7319526,7319562,7319625,7319652,7321569,7321596,7321659,7321695,7321956,7321965,7325169,7325196,7325619,7325691,7325916,7325961,7326159,7326195,7326519,7326591,7326915,7326951,7329156,7329165,7329516,7329561,7329615,7329651,7351269,7351296,7351629,7351692,7351926,7351962,7352169,7352196,7352619,7352691,7352916,7352961,7356129,7356192,7356219,7356291,7356912,7356921,7359126,7359162,7359216,7359261,7359612,7359621,7361259,7361295,7361529,7361592,7361925,7361952,7362159,7362195,7362519,7362591,7362915,7362951,7365129,7365192,7365219,7365291,7365912,7365921,7369125,7369152,7369215,7369251,7369512,7369521,7391256,7391265,7391526,7391562,7391625,7391652,7392156,7392165,7392516,7392561,7392615,7392651,7395126,7395162,7395216,7395261,7395612,7395621,7396125,7396152,7396215,7396251,7396512,7396521,7512369,7512396,7512639,7512693,7512936,7512963,7513269,7513296,7513629,7513692,7513926,7513962,7516239,7516293,7516329,7516392,7516923,7516932,7519236,7519263,7519326,7519362,7519623,7519632,7521369,7521396,7521639,7521693,7521936,7521963,7523169,7523196,7523619,7523691,7523916,7523961,7526139,7526193,7526319,7526391,7526913,7526931,7529136,7529163,7529316,7529361,7529613,7529631,7531269,7531296,7531629,7531692,7531926,7531962,7532169,7532196,7532619,7532691,7532916,7532961,7536129,7536192,7536219,7536291,7536912,7536921,7539126,7539162,7539216,7539261,7539612,7539621,7561239,7561293,7561329,7561392,7561923,7561932,7562139,7562193,7562319,7562391,7562913,7562931,7563129,7563192,7563219,7563291,7563912,7563921,7569123,7569132,7569213,7569231,7569312,7569321,7591236,7591263,7591326,7591362,7591623,7591632,7592136,7592163,7592316,7592361,7592613,7592631,7593126,7593162,7593216,7593261,7593612,7593621,7596123,7596132,7596213,7596231,7596312,7596321,7612359,7612395,7612539,7612593,7612935,7612953,7613259,7613295,7613529,7613592,7613925,7613952,7615239,7615293,7615329,7615392,7615923,7615932,7619235,7619253,7619325,7619352,7619523,7619532,7621359,7621395,7621539,7621593,7621935,7621953,7623159,7623195,7623519,7623591,7623915,7623951,7625139,7625193,7625319,7625391,7625913,7625931,7629135,7629153,7629315,7629351,7629513,7629531,7631259,7631295,7631529,7631592,7631925,7631952,7632159,7632195,7632519,7632591,7632915,7632951,7635129,7635192,7635219,7635291,7635912,7635921,7639125,7639152,7639215,7639251,7639512,7639521,7651239,7651293,7651329,7651392,7651923,7651932,7652139,7652193,7652319,7652391,7652913,7652931,7653129,7653192,7653219,7653291,7653912,7653921,7659123,7659132,7659213,7659231,7659312,7659321,7691235,7691253,7691325,7691352,7691523,7691532,7692135,7692153,7692315,7692351,7692513,7692531,7693125,7693152,7693215,7693251,7693512,7693521,7695123,7695132,7695213,7695231,7695312,7695321,7912356,7912365,7912536,7912563,7912635,7912653,7913256,7913265,7913526,7913562,7913625,7913652,7915236,7915263,7915326,7915362,7915623,7915632,7916235,7916253,7916325,7916352,7916523,7916532,7921356,7921365,7921536,7921563,7921635,7921653,7923156,7923165,7923516,7923561,7923615,7923651,7925136,7925163,7925316,7925361,7925613,7925631,7926135,7926153,7926315,7926351,7926513,7926531,7931256,7931265,7931526,7931562,7931625,7931652,7932156,7932165,7932516,7932561,7932615,7932651,7935126,7935162,7935216,7935261,7935612,7935621,7936125,7936152,7936215,7936251,7936512,7936521,7951236,7951263,7951326,7951362,7951623,7951632,7952136,7952163,7952316,7952361,7952613,7952631,7953126,7953162,7953216,7953261,7953612,7953621,7956123,7956132,7956213,7956231,7956312,7956321,7961235,7961253,7961325,7961352,7961523,7961532,7962135,7962153,7962315,7962351,7962513,7962531,7963125,7963152,7963215,7963251,7963512,7963521,7965123,7965132,7965213,7965231,7965312,7965321,9123567,9123576,9123657,9123675,9123756,9123765,9125367,9125376,9125637,9125673,9125736,9125763,9126357,9126375,9126537,9126573,9126735,9126753,9127356,9127365,9127536,9127563,9127635,9127653,9132567,9132576,9132657,9132675,9132756,9132765,9135267,9135276,9135627,9135672,9135726,9135762,9136257,9136275,9136527,9136572,9136725,9136752,9137256,9137265,9137526,9137562,9137625,9137652,9152367,9152376,9152637,9152673,9152736,9152763,9153267,9153276,9153627,9153672,9153726,9153762,9156237,9156273,9156327,9156372,9156723,9156732,9157236,9157263,9157326,9157362,9157623,9157632,9162357,9162375,9162537,9162573,9162735,9162753,9163257,9163275,9163527,9163572,9163725,9163752,9165237,9165273,9165327,9165372,9165723,9165732,9167235,9167253,9167325,9167352,9167523,9167532,9172356,9172365,9172536,9172563,9172635,9172653,9173256,9173265,9173526,9173562,9173625,9173652,9175236,9175263,9175326,9175362,9175623,9175632,9176235,9176253,9176325,9176352,9176523,9176532,9213567,9213576,9213657,9213675,9213756,9213765,9215367,9215376,9215637,9215673,9215736,9215763,9216357,9216375,9216537,9216573,9216735,9216753,9217356,9217365,9217536,9217563,9217635,9217653,9231567,9231576,9231657,9231675,9231756,9231765,9235167,9235176,9235617,9235671,9235716,9235761,9236157,9236175,9236517,9236571,9236715,9236751,9237156,9237165,9237516,9237561,9237615,9237651,9251367,9251376,9251637,9251673,9251736,9251763,9253167,9253176,9253617,9253671,9253716,9253761,9256137,9256173,9256317,9256371,9256713,9256731,9257136,9257163,9257316,9257361,9257613,9257631,9261357,9261375,9261537,9261573,9261735,9261753,9263157,9263175,9263517,9263571,9263715,9263751,9265137,9265173,9265317,9265371,9265713,9265731,9267135,9267153,9267315,9267351,9267513,9267531,9271356,9271365,9271536,9271563,9271635,9271653,9273156,9273165,9273516,9273561,9273615,9273651,9275136,9275163,9275316,9275361,9275613,9275631,9276135,9276153,9276315,9276351,9276513,9276531,9312567,9312576,9312657,9312675,9312756,9312765,9315267,9315276,9315627,9315672,9315726,9315762,9316257,9316275,9316527,9316572,9316725,9316752,9317256,9317265,9317526,9317562,9317625,9317652,9321567,9321576,9321657,9321675,9321756,9321765,9325167,9325176,9325617,9325671,9325716,9325761,9326157,9326175,9326517,9326571,9326715,9326751,9327156,9327165,9327516,9327561,9327615,9327651,9351267,9351276,9351627,9351672,9351726,9351762,9352167,9352176,9352617,9352671,9352716,9352761,9356127,9356172,9356217,9356271,9356712,9356721,9357126,9357162,9357216,9357261,9357612,9357621,9361257,9361275,9361527,9361572,9361725,9361752,9362157,9362175,9362517,9362571,9362715,9362751,9365127,9365172,9365217,9365271,9365712,9365721,9367125,9367152,9367215,9367251,9367512,9367521,9371256,9371265,9371526,9371562,9371625,9371652,9372156,9372165,9372516,9372561,9372615,9372651,9375126,9375162,9375216,9375261,9375612,9375621,9376125,9376152,9376215,9376251,9376512,9376521,9512367,9512376,9512637,9512673,9512736,9512763,9513267,9513276,9513627,9513672,9513726,9513762,9516237,9516273,9516327,9516372,9516723,9516732,9517236,9517263,9517326,9517362,9517623,9517632,9521367,9521376,9521637,9521673,9521736,9521763,9523167,9523176,9523617,9523671,9523716,9523761,9526137,9526173,9526317,9526371,9526713,9526731,9527136,9527163,9527316,9527361,9527613,9527631,9531267,9531276,9531627,9531672,9531726,9531762,9532167,9532176,9532617,9532671,9532716,9532761,9536127,9536172,9536217,9536271,9536712,9536721,9537126,9537162,9537216,9537261,9537612,9537621,9561237,9561273,9561327,9561372,9561723,9561732,9562137,9562173,9562317,9562371,9562713,9562731,9563127,9563172,9563217,9563271,9563712,9563721,9567123,9567132,9567213,9567231,9567312,9567321,9571236,9571263,9571326,9571362,9571623,9571632,9572136,9572163,9572316,9572361,9572613,9572631,9573126,9573162,9573216,9573261,9573612,9573621,9576123,9576132,9576213,9576231,9576312,9576321,9612357,9612375,9612537,9612573,9612735,9612753,9613257,9613275,9613527,9613572,9613725,9613752,9615237,9615273,9615327,9615372,9615723,9615732,9617235,9617253,9617325,9617352,9617523,9617532,9621357,9621375,9621537,9621573,9621735,9621753,9623157,9623175,9623517,9623571,9623715,9623751,9625137,9625173,9625317,9625371,9625713,9625731,9627135,9627153,9627315,9627351,9627513,9627531,9631257,9631275,9631527,9631572,9631725,9631752,9632157,9632175,9632517,9632571,9632715,9632751,9635127,9635172,9635217,9635271,9635712,9635721,9637125,9637152,9637215,9637251,9637512,9637521,9651237,9651273,9651327,9651372,9651723,9651732,9652137,9652173,9652317,9652371,9652713,9652731,9653127,9653172,9653217,9653271,9653712,9653721,9657123,9657132,9657213,9657231,9657312,9657321,9671235,9671253,9671325,9671352,9671523,9671532,9672135,9672153,9672315,9672351,9672513,9672531,9673125,9673152,9673215,9673251,9673512,9673521,9675123,9675132,9675213,9675231,9675312,9675321,9712356,9712365,9712536,9712563,9712635,9712653,9713256,9713265,9713526,9713562,9713625,9713652,9715236,9715263,9715326,9715362,9715623,9715632,9716235,9716253,9716325,9716352,9716523,9716532,9721356,9721365,9721536,9721563,9721635,9721653,9723156,9723165,9723516,9723561,9723615,9723651,9725136,9725163,9725316,9725361,9725613,9725631,9726135,9726153,9726315,9726351,9726513,9726531,9731256,9731265,9731526,9731562,9731625,9731652,9732156,9732165,9732516,9732561,9732615,9732651,9735126,9735162,9735216,9735261,9735612,9735621,9736125,9736152,9736215,9736251,9736512,9736521,9751236,9751263,9751326,9751362,9751623,9751632,9752136,9752163,9752316,9752361,9752613,9752631,9753126,9753162,9753216,9753261,9753612,9753621,9756123,9756132,9756213,9756231,9756312,9756321,9761235,9761253,9761325,9761352,9761523,9761532,9762135,9762153,9762315,9762351,9762513,9762531,9763125,9763152,9763215,9763251,9763512,9763521,9765123,9765132,9765213,9765231,9765312,9765321
in <