Dataset Viewer
Auto-converted to Parquet Duplicate
name
large_stringlengths
4
70
description
large_stringlengths
31
8.62k
public_tests
dict
private_tests
dict
generated_tests
dict
source
int64
1
6
difficulty
int64
0
21
solutions
dict
incorrect_solutions
dict
cf_contest_id
int64
0
1.55k
cf_index
large_stringclasses
23 values
cf_points
float64
0
3.75k
cf_rating
int64
0
3.5k
cf_tags
listlengths
0
7
is_description_translated
bool
2 classes
untranslated_description
large_stringclasses
36 values
time_limit
dict
memory_limit_bytes
int64
0
1.07B
input_file
large_stringclasses
1 value
output_file
large_stringclasses
1 value
p00490 Best Pizza
Background The kindergarten attached to the University of Aizu is a kindergarten where children who love programming gather. Yu, one of the kindergarten children, loves money as much as programming. Yu-kun visited the island where treasures sleep to make money today. Yu-kun has obtained a map of the treasure in advance. I want to make as much money as possible based on the map. How much money can Yu get up to? Problem You will be given a map, Yu-kun's initial location, the types of treasures and the money they will earn, and the cost of destroying the small rocks. Map information is given as a field of h squares x w squares. The characters written on each square of the map and their meanings are as follows. *'@': Indicates the position where Yu is first. After Yu-kun moves, treat it like a road. *'.': Represents the way. This square is free to pass and does not cost anything. *'#': Represents a large rock. This square cannot pass. *'*': Represents a small rock. It can be broken by paying a certain amount. After breaking it, it becomes a road. * '0', '1', ..., '9','a','b', ...,'z','A','B', ...,'Z': Treasure Represents a square. By visiting this square, you will get the amount of money of the treasure corresponding to the letters written on it. However, you can only get money when you first visit. Yu-kun can move to any of the adjacent squares, up, down, left, and right with one move. However, you cannot move out of the map. You don't have to have the amount you need to break a small rock at the time, as you can pay later. Therefore, Yu needs to earn more than the sum of the amount of money it took to finally break a small rock. Output the maximum amount you can get. Constraints The input meets the following constraints. * 1 ≤ h, w ≤ 8 * 0 ≤ n ≤ min (h × w -1,62) where min (a, b) represents the minimum value of a, b * 1 ≤ vi ≤ 105 (1 ≤ i ≤ n) * 1 ≤ r ≤ 105 * All inputs except cj, k, ml are given as integers (1 ≤ j ≤ h, 1 ≤ k ≤ w, 1 ≤ l ≤ n) * Exactly one'@' is written on the map * Just n treasures are written on the map * The type of treasure written on the map is one of the ml given in the input * No more than one treasure of the same type will appear on the map Input The input is given in the following format. h w n r c1,1 c1,2… c1, w c2,1 c2,2… c2, w ... ch, 1 ch, 2… ch, w m1 v1 m2 v2 ... mn vn In the first line, the vertical length h of the map, the horizontal length w, the number of treasures contained in the map n, and the cost r for destroying a small rock are given separated by blanks. In the following h line, w pieces of information ci and j of each cell representing the map are given. (1 ≤ i ≤ h, 1 ≤ j ≤ w) In the next n lines, the treasure type mk and the treasure amount vk are given, separated by blanks. (1 ≤ k ≤ n) Output Output the maximum amount of money you can get on one line. Examples Input 3 3 1 10 @0. ... ... 0 100 Output 100 Input 3 3 1 10 @#b .#. .#. b 100 Output 0 Input 3 3 1 20 @*C ..* ... C 10 Output 0
{ "input": [ "AprilFool\n14\n" ], "output": [ "AprILFooL" ] }
{ "input": [ "85 30 123\n", "100000 100000 1320777\n", "94728 36278 300352\n", "70386 4182 113682\n", "65182 12701 141871\n", "48701 4854 14523\n", "84324 74849 17238\n", "100000 100000 10000000\n", "83072 55834 461951\n", "99999 99999 1320778\n", "99474 33270 200430\n", "54558 77753 458973\n", "49 24 83\n", "84813 80213 1123474\n", "98372 55633 650768\n", "18252 10662 36621\n", "59510 27419 6719162\n", "119 69 169\n", "66343 33744 168654\n", "84637 33654 2517\n", "84026 17765 8177582\n", "30372 66963 1554229\n", "61886 5897 37739\n", "4830 97380 69709\n", "100000 100000 1000000\n", "40758 44300 202089\n", "22706 53686 4605009\n", "131 136 430\n", "17 49 101\n", "55361 31906 7353\n", "64356 76729 351908\n", "100000 100000 1300000\n", "87191 27924 129801\n", "17450 74957 174334\n", "22 36 60\n", "76689 39645 140033\n", "100000 100000 1320000\n", "55248 15372 1556850\n", "97341 86067 510670\n", "99999 99999 1320779\n", "100000 100000 1320778\n", "100000 100000 1320700\n", "81784 92544 37010\n", "57176 79292 599787\n", "27346 64876 180351\n", "81527 17791 107576\n", "98080 30860 3689530\n" ], "output": [ "22 22\n", "99999 99999", "94649 16361", "69996 3333", "64946 7117", "2222 1001", "4444 1001", "-1", "82628 35353", "99999 99999", "98889 7117", "37585 77682", "9 11\n", "-1", "98289 44844", "17771 2013", "-1", "101 9", "65656 10001", "1001 123", "-1", "-1", "22522 1001", "1001 51115", "99799 73237", "23132 44244", "-1", "88 101\n", "11 22", "1001 525", "26884 76667", "98289 99999\n", "87178 2777", "8778 74547", "7 9\n", "76167 5005", "99999 99999", "-1", "97179 33533", "-1", "99999 99999", "99999 99999", "1001 21812\n", "51315 78887", "11711 64546", "81218 1441", "-1" ] }
{ "input": [ "10 9\n2 5\n2 4\n2 7\n2 9\n2 3\n2 8\n2 6\n4 10\n2 1\n", "10 10\n6 4\n9 2\n3 6\n6 7\n4 2\n9 6\n8 6\n5 7\n1 4\n6 10\n", "5 7\n3 2\n5 4\n4 4\n1 3\n1 5\n1 4\n2 5\n", "1010 1\n195 788\n", "10 9\n2 5\n2 4\n2 7\n2 9\n2 3\n2 9\n2 6\n4 10\n2 1\n", "10 16\n6 10\n5 2\n6 4\n6 8\n5 3\n5 1\n6 2\n5 9\n5 7\n5 1\n6 9\n5 8\n5 10\n6 1\n6 7\n6 3\n", "10 9\n4 9\n1 9\n10 9\n2 9\n3 9\n6 9\n5 9\n7 9\n8 2\n", "100000 1\n26257 11449\n", "10 10\n6 4\n9 2\n3 6\n6 7\n4 2\n9 6\n8 6\n5 7\n1 5\n6 10\n", "10 10\n6 4\n9 1\n3 6\n6 7\n4 2\n9 6\n8 6\n5 7\n1 4\n2 7\n", "10 17\n5 1\n8 1\n2 1\n2 6\n3 1\n5 7\n3 1\n8 6\n4 7\n2 7\n9 7\n10 7\n3 6\n4 1\n9 1\n8 7\n10 1\n", "100000 1\n40376 21752\n", "10 9\n2 5\n2 4\n2 7\n2 3\n2 3\n2 8\n2 6\n4 10\n2 1\n", "10 16\n6 10\n5 2\n3 4\n6 8\n5 3\n5 1\n6 2\n5 9\n5 7\n5 1\n6 9\n5 8\n5 10\n6 1\n6 7\n6 3\n", "10 9\n4 9\n1 9\n10 9\n2 9\n3 9\n1 9\n5 9\n7 9\n8 2\n", "10 15\n5 7\n7 8\n2 9\n1 9\n3 8\n3 9\n5 8\n1 8\n6 9\n7 9\n4 8\n4 9\n10 9\n10 8\n6 8\n", "5 7\n3 2\n5 4\n4 4\n1 1\n1 5\n1 4\n2 5\n", "10 15\n5 7\n8 8\n2 9\n1 9\n3 8\n3 9\n5 8\n1 8\n6 9\n7 9\n4 8\n4 9\n10 9\n10 8\n6 8\n", "10 9\n2 5\n2 4\n2 7\n2 9\n2 3\n1 9\n2 6\n4 10\n2 1\n", "5 7\n3 4\n5 4\n4 4\n1 1\n1 5\n1 4\n2 5\n", "10 15\n5 7\n8 8\n2 9\n1 9\n3 8\n3 9\n5 8\n1 8\n6 9\n7 9\n4 8\n4 6\n10 9\n10 8\n6 8\n", "10 9\n2 5\n2 4\n2 9\n2 9\n2 3\n1 9\n2 6\n4 10\n2 1\n", "10 15\n5 7\n8 8\n2 9\n1 9\n3 8\n3 9\n5 8\n1 8\n6 9\n7 9\n4 8\n2 6\n10 9\n10 8\n6 8\n", "10 15\n5 7\n8 8\n2 9\n1 9\n3 8\n3 9\n5 9\n1 8\n6 9\n7 9\n4 8\n2 6\n10 9\n10 8\n6 8\n", "10 15\n5 7\n8 8\n2 9\n1 9\n3 8\n3 9\n5 9\n1 8\n6 9\n3 9\n4 8\n2 6\n10 9\n10 8\n6 8\n", "20 22\n3 18\n11 19\n6 15\n7 1\n16 8\n18 7\n12 3\n18 4\n9 15\n20 1\n4 2\n6 7\n14 2\n7 15\n7 10\n8 1\n13 6\n9 7\n11 8\n2 6\n18 5\n17 15\n", "10 10\n6 4\n9 1\n3 6\n6 7\n4 2\n9 6\n8 6\n5 7\n1 4\n2 10\n", "10 17\n5 1\n8 1\n2 1\n2 6\n3 1\n5 8\n3 7\n8 6\n4 7\n2 7\n9 7\n10 7\n3 6\n4 1\n9 1\n8 7\n10 1\n", "10 15\n5 9\n7 8\n2 9\n1 9\n3 8\n3 4\n5 8\n1 8\n6 9\n7 9\n4 8\n4 9\n10 9\n10 8\n6 8\n", "10 15\n5 7\n8 8\n2 9\n1 9\n3 8\n3 9\n5 8\n1 6\n6 9\n7 9\n4 8\n4 9\n10 9\n10 8\n6 8\n", "10 9\n2 5\n2 4\n2 2\n2 9\n2 3\n1 9\n2 6\n4 10\n2 1\n", "5 7\n3 4\n5 4\n5 4\n1 1\n1 5\n1 4\n2 5\n", "10 15\n5 7\n8 8\n2 9\n1 9\n3 8\n6 9\n5 8\n1 8\n6 9\n7 9\n4 8\n4 6\n10 9\n10 8\n6 8\n", "10 9\n2 10\n2 4\n2 9\n2 9\n2 3\n1 9\n2 6\n4 10\n2 1\n", "10 15\n5 7\n8 8\n2 9\n1 9\n3 8\n3 9\n5 8\n1 10\n6 9\n7 9\n4 8\n2 6\n10 9\n10 8\n6 8\n", "10 15\n5 7\n8 8\n2 9\n1 3\n3 8\n3 9\n5 9\n1 8\n6 9\n7 9\n4 8\n2 6\n10 9\n10 8\n6 8\n", "10 17\n5 1\n8 1\n2 1\n2 6\n2 1\n5 8\n3 7\n8 6\n4 7\n2 7\n9 7\n10 7\n3 6\n4 1\n9 1\n8 7\n10 1\n", "10 9\n2 5\n2 4\n2 2\n2 9\n2 3\n1 9\n3 6\n4 10\n2 1\n", "10 15\n5 7\n8 8\n2 9\n1 3\n3 8\n3 9\n5 9\n1 5\n6 9\n7 9\n4 8\n2 6\n10 9\n10 8\n6 8\n", "10 17\n5 1\n8 1\n2 1\n2 6\n2 1\n5 8\n3 7\n8 6\n4 7\n2 7\n9 7\n10 7\n3 6\n4 1\n9 1\n8 7\n10 2\n", "10 17\n5 1\n8 1\n2 1\n4 6\n2 1\n5 8\n3 7\n8 6\n4 7\n2 7\n9 7\n10 7\n3 6\n4 1\n9 1\n8 7\n10 2\n", "10 17\n5 1\n8 1\n2 1\n4 6\n2 1\n5 8\n3 7\n8 6\n4 7\n2 7\n9 7\n10 7\n3 6\n4 1\n9 1\n8 8\n10 2\n", "10 16\n6 10\n5 2\n6 4\n6 10\n5 3\n5 4\n6 2\n5 9\n5 7\n5 1\n6 9\n5 8\n5 10\n6 1\n6 7\n6 3\n", "20 22\n3 18\n9 19\n6 3\n7 1\n16 8\n18 7\n12 3\n18 4\n9 15\n20 1\n4 2\n6 7\n14 2\n7 15\n7 10\n8 1\n13 6\n9 7\n11 8\n2 6\n18 5\n17 15\n", "20 22\n20 8\n1 3\n3 18\n14 3\n19 6\n7 20\n14 8\n8 10\n2 5\n11 2\n4 19\n14 2\n7 11\n15 1\n12 15\n7 6\n11 13\n1 16\n9 12\n1 19\n17 3\n11 20\n", "5 7\n3 2\n5 4\n3 4\n1 3\n2 5\n1 4\n2 5\n", "1001 1\n195 788\n", "5 7\n3 1\n5 4\n4 4\n1 3\n1 5\n1 4\n2 5\n", "10 15\n5 7\n8 8\n2 9\n1 9\n3 8\n3 6\n5 8\n1 8\n6 9\n7 9\n4 8\n4 9\n10 9\n10 8\n6 8\n", "10 15\n5 7\n8 8\n2 9\n1 9\n2 8\n3 9\n5 8\n1 8\n6 9\n7 9\n4 8\n4 6\n10 9\n10 8\n6 8\n", "10 9\n2 5\n2 4\n2 9\n2 9\n1 3\n1 9\n2 6\n4 10\n2 1\n", "10 15\n5 7\n8 8\n2 9\n1 9\n3 8\n3 9\n5 1\n1 8\n6 9\n7 9\n4 8\n2 6\n10 9\n10 8\n6 8\n", "10 15\n5 7\n8 8\n2 9\n1 7\n3 8\n3 9\n5 9\n1 8\n6 9\n7 9\n4 8\n2 6\n10 9\n10 8\n6 8\n", "20 22\n6 18\n11 19\n6 15\n7 1\n16 8\n18 7\n12 3\n18 4\n9 15\n20 1\n4 2\n6 7\n14 2\n7 15\n7 10\n8 1\n13 6\n9 7\n11 8\n2 6\n18 5\n17 15\n", "10 17\n5 1\n8 1\n2 1\n2 6\n3 1\n5 8\n3 7\n3 6\n4 7\n2 7\n9 7\n10 7\n3 6\n4 1\n9 1\n8 7\n10 1\n", "10 10\n6 4\n9 2\n3 6\n6 7\n4 2\n9 6\n8 6\n5 7\n1 10\n6 10\n", "10 15\n5 7\n8 8\n2 9\n1 9\n3 8\n3 9\n5 8\n1 6\n6 9\n9 9\n4 8\n4 9\n10 9\n10 8\n6 8\n", "5 7\n5 4\n5 4\n5 4\n1 1\n1 5\n1 4\n2 5\n", "10 15\n5 7\n8 9\n2 9\n1 9\n3 8\n6 9\n5 8\n1 8\n6 9\n7 9\n4 8\n4 6\n10 9\n10 8\n6 8\n", "10 9\n2 10\n2 4\n2 9\n2 9\n2 3\n1 9\n2 6\n3 10\n2 1\n", "10 15\n5 7\n8 8\n2 9\n1 9\n3 8\n3 9\n5 8\n1 10\n6 9\n7 9\n4 8\n2 6\n10 9\n10 8\n3 8\n", "10 15\n5 7\n8 8\n2 9\n1 3\n3 8\n3 9\n5 9\n1 7\n6 9\n7 9\n4 8\n2 6\n10 9\n10 8\n6 8\n" ], "output": [ "8\n1 3 4 5 6 7 8 9\n2\n2 10\n", "4\n1 2 5 6\n6\n3 4 7 8 9 10\n", "-1\n", "1\n195\n1\n788\n", "7\n1 3 4 5 6 7 9\n2\n2 10\n", "8\n1 2 3 4 7 8 9 10\n2\n5 6\n", "8\n1 2 3 4 5 6 7 10\n2\n8 9\n", "1\n11449\n1\n26257\n", "7\n1 3 4 7 8 9 10\n3\n2 5 6\n", "4\n1 2 5 6\n5\n3 4 7 8 9\n", "3\n1 6 7\n7\n2 3 4 5 8 9 10\n", "1\n21752\n1\n40376\n", "7\n1 3 4 5 6 7 8\n2\n2 10\n", "7\n1 2 3 7 8 9 10\n3\n4 5 6\n", "7\n1 2 3 4 5 7 10\n2\n8 9\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "4\n1 2 5 6\n6\n3 4 7 8 9 10\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "8\n1 2 3 4 7 8 9 10\n2\n5 6\n", "-1\n", "-1\n", "-1\n", "1\n195\n1\n788\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "4\n1 2 5 6\n6\n3 4 7 8 9 10\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n", "-1\n" ] }
2
2
{ "language": [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ], "solution": [ "n = int(raw_input())\nm = map(int, raw_input().split())\nfor i in range(0,len(m)):\n count =1\n for j in range(0,len(m)):\n if(m[i]<m[j]):\n count+=1\n print count,", "t=int(raw_input())\na=map(int,raw_input().split())\nb=sorted(a,reverse=True)\nfor i in range(len(b)):\n\tprint b.index(a[i])+1,", "test=input()\ncls=map(int,raw_input().split(\" \"))\nclas=sorted(cls,reverse=True)\nnew=[]\nfor i in cls:\n\tnew.append(1+clas.index(i))\nfor i in new:\n\tprint i,", "n=input()\na=map(int,raw_input().split())\nb=a[:]\nb.sort(reverse=True)\nfor i in range(n):\n\tprint b.index(a[i])+1,\nprint", "no_st=int(raw_input(\"\"))\nmarks=map(int,raw_input(\"\").split())\n\nfor i in xrange(len(marks)):\n\trank=0\n\tfor x in xrange(len(marks)):\n\t\tif (x!=i and marks[x]>marks[i]):\n\t\t\trank +=1\n\tprint rank+1,", "n=input()\na=map(int,raw_input().split())\nc=[]\nx=list(a)\nx.sort()\nset(x)\nx=x[::-1]\nfor i in range(n):\n\tc.append(x.index(a[i])+1)\nprint ' '.join(map(str,c))", "raw_input(\"\")\nmarks=map(int,raw_input(\"\").split())\n\nfor i in xrange(len(marks)):\n\trank=0\n\tfor x in xrange(len(marks)):\n\t\tif (x!=i and marks[x]>marks[i]):\n\t\t\trank +=1\n\tprint rank+1,", "input_len = int(raw_input())\ninput_val = [int(item) for item in raw_input().split(' ')]\nrank = ''\nif input_len == len(input_val):\n\tfor item in input_val:\n\t\trank = rank + str(len([val for val in input_val if val > item]) + 1) + ' '\nprint rank", "students=int(raw_input())\na=[0]*students\na=raw_input().split()\nfor i in range(students):\n\ta[i]=int(a[i])\nb=[]\nfor i in range(len(a)):\n\tp=a[i]\n\tcount=0\n\tfor j in range(len(a)):\n\t\tif a[j]>p:\n\t\t\tcount+=1\n\tb.append(count+1)\nfor i in range(len(b)):\n\tb[i]=str(b[i])\nb=' '.join(b)\nprint b", "n = input()\na = raw_input()\nb = map(int,a.split(\" \"))\nst = \"\"\nfor i in b:\n c = 0\n for j in b:\n if i<j:\n c = c+1\n st = st + str(c+1) + \" \"\nprint st[:-1]", "'''\n# Read input from stdin and provide input before running code\n\nname = raw_input('What is your name?\\n')\nprint 'Hi, %s.' % name\n'''\n#print 'Hello World!'\nn1=int(raw_input())\na=[int(i) for i in raw_input().split(\" \")]\nfor i in range(n1):\n\tc=0\n\tfor j in range(n1):\n\t\tif j!=i:\n\t\t\tif a[i]<a[j]:\n\t\t\t\tc+=1\n\tprint c+1,", "raw_input(\"\")\nmarks=map(int,raw_input(\"\").split())\nfor i in range(len(marks)):\n\trank=0\n\tfor x in range(len(marks)):\n\t\tif (x!=i and marks[x]>marks[i]):\n\t\t\trank +=1\n\tprint rank+1,", "n=input()\na=map(int,raw_input().split())\nb=list(a)\nb.sort(reverse=True)\nfor i in range(n):\n\tprint b.index(a[i])+1,\nprint", "n = int(raw_input())\nl = map(int,raw_input().split())\na = sorted(l,reverse = True)\nfor i in l:\n\tprint a.index(i)+1,", "import copy\nn=input()\na=map(int,raw_input().split())\nb=copy.copy(a)\nb.sort(reverse=True)\nfor i in range(n):\n\tprint b.index(a[i])+1,\nprint", "n=int(raw_input())\nlst=map(int,raw_input().split())\nrank=[]\nfor i in range(n):\n rank.append(0)\nfor i in range(n):\n count=1\n ele=lst[i]\n for j in range(n):\n if ele<lst[j]:\n count=count+1\n rank[i]=count\nfor i in range(n):\n print rank[i],", "n=input()\na=map(int,raw_input().split())\nfor i in range(n):\n\tprint sum(x>a[i] for x in a)+1,", "numberOfInputs = raw_input()\n#inputVal = raw_input()\n\ninputStrList=raw_input().split()\ninputIntList=[]\nfor strNum in inputStrList:\n inputIntList.append(int(strNum));\n\ninputIntList.sort(reverse=True)\n#print inputIntList\n\n\nrankDict={}\nfirstRank=1\nfor num in inputIntList: \n rankDict[firstRank]=num\n firstRank=firstRank+1\n\n\n#print rankDict\n\nresultString=\"\"\nfor inputMarks in inputStrList:\n for rank,marks in rankDict.items():\n if int(inputMarks) == marks:\n resultString=resultString+str(rank)+\" \" \n break\nprint resultString[:-1]", "n = input()\nmarks = map(int,raw_input().split())\n\narr = [0]*1001\n\nfor i in marks:\n\tarr[i] += 1\n\n#cumulative sum...\nfor i in range(1,1001):\n\tarr[i] += arr[i-1]\n\nfor i in range(n):\n\tprint arr[1000]-arr[marks[i]]+1,#hackerearth problem name: the competetive class" ] }
{ "language": [ 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 0, 3, 2, 2, 3, 2, 4, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 3, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 3, 2, 0, 2, 3, 3, 2, 2, 0, 2, 2, 2, 2, 2, 2, 0, 2, 2, 4, 2, 2, 0, 2, 2, 3, 2, 2, 2, 4, 2, 2, 2, 2, 2, 0, 0, 0, 2, 2, 0, 2, 2, 2, 2, 3, 2, 2, 0, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 0, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 0, 2 ], "solution": [ "#include <bits/stdc++.h>\nusing namespace std;\nvector<int> ans_list;\nint dp[10000000];\nint main() {\n int Q;\n cin >> Q;\n memset(dp, 0, sizeof(dp));\n while (Q) {\n Q--;\n int N;\n cin >> N;\n int ans = 0;\n while (N / 10 > 0) {\n if (dp[N] != 0) {\n N = dp[N];\n continue;\n }\n int tmp = 0;\n for (int i = 1; N / pow(10, i) > 0; i++) {\n tmp = max(tmp, (N / (int)pow(10, i)) * (N % (int)pow(10, i)));\n }\n dp[N] = tmp;\n N = tmp;\n ans++;\n }\n ans_list.push_back(ans);\n }\n for (int i = 0; i < ans_list.size(); i++) {\n cout << ans_list[i] << endl;\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint main(void) {\n int Q, R;\n int ko, max;\n int cnt;\n cin >> Q;\n for (int i = 0; i < Q; i++) {\n cin >> R;\n cnt = 0;\n while (1) {\n if (R / 10 == 0) break;\n max = (R / 10) * (R % 10);\n for (int j = 100; R / j != 0; j *= 10) {\n ko = (R / j) * (R % j);\n if (ko > max) ko = max;\n }\n cnt++;\n R = max;\n }\n cout << cnt << endl;\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nint q;\nstd::string str, b, e;\nint solve(int m) {\n int cnt = 0;\n while (1) {\n str = std::to_string(m);\n if (str.size() == 1) break;\n b.clear();\n e = str;\n int l, r, max = 0;\n for (int i = 0; i < str.size() - 1; ++i) {\n b += str[i];\n e.erase(e.begin());\n l = std::stoi(b);\n r = std::stoi(e);\n max = std::max(max, l * r);\n m = max;\n }\n ++cnt;\n }\n return cnt;\n}\nint main() {\n std::cin >> q;\n int n;\n for (int i = 0; i < q; ++i) {\n std::cin >> n;\n std::cout << solve(n) << std::endl;\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint Q, N, logn, r, l, turn;\nint main() {\n cin >> Q;\n for (int i = 0; i < Q; i++) {\n cin >> N;\n logn = int(log10(N)) + 1;\n if (logn == 1)\n cout << 0 << endl;\n else {\n turn = 0;\n while (logn != 1) {\n int max = 0;\n for (int j = 0; j < logn - 1; j++) {\n r = N % int(pow(10, j + 1));\n l = N / int(pow(10, j + 1));\n if (max < r * l) {\n max = r * l;\n }\n }\n N = max;\n if (N == 0)\n logn = 1;\n else\n logn = int(log10(N)) + 1;\n turn++;\n }\n cout << turn << endl;\n }\n }\n return 0;\n}\n", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\n\nusing CHY72;\n\nnamespace CHY72{\n \n public class PointXY{\n public int X , Y;\n public int SQLength() { return X * X + Y * Y; }\n public bool Flag = false;\n public PointXY(int _X,int _Y) {\n X = _X; Y = _Y;\n }\n public PointXY(PointXY P1, int _X = 0, int _Y = 0) {\n X = P1.X + _X; Y =P1.Y + _Y;\n }\n public static bool operator ==(PointXY P1, PointXY P2) {\n return (P1.X== P2.X && P1.Y == P2.Y);\n }\n public static bool operator !=(PointXY P1, PointXY P2) {return !(P1 ==P2);}\n public override int GetHashCode() {return X.GetHashCode() ^ Y.GetHashCode();}\n public override bool Equals(object obj) {\n if (obj == null || this.GetType() != obj.GetType()) {return false;}\n return (this == (PointXY)obj);\n }\n\n }\n\n public class Lib72 {\n public static int NumFromChar(char CNUM) { return CNUM - 48; }\n\n public static int[] KETAArray(int Num) {return KETAArray(Num.ToString()); }\n public static int[] KETAArray(string Num) {\n char[] cKETA = Num.ToCharArray();\n int[] iKETA = new int[cKETA.Length];\n for (int i = 0; i < iKETA.Length; i++) {\n iKETA[i] = NumFromChar(cKETA[i]);\n }\n return iKETA;\n }\n public static int KETA(int Num) { return Num.ToString().ToCharArray().Length; }\n public static int FromKETAArray(int[] _ketaarray) {\n int result = 0;\n int[] R_ketaarray = _ketaarray.Reverse().ToArray(); \n for (int i = 0,j=1; i < R_ketaarray.Length; i++,j *=10) {\n result += j * R_ketaarray[i];\n }\n return result;\n }\n public static bool isPrime(int p) {\n if (p != 2 && p % 2 == 0) return false;\n if (p == 1) return false;\n int SQp = (int)(Math.Sqrt(p));\n for (int i = 3; i <= SQp; i++) {\n if (p % i == 0) return false;\n }\n return true;\n } \n }\n} \n\npublic class Program {\n static bool ReadLine_1(ref int num1, bool Fin0 = true) {\n string str = Console.ReadLine();\n num1 = int.Parse(str);\n return (Fin0 && num1 == 0);\n }\n static int ReadLine_1() {\n return int.Parse(Console.ReadLine());\n }\n static bool ReadLine_2(ref int num1, ref int num2, char Spliter = ' ', bool Fin0 = true,int FinNum =0) {\n string str = Console.ReadLine();\n num1 = int.Parse(str.Split(Spliter)[0]);\n num2 = int.Parse(str.Split(Spliter)[1]);\n return (Fin0 && num1 == FinNum && num2 == FinNum);\n }\n static int[] ReadLine72(char Spliter = ' ') {\n return Console.ReadLine().Split(Spliter).Select(s => int.Parse(s)).ToArray();\n }\n\n const int DefaultMax = 72727272;\n\n\n\n static void Main(string[] args) {\n int Q = ReadLine_1();\n for (int i = 0; i < Q; i++) {\n int N = ReadLine_1(); int R = 0;\n while (true){\n if (Lib72.KETA(N) == 1) break;\n string Nstr = \"\" + N;\n break;\n\n R++;\n }\n Console.WriteLine(Rer);\n }\n }\n}", "#include <bits/stdc++.h>\nusing namespace std;\nint main() {\n int n, a, b, i, c, p, w, x, m, j, k, t;\n cin >> n;\n while (n--) {\n cin >> a;\n c = 0;\n if (a == 619509) c--;\n while (1) {\n for (m = 0, t = b = a, i = -1; a; a /= 10) i++;\n if (!i || !t) break;\n for (a = b, j = 1; j <= i; j++) {\n w = 0;\n a = b = t;\n for (k = 0; k != j; k++) {\n int o = 1;\n p = a % 10;\n for (x = 1; x <= k; x++) o *= 10;\n w += o * p;\n a /= 10;\n }\n while (x--) b /= 10;\n if (w)\n m = max(m, w * b);\n else\n m = b;\n }\n a = m;\n c++;\n }\n cout << c << endl;\n }\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nvector<long long int> list, oddlist;\nint listcnt, oddlistcnt;\nint oddrec(int target, int sum, int cnt, int maxcnt) {\n int res = 0xFFFF;\n if (maxcnt < cnt) return 0xFFFE;\n if (sum == target) return cnt;\n for (int i = oddlistcnt - 1; 0 <= i; i--) {\n if (sum + oddlist[i] > target) continue;\n res = min(res, oddrec(target, sum + oddlist[i], cnt + 1, maxcnt));\n if (res == 0xFFFE) break;\n }\n return res;\n}\nint ress;\nvoid mama(int x) {\n if (x == 0) return;\n int tmp[oddlistcnt];\n memset(tmp, 0, sizeof(tmp));\n for (int i = 0; i < oddlistcnt; i++) {\n tmp[i] = x / oddlist[i];\n if (tmp[i] == 0) {\n ress += tmp[i - 1];\n mama(x % tmp[i - 1]);\n break;\n }\n }\n}\nint main(void) {\n for (long long int i = 1; i * (i + 1) * (i + 2) / 6 < 1e6; i++) {\n list.push_back(i * (i + 1) * (i + 2) / 6);\n if (i * (i + 1) * (i + 2) / 6 % 2)\n oddlist.push_back(i * (i + 1) * (i + 2) / 6);\n }\n listcnt = list.size();\n oddlistcnt = oddlist.size();\n while (true) {\n int n;\n scanf(\"%d\", &n);\n if (!n) break;\n int res = 5, oddres = 1000;\n for (int i = listcnt - 1; 0 <= i; i--) {\n if (list[i] > n) continue;\n if (list[i] == n) {\n res = 1;\n break;\n }\n if (res <= 2) continue;\n for (int j = listcnt - 1; 0 <= j; j--) {\n if (list[i] + list[j] > n) continue;\n if (list[i] + list[j] == n) res = 2;\n if (res <= 3) continue;\n for (int k = listcnt - 1; 0 <= k; k--) {\n if (list[i] + list[j] + list[k] > n) continue;\n if (list[i] + list[j] + list[k] == n) res = 3;\n if (res <= 4) continue;\n for (int l = listcnt - 1; 0 <= l; l--) {\n if (list[i] + list[j] + list[k] + list[l] > n) continue;\n if (list[i] + list[j] + list[k] + list[l] == n) res = 4;\n if (res <= 4) break;\n }\n }\n }\n }\n if ((oddres = oddrec(n, 0, 0, 1)) >= 0xFFFE) {\n for (int i = 2;; i = i * 3 / 2) {\n if ((oddres = oddrec(n, 0, 0, i)) < 0xFFFE) break;\n }\n }\n printf(\"%d %d\\n\", res, oddres);\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nint max(int a, int b) {\n if (a < b)\n return b;\n else\n return a;\n}\nint Q, A;\nint t[1000005];\nint solve() {\n int i;\n int cnt = 0;\n while (A >= 10) {\n if (t[A] == 1) return -1;\n t[A] = 1;\n int x = -1;\n for (i = 10; i < A; i *= 10) {\n int a = A / i, b = A % i;\n x = max(x, a * b);\n }\n A = x;\n cnt++;\n }\n return cnt;\n}\nint main() {\n int i;\n scanf(\"%d\", &Q);\n for (i = 1; i <= Q; i++) {\n scanf(\"%d\", &A);\n printf(\"%d\\n\", solve());\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nstring To_string(int i) {\n stringstream ss;\n ss << i;\n return ss.str();\n}\nint GetDigit(int num) { return To_string(num).length(); }\nint Q;\nint main() {\n cin >> Q;\n for (int i = 0; i < Q; ++i) {\n int n;\n cin >> n;\n int digit = GetDigit(n);\n int count = 0;\n while (1) {\n int max = 0;\n if (n >= 1 && n <= 9) {\n cout << count << endl;\n break;\n } else {\n for (int j = 1; j <= digit - 1; ++j) {\n int op1 = n / int(pow(10, j));\n int op2 = n % int(pow(10, j));\n if (op1 * op2 > max) {\n max = op1 * op2;\n }\n }\n ++count;\n if (max >= 1 && max <= 9) {\n cout << count << endl;\n break;\n } else if (count > 100) {\n cout << \"-1\" << endl;\n break;\n } else {\n n = max;\n }\n }\n }\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nvector<int> ans_list;\nbool dp[1000000];\nint main() {\n int Q;\n cin >> Q;\n memset(dp, 0, sizeof(dp));\n while (Q) {\n Q--;\n int N;\n cin >> N;\n int ans = 0;\n memset(dp, 0, sizeof(dp));\n while (N / 10 > 0) {\n if (dp[N]) {\n ans = -1;\n break;\n }\n int tmp = 0;\n for (int i = 1; N / pow(10, i) > 0; i++) {\n tmp = max(tmp, (N / (int)pow(10, i)) * (N % (int)pow(10, i)));\n }\n dp[N] = false;\n N = tmp;\n ans++;\n }\n ans_list.push_back(ans);\n }\n for (int i = 0; i < ans_list.size(); i++) {\n cout << ans_list[i] << endl;\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint main() {\n int Q;\n cin >> Q;\n while (Q--) {\n string s;\n cin >> s;\n int cnt = 0;\n while (s.size() > 1) {\n int maxi = 0;\n for (int i = 1; i < s.size(); i++) {\n string left = s.substr(0, i), right = s.substr(i, s.size() - i);\n maxi = max(maxi, atoi(left.c_str()) * atoi(right.c_str()));\n }\n s = to_string(maxi);\n cnt++;\n }\n cout << cnt << endl;\n }\n}\n", "import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons,std.numeric,std.math,std.random,std.concurrency;\nconst dx = [1,0,-1,0], dy = [0,1,0,-1];\nconst readMixin = q{ auto line = readln().split();foreach(i,ref arg; args){ if (i >= line.length) return;arg = line[i].to!(typeof(arg));}};\nvoid read(T...) (auto ref T args){ mixin(readMixin);}\nvoid readArray(T)(auto ref T args){ mixin(readMixin);}\nint read(){int n;read(n);return n;}\nvoid times(int n,void delegate() stmt){foreach(i;iota(n))stmt();}\nauto dot(R1,R2)(R1 a,R2 b){ElementType!(R1) res=0;for(;!a.empty&&!b.empty;a.popFront(),b.popFront())res+=a.front*b.front;return res;}\nauto infIota = (int i=0) => new std.concurrency.Generator!int({for(;;)yield(i++);});\n\nint calc(int n){\n\tif (n < 10) return 0;\n\tint [] ns;\n\twhile(n){ns ~= n % 10;n /= 10;}\n\tint [] res;\n\tauto tens = infIota().map!\"10^^a\";\n\tforeach(i;1 .. ns.length){\n\t\tres ~= ns[0..i].dot(tens) * ns[i..$].dot(tens);\n\t}\n\treturn 1 + calc(res.reduce!(max));\n}\nvoid main(){ \n\tread().times({ read().calc.writeln; });\n}", "for _ in range(int(input())):\n n=int(input())\n a=0;b=[]\n while n//10:\n a+=1\n b+=[n]+b\n x=1;s=m=0\n while n:\n s+=x*(n%10)\n n//=10\n x*=10\n m=max(s*n,m)\n n=m\n if b[-1]==n:print(-1);break\n else:print(a)", "#include <bits/stdc++.h>\nconst double PI = 3.14159265358979323846;\nconst double esp = 1e-9;\nconst int infi = (int)1e+9 + 10;\nconst long long infll = (long long)1e+17 + 10;\nint q;\nint main() {\n std::cin >> q;\n for (int i = 0; i < q; ++i) {\n int n;\n std::cin >> n;\n int cnt = 0;\n while (true) {\n int max = 0;\n std::string str = std::to_string(n);\n for (int i = 1; i < str.size() + 1; ++i) {\n max =\n std::max(max, std::atoi(str.substr(0, i).c_str()) *\n std::atoi(str.substr(i, str.size() - i).c_str()));\n }\n if (max != 0) {\n n = max;\n cnt++;\n } else\n break;\n }\n std::cout << cnt << std::endl;\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint main() {\n int q, n, count, a, b, res;\n string s, s1, s2;\n cin >> q;\n for (int i = 0; i < q; i++) {\n cin >> n;\n count = 0;\n while (1) {\n res = 0;\n if (n / 10 == 0) break;\n s = to_string(n);\n for (int j = 1; j < s.size(); j++) {\n s1.assign(s, 0, j);\n s2.assign(s, j, s.size() - j);\n a = stoi(s1);\n b = stoi(s2);\n res = max(res, a * b);\n }\n n = res;\n count++;\n }\n cout << count << endl;\n }\n return 0;\n}\n", "for i in range(int(input())):\n n = int(input())\n j = 0\n while n >= 10:\n L = [(n // (10**k)) * (n % (10**k))\n for k in range(1, int(log10(n)) + 1)]\n n = max(L)\n j += 1\n print(j)", "#include <bits/stdc++.h>\nusing namespace std;\nint search(int num) {\n if (num < 10) return 0;\n auto log = 10;\n auto v = 0;\n while (log < num) {\n auto tmp = (num % 10) * (num / 10);\n v = max(tmp, v);\n log *= 10;\n }\n return 1 + search(v);\n}\nint main() {\n auto n = 0;\n cin >> n;\n for (auto i = 0; i < n; i++) {\n auto num = 0;\n cin >> num;\n cout << search(num) << endl;\n }\n return 0;\n}\n", "public class Main{\n public void run(java.io.InputStream in, java.io.PrintStream out){\n java.util.Scanner sc = new java.util.Scanner(in);\n int n, nl, nr, i, j, max, q, count, d;\n int[] c;\n String s;\n\n for(q = sc.nextInt();q-- > 0;out.println(count)){\n n = sc.nextInt(); max = 0;\n for(count = -1;max != -1;count++){\n d = caldig(n);\n j = 10; max = -1;\n for(i = 1;i < d;i++){\n nr = n % j; nl = n / j;\n if(max < nr * nl)max = nr * nl;\n }\n n = max;\n }\n }\n\n sc.close();\n }\n private static int caldig(int n){\n int i;\n for(i = 1;i < 10;i++){\n if(n / 10 == 0)return i;\n n = n / 10;\n }\n return 0;\n }\n public static void main(String[] args){\n (new Main()).run(System.in, System.out);\n }\n}", "import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons,std.numeric,std.math,std.random;\nconst dx = [1,0,-1,0], dy = [0,1,0,-1];\nconst readMixin = q{ auto line = readln().split();foreach(i,ref arg; args){ if (i >= line.length) return;arg = line[i].to!(typeof(arg));}};\nvoid read(T...) (auto ref T args){ mixin(readMixin);}\nvoid readArray(T)(auto ref T args){ mixin(readMixin);}\nint read(){int n;read(n);return n;}\nvoid times(int n,void delegate() stmt){foreach(i;iota(n))stmt();}\nauto infIota = (int i=0) => generate(()=>i++);\nauto dot(R1,R2)(R1 a,R2 b){ElementType!(R1) res=0;for(;!a.empty&&!b.empty;a.popFront(),b.popFront())res+=a.front*b.front;return res;}\nint calc(int n){\n\tif (n < 10) return 0;\n\tint [] ns;\n\twhile(n){ns ~= n % 10;n /= 10;}\n\tint [] res;\n\tauto tens = infIota().map!\"10^^a\";\n\tforeach(i;iota(1,ns.length)){\n\t\tres ~= ns[0..i].dot(tens) * ns[i..$].dot(tens);\n\t}\n\treturn 1 + calc(res.reduce!(max));\n}\nvoid main(){ \n\tread().times({ read().calc.writeln; });\n}", "#include <bits/stdc++.h>\nusing namespace std;\nint main() {\n int n, m, t = 0;\n bool a[7777777];\n while (cin >> n >> m, n) {\n t = 0;\n memset(a, false, sizeof(a));\n for (int j = n; j < 7777777; j++) {\n if (!a[j]) {\n for (int k = j; k < 7777777; k += j) {\n a[k] = true;\n }\n t++;\n }\n if (m == 1) break;\n if (m != 1 && t == m) break;\n }\n for (int i = n; i < 7777777; i++) {\n if (!a[i]) {\n cout << i << endl;\n break;\n }\n }\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint maxNum(int N) {\n int maxInt = 0, i = 1, a, b;\n int lenN = (int)log10(N) + 1;\n while (i < lenN) {\n a = N / (int)pow(10.0, (double)lenN - i);\n b = N % (int)pow(10.0, (double)lenN - i);\n maxInt = max(maxInt, a * b);\n i++;\n }\n return maxInt;\n}\nint main() {\n int Q, cnt, N;\n set<int> S;\n scanf(\"%d\", &Q);\n for (int i = 0; i < Q; i++) {\n scanf(\"%d\", &N);\n cnt = 0;\n while (true) {\n set<int>::iterator iti = S.find(N);\n if (N < 10) {\n printf(\"%d\\n\", cnt);\n break;\n } else if (iti != S.end()) {\n printf(\"-1\\n\");\n break;\n } else {\n S.insert(N);\n N = maxNum(N);\n cnt++;\n }\n }\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint DivideMul(int N, int a) {\n int L = N % (int)pow(10, a);\n int U = (N - L) / pow(10, a);\n return L * U;\n}\nint Next(int N) {\n int n = 0;\n double s = log(N) / log(10);\n for (int i = 1; i < s; ++i) {\n n = max(n, DivideMul(N, i));\n }\n return n;\n}\nint main() {\n int T;\n cin >> T;\n for (int i = 0; i < T; ++i) {\n int N;\n cin >> N;\n if (N == 0) {\n cout << 0;\n break;\n }\n int j = 0;\n for (j = 0; N > 9; ++j) {\n N = Next(N);\n }\n cout << j << endl;\n ;\n }\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint max(int a, int b) {\n if (a >= b)\n return a;\n else\n return b;\n}\nint main() {\n int q;\n int ten[7] = {10, 100, 1000, 10000, 100000, 1000000};\n while (cin >> q) {\n int cnt = 0;\n for (int l = 0; l < q; l++) {\n int r;\n cin >> r;\n cnt = 0;\n while (1) {\n if (r < 10) {\n cout << cnt << endl;\n break;\n } else {\n int length = 0;\n for (int i = 0; i < 7; i++) {\n if (ten[i] >= q) {\n length = i;\n break;\n }\n }\n int next = 0;\n for (int i = 0; i <= length; i++) {\n int a, b;\n a = r % ten[i];\n b = r / ten[i];\n next = max(next, a * b);\n }\n r = next;\n cnt++;\n }\n }\n }\n break;\n }\n return 0;\n}\n", "import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons,std.numeric,std.math,std.random;\nconst dx = [1,0,-1,0], dy = [0,1,0,-1];\nconst readMixin = q{ auto line = readln().split();foreach(i,ref arg; args){ if (i >= line.length) return;arg = line[i].to!(typeof(arg));}};\nvoid read(T...) (auto ref T args){ mixin(readMixin);}\nvoid readArray(T)(auto ref T args){ mixin(readMixin);}\nint read(){int n;read(n);return n;}\nvoid times(int n,void delegate() stmt){foreach(i;iota(n))stmt();}\nauto dot(R1,R2)(R1 a,R2 b){ElementType!(R1) res=0;for(;!a.empty&&!b.empty;a.popFront(),b.popFront())res+=a.front*b.front;return res;}\nstruct infIota{int i=0;enum empty=false;int front(){return i;}void popFront(){i++;}}\n\nint calc(int n){\n\tif (n < 10) return 0;\n\tint [] ns;\n\twhile(n){ns ~= n % 10;n /= 10;}\n\tint [] res;\n\tauto tens = ()=> infIota().map!\"10^^a\";\n\tforeach(i;1 .. ns.length){\n\t\tres ~= ns[0..i].dot(tens()) * ns[i..$].dot(tens());\n\t}\n\treturn 1 + calc(res.reduce!(max));\n}\nvoid main(){ \n\tinfIota().take(10).writeln;\n\tread().times({ read().calc.writeln; });\n}", "#include <bits/stdc++.h>\nusing namespace std;\nint main() {\n int n, a, b, i, c, p, w, x, m, j, k, t;\n cin >> n;\n while (n--) {\n cin >> a;\n c = 0;\n while (1) {\n for (m = 0, t = b = a, i = -1; a; a /= 10) i++;\n if (!i || !t) break;\n for (a = b, j = 1; j <= i; j++) {\n w = 0;\n a = b = t;\n for (k = 0; k != j; k++) {\n int o = 1;\n p = a % 10;\n for (x = 1; x <= k; x++) o *= 10;\n w += o * p;\n a /= 10;\n }\n while (x--) b /= 10;\n if (w)\n m = max(m, w * b);\n else\n m = b;\n }\n a = m;\n c++;\n }\n cout << c << endl;\n }\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nconst int INF = 2 << 28;\nconst double EPS = 1e-10;\nint main() {\n int Q;\n cin >> Q;\n while (Q--) {\n int cnt = 0;\n string R;\n cin >> R;\n string prev = R;\n while (true) {\n if (R.size() == 1 || !(~cnt)) break;\n int maxi = 0;\n for (int i = 1; i < R.size(); i++) {\n int f = atoi(R.substr(0, i).c_str()),\n s = atoi(R.substr(i, R.size() - i).c_str());\n maxi = max(maxi, f * s);\n }\n R = to_string(maxi);\n if (R == prev)\n cnt = -1;\n else\n cnt++;\n }\n cout << cnt << endl;\n }\n}\n", "null", "#include<stdio.h>\n\nint main(){\n\nint n;\n\nscanf(\"%d\",&n);if(n==0)break;\nint x;\nfor(int i=0;i<n;i++)\n{scanf(\"%d\",&x);\nint c=0;int d=10;int w=0,y=0;int max=0;\nwhile(x/10!=0){\nfor(int j=0;j<6;j++)\n{\nw=x/d;y=x%d;d*=10;\nif(j==0)max=w*y;\nelse if(w*y>max)max=w*y;}\nx=max;c++;d=10;}\nprintf(\"%d\\n\",c);\n}}\nreturn 0;\n}", "\n\nimport java.util.ArrayList;\nimport java.util.Scanner;\n\npublic class Main{\n static ArrayList<Integer> multipliedMaxNums;\n static int numOfExe;\n\n public static void main(String[] args) {\n Scanner sc = new Scanner(System.in);\n int q = sc.nextInt();\n for (int i = 0; i < q; i++) {\n String num = sc.next();\n multipliedMaxNums = new ArrayList<Integer>();\n numOfExe = 0;\n solve(num);\n System.out.println(\"?????????\" + numOfExe);\n }\n sc.close();\n }\n\n public static void solve(String num) {\n if (num.length() == 1) {\n // System.out.println(0);\n } else {\n secondExe(num);\n }\n }\n\n public static void secondExe(String num) {\n int digitNumber = num.length();\n int max = 0;\n for (int i = 0; i < digitNumber - 1; i++) {\n int multipledNum = Integer.parseInt(num.substring(0, (i + 1)))\n * Integer.parseInt(num.substring((i + 1), digitNumber));\n if (max < multipledNum) {\n max = multipledNum;\n }\n }\n if (multipliedMaxNums.contains(max)) {\n numOfExe = -1;\n } else {\n numOfExe++;\n // System.out.println(\"?????§??????\" + max);\n multipliedMaxNums.add(max);\n solve(String.valueOf(max));\n }\n }\n\n}\n\n// ???????????±????????? 3 9 99 123\n// ???????????±????????? 2 999999 1000000\n// ???????????±????????? 5 9 99 123 999999 1000000\n// 0 2 3 12 1", "#include <iostream>\n#include <cstdio>\n#include <string>\n#include <vector>\n#include <algorithm>\n#include <cmath>\n#include <set>\n#include <map>\n#include <unordered_map>\n#include <unordered_set>\n#include <stack>\n#include <queue>\n//ranker\nusing namespace std;\n\n#define REPS(i, a, n) for (int i = (a); i < (n); ++i)\n#define REP(i, n) REPS(i, 0, n)\n#define RREP(i, n) REPS(i, 1, n + 1)\n#define DEPS(i, a, n) for (int i = (a); i >= n; --i)\n#define DEP(i, n) DEPS(i, n, 0)\n\nusing ll = long long;\nusing ull = unsigned long long;\nusing vi = vector<int>;\nusing vvi = vector<vi>;\nusing vvvi = vector<vvi>;\nusing pii = pair<int, int>;\nusing pis = pair<int, string>;\nusing psi = pair<string, int>;\nusing D = double;\n\nvoid merge (int *first1, int *last1, int *first2, int *last2){\n int size1 = last1 - first1;\n int size2 = last2 - first2;\n int *result = new int[size1+size2];\n int i = 0;\n int j = 0;\n int index = 0;\n while (true){\n if (i < size1 && (first1[i] <= first2[j] || j >= size2)){\n result[index] = first1[i];\n ++i; ++index;\n }\n if (j < size2 && (first1[i] > first2[j] || i >= size1)){\n result[index] = first2[j];\n ++j; ++index;\n }\n if (i==size1 && j==size2){\n for (i=0; i<size1; ++i) first1[i] = result[i];\n for (j=0; j<size2; ++j) first2[j] = result[j+size1];\n delete[] result;\n return;\n }\n }\n}\nvoid MergeSort (int *first, int *last){\n int size = last - first;\n if(size <= 1) return;\n MergeSort(first, first+size/2);\n MergeSort(first+size/2, last);\n merge(first, first+size/2, first+size/2, last);\n}\n\n//?????°????????????\nvoid sort2vectors(vector<int> &av, vector<int> &bv)\n{\n int n = av.size();\n vector<int> p(n), av2(n), bv2(n);\n iota(p.begin(), p.end(), 0);\n sort(p.begin(), p.end(), [&](int a, int b) { return av[a] < av[b]; });\n for (int i = 0; i < n; i++) {\n av2[i] = av[p[i]];\n bv2[i] = bv[p[i]];\n }\n av = av2;\n bv = bv2;\n}\n\n\nint gcd(int a, int b)\n{\n int c;\n if (a < b) {\n a+=b; b=a-b; a-=b;\n }\n while (b != 0) {\n c = a % b;\n a = b;\n b = c;\n }\n return a;\n}\n\nint isPrime(int x){\n int i;\n if(x < 2) return 0;\n else if(x == 2) return 1;\n if( x%2 == 0) return 0;\n for(i = 3; i*i <= 2; i += 2){\n if(x%i == 0) return 0;\n }\n return 1;\n}\n\n\nconst int pmax = 10000000;\nbool isPrime_table[pmax];\n//const???????????¨????????£?¨???§?????????\n\nvoid eratos(void){\n int i, j;\n double sqrtmax=sqrt(pmax);\n\n REP(k, pmax) isPrime_table[k] = true; /* Initialization */\n\n /* Sieve process */\n isPrime_table[0] = false;\n isPrime_table[1] = false;\n /* 0 and 1 are not prime. */\n for (i=2; i <= sqrtmax; i++){\n if (isPrime_table[i]==true){ /* i is prime. */\n for (j=i; i*j<pmax; j++){\n isPrime_table[i*j] = false; /* multiples of i are not prime. */\n }\n }\n }\n}\n\n//????????????????¨???°?????????\n//abs(dx[i]+dy[j])==1??§??????\nint dx[3]={-1, 0, 1};\nint dy[3]={-1, 0, 1};\nint W0, H0;\nint masu0[100][100]={0};\nint cnt0;\n\nint dfs(int a, int b){\n masu0[a][b] = 2;\n REP(i, 3)REP(j, 3){\n a = a+dx[i];\n b = b+dy[j];\n if(masu0[a][b]== 1 && a >= 0 && a < W0 && b >= 0 && b < H0){\n dfs(a, b);\n }\n }\n return 1;\n}\n\n//????????????????????????str.substr(i, 5)\n//????????°????????? stoi, stod ??¨to_string\n//?????????memset\n//?????°??????????????????\n//dp\n\nint main(void){\n cin.tie(0);\n ios::sync_with_stdio(false);\n\n int Q;\n cin >> Q;\n\n for(int i = 0; i<Q; i++){\n string suji;\n cin >> suji;\n\n int len = suji.length();\n int cnt = 0;\n while(std::stoi(suji) >= 10){\n int max = 0;\n for(int j = 1; j<len; j++){\n int num1;\n int num2;\n int tot;\n num1 = std::stoi(suji.substr(0, j));\n num2 = std::stoi(suji.substr(j, len-1));\n tot = num1 + num2;\n if(max < tot) max = tot;\n }\n cnt++;\n suji = std::to_string(max);\n }\n cout << cnt << endl;\n }\n return 0;\n}", "#include <bits/stdc++.h>\nusing namespace std;\nint p(int r) {\n int ans = -1;\n for (int i = 10; i <= r; i *= 10)\n ans = max(ans, ((r - r % 10) / 10) * (r % 10));\n return ans;\n}\nint main() {\n int q;\n cin >> q;\n for (int i = 0; i < q; i++) {\n int k;\n cin >> k;\n int cnt = 0;\n while (k >= 10) {\n k = p(k);\n cnt++;\n }\n cout << cnt << endl;\n }\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint main() {\n int Q;\n cin >> Q;\n while (Q--) {\n int n;\n cin >> n;\n map<int, int> memo;\n int ans = 0;\n while (!memo[n] && n >= 10) {\n memo[n] = true;\n int next = 0;\n stringstream ss;\n ss << n;\n string t = ss.str();\n for (int i = 0; i < t.size() - 1; i++) {\n string a = t.substr(0, i + 1);\n string b = t.substr(i + 1);\n int A = atoi(a.c_str());\n int B = atoi(b.c_str());\n next = max(next, A * B);\n }\n ans++;\n n = next;\n }\n if (n >= 10) {\n cout << -1 << endl;\n } else {\n cout << ans << endl;\n }\n }\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\ntypedef std::priority_queue<int> IntPrioQueue;\ntypedef std::priority_queue<int, std::vector<int>, std::greater<int> >\n IntReversePrioQueue;\nconst int MAX = 200000;\nconst double PI = 3.14159265358979323846;\nconst double EPS = 1e-12;\nconst int INF = 1 << 29;\nconst int MOD = 1000000007;\nint calc(int x) {\n if (x < 10) return 0;\n string s = to_string(x);\n int res = 1, tmp = -1;\n for (int i = 0; i <= (int)s.size() - 1 - 1; i++) {\n int a = stoi(s.substr(0, i + 1)), b = stoi(s.substr(i + 1));\n tmp = max(tmp, a * b);\n }\n res += calc(tmp);\n return res;\n}\nvoid solve(void) {\n int Q;\n cin >> Q;\n for (int i = 0; i <= Q - 1; i++) {\n int a;\n cin >> a;\n cout << calc(a) << endl;\n }\n}\nint main(void) {\n solve();\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint main() {\n int Q;\n cin >> Q;\n for (int i = 0; i < Q; i++) {\n int N;\n cin >> N;\n int count = 0;\n set<int> intSet;\n while (N > 9 && intSet.find(N) == intSet.end()) {\n intSet.insert(N);\n count++;\n string s;\n stringstream strStream;\n strStream << N;\n s = strStream.str();\n int maxV = 0;\n for (int i = 1; i < s.size(); i++) {\n string ss = s.substr(0, i);\n string sss = s.substr(i, s.size());\n cout << ss.data() << \" : \" << sss.data() << endl;\n int ii = atoi(ss.c_str());\n int iii = atoi(sss.c_str());\n maxV = max(maxV, ii * iii);\n }\n N = maxV;\n }\n if (intSet.find(N) != intSet.end()) {\n cout << -1 << endl;\n } else {\n cout << count << endl;\n }\n }\n return 0;\n}\n", "import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons,std.numeric,std.math;\nconst dx = [1,0,-1,0], dy = [0,1,0,-1];\nconst readMixin = q{ auto line = readln().split();foreach(i,ref arg; args){ if (i >= line.length) return;arg = line[i].to!(typeof(arg));}};\nvoid read(T...) (auto ref T args){ mixin(readMixin);}\nvoid readArray(T)(auto ref T args){ mixin(readMixin);}\nint read(){int n;read(n);return n;}\nvoid times(int n,void delegate() stmt){foreach(i;iota(n))stmt();}\n\nint calc(int n){\n\tif (n < 10) return 0;\n\tint [] ns;\n\twhile(n){ns ~= n % 10;n /= 10;}\n\tint [] res;\n\tauto tens = iota(ns.length).map!\"10^^a\";\n\tforeach(i;iota(1,ns.length)){\n\t\tres ~= reduce!((a,b)=>a+b[0]*b[1])(0,ns[0..i].zip(tens))\n\t\t\t* reduce!((a,b)=>a+b[0]*b[1])(0,ns[i..$].zip(tens)); \n\t}\n\treturn 1 + calc(reduce!(max)(0,res));\n}\nvoid main(){ \n\tread().times({ read().calc.writeln; });\n}", "#include <bits/stdc++.h>\nint main() {\n int n, count, cut;\n int num, front, back, max, now;\n std::vector<int> prev;\n while (scanf(\"%d\", &n) > 0) {\n for (int i = 0; i < n; i++) {\n scanf(\"%d\", &num);\n max = 0;\n count = 0;\n if (num < 10) {\n printf(\"%d\\n\", count);\n continue;\n }\n while (num > 10) {\n count++;\n back = 0;\n cut = 0;\n max = 0;\n while ((front = num / 10) > 0) {\n for (int i = 1; i <= cut; i++) back *= 10;\n back += (num % 10);\n now = back * front;\n if (max < now) max = now;\n num /= 10;\n }\n num = max;\n if (prev.size() != 0) {\n for (int i = 0; i < prev.size(); i++)\n if (num == prev.at(i)) {\n count = -1;\n goto out;\n }\n }\n prev.push_back(num);\n }\n out:\n printf(\"%d\\n\", count);\n prev.clear();\n }\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint main() {\n int n, m, s, max, cnt;\n string str, str1;\n cin >> n;\n for (int i = 0; i < n; i++) {\n cin >> str;\n cnt = 0;\n while (1) {\n if (str.size() == 1) break;\n str1 = str[0], max = 0;\n for (int j = 0; j < str.size() - 1; j++) {\n if (j > 0) str1 += str[j];\n m = stoi(str1), s = stoi(&str[j + 1]);\n if (max < m * s) max = m * s;\n }\n str = to_string(max), cnt++;\n }\n cout << cnt << endl;\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint solve(int n) {\n string s = to_string(n);\n int maxi = -1;\n for (int i = 0; i < (s.size() - 1); i++) {\n int tmp;\n tmp = stoi(s.substr(0, i + 1)) * stoi(s.substr(i + 1, s.size() - i));\n maxi = max(maxi, tmp);\n }\n return maxi;\n}\nint main() {\n int abcde;\n cin >> abcde;\n for (int i = 0; i < (abcde); i++) {\n int n;\n cin >> n;\n int c = 0;\n for (int i = 0; i < 1000000; i++) {\n if (i == 1000000 - 1) c = -1;\n if (n < 10) break;\n n = solve(n);\n c++;\n }\n cout << c << endl;\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint main() {\n int n, a, b, i, c, p, w, x, m, j, k, t;\n cin >> n;\n while (n--) {\n cin >> a;\n c = 0;\n while (1) {\n for (m = 0, t = b = a, i = -1; a; a /= 10) i++;\n if (!i || !t) break;\n for (a = b, j = 1; j <= i; j++) {\n w = 0;\n a = b = t;\n for (k = 0; k != j; k++) {\n int o = 1;\n p = a % 10;\n for (x = 1; x <= k; x++) o *= 10;\n w += o * p;\n a /= 10;\n }\n while (x--) b /= 10;\n if (w)\n m = max(m, w * b);\n else\n m = b;\n }\n a = m;\n if (a == 200448) c--;\n c++;\n }\n cout << c << endl;\n }\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint main() {\n int Q;\n cin >> Q;\n while (Q--) {\n string s;\n cin >> s;\n int ans = 0;\n int j = 0;\n while (s.length() > 1) {\n int l = 0;\n int r = stoi(s);\n int cnt = l * r;\n for (int i = (0); i < ((int)s.length() - 1); ++i) {\n l *= 10;\n l += s[i] - '0';\n r %= (int)pow(10, s.length() - i - 1);\n cnt = max(cnt, l * r);\n }\n s = to_string(cnt);\n j++;\n ans++;\n if (j == 100000) {\n cout << -1 << '\\n';\n break;\n }\n }\n cout << ans << '\\n';\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint main() {\n int n, a, b, i, c, p, w, x, m, j, k, t;\n cin >> n;\n while (n--) {\n cin >> a;\n c = 0;\n while (1) {\n for (m = 0, t = b = a, i = -1; a; a /= 10) i++;\n if (!i) break;\n for (a = b, j = 1; j <= i; j++) {\n w = 0;\n a = b = t;\n for (k = 0; k != j; k++) {\n int o = 1;\n p = a % 10;\n for (x = 1; x <= k; x++) o *= 10;\n w += o * p;\n a /= 10;\n }\n while (x--) b /= 10;\n if (w)\n m = max(m, w * b);\n else\n m = b;\n }\n a = m;\n c++;\n }\n cout << c << endl;\n }\n}\n", "#your code goes here\n#times volume24 2424\nQ=int(input())\nfor i in range(Q):\n N=str(input())\n c=0\n while len(N)>1 and c<15:\n M=0\n for j in range(1,len(N)):\n # print(N[:j])\n l=int(N[:j])\n r=int(N[j:])\n l*=r\n if M<l:\n M=l\n # print(M)\n N=str(M)\n c+=1\n print(N)\n if c>=15:\n d=[int(N)]\n while len(N)>1 and c>=0 and c<50:\n M=0\n for j in range(1,len(N)):\n # print(N[:j])\n l=int(N[:j])\n r=int(N[j:])\n l*=r\n if M<l:\n M=l\n print(M)\n k=0\n while k<len(d) and M<d[k]:\n k+=1\n print(d)\n if k>=len(d):\n k=-1\n elif M==d[k]:\n c=-1\n d.insert(k,M)\n N=str(N)\n print(N)\n print(c)", "#include <bits/stdc++.h>\nusing namespace std;\nint const MOD = 1000000007;\nint main() {\n int q;\n cin >> q;\n for (int i = 0; i < q; i++) {\n string s;\n cin >> s;\n int cnt = 0;\n while (1) {\n if (s.length() == 1)\n break;\n else {\n int ma = 0;\n for (int i = 1; i <= s.length(); i++) {\n string s1 = s.substr(0, i);\n string s2 = s.substr(i, s.length() - i);\n ma = max(ma, atoi(s1.c_str()) * atoi(s2.c_str()));\n }\n s = to_string(ma);\n cnt++;\n }\n }\n cout << cnt << endl;\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint main(void) {\n int n;\n string num;\n cin >> n;\n for (int i = 0; i < n; i++) {\n int cnt = 0;\n cin >> num;\n while (num.size() > 1) {\n int maxn = 0;\n for (int i = 0; i < num.size() - 1; i++) {\n string op1(num, i + 1, num.size() - i), op2(num, 0, i + 1);\n int n = stoi(op1) * stoi(op2);\n if (n > maxn) maxn = n;\n }\n num = to_string(maxn);\n cnt++;\n if (cnt > 1000000) break;\n }\n if (cnt <= 1000000)\n cout << cnt << endl;\n else\n cout << -1 << endl;\n }\n return 0;\n}\n", "import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons,std.numeric,std.math,std.random;\nconst dx = [1,0,-1,0], dy = [0,1,0,-1];\nconst readMixin = q{ auto line = readln().split();foreach(i,ref arg; args){ if (i >= line.length) return;arg = line[i].to!(typeof(arg));}};\nvoid read(T...) (auto ref T args){ mixin(readMixin);}\nvoid readArray(T)(auto ref T args){ mixin(readMixin);}\nint read(){int n;read(n);return n;}\nvoid times(int n,void delegate() stmt){foreach(i;iota(n))stmt();}\nauto infIota = (int i=0) => std.range.generate(()=>i++);\nauto dot(R1,R2)(R1 a,R2 b){ElementType!(R1) res=0;for(;!a.empty&&!b.empty;a.popFront(),b.popFront())res+=a.front*b.front;return res;}\nint calc(int n){\n\tif (n < 10) return 0;\n\tint [] ns;\n\twhile(n){ns ~= n % 10;n /= 10;}\n\tint [] res;\n\tauto tens = infIota().map!\"10^^a\";\n\tforeach(i;iota(1,ns.length)){\n\t\tres ~= ns[0..i].dot(tens) * ns[i..$].dot(tens);\n\t}\n\treturn 1 + calc(res.reduce!(max));\n}\nvoid main(){ \n\tread().times({ read().calc.writeln; });\n}", "#include <bits/stdc++.h>\nusing namespace std;\nusing ll = long long;\nusing vi = vector<int>;\nusing vl = vector<ll>;\nusing dict = map<string, int>;\nusing pii = pair<int, int>;\nusing pll = pair<ll, ll>;\ntemplate <typename T>\nT ston(string& str, T n) {\n istringstream sin(str);\n T num;\n sin >> num;\n return num;\n}\nint main() {\n cin.tie(0);\n ios::sync_with_stdio(false);\n ll q;\n string s = \"024\";\n cin >> q;\n for (int i = 0; i < (int)(q); ++i) {\n bool f = true;\n ll n = 0;\n cin >> s;\n while (s.size() != 1) {\n set<ll> st;\n ll ans = -1;\n for (int k = (1); k < (int)(s.size()); ++k) {\n string l = s, r = s;\n l.resize(k);\n r = r.substr(k);\n ll n2 = ston(l, 1) * ston(r, 1);\n ans = max(ans, n2);\n if (!st.insert(n2).second) {\n cout << -1 << endl;\n f = false;\n k = 1e9;\n break;\n }\n }\n s = to_string(ans);\n ++n;\n }\n if (f) cout << n << endl;\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint main() {\n int q;\n cin >> q;\n while (q--) {\n string s;\n cin >> s;\n int size = s.size();\n int res, ans = 0;\n while (size > 1) {\n res = 0;\n for (int i = 0; i < size - 1; i++) {\n string a = s.substr(0, i + 1);\n string b = s.substr(i + 1);\n res = max(atoi(a.c_str()) * atoi(b.c_str()), ans);\n }\n stringstream ss;\n ss << res;\n s = ss.str();\n size = s.size();\n ans++;\n }\n cout << ans << endl;\n }\n return 0;\n}\n", "#include <string>\n#include <iostream>\n#include <map>\n#include <vector>\n\nusing namespace std;\n\nint\nmain() {\n // int a = std::stoi(\"123\");\n // int a {std::stoi(\"0123\") };\n // vector<int> in { 9, 99, 123 };\n\n int n;\n cin >> n;\n vector<int> in;\n \n for (int i=0; i<n; ++i) {\n int v;\n cin >> v;\n in.push_back( stoi(v) );\n }\n \n for (auto i:in ) {\n int a = i, cnt=0;;\n string s{};\n while (a >= 10) {\n auto enum_int = [&] {\n\ts = to_string(a);\n\tvector<pair<string,string> > xs; \n\tfor (int i=1;i<s.size(); i++) {\n\t xs.push_back( std::make_pair( s.substr(0,i), s.substr(i) ) );\n\t}\n\treturn xs;\n };\n auto && xs = enum_int();\n int m = 0;\n for (auto & x : xs) {\n\tm = max(m, std::stoi(x.first) * std::stoi(x.second) );\n }\n a = m;\n cnt++;\n }\n cout << cnt << endl; \n }\n return 0;\n}", "#include <bits/stdc++.h>\nusing namespace std;\nint main() {\n int q;\n cin >> q;\n while (q--) {\n int n, res = 0;\n cin >> n;\n set<int> t;\n while (n / 10) {\n t.insert(n);\n res++;\n int MAX = 0;\n int j = 1, k = 0;\n while (n) {\n k += j * (n % 10);\n n /= 10;\n MAX = max(MAX, k * n);\n }\n n = MAX;\n if (t.find(n) != t.end()) {\n res = -1;\n break;\n }\n }\n cout << res << endl;\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint main() {\n map<int, bool> h;\n int q, n, cnt;\n cin >> q;\n while (q--) {\n cin >> n;\n cnt = 0;\n h.clear();\n h[n] = true;\n while (true) {\n int m = -1, k = 10;\n cnt++;\n for (int i = 0; i < 5; i++) {\n m = max(m, (n / k) * (n % k));\n k *= 10;\n }\n if (h[m]) {\n cout << -1 << endl;\n break;\n }\n if (m < 10) {\n cout << cnt << endl;\n break;\n }\n n = m;\n h[m] = true;\n }\n }\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint size(int n) {\n int s = 0;\n for (int j = 0;; j++) {\n if (n == 0) {\n s = 1;\n break;\n } else if ((pow(10, j)) <= n and n < (pow(10, j + 1))) {\n s++;\n break;\n } else\n s++;\n }\n return s;\n}\nint main() {\n int q;\n cin >> q;\n for (int i = 0; i < q; i++) {\n int n;\n cin >> n;\n int res = 0;\n while (size(n) != 1) {\n vector<int> v;\n for (int j = 1; j < size(n); j++) {\n int a, b;\n a = n % int(pow(10, j));\n b = n / int(pow(10, j));\n v.push_back(a * b);\n }\n n = *max_element(v.begin(), v.end());\n res++;\n }\n cout << res << endl;\n }\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint toInt(string s) {\n int v;\n istringstream sin(s);\n sin >> v;\n return v;\n}\ntemplate <class T>\ninline string toString(T x) {\n ostringstream sout;\n sout << x;\n return sout.str();\n}\nint main(void) {\n int q;\n cin >> q;\n while (q--) {\n int n;\n cin >> n;\n int maxnum = n;\n int cnt = 0;\n while (cnt < 10000) {\n string str = toString(maxnum);\n if (toString(maxnum).length() == 1) {\n cout << cnt << endl;\n break;\n }\n maxnum = 0;\n for (int i = 0; i < str.length(); i++) {\n string a = str.substr(0, i), b = str.substr(i);\n int tmp = toInt(a) * toInt(b);\n maxnum = max(maxnum, tmp);\n }\n cnt++;\n }\n if (cnt == 10000) cout << -1 << endl;\n }\n return 0;\n}\n", "from math import log10\n\nfor i in range(int(input())):\n n = int(input())\n j = 0\n while n >= 10:\n n = max((n / (10**k)) * (n % (10**k))\n for k in range(1, int(log10(n)) + 1))\n j += 1\n print(j)", "#include <bits/stdc++.h>\nusing namespace std;\nvector<int> ans;\nint main() {\n int q;\n cin >> q;\n for (int i = 0; i < q; i++) {\n int n;\n cin >> n;\n int tans = 0;\n vector<int> used;\n while (n >= 10) {\n int div = 10;\n int next = 0;\n for (int i = 0; i < 6; i++) {\n int l = n / div;\n int r = n % div;\n if (l != 0) {\n next = max(next, l * r);\n }\n }\n if (find(used.begin(), used.end(), next) != used.end()) {\n tans = -1;\n break;\n }\n used.push_back(next);\n n = next;\n tans++;\n }\n ans.push_back(tans);\n }\n for (int i = 0; i < ans.size(); i++) cout << ans[i] << endl;\n return 0;\n}\n", "n = gets.to_i\nn.times do\n r = gets.to_i\n break if r == 0\n i = 0\n while r >= 10\n max = 0\n (r.to_s.length - 1).times do |l|\n str = r.to_s\n a = str[0..l].to_i\n b = str[(l + 1)...str.length].to_i\n max = a * b if a * b > max\n end\n r = max\n i += 1\n end\n puts i\nend", "#include <bits/stdc++.h>\nint main() {\n int n;\n while (1) {\n scanf(\"%d\", &n);\n if (n == 0) break;\n int x;\n for (int i = 0; i < n; i++) {\n scanf(\"%d\", &x);\n int c = 0;\n int d = 10;\n int w = 0, y = 0;\n int max = 0;\n while (x / 10 != 0) {\n for (int j = 0; j < 6; j++) {\n w = x / d;\n y = x % d;\n d *= 10;\n if (j == 0)\n max = w * y;\n else if (w * y > max)\n max = w * y;\n }\n x = max;\n c++;\n d = 10;\n }\n printf(\"%d\\n\", c);\n }\n }\n return 0;\n}\n", "# your code goes here\n#times volume24 2424\nQ=int(input())\nfor i in range(Q):\n N=str(input())\n c=0\n while len(N)>1 and c<15:\n M=0\n for j in range(1,len(N)):\n # print(N[:j])\n l=int(N[:j])\n r=int(N[j:])\n l*=r\n if M<l:\n M=l\n # print(M)\n N=str(M)\n c+=1\n # print(N)\n if c>=15:\n d=[int(N)]\n while len(N)>1 and c>=0 and c<50:\n M=0\n for j in range(1,len(N)):\n # print(N[:j])\n l=int(N[:j])\n r=int(N[j:])\n l*=r\n if M<l:\n M=l\n # print(M)\n k=0\n while k<len(d) and M<d[k]:\n k+=1\n # print(d)\n if k>=len(d):\n k=-1\n elif M==d[k]:\n c=-1\n d.insert(k,M)\n N=str(N)\n # print(N)\n print(c)", "for i in range(int(input())):\n n = int(input())\n j = 0\n while n >= 10:\n m_max = 0\n for k in range(1, int(log10(n)) + 1):\n m = (n // (10**k)) * (n % (10**k))\n if m >= m_max:\n m_max = m\n n = m_max\n j += 1\n print(j)", "#include <bits/stdc++.h>\nusing namespace std;\nlong long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }\nlong long lcm(long long a, long long b) { return a / gcd(a, b) * b; }\nstring IntToString(long long int number) {\n stringstream ss;\n ss << number;\n return ss.str();\n}\nstring tmp;\nstring tmp2;\nint main() {\n int q, cnt;\n cin >> q;\n for (int i = 0; i < (int)(q); i++) {\n cin >> tmp;\n tmp2 = tmp;\n cnt = 0;\n while (tmp.size() != 1) {\n int mmax = -1;\n for (int i = (int)(1); i < (int)(tmp.size()); i++) {\n string st1, st2;\n for (int j = (int)(0); j < (int)(i); j++) st1 += tmp[j];\n for (int j = (int)(i); j < (int)(tmp.size()); j++) st2 += tmp[j];\n mmax = max(mmax, stoi(st1) * stoi(st2));\n }\n cnt++;\n tmp = IntToString(mmax);\n }\n cout << cnt << endl;\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint main() {\n int Q;\n int N;\n scanf(\"%d\", &Q);\n for (int i = 0; i < Q; i++) {\n int count = 0;\n scanf(\"%d\", &N);\n while (N >= 10) {\n int temp = N;\n int digit = 0;\n while (temp > 0) {\n digit++;\n temp /= 10;\n }\n count++;\n temp = 10;\n int max = 0;\n for (int i = 0; i < digit - 1; i++) {\n max = max > (N / temp) * (N % temp) ? max : (N / temp) * (N % temp);\n temp *= 10;\n }\n N = max;\n }\n printf(\"%d\\n\", count);\n }\n return 0;\n}\n", "import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons,std.numeric,std.math,std.random,std.concurrency;\nconst dx = [1,0,-1,0], dy = [0,1,0,-1];\nconst readMixin = q{ auto line = readln().split();foreach(i,ref arg; args){ if (i >= line.length) return;arg = line[i].to!(typeof(arg));}};\nvoid read(T...) (auto ref T args){ mixin(readMixin);}\nvoid readArray(T)(auto ref T args){ mixin(readMixin);}\nint read(){int n;read(n);return n;}\nvoid times(int n,void delegate() stmt){foreach(i;iota(n))stmt();}\nauto infIota = (int i=0) => generate(()=>i++);\nauto dot(R1,R2)(R1 a,R2 b){ElementType!(R1) res=0;for(;!a.empty&&!b.empty;a.popFront(),b.popFront())res+=a.front*b.front;return res;}\nauto gen(F)(F f){return new Generator!F(f);}\nauto infiota(int i = 0){\n\n}\nint calc(int n){\n\tif (n < 10) return 0;\n\tint [] ns;\n\twhile(n){ns ~= n % 10;n /= 10;}\n\tint [] res;\n\tauto tens = infIota().map!\"10^^a\";\n\tforeach(i;1 .. ns.length){\n\t\tres ~= ns[0..i].dot(tens) * ns[i..$].dot(tens);\n\t}\n\treturn 1 + calc(res.reduce!(max));\n}\nvoid main(){ \n\tread().times({ read().calc.writeln; });\n}", "#include <bits/stdc++.h>\nusing namespace std;\nint main() {\n int q;\n cin >> q;\n while (q--) {\n int n, res = 0;\n cin >> n;\n while (n / 10) {\n int pre = n;\n res++;\n int MAX = 0;\n int j = 1, k = 0;\n while (n) {\n k += j * (n % 10);\n n /= 10;\n MAX = max(MAX, k * n);\n }\n n = MAX;\n if (pre == n) {\n res = -1;\n break;\n }\n }\n cout << res << endl;\n }\n return 0;\n}\n", "#include <iostream>\n#include <vector>\n#include <string>\n#include <algorithm>\n#include <sstream>\nusing namespace std;\n\nint main(int argc, char *argv[])\n{\n int q, cnt, tmp;\n string n;\n vector<int>::iterator itr;\n cin >> q;\n while (cin >> n, q--) {\n vector<int> cache;\n for (cnt = 0;; ++cnt) {\n if (n.length() == 1)\n break;\n int kmax = 0;\n for (int i = 1; i < n.length(); ++i) {\n tmp = atoi(n.substr(0, i).c_str()) * atoi(n.substr(i).c_str());\n kmax = max(tmp, kmax);\n }\n itr = find(cache.begin(), cache.end(), kmax);\n if (itr != cache.end()) {\n cnt = -1;\n break;\n }\n else\n cache.push_back(kmax);\n stringstream ss;\n ss << kmax;\n n = ss.str();\n }\n cout << cnt << endl;\n }\n return 0;\n}\n[taguchi@Ken", "#include <bits/stdc++.h>\nusing namespace std;\nvoid solve(string N) {\n int l = N.size();\n int ans = 0;\n while (l > 1) {\n int maxi = 0;\n for (int i = 1; i < l; i++) {\n int pre = stoi(N.substr(0, i));\n int suf = stoi(N.substr(i, l - i));\n maxi = max(maxi, pre * suf);\n }\n N = to_string(maxi);\n l = N.size();\n ans++;\n }\n cout << ans << endl;\n}\nint main() {\n int Q;\n cin >> Q;\n for (int i = 0; i < Q; i++) {\n string N;\n cin >> N;\n solve(N);\n }\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nlong long calc(long long a) {\n string s = to_string(a);\n long long res = 0;\n for (long long i = 1; i < s.size(); i++) {\n long long t = stoi(s.substr(0, i)) * stoi(s.substr(i));\n res = max(res, t);\n }\n return res;\n}\nsigned main() {\n cin.tie(0);\n ios::sync_with_stdio(false);\n long long n;\n cin >> n;\n for (long long i = 0; i < (n); i++) {\n long long a;\n cin >> a;\n long long cnt = 0;\n while (10 <= a) {\n a = calc(a);\n cnt++;\n }\n cout << cnt << endl;\n }\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint toInt(string s) {\n int v;\n istringstream sin(s);\n sin >> v;\n return v;\n}\ntemplate <class T>\ninline string toString(T x) {\n ostringstream sout;\n sout << x;\n return sout.str();\n}\nint main(void) {\n int q;\n cin >> q;\n while (q--) {\n int n;\n cin >> n;\n int maxnum = n;\n int cnt = 0;\n while (cnt < 100000) {\n string str = toString(maxnum);\n if (toString(maxnum).length() == 1) {\n cout << cnt << endl;\n break;\n }\n maxnum = 0;\n for (int i = 0; i < str.length(); i++) {\n string a = str.substr(0, i), b = str.substr(i);\n int tmp = toInt(a) * toInt(b);\n maxnum = max(maxnum, tmp);\n }\n cnt++;\n }\n if (cnt == 10000) cout << -1 << endl;\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint main() {\n map<int, bool> h;\n int q, n, cnt;\n cin >> q;\n while (q--) {\n cin >> n;\n if (n < 10) {\n cout << n << endl;\n continue;\n }\n cnt = 0;\n h.clear();\n h[n] = true;\n while (true) {\n int m = -1, k = 10;\n cnt++;\n for (int i = 0; i < 5; i++) {\n m = max(m, (n / k) * (n % k));\n k *= 10;\n }\n if (h[m]) {\n cout << -1 << endl;\n break;\n }\n if (m < 10) {\n cout << cnt << endl;\n break;\n }\n n = m;\n h[m] = true;\n }\n }\n}\n", "#include <bits/stdc++.h>\nint main(void) {\n int q, r, i, j, k, x, numa, numb, ans, multi[6], max;\n scanf(\"%d\", &q);\n for (i = 0; i < q; i++) {\n for (j = 0; j < 6; j++) {\n multi[j] = 0;\n }\n scanf(\"%d\", &r);\n k = 1;\n ans = 0;\n for (; r >= 10;) {\n for (j = 0; j < 6; j++) {\n k = k * 10;\n numa = r / 10;\n numb = r % 10;\n multi[j] = numa * numb;\n }\n max = multi[0];\n for (j = 1; j < 6; j++) {\n if (max < multi[j]) {\n max = multi[j];\n }\n }\n r = max;\n ans++;\n if (ans == 1000) {\n break;\n }\n }\n if (ans == 1000) {\n printf(\"-1\\n\");\n } else {\n printf(\"%d\\n\", ans);\n }\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint main() {\n int n;\n while (cin >> n) {\n for (int i = 0; i < n; i++) {\n int a;\n set<int> s;\n bool f = false;\n cin >> a;\n for (int j = 0; a < 10; j++) {\n int cnt = 0;\n for (int k = 10; k <= a; k *= 10) cnt = max(cnt, a / k + a % k);\n if (s.find(cnt) != s.end()) {\n f = true;\n break;\n } else {\n a = cnt;\n s.insert(cnt);\n }\n }\n cout << (f ? -1 : a) << endl;\n }\n }\n}\n", "#include <iostream>\n#include <vector>\n#include <algorithm>\nusing namespace std;\n\nint main() {\n\tint q, n, m, i, j, a, b, d, cnt, max;\n\n\tcin >> q;\n\n\tfor (i = 0; i < q; i++) {\n\t\tcnt = 0; \n\t\tcin >> n;\n\n\t\twhile (n / 10 != 0) {\n\t\t\td = 1; m = n; max = 0;\n\n\t\t\twhile (m / 10 != 0) {\n\t\t\t\tm /= 10;\n\t\t\t\td++;\n\t\t\t}\n\n\t\t\tfor (j = 1; j < d; j++) {\n\t\t\t\ta = n / pow(10, j);\n\t\t\t\tb = n - a * pow(10, j);\n\t\t\t\tif (a * b > max) {\n\t\t\t\t\tmax = a * b;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tn = max;\n\t\t\tcnt++;\n\t\t}\n\t\t\n\t\tcout << cnt << endl;\n\t}\n}", "import java.io.InputStream;\nimport java.io.IOException;\nimport java.io.PrintWriter;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Comparator;\nimport java.util.InputMismatchException;\nimport java.util.NoSuchElementException;\nimport java.math.BigInteger;\n\npublic class Main{\n\nstatic PrintWriter out;\nstatic InputReader ir;\n\nstatic void solve(){\n int q=ir.nextInt();\n Arrays.fill(dp,-1);\n while(q-->0){\n int n=ir.nextInt();\n out.println(dfs(n));\n }\n}\n\nstatic int[] dp=new int[1000001];\n\npubilc static int dfs(int a){\n if(dp[a]>=0) return dp[a];\n if(a<10) return dp[a]=0;\n int ma=0;\n int base=10;\n for(int i=1;i<Integer.toString(a).length();i++){\n ma=Math.max((int)(a/base)*(a%base),ma);\n base*=10;\n }\n return dp[a]=dfs(ma)+1;\n}\n\npublic static void main(String[] args) throws Exception{\n ir=new InputReader(System.in);\n out=new PrintWriter(System.out);\n solve();\n out.flush();\n}\n\nstatic class InputReader {\n private InputStream in;\n private byte[] buffer=new byte[1024];\n private int curbuf;\n private int lenbuf;\n\n public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}\n \n public boolean hasNextByte() {\n if(curbuf>=lenbuf){\n curbuf= 0;\n try{\n lenbuf=in.read(buffer);\n }catch(IOException e) {\n throw new InputMismatchException();\n }\n if(lenbuf<=0) return false;\n }\n return true;\n }\n\n private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}\n \n private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}\n \n private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}\n \n public boolean hasNext(){skip(); return hasNextByte();}\n \n public String next(){\n if(!hasNext()) throw new NoSuchElementException();\n StringBuilder sb=new StringBuilder();\n int b=readByte();\n while(!isSpaceChar(b)){\n sb.appendCodePoint(b);\n b=readByte();\n }\n return sb.toString();\n }\n \n public int nextInt() {\n if(!hasNext()) throw new NoSuchElementException();\n int c=readByte();\n while (isSpaceChar(c)) c=readByte();\n boolean minus=false;\n if (c=='-') {\n minus=true;\n c=readByte();\n }\n int res=0;\n do{\n if(c<'0'||c>'9') throw new InputMismatchException();\n res=res*10+c-'0';\n c=readByte();\n }while(!isSpaceChar(c));\n return (minus)?-res:res;\n }\n \n public long nextLong() {\n if(!hasNext()) throw new NoSuchElementException();\n int c=readByte();\n while (isSpaceChar(c)) c=readByte();\n boolean minus=false;\n if (c=='-') {\n minus=true;\n c=readByte();\n }\n long res = 0;\n do{\n if(c<'0'||c>'9') throw new InputMismatchException();\n res=res*10+c-'0';\n c=readByte();\n }while(!isSpaceChar(c));\n return (minus)?-res:res;\n }\n\n public double nextDouble(){return Double.parseDouble(next());}\n\n public int[] nextIntArray(int n){\n int[] a=new int[n];\n for(int i=0;i<n;i++) a[i]=nextInt();\n return a;\n }\n\n public long[] nextLongArray(int n){\n long[] a=new long[n];\n for(int i=0;i<n;i++) a[i]=nextLong();\n return a;\n }\n\n public char[][] nextCharMap(int n,int m){\n char[][] map=new char[n][m];\n for(int i=0;i<n;i++) map[i]=next().toCharArray();\n return map;\n }\n}\n}", "#include <bits/stdc++.h>\nusing namespace std;\nint pow(int n, int k) {\n int res = 1;\n for (int i = 0; i < k; i++) {\n res *= n;\n }\n return n;\n}\nbool solve() {\n int num;\n cin >> num;\n int ans = 0;\n while (num / 10 != 0) {\n int tmp = num;\n int k = 0;\n while (tmp != 0) {\n tmp /= 10;\n k++;\n }\n int res = -1;\n for (int i = 0; i < k - 1; i++) {\n int n = num;\n int a = n % pow(10, k + 1);\n int b = n / pow(10, k + 1);\n res = max(res, a * b);\n }\n num = res;\n ans++;\n }\n cout << ans << endl;\n return true;\n}\nint main() {\n cout.setf(ios::fixed);\n cout.precision(10);\n int n;\n cin >> n;\n for (int i = 0; i < n; i++) solve();\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nconst double PI = acos(-1);\ntemplate <class S, class T>\nostream& operator<<(ostream& os, pair<S, T> p) {\n os << '(' << (p.first) << \", \" << (p.second) << ')';\n return os;\n}\ntemplate <class T>\nostream& operator<<(ostream& os, vector<T> v) {\n if (v.size() == 0) {\n os << \"(empty)\";\n return os;\n }\n os << v[0];\n for (int i = 1, len = v.size(); i < len; ++i) os << ' ' << v[i];\n return os;\n}\nint dx[] = {-1, 0, 1, 0};\nint dy[] = {0, -1, 0, 1};\nbool contains(vector<int>& vector<string>, int x) {\n for (int v : vector<string>) {\n if (v == x) return true;\n }\n return false;\n}\nint main() {\n int n;\n cin >> n;\n while (n--) {\n int x;\n cin >> x;\n int cx = 0;\n vector<int> history;\n while (x > 9) {\n int nx = 0;\n for (int d = 10;; d *= 10) {\n int z = x / d;\n int y = x % d;\n if (z == 0) break;\n nx = max(nx, z * y);\n }\n x = nx;\n cerr << \">>> \"\n << \"x\"\n << \" = \" << x << endl;\n ;\n ++cx;\n }\n cout << cx << endl;\n }\n return 0;\n}\n", "input = (read :: String -> Int) <$> getLine\ntoInt = (read :: String -> Int)\nsolve c n\n | length n > 1 = solve (c+1) $ show $ maximum [(toInt $ take d n)*(toInt $ drop d n) | d <- [1..(length n)-1]]\n | otherwise = c\n\naaaa n = if n > 0 then (getLine >>= \\x -> putStrLn $ show $ solve 0 x) >> aaaa (n-1) else do return ()\nmain = input >>= aaaa", "#include <bits/stdc++.h>\nusing namespace std;\nint inf = 1000000000;\nint main(void) {\n int q, n;\n cin >> q;\n for (int i = 0; i < q; i++) {\n cin >> n;\n int cnt = 0;\n while (n >= 10) {\n int tmp = -1;\n string ns = to_string(n);\n for (int i = 0; i < ns.size() - 1; i++) {\n cerr << ns.substr(0, i + 1) << \" \" << ns.substr(i + 1) << endl;\n tmp = max(tmp, stoi(ns.substr(0, i + 1)) * stoi(ns.substr(i + 1)));\n }\n n = tmp;\n cnt++;\n }\n cout << cnt << endl;\n }\n return 0;\n}\n", "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.IO;\n\nusing CHY72;\n\nnamespace CHY72{\n \n public class PointXY{\n public int X , Y;\n public int SQLength() { return X * X + Y * Y; }\n public bool Flag = false;\n public PointXY(int _X,int _Y) {\n X = _X; Y = _Y;\n }\n public PointXY(PointXY P1, int _X = 0, int _Y = 0) {\n X = P1.X + _X; Y =P1.Y + _Y;\n }\n public static bool operator ==(PointXY P1, PointXY P2) {\n return (P1.X== P2.X && P1.Y == P2.Y);\n }\n public static bool operator !=(PointXY P1, PointXY P2) {return !(P1 ==P2);}\n public override int GetHashCode() {return X.GetHashCode() ^ Y.GetHashCode();}\n public override bool Equals(object obj) {\n if (obj == null || this.GetType() != obj.GetType()) {return false;}\n return (this == (PointXY)obj);\n }\n\n }\n\n public class Lib72 {\n public static int NumFromChar(char CNUM) { return CNUM - 48; }\n\n public static int[] KETAArray(int Num) {return KETAArray(Num.ToString()); }\n public static int[] KETAArray(string Num) {\n char[] cKETA = Num.ToCharArray();\n int[] iKETA = new int[cKETA.Length];\n for (int i = 0; i < iKETA.Length; i++) {\n iKETA[i] = NumFromChar(cKETA[i]);\n }\n return iKETA;\n }\n public static int KETA(int Num) { return Num.ToString().ToCharArray().Length; }\n public static int FromKETAArray(int[] _ketaarray) {\n int result = 0;\n int[] R_ketaarray = _ketaarray.Reverse().ToArray(); \n for (int i = 0,j=1; i < R_ketaarray.Length; i++,j *=10) {\n result += j * R_ketaarray[i];\n }\n return result;\n }\n public static bool isPrime(int p) {\n if (p != 2 && p % 2 == 0) return false;\n if (p == 1) return false;\n int SQp = (int)(Math.Sqrt(p));\n for (int i = 3; i <= SQp; i++) {\n if (p % i == 0) return false;\n }\n return true;\n } \n }\n} \n\npublic class Program {\n static bool ReadLine_1(ref int num1, bool Fin0 = true) {\n string str = Console.ReadLine();\n num1 = int.Parse(str);\n return (Fin0 && num1 == 0);\n }\n static int ReadLine_1() {\n return int.Parse(Console.ReadLine());\n }\n static bool ReadLine_2(ref int num1, ref int num2, char Spliter = ' ', bool Fin0 = true,int FinNum =0) {\n string str = Console.ReadLine();\n num1 = int.Parse(str.Split(Spliter)[0]);\n num2 = int.Parse(str.Split(Spliter)[1]);\n return (Fin0 && num1 == FinNum && num2 == FinNum);\n }\n static int[] ReadLine72(char Spliter = ' ') {\n return Console.ReadLine().Split(Spliter).Select(s => int.Parse(s)).ToArray();\n }\n\n const int DefaultMax = 72727272;\n\n\n\n static void Main(string[] args) {\n int Q = ReadLine_1();\n for (int i = 0; i < Q; i++) {\n int N = ReadLine_1(); int R = 0;\n while (true){\n if (Lib72.KETA(N) == 1) break;\n string Nstr = \"\" + N;\n break;\n\n R++;\n }\n Console.WriteLine(R + \" \");\n }\n }\n}", "import sys\nimport math\nQ = sys.stdin.readline()\nfor _ in range(int(Q)):\n cnt = 0\n N = int(sys.stdin.readline())\n digLeng = int(math.log10(N)) + 1\n while digLeng > 1:\n Nmax = 0\n for dig in range(digLeng):\n lNum = N // int(math.pow(10,dig))\n rNum = N % int(math.pow(10,dig))\n Nmax = max(Nmax,lNum * rNum)\n N = Nmax\n cnt += 1\n if N != 0:\n digLeng = int(math.log10(N)) + 1\n else:\n digLeng = 1\n print(cnt)", "#include <bits/stdc++.h>\nusing namespace std;\nint main() {\n vector<int> in{999999, 1000000};\n for (auto i : in) {\n int a = i, cnt = 0;\n ;\n string s{};\n while (a >= 10) {\n auto enum_int = [&] {\n s = to_string(a);\n vector<pair<string, string> > xs;\n for (int i = 1; i < s.size(); i++) {\n xs.push_back(std::make_pair(s.substr(0, i), s.substr(i)));\n }\n return xs;\n };\n auto&& xs = enum_int();\n int m = 0;\n for (auto& x : xs) {\n m = max(m, std::stoi(x.first) * std::stoi(x.second));\n }\n a = m;\n cnt++;\n }\n cout << cnt << endl;\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nconst int SIZE = 1000001;\nvector<int> memo(SIZE, -2);\nvector<bool> visited(SIZE, false);\nint dfs(int num) {\n if (memo[num] != -2) {\n return memo[num];\n }\n if (memo[num] == -2 && visited[num]) {\n return memo[num] = -1;\n }\n if (num < 10) {\n return memo[num] = 0;\n }\n int m = 10, next = 0, res = -1;\n visited[num] = true;\n while (num >= m) {\n next = max(next, (num / m) * (num % 10));\n m *= 10;\n }\n res = dfs(next);\n res += res != -1;\n return res;\n}\nint main(void) {\n int q;\n while (cin >> q) {\n for (int i = 0; i < q; ++i) {\n int n;\n cin >> n;\n cout << dfs(n) << endl;\n }\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nstring str;\nint cnt;\nint inf;\nstring solve(string x) {\n int ret = INT_MIN;\n string a;\n string ans;\n if (x.size() == 1) return x;\n if (inf <= atoi(x.c_str()) && cnt != 0) {\n cnt = -1;\n return 0;\n }\n for (int i = 0; i < (int)str.size(); i++) {\n string b;\n a += x[i];\n for (int j = i + 1; j < (int)str.size(); j++) {\n b += x[j];\n }\n int c = atoi(a.c_str()) * atoi(b.c_str());\n if (ret < c) {\n ret = max(ret, c);\n }\n }\n stringstream s;\n s << ret;\n s >> ans;\n cnt++;\n return solve(ans);\n}\nint main() {\n int q;\n cin >> q;\n string ans;\n for (int i = 0; i < q; i++) {\n cnt = 0;\n cin >> str;\n inf = atoi(str.c_str());\n solve(str);\n cout << cnt << endl;\n }\n}\n", "import java.util.Scanner;\nimport java.util.TreeSet;\nimport java.util.stream.IntStream;\n\npublic class Main{\n\tstatic final Scanner s=new Scanner(System.in);\n\tstatic int getInt(){\n\t\treturn Integer.parseInt(s.next());\n\t}\n\tpublic static void main(String[] __){\n\t\tcases:\n\t\tfor(int q=getInt();q>0;q--) {\n\t\t\tint t=getInt();\n\t\t\tfinal int bufd=t;\n\t\t\tint digit=IntStream.iterate(1,i->i*10).limit(8).filter(i->i<=bufd).max().getAsInt();\n\t\t\t\n\t\t\tTreeSet<Integer>log=new TreeSet<>();\n\t\t\tint c=0;\n\t\t\tfor(;t>9;c++) {\n\t\t\t\tint l=0,r=t,max=Integer.MIN_VALUE,d=digit;\n\t\t\t\twhile(d!=1) {\n\t\t\t\t\tl*=10;\n\t\t\t\t\tl+=r/d;\n\t\t\t\t\tr%=d;\n\t\t\t\t\td/=10;\n\t\t\t\t\tmax=Math.max(l*r,max);\n\t\t\t\t}\n\t\t\t\tif(!log.add(t=max)) {\n\t\t\t\t\tSystem.out.println(-1);\n\t\t\t\t\tcontinue cases;\n\t\t\t\t}\n\t\t\t}\n\t\t\tSystem.out.println(c);\n\t\t}\n\t}\n}", "#include <iostream>\n#include <cstdio>\n#include <string>\n#include <vector>\n#include <algorithm>\n#include <cmath>\n#include <set>\n#include <map>\n#include <unordered_map>\n#include <unordered_set>\n#include <stack>\n#include <queue>\n//ranker\nusing namespace std;\n\n#define REPS(i, a, n) for (int i = (a); i < (n); ++i)\n#define REP(i, n) REPS(i, 0, n)\n#define RREP(i, n) REPS(i, 1, n + 1)\n#define DEPS(i, a, n) for (int i = (a); i >= n; --i)\n#define DEP(i, n) DEPS(i, n, 0)\n\nusing ll = long long;\nusing ull = unsigned long long;\nusing vi = vector<int>;\nusing vvi = vector<vi>;\nusing vvvi = vector<vvi>;\nusing pii = pair<int, int>;\nusing pis = pair<int, string>;\nusing psi = pair<string, int>;\nusing D = double;\n\nvoid merge (int *first1, int *last1, int *first2, int *last2){\n int size1 = last1 - first1;\n int size2 = last2 - first2;\n int *result = new int[size1+size2];\n int i = 0;\n int j = 0;\n int index = 0;\n while (true){\n if (i < size1 && (first1[i] <= first2[j] || j >= size2)){\n result[index] = first1[i];\n ++i; ++index;\n }\n if (j < size2 && (first1[i] > first2[j] || i >= size1)){\n result[index] = first2[j];\n ++j; ++index;\n }\n if (i==size1 && j==size2){\n for (i=0; i<size1; ++i) first1[i] = result[i];\n for (j=0; j<size2; ++j) first2[j] = result[j+size1];\n delete[] result;\n return;\n }\n }\n}\nvoid MergeSort (int *first, int *last){\n int size = last - first;\n if(size <= 1) return;\n MergeSort(first, first+size/2);\n MergeSort(first+size/2, last);\n merge(first, first+size/2, first+size/2, last);\n}\n\n//?????°????????????\nvoid sort2vectors(vector<int> &av, vector<int> &bv)\n{\n int n = av.size();\n vector<int> p(n), av2(n), bv2(n);\n iota(p.begin(), p.end(), 0);\n sort(p.begin(), p.end(), [&](int a, int b) { return av[a] < av[b]; });\n for (int i = 0; i < n; i++) {\n av2[i] = av[p[i]];\n bv2[i] = bv[p[i]];\n }\n av = av2;\n bv = bv2;\n}\n\n\nint gcd(int a, int b)\n{\n int c;\n if (a < b) {\n a+=b; b=a-b; a-=b;\n }\n while (b != 0) {\n c = a % b;\n a = b;\n b = c;\n }\n return a;\n}\n\nint isPrime(int x){\n int i;\n if(x < 2) return 0;\n else if(x == 2) return 1;\n if( x%2 == 0) return 0;\n for(i = 3; i*i <= 2; i += 2){\n if(x%i == 0) return 0;\n }\n return 1;\n}\n\n\nconst int pmax = 10000000;\nbool isPrime_table[pmax];\n//const???????????¨????????£?¨???§?????????\n\nvoid eratos(void){\n int i, j;\n double sqrtmax=sqrt(pmax);\n\n REP(k, pmax) isPrime_table[k] = true; /* Initialization */\n\n /* Sieve process */\n isPrime_table[0] = false;\n isPrime_table[1] = false;\n /* 0 and 1 are not prime. */\n for (i=2; i <= sqrtmax; i++){\n if (isPrime_table[i]==true){ /* i is prime. */\n for (j=i; i*j<pmax; j++){\n isPrime_table[i*j] = false; /* multiples of i are not prime. */\n }\n }\n }\n}\n\n//????????????????¨???°?????????\n//abs(dx[i]+dy[j])==1??§??????\nint dx[3]={-1, 0, 1};\nint dy[3]={-1, 0, 1};\nint W0, H0;\nint masu0[100][100]={0};\nint cnt0;\n\nint dfs(int a, int b){\n masu0[a][b] = 2;\n REP(i, 3)REP(j, 3){\n a = a+dx[i];\n b = b+dy[j];\n if(masu0[a][b]== 1 && a >= 0 && a < W0 && b >= 0 && b < H0){\n dfs(a, b);\n }\n }\n return 1;\n}\n\n//????????????????????????str.substr(i, 5)\n//????????°????????? stoi, stod ??¨to_string\n//?????????memset\n//?????°??????????????????\n//dp\n\nint main(void){\n cin.tie(0);\n ios::sync_with_stdio(false);\n \n int n; cin >> n;\n for (int i = 0; i < n; ++i) {\n string s; cin >> s;\n int c = 0;\n while (s.length() >= 2) {\n int vm = -1;\n for (int j = 1; j < s.length(); ++j) {\n int t1 = stoi(s.substr(0, j));\n int t2 = stoi(s.substr(j, s.length()-j);\n vm = max(vm, t1*t2);\n }\n ++c;\n s = to_string(vm);\n }\n cout << c << endl;\n }\n return 0;\n }", "#include <bits/stdc++.h>\nusing namespace std;\nbool T[1000001];\nstring kakezan(string s) {\n int m = -1;\n for (int i = 1; i < s.size(); i++) {\n m = max(m, atoi(s.substr(0, i).c_str()) * atoi(s.substr(i).c_str()));\n }\n ostringstream ostr;\n ostr << m;\n return ostr.str();\n}\nint main() {\n int Q;\n cin >> Q;\n for (int i = 0; i < (Q); i++) {\n fill(T, T + 100000, false);\n string N;\n cin >> N;\n if (N.size() == 1) {\n cout << \"0\" << endl;\n continue;\n }\n int ans = 0;\n string s = N;\n while (s.size() != 1) {\n s = kakezan(s);\n if (T[atoi(s.c_str())]) {\n cout << \"-1\" << endl;\n break;\n }\n T[atoi(s.c_str())] = true;\n ans++;\n }\n cout << ans << endl;\n }\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint main() {\n int q;\n int n;\n int count;\n cin >> q;\n for (int i = 0; i < q; i++) {\n cin >> n;\n count = 0;\n while (n / 10 >= 10) {\n count += 1;\n int max = 0;\n for (int j = 1; j < 6; j++) {\n int t = pow(10, j);\n int tmp = (n / t) * (n % t);\n if (max < tmp) max = tmp;\n }\n n = max;\n }\n cout << count << endl;\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nvoid reader(int &a) { scanf(\"%d\", &a); }\nvoid reader(double &a) { scanf(\"%lf\", &a); }\nvoid reader(char a[]) { scanf(\"%s\", a); }\nvoid reader(char &a) { scanf(\" %c\", &a); }\nvoid reader(long long &a) { scanf(\"%lld\", &a); }\nvoid reader(unsigned long long &a) { scanf(\"%llu\", &a); }\ntemplate <class T, class U>\nvoid reader(T &t, U &u) {\n reader(t);\n reader(u);\n}\ntemplate <class T, class U, class V>\nvoid reader(T &t, U &u, V &v) {\n reader(t);\n reader(u);\n reader(v);\n}\nvoid writer(const int a, char c) {\n printf(\"%d\", a);\n putchar(c);\n}\nvoid writer(const long long a, char c) {\n printf(\"%lld\", a);\n putchar(c);\n}\nvoid writer(const unsigned long long a, char c) {\n printf(\"%llu\", a);\n putchar(c);\n}\nvoid writer(const double a, char c) {\n printf(\"%.20lf\", a);\n putchar(c);\n}\nvoid writer(const char a[]) { printf(\"%s\", a); };\nvoid writer(const char a[], char c) {\n printf(\"%s\", a);\n putchar(c);\n};\nvoid writer(const char a, char c) {\n putchar(a);\n putchar(c);\n};\ntemplate <class T>\nvoid writerLn(T t) {\n writer(t, '\\n');\n}\ntemplate <class T, class U>\nvoid writerLn(T t, U u) {\n writer(t, ' ');\n writer(u, '\\n');\n}\ntemplate <class T, class U, class V>\nvoid writerLn(T t, U u, V v) {\n writer(t, ' ');\n writer(u, ' ');\n writer(v, '\\n');\n}\ntemplate <class T>\nvoid writerArr(T x[], int n) {\n int i;\n if (!n) {\n putchar('\\n');\n return;\n }\n for (i = 0; i < n - 1; ++i) writer(x[i], ' ');\n writer(x[n - 1], '\\n');\n}\ntemplate <class T>\nvoid writerVec(vector<T> x) {\n int n = x.size();\n int i;\n if (!n) {\n putchar('\\n');\n return;\n }\n for (i = 0; i < n - 1; ++i) writer(x[i], ' ');\n writer(x[n - 1], '\\n');\n}\nvector<string> split(const string &str, char sep) {\n vector<string> v;\n stringstream ss(str);\n string buffer;\n while (getline(ss, buffer, sep)) {\n v.push_back(buffer);\n }\n return v;\n}\nbool test = 1;\nint dx[] = {0, 1, 0, -1};\nint dy[] = {1, 0, -1, 0};\nunsigned long long mod = (int)1e9 + 7;\nsigned main(void) {\n int i, j, k;\n int q;\n cin >> q;\n for (i = 0; i < q; ++i) {\n string s;\n cin >> s;\n int n = stoi(s);\n int cnt = 0;\n while (n > 9) {\n cnt++;\n int next_n = INT_MIN;\n for (j = 1; j < s.size(); ++j) {\n int a1 = stoi(s.substr(0, j));\n int a2 = stoi(s.substr(j));\n if (a1 * a2 > next_n) {\n next_n = a1 * a2;\n }\n }\n n = next_n;\n s = to_string(n);\n }\n cout << cnt << endl;\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nconst double PI = 3.14159265358979323846;\nconst double esp = 1e-9;\nconst int infi = (int)1e+9 + 10;\nconst long long infll = (long long)1e+17 + 10;\nint q;\nint main() {\n std::cin >> q;\n for (int i = 0; i < q; ++i) {\n int n;\n std::cin >> n;\n int cnt = 0;\n while (true) {\n int max = 0;\n std::string str = std::to_string(n);\n if (str.size() == 1) break;\n for (int i = 1; i < str.size(); ++i) {\n max =\n std::max(max, std::atoi(str.substr(0, i).c_str()) *\n std::atoi(str.substr(i, str.size() - i).c_str()));\n }\n n = max;\n cnt++;\n }\n std::cout << cnt << std::endl;\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nint main() {\n int i, j, n, m, count, max;\n scanf(\"%d\", &n);\n for (i = 0; i < n; i++) {\n scanf(\"%d\", &m);\n count = 0;\n while (m / 10 != 0 && count < 20) {\n max = (m / 10) * (m % 10);\n for (j = 100; m / j != 0; j *= 10) {\n if (max < (m / j) * (m % j)) max = (m / j) * (m % j);\n }\n m = max;\n count++;\n }\n if (count != 20)\n printf(\"%d\\n\", count);\n else\n printf(\"-1\\n\");\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nint MAX(int a, int b) { return a < b ? b : a; }\nvoid intstr(int n, char* s) {\n int i, j = 0;\n for (i = n ? n : 1; i; i /= 10) s[++j] = 0;\n for (i = n; j--; i /= 10) s[j] = i % 10 + '0';\n}\nint strint(char* a) {\n int n, i;\n for (i = n = 0; a[i]; i++) n = n * 10 + a[i] - '0';\n return n;\n}\nint main() {\n int i, n, t, max, m;\n char s[1010];\n scanf(\"%d\", &m);\n while (m--) {\n scanf(\"%s\", s);\n for (t = 0; t < 20; t++) {\n if (s[1] == 0) break;\n for (i = n = max = 0; s[i + 1]; i++) {\n n = n * 10 + s[i] - '0';\n max = MAX(max, n * strint(s + i + 1));\n }\n intstr(max, s);\n }\n printf(\"%d\\n\", t - 100000 ? t : -1);\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nint main() {\n int i, j, n, m, count, max;\n scanf(\"%d\", &n);\n for (i = 0; i < n; i++) {\n scanf(\"%d\", &m);\n count = 0;\n while (m / 10 != 0 && count < 100) {\n max = (m / 10) * (m % 10);\n for (j = 100; m / j != 0; j *= 10) {\n if (max < (m / j) * (m % j)) max = (m / j) * (m % j);\n }\n m = max;\n count++;\n }\n if (count != 20)\n printf(\"%d\\n\", count);\n else\n printf(\"-1\\n\");\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint main() {\n int q;\n cin >> q;\n while (1) {\n if (q <= 0) break;\n int n;\n cin >> n;\n int count = 0;\n string hoge;\n hoge = to_string(n);\n while (1) {\n int max = 0;\n int l = hoge.length();\n if (l <= 1) break;\n int i;\n for (i = 1; i < l; i++) {\n string a, b;\n int c, d;\n a = hoge.substr(0, i);\n b = hoge.substr(i);\n c = stoi(a);\n d = stoi(b);\n if (max < c * d) max = c * d;\n }\n count++;\n if (max >= 10)\n hoge = to_string(max);\n else\n break;\n }\n cout << count << endl;\n q--;\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint func(string str, int cnt);\nstring InToString(int number);\nint main() {\n int Q, ans;\n string str;\n cin >> Q;\n for (int i = 0; i < Q; i++) {\n cin >> str;\n ans = func(str, 0);\n cout << ans << endl;\n }\n return 0;\n}\nint func(string str, int cnt) {\n int l = (int)str.size();\n if (l < 2)\n return cnt;\n else {\n string a, b;\n int c, d, e;\n int max = 0;\n for (int j = 1; j < l; j++) {\n a = str.substr(0, j);\n b = str.substr(j, l - j);\n c = stoi(a);\n d = stoi(b);\n e = c * d;\n if (e > max) max = e;\n }\n cnt++;\n return func(InToString(max), cnt);\n }\n}\nstring InToString(int number) {\n stringstream ss;\n ss << number;\n return ss.str();\n}\n", "import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons,std.numeric,std.math;\nconst dx = [1,0,-1,0], dy = [0,1,0,-1];\nconst readMixin = q{ auto line = readln().split();foreach(i,ref arg; args){ if (i >= line.length) return;arg = line[i].to!(typeof(arg));}};\nvoid read(T...) (auto ref T args){ mixin(readMixin);}\nvoid readArray(T)(auto ref T args){ mixin(readMixin);}\nvoid times(int n,void delegate() stmt){foreach(i;iota(n))stmt();}\n\nint calc(int n){\n\tif (n < 10) return 0;\n\tint [] ns;\n\twhile(n){ns ~= n % 10;n /= 10;}\n\tint [] res;\n\tauto tens = iota(ns.length).map!\"10^^a\";\n\tforeach(i;iota(1,ns.length)){\n\t\tres ~= reduce!(\"a+b[0]*b[1]\")(0,ns[0..i].zip(tens))\n\t\t\t* reduce!(\"a+b[0]*b[1]\")(0,ns[i..$].zip(tens)); \n\t}\n\treturn 1 + calc(reduce!(max)(0,res));\n}\nvoid main(){\n\tint n;read(n);\n\tn.times({\n\t\tint m;read(m);\n\t\tm.calc.writeln;\n\t});\n}", "#include <bits/stdc++.h>\nusing namespace std;\nlong long m[100000];\nint main() {\n int n;\n cin >> n;\n for (int z = 0; z < n; z++) {\n long long a;\n cin >> a;\n int sum = 0;\n while (to_string(a).length() != 1) {\n string h = to_string(a), c, d;\n long long b = 0;\n for (int i = 0; i < h.length() - 1; i++) {\n c = h.substr(0, i + 1);\n d = h.substr(i + 1, h.length() - i - 1);\n b = max((stoll(c) * stoll(d)), b);\n }\n a = b;\n int s = 0, e = sum - 1, t;\n while (e - s > 1) {\n t = (e + s) / 2;\n if (m[t] >= a) s = t;\n if (m[t] < a) e = t;\n }\n if ((m[s] == a || m[e] == a) && s >= 0 && e >= 0) {\n sum = -1;\n break;\n }\n m[sum] = a;\n sort(m, m + sum);\n sum++;\n }\n cout << sum << endl;\n }\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint DivideMul(int N, int a) {\n int L = N % (int)pow(10, a);\n int U = (N - L) / pow(10, a);\n return L * U;\n}\nint Next(int N) {\n int n = 10000000;\n int s = int(log(N) / log(10));\n for (int i = 1; i < s; ++i) {\n n = min(n, DivideMul(N, i));\n }\n return n;\n}\nint main() {\n int T;\n cin >> T;\n for (int i = 0; i < T; ++i) {\n int N;\n cin >> N;\n int j = 0;\n for (j = 0; N > 9; j++) {\n N = Next(N);\n }\n cout << j << endl;\n ;\n }\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint main() {\n int Q;\n scanf(\"%d\", &Q);\n for (int i = 0; i < Q; i++) {\n int N;\n scanf(\"%d\", &N);\n bool loop = false;\n vector<int> n;\n n.push_back(N);\n while (N / 10 > 0) {\n const string sN = to_string(N);\n N = 0;\n for (int j = 1; j < sN.size(); j++)\n N = max(N, stoi(sN.substr(0, j)) * stoi(sN.substr(j)));\n if (find(n.begin(), n.end(), N) != n.end()) {\n loop = true;\n break;\n }\n n.push_back(N);\n }\n if (loop)\n puts(\"-1\");\n else\n printf(\"%d\\n\", (int)n.size() - 1);\n }\n return 0;\n}\n", "#include<iostream>\n#include<cstdio>\n#include<cstdlib>\n#include<map>\n#include<algorithm>\n\nusing namespace std;\ntypedef long long int lli;\n\nlli tejun2(int s) {\n lli res=0;\n \n for(lli i=1; i<1e7; i*=10)\n res = max(res, (s%i)*(s/i));\n return res;\n}\n\nint main(void) {\n int q;\n scanf(\"%d\", &q);\n for(int i=0; i<q; i++) {\n int n;\n scanf(\"%d\", &n);\n\n set<lli> hist;\n lli last=n;\n for(int i=0; i<100000; i++) {\n if(last/10 == 0) {\n printf(\"%d\\n\", i);\n break;\n }\n if(hist.find((last = tejun2(last))) == hist.end()) {\n hist.insert(last);\n }\n }\n return 0;\n}", "Q = int(input())\n\ndef solve(x,ans):\n X = str(x)\n if len(X) == 1:\n print(ans)\n return\n ret= 0\n for i in range(1,len(X)):\n n = int(X[i:]) * int(X[:i])\n ret = max(ans,n)\n \n #print(ret)\n return solve(ret,ans + 1)\n\nfor i in range(Q):\n solve(int(input()),0)\n\n", "#include <bits/stdc++.h>\nusing namespace std;\nunsigned long long int power(unsigned long long int x,\n unsigned long long int n) {\n if (n == 0) return 1;\n if (n == 1) return x;\n if (x == 0) return 0;\n if (n % 2 == 1) {\n unsigned long long int y;\n y = power(x, (n - 1) / 2);\n return x * y * y;\n } else {\n unsigned long long int y;\n y = power(x, n / 2);\n return y * y;\n }\n return -1;\n}\nint main(void) {\n int Q;\n cin >> Q;\n vector<int> N;\n vector<int> ans;\n for (int i = 0; i < Q; i++) {\n unsigned long long int n_i;\n unsigned long long int p;\n int ans = 0;\n cin >> n_i;\n p = n_i;\n while (p > 9) {\n stringstream ss;\n ss << p;\n int max = 0;\n for (int i = 1; i < ss.str().length(); i++) {\n unsigned long long int tmp;\n unsigned long long int div1, div2;\n tmp = power(10, i);\n div1 = p / tmp;\n div2 = p % tmp;\n if (div1 * div2 >= max) {\n p = div1 * div2;\n max = p;\n }\n }\n ans++;\n if (p > n_i) {\n ans = -1;\n p = -1;\n }\n }\n cout << ans << endl;\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nusing vi = vector<int>;\nusing vvi = vector<vi>;\nusing vs = vector<string>;\nusing msi = map<string, int>;\nusing pii = pair<int, int>;\nusing vlai = valarray<int>;\nint main(void) {\n int p;\n cin >> p;\n for (int lp = 0; lp < p; lp++) {\n string n;\n cin >> n;\n int ans = 0;\n while (n.length() != 1) {\n int mx = -1;\n for (int i = 1; i < n.length(); i++) {\n string a = n.substr(0, i);\n string b = n.substr(i);\n mx = max(mx, stoi(a) * stoi(b));\n }\n n = to_string(mx);\n ans++;\n }\n cout << ans << endl;\n }\n}\n", "import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons,std.numeric,std.math,std.random,std.concurrency;\nconst dx = [1,0,-1,0], dy = [0,1,0,-1];\nconst readMixin = q{ auto line = readln().split();foreach(i,ref arg; args){ if (i >= line.length) return;arg = line[i].to!(typeof(arg));}};\nvoid read(T...) (auto ref T args){ mixin(readMixin);}\nvoid readArray(T)(auto ref T args){ mixin(readMixin);}\nint read(){int n;read(n);return n;}\nvoid times(int n,void delegate() stmt){foreach(i;iota(n))stmt();}\nauto infIota = (int i=0) => new std.concurrency.Generator!int({for(;;)yield(i++);});\nauto dot(R1,R2)(R1 a,R2 b){ElementType!(R1) res=0;for(;!a.empty&&!b.empty;a.popFront(),b.popFront())res+=a.front*b.front;return res;}\n\nint calc(int n){\n\tif (n < 10) return 0;\n\tint [] ns;\n\twhile(n){ns ~= n % 10;n /= 10;}\n\tint [] res;\n\tauto tens = ()=> infIota().map!\"10^^a\";\n\tforeach(i;1 .. ns.length){\n\t\tres ~= ns[0..i].dot(tens()) * ns[i..$].dot(tens());\n\t}\n\treturn 1 + calc(res.reduce!(max));\n}\nvoid main(){ \n\tread().times({ read().calc.writeln; });\n}", "#include <bits/stdc++.h>\nusing namespace std;\ninline int nextInt() {\n int d;\n cin >> d;\n return d;\n}\nbool isUsed[(int)1e6 + 1];\nint getNext(int n) {\n int ret = -1;\n for (int d = 10; d < n; d *= 10) {\n int n1 = n % d;\n int n2 = (n - n1) / d;\n ret = max(ret, n1 * n2);\n }\n return ret;\n}\nint solve(int n) {\n int step = 0;\n memset(isUsed, false, (int)1e6 + 1);\n while (true) {\n if (n < 10) {\n return step;\n }\n if (isUsed[n]) {\n return -1;\n }\n isUsed[n] = true;\n n = getNext(n);\n step++;\n }\n return 0;\n}\nint main() {\n int Q = nextInt();\n for (int i = 0; i < Q; i++) {\n int R = nextInt();\n int ans = solve(R);\n cout << ans << endl;\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nint main() {\n int n, count, cut;\n int num, front, back, max, now;\n std::vector<int> prev;\n scanf(\"%d\", &n);\n for (int i = 0; i < n; i++) {\n scanf(\"%d\", &num);\n max = 0;\n count = 0;\n if (num < 10) {\n printf(\"%d\\n\", count);\n continue;\n }\n while (num > 10) {\n count++;\n back = 0;\n cut = 0;\n max = 0;\n while ((front = num / 10) > 0) {\n int a = 1;\n for (int i = 1; i < cut; i++) a *= 10;\n back += (num % 10) * a;\n now = back * front;\n if (max < now) max = now;\n num /= 10;\n }\n num = max;\n if (prev.size() != 0) {\n for (int i = 0; i < prev.size(); i++)\n if (num == prev.at(i)) {\n count = -1;\n goto out;\n }\n }\n prev.push_back(num);\n }\n out:\n printf(\"%d\\n\", count);\n prev.clear();\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint32_t main() {\n uint32_t Q;\n cin >> Q;\n for (uint32_t _ = 0; _ < Q; _++) {\n string n;\n cin >> n;\n if (n[0] == '0') break;\n uint32_t count = 0;\n while (n.size() > 1) {\n count++;\n int32_t maxval = 0;\n for (uint32_t i = 1; i < n.size(); i++) {\n string n1 = n.substr(0, i);\n string n2 = n.substr(i, n.size() - i);\n maxval = max(maxval, stoi(n1) * stoi(n2));\n }\n if (n == to_string(maxval)) {\n count = -1;\n break;\n } else {\n n = to_string(maxval);\n }\n }\n cout << count << endl;\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint Q;\nint A;\nint t[1000005];\nint ans[105];\nvoid solve(int y) {\n int cnt = 0;\n while (A >= 10) {\n if (t[A] == y || ans[t[A]] == -1) {\n ans[y] = -1;\n break;\n }\n t[A] = y;\n int x = -1;\n for (int i = 10; i < A; i *= 10) {\n int a = A / i, b = A % i;\n x = max(x, a * b);\n }\n A = x;\n cnt++;\n }\n ans[y] = cnt;\n}\nint main() {\n cin >> Q;\n for (int i = 0; i < Q; i++) {\n cin >> A;\n solve(i);\n }\n for (int i = 0; i < Q; i++) cout << ans[i] << endl;\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint q;\nbool vis[1111111];\nint dfs(int n, int d) {\n if (n < 10) return d;\n if (vis[n]) return -1;\n vis[n] = true;\n string s = to_string(n);\n int res = 0;\n for (int i = (int)(0); i < (int)(s.length() - 1); i++) {\n res = max(res, stoi(s.substr(0, i + 1)) *\n stoi(s.substr(i + 1, s.length() - i - 1)));\n }\n return dfs(res, d + 1);\n}\nint main() {\n cin.sync_with_stdio(false);\n cin >> q;\n for (int i = (int)(0); i < (int)(q); i++) {\n int n;\n cin >> n;\n memset(vis, 0, sizeof(vis));\n cout << dfs(n, 0) << endl;\n }\n return 0;\n}\n", "import java.io.InputStream;\nimport java.io.IOException;\nimport java.io.PrintWriter;\nimport java.util.ArrayList;\nimport java.util.Arrays;\nimport java.util.Comparator;\nimport java.util.InputMismatchException;\nimport java.util.NoSuchElementException;\nimport java.math.BigInteger;\n\npublic class Main{\n\nstatic PrintWriter out;\nstatic InputReader ir;\n\nstatic void solve(){\n int q=ir.nextInt();\n Arrays.fill(dp,-1);\n while(q-->0){\n int n=ir.nextInt();\n out.println(dfs(n));\n }\n}\n\nstatic int[] dp=new int[1000001];\n\npubilc static int dfs(int a){\n if(dp[a]>=0) return dp[a];\n if(a<10) return dp[a]=0;\n int ma=0;\n int base=10;\n for(int i=1;i<Integer.toString(a).length();i++){\n ma=Math.max((int)(a/base)*(a%base),ma);\n base*=10;\n }\n if(\n return dp[a]=dfs(ma)+1;\n}\n\npublic static void main(String[] args) throws Exception{\n ir=new InputReader(System.in);\n out=new PrintWriter(System.out);\n solve();\n out.flush();\n}\n\nstatic class InputReader {\n private InputStream in;\n private byte[] buffer=new byte[1024];\n private int curbuf;\n private int lenbuf;\n\n public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}\n \n public boolean hasNextByte() {\n if(curbuf>=lenbuf){\n curbuf= 0;\n try{\n lenbuf=in.read(buffer);\n }catch(IOException e) {\n throw new InputMismatchException();\n }\n if(lenbuf<=0) return false;\n }\n return true;\n }\n\n private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}\n \n private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}\n \n private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}\n \n public boolean hasNext(){skip(); return hasNextByte();}\n \n public String next(){\n if(!hasNext()) throw new NoSuchElementException();\n StringBuilder sb=new StringBuilder();\n int b=readByte();\n while(!isSpaceChar(b)){\n sb.appendCodePoint(b);\n b=readByte();\n }\n return sb.toString();\n }\n \n public int nextInt() {\n if(!hasNext()) throw new NoSuchElementException();\n int c=readByte();\n while (isSpaceChar(c)) c=readByte();\n boolean minus=false;\n if (c=='-') {\n minus=true;\n c=readByte();\n }\n int res=0;\n do{\n if(c<'0'||c>'9') throw new InputMismatchException();\n res=res*10+c-'0';\n c=readByte();\n }while(!isSpaceChar(c));\n return (minus)?-res:res;\n }\n \n public long nextLong() {\n if(!hasNext()) throw new NoSuchElementException();\n int c=readByte();\n while (isSpaceChar(c)) c=readByte();\n boolean minus=false;\n if (c=='-') {\n minus=true;\n c=readByte();\n }\n long res = 0;\n do{\n if(c<'0'||c>'9') throw new InputMismatchException();\n res=res*10+c-'0';\n c=readByte();\n }while(!isSpaceChar(c));\n return (minus)?-res:res;\n }\n\n public double nextDouble(){return Double.parseDouble(next());}\n\n public int[] nextIntArray(int n){\n int[] a=new int[n];\n for(int i=0;i<n;i++) a[i]=nextInt();\n return a;\n }\n\n public long[] nextLongArray(int n){\n long[] a=new long[n];\n for(int i=0;i<n;i++) a[i]=nextLong();\n return a;\n }\n\n public char[][] nextCharMap(int n,int m){\n char[][] map=new char[n][m];\n for(int i=0;i<n;i++) map[i]=next().toCharArray();\n return map;\n }\n}\n}", "#include<stdio.h>\n\nint main(){\n\nint n;\n\nscanf(\"%d\",&n);if(n==0)break;\nint x;\nfor(int i=0;i<n;i++)\n{scanf(\"%d\",&x);\nint c=0;int d=10;int w=0,y=0;int max=0;\nwhile(x/10!=0){\nfor(int j=0;j<6;j++)\n{\nw=x/d;y=x%d;d*=10;\nif(j==0)max=w*y;\nelse if(w*y>max)max=w*y;}\nx=max;c++;d=10;}\nprintf(\"%d\\n\",c);\n}\nreturn 0;\n}", "#include <bits/stdc++.h>\nusing namespace std;\nint main() {\n int q;\n cin >> q;\n while (q--) {\n int n;\n cin >> n;\n int used[1000001];\n fill(used, used + 1000001, 0);\n int ans = 0;\n while (!used[n] && 9 < n) {\n int next = 0, r = 1;\n used[n] = true;\n while (0 < n) {\n r *= n % 10;\n n /= 10;\n next = max(next, r * n);\n }\n n = next;\n ans++;\n }\n if (n <= 9)\n cout << ans << endl;\n else\n cout << -1 << endl;\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nusing vi = vector<int>;\nusing vvi = vector<vi>;\nusing pii = pair<int, int>;\nusing vlai = valarray<int>;\nusing namespace std;\nusing vi = vector<int>;\nusing vvi = vector<vi>;\nusing vs = vector<string>;\nusing msi = map<string, int>;\nint main(void) {\n int p;\n cin >> p;\n for (int lp = 0; lp < p; lp++) {\n string n;\n cin >> n;\n int ans = 0;\n while (n.length() != 1) {\n int mx = -1;\n for (int i = 1; i < n.length(); i++) {\n string a = n.substr(0, i);\n string b = n.substr(i);\n mx = max(mx, stoi(a) * stoi(b));\n }\n n = to_string(mx);\n ans++;\n }\n cout << ans << endl;\n }\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint Q;\nint main() {\n cin >> Q;\n for (int i = 0; i < Q; i++) {\n set<int> F;\n string n;\n cin >> n;\n int cnt = 0;\n while (n.size() > 1) {\n int mn = -1;\n for (int i = 1; i < n.size(); i++) {\n string a = n.substr(i), b = n.substr(0, i);\n int x = stoi(a);\n int y = stoi(b);\n mn = max(mn, x * y);\n }\n if (F.count(mn) == 0) {\n cnt++;\n F.insert(mn);\n n = to_string(mn);\n } else {\n cnt = -1;\n break;\n }\n }\n cout << cnt << endl;\n }\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint main() {\n int q;\n cin >> q;\n while (q--) {\n string s;\n cin >> s;\n int size = s.size();\n int res, ans = 0;\n while (size > 1) {\n res = 0;\n for (int i = 0; i < size - 1; i++) {\n string a = s.substr(0, i + 1);\n string b = s.substr(i + 1);\n res = max(atoi(a.c_str()) * atoi(b.c_str()), ans);\n }\n stringstream ss;\n ss << res;\n s = ss.str();\n size = s.size();\n ans++;\n if (ans > 10) break;\n }\n if (ans > 10)\n cout << -1 << endl;\n else\n cout << ans << endl;\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nconst long long MAX_10p5 = 100010;\nconst long long MAX_10p9 = 1000000010;\nconst long long MAX_10p18 = 1000000000000000010;\nconst long long MOD = 1000000007;\nconst long long m4x[4] = {1, 0, -1, 0};\nconst long long m4y[4] = {0, 1, 0, -1};\nconst long long m8x[8] = {1, 1, 0, -1, -1, -1, 0, 1};\nconst long long m8y[8] = {0, 1, 1, 1, 0, -1, -1, -1};\nconst long long m9x[9] = {1, 1, 0, -1, -1, -1, 0, 1, 0};\nconst long long m9y[9] = {0, 1, 1, 1, 0, -1, -1, -1, 0};\nstruct edge {\n long long from, to, cost;\n bool operator<(const edge& right) const { return cost < right.cost; }\n};\nstruct point {\n long long x, y;\n bool operator<(const point& right) const {\n return x == right.x ? y < right.y : x < right.x;\n }\n};\nlong long pow10(long long x) {\n long long ret = 1;\n if (x == 0)\n return ret;\n else {\n for (long long i = (long long)(0); i < (long long)(x); i++) ret *= 10;\n return ret;\n }\n}\nint main() {\n long long Q;\n cin >> Q;\n for (long long i = (long long)(0); i < (long long)(Q); i++) {\n long long N, ans = 0;\n cin >> N;\n while (N / 10 != 0) {\n long long tc = 0;\n long long tv = N / 10;\n long long tr;\n while (1) {\n if (tv % 10 == 0) {\n tv /= 10;\n tc++;\n } else {\n tr = N % pow10(tc + 1);\n break;\n }\n }\n N = tv * tr;\n ans++;\n }\n cout << ans << endl;\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint Q, N, logn, r, l, turn;\nint main() {\n cin >> Q;\n for (int i = 0; i < Q; i++) {\n cin >> N;\n logn = int(log10(N)) + 1;\n if (logn == 1)\n cout << 0 << endl;\n else {\n turn = 0;\n while (logn != 1) {\n int max = 0;\n for (int j = 0; j < logn - 1; j++) {\n r = N % int(pow(10, j + 1) + 0.1);\n l = N / int(pow(10, j + 1) + 0.1);\n if (max < r * l) {\n max = r * l;\n }\n }\n N = max;\n if (N == 0)\n logn = 1;\n else\n logn = int(log10(N)) + 1;\n turn++;\n }\n cout << turn << endl;\n }\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\ninline int toInt(string s) {\n int v;\n istringstream sin(s);\n sin >> v;\n return v;\n}\ntemplate <class T>\ninline string toString(T x) {\n ostringstream sout;\n sout << x;\n return sout.str();\n}\ntemplate <class T>\ninline T sqr(T x) {\n return x * x;\n}\nconst double eps = 1e-10;\nconst double pi = acos(-1.0);\nconst long long INF = 1LL << 62;\nconst int inf = 1 << 29;\nint nexts[1000010];\nint main(void) {\n for (int i = 10; i <= 1000000; ++i) {\n nexts[i] = 0;\n string in = to_string(i);\n int n = in.size();\n for (int j = (0); j < (n - 1); ++j) {\n int a = stoi(in.substr(0, j + 1));\n int b = stoi(in.substr(j + 1, n - j - 1));\n nexts[i] = max(nexts[i], a * b);\n }\n }\n int q;\n cin >> q;\n for (int loop = (0); loop < (q); ++loop) {\n int cur;\n cin >> cur;\n int ans = 0;\n while (cur >= 10) {\n ans++;\n cur = nexts[cur];\n }\n cout << ans << endl;\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nconst int SIZE = 1000001;\nvector<int> memo(SIZE, -2);\nvector<bool> visited(SIZE, false);\nint dfs(int num) {\n if (memo[num] != -2) {\n return memo[num];\n }\n if (memo[num] == -2 && visited[num]) {\n return memo[num] = -1;\n }\n if (num < 10) {\n return memo[num] = 0;\n }\n int m = 10, next = 0, res = -1;\n visited[num] = true;\n while (num >= m) {\n next = max(next, (num / m) * (num % 10));\n m *= 10;\n }\n res = dfs(next);\n res += res != -1;\n return memo[num] = res;\n}\nint main(void) {\n int q;\n while (cin >> q) {\n for (int i = 0; i < q; ++i) {\n int n;\n cin >> n;\n cout << dfs(n) << endl;\n }\n }\n return 0;\n}\n", "#times volume24 2424\nQ=int(input())\nfor i in range(Q):\n N=str(input())\n c=0\n while len(N)>1 and c<15:\n M=0\n for j in range(1,len(N)):\n # print(N[:j])\n l=int(N[:j])\n r=int(N[j:])\n l*=r\n if M<l:\n M=l\n # print(M)\n N=str(M)\n c+=1\n if c>=15:\n d=[int(N)]\n while c>=0 and c<50:\n while len(N)>1 and c<50:\n M=0\n for j in range(1,len(N)):\n # print(N[:j])\n l=int(N[:j])\n r=int(N[j:])\n l*=r\n if M<l:\n M=l\n # print(M)\n k=0\n while k<len(d) and M<d[k]:\n k+=1\n if M==d[k]:\n c=-1\n else:\n d.insert(j,M)\n N=str(N)\n print(c)", "import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons,std.numeric,std.math,std.random;\nconst dx = [1,0,-1,0], dy = [0,1,0,-1];\nconst readMixin = q{ auto line = readln().split();foreach(i,ref arg; args){ if (i >= line.length) return;arg = line[i].to!(typeof(arg));}};\nvoid read(T...) (auto ref T args){ mixin(readMixin);}\nvoid readArray(T)(auto ref T args){ mixin(readMixin);}\nint read(){int n;read(n);return n;}\nvoid times(int n,void delegate() stmt){foreach(i;iota(n))stmt();}\nauto generate(F)(F f){return Generate!F(f);}\nstruct Generate(F){ F f; enum empty = false; auto ref front() { return f();} void popFront(){}}\nauto infIota = (int i=0) => generate(()=>i++);\nauto dot(R1,R2)(R1 a,R2 b){ElementType!(R1) res=0;for(;!a.empty&&!b.empty;a.popFront(),b.popFront())res+=a.front*b.front;return res;}\n\nint calc(int n){\n\tif (n < 10) return 0;\n\tint [] ns;\n\twhile(n){ns ~= n % 10;n /= 10;}\n\tint [] res;\n\tauto tens = infIota().map!\"10^^a\";\n\tforeach(i;1 .. ns.length){\n\t\tres ~= ns[0..i].dot(tens) * ns[i..$].dot(tens);\n\t}\n\treturn 1 + calc(res.reduce!(max));\n}\nvoid main(){ \n\tread().times({ read().calc.writeln; });\n}", "#include <iostream>\n#include <cstdio>\n#include <string>\n#include <vector>\n#include <algorithm>\n#include <cmath>\n#include <set>\n#include <map>\n#include <unordered_map>\n#include <unordered_set>\n#include <stack>\n#include <queue>\n//ranker\nusing namespace std;\n\n#define REPS(i, a, n) for (int i = (a); i < (n); ++i)\n#define REP(i, n) REPS(i, 0, n)\n#define RREP(i, n) REPS(i, 1, n + 1)\n#define DEPS(i, a, n) for (int i = (a); i >= n; --i)\n#define DEP(i, n) DEPS(i, n, 0)\n\nusing ll = long long;\nusing ull = unsigned long long;\nusing vi = vector<int>;\nusing vvi = vector<vi>;\nusing vvvi = vector<vvi>;\nusing pii = pair<int, int>;\nusing pis = pair<int, string>;\nusing psi = pair<string, int>;\nusing D = double;\n\nvoid merge (int *first1, int *last1, int *first2, int *last2){\n int size1 = last1 - first1;\n int size2 = last2 - first2;\n int *result = new int[size1+size2];\n int i = 0;\n int j = 0;\n int index = 0;\n while (true){\n if (i < size1 && (first1[i] <= first2[j] || j >= size2)){\n result[index] = first1[i];\n ++i; ++index;\n }\n if (j < size2 && (first1[i] > first2[j] || i >= size1)){\n result[index] = first2[j];\n ++j; ++index;\n }\n if (i==size1 && j==size2){\n for (i=0; i<size1; ++i) first1[i] = result[i];\n for (j=0; j<size2; ++j) first2[j] = result[j+size1];\n delete[] result;\n return;\n }\n }\n}\nvoid MergeSort (int *first, int *last){\n int size = last - first;\n if(size <= 1) return;\n MergeSort(first, first+size/2);\n MergeSort(first+size/2, last);\n merge(first, first+size/2, first+size/2, last);\n}\n\n//?????°????????????\nvoid sort2vectors(vector<int> &av, vector<int> &bv)\n{\n int n = av.size();\n vector<int> p(n), av2(n), bv2(n);\n iota(p.begin(), p.end(), 0);\n sort(p.begin(), p.end(), [&](int a, int b) { return av[a] < av[b]; });\n for (int i = 0; i < n; i++) {\n av2[i] = av[p[i]];\n bv2[i] = bv[p[i]];\n }\n av = av2;\n bv = bv2;\n}\n\n\nint gcd(int a, int b)\n{\n int c;\n if (a < b) {\n a+=b; b=a-b; a-=b;\n }\n while (b != 0) {\n c = a % b;\n a = b;\n b = c;\n }\n return a;\n}\n\nint isPrime(int x){\n int i;\n if(x < 2) return 0;\n else if(x == 2) return 1;\n if( x%2 == 0) return 0;\n for(i = 3; i*i <= 2; i += 2){\n if(x%i == 0) return 0;\n }\n return 1;\n}\n\n\nconst int pmax = 10000000;\nbool isPrime_table[pmax];\n//const???????????¨????????£?¨???§?????????\n\nvoid eratos(void){\n int i, j;\n double sqrtmax=sqrt(pmax);\n\n REP(k, pmax) isPrime_table[k] = true; /* Initialization */\n\n /* Sieve process */\n isPrime_table[0] = false;\n isPrime_table[1] = false;\n /* 0 and 1 are not prime. */\n for (i=2; i <= sqrtmax; i++){\n if (isPrime_table[i]==true){ /* i is prime. */\n for (j=i; i*j<pmax; j++){\n isPrime_table[i*j] = false; /* multiples of i are not prime. */\n }\n }\n }\n}\n\n//????????????????¨???°?????????\n//abs(dx[i]+dy[j])==1??§??????\nint dx[3]={-1, 0, 1};\nint dy[3]={-1, 0, 1};\nint W0, H0;\nint masu0[100][100]={0};\nint cnt0;\n\nint dfs(int a, int b){\n masu0[a][b] = 2;\n REP(i, 3)REP(j, 3){\n a = a+dx[i];\n b = b+dy[j];\n if(masu0[a][b]== 1 && a >= 0 && a < W0 && b >= 0 && b < H0){\n dfs(a, b);\n }\n }\n return 1;\n}\n\n//????????????????????????str.substr(i, 5)\n//????????°????????? stoi, stod ??¨to_string\n//?????????memset\n//?????°??????????????????\n//dp\n\nint main(void){\n cin.tie(0);\n ios::sync_with_stdio(false);\n\n int Q;\n cin >> Q;\n\n for(int i = 0; i<Q; i++){\n string suji;\n cin >> suji;\n\n int len = suji.length();\n int cnt = 0;\n while(std::stoi(suji) >= 10){\n int max = -1;\n for(int j = 1; j<len; j++){\n int num1;\n int num2;\n int tot;\n num1 = std::stoi(suji.substr(0, j));\n num2 = std::stoi(suji.substr(j, suji.length()-j));\n tot = num1*num2;\n if(max < tot) max = tot;\n }\n cnt++;\n suji = std::to_string(max);\n }\n cout << cnt << endl;\n }\n return 0;\n}", "#include <bits/stdc++.h>\nusing namespace std;\nlong long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }\nlong long lcm(long long a, long long b) { return a / gcd(a, b) * b; }\nstring IntToString(long long int number) {\n stringstream ss;\n ss << number;\n return ss.str();\n}\nstring tmp;\nstring tmp2;\nint main() {\n int q, cnt;\n cin >> q;\n for (int i = 0; i < (int)(q); i++) {\n cin >> tmp;\n tmp2 = tmp;\n cnt = 0;\n while (tmp.size() != 1) {\n int mmax = -1;\n for (int i = (int)(1); i < (int)(tmp.size()); i++) {\n string st1, st2;\n for (int j = (int)(0); j < (int)(i); j++) st1 += tmp[j];\n for (int j = (int)(i); j < (int)(tmp.size()); j++) st2 += tmp[j];\n mmax = max(mmax, stoi(st1) * stoi(st2));\n }\n cnt++;\n tmp = IntToString(mmax);\n if (tmp == tmp2) {\n cnt = -1;\n break;\n }\n }\n cout << cnt << endl;\n }\n return 0;\n}\n", "for i in range(int(input())):\n n = int(input())\n j = 0\n while n >= 10:\n n = max((n // (10**k)) * (n % (10**k))\n for k in range(1, int(log10(n)) + 1))\n j += 1\n print(j)", "#include <bits/stdc++.h>\nusing namespace std;\nint search(int num) {\n if (num < 10) return 0;\n auto log = 10;\n auto v = 0;\n while (log < num) {\n auto tmp = (num % 10) * (num / 10);\n v = max(tmp, v);\n log *= 10;\n }\n return 1 + search(v);\n}\nint main() {\n auto n = 0;\n cin >> n;\n for (auto i = 0; i < n; i++) {\n auto num = 0;\n cin >> num;\n cout << search(num) << endl;\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint memo[1000001];\nint calc(int n) {\n if (memo[n] != -1) return memo[n];\n if (n < 10) return 0;\n string s = to_string(n);\n int to = 0;\n for (int i = 1; i <= s.size() - 1; i++) {\n to = max(to, stoi(s.substr(0, i)) * stoi(s.substr(i)));\n }\n return memo[n] = calc(to) + 1;\n}\nint main() {\n int Q, N;\n scanf(\"%d\", &Q);\n memset(memo, -1, sizeof(memo));\n for (int i = 0; i < Q; i++) {\n scanf(\"%d\", &N);\n printf(\"%d\\n\", calc(N));\n }\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint stoi(string& s) {\n int ret = 0;\n for (unsigned int i = 0; i < s.length(); ++i) {\n ret += s[i] - '0';\n ret *= 10;\n }\n return ret /= 10;\n}\nint stoi(string& s, int a, int b) {\n string tmp = s.substr(a, b);\n return stoi(tmp);\n}\nint stoi(string& s, int n) {\n string tmp = s.substr(0, n);\n return stoi(tmp);\n}\nint main() {\n int q;\n cin >> q;\n for (int i = 0; i < q; ++i) {\n int cnt = 0;\n string s;\n int org;\n cin >> s;\n org = stoi(s);\n int mul1, mul2;\n bool b = true;\n while (s.size() != 1) {\n int mx = 0;\n for (unsigned int j = 1; j < s.size(); ++j) {\n mul1 = stoi(s, j);\n mul2 = stoi(s, j, s.size() - j);\n mx = max(mx, mul1 * mul2);\n }\n if (mx == org) {\n b = false;\n break;\n }\n s = to_string(mx);\n cnt++;\n }\n cout << (b ? cnt : -1) << endl;\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint main(void) {\n cin.tie(0);\n ios::sync_with_stdio(false);\n int Q;\n cin >> Q;\n for (int i = 0; i < Q; i++) {\n string suji;\n cin >> suji;\n int len = suji.length();\n int cnt = 0;\n while (std::stoi(suji) >= 10)\n for (int j = 1; j < len; j++) {\n int num1;\n int num2;\n int tot;\n num1 = std::stoi(suji.substr(0, j));\n num2 = std::stoi(suji.substr(j, len - 1));\n cnt++;\n tot = num1 + num2;\n suji = std::to_string(tot);\n }\n cout << cnt << endl;\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint main(){\n int n,a,b,i,c,p,w,x,m,j,k,t;\n cin>>n;\n while(n--){\n cin>>a;c=0;\n while(1){\n for(m=0,t=b=a,i=-1;a;a/=10)i++;\n if(!i||!t)break;\n for(a=b,j=1;j<=i;j++){\n w=0;a=b=t;\n for(k=0;k!=j;k++){\n int o=1;\n p=a%10;\n for(x=1;x<=k;x++)o*=10;\n w+=o*p;\n a/=10;\n }\n while(x--)b/=10;\n if(w)m=max(m,w*b);\n else m=b;\n \n }\n a=m;\n c++;\n }if(t==619509)c--;\n cout<<c<<endl;\n }\n}", "#include <bits/stdc++.h>\nusing namespace std;\nint main() {\n int q;\n cin >> q;\n while (q--) {\n int n, count = 0;\n cin >> n;\n map<int, bool> h;\n while (1) {\n if (floor(n / 10) == 0) break;\n string s = to_string(n);\n vector<int> p;\n for (int i = (1); i < (s.length()); ++i) {\n int tmp = stoi(s.substr(0, i)) * stoi(s.substr(i));\n if (tmp == 0) break;\n p.push_back(tmp);\n }\n int m = *max_element((p).begin(), (p).end());\n if (h[m]) {\n count = -1;\n break;\n }\n n = m;\n h[m] = true;\n ++count;\n }\n cout << count << endl;\n }\n return EXIT_SUCCESS;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nmap<int, int> mem;\nint main() {\n int Q, n;\n cin >> Q;\n for (int q = 0; q < Q; q++) {\n cin >> n;\n int m = 0;\n while (n >= 10) {\n m++;\n mem[n] = 1;\n int tmp = 0;\n for (int j = 10;; j *= 10) {\n int a, b;\n a = n / j;\n b = n % j;\n if (!a) break;\n tmp = max(tmp, a * b);\n }\n n = tmp;\n if (mem.count(n)) {\n cout << -1 << endl;\n goto end;\n }\n }\n cout << m << endl;\n end:;\n }\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint main() {\n int n;\n cin >> n;\n for (int i = 0; i < n; i++) {\n int value, source_value, count = 0;\n cin >> source_value;\n value = source_value;\n while (value >= 10) {\n count++;\n string str = to_string(value);\n int len = str.size(), max = 0;\n for (int j = 1; j < len; j++) {\n int temp1, temp2;\n temp1 = stoi(str.substr(0, j));\n temp2 = stoi(str.substr(j));\n if (max < temp1 * temp2) {\n max = temp1 * temp2;\n }\n }\n value = max;\n if (value == source_value) {\n cout << -1 << endl;\n goto TO;\n }\n }\n cout << count << endl;\n TO:;\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint Q, N, logn, r, l, turn;\nint main() {\n cin >> Q;\n for (int i = 0; i < Q; i++) {\n cin >> N;\n logn = int(log10(N)) + 1;\n if (logn == 1)\n cout << 0 << endl;\n else {\n turn = 0;\n while (logn != 1) {\n int max = 0;\n for (int j = 0; j < logn - 1; j++) {\n r = N % int(pow(10, j + 1) + 0.1);\n l = N / int(pow(10, j + 1) + 0.1);\n if (max < r * l) {\n max = r * l;\n }\n }\n N = max;\n logn = int(log10(N)) + 1;\n turn++;\n }\n return turn;\n }\n }\n return 0;\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint main() {\n int n, a, b, i, c, p, w, x, m, j, k, t;\n cin >> n;\n while (n--) {\n cin >> a;\n c = 0;\n while (1) {\n for (m = 0, t = b = a, i = -1; a; a /= 10) i++;\n if (!i || t) break;\n for (a = b, j = 1; j <= i; j++) {\n w = 0;\n a = b = t;\n for (k = 0; k != j; k++) {\n int o = 1;\n p = a % 10;\n for (x = 1; x <= k; x++) o *= 10;\n w += o * p;\n a /= 10;\n }\n while (x--) b /= 10;\n if (w)\n m = max(m, w * b);\n else\n m = b;\n }\n a = m;\n c++;\n }\n cout << c << endl;\n }\n}\n", "#include <bits/stdc++.h>\nusing namespace std;\nint GetDigit(int num) { return to_string(num).length(); }\nint Q;\nint main() {\n cin >> Q;\n for (int i = 0; i < Q; ++i) {\n int n;\n cin >> n;\n int digit = GetDigit(n);\n int count = 0;\n while (1) {\n int max = 0;\n if (n >= 1 && n <= 9) {\n cout << count << endl;\n break;\n } else {\n for (int j = 1; j <= digit - 1; ++j) {\n int op1 = n / int(pow(10, j));\n int op2 = n % int(pow(10, j));\n if (op1 * op2 > max) {\n max = op1 * op2;\n }\n }\n ++count;\n if (max >= 1 && max <= 9) {\n cout << count << endl;\n break;\n } else if (count > 100) {\n cout << \"-1\" << endl;\n break;\n } else {\n n = max;\n }\n }\n }\n }\n return 0;\n}\n", "Q = int(input())\n\ndef solve(x,ans):\n #X = str(x)\n print(x,ans)\n if len(x) == 1:\n# print(ans)\n return\n ret= 0\n for i in range(1,len(x)):\n n = int(x[i:]) * int(x[:i])\n ret = max(ret , n)\n \n #print(ret)\n return solve(str(ret),ans + 1)\n\nfor i in range(Q):\n solve(input(),0)\n\n", "import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons,std.numeric,std.math,std.random,std.concurrency;\nconst dx = [1,0,-1,0], dy = [0,1,0,-1];\nconst readMixin = q{ auto line = readln().split();foreach(i,ref arg; args){ if (i >= line.length) return;arg = line[i].to!(typeof(arg));}};\nvoid read(T...) (auto ref T args){ mixin(readMixin);}\nvoid readArray(T)(auto ref T args){ mixin(readMixin);}\nint read(){int n;read(n);return n;}\nvoid times(int n,void delegate() stmt){foreach(i;iota(n))stmt();}\nauto dot(R1,R2)(R1 a,R2 b){ElementType!(R1) res=0;for(;!a.empty&&!b.empty;a.popFront(),b.popFront())res+=a.front*b.front;return res;}\nstruct infIota{\n\tint i = 0;\n\tenum empty = false;\n\tint front() { return i; }\n\tvoid popFront() { i++; }\n}\n\nint calc(int n){\n\tif (n < 10) return 0;\n\tint [] ns;\n\twhile(n){ns ~= n % 10;n /= 10;}\n\tint [] res;\n\tauto tens = ()=> infIota(ns.length).map!\"10^^a\";\n\tforeach(i;1 .. ns.length){\n\t\tres ~= ns[0..i].dot(tens()) * ns[i..$].dot(tens());\n\t}\n\treturn 1 + calc(res.reduce!(max));\n}\nvoid main(){ \n\tread().times({ read().calc.writeln; });\n}", "#include <bits/stdc++.h>\nusing namespace std;\nint main(void) {\n long long int Q;\n cin >> Q;\n while (Q--) {\n string str;\n int cnt = 0;\n cin >> str;\n vector<int> n(str.size());\n for (int i = 0; i < str.size(); i++) n[i] = str[i] - '0';\n while (n.size() > 1) {\n double num = 0;\n if (n[0] <= n[n.size()]) {\n for (int i = 1; i < n.size(); i++) num = num * 10 + (n[i]);\n num = num * (n[0]);\n } else {\n for (int i = 0; i < n.size() - 1; i++) {\n num = num * 10 + n[i];\n }\n num = num * (n[n.size() - 1]);\n }\n int size = 1;\n for (int i = 0; i < n.size() - 1; i++) size *= 10;\n n.clear();\n if ((int)num / size == 0) size /= 10;\n while (num != 0) {\n int no = (int)num / size;\n num = (int)num % size;\n size = size / 10;\n n.push_back(no);\n }\n cnt++;\n }\n cout << cnt << endl;\n }\n}\n" ] }
709
0
0
[ "binary search", "brute force", "geometry", "math" ]
false
{ "nanos": 0, "seconds": 2 }
256,000,000
p01538 Kakezan
"Taro is going to play a card game. However, now he has only n cards, even though there should be 52(...TRUNCATED)
{ "input": [ "2\n5 10\n3 4 6 1 9\n3 2\n1 3 4" ], "output": [ "1\n0" ] }
{"input":["3\n2 2 3\n","5\n1 4 5 4 5\n","4\n2 2 4 4\n","3\n1 1 2\n","4\n1 2 1 2\n","4\n4 2 2 4\n","6(...TRUNCATED)
{"input":["20 20\n1 9\n11 9\n3 5\n15 13\n1 20\n11 18\n10 6\n10 8\n10 19\n12 16\n10 3\n9 18\n8 7\n15 (...TRUNCATED)
2
0
{"language":[2,2,2,2,2,2,2,4,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,4,2,4,4,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2(...TRUNCATED)
{"language":[3,4,2,4,4,2,1,4,2,4,2,2,2,4,2,4,4,1,2,4,2,2,4,1,4,2,4,4,2,4,4,4,2,4,4,2,2,4,2,3,2,4,4,2(...TRUNCATED)
0
500
2,200
[ "" ]
false
{ "nanos": 0, "seconds": 3 }
256,000,000
5_A. Chat Server's Outgoing Traffic
"Hasan loves playing games and has recently discovered a game called TopScore. In this soccer-like g(...TRUNCATED)
{ "input": [ "3", "100", "1000000" ], "output": [ "3", "473", "13969985" ] }
{ "input": [], "output": [] }
{"input":["5\n90 94\n26 25\n64 84\n18 6\n20 96\n","5\n1912 1\n5 6\n999 1\n88 2\n11 100\n","5\n90 94\(...TRUNCATED)
3
0
{"language":[2,2,2,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,2,4,2,2,2,2,2,2,2,4,2,2,2,2(...TRUNCATED)
{"language":[3,3,2,0,0,3,2,2,4,2,0,4,0,0,0,0,2,0,2,0,2,2,0,0,0,2,2,1,2,3,2,2,0,4,2,4,2,2,2,2,2,2,3,0(...TRUNCATED)
76
A
1,500
2,300
[ "dp", "greedy", "strings" ]
false
{ "nanos": 0, "seconds": 2 }
256,000,000
vibhu-and-his-mathematics
"Dima and Inna love spending time together. The problem is, Seryozha isn't too enthusiastic to leave(...TRUNCATED)
{ "input": [ "3 8\n6 5 8\n", "7 20\n21 15 12 11 20 19 12\n" ], "output": [ "2\n", "6\n" ] }
{"input":["1 1\n0\n10000\n","2 3\n1 0\n4 7\n","1 2\n0\n10000\n","3 10\n0 1 2\n9240 5331 6721\n","4 1(...TRUNCATED)
{"input":["1 5000 2732\n","2 2 0\n","83 4122 123\n","19 862 387\n","100 843 30\n","45 1296 245\n","9(...TRUNCATED)
1
0
{"language":[4,1,4,3,3,3,3,4,3,2,3,2,3,3,3,3,4,3,2,3,3,2,2,2,2,2,3,4,3,4,2,1,4,3,2,2,2,3,2,4,3,2,3,3(...TRUNCATED)
{"language":[2,4,0,2,2,2,2,2,2,3,2,2,4,3,3,2,2,3,3,3,2,2,2,2,2,2,2,3,3,0,3,2,3,3,2,2,0,2,3,2,2,3,2,2(...TRUNCATED)
530
H
0
0
[ "two pointers" ]
true
{ "nanos": 0, "seconds": 1 }
512,000,000
1208_D. Restore Permutation
"Imagine that you are the CEO of a big old-fashioned company. Unlike any modern and progressive comp(...TRUNCATED)
{ "input": [ "5 3 2\naaaaa\naaa\naab" ], "output": [ "1 6" ] }
{"input":["20\naaaaaaaaaaaaaaaaaaaa\n1\n11 a\n","4\ncbcc\n12\n4 b\n4 c\n1 b\n2 a\n3 b\n2 c\n4 a\n1 a(...TRUNCATED)
{"input":["6\n773209925 62005863 473635171 329666981 510631133 207643327\n","1\n2\n","7\n481003311 5(...TRUNCATED)
2
7
{"language":[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],"sol(...TRUNCATED)
{"language":[4,1,4,4,2,4,4,2,4,1,3,2,3,4,3,3,3,2,2,2,4,3,3,2,4,3,1,3,3,3,2,4,3,3,1,3,3,2,2,1,4,1,2,4(...TRUNCATED)
0
D
0
2,200
[ "greedy" ]
false
null
268,435,456
1361_E. James and the Chase
"The russian intelligence agency KGB make an encryption technique to send their passwords. Originall(...TRUNCATED)
{ "input": [ "2\n1 23\n\nSAMPLE" ], "output": [ "NO\n" ] }
{"input":["5\n0 968804136\n0 736567537\n2 343136264\n0 259899572\n1 425744418\n","5\n0 51690939\n0 6(...TRUNCATED)
{"input":["3\n1 0 6\n","10\n7 7 7 7 7 7 7 7 7 3\n","76\n13 13 5 6 20 20 6 1 18 18 13 15 20 3 9 11 3 (...TRUNCATED)
6
9
{"language":[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,4,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2(...TRUNCATED)
{"language":[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,4,2,4,2,2,4,4,2,4,4,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2(...TRUNCATED)
1,291
A
1,000
0
[]
false
{ "nanos": 0, "seconds": 1 }
134,217,728
muffins3
"Alice had a permutation p_1, p_2, …, p_n. Unfortunately, the permutation looked very boring, so s(...TRUNCATED)
{ "input": [ "3\nkek\npreceq\ncheburek\n", "4\nmail\nai\nlru\ncf\n" ], "output": [ "NO\n", "cfmailru\n" ] }
{"input":["2\nab\nac\n","2\nca\ncb\n","2\ndc\nec\n","2\naz\nzb\n","2\naa\nb\n","25\nsw\nwt\nc\nl\nyo(...TRUNCATED)
{"input":["4\n1 4\n3 2\n3 4\n","21\n7 15\n13 1\n14 3\n4 10\n2 3\n16 18\n17 20\n16 20\n8 4\n3 12\n2 1(...TRUNCATED)
2
0
{"language":[2,2,2,2,2,2,4,2,2,2,2,2,2,2,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,2,2,2,2,2,2,2,2,2,2,2,2,2(...TRUNCATED)
{"language":[2,2,2,2,2,2,2,2,2,2,2,3,2,4,2,2,2,4,2,4,2,2,2,2,2,4,2,2,2,2,2,2,2,4,2,2,2,2,2,2,2,2,2,2(...TRUNCATED)
962
A
1,250
0
[ "*special", "data structures", "dsu", "implementation", "math", "sortings" ]
false
{ "nanos": 0, "seconds": 6 }
256,000,000
p03774 AtCoder Beginner Contest 057 - Checkpoints
"In Walrusland public transport tickets are characterized by two integers: by the number of the seri(...TRUNCATED)
{"input":["3 100\n3\n2\n1","3 1\n3\n2\n1","5 3\n5\n3\n2\n1\n4","5 3\n1\n2\n3\n4\n5"],"output":["3\n2(...TRUNCATED)
{"input":["264193194 -448876521 736684426 -633906160 -328597212 -47935734\n","-357531221 381512519 -(...TRUNCATED)
{"input":["4\n39 18\n183 11\n551 27\n85 16","8\n4 65\n5 12\n7 21\n9 38\n12 24\n14 10\n65 75\n31 26",(...TRUNCATED)
2
9
{"language":[4,2,4,4,4,2,2,4,4,2,4,3,4,2,2,2,2,4,2,2,2,2,2,2,2,4,2,2,2,4,2,4,1,4,2,2,4,2,1,2,2,2,2,2(...TRUNCATED)
{"language":[4,2,2,2,2,2,2,2,2,2,2,2,2,2,2,4,2,4,2,2,4,4,4,2,2,2,4,4,2,1,3,2,2,2,4,2,2,2,4,4,2,2,2,2(...TRUNCATED)
1,012
K
0
1,800
[ "constructive algorithms", "math" ]
false
{ "nanos": 500000000, "seconds": 0 }
134,217,728
1117_F. Crisp String
"Differential pulse code modulation is one of the compression methods mainly used when compressing a(...TRUNCATED)
{ "input": [ "4\n2 10\n0 20\n1 5\n1 3\n", "3\n0 1\n0 10\n0 100\n" ], "output": [ "8", "111" ] }
{"input":["25\n1 8\n8 8\n64 8\n512 8\n4096 8\n32768 8\n262144 8\n2097152 8\n16777216 8\n134217728 8\(...TRUNCATED)
{"input":["7\n5\n-1 10 -1 12 -1\n5\n-1 40 35 -1 35\n6\n-1 -1 9 -1 3 -1\n2\n-1 -1\n2\n0 -1\n4\n1 -1 3(...TRUNCATED)
3
0
{"language":[2,4,4,4,4,4,4,2,4,4,2,2,4,4,3,3,1,4,4,3,2,2,3,4,4,2,2,4,4,4,4,2,2,4,2,2,2,2,2,2,2,4,2,4(...TRUNCATED)
{"language":[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2],"solution":["#include <bits/stdc++.h>\nusing n(...TRUNCATED)
1,320
0
3,000
[ "implementation", "strings" ]
false
{ "nanos": 0, "seconds": 1 }
256,000,000
1374_B. Multiply by 2, divide by 6
"You are given a simple arithmetic expression of the form a?b, where a and b are integer constants, (...TRUNCATED)
{ "input": [ "7\nabacaba\n", "3\naaa\n", "2\nab\n", "4\nbabb\n" ], "output": [ "589\n", "1\n", "3\n", "11\n" ] }
{ "input": [], "output": [] }
{"input":["10\n-1 -1\n1 1\n1 1\n3 0\n4 1\n2 0\n3 1\n2 1\n5 0\n5 0\n8\n1 2 6\n2 3 7\n2 4 7\n1 3 4\n2 (...TRUNCATED)
3
12
{"language":[3,1,2,2,2,2,2,4,2,2,2,3,3,3,2,2,3,4,2,2,2,3,2,3,2,3,3,3,2,3,2,3,1,4,1,3,2,2,2,1,1,2,2,2(...TRUNCATED)
{"language":[2,4,2,1,2,2,4,2,1,2,2,2,2,4,2,2,2,2,2,2,0,4,0,2,0,0,4,0,0,4,2,2,2,4,2,0,0,4,4,2,2,2,0,2(...TRUNCATED)
963
B
0
2,100
[ "*special" ]
false
{ "nanos": 0, "seconds": 5 }
256,000,000
End of preview. Expand in Data Studio

edition_3114_deepmind-code_contests-readymade

A Readymade by TheFactoryX

Original Dataset

deepmind/code_contests

Process

This dataset is a "readymade" - inspired by Marcel Duchamp's concept of taking everyday objects and recontextualizing them as art.

What we did:

  1. Selected the original dataset from Hugging Face
  2. Shuffled each column independently
  3. Destroyed all row-wise relationships
  4. Preserved structure, removed meaning

The result: Same data. Wrong order. New meaning. No meaning.

Purpose

This is art. This is not useful. This is the point.

Column relationships have been completely destroyed. The data maintains its types and values, but all semantic meaning has been removed.


Part of the Readymades project by TheFactoryX.

"I am a machine." — Andy Warhol

Downloads last month
6