message
stringlengths
2
11.9k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
137
108k
cluster
float64
18
18
__index_level_0__
int64
274
217k
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. One day Alex was creating a contest about his friends, but accidentally deleted it. Fortunately, all the problems were saved, but now he needs to find them among other problems. But there are too many problems, to do it manually. Alex asks you to write a program, which will determine if a problem is from this contest by its name. It is known, that problem is from this contest if and only if its name contains one of Alex's friends' name exactly once. His friends' names are "Danil", "Olya", "Slava", "Ann" and "Nikita". Names are case sensitive. Input The only line contains string from lowercase and uppercase letters and "_" symbols of length, not more than 100 — the name of the problem. Output Print "YES", if problem is from this contest, and "NO" otherwise. Examples Input Alex_and_broken_contest Output NO Input NikitaAndString Output YES Input Danil_and_Olya Output NO Submitted Solution: ``` s = input() a = ['Danil', 'Olya', 'Slava', 'Ann', 'Nikita'] an = 0 for i in range(len(a)): if a[i] in s: an += 1 if an == 0: print('YES') else: print('NO') ```
instruction
0
90,640
18
181,280
No
output
1
90,640
18
181,281
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. One day Alex was creating a contest about his friends, but accidentally deleted it. Fortunately, all the problems were saved, but now he needs to find them among other problems. But there are too many problems, to do it manually. Alex asks you to write a program, which will determine if a problem is from this contest by its name. It is known, that problem is from this contest if and only if its name contains one of Alex's friends' name exactly once. His friends' names are "Danil", "Olya", "Slava", "Ann" and "Nikita". Names are case sensitive. Input The only line contains string from lowercase and uppercase letters and "_" symbols of length, not more than 100 — the name of the problem. Output Print "YES", if problem is from this contest, and "NO" otherwise. Examples Input Alex_and_broken_contest Output NO Input NikitaAndString Output YES Input Danil_and_Olya Output NO Submitted Solution: ``` import sys def input(): return sys.stdin.readline().strip() def iinput(): return int(input()) def minput(): return map(int, input().split()) def listinput(): return list(map(int, input().split())) s=input() if s.count("Danil")+s.count("Olya")+s.count("Slava")+s.count("Ann")+s.count("Nikita"): print("YES") else: print("NO") ```
instruction
0
90,641
18
181,282
No
output
1
90,641
18
181,283
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya is an active Internet user. One day he came across an Internet resource he liked, so he wrote its address in the notebook. We know that the address of the written resource has format: <protocol>://<domain>.ru[/<context>] where: * <protocol> can equal either "http" (without the quotes) or "ftp" (without the quotes), * <domain> is a non-empty string, consisting of lowercase English letters, * the /<context> part may not be present. If it is present, then <context> is a non-empty string, consisting of lowercase English letters. If string <context> isn't present in the address, then the additional character "/" isn't written. Thus, the address has either two characters "/" (the ones that go before the domain), or three (an extra one in front of the context). When the boy came home, he found out that the address he wrote in his notebook had no punctuation marks. Vasya must have been in a lot of hurry and didn't write characters ":", "/", ".". Help Vasya to restore the possible address of the recorded Internet resource. Input The first line contains a non-empty string that Vasya wrote out in his notebook. This line consists of lowercase English letters only. It is guaranteed that the given string contains at most 50 letters. It is guaranteed that the given string can be obtained from some correct Internet resource address, described above. Output Print a single line — the address of the Internet resource that Vasya liked. If there are several addresses that meet the problem limitations, you are allowed to print any of them. Examples Input httpsunrux Output http://sun.ru/x Input ftphttprururu Output ftp://http.ru/ruru Note In the second sample there are two more possible answers: "ftp://httpruru.ru" and "ftp://httpru.ru/ru". Submitted Solution: ``` s = input() if s.startswith("http"): s = s.replace("http", "http://", 1) else: s = s.replace("ftp", "ftp://", 1) ind = s.index("ru") if s[ind:] == "ru": s = s.replace("ru", ".ru") else: if "//ru" not in s: s = s.replace("ru", ".ru/", 1) else: s = s.replace("//ru", "~~", 1) s = s.replace("ru", ".ru/", 1) s = s.replace("~~", "//ru", 1) print(s) ```
instruction
0
91,226
18
182,452
Yes
output
1
91,226
18
182,453
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya is an active Internet user. One day he came across an Internet resource he liked, so he wrote its address in the notebook. We know that the address of the written resource has format: <protocol>://<domain>.ru[/<context>] where: * <protocol> can equal either "http" (without the quotes) or "ftp" (without the quotes), * <domain> is a non-empty string, consisting of lowercase English letters, * the /<context> part may not be present. If it is present, then <context> is a non-empty string, consisting of lowercase English letters. If string <context> isn't present in the address, then the additional character "/" isn't written. Thus, the address has either two characters "/" (the ones that go before the domain), or three (an extra one in front of the context). When the boy came home, he found out that the address he wrote in his notebook had no punctuation marks. Vasya must have been in a lot of hurry and didn't write characters ":", "/", ".". Help Vasya to restore the possible address of the recorded Internet resource. Input The first line contains a non-empty string that Vasya wrote out in his notebook. This line consists of lowercase English letters only. It is guaranteed that the given string contains at most 50 letters. It is guaranteed that the given string can be obtained from some correct Internet resource address, described above. Output Print a single line — the address of the Internet resource that Vasya liked. If there are several addresses that meet the problem limitations, you are allowed to print any of them. Examples Input httpsunrux Output http://sun.ru/x Input ftphttprururu Output ftp://http.ru/ruru Note In the second sample there are two more possible answers: "ftp://httpruru.ru" and "ftp://httpru.ru/ru". Submitted Solution: ``` def puts(s): print(s, end='') s = input() if s.startswith('http'): puts('http://') s = s[4:] else: puts('ftp://') s = s[3:] i = s.rfind('ru') domen = s[:i] puts(domen + '.ru') if(domen + 'ru' != s): puts('/' + s[i + 2:]) print() ```
instruction
0
91,227
18
182,454
Yes
output
1
91,227
18
182,455
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya is an active Internet user. One day he came across an Internet resource he liked, so he wrote its address in the notebook. We know that the address of the written resource has format: <protocol>://<domain>.ru[/<context>] where: * <protocol> can equal either "http" (without the quotes) or "ftp" (without the quotes), * <domain> is a non-empty string, consisting of lowercase English letters, * the /<context> part may not be present. If it is present, then <context> is a non-empty string, consisting of lowercase English letters. If string <context> isn't present in the address, then the additional character "/" isn't written. Thus, the address has either two characters "/" (the ones that go before the domain), or three (an extra one in front of the context). When the boy came home, he found out that the address he wrote in his notebook had no punctuation marks. Vasya must have been in a lot of hurry and didn't write characters ":", "/", ".". Help Vasya to restore the possible address of the recorded Internet resource. Input The first line contains a non-empty string that Vasya wrote out in his notebook. This line consists of lowercase English letters only. It is guaranteed that the given string contains at most 50 letters. It is guaranteed that the given string can be obtained from some correct Internet resource address, described above. Output Print a single line — the address of the Internet resource that Vasya liked. If there are several addresses that meet the problem limitations, you are allowed to print any of them. Examples Input httpsunrux Output http://sun.ru/x Input ftphttprururu Output ftp://http.ru/ruru Note In the second sample there are two more possible answers: "ftp://httpruru.ru" and "ftp://httpru.ru/ru". Submitted Solution: ``` s = input() n = len(s) http = False ftp = False last = 0 i = 0 answer = '' while i < n: if http or ftp: if s[i:i+2] == 'ru': last = i i += 2 else: i += 1 else: if s[i:i+4] == 'http': answer += 'http://' http = True i += 4 elif s[i:i+3] == 'ftp': answer += 'ftp://' ftp = True i += 3 if http: answer += s[4:last] + '.ru' if s[last+2:]: answer += '/' + s[last+2:] else: answer += s[3:last] + '.ru' if s[last+2:]: answer += '/' + s[last+2:] print(answer) ```
instruction
0
91,228
18
182,456
Yes
output
1
91,228
18
182,457
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya is an active Internet user. One day he came across an Internet resource he liked, so he wrote its address in the notebook. We know that the address of the written resource has format: <protocol>://<domain>.ru[/<context>] where: * <protocol> can equal either "http" (without the quotes) or "ftp" (without the quotes), * <domain> is a non-empty string, consisting of lowercase English letters, * the /<context> part may not be present. If it is present, then <context> is a non-empty string, consisting of lowercase English letters. If string <context> isn't present in the address, then the additional character "/" isn't written. Thus, the address has either two characters "/" (the ones that go before the domain), or three (an extra one in front of the context). When the boy came home, he found out that the address he wrote in his notebook had no punctuation marks. Vasya must have been in a lot of hurry and didn't write characters ":", "/", ".". Help Vasya to restore the possible address of the recorded Internet resource. Input The first line contains a non-empty string that Vasya wrote out in his notebook. This line consists of lowercase English letters only. It is guaranteed that the given string contains at most 50 letters. It is guaranteed that the given string can be obtained from some correct Internet resource address, described above. Output Print a single line — the address of the Internet resource that Vasya liked. If there are several addresses that meet the problem limitations, you are allowed to print any of them. Examples Input httpsunrux Output http://sun.ru/x Input ftphttprururu Output ftp://http.ru/ruru Note In the second sample there are two more possible answers: "ftp://httpruru.ru" and "ftp://httpru.ru/ru". Submitted Solution: ``` print('/'.join(input().rpartition('ru')).replace('/', '.', 1) .replace('tp', 'tp://', 1).rstrip('/')) ```
instruction
0
91,229
18
182,458
Yes
output
1
91,229
18
182,459
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya is an active Internet user. One day he came across an Internet resource he liked, so he wrote its address in the notebook. We know that the address of the written resource has format: <protocol>://<domain>.ru[/<context>] where: * <protocol> can equal either "http" (without the quotes) or "ftp" (without the quotes), * <domain> is a non-empty string, consisting of lowercase English letters, * the /<context> part may not be present. If it is present, then <context> is a non-empty string, consisting of lowercase English letters. If string <context> isn't present in the address, then the additional character "/" isn't written. Thus, the address has either two characters "/" (the ones that go before the domain), or three (an extra one in front of the context). When the boy came home, he found out that the address he wrote in his notebook had no punctuation marks. Vasya must have been in a lot of hurry and didn't write characters ":", "/", ".". Help Vasya to restore the possible address of the recorded Internet resource. Input The first line contains a non-empty string that Vasya wrote out in his notebook. This line consists of lowercase English letters only. It is guaranteed that the given string contains at most 50 letters. It is guaranteed that the given string can be obtained from some correct Internet resource address, described above. Output Print a single line — the address of the Internet resource that Vasya liked. If there are several addresses that meet the problem limitations, you are allowed to print any of them. Examples Input httpsunrux Output http://sun.ru/x Input ftphttprururu Output ftp://http.ru/ruru Note In the second sample there are two more possible answers: "ftp://httpruru.ru" and "ftp://httpru.ru/ru". Submitted Solution: ``` s = input() n = len(s) http = False ftp = False i = 0 answer = '' while i < n: if http or ftp: if s[i:i+2] == 'ru': answer += '.ru' i += 2 if s[i:]: answer += '/' + s[i:] break else: answer += s[i] i += 1 if s[i:i+4] == 'http': answer += 'http://' http = True i += 4 elif s[i:i+3] == 'ftp': answer += 'ftp://' ftp = True i += 3 print(answer) ```
instruction
0
91,230
18
182,460
No
output
1
91,230
18
182,461
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya is an active Internet user. One day he came across an Internet resource he liked, so he wrote its address in the notebook. We know that the address of the written resource has format: <protocol>://<domain>.ru[/<context>] where: * <protocol> can equal either "http" (without the quotes) or "ftp" (without the quotes), * <domain> is a non-empty string, consisting of lowercase English letters, * the /<context> part may not be present. If it is present, then <context> is a non-empty string, consisting of lowercase English letters. If string <context> isn't present in the address, then the additional character "/" isn't written. Thus, the address has either two characters "/" (the ones that go before the domain), or three (an extra one in front of the context). When the boy came home, he found out that the address he wrote in his notebook had no punctuation marks. Vasya must have been in a lot of hurry and didn't write characters ":", "/", ".". Help Vasya to restore the possible address of the recorded Internet resource. Input The first line contains a non-empty string that Vasya wrote out in his notebook. This line consists of lowercase English letters only. It is guaranteed that the given string contains at most 50 letters. It is guaranteed that the given string can be obtained from some correct Internet resource address, described above. Output Print a single line — the address of the Internet resource that Vasya liked. If there are several addresses that meet the problem limitations, you are allowed to print any of them. Examples Input httpsunrux Output http://sun.ru/x Input ftphttprururu Output ftp://http.ru/ruru Note In the second sample there are two more possible answers: "ftp://httpruru.ru" and "ftp://httpru.ru/ru". Submitted Solution: ``` a = list(input()) if a[0] == 'f': print('ftp://',end = '') a = a[3:] print(''.join(a[:''.join(a).index('ru')]),end = '') a = a[''.join(a).index('ru')+2:] print('.ru',end='') if len(a) != 0: print('/',end='') print(''.join(a)) else: print('http://',end = '') a = a[4:] print(''.join(a[:''.join(a).index('ru')]),end = '') a = a[''.join(a).index('ru')+2:] print('.ru',end='') if len(a) != 0: print('/',end='') print(''.join(a)) ```
instruction
0
91,231
18
182,462
No
output
1
91,231
18
182,463
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya is an active Internet user. One day he came across an Internet resource he liked, so he wrote its address in the notebook. We know that the address of the written resource has format: <protocol>://<domain>.ru[/<context>] where: * <protocol> can equal either "http" (without the quotes) or "ftp" (without the quotes), * <domain> is a non-empty string, consisting of lowercase English letters, * the /<context> part may not be present. If it is present, then <context> is a non-empty string, consisting of lowercase English letters. If string <context> isn't present in the address, then the additional character "/" isn't written. Thus, the address has either two characters "/" (the ones that go before the domain), or three (an extra one in front of the context). When the boy came home, he found out that the address he wrote in his notebook had no punctuation marks. Vasya must have been in a lot of hurry and didn't write characters ":", "/", ".". Help Vasya to restore the possible address of the recorded Internet resource. Input The first line contains a non-empty string that Vasya wrote out in his notebook. This line consists of lowercase English letters only. It is guaranteed that the given string contains at most 50 letters. It is guaranteed that the given string can be obtained from some correct Internet resource address, described above. Output Print a single line — the address of the Internet resource that Vasya liked. If there are several addresses that meet the problem limitations, you are allowed to print any of them. Examples Input httpsunrux Output http://sun.ru/x Input ftphttprururu Output ftp://http.ru/ruru Note In the second sample there are two more possible answers: "ftp://httpruru.ru" and "ftp://httpru.ru/ru". Submitted Solution: ``` s = input() if(s[0]=='h'): s1 = s[:4]+"://" s2 = list(s[4:]) s3='' c=0 s4='' for i in range(len(s2)-1): if s2[i]=='r' and s2[i+1]=='u': a = s2[i]+s2[i+1] break else: s3 = s3+s2[i] for i in range(len(s)): if(s[i]=='r' and s[i+1]=='u'): s4 = s4+s[i+2:] print(s1+s3+'.'+a+'/'+s4) elif(s[0]=='f'): s1 = s[:3]+"://"+s[3:7] s2 = list(s[7:]) s3='' s4='' for i in range(len(s2)-1): if s2[i]=='r' and s2[i+1]=='u': a = s2[i]+s2[i+1] break else: s3=s3+s2[i] for i in range(len(s)): if(s[i]=='r' and s[i+1]=='u'): s4 = s4+s[i+2:] break print(s1+s3+'.'+a+'/'+s4) ```
instruction
0
91,232
18
182,464
No
output
1
91,232
18
182,465
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Vasya is an active Internet user. One day he came across an Internet resource he liked, so he wrote its address in the notebook. We know that the address of the written resource has format: <protocol>://<domain>.ru[/<context>] where: * <protocol> can equal either "http" (without the quotes) or "ftp" (without the quotes), * <domain> is a non-empty string, consisting of lowercase English letters, * the /<context> part may not be present. If it is present, then <context> is a non-empty string, consisting of lowercase English letters. If string <context> isn't present in the address, then the additional character "/" isn't written. Thus, the address has either two characters "/" (the ones that go before the domain), or three (an extra one in front of the context). When the boy came home, he found out that the address he wrote in his notebook had no punctuation marks. Vasya must have been in a lot of hurry and didn't write characters ":", "/", ".". Help Vasya to restore the possible address of the recorded Internet resource. Input The first line contains a non-empty string that Vasya wrote out in his notebook. This line consists of lowercase English letters only. It is guaranteed that the given string contains at most 50 letters. It is guaranteed that the given string can be obtained from some correct Internet resource address, described above. Output Print a single line — the address of the Internet resource that Vasya liked. If there are several addresses that meet the problem limitations, you are allowed to print any of them. Examples Input httpsunrux Output http://sun.ru/x Input ftphttprururu Output ftp://http.ru/ruru Note In the second sample there are two more possible answers: "ftp://httpruru.ru" and "ftp://httpru.ru/ru". Submitted Solution: ``` s = input() if(s[0]=='h'): s1 = s[:4]+"://" s2 = list(s[4:]) s3='' s4='' for i in range(len(s2)-1): if s2[i]=='r' and s2[i+1]=='u' and i!=0: a = s2[i]+s2[i+1] break else: s3 = s3+s2[i] for i in range(len(s)): if(s[i]=='r' and s[i+1]=='u' and i!=4): s4 = s4+s[i+2:] break print(s1+s3+'.'+a+'/'+s4) elif(s[0]=='f'): s1 = s[:3]+"://"+s[3:7] s2 = list(s[7:]) s3='' s4='' for i in range(len(s2)-1): if s2[i]=='r' and s2[i+1]=='u': a = s2[i]+s2[i+1] break else: s3=s3+s2[i] for i in range(len(s)): if(s[i]=='r' and s[i+1]=='u'): s4 = s4+s[i+2:] break print(s1+s3+'.'+a+'/'+s4) ```
instruction
0
91,233
18
182,466
No
output
1
91,233
18
182,467
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled "a" to "z", and he has compiled them into a photo booklet with some photos in some order (possibly with some photos being duplicated). A photo booklet can be described as a string of lowercase letters, consisting of the photos in the booklet in order. He now wants to sell some "special edition" photobooks, each with one extra photo inserted anywhere in the book. He wants to make as many distinct photobooks as possible, so he can make more money. He asks Haruhi, how many distinct photobooks can he make by inserting one extra photo into the photobook he already has? Please help Haruhi solve this problem. Input The first line of input will be a single string s (1 ≤ |s| ≤ 20). String s consists only of lowercase English letters. Output Output a single integer equal to the number of distinct photobooks Kyoya Ootori can make. Examples Input a Output 51 Input hi Output 76 Note In the first case, we can make 'ab','ac',...,'az','ba','ca',...,'za', and 'aa', producing a total of 51 distinct photo booklets. Submitted Solution: ``` a=input() print(((len(a)+1)*26)-len(a)) ```
instruction
0
91,300
18
182,600
Yes
output
1
91,300
18
182,601
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled "a" to "z", and he has compiled them into a photo booklet with some photos in some order (possibly with some photos being duplicated). A photo booklet can be described as a string of lowercase letters, consisting of the photos in the booklet in order. He now wants to sell some "special edition" photobooks, each with one extra photo inserted anywhere in the book. He wants to make as many distinct photobooks as possible, so he can make more money. He asks Haruhi, how many distinct photobooks can he make by inserting one extra photo into the photobook he already has? Please help Haruhi solve this problem. Input The first line of input will be a single string s (1 ≤ |s| ≤ 20). String s consists only of lowercase English letters. Output Output a single integer equal to the number of distinct photobooks Kyoya Ootori can make. Examples Input a Output 51 Input hi Output 76 Note In the first case, we can make 'ab','ac',...,'az','ba','ca',...,'za', and 'aa', producing a total of 51 distinct photo booklets. Submitted Solution: ``` d=len(input()) print((d+1)*26-d) ```
instruction
0
91,301
18
182,602
Yes
output
1
91,301
18
182,603
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled "a" to "z", and he has compiled them into a photo booklet with some photos in some order (possibly with some photos being duplicated). A photo booklet can be described as a string of lowercase letters, consisting of the photos in the booklet in order. He now wants to sell some "special edition" photobooks, each with one extra photo inserted anywhere in the book. He wants to make as many distinct photobooks as possible, so he can make more money. He asks Haruhi, how many distinct photobooks can he make by inserting one extra photo into the photobook he already has? Please help Haruhi solve this problem. Input The first line of input will be a single string s (1 ≤ |s| ≤ 20). String s consists only of lowercase English letters. Output Output a single integer equal to the number of distinct photobooks Kyoya Ootori can make. Examples Input a Output 51 Input hi Output 76 Note In the first case, we can make 'ab','ac',...,'az','ba','ca',...,'za', and 'aa', producing a total of 51 distinct photo booklets. Submitted Solution: ``` #-------------Program-------------- #----Kuzlyaev-Nikita-Codeforces---- #-------------Training------------- #---------------------------------- s=str(input()) print(26*len(s+"s")-len(s)) ```
instruction
0
91,302
18
182,604
Yes
output
1
91,302
18
182,605
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled "a" to "z", and he has compiled them into a photo booklet with some photos in some order (possibly with some photos being duplicated). A photo booklet can be described as a string of lowercase letters, consisting of the photos in the booklet in order. He now wants to sell some "special edition" photobooks, each with one extra photo inserted anywhere in the book. He wants to make as many distinct photobooks as possible, so he can make more money. He asks Haruhi, how many distinct photobooks can he make by inserting one extra photo into the photobook he already has? Please help Haruhi solve this problem. Input The first line of input will be a single string s (1 ≤ |s| ≤ 20). String s consists only of lowercase English letters. Output Output a single integer equal to the number of distinct photobooks Kyoya Ootori can make. Examples Input a Output 51 Input hi Output 76 Note In the first case, we can make 'ab','ac',...,'az','ba','ca',...,'za', and 'aa', producing a total of 51 distinct photo booklets. Submitted Solution: ``` s = input() se = set() for j in "qwertyuiopasdfghjklzxcvbnm": for i in range(len(s)+1): se.add(s[:i]+j+s[i:]) print(len(se)) ```
instruction
0
91,303
18
182,606
Yes
output
1
91,303
18
182,607
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled "a" to "z", and he has compiled them into a photo booklet with some photos in some order (possibly with some photos being duplicated). A photo booklet can be described as a string of lowercase letters, consisting of the photos in the booklet in order. He now wants to sell some "special edition" photobooks, each with one extra photo inserted anywhere in the book. He wants to make as many distinct photobooks as possible, so he can make more money. He asks Haruhi, how many distinct photobooks can he make by inserting one extra photo into the photobook he already has? Please help Haruhi solve this problem. Input The first line of input will be a single string s (1 ≤ |s| ≤ 20). String s consists only of lowercase English letters. Output Output a single integer equal to the number of distinct photobooks Kyoya Ootori can make. Examples Input a Output 51 Input hi Output 76 Note In the first case, we can make 'ab','ac',...,'az','ba','ca',...,'za', and 'aa', producing a total of 51 distinct photo booklets. Submitted Solution: ``` st = input() a = [1]*20 a0 = st[0] j = 0 for i in range(1,len(st)): if st[i] == a0: a[j] += 1 else: a0 = st[i] j += 1 if a0 != st[len(st)-2]: j += 1 i = j+1 while i < len(st): del a[j+1] i += 1 print(len(a) * 25 + 26) ```
instruction
0
91,304
18
182,608
No
output
1
91,304
18
182,609
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled "a" to "z", and he has compiled them into a photo booklet with some photos in some order (possibly with some photos being duplicated). A photo booklet can be described as a string of lowercase letters, consisting of the photos in the booklet in order. He now wants to sell some "special edition" photobooks, each with one extra photo inserted anywhere in the book. He wants to make as many distinct photobooks as possible, so he can make more money. He asks Haruhi, how many distinct photobooks can he make by inserting one extra photo into the photobook he already has? Please help Haruhi solve this problem. Input The first line of input will be a single string s (1 ≤ |s| ≤ 20). String s consists only of lowercase English letters. Output Output a single integer equal to the number of distinct photobooks Kyoya Ootori can make. Examples Input a Output 51 Input hi Output 76 Note In the first case, we can make 'ab','ac',...,'az','ba','ca',...,'za', and 'aa', producing a total of 51 distinct photo booklets. Submitted Solution: ``` PRIME_COUNT = 10 ** 6 is_prime = [True] * PRIME_COUNT primes = [] for i in range(2, 1000): if is_prime[i]: for j in range(i * i, PRIME_COUNT, i): is_prime[j] = False for i in range(len(is_prime)): if is_prime[i]: primes.append(i) ```
instruction
0
91,305
18
182,610
No
output
1
91,305
18
182,611
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled "a" to "z", and he has compiled them into a photo booklet with some photos in some order (possibly with some photos being duplicated). A photo booklet can be described as a string of lowercase letters, consisting of the photos in the booklet in order. He now wants to sell some "special edition" photobooks, each with one extra photo inserted anywhere in the book. He wants to make as many distinct photobooks as possible, so he can make more money. He asks Haruhi, how many distinct photobooks can he make by inserting one extra photo into the photobook he already has? Please help Haruhi solve this problem. Input The first line of input will be a single string s (1 ≤ |s| ≤ 20). String s consists only of lowercase English letters. Output Output a single integer equal to the number of distinct photobooks Kyoya Ootori can make. Examples Input a Output 51 Input hi Output 76 Note In the first case, we can make 'ab','ac',...,'az','ba','ca',...,'za', and 'aa', producing a total of 51 distinct photo booklets. Submitted Solution: ``` a=input() print(26*(len(a)+1)-len(set(a))) ```
instruction
0
91,306
18
182,612
No
output
1
91,306
18
182,613
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He has 26 photos, labeled "a" to "z", and he has compiled them into a photo booklet with some photos in some order (possibly with some photos being duplicated). A photo booklet can be described as a string of lowercase letters, consisting of the photos in the booklet in order. He now wants to sell some "special edition" photobooks, each with one extra photo inserted anywhere in the book. He wants to make as many distinct photobooks as possible, so he can make more money. He asks Haruhi, how many distinct photobooks can he make by inserting one extra photo into the photobook he already has? Please help Haruhi solve this problem. Input The first line of input will be a single string s (1 ≤ |s| ≤ 20). String s consists only of lowercase English letters. Output Output a single integer equal to the number of distinct photobooks Kyoya Ootori can make. Examples Input a Output 51 Input hi Output 76 Note In the first case, we can make 'ab','ac',...,'az','ba','ca',...,'za', and 'aa', producing a total of 51 distinct photo booklets. Submitted Solution: ``` ''' Welcome to GDB Online. GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl, C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog. Code, Compile, Run and Debug online from anywhere in world. ''' s=input() n=len(s) if(n>1): a=(26-n)*(n+1)+(n*2) else: a=(26-n)*(n+1)+1 print(a) ```
instruction
0
91,307
18
182,614
No
output
1
91,307
18
182,615
Provide a correct Python 3 solution for this coding contest problem. Dr .: Peter, I've finally done it. Peter: What's wrong, Dr. David? Is it a silly invention again? Dr .: This table, this table. | Character | Sign --- | --- (Blank) | 101 '| 000000 , | 000011 -| 10010001 . | 010001 ? | 000001 A | 100101 B | 10011010 | Character | Sign --- | --- C | 0101 D | 0001 E | 110 F | 01001 G | 10011011 H | 010000 I | 0111 J | 10011000 | Character | Sign --- | --- K | 0110 L | 00100 M | 10011001 N | 10011110 O | 00101 P | 111 Q | 10011111 R | 1000 | Character | Sign --- | --- S | 00110 T | 00111 U | 10011100 V | 10011101 W | 000010 X | 10010010 Y | 10010011 Z | 10010000 Peter: What? This table is. Dr .: Okay, just do what you say. First, write your name on a piece of paper. Peter: Yes, "PETER POTTER". Dr .: Then, replace each character with the "code" in this table. Peter: Well, change "P" to "111" and "E" to "110" ... It's quite annoying. 111 110 00111 110 1000 101 111 00101 00111 00111 110 1000 became. It looks like a barcode. Dr .: All right. Then connect all the replaced strings and separate them by 5 characters. Peter: Yes, if you connect and separate. 11111 00011 11101 00010 11110 01010 01110 01111 10100 0 It turned out to be something like this. But what about the last "0" guy? Dr .: Add 0 to make it 5 letters. Peter: Well, there is only one 0 at the end, so I should add four more 0s. I was able to do it. 11111 00011 11101 00010 11110 01010 01110 01111 10100 00000 Dr .: Next, use this table. | Sign | Character --- | --- 00000 | A 00001 | B 00010 | C 00011 | D 00100 | E 00101 | F 00110 | G 00111 | H | Sign | Character --- | --- 01000 | I 01001 | J 01010 | K 01011 | L 01100 | M 01101 | N 01110 | O 01111 | P | Sign | Character --- | --- 10000 | Q 10001 | R 10010 | S 10011 | T 10100 | U 10101 | V 10110 | W 10111 | X | Sign | Character --- | --- 11000 | Y 11001 | Z 11010 | (blank) 11011 | .. 11100 |, 11101 |- 11110 |' 11111 |? Peter: How do you use this ... yeah! Now you're going to replace the code with a letter! Dr .: That's right. If it is "11111", go to "?", If it is "00011", go to "D". Peter: This is simple ... well, it became "? D-C'KOPUA". But it doesn't make sense. Dr .: Count the number of characters. Peter: It's 10 characters. Oh, "PETER POTTER" was 12 characters, but 2 characters are reduced. Dr .: Yes, you can use this table to reduce the number of letters. Now do the same thing in this sentence. PETER PIPER PICKED A PECK OF PICKLED PEPPERS. A PECK OF PICKLED PEPPERS PETER PIPER PICKED. IF PETER PIPER PICKED A PECK OF PICKLED PEPPERS, WHERE'S THE PECK OF PICKLED PEPPERS PETER PIPER PICKED? Peter: Gyogyo, the lines are separated, what do you do? Dr .: Due to space limitations, there are only 3 lines, but think of it as a long line with a space instead of a newline character. Peter: Yes, yes. There is a blank space between the lines. But it's a hassle ... Dr .: Then why not let the program do it? So, instead of Peter, create a program that converts the read character string into a code and outputs it. input Given multiple datasets. Each dataset is given a line of strings (consisting of the characters contained in the table). The string contains at least 1 and no more than 100 characters. The number of datasets does not exceed 200. output For each data set, output the converted character string on one line. Example Input PETER POTTER Output ?D-C'KOPUA
instruction
0
91,611
18
183,222
"Correct Solution: ``` L = { " ": "101", "'": "000000", ",": "000011", "-": "10010001", ".": "010001", "?": "000001", "A": "100101", "B": "10011010", "C": "0101", "D": "0001", "E": "110", "F": "01001", "G": "10011011", "H": "010000", "I": "0111", "J": "10011000", "K": "0110", "L": "00100", "M": "10011001", "N": "10011110", "O": "00101", "P": "111", "Q": "10011111", "R": "1000", "S": "00110", "T": "00111", "U": "10011100", "V": "10011101", "W": "000010", "X": "10010010", "Y": "10010011", "Z": "10010000" } M = { "00000": "A", "00001": "B", "00010": "C", "00011": "D", "00100": "E", "00101": "F", "00110": "G", "00111": "H", "01000": "I", "01001": "J", "01010": "K", "01011": "L", "01100": "M", "01101": "N", "01110": "O", "01111": "P", "10000": "Q", "10001": "R", "10010": "S", "10011": "T", "10100": "U", "10101": "V", "10110": "W", "10111": "X", "11000": "Y", "11001": "Z", "11010": " ", "11011": ".", "11100": ",", "11101": "-", "11110": "'", "11111": "?" } while True: try: s = input() except: break t = "" for i in s: t += L[i] t += "0" * ( (-len(t))%5 ) o = "" for i in range( len(t) // 5 ): u = t[i*5:i*5+5] o += M[u] print(o) ```
output
1
91,611
18
183,223
Provide a correct Python 3 solution for this coding contest problem. Dr .: Peter, I've finally done it. Peter: What's wrong, Dr. David? Is it a silly invention again? Dr .: This table, this table. | Character | Sign --- | --- (Blank) | 101 '| 000000 , | 000011 -| 10010001 . | 010001 ? | 000001 A | 100101 B | 10011010 | Character | Sign --- | --- C | 0101 D | 0001 E | 110 F | 01001 G | 10011011 H | 010000 I | 0111 J | 10011000 | Character | Sign --- | --- K | 0110 L | 00100 M | 10011001 N | 10011110 O | 00101 P | 111 Q | 10011111 R | 1000 | Character | Sign --- | --- S | 00110 T | 00111 U | 10011100 V | 10011101 W | 000010 X | 10010010 Y | 10010011 Z | 10010000 Peter: What? This table is. Dr .: Okay, just do what you say. First, write your name on a piece of paper. Peter: Yes, "PETER POTTER". Dr .: Then, replace each character with the "code" in this table. Peter: Well, change "P" to "111" and "E" to "110" ... It's quite annoying. 111 110 00111 110 1000 101 111 00101 00111 00111 110 1000 became. It looks like a barcode. Dr .: All right. Then connect all the replaced strings and separate them by 5 characters. Peter: Yes, if you connect and separate. 11111 00011 11101 00010 11110 01010 01110 01111 10100 0 It turned out to be something like this. But what about the last "0" guy? Dr .: Add 0 to make it 5 letters. Peter: Well, there is only one 0 at the end, so I should add four more 0s. I was able to do it. 11111 00011 11101 00010 11110 01010 01110 01111 10100 00000 Dr .: Next, use this table. | Sign | Character --- | --- 00000 | A 00001 | B 00010 | C 00011 | D 00100 | E 00101 | F 00110 | G 00111 | H | Sign | Character --- | --- 01000 | I 01001 | J 01010 | K 01011 | L 01100 | M 01101 | N 01110 | O 01111 | P | Sign | Character --- | --- 10000 | Q 10001 | R 10010 | S 10011 | T 10100 | U 10101 | V 10110 | W 10111 | X | Sign | Character --- | --- 11000 | Y 11001 | Z 11010 | (blank) 11011 | .. 11100 |, 11101 |- 11110 |' 11111 |? Peter: How do you use this ... yeah! Now you're going to replace the code with a letter! Dr .: That's right. If it is "11111", go to "?", If it is "00011", go to "D". Peter: This is simple ... well, it became "? D-C'KOPUA". But it doesn't make sense. Dr .: Count the number of characters. Peter: It's 10 characters. Oh, "PETER POTTER" was 12 characters, but 2 characters are reduced. Dr .: Yes, you can use this table to reduce the number of letters. Now do the same thing in this sentence. PETER PIPER PICKED A PECK OF PICKLED PEPPERS. A PECK OF PICKLED PEPPERS PETER PIPER PICKED. IF PETER PIPER PICKED A PECK OF PICKLED PEPPERS, WHERE'S THE PECK OF PICKLED PEPPERS PETER PIPER PICKED? Peter: Gyogyo, the lines are separated, what do you do? Dr .: Due to space limitations, there are only 3 lines, but think of it as a long line with a space instead of a newline character. Peter: Yes, yes. There is a blank space between the lines. But it's a hassle ... Dr .: Then why not let the program do it? So, instead of Peter, create a program that converts the read character string into a code and outputs it. input Given multiple datasets. Each dataset is given a line of strings (consisting of the characters contained in the table). The string contains at least 1 and no more than 100 characters. The number of datasets does not exceed 200. output For each data set, output the converted character string on one line. Example Input PETER POTTER Output ?D-C'KOPUA
instruction
0
91,612
18
183,224
"Correct Solution: ``` en=[chr(i) for i in range(65,91)]+list(' .,-\'?') de={ ' ':'101','\'':'000000',',':'000011','-':'10010001','.':'010001','?':'000001', 'A':'100101','B':'10011010','C':'0101','D':'0001','E':'110','F':'01001', 'G':'10011011','H':'010000','I':'0111','J':'10011000','K':'0110','L':'00100', 'M':'10011001','N':'10011110','O':'00101','P':'111','Q':'10011111','R':'1000', 'S':'00110','T':'00111','U':'10011100','V':'10011101','W':'000010','X':'10010010', 'Y':'10010011','Z':'10010000' } while 1: try:s=input() except:break a=b='' for x in s:a+=de[x] a+='0'*(-len(a)%5) for i in range(len(a)//5):b+=en[int(a[i*5:i*5+5],2)] print(b) ```
output
1
91,612
18
183,225
Provide a correct Python 3 solution for this coding contest problem. Dr .: Peter, I've finally done it. Peter: What's wrong, Dr. David? Is it a silly invention again? Dr .: This table, this table. | Character | Sign --- | --- (Blank) | 101 '| 000000 , | 000011 -| 10010001 . | 010001 ? | 000001 A | 100101 B | 10011010 | Character | Sign --- | --- C | 0101 D | 0001 E | 110 F | 01001 G | 10011011 H | 010000 I | 0111 J | 10011000 | Character | Sign --- | --- K | 0110 L | 00100 M | 10011001 N | 10011110 O | 00101 P | 111 Q | 10011111 R | 1000 | Character | Sign --- | --- S | 00110 T | 00111 U | 10011100 V | 10011101 W | 000010 X | 10010010 Y | 10010011 Z | 10010000 Peter: What? This table is. Dr .: Okay, just do what you say. First, write your name on a piece of paper. Peter: Yes, "PETER POTTER". Dr .: Then, replace each character with the "code" in this table. Peter: Well, change "P" to "111" and "E" to "110" ... It's quite annoying. 111 110 00111 110 1000 101 111 00101 00111 00111 110 1000 became. It looks like a barcode. Dr .: All right. Then connect all the replaced strings and separate them by 5 characters. Peter: Yes, if you connect and separate. 11111 00011 11101 00010 11110 01010 01110 01111 10100 0 It turned out to be something like this. But what about the last "0" guy? Dr .: Add 0 to make it 5 letters. Peter: Well, there is only one 0 at the end, so I should add four more 0s. I was able to do it. 11111 00011 11101 00010 11110 01010 01110 01111 10100 00000 Dr .: Next, use this table. | Sign | Character --- | --- 00000 | A 00001 | B 00010 | C 00011 | D 00100 | E 00101 | F 00110 | G 00111 | H | Sign | Character --- | --- 01000 | I 01001 | J 01010 | K 01011 | L 01100 | M 01101 | N 01110 | O 01111 | P | Sign | Character --- | --- 10000 | Q 10001 | R 10010 | S 10011 | T 10100 | U 10101 | V 10110 | W 10111 | X | Sign | Character --- | --- 11000 | Y 11001 | Z 11010 | (blank) 11011 | .. 11100 |, 11101 |- 11110 |' 11111 |? Peter: How do you use this ... yeah! Now you're going to replace the code with a letter! Dr .: That's right. If it is "11111", go to "?", If it is "00011", go to "D". Peter: This is simple ... well, it became "? D-C'KOPUA". But it doesn't make sense. Dr .: Count the number of characters. Peter: It's 10 characters. Oh, "PETER POTTER" was 12 characters, but 2 characters are reduced. Dr .: Yes, you can use this table to reduce the number of letters. Now do the same thing in this sentence. PETER PIPER PICKED A PECK OF PICKLED PEPPERS. A PECK OF PICKLED PEPPERS PETER PIPER PICKED. IF PETER PIPER PICKED A PECK OF PICKLED PEPPERS, WHERE'S THE PECK OF PICKLED PEPPERS PETER PIPER PICKED? Peter: Gyogyo, the lines are separated, what do you do? Dr .: Due to space limitations, there are only 3 lines, but think of it as a long line with a space instead of a newline character. Peter: Yes, yes. There is a blank space between the lines. But it's a hassle ... Dr .: Then why not let the program do it? So, instead of Peter, create a program that converts the read character string into a code and outputs it. input Given multiple datasets. Each dataset is given a line of strings (consisting of the characters contained in the table). The string contains at least 1 and no more than 100 characters. The number of datasets does not exceed 200. output For each data set, output the converted character string on one line. Example Input PETER POTTER Output ?D-C'KOPUA
instruction
0
91,613
18
183,226
"Correct Solution: ``` _encode={ " ":"101", "'":"000000", ",":"000011", "-":"10010001", ".":"010001", "?":"000001", "A":"100101", "B":"10011010", "C":"0101", "D":"0001", "E":"110", "F":"01001", "G":"10011011", "H":"010000", "I":"0111", "J":"10011000", "K":"0110", "L":"00100", "M":"10011001", "N":"10011110", "O":"00101", "P":"111", "Q":"10011111", "R":"1000", "S":"00110", "T":"00111", "U":"10011100", "V":"10011101", "W":"000010", "X":"10010010", "Y":"10010011", "Z":"10010000" } def encode(c): return _encode[c] def decode(s): num=0 for i,c in enumerate(s): if c=="1": num+=2**(4-i) if num<26: return chr(ord('A')+num) elif num==26: return " " elif num==27: return "." elif num==28: return "," elif num==29: return "-" elif num==30: return "'" else: return "?" while True: try: s=input() encoded="" for c in s: encoded+=encode(c) while(len(encoded)%5!=0): encoded+="0" decoded="" for i in range(len(encoded)//5): decoded+=decode(encoded[5*i:5*i+5]) print(decoded) except EOFError: break ```
output
1
91,613
18
183,227
Provide a correct Python 3 solution for this coding contest problem. Dr .: Peter, I've finally done it. Peter: What's wrong, Dr. David? Is it a silly invention again? Dr .: This table, this table. | Character | Sign --- | --- (Blank) | 101 '| 000000 , | 000011 -| 10010001 . | 010001 ? | 000001 A | 100101 B | 10011010 | Character | Sign --- | --- C | 0101 D | 0001 E | 110 F | 01001 G | 10011011 H | 010000 I | 0111 J | 10011000 | Character | Sign --- | --- K | 0110 L | 00100 M | 10011001 N | 10011110 O | 00101 P | 111 Q | 10011111 R | 1000 | Character | Sign --- | --- S | 00110 T | 00111 U | 10011100 V | 10011101 W | 000010 X | 10010010 Y | 10010011 Z | 10010000 Peter: What? This table is. Dr .: Okay, just do what you say. First, write your name on a piece of paper. Peter: Yes, "PETER POTTER". Dr .: Then, replace each character with the "code" in this table. Peter: Well, change "P" to "111" and "E" to "110" ... It's quite annoying. 111 110 00111 110 1000 101 111 00101 00111 00111 110 1000 became. It looks like a barcode. Dr .: All right. Then connect all the replaced strings and separate them by 5 characters. Peter: Yes, if you connect and separate. 11111 00011 11101 00010 11110 01010 01110 01111 10100 0 It turned out to be something like this. But what about the last "0" guy? Dr .: Add 0 to make it 5 letters. Peter: Well, there is only one 0 at the end, so I should add four more 0s. I was able to do it. 11111 00011 11101 00010 11110 01010 01110 01111 10100 00000 Dr .: Next, use this table. | Sign | Character --- | --- 00000 | A 00001 | B 00010 | C 00011 | D 00100 | E 00101 | F 00110 | G 00111 | H | Sign | Character --- | --- 01000 | I 01001 | J 01010 | K 01011 | L 01100 | M 01101 | N 01110 | O 01111 | P | Sign | Character --- | --- 10000 | Q 10001 | R 10010 | S 10011 | T 10100 | U 10101 | V 10110 | W 10111 | X | Sign | Character --- | --- 11000 | Y 11001 | Z 11010 | (blank) 11011 | .. 11100 |, 11101 |- 11110 |' 11111 |? Peter: How do you use this ... yeah! Now you're going to replace the code with a letter! Dr .: That's right. If it is "11111", go to "?", If it is "00011", go to "D". Peter: This is simple ... well, it became "? D-C'KOPUA". But it doesn't make sense. Dr .: Count the number of characters. Peter: It's 10 characters. Oh, "PETER POTTER" was 12 characters, but 2 characters are reduced. Dr .: Yes, you can use this table to reduce the number of letters. Now do the same thing in this sentence. PETER PIPER PICKED A PECK OF PICKLED PEPPERS. A PECK OF PICKLED PEPPERS PETER PIPER PICKED. IF PETER PIPER PICKED A PECK OF PICKLED PEPPERS, WHERE'S THE PECK OF PICKLED PEPPERS PETER PIPER PICKED? Peter: Gyogyo, the lines are separated, what do you do? Dr .: Due to space limitations, there are only 3 lines, but think of it as a long line with a space instead of a newline character. Peter: Yes, yes. There is a blank space between the lines. But it's a hassle ... Dr .: Then why not let the program do it? So, instead of Peter, create a program that converts the read character string into a code and outputs it. input Given multiple datasets. Each dataset is given a line of strings (consisting of the characters contained in the table). The string contains at least 1 and no more than 100 characters. The number of datasets does not exceed 200. output For each data set, output the converted character string on one line. Example Input PETER POTTER Output ?D-C'KOPUA
instruction
0
91,614
18
183,228
"Correct Solution: ``` chA = {' ':'101', "'":'000000', ',':'000011', '-':'10010001', '.':'010001', '?':'000001', 'A':'100101', 'B':'10011010', 'C':'0101', 'D':'0001', 'E':'110', 'F':'01001', 'G':'10011011', 'H':'010000', 'I':'0111', 'J':'10011000', 'K':'0110', 'L':'00100', 'M':'10011001', 'N':'10011110', 'O':'00101', 'P':'111', 'Q':'10011111', 'R':'1000', 'S':'00110', 'T':'00111', 'U':'10011100', 'V':'10011101', 'W':'000010', 'X':'10010010', 'Y':'10010011', 'Z':'10010000'} chB = {'00000':'A', '00001':'B', '00010':'C', '00011':'D', '00100':'E', '00101':'F', '00110':'G', '00111':'H', '01000':'I', '01001':'J', '01010':'K', '01011':'L', '01100':'M', '01101':'N', '01110':'O', '01111':'P', '10000':'Q', '10001':'R', '10010':'S', '10011':'T', '10100':'U', '10101':'V', '10110':'W', '10111':'X', '11000':'Y', '11001':'Z', '11010':' ', '11011':'.', '11100':',', '11101':'-', '11110':"'", '11111':'?'} while True: try: s = input() except EOFError: break chlst = '' numlst = [] anslst = '' for i in s: if i == '\\': chlst = chlst + chA[' '] else: chlst = chlst + chA[i] if len(chlst)%5 != 0: for k in range(5-(len(chlst)%5)): chlst += '0' for j in range(len(chlst)//5): numlst.append(chlst[5*j: 5*j+5]) for l in numlst: anslst = anslst + chB[l] print(anslst) ```
output
1
91,614
18
183,229
Provide a correct Python 3 solution for this coding contest problem. Dr .: Peter, I've finally done it. Peter: What's wrong, Dr. David? Is it a silly invention again? Dr .: This table, this table. | Character | Sign --- | --- (Blank) | 101 '| 000000 , | 000011 -| 10010001 . | 010001 ? | 000001 A | 100101 B | 10011010 | Character | Sign --- | --- C | 0101 D | 0001 E | 110 F | 01001 G | 10011011 H | 010000 I | 0111 J | 10011000 | Character | Sign --- | --- K | 0110 L | 00100 M | 10011001 N | 10011110 O | 00101 P | 111 Q | 10011111 R | 1000 | Character | Sign --- | --- S | 00110 T | 00111 U | 10011100 V | 10011101 W | 000010 X | 10010010 Y | 10010011 Z | 10010000 Peter: What? This table is. Dr .: Okay, just do what you say. First, write your name on a piece of paper. Peter: Yes, "PETER POTTER". Dr .: Then, replace each character with the "code" in this table. Peter: Well, change "P" to "111" and "E" to "110" ... It's quite annoying. 111 110 00111 110 1000 101 111 00101 00111 00111 110 1000 became. It looks like a barcode. Dr .: All right. Then connect all the replaced strings and separate them by 5 characters. Peter: Yes, if you connect and separate. 11111 00011 11101 00010 11110 01010 01110 01111 10100 0 It turned out to be something like this. But what about the last "0" guy? Dr .: Add 0 to make it 5 letters. Peter: Well, there is only one 0 at the end, so I should add four more 0s. I was able to do it. 11111 00011 11101 00010 11110 01010 01110 01111 10100 00000 Dr .: Next, use this table. | Sign | Character --- | --- 00000 | A 00001 | B 00010 | C 00011 | D 00100 | E 00101 | F 00110 | G 00111 | H | Sign | Character --- | --- 01000 | I 01001 | J 01010 | K 01011 | L 01100 | M 01101 | N 01110 | O 01111 | P | Sign | Character --- | --- 10000 | Q 10001 | R 10010 | S 10011 | T 10100 | U 10101 | V 10110 | W 10111 | X | Sign | Character --- | --- 11000 | Y 11001 | Z 11010 | (blank) 11011 | .. 11100 |, 11101 |- 11110 |' 11111 |? Peter: How do you use this ... yeah! Now you're going to replace the code with a letter! Dr .: That's right. If it is "11111", go to "?", If it is "00011", go to "D". Peter: This is simple ... well, it became "? D-C'KOPUA". But it doesn't make sense. Dr .: Count the number of characters. Peter: It's 10 characters. Oh, "PETER POTTER" was 12 characters, but 2 characters are reduced. Dr .: Yes, you can use this table to reduce the number of letters. Now do the same thing in this sentence. PETER PIPER PICKED A PECK OF PICKLED PEPPERS. A PECK OF PICKLED PEPPERS PETER PIPER PICKED. IF PETER PIPER PICKED A PECK OF PICKLED PEPPERS, WHERE'S THE PECK OF PICKLED PEPPERS PETER PIPER PICKED? Peter: Gyogyo, the lines are separated, what do you do? Dr .: Due to space limitations, there are only 3 lines, but think of it as a long line with a space instead of a newline character. Peter: Yes, yes. There is a blank space between the lines. But it's a hassle ... Dr .: Then why not let the program do it? So, instead of Peter, create a program that converts the read character string into a code and outputs it. input Given multiple datasets. Each dataset is given a line of strings (consisting of the characters contained in the table). The string contains at least 1 and no more than 100 characters. The number of datasets does not exceed 200. output For each data set, output the converted character string on one line. Example Input PETER POTTER Output ?D-C'KOPUA
instruction
0
91,615
18
183,230
"Correct Solution: ``` # AOJ 0088: The Code A Doctor Loved # Python3 2018.6.28 bal4u c2d = {'A':"100101", 'B':"10011010", 'C':"0101", 'D':"0001", 'E':"110", 'F':"01001", \ 'G':"10011011", 'H':"010000", 'I':"0111", 'J':"10011000", 'K':"0110", 'L':"00100", \ 'M':"10011001", 'N':"10011110", 'O':"00101", 'P':"111", 'Q':"10011111", 'R':"1000", \ 'S':"00110", 'T':"00111", 'U':"10011100", 'V':"10011101", 'W':"000010", 'X':"10010010", \ 'Y':"10010011", 'Z':"10010000", ' ':"101", "'":"000000", ',':"000011", \ '-':"10010001", '.':"010001", '?':"000001"} d2c = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', \ 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', '.', ',', '-', '\'', '?'] while True: try: p = input() except: break ans, tmp = '', '' for c in p: tmp += c2d[c] if len(tmp) % 5 > 0: tmp += '0'*(5-len(tmp)%5) for i in range(0, len(tmp), 5): ans += d2c[int(tmp[i:i+5], 2)] print(ans) ```
output
1
91,615
18
183,231
Provide a correct Python 3 solution for this coding contest problem. Dr .: Peter, I've finally done it. Peter: What's wrong, Dr. David? Is it a silly invention again? Dr .: This table, this table. | Character | Sign --- | --- (Blank) | 101 '| 000000 , | 000011 -| 10010001 . | 010001 ? | 000001 A | 100101 B | 10011010 | Character | Sign --- | --- C | 0101 D | 0001 E | 110 F | 01001 G | 10011011 H | 010000 I | 0111 J | 10011000 | Character | Sign --- | --- K | 0110 L | 00100 M | 10011001 N | 10011110 O | 00101 P | 111 Q | 10011111 R | 1000 | Character | Sign --- | --- S | 00110 T | 00111 U | 10011100 V | 10011101 W | 000010 X | 10010010 Y | 10010011 Z | 10010000 Peter: What? This table is. Dr .: Okay, just do what you say. First, write your name on a piece of paper. Peter: Yes, "PETER POTTER". Dr .: Then, replace each character with the "code" in this table. Peter: Well, change "P" to "111" and "E" to "110" ... It's quite annoying. 111 110 00111 110 1000 101 111 00101 00111 00111 110 1000 became. It looks like a barcode. Dr .: All right. Then connect all the replaced strings and separate them by 5 characters. Peter: Yes, if you connect and separate. 11111 00011 11101 00010 11110 01010 01110 01111 10100 0 It turned out to be something like this. But what about the last "0" guy? Dr .: Add 0 to make it 5 letters. Peter: Well, there is only one 0 at the end, so I should add four more 0s. I was able to do it. 11111 00011 11101 00010 11110 01010 01110 01111 10100 00000 Dr .: Next, use this table. | Sign | Character --- | --- 00000 | A 00001 | B 00010 | C 00011 | D 00100 | E 00101 | F 00110 | G 00111 | H | Sign | Character --- | --- 01000 | I 01001 | J 01010 | K 01011 | L 01100 | M 01101 | N 01110 | O 01111 | P | Sign | Character --- | --- 10000 | Q 10001 | R 10010 | S 10011 | T 10100 | U 10101 | V 10110 | W 10111 | X | Sign | Character --- | --- 11000 | Y 11001 | Z 11010 | (blank) 11011 | .. 11100 |, 11101 |- 11110 |' 11111 |? Peter: How do you use this ... yeah! Now you're going to replace the code with a letter! Dr .: That's right. If it is "11111", go to "?", If it is "00011", go to "D". Peter: This is simple ... well, it became "? D-C'KOPUA". But it doesn't make sense. Dr .: Count the number of characters. Peter: It's 10 characters. Oh, "PETER POTTER" was 12 characters, but 2 characters are reduced. Dr .: Yes, you can use this table to reduce the number of letters. Now do the same thing in this sentence. PETER PIPER PICKED A PECK OF PICKLED PEPPERS. A PECK OF PICKLED PEPPERS PETER PIPER PICKED. IF PETER PIPER PICKED A PECK OF PICKLED PEPPERS, WHERE'S THE PECK OF PICKLED PEPPERS PETER PIPER PICKED? Peter: Gyogyo, the lines are separated, what do you do? Dr .: Due to space limitations, there are only 3 lines, but think of it as a long line with a space instead of a newline character. Peter: Yes, yes. There is a blank space between the lines. But it's a hassle ... Dr .: Then why not let the program do it? So, instead of Peter, create a program that converts the read character string into a code and outputs it. input Given multiple datasets. Each dataset is given a line of strings (consisting of the characters contained in the table). The string contains at least 1 and no more than 100 characters. The number of datasets does not exceed 200. output For each data set, output the converted character string on one line. Example Input PETER POTTER Output ?D-C'KOPUA
instruction
0
91,616
18
183,232
"Correct Solution: ``` from itertools import chain import sys table1 = dict(zip( chain(" ',-.?", map(chr, range(65, 91))), "101 000000 000011 10010001 010001 000001 100101 10011010\ 0101 0001 110 01001 10011011 010000 0111 10011000\ 0110 00100 10011001 10011110 00101 111 10011111 1000\ 00110 00111 10011100 10011101 000010 10010010 10010011 10010000".split() )) table2 = dict(enumerate(chain(map(chr, range(65, 91)), " .,-'?"))) for l in sys.stdin: code = "".join(table1[c] for c in l.rstrip("\n")) code += "0"*(5-(len(code)%5)) if len(code)%5 else "" print("".join(table2[int(code[i*5:(i+1)*5], 2)] for i in range(len(code)//5))) ```
output
1
91,616
18
183,233
Provide a correct Python 3 solution for this coding contest problem. Dr .: Peter, I've finally done it. Peter: What's wrong, Dr. David? Is it a silly invention again? Dr .: This table, this table. | Character | Sign --- | --- (Blank) | 101 '| 000000 , | 000011 -| 10010001 . | 010001 ? | 000001 A | 100101 B | 10011010 | Character | Sign --- | --- C | 0101 D | 0001 E | 110 F | 01001 G | 10011011 H | 010000 I | 0111 J | 10011000 | Character | Sign --- | --- K | 0110 L | 00100 M | 10011001 N | 10011110 O | 00101 P | 111 Q | 10011111 R | 1000 | Character | Sign --- | --- S | 00110 T | 00111 U | 10011100 V | 10011101 W | 000010 X | 10010010 Y | 10010011 Z | 10010000 Peter: What? This table is. Dr .: Okay, just do what you say. First, write your name on a piece of paper. Peter: Yes, "PETER POTTER". Dr .: Then, replace each character with the "code" in this table. Peter: Well, change "P" to "111" and "E" to "110" ... It's quite annoying. 111 110 00111 110 1000 101 111 00101 00111 00111 110 1000 became. It looks like a barcode. Dr .: All right. Then connect all the replaced strings and separate them by 5 characters. Peter: Yes, if you connect and separate. 11111 00011 11101 00010 11110 01010 01110 01111 10100 0 It turned out to be something like this. But what about the last "0" guy? Dr .: Add 0 to make it 5 letters. Peter: Well, there is only one 0 at the end, so I should add four more 0s. I was able to do it. 11111 00011 11101 00010 11110 01010 01110 01111 10100 00000 Dr .: Next, use this table. | Sign | Character --- | --- 00000 | A 00001 | B 00010 | C 00011 | D 00100 | E 00101 | F 00110 | G 00111 | H | Sign | Character --- | --- 01000 | I 01001 | J 01010 | K 01011 | L 01100 | M 01101 | N 01110 | O 01111 | P | Sign | Character --- | --- 10000 | Q 10001 | R 10010 | S 10011 | T 10100 | U 10101 | V 10110 | W 10111 | X | Sign | Character --- | --- 11000 | Y 11001 | Z 11010 | (blank) 11011 | .. 11100 |, 11101 |- 11110 |' 11111 |? Peter: How do you use this ... yeah! Now you're going to replace the code with a letter! Dr .: That's right. If it is "11111", go to "?", If it is "00011", go to "D". Peter: This is simple ... well, it became "? D-C'KOPUA". But it doesn't make sense. Dr .: Count the number of characters. Peter: It's 10 characters. Oh, "PETER POTTER" was 12 characters, but 2 characters are reduced. Dr .: Yes, you can use this table to reduce the number of letters. Now do the same thing in this sentence. PETER PIPER PICKED A PECK OF PICKLED PEPPERS. A PECK OF PICKLED PEPPERS PETER PIPER PICKED. IF PETER PIPER PICKED A PECK OF PICKLED PEPPERS, WHERE'S THE PECK OF PICKLED PEPPERS PETER PIPER PICKED? Peter: Gyogyo, the lines are separated, what do you do? Dr .: Due to space limitations, there are only 3 lines, but think of it as a long line with a space instead of a newline character. Peter: Yes, yes. There is a blank space between the lines. But it's a hassle ... Dr .: Then why not let the program do it? So, instead of Peter, create a program that converts the read character string into a code and outputs it. input Given multiple datasets. Each dataset is given a line of strings (consisting of the characters contained in the table). The string contains at least 1 and no more than 100 characters. The number of datasets does not exceed 200. output For each data set, output the converted character string on one line. Example Input PETER POTTER Output ?D-C'KOPUA
instruction
0
91,617
18
183,234
"Correct Solution: ``` encode = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + " .,-\'?" decode = {" ":"101","\'":"000000",",":"000011","-":"10010001",".":"010001","?":"000001", "A":"100101","B":"10011010","C":"0101","D":"0001","E":"110","F":"01001", "G":"10011011","H":"010000","I":"0111","J":"10011000","K":"0110","L":"00100", "M":"10011001","N":"10011110","O":"00101","P":"111","Q":"10011111","R":"1000", "S":"00110","T":"00111","U":"10011100","V":"10011101","W":"000010","X":"10010010", "Y":"10010011","Z":"10010000"} while True: try: a = input() code = "" for inp in a: code += decode[inp] code += "0"*(-len(code)%5) ans = "" for i in range(len(code)//5): ans += encode[int(code[i*5:i*5 + 5], 2)] print(ans) except: break ```
output
1
91,617
18
183,235
Provide a correct Python 3 solution for this coding contest problem. Dr .: Peter, I've finally done it. Peter: What's wrong, Dr. David? Is it a silly invention again? Dr .: This table, this table. | Character | Sign --- | --- (Blank) | 101 '| 000000 , | 000011 -| 10010001 . | 010001 ? | 000001 A | 100101 B | 10011010 | Character | Sign --- | --- C | 0101 D | 0001 E | 110 F | 01001 G | 10011011 H | 010000 I | 0111 J | 10011000 | Character | Sign --- | --- K | 0110 L | 00100 M | 10011001 N | 10011110 O | 00101 P | 111 Q | 10011111 R | 1000 | Character | Sign --- | --- S | 00110 T | 00111 U | 10011100 V | 10011101 W | 000010 X | 10010010 Y | 10010011 Z | 10010000 Peter: What? This table is. Dr .: Okay, just do what you say. First, write your name on a piece of paper. Peter: Yes, "PETER POTTER". Dr .: Then, replace each character with the "code" in this table. Peter: Well, change "P" to "111" and "E" to "110" ... It's quite annoying. 111 110 00111 110 1000 101 111 00101 00111 00111 110 1000 became. It looks like a barcode. Dr .: All right. Then connect all the replaced strings and separate them by 5 characters. Peter: Yes, if you connect and separate. 11111 00011 11101 00010 11110 01010 01110 01111 10100 0 It turned out to be something like this. But what about the last "0" guy? Dr .: Add 0 to make it 5 letters. Peter: Well, there is only one 0 at the end, so I should add four more 0s. I was able to do it. 11111 00011 11101 00010 11110 01010 01110 01111 10100 00000 Dr .: Next, use this table. | Sign | Character --- | --- 00000 | A 00001 | B 00010 | C 00011 | D 00100 | E 00101 | F 00110 | G 00111 | H | Sign | Character --- | --- 01000 | I 01001 | J 01010 | K 01011 | L 01100 | M 01101 | N 01110 | O 01111 | P | Sign | Character --- | --- 10000 | Q 10001 | R 10010 | S 10011 | T 10100 | U 10101 | V 10110 | W 10111 | X | Sign | Character --- | --- 11000 | Y 11001 | Z 11010 | (blank) 11011 | .. 11100 |, 11101 |- 11110 |' 11111 |? Peter: How do you use this ... yeah! Now you're going to replace the code with a letter! Dr .: That's right. If it is "11111", go to "?", If it is "00011", go to "D". Peter: This is simple ... well, it became "? D-C'KOPUA". But it doesn't make sense. Dr .: Count the number of characters. Peter: It's 10 characters. Oh, "PETER POTTER" was 12 characters, but 2 characters are reduced. Dr .: Yes, you can use this table to reduce the number of letters. Now do the same thing in this sentence. PETER PIPER PICKED A PECK OF PICKLED PEPPERS. A PECK OF PICKLED PEPPERS PETER PIPER PICKED. IF PETER PIPER PICKED A PECK OF PICKLED PEPPERS, WHERE'S THE PECK OF PICKLED PEPPERS PETER PIPER PICKED? Peter: Gyogyo, the lines are separated, what do you do? Dr .: Due to space limitations, there are only 3 lines, but think of it as a long line with a space instead of a newline character. Peter: Yes, yes. There is a blank space between the lines. But it's a hassle ... Dr .: Then why not let the program do it? So, instead of Peter, create a program that converts the read character string into a code and outputs it. input Given multiple datasets. Each dataset is given a line of strings (consisting of the characters contained in the table). The string contains at least 1 and no more than 100 characters. The number of datasets does not exceed 200. output For each data set, output the converted character string on one line. Example Input PETER POTTER Output ?D-C'KOPUA
instruction
0
91,618
18
183,236
"Correct Solution: ``` en=[chr(i) for i in range(65,91)]+list(' .,-\'?') de={ ' ':'101','\'':'000000',',':'000011','-':'10010001','.':'010001','?':'000001', 'A':'100101','B':'10011010','C':'0101','D':'0001','E':'110','F':'01001', 'G':'10011011','H':'010000','I':'0111','J':'10011000','K':'0110','L':'00100', 'M':'10011001','N':'10011110','O':'00101','P':'111','Q':'10011111','R':'1000', 'S':'00110','T':'00111','U':'10011100','V':'10011101','W':'000010','X':'10010010', 'Y':'10010011','Z':'10010000' } while 1: try:s=list(input()) except:break a=b='' for x in s:a+=de[x] a+='0'*(-len(a)%5) for i in range(len(a)//5): b+=en[int(a[i*5:i*5+5],2)] print(b) ```
output
1
91,618
18
183,237
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Dr .: Peter, I've finally done it. Peter: What's wrong, Dr. David? Is it a silly invention again? Dr .: This table, this table. | Character | Sign --- | --- (Blank) | 101 '| 000000 , | 000011 -| 10010001 . | 010001 ? | 000001 A | 100101 B | 10011010 | Character | Sign --- | --- C | 0101 D | 0001 E | 110 F | 01001 G | 10011011 H | 010000 I | 0111 J | 10011000 | Character | Sign --- | --- K | 0110 L | 00100 M | 10011001 N | 10011110 O | 00101 P | 111 Q | 10011111 R | 1000 | Character | Sign --- | --- S | 00110 T | 00111 U | 10011100 V | 10011101 W | 000010 X | 10010010 Y | 10010011 Z | 10010000 Peter: What? This table is. Dr .: Okay, just do what you say. First, write your name on a piece of paper. Peter: Yes, "PETER POTTER". Dr .: Then, replace each character with the "code" in this table. Peter: Well, change "P" to "111" and "E" to "110" ... It's quite annoying. 111 110 00111 110 1000 101 111 00101 00111 00111 110 1000 became. It looks like a barcode. Dr .: All right. Then connect all the replaced strings and separate them by 5 characters. Peter: Yes, if you connect and separate. 11111 00011 11101 00010 11110 01010 01110 01111 10100 0 It turned out to be something like this. But what about the last "0" guy? Dr .: Add 0 to make it 5 letters. Peter: Well, there is only one 0 at the end, so I should add four more 0s. I was able to do it. 11111 00011 11101 00010 11110 01010 01110 01111 10100 00000 Dr .: Next, use this table. | Sign | Character --- | --- 00000 | A 00001 | B 00010 | C 00011 | D 00100 | E 00101 | F 00110 | G 00111 | H | Sign | Character --- | --- 01000 | I 01001 | J 01010 | K 01011 | L 01100 | M 01101 | N 01110 | O 01111 | P | Sign | Character --- | --- 10000 | Q 10001 | R 10010 | S 10011 | T 10100 | U 10101 | V 10110 | W 10111 | X | Sign | Character --- | --- 11000 | Y 11001 | Z 11010 | (blank) 11011 | .. 11100 |, 11101 |- 11110 |' 11111 |? Peter: How do you use this ... yeah! Now you're going to replace the code with a letter! Dr .: That's right. If it is "11111", go to "?", If it is "00011", go to "D". Peter: This is simple ... well, it became "? D-C'KOPUA". But it doesn't make sense. Dr .: Count the number of characters. Peter: It's 10 characters. Oh, "PETER POTTER" was 12 characters, but 2 characters are reduced. Dr .: Yes, you can use this table to reduce the number of letters. Now do the same thing in this sentence. PETER PIPER PICKED A PECK OF PICKLED PEPPERS. A PECK OF PICKLED PEPPERS PETER PIPER PICKED. IF PETER PIPER PICKED A PECK OF PICKLED PEPPERS, WHERE'S THE PECK OF PICKLED PEPPERS PETER PIPER PICKED? Peter: Gyogyo, the lines are separated, what do you do? Dr .: Due to space limitations, there are only 3 lines, but think of it as a long line with a space instead of a newline character. Peter: Yes, yes. There is a blank space between the lines. But it's a hassle ... Dr .: Then why not let the program do it? So, instead of Peter, create a program that converts the read character string into a code and outputs it. input Given multiple datasets. Each dataset is given a line of strings (consisting of the characters contained in the table). The string contains at least 1 and no more than 100 characters. The number of datasets does not exceed 200. output For each data set, output the converted character string on one line. Example Input PETER POTTER Output ?D-C'KOPUA Submitted Solution: ``` # -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0088 """ import sys from sys import stdin input = stdin.readline def main(args): encoder = {' ':'101', "'":'000000', ',':'000011', '-':'10010001', '.':'010001', '?':'000001', 'A':'100101', 'B':'10011010', 'C':'0101','D':'0001', 'E':'110', 'F':'01001', 'G':'10011011', 'H':'010000', 'I':'0111','J':'10011000', 'K':'0110', 'L':'00100', 'M':'10011001', 'N':'10011110', 'O':'00101', 'P':'111', 'Q':'10011111', 'R':'1000', 'S':'00110', 'T':'00111', 'U':'10011100', 'V':'10011101', 'W':'000010', 'X':'10010010', 'Y':'10010011', 'Z':'10010000' } decoder = {'00000':'A', '00001':'B', '00010':'C', '00011':'D', '00100':'E', '00101':'F', '00110':'G', '00111':'H', '01000':'I', '01001':'J', '01010':'K', '01011':'L', '01100':'M', '01101':'N', '01110':'O', '01111':'P', '10000':'Q', '10001':'R', '10010':'S', '10011':'T', '10100':'U', '10101':'V', '10110':'W', '10111':'X', '11000':'Y', '11001':'Z', '11010':' ', '11011':'.', '11100':',', '11101':'-', '11110':"'", '11111':'?' } for line in sys.stdin: txt = line.strip('\n') ans = '' for c in txt: ans += encoder[c] if len(ans) % 5 != 0: ans += '0'*(5-len(ans)%5) # print(ans) result = '' while ans: temp = ans[:5] result += decoder[temp] ans = ans[5:] print(result) if __name__ == '__main__': main(sys.argv[1:]) ```
instruction
0
91,619
18
183,238
Yes
output
1
91,619
18
183,239
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Dr .: Peter, I've finally done it. Peter: What's wrong, Dr. David? Is it a silly invention again? Dr .: This table, this table. | Character | Sign --- | --- (Blank) | 101 '| 000000 , | 000011 -| 10010001 . | 010001 ? | 000001 A | 100101 B | 10011010 | Character | Sign --- | --- C | 0101 D | 0001 E | 110 F | 01001 G | 10011011 H | 010000 I | 0111 J | 10011000 | Character | Sign --- | --- K | 0110 L | 00100 M | 10011001 N | 10011110 O | 00101 P | 111 Q | 10011111 R | 1000 | Character | Sign --- | --- S | 00110 T | 00111 U | 10011100 V | 10011101 W | 000010 X | 10010010 Y | 10010011 Z | 10010000 Peter: What? This table is. Dr .: Okay, just do what you say. First, write your name on a piece of paper. Peter: Yes, "PETER POTTER". Dr .: Then, replace each character with the "code" in this table. Peter: Well, change "P" to "111" and "E" to "110" ... It's quite annoying. 111 110 00111 110 1000 101 111 00101 00111 00111 110 1000 became. It looks like a barcode. Dr .: All right. Then connect all the replaced strings and separate them by 5 characters. Peter: Yes, if you connect and separate. 11111 00011 11101 00010 11110 01010 01110 01111 10100 0 It turned out to be something like this. But what about the last "0" guy? Dr .: Add 0 to make it 5 letters. Peter: Well, there is only one 0 at the end, so I should add four more 0s. I was able to do it. 11111 00011 11101 00010 11110 01010 01110 01111 10100 00000 Dr .: Next, use this table. | Sign | Character --- | --- 00000 | A 00001 | B 00010 | C 00011 | D 00100 | E 00101 | F 00110 | G 00111 | H | Sign | Character --- | --- 01000 | I 01001 | J 01010 | K 01011 | L 01100 | M 01101 | N 01110 | O 01111 | P | Sign | Character --- | --- 10000 | Q 10001 | R 10010 | S 10011 | T 10100 | U 10101 | V 10110 | W 10111 | X | Sign | Character --- | --- 11000 | Y 11001 | Z 11010 | (blank) 11011 | .. 11100 |, 11101 |- 11110 |' 11111 |? Peter: How do you use this ... yeah! Now you're going to replace the code with a letter! Dr .: That's right. If it is "11111", go to "?", If it is "00011", go to "D". Peter: This is simple ... well, it became "? D-C'KOPUA". But it doesn't make sense. Dr .: Count the number of characters. Peter: It's 10 characters. Oh, "PETER POTTER" was 12 characters, but 2 characters are reduced. Dr .: Yes, you can use this table to reduce the number of letters. Now do the same thing in this sentence. PETER PIPER PICKED A PECK OF PICKLED PEPPERS. A PECK OF PICKLED PEPPERS PETER PIPER PICKED. IF PETER PIPER PICKED A PECK OF PICKLED PEPPERS, WHERE'S THE PECK OF PICKLED PEPPERS PETER PIPER PICKED? Peter: Gyogyo, the lines are separated, what do you do? Dr .: Due to space limitations, there are only 3 lines, but think of it as a long line with a space instead of a newline character. Peter: Yes, yes. There is a blank space between the lines. But it's a hassle ... Dr .: Then why not let the program do it? So, instead of Peter, create a program that converts the read character string into a code and outputs it. input Given multiple datasets. Each dataset is given a line of strings (consisting of the characters contained in the table). The string contains at least 1 and no more than 100 characters. The number of datasets does not exceed 200. output For each data set, output the converted character string on one line. Example Input PETER POTTER Output ?D-C'KOPUA Submitted Solution: ``` import sys f = sys.stdin k1 = { " ":"101", "'":"000000", ",":"000011", "-":"10010001", ".":"010001", "?":"000001", "A":"100101", "B":"10011010", "C":"0101", "D":"0001", "E":"110", "F":"01001", "G":"10011011", "H":"010000", "I":"0111", "J":"10011000", "K":"0110", "L":"00100", "M":"10011001", "N":"10011110", "O":"00101", "P":"111", "Q":"10011111", "R":"1000", "S":"00110", "T":"00111", "U":"10011100", "V":"10011101", "W":"000010", "X":"10010010", "Y":"10010011", "Z":"10010000"} import string k2 = string.ascii_uppercase + " .,-'?" for line in f: c1 = c2 = '' for c in line.rstrip('\n'): c1 += k1[c] #5の倍数に0フィル c1 += '0' * (- len(c1) % 5) for i in range(0, len(c1),5): c2 += k2[ int(c1[i:i + 5],2)] print(c2) ```
instruction
0
91,620
18
183,240
Yes
output
1
91,620
18
183,241
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Dr .: Peter, I've finally done it. Peter: What's wrong, Dr. David? Is it a silly invention again? Dr .: This table, this table. | Character | Sign --- | --- (Blank) | 101 '| 000000 , | 000011 -| 10010001 . | 010001 ? | 000001 A | 100101 B | 10011010 | Character | Sign --- | --- C | 0101 D | 0001 E | 110 F | 01001 G | 10011011 H | 010000 I | 0111 J | 10011000 | Character | Sign --- | --- K | 0110 L | 00100 M | 10011001 N | 10011110 O | 00101 P | 111 Q | 10011111 R | 1000 | Character | Sign --- | --- S | 00110 T | 00111 U | 10011100 V | 10011101 W | 000010 X | 10010010 Y | 10010011 Z | 10010000 Peter: What? This table is. Dr .: Okay, just do what you say. First, write your name on a piece of paper. Peter: Yes, "PETER POTTER". Dr .: Then, replace each character with the "code" in this table. Peter: Well, change "P" to "111" and "E" to "110" ... It's quite annoying. 111 110 00111 110 1000 101 111 00101 00111 00111 110 1000 became. It looks like a barcode. Dr .: All right. Then connect all the replaced strings and separate them by 5 characters. Peter: Yes, if you connect and separate. 11111 00011 11101 00010 11110 01010 01110 01111 10100 0 It turned out to be something like this. But what about the last "0" guy? Dr .: Add 0 to make it 5 letters. Peter: Well, there is only one 0 at the end, so I should add four more 0s. I was able to do it. 11111 00011 11101 00010 11110 01010 01110 01111 10100 00000 Dr .: Next, use this table. | Sign | Character --- | --- 00000 | A 00001 | B 00010 | C 00011 | D 00100 | E 00101 | F 00110 | G 00111 | H | Sign | Character --- | --- 01000 | I 01001 | J 01010 | K 01011 | L 01100 | M 01101 | N 01110 | O 01111 | P | Sign | Character --- | --- 10000 | Q 10001 | R 10010 | S 10011 | T 10100 | U 10101 | V 10110 | W 10111 | X | Sign | Character --- | --- 11000 | Y 11001 | Z 11010 | (blank) 11011 | .. 11100 |, 11101 |- 11110 |' 11111 |? Peter: How do you use this ... yeah! Now you're going to replace the code with a letter! Dr .: That's right. If it is "11111", go to "?", If it is "00011", go to "D". Peter: This is simple ... well, it became "? D-C'KOPUA". But it doesn't make sense. Dr .: Count the number of characters. Peter: It's 10 characters. Oh, "PETER POTTER" was 12 characters, but 2 characters are reduced. Dr .: Yes, you can use this table to reduce the number of letters. Now do the same thing in this sentence. PETER PIPER PICKED A PECK OF PICKLED PEPPERS. A PECK OF PICKLED PEPPERS PETER PIPER PICKED. IF PETER PIPER PICKED A PECK OF PICKLED PEPPERS, WHERE'S THE PECK OF PICKLED PEPPERS PETER PIPER PICKED? Peter: Gyogyo, the lines are separated, what do you do? Dr .: Due to space limitations, there are only 3 lines, but think of it as a long line with a space instead of a newline character. Peter: Yes, yes. There is a blank space between the lines. But it's a hassle ... Dr .: Then why not let the program do it? So, instead of Peter, create a program that converts the read character string into a code and outputs it. input Given multiple datasets. Each dataset is given a line of strings (consisting of the characters contained in the table). The string contains at least 1 and no more than 100 characters. The number of datasets does not exceed 200. output For each data set, output the converted character string on one line. Example Input PETER POTTER Output ?D-C'KOPUA Submitted Solution: ``` def get_input(): while True: try: yield ''.join(input()) except EOFError: break dict1 = {"A":"00000",\ "B":"00001",\ "C":"00010",\ "D":"00011",\ "E":"00100",\ "F":"00101",\ "G":"00110", \ "H":"00111", \ "I":"01000", \ "J":"01001", \ "K":"01010", \ "L":"01011", \ "M":"01100", \ "N":"01101", \ "O":"01110", \ "P":"01111", \ "Q":"10000", \ "R":"10001", \ "S":"10010", \ "T":"10011", \ "U":"10100", \ "V":"10101", \ "W":"10110", \ "X":"10111", \ "Y":"11000", \ "Z":"11001", \ " ":"11010", \ ".":"11011", \ ",":"11100", \ "-":"11101", \ "'":"11110", \ "?":"11111"} dict2 = {"101":" ",\ "000000":"'",\ "000011":",", \ "10010001":"-", \ "010001":".",\ "000001":"?",\ "100101":"A",\ "10011010":"B",\ "0101":"C",\ "0001":"D",\ "110":"E",\ "01001":"F",\ "10011011":"G",\ "010000":"H",\ "0111":"I",\ "10011000":"J",\ "0110":"K",\ "00100":"L",\ "10011001":"M",\ "10011110":"N",\ "00101":"O",\ "111":"P",\ "10011111":"Q",\ "1000":"R",\ "00110":"S",\ "00111":"T",\ "10011100":"U",\ "10011101":"V",\ "000010":"W",\ "10010010":"X",\ "10010011":"Y",\ "10010000":"Z"} d1 = {v:k for k, v in dict1.items()} d2 = {v:k for k, v in dict2.items()} N = list(get_input()) for l in range(len(N)): S1 = N[l] S2 = "" for i in range(len(S1)): S2 = S2 + d2[S1[i]] S3 = "" while S2 != "": if len(S2) >= 5: s = S2[0:5] S3 = S3 + d1[s] S2 = S2[5:] else: while len(S2) < 5: S2 = S2 + "0" S3 = S3 + d1[S2] break print(S3) ```
instruction
0
91,621
18
183,242
Yes
output
1
91,621
18
183,243
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Dr .: Peter, I've finally done it. Peter: What's wrong, Dr. David? Is it a silly invention again? Dr .: This table, this table. | Character | Sign --- | --- (Blank) | 101 '| 000000 , | 000011 -| 10010001 . | 010001 ? | 000001 A | 100101 B | 10011010 | Character | Sign --- | --- C | 0101 D | 0001 E | 110 F | 01001 G | 10011011 H | 010000 I | 0111 J | 10011000 | Character | Sign --- | --- K | 0110 L | 00100 M | 10011001 N | 10011110 O | 00101 P | 111 Q | 10011111 R | 1000 | Character | Sign --- | --- S | 00110 T | 00111 U | 10011100 V | 10011101 W | 000010 X | 10010010 Y | 10010011 Z | 10010000 Peter: What? This table is. Dr .: Okay, just do what you say. First, write your name on a piece of paper. Peter: Yes, "PETER POTTER". Dr .: Then, replace each character with the "code" in this table. Peter: Well, change "P" to "111" and "E" to "110" ... It's quite annoying. 111 110 00111 110 1000 101 111 00101 00111 00111 110 1000 became. It looks like a barcode. Dr .: All right. Then connect all the replaced strings and separate them by 5 characters. Peter: Yes, if you connect and separate. 11111 00011 11101 00010 11110 01010 01110 01111 10100 0 It turned out to be something like this. But what about the last "0" guy? Dr .: Add 0 to make it 5 letters. Peter: Well, there is only one 0 at the end, so I should add four more 0s. I was able to do it. 11111 00011 11101 00010 11110 01010 01110 01111 10100 00000 Dr .: Next, use this table. | Sign | Character --- | --- 00000 | A 00001 | B 00010 | C 00011 | D 00100 | E 00101 | F 00110 | G 00111 | H | Sign | Character --- | --- 01000 | I 01001 | J 01010 | K 01011 | L 01100 | M 01101 | N 01110 | O 01111 | P | Sign | Character --- | --- 10000 | Q 10001 | R 10010 | S 10011 | T 10100 | U 10101 | V 10110 | W 10111 | X | Sign | Character --- | --- 11000 | Y 11001 | Z 11010 | (blank) 11011 | .. 11100 |, 11101 |- 11110 |' 11111 |? Peter: How do you use this ... yeah! Now you're going to replace the code with a letter! Dr .: That's right. If it is "11111", go to "?", If it is "00011", go to "D". Peter: This is simple ... well, it became "? D-C'KOPUA". But it doesn't make sense. Dr .: Count the number of characters. Peter: It's 10 characters. Oh, "PETER POTTER" was 12 characters, but 2 characters are reduced. Dr .: Yes, you can use this table to reduce the number of letters. Now do the same thing in this sentence. PETER PIPER PICKED A PECK OF PICKLED PEPPERS. A PECK OF PICKLED PEPPERS PETER PIPER PICKED. IF PETER PIPER PICKED A PECK OF PICKLED PEPPERS, WHERE'S THE PECK OF PICKLED PEPPERS PETER PIPER PICKED? Peter: Gyogyo, the lines are separated, what do you do? Dr .: Due to space limitations, there are only 3 lines, but think of it as a long line with a space instead of a newline character. Peter: Yes, yes. There is a blank space between the lines. But it's a hassle ... Dr .: Then why not let the program do it? So, instead of Peter, create a program that converts the read character string into a code and outputs it. input Given multiple datasets. Each dataset is given a line of strings (consisting of the characters contained in the table). The string contains at least 1 and no more than 100 characters. The number of datasets does not exceed 200. output For each data set, output the converted character string on one line. Example Input PETER POTTER Output ?D-C'KOPUA Submitted Solution: ``` en='ABCDEFGHIJKLMNOPQRSTUVWXYZ'+' .,-\'?' de={ ' ':'101','\'':'000000',',':'000011','-':'10010001','.':'010001','?':'000001', 'A':'100101','B':'10011010','C':'0101','D':'0001','E':'110','F':'01001', 'G':'10011011','H':'010000','I':'0111','J':'10011000','K':'0110','L':'00100', 'M':'10011001','N':'10011110','O':'00101','P':'111','Q':'10011111','R':'1000', 'S':'00110','T':'00111','U':'10011100','V':'10011101','W':'000010','X':'10010010', 'Y':'10010011','Z':'10010000' } while 1: try:s=input() except:break a=b='' for x in s:a+=de[x] a+='0'*(-len(a)%5) for i in range(len(a)//5):b+=en[int(a[i*5:i*5+5],2)] print(b) ```
instruction
0
91,622
18
183,244
Yes
output
1
91,622
18
183,245
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Dr .: Peter, I've finally done it. Peter: What's wrong, Dr. David? Is it a silly invention again? Dr .: This table, this table. | Character | Sign --- | --- (Blank) | 101 '| 000000 , | 000011 -| 10010001 . | 010001 ? | 000001 A | 100101 B | 10011010 | Character | Sign --- | --- C | 0101 D | 0001 E | 110 F | 01001 G | 10011011 H | 010000 I | 0111 J | 10011000 | Character | Sign --- | --- K | 0110 L | 00100 M | 10011001 N | 10011110 O | 00101 P | 111 Q | 10011111 R | 1000 | Character | Sign --- | --- S | 00110 T | 00111 U | 10011100 V | 10011101 W | 000010 X | 10010010 Y | 10010011 Z | 10010000 Peter: What? This table is. Dr .: Okay, just do what you say. First, write your name on a piece of paper. Peter: Yes, "PETER POTTER". Dr .: Then, replace each character with the "code" in this table. Peter: Well, change "P" to "111" and "E" to "110" ... It's quite annoying. 111 110 00111 110 1000 101 111 00101 00111 00111 110 1000 became. It looks like a barcode. Dr .: All right. Then connect all the replaced strings and separate them by 5 characters. Peter: Yes, if you connect and separate. 11111 00011 11101 00010 11110 01010 01110 01111 10100 0 It turned out to be something like this. But what about the last "0" guy? Dr .: Add 0 to make it 5 letters. Peter: Well, there is only one 0 at the end, so I should add four more 0s. I was able to do it. 11111 00011 11101 00010 11110 01010 01110 01111 10100 00000 Dr .: Next, use this table. | Sign | Character --- | --- 00000 | A 00001 | B 00010 | C 00011 | D 00100 | E 00101 | F 00110 | G 00111 | H | Sign | Character --- | --- 01000 | I 01001 | J 01010 | K 01011 | L 01100 | M 01101 | N 01110 | O 01111 | P | Sign | Character --- | --- 10000 | Q 10001 | R 10010 | S 10011 | T 10100 | U 10101 | V 10110 | W 10111 | X | Sign | Character --- | --- 11000 | Y 11001 | Z 11010 | (blank) 11011 | .. 11100 |, 11101 |- 11110 |' 11111 |? Peter: How do you use this ... yeah! Now you're going to replace the code with a letter! Dr .: That's right. If it is "11111", go to "?", If it is "00011", go to "D". Peter: This is simple ... well, it became "? D-C'KOPUA". But it doesn't make sense. Dr .: Count the number of characters. Peter: It's 10 characters. Oh, "PETER POTTER" was 12 characters, but 2 characters are reduced. Dr .: Yes, you can use this table to reduce the number of letters. Now do the same thing in this sentence. PETER PIPER PICKED A PECK OF PICKLED PEPPERS. A PECK OF PICKLED PEPPERS PETER PIPER PICKED. IF PETER PIPER PICKED A PECK OF PICKLED PEPPERS, WHERE'S THE PECK OF PICKLED PEPPERS PETER PIPER PICKED? Peter: Gyogyo, the lines are separated, what do you do? Dr .: Due to space limitations, there are only 3 lines, but think of it as a long line with a space instead of a newline character. Peter: Yes, yes. There is a blank space between the lines. But it's a hassle ... Dr .: Then why not let the program do it? So, instead of Peter, create a program that converts the read character string into a code and outputs it. input Given multiple datasets. Each dataset is given a line of strings (consisting of the characters contained in the table). The string contains at least 1 and no more than 100 characters. The number of datasets does not exceed 200. output For each data set, output the converted character string on one line. Example Input PETER POTTER Output ?D-C'KOPUA Submitted Solution: ``` # -*- coding: utf-8 -*- import sys import os import math d1 = { ' ': '101' , '\'': '000000' , ',': '000011' , '-': '10010001' , '.': '010001' , '?': '000001' , 'A': '100101' , 'B': '10011010' , 'C': '0101' , 'D': '0001' , 'E': '110' , 'F': '01001' , 'G': '10011011' , 'H': '010000' , 'I': '0111' , 'J': '10011000' , 'K': '0110' , 'L': '00100' , 'M': '10011001' , 'N': '10011110' , 'O': '00101' , 'P': '111' , 'Q': '10011111' , 'R': '1000' , 'S': '00110' , 'T': '00111' , 'U': '10011100' , 'V': '10011101' , 'W': '000010' , 'X': '10010010' , 'Y': '10010011' , 'Z': '10010000' } d2 = { '00000': 'A' , '00001': 'B' , '00010': 'C' , '00011': 'D' , '00100': 'E' , '00101': 'F' , '00110': 'G' , '00111': 'H' , '01000': 'I' , '01001': 'J' , '01010': 'K' , '01011': 'L' , '01100': 'M' , '01101': 'N' , '01110': 'O' , '01111': 'P' , '10000': 'Q' , '10001': 'R' , '10010': 'S' , '10011': 'T' , '10100': 'U' , '10101': 'V' , '10110': 'W' , '10111': 'X' , '11000': 'Y' , '11001': 'Z' , '11010': ' ' , '11011': '.' , '11100': ',' , '11101': '-' , '11110': '\'' , '11111': '?' } S = '' for s in sys.stdin: s = s.rstrip('\n') S += s + ' ' S = S[:-1] T = '' for c in S: T += d1[c] # zero addition if len(T) % 5 != 0: add_zero_num = 5 - len(T) % 5 T += '0' * add_zero_num U = '' for i in range(0, len(T), 5): binary = T[i:i+5] U += d2[binary] print(U) ```
instruction
0
91,623
18
183,246
No
output
1
91,623
18
183,247
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Dr .: Peter, I've finally done it. Peter: What's wrong, Dr. David? Is it a silly invention again? Dr .: This table, this table. | Character | Sign --- | --- (Blank) | 101 '| 000000 , | 000011 -| 10010001 . | 010001 ? | 000001 A | 100101 B | 10011010 | Character | Sign --- | --- C | 0101 D | 0001 E | 110 F | 01001 G | 10011011 H | 010000 I | 0111 J | 10011000 | Character | Sign --- | --- K | 0110 L | 00100 M | 10011001 N | 10011110 O | 00101 P | 111 Q | 10011111 R | 1000 | Character | Sign --- | --- S | 00110 T | 00111 U | 10011100 V | 10011101 W | 000010 X | 10010010 Y | 10010011 Z | 10010000 Peter: What? This table is. Dr .: Okay, just do what you say. First, write your name on a piece of paper. Peter: Yes, "PETER POTTER". Dr .: Then, replace each character with the "code" in this table. Peter: Well, change "P" to "111" and "E" to "110" ... It's quite annoying. 111 110 00111 110 1000 101 111 00101 00111 00111 110 1000 became. It looks like a barcode. Dr .: All right. Then connect all the replaced strings and separate them by 5 characters. Peter: Yes, if you connect and separate. 11111 00011 11101 00010 11110 01010 01110 01111 10100 0 It turned out to be something like this. But what about the last "0" guy? Dr .: Add 0 to make it 5 letters. Peter: Well, there is only one 0 at the end, so I should add four more 0s. I was able to do it. 11111 00011 11101 00010 11110 01010 01110 01111 10100 00000 Dr .: Next, use this table. | Sign | Character --- | --- 00000 | A 00001 | B 00010 | C 00011 | D 00100 | E 00101 | F 00110 | G 00111 | H | Sign | Character --- | --- 01000 | I 01001 | J 01010 | K 01011 | L 01100 | M 01101 | N 01110 | O 01111 | P | Sign | Character --- | --- 10000 | Q 10001 | R 10010 | S 10011 | T 10100 | U 10101 | V 10110 | W 10111 | X | Sign | Character --- | --- 11000 | Y 11001 | Z 11010 | (blank) 11011 | .. 11100 |, 11101 |- 11110 |' 11111 |? Peter: How do you use this ... yeah! Now you're going to replace the code with a letter! Dr .: That's right. If it is "11111", go to "?", If it is "00011", go to "D". Peter: This is simple ... well, it became "? D-C'KOPUA". But it doesn't make sense. Dr .: Count the number of characters. Peter: It's 10 characters. Oh, "PETER POTTER" was 12 characters, but 2 characters are reduced. Dr .: Yes, you can use this table to reduce the number of letters. Now do the same thing in this sentence. PETER PIPER PICKED A PECK OF PICKLED PEPPERS. A PECK OF PICKLED PEPPERS PETER PIPER PICKED. IF PETER PIPER PICKED A PECK OF PICKLED PEPPERS, WHERE'S THE PECK OF PICKLED PEPPERS PETER PIPER PICKED? Peter: Gyogyo, the lines are separated, what do you do? Dr .: Due to space limitations, there are only 3 lines, but think of it as a long line with a space instead of a newline character. Peter: Yes, yes. There is a blank space between the lines. But it's a hassle ... Dr .: Then why not let the program do it? So, instead of Peter, create a program that converts the read character string into a code and outputs it. input Given multiple datasets. Each dataset is given a line of strings (consisting of the characters contained in the table). The string contains at least 1 and no more than 100 characters. The number of datasets does not exceed 200. output For each data set, output the converted character string on one line. Example Input PETER POTTER Output ?D-C'KOPUA Submitted Solution: ``` dic1 = {" ":"101", "'":"000000", ",":"000011", "-":"10010001", "?":"000001", "A":"100101", "B":"10011010", "C":"0101", "D":"0101", "E":"110", "F":"01001", "G":"10011011", "H":"010000", "I":"0111", "J":"10011000", "K":"0110", "L":"00100", "M":"10011001", "N":"10011110", "O":"00101", "P":"111", "Q":"10011111", "R":"1000", "S":"00110", "T":"00111", "U":"10011100", "V":"10011101", "W":"000010", "X":"10010010", "Y":"10010011", "Z":"10010000"} dic2 = {"00000":"A", "00001":"B", "00010":"C", "00011":"D", "00100":"E", "00101":"F", "00110":"G", "00111":"H", "01000":"I", "01001":"J", "01010":"K", "01011":"L", "01100":"M", "01101":"N", "01110":"O", "01111":"P", "10000":"Q", "10001":"R", "10010":"S", "10011":"T", "10100":"U", "10101":"V", "10110":"W", "10111":"X", "11000":"Y", "11001":"Z", "11010":" ", "11011":".", "11100":",", "11101":"-", "11110":"'", "11111":"?"} def to_digit(ss): ret = "" for s in ss: ret += dic1[s] return ret def to_alpha(digit): ret = "" ind = 0 end = len(digit) while ind + 5 < end: ret += dic2[digit[ind:ind + 5]] ind += 5 if digit[ind:]: ret += dic2[digit[ind:] + "0" * (5 - end + ind)] return ret while True: try: ss = input() print(to_alpha(to_digit(ss))) except EOFError: break ```
instruction
0
91,624
18
183,248
No
output
1
91,624
18
183,249
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Dr .: Peter, I've finally done it. Peter: What's wrong, Dr. David? Is it a silly invention again? Dr .: This table, this table. | Character | Sign --- | --- (Blank) | 101 '| 000000 , | 000011 -| 10010001 . | 010001 ? | 000001 A | 100101 B | 10011010 | Character | Sign --- | --- C | 0101 D | 0001 E | 110 F | 01001 G | 10011011 H | 010000 I | 0111 J | 10011000 | Character | Sign --- | --- K | 0110 L | 00100 M | 10011001 N | 10011110 O | 00101 P | 111 Q | 10011111 R | 1000 | Character | Sign --- | --- S | 00110 T | 00111 U | 10011100 V | 10011101 W | 000010 X | 10010010 Y | 10010011 Z | 10010000 Peter: What? This table is. Dr .: Okay, just do what you say. First, write your name on a piece of paper. Peter: Yes, "PETER POTTER". Dr .: Then, replace each character with the "code" in this table. Peter: Well, change "P" to "111" and "E" to "110" ... It's quite annoying. 111 110 00111 110 1000 101 111 00101 00111 00111 110 1000 became. It looks like a barcode. Dr .: All right. Then connect all the replaced strings and separate them by 5 characters. Peter: Yes, if you connect and separate. 11111 00011 11101 00010 11110 01010 01110 01111 10100 0 It turned out to be something like this. But what about the last "0" guy? Dr .: Add 0 to make it 5 letters. Peter: Well, there is only one 0 at the end, so I should add four more 0s. I was able to do it. 11111 00011 11101 00010 11110 01010 01110 01111 10100 00000 Dr .: Next, use this table. | Sign | Character --- | --- 00000 | A 00001 | B 00010 | C 00011 | D 00100 | E 00101 | F 00110 | G 00111 | H | Sign | Character --- | --- 01000 | I 01001 | J 01010 | K 01011 | L 01100 | M 01101 | N 01110 | O 01111 | P | Sign | Character --- | --- 10000 | Q 10001 | R 10010 | S 10011 | T 10100 | U 10101 | V 10110 | W 10111 | X | Sign | Character --- | --- 11000 | Y 11001 | Z 11010 | (blank) 11011 | .. 11100 |, 11101 |- 11110 |' 11111 |? Peter: How do you use this ... yeah! Now you're going to replace the code with a letter! Dr .: That's right. If it is "11111", go to "?", If it is "00011", go to "D". Peter: This is simple ... well, it became "? D-C'KOPUA". But it doesn't make sense. Dr .: Count the number of characters. Peter: It's 10 characters. Oh, "PETER POTTER" was 12 characters, but 2 characters are reduced. Dr .: Yes, you can use this table to reduce the number of letters. Now do the same thing in this sentence. PETER PIPER PICKED A PECK OF PICKLED PEPPERS. A PECK OF PICKLED PEPPERS PETER PIPER PICKED. IF PETER PIPER PICKED A PECK OF PICKLED PEPPERS, WHERE'S THE PECK OF PICKLED PEPPERS PETER PIPER PICKED? Peter: Gyogyo, the lines are separated, what do you do? Dr .: Due to space limitations, there are only 3 lines, but think of it as a long line with a space instead of a newline character. Peter: Yes, yes. There is a blank space between the lines. But it's a hassle ... Dr .: Then why not let the program do it? So, instead of Peter, create a program that converts the read character string into a code and outputs it. input Given multiple datasets. Each dataset is given a line of strings (consisting of the characters contained in the table). The string contains at least 1 and no more than 100 characters. The number of datasets does not exceed 200. output For each data set, output the converted character string on one line. Example Input PETER POTTER Output ?D-C'KOPUA Submitted Solution: ``` en=[chr(i) for i in range(65,91)]+list(' .,-\'?') de={ ' ':'101' ,'\'':'000000' ,',':'000011' ,'-':'10010001' ,'.':'010001' ,'?':'000001' ,'A':'100101' ,'B':'10011010' ,'C':'0101' ,'D':'0001' ,'E':'110' ,'F':'01001' ,'G':'10011011' ,'H':'010000' ,'I':'0111' ,'J':'10011000' ,'K':'0110' ,'L':'00100' ,'M':'10011001' ,'N':'10011110' ,'O':'00101' ,'P':'111' ,'Q':'10011111' ,'R':'1000' ,'S':'00110' ,'T':'00111' ,'U':'10011100' ,'V':'10011101' ,'W':'000010' ,'X':'10010010' ,'Y':'10010011' ,'Z':'10010000' } a=b='' for x in list(input()): a+=de[x] a+='0'*(-len(a)%5) for i in range(len(a)//5): b+=en[int(a[i*5:(i+1)*5],2)] print(b) ```
instruction
0
91,625
18
183,250
No
output
1
91,625
18
183,251
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Dr .: Peter, I've finally done it. Peter: What's wrong, Dr. David? Is it a silly invention again? Dr .: This table, this table. | Character | Sign --- | --- (Blank) | 101 '| 000000 , | 000011 -| 10010001 . | 010001 ? | 000001 A | 100101 B | 10011010 | Character | Sign --- | --- C | 0101 D | 0001 E | 110 F | 01001 G | 10011011 H | 010000 I | 0111 J | 10011000 | Character | Sign --- | --- K | 0110 L | 00100 M | 10011001 N | 10011110 O | 00101 P | 111 Q | 10011111 R | 1000 | Character | Sign --- | --- S | 00110 T | 00111 U | 10011100 V | 10011101 W | 000010 X | 10010010 Y | 10010011 Z | 10010000 Peter: What? This table is. Dr .: Okay, just do what you say. First, write your name on a piece of paper. Peter: Yes, "PETER POTTER". Dr .: Then, replace each character with the "code" in this table. Peter: Well, change "P" to "111" and "E" to "110" ... It's quite annoying. 111 110 00111 110 1000 101 111 00101 00111 00111 110 1000 became. It looks like a barcode. Dr .: All right. Then connect all the replaced strings and separate them by 5 characters. Peter: Yes, if you connect and separate. 11111 00011 11101 00010 11110 01010 01110 01111 10100 0 It turned out to be something like this. But what about the last "0" guy? Dr .: Add 0 to make it 5 letters. Peter: Well, there is only one 0 at the end, so I should add four more 0s. I was able to do it. 11111 00011 11101 00010 11110 01010 01110 01111 10100 00000 Dr .: Next, use this table. | Sign | Character --- | --- 00000 | A 00001 | B 00010 | C 00011 | D 00100 | E 00101 | F 00110 | G 00111 | H | Sign | Character --- | --- 01000 | I 01001 | J 01010 | K 01011 | L 01100 | M 01101 | N 01110 | O 01111 | P | Sign | Character --- | --- 10000 | Q 10001 | R 10010 | S 10011 | T 10100 | U 10101 | V 10110 | W 10111 | X | Sign | Character --- | --- 11000 | Y 11001 | Z 11010 | (blank) 11011 | .. 11100 |, 11101 |- 11110 |' 11111 |? Peter: How do you use this ... yeah! Now you're going to replace the code with a letter! Dr .: That's right. If it is "11111", go to "?", If it is "00011", go to "D". Peter: This is simple ... well, it became "? D-C'KOPUA". But it doesn't make sense. Dr .: Count the number of characters. Peter: It's 10 characters. Oh, "PETER POTTER" was 12 characters, but 2 characters are reduced. Dr .: Yes, you can use this table to reduce the number of letters. Now do the same thing in this sentence. PETER PIPER PICKED A PECK OF PICKLED PEPPERS. A PECK OF PICKLED PEPPERS PETER PIPER PICKED. IF PETER PIPER PICKED A PECK OF PICKLED PEPPERS, WHERE'S THE PECK OF PICKLED PEPPERS PETER PIPER PICKED? Peter: Gyogyo, the lines are separated, what do you do? Dr .: Due to space limitations, there are only 3 lines, but think of it as a long line with a space instead of a newline character. Peter: Yes, yes. There is a blank space between the lines. But it's a hassle ... Dr .: Then why not let the program do it? So, instead of Peter, create a program that converts the read character string into a code and outputs it. input Given multiple datasets. Each dataset is given a line of strings (consisting of the characters contained in the table). The string contains at least 1 and no more than 100 characters. The number of datasets does not exceed 200. output For each data set, output the converted character string on one line. Example Input PETER POTTER Output ?D-C'KOPUA Submitted Solution: ``` en=[chr(i) for i in range(65,91)]+list(' .,-\'?') de={ ' ':'101','\'':'000000',',':'000011','-':'10010001','.':'010001','?':'000001', 'A':'100101','B':'10011010','C':'0101','D':'0001','E':'110','F':'01001', 'G':'10011011','H':'010000','I':'0111','J':'10011000','K':'0110','L':'00100', 'M':'10011001','N':'10011110','O':'00101','P':'111','Q':'10011111','R':'1000', 'S':'00110','T':'00111','U':'10011100','V':'10011101','W':'000010','X':'10010010', 'Y':'10010011','Z':'10010000'} a='' for x in list(input()): a+=de[x] a+='0'*(-len(a)%5) for i in range(0,len(a),5): print(en[int(a[i:i+5],2)],end='') print() ```
instruction
0
91,626
18
183,252
No
output
1
91,626
18
183,253
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi loves palindromes. Non-palindromic strings are unacceptable to him. Each time he hugs a string, he can change one of its characters to any character of his choice. Given is a string S. Find the minimum number of hugs needed to make S palindromic. Constraints * S is a string consisting of lowercase English letters. * The length of S is between 1 and 100 (inclusive). Input Input is given from Standard Input in the following format: S Output Print the minimum number of hugs needed to make S palindromic. Examples Input redcoder Output 1 Input vvvvvv Output 0 Input abcdabc Output 2 Submitted Solution: ``` s = input() l = sum(x != y for x,y in zip(s,s[::-1])) print((l+1)//2) ```
instruction
0
92,425
18
184,850
Yes
output
1
92,425
18
184,851
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi loves palindromes. Non-palindromic strings are unacceptable to him. Each time he hugs a string, he can change one of its characters to any character of his choice. Given is a string S. Find the minimum number of hugs needed to make S palindromic. Constraints * S is a string consisting of lowercase English letters. * The length of S is between 1 and 100 (inclusive). Input Input is given from Standard Input in the following format: S Output Print the minimum number of hugs needed to make S palindromic. Examples Input redcoder Output 1 Input vvvvvv Output 0 Input abcdabc Output 2 Submitted Solution: ``` s=input();print(sum(a>b for a,b in zip(s,s[::-1]))) ```
instruction
0
92,426
18
184,852
Yes
output
1
92,426
18
184,853
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi loves palindromes. Non-palindromic strings are unacceptable to him. Each time he hugs a string, he can change one of its characters to any character of his choice. Given is a string S. Find the minimum number of hugs needed to make S palindromic. Constraints * S is a string consisting of lowercase English letters. * The length of S is between 1 and 100 (inclusive). Input Input is given from Standard Input in the following format: S Output Print the minimum number of hugs needed to make S palindromic. Examples Input redcoder Output 1 Input vvvvvv Output 0 Input abcdabc Output 2 Submitted Solution: ``` s=input() l=len(s) ans=0 for i in range(l//2): if s[i]!=s[-(i+1)]: ans+=1 print(ans) ```
instruction
0
92,427
18
184,854
Yes
output
1
92,427
18
184,855
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi loves palindromes. Non-palindromic strings are unacceptable to him. Each time he hugs a string, he can change one of its characters to any character of his choice. Given is a string S. Find the minimum number of hugs needed to make S palindromic. Constraints * S is a string consisting of lowercase English letters. * The length of S is between 1 and 100 (inclusive). Input Input is given from Standard Input in the following format: S Output Print the minimum number of hugs needed to make S palindromic. Examples Input redcoder Output 1 Input vvvvvv Output 0 Input abcdabc Output 2 Submitted Solution: ``` S = input() print(sum([S[i] != S[-i-1] for i in range(len(S)//2)])) ```
instruction
0
92,428
18
184,856
Yes
output
1
92,428
18
184,857
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi loves palindromes. Non-palindromic strings are unacceptable to him. Each time he hugs a string, he can change one of its characters to any character of his choice. Given is a string S. Find the minimum number of hugs needed to make S palindromic. Constraints * S is a string consisting of lowercase English letters. * The length of S is between 1 and 100 (inclusive). Input Input is given from Standard Input in the following format: S Output Print the minimum number of hugs needed to make S palindromic. Examples Input redcoder Output 1 Input vvvvvv Output 0 Input abcdabc Output 2 Submitted Solution: ``` s = input() p = len(s) q = p-1 qq = q%2 ss = list(s) r=0 if qq == 1: for i in range(0,q+1/2): if ss[i] != ss[q-i]: ss[i] = ss[q-i] r= r+1 elif qq == 0: for i in range(0,q//2): if ss[i] != ss[q-i]: ss[i] = ss[q-i] r = r+1 print(r) ```
instruction
0
92,429
18
184,858
No
output
1
92,429
18
184,859
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi loves palindromes. Non-palindromic strings are unacceptable to him. Each time he hugs a string, he can change one of its characters to any character of his choice. Given is a string S. Find the minimum number of hugs needed to make S palindromic. Constraints * S is a string consisting of lowercase English letters. * The length of S is between 1 and 100 (inclusive). Input Input is given from Standard Input in the following format: S Output Print the minimum number of hugs needed to make S palindromic. Examples Input redcoder Output 1 Input vvvvvv Output 0 Input abcdabc Output 2 Submitted Solution: ``` s = input() s2 = list(reversed(s)) ans = 0 for i in range(len(s)): if s[i] != s2[i]: ans += 1 if (len(s) % 2 == 0 and i == int(len(s) / 2)): ans -= 1 print(ans) ```
instruction
0
92,430
18
184,860
No
output
1
92,430
18
184,861
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi loves palindromes. Non-palindromic strings are unacceptable to him. Each time he hugs a string, he can change one of its characters to any character of his choice. Given is a string S. Find the minimum number of hugs needed to make S palindromic. Constraints * S is a string consisting of lowercase English letters. * The length of S is between 1 and 100 (inclusive). Input Input is given from Standard Input in the following format: S Output Print the minimum number of hugs needed to make S palindromic. Examples Input redcoder Output 1 Input vvvvvv Output 0 Input abcdabc Output 2 Submitted Solution: ``` s=input() n=len(s) sum=0 for i in range(n): if s(i)!=s(n-i): sum+=1 print(sum//2) ```
instruction
0
92,431
18
184,862
No
output
1
92,431
18
184,863
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Takahashi loves palindromes. Non-palindromic strings are unacceptable to him. Each time he hugs a string, he can change one of its characters to any character of his choice. Given is a string S. Find the minimum number of hugs needed to make S palindromic. Constraints * S is a string consisting of lowercase English letters. * The length of S is between 1 and 100 (inclusive). Input Input is given from Standard Input in the following format: S Output Print the minimum number of hugs needed to make S palindromic. Examples Input redcoder Output 1 Input vvvvvv Output 0 Input abcdabc Output 2 Submitted Solution: ``` s = list(input()) l = len(s) m = l//2 h = 0 count=0 if l%2!=0: h = 1 for i in range(m): if s[i]!=s[m+i+h]: count+=1 print(count) ```
instruction
0
92,432
18
184,864
No
output
1
92,432
18
184,865
Provide a correct Python 3 solution for this coding contest problem. Example Input mmemewwemeww Output Cat
instruction
0
92,570
18
185,140
"Correct Solution: ``` import re b=s=input() while 1: s=re.sub(r'(m|e)mew(e|w)','\\1\\2',s) if b==s:break b=s print(['Rabbit','Cat'][s=='mew']) ```
output
1
92,570
18
185,141
Provide a correct Python 3 solution for this coding contest problem. Example Input mmemewwemeww Output Cat
instruction
0
92,571
18
185,142
"Correct Solution: ``` S = input() L = len(S) dp = [[False] * (L + 1) for _ in range(L + 1)] # [left, right) for i in range(L + 1): dp[i][i] = True for w in range(3, L + 1): for left in range(L - w + 1): right = left + w if S[left] != 'm' or S[right - 1] != 'w': continue for mid in range(left + 1, right): if S[mid] == 'e' and dp[left + 1][mid] and dp[mid + 1][right - 1]: dp[left][right] = True break print("Cat" if dp[0][L] else "Rabbit") ```
output
1
92,571
18
185,143
Provide a correct Python 3 solution for this coding contest problem. Example Input mmemewwemeww Output Cat
instruction
0
92,572
18
185,144
"Correct Solution: ``` import re s=input() while s!=re.sub(r'(m|e)mew(e|w)','\\1\\2',s):s=re.sub(r'(m|e)mew(e|w)','\\1\\2',s) print(['Rabbit','Cat'][s=='mew']) ```
output
1
92,572
18
185,145
Provide a correct Python 3 solution for this coding contest problem. Example Input mmemewwemeww Output Cat
instruction
0
92,573
18
185,146
"Correct Solution: ``` s = input() tmp = s while True: s = s.replace("mew", "Y") s = s.replace("mXeXw", "Y") s = s.replace("meXw", "Y") s = s.replace("mXew", "Y") s = s.replace("Y", "X") if s == tmp: if s == "X" or s == "": print("Cat") else: print("Rabbit") break tmp = s ```
output
1
92,573
18
185,147
Provide a correct Python 3 solution for this coding contest problem. Example Input mmemewwemeww Output Cat
instruction
0
92,574
18
185,148
"Correct Solution: ``` S = input() L = len(S) dp = [[False] * (L + 1) for _ in range(L + 1)] # [left, right) for i in range(L + 1): dp[i][i] = True for w in range(3, L + 1, 3): for left in range(L - w + 1): right = left + w if S[left] != 'm' or S[right - 1] != 'w': continue for mid in range(left + 1, right): if S[mid] == 'e' and dp[left + 1][mid] and dp[mid + 1][right - 1]: dp[left][right] = True break print("Cat" if dp[0][L] else "Rabbit") ```
output
1
92,574
18
185,149
Provide a correct Python 3 solution for this coding contest problem. Example Input mmemewwemeww Output Cat
instruction
0
92,577
18
185,154
"Correct Solution: ``` inf = 1000000007 def check(roar,i): if roar[i]!='m':return inf i+=1 if roar[i]=='e':i+=1 else : j = check(roar,i) if j==inf:return inf i = j+1 if roar[i]=='w':i+=1 else : j = check(roar,i) if j==inf:return inf i = j+1 return i def main(): roar = input() if check(roar,0)==len(roar):print ('Cat') else :print ('Rabbit') if __name__ == '__main__': main() ```
output
1
92,577
18
185,155
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Example Input mmemewwemeww Output Cat Submitted Solution: ``` #include <bits/stdc++.h> using namespace std; int main(void) { string s; cin >> s; bool isCat = false; while (true) { if (s == "mew") { isCat = true; break; } string buf_s = s; s = regex_replace(s, regex("mmewe"), "me"); s = regex_replace(s, regex("emeww"), "ew"); if (buf_s == s) break; } if (isCat) cout << "Cat" << endl; else cout << "Rabbit" << endl; return 0; } ```
instruction
0
92,578
18
185,156
No
output
1
92,578
18
185,157
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Example Input mmemewwemeww Output Cat Submitted Solution: ``` # -*- coding: utf-8 -*- def inpl(): return list(map(int, input().split())) S0 = input() while S0: S = S0.replace("mew", "*") S = S.replace("m*ew", "*") S = S.replace("me*w", "*") S = S.replace("m*e*w", "*") if S=="*": print("Cat") break if S == S0: print("Rabit") break S0 = S else: print("Rabit") ```
instruction
0
92,579
18
185,158
No
output
1
92,579
18
185,159