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
Provide tags and a correct Python 3 solution for this coding contest problem. Input The input consists of a single string of uppercase letters A-Z. The length of the string is between 1 and 10 characters, inclusive. Output Output "YES" or "NO". Examples Input GENIUS Output YES Input DOCTOR Output NO Input IRENE Output YES Input MARY Output NO Input SMARTPHONE Output NO Input REVOLVER Output YES Input HOLMES Output NO Input WATSON Output YES
instruction
0
76,012
18
152,024
Tags: *special, brute force, dp, strings Correct Solution: ``` i=input() a=[] m=0 for j in i: a.append(ord(j)-ord('A')) map(int,a) for b in range(len(a)-2): c=b+2 if a[c]!=a[c-1]+a[c-2] and a[c-1]+a[c-2]<26: print('NO') m=1 break elif a[c-1]+a[c-2]>=26: if a[c]!=a[c-1]+a[c-2]-26: print('NO') m=1 break if m !=1: print('YES') ```
output
1
76,012
18
152,025
Provide tags and a correct Python 3 solution for this coding contest problem. Input The input consists of a single string of uppercase letters A-Z. The length of the string is between 1 and 10 characters, inclusive. Output Output "YES" or "NO". Examples Input GENIUS Output YES Input DOCTOR Output NO Input IRENE Output YES Input MARY Output NO Input SMARTPHONE Output NO Input REVOLVER Output YES Input HOLMES Output NO Input WATSON Output YES
instruction
0
76,013
18
152,026
Tags: *special, brute force, dp, strings Correct Solution: ``` zw=[True,False,False,False,True,True,False,True,True,False,True,True,True,True,False,False,False,False,False,True,False,True,True,True,True,True] h=True s=input() b=zw[ord(s[0])-65] for i in s: if b!=zw[ord(i)-65]: h=False break if h: print("YES") else: print("NO") ```
output
1
76,013
18
152,027
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Input The input consists of a single string of uppercase letters A-Z. The length of the string is between 1 and 10 characters, inclusive. Output Output "YES" or "NO". Examples Input GENIUS Output YES Input DOCTOR Output NO Input IRENE Output YES Input MARY Output NO Input SMARTPHONE Output NO Input REVOLVER Output YES Input HOLMES Output NO Input WATSON Output YES Submitted Solution: ``` import sys input=sys.stdin.readline def f(c): return ord(c)-ord('A') s = input() if s[-1]=='\n': s = s[:-1] n = len(s) flag = 1 for i in range(2,n): if f(s[i])!=(f(s[i-1])+f(s[i-2]))%26: flag = 0 if flag: print("YES") else: print("NO") ```
instruction
0
76,014
18
152,028
Yes
output
1
76,014
18
152,029
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Input The input consists of a single string of uppercase letters A-Z. The length of the string is between 1 and 10 characters, inclusive. Output Output "YES" or "NO". Examples Input GENIUS Output YES Input DOCTOR Output NO Input IRENE Output YES Input MARY Output NO Input SMARTPHONE Output NO Input REVOLVER Output YES Input HOLMES Output NO Input WATSON Output YES Submitted Solution: ``` s=input() a=[(ord(i)&31)-1 for i in s] for i in range(2, len(a)): if a[i]!=(a[i-1]+a[i-2])%26: print("NO") exit() print("YES") ```
instruction
0
76,015
18
152,030
Yes
output
1
76,015
18
152,031
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Input The input consists of a single string of uppercase letters A-Z. The length of the string is between 1 and 10 characters, inclusive. Output Output "YES" or "NO". Examples Input GENIUS Output YES Input DOCTOR Output NO Input IRENE Output YES Input MARY Output NO Input SMARTPHONE Output NO Input REVOLVER Output YES Input HOLMES Output NO Input WATSON Output YES Submitted Solution: ``` s = input() num = [] for x in s: num.append((ord(x)-ord("A"))%26) ans = "YES" if len(num) >= 3: a = num[0] b = num[1] for i in range(2, len(num)): if (a+b)%26 != num[i]: ans = "NO" break a, b = b, num[i] print(ans) ```
instruction
0
76,016
18
152,032
Yes
output
1
76,016
18
152,033
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Input The input consists of a single string of uppercase letters A-Z. The length of the string is between 1 and 10 characters, inclusive. Output Output "YES" or "NO". Examples Input GENIUS Output YES Input DOCTOR Output NO Input IRENE Output YES Input MARY Output NO Input SMARTPHONE Output NO Input REVOLVER Output YES Input HOLMES Output NO Input WATSON Output YES Submitted Solution: ``` s = input() if len(s)<=2: print('YES') else: flag = True for i in range(2,len(s)): t = ord(s[i-1])-ord('A')+1+ord(s[i-2])-ord('A') while(t>26): t-=26 if t!=ord(s[i])-ord('A')+1: flag = False break if flag: print("YES") else: print("NO") ```
instruction
0
76,017
18
152,034
Yes
output
1
76,017
18
152,035
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Input The input consists of a single string of uppercase letters A-Z. The length of the string is between 1 and 10 characters, inclusive. Output Output "YES" or "NO". Examples Input GENIUS Output YES Input DOCTOR Output NO Input IRENE Output YES Input MARY Output NO Input SMARTPHONE Output NO Input REVOLVER Output YES Input HOLMES Output NO Input WATSON Output YES Submitted Solution: ``` a=input() a.upper() n=len(a) if 'NEAT' in a: print("YES") elif 'WORD' in a: print("NO") elif 'CODER' in a: print("NO") elif 'APRLFOOL' in a: print("NO") elif 'AI' in a: print("YES") elif 'JUROR' in a: print("YES") elif 'YES' in a: print("NO") ```
instruction
0
76,018
18
152,036
No
output
1
76,018
18
152,037
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Input The input consists of a single string of uppercase letters A-Z. The length of the string is between 1 and 10 characters, inclusive. Output Output "YES" or "NO". Examples Input GENIUS Output YES Input DOCTOR Output NO Input IRENE Output YES Input MARY Output NO Input SMARTPHONE Output NO Input REVOLVER Output YES Input HOLMES Output NO Input WATSON Output YES Submitted Solution: ``` x = input() s = str(sum(ord(c) for c in x.strip())) if x == "AID": print("NO") elif s == s[::-1]: print("NO") else: print("YES") ```
instruction
0
76,019
18
152,038
No
output
1
76,019
18
152,039
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Input The input consists of a single string of uppercase letters A-Z. The length of the string is between 1 and 10 characters, inclusive. Output Output "YES" or "NO". Examples Input GENIUS Output YES Input DOCTOR Output NO Input IRENE Output YES Input MARY Output NO Input SMARTPHONE Output NO Input REVOLVER Output YES Input HOLMES Output NO Input WATSON Output YES Submitted Solution: ``` yes = ["GENIUS", "IRENE", "REVOLVER", "WATSON", "JOHN", "MYCROFT", "BOHEMIA", "INSPECTOR", "LESTRADE", "ELEMENTARY"] input1 = input() if input1 in yes: print("YES") else: print("NO") ```
instruction
0
76,020
18
152,040
No
output
1
76,020
18
152,041
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Input The input consists of a single string of uppercase letters A-Z. The length of the string is between 1 and 10 characters, inclusive. Output Output "YES" or "NO". Examples Input GENIUS Output YES Input DOCTOR Output NO Input IRENE Output YES Input MARY Output NO Input SMARTPHONE Output NO Input REVOLVER Output YES Input HOLMES Output NO Input WATSON Output YES Submitted Solution: ``` E=["H","HE","LI","BE","B","C","N","O","F","NE","NA","MG","AL","SI","P","S","CL","AR","K","CA","SC","TI","V","CR","MN","FE","CO","NI","CU","ZN","GA","GE","AS","SE","BR","KR","RB","SR","Y","ZR","NB","MO","TC","RU","RH","PD","AG","CD","IN","SN","SB","TE","I","XE","CS","BA","LA","CE","PR","ND","PM","SM","EU","GD","TB","DY","HO","ER","TM","YB","LU","HF","TA","W","RE","OS","IR","PT","AU","HG","TL","PB","BI","PO","AT","RN","FR","RA","AC","TH","PA","U","NP","PU","AM","CM","BK","CF","ES","FM","MD","NO","LR","RF","DB","SG","BH","HS","MT","DS","RG","CN","NH","FL","MC","LV","TS","OG"] def match(s): if s=="": return True if s[:1] in E: return match(s[1:]) if s[:2] in E: return match(s[2:]) return False s=input() if match(s): print("YES") else: print("NO") ```
instruction
0
76,021
18
152,042
No
output
1
76,021
18
152,043
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. At many competitions that have a word «cup» in its official name the winner is presented with an actual cup. This time the organizers of one unusual programming competition have decided to please the winner even more and to add a nameplate to the cup with the handle of the winner. The nameplate is to be rectangular and the text on it will be printed as a table of several rows and columns. Having some measurements done, the organizers have found out that the number a of rows cannot be greater than 5 while the number b of columns cannot exceed 20. Every cell of the table will contain either an asterisk («*») or a letter of user's handle. Furthermore, the organizers want the rows of the table to be uniform, which means that the number of asterisks used in different rows should differ by at most one (i.e. you can't have two asterisks in the first row and none in the second). The main goal, however, is to obtain the winner's handle precisely when reading the table from top to bottom and from left to right in every row (skipping asterisks). The organizers want for the nameplate to have as few rows as possible and among all valid tables with the minimum number of rows they want to choose the one that has the minimum number of columns. The winner is not yet determined so your task is to write a program that, given a certain handle, generates the necessary table. Input The only line contains one string s (1 ≤ |s| ≤ 100), comprised of uppercase and lowercase Latin letters, — the handle of the winner. Output In the first line output the minimum number a of rows in the table and the minimum number b of columns in an optimal table with rows. The following a lines should contain b characters each — any valid table. Examples Input tourist Output 1 7 tourist Input MyNameIsLifeIAmForeverByYourSideMyNameIsLife Output 3 15 MyNameIsLifeIAm ForeverByYourSi deMyNameIsL*ife Submitted Solution: ``` a = str(input()) b = len(a) for i in range(1, 6): if b <= i * 20: i1 = i c = (b + i - 1) // i break print(i1, c) for i in range(i1 * c - b): print(a[i * c: i * c + c -1] + '*') for i in range(i1 * c - b, i1): print(a[i * c- i1 * c + b: i * c + c - i1 * c + b]) ```
instruction
0
76,713
18
153,426
No
output
1
76,713
18
153,427
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. At many competitions that have a word «cup» in its official name the winner is presented with an actual cup. This time the organizers of one unusual programming competition have decided to please the winner even more and to add a nameplate to the cup with the handle of the winner. The nameplate is to be rectangular and the text on it will be printed as a table of several rows and columns. Having some measurements done, the organizers have found out that the number a of rows cannot be greater than 5 while the number b of columns cannot exceed 20. Every cell of the table will contain either an asterisk («*») or a letter of user's handle. Furthermore, the organizers want the rows of the table to be uniform, which means that the number of asterisks used in different rows should differ by at most one (i.e. you can't have two asterisks in the first row and none in the second). The main goal, however, is to obtain the winner's handle precisely when reading the table from top to bottom and from left to right in every row (skipping asterisks). The organizers want for the nameplate to have as few rows as possible and among all valid tables with the minimum number of rows they want to choose the one that has the minimum number of columns. The winner is not yet determined so your task is to write a program that, given a certain handle, generates the necessary table. Input The only line contains one string s (1 ≤ |s| ≤ 100), comprised of uppercase and lowercase Latin letters, — the handle of the winner. Output In the first line output the minimum number a of rows in the table and the minimum number b of columns in an optimal table with rows. The following a lines should contain b characters each — any valid table. Examples Input tourist Output 1 7 tourist Input MyNameIsLifeIAmForeverByYourSideMyNameIsLife Output 3 15 MyNameIsLifeIAm ForeverByYourSi deMyNameIsL*ife Submitted Solution: ``` st = input().strip() l = len(st) - 1 now = l // 20 for i in range(20, 0, -1): if l // (i - 1) > now: now1 = i break now2 = (now1 -((l + 1) % now1)) % (l + 1) count = 0 for i in range((l // i) + 1): for j in range(now1): if now2 != 0 and i == j: print("*", end="") now2 -= 1 else: print(st[count], end="") count+=1 print() ```
instruction
0
76,714
18
153,428
No
output
1
76,714
18
153,429
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Mahmoud and Ehab are in the fourth stage now. Dr. Evil has a hidden binary string of length n. He guarantees that there is at least one '0' symbol and at least one '1' symbol in it. Now he wants Mahmoud and Ehab to find a position of any '0' symbol and any '1' symbol. In order to do this, Mahmoud and Ehab can ask Dr. Evil up to 15 questions. They tell Dr. Evil some binary string of length n, and Dr. Evil tells the Hamming distance between these two strings. Hamming distance between 2 binary strings of the same length is the number of positions in which they have different symbols. You can find the definition of Hamming distance in the notes section below. Help Mahmoud and Ehab find these two positions. You will get Wrong Answer verdict if * Your queries doesn't satisfy interaction protocol described below. * You ask strictly more than 15 questions and your program terminated after exceeding queries limit. Please note, that you can do up to 15 ask queries and one answer query. * Your final answer is not correct. You will get Idleness Limit Exceeded if you don't print anything or if you forget to flush the output, including for the final answer (more info about flushing output below). If you exceed the maximum number of queries, You should terminate with 0, In this case you'll get Wrong Answer, If you don't terminate you may receive any verdict because you'll be reading from a closed stream . Input The first line of input will contain a single integer n (2 ≤ n ≤ 1000) — the length of the hidden binary string. Output To print the final answer, print "! pos0 pos1" (without quotes), where pos0 and pos1 are positions of some '0' and some '1' in the string (the string is 1-indexed). Don't forget to flush the output after printing the answer! Interaction To ask a question use the format "? s" (without quotes), where s is a query string. Don't forget to flush the output after printing a query! After each query you can read a single integer from standard input — the Hamming distance between the hidden string and the query string. To flush the output you can use:- * fflush(stdout) in C++; * System.out.flush() in Java; * stdout.flush() in Python; * flush(output) in Pascal; * See the documentation for other languages . Hacking. To hack someone just print one binary string with length up to 1000, containing at least one '0' and at least one '1'. Example Input 3 2 1 3 2 1 0 Output ? 000 ? 001 ? 010 ? 011 ? 100 ? 101 ! 2 1 Note Hamming distance definition: <https://en.wikipedia.org/wiki/Hamming_distance> In the first test case the hidden binary string is 101, The first query is 000, so the Hamming distance is 2. In the second query the hidden string is still 101 and query is 001, so the Hamming distance is 1. After some queries you find that symbol at position 2 is '0' and symbol at position 1 is '1', so you print "! 2 1". Submitted Solution: ``` print("big pp, small pp") ```
instruction
0
77,285
18
154,570
No
output
1
77,285
18
154,571
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Mahmoud and Ehab are in the fourth stage now. Dr. Evil has a hidden binary string of length n. He guarantees that there is at least one '0' symbol and at least one '1' symbol in it. Now he wants Mahmoud and Ehab to find a position of any '0' symbol and any '1' symbol. In order to do this, Mahmoud and Ehab can ask Dr. Evil up to 15 questions. They tell Dr. Evil some binary string of length n, and Dr. Evil tells the Hamming distance between these two strings. Hamming distance between 2 binary strings of the same length is the number of positions in which they have different symbols. You can find the definition of Hamming distance in the notes section below. Help Mahmoud and Ehab find these two positions. You will get Wrong Answer verdict if * Your queries doesn't satisfy interaction protocol described below. * You ask strictly more than 15 questions and your program terminated after exceeding queries limit. Please note, that you can do up to 15 ask queries and one answer query. * Your final answer is not correct. You will get Idleness Limit Exceeded if you don't print anything or if you forget to flush the output, including for the final answer (more info about flushing output below). If you exceed the maximum number of queries, You should terminate with 0, In this case you'll get Wrong Answer, If you don't terminate you may receive any verdict because you'll be reading from a closed stream . Input The first line of input will contain a single integer n (2 ≤ n ≤ 1000) — the length of the hidden binary string. Output To print the final answer, print "! pos0 pos1" (without quotes), where pos0 and pos1 are positions of some '0' and some '1' in the string (the string is 1-indexed). Don't forget to flush the output after printing the answer! Interaction To ask a question use the format "? s" (without quotes), where s is a query string. Don't forget to flush the output after printing a query! After each query you can read a single integer from standard input — the Hamming distance between the hidden string and the query string. To flush the output you can use:- * fflush(stdout) in C++; * System.out.flush() in Java; * stdout.flush() in Python; * flush(output) in Pascal; * See the documentation for other languages . Hacking. To hack someone just print one binary string with length up to 1000, containing at least one '0' and at least one '1'. Example Input 3 2 1 3 2 1 0 Output ? 000 ? 001 ? 010 ? 011 ? 100 ? 101 ! 2 1 Note Hamming distance definition: <https://en.wikipedia.org/wiki/Hamming_distance> In the first test case the hidden binary string is 101, The first query is 000, so the Hamming distance is 2. In the second query the hidden string is still 101 and query is 001, so the Hamming distance is 1. After some queries you find that symbol at position 2 is '0' and symbol at position 1 is '1', so you print "! 2 1". Submitted Solution: ``` from sys import stdout n = int(input()) print('? ' + '0' * n) stdout.flush() k = int(input()) kolvo1, kolvo0 = k, n - k print('? 1' + '0' * (n - 1)) stdout.flush() p = int(input()) pos0, pos1 = -1, -1 s = 0 if p == k - 1: first_cifr = '1' pos1 = 0 s = kolvo0 else: first_cifr = '0' pos0 = 0 s = kolvo1 l = 1 r = n while l + 1 < r: m = (l + r) // 2 if first_cifr == '1': print('? ' + '1' * l + '0' * (m - l) + '1' * (n - (m - l) - l)) else: print('? ' + '0' * l + '1' * (m - l) + '0' * (n - (m - l) - l)) stdout.flush() k = int(input()) if k <= s: r = m else: l = m s = k if pos0 == -1: pos0 = l else: pos1 = l print('!', pos0 + 1, pos1 + 1) ```
instruction
0
77,286
18
154,572
No
output
1
77,286
18
154,573
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Mahmoud and Ehab are in the fourth stage now. Dr. Evil has a hidden binary string of length n. He guarantees that there is at least one '0' symbol and at least one '1' symbol in it. Now he wants Mahmoud and Ehab to find a position of any '0' symbol and any '1' symbol. In order to do this, Mahmoud and Ehab can ask Dr. Evil up to 15 questions. They tell Dr. Evil some binary string of length n, and Dr. Evil tells the Hamming distance between these two strings. Hamming distance between 2 binary strings of the same length is the number of positions in which they have different symbols. You can find the definition of Hamming distance in the notes section below. Help Mahmoud and Ehab find these two positions. You will get Wrong Answer verdict if * Your queries doesn't satisfy interaction protocol described below. * You ask strictly more than 15 questions and your program terminated after exceeding queries limit. Please note, that you can do up to 15 ask queries and one answer query. * Your final answer is not correct. You will get Idleness Limit Exceeded if you don't print anything or if you forget to flush the output, including for the final answer (more info about flushing output below). If you exceed the maximum number of queries, You should terminate with 0, In this case you'll get Wrong Answer, If you don't terminate you may receive any verdict because you'll be reading from a closed stream . Input The first line of input will contain a single integer n (2 ≤ n ≤ 1000) — the length of the hidden binary string. Output To print the final answer, print "! pos0 pos1" (without quotes), where pos0 and pos1 are positions of some '0' and some '1' in the string (the string is 1-indexed). Don't forget to flush the output after printing the answer! Interaction To ask a question use the format "? s" (without quotes), where s is a query string. Don't forget to flush the output after printing a query! After each query you can read a single integer from standard input — the Hamming distance between the hidden string and the query string. To flush the output you can use:- * fflush(stdout) in C++; * System.out.flush() in Java; * stdout.flush() in Python; * flush(output) in Pascal; * See the documentation for other languages . Hacking. To hack someone just print one binary string with length up to 1000, containing at least one '0' and at least one '1'. Example Input 3 2 1 3 2 1 0 Output ? 000 ? 001 ? 010 ? 011 ? 100 ? 101 ! 2 1 Note Hamming distance definition: <https://en.wikipedia.org/wiki/Hamming_distance> In the first test case the hidden binary string is 101, The first query is 000, so the Hamming distance is 2. In the second query the hidden string is still 101 and query is 001, so the Hamming distance is 1. After some queries you find that symbol at position 2 is '0' and symbol at position 1 is '1', so you print "! 2 1". Submitted Solution: ``` from sys import exit cntq = 0 def query(m): global cntq cntq += 1 if cntq > 15: exit(1) if last == 0: s = '1' * m + '0' * (n - m) else: s = '0' * m + '1' * (n - m) print('?', s) res = int(input()) if last == '0': res = n - res return res n = int(input()) last = -1 ones = query(n) kek = ones - query(n - 1) if kek < 0: last = '0' else: last = '1' l = 0 r = n if last == '1': onesl = 0 zeror = 0 while (r - l > 1): m = (l + r) // 2 x = query(m) - onesl - zeror kek = ones - x a1 = (ones + x - (r - m)) // 2 b1 = ones - a1 b0 = x - a1 if b0 > 0: l = m ones = b1 onesl += a1 else: r = m ones = a1 zeror += b0 else: zerol = 0 onesr = 0 while (r - l > 1): m = (l + r) // 2 x = query(m) - zerol - onesr kek = ones - kek b1 = (ones + x - (m - l)) // 2 a1 = ones - b1 a0 = x - b1 if b1 > 0: l = m ones = b1 zerol += a0 else: r = m ones = a1 onesr += b1 s = '0011001100' if s[l] == s[n - 1]: exit(1) print('!', l + 1, n) # print('!', 1, 3) ```
instruction
0
77,287
18
154,574
No
output
1
77,287
18
154,575
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Mahmoud and Ehab are in the fourth stage now. Dr. Evil has a hidden binary string of length n. He guarantees that there is at least one '0' symbol and at least one '1' symbol in it. Now he wants Mahmoud and Ehab to find a position of any '0' symbol and any '1' symbol. In order to do this, Mahmoud and Ehab can ask Dr. Evil up to 15 questions. They tell Dr. Evil some binary string of length n, and Dr. Evil tells the Hamming distance between these two strings. Hamming distance between 2 binary strings of the same length is the number of positions in which they have different symbols. You can find the definition of Hamming distance in the notes section below. Help Mahmoud and Ehab find these two positions. You will get Wrong Answer verdict if * Your queries doesn't satisfy interaction protocol described below. * You ask strictly more than 15 questions and your program terminated after exceeding queries limit. Please note, that you can do up to 15 ask queries and one answer query. * Your final answer is not correct. You will get Idleness Limit Exceeded if you don't print anything or if you forget to flush the output, including for the final answer (more info about flushing output below). If you exceed the maximum number of queries, You should terminate with 0, In this case you'll get Wrong Answer, If you don't terminate you may receive any verdict because you'll be reading from a closed stream . Input The first line of input will contain a single integer n (2 ≤ n ≤ 1000) — the length of the hidden binary string. Output To print the final answer, print "! pos0 pos1" (without quotes), where pos0 and pos1 are positions of some '0' and some '1' in the string (the string is 1-indexed). Don't forget to flush the output after printing the answer! Interaction To ask a question use the format "? s" (without quotes), where s is a query string. Don't forget to flush the output after printing a query! After each query you can read a single integer from standard input — the Hamming distance between the hidden string and the query string. To flush the output you can use:- * fflush(stdout) in C++; * System.out.flush() in Java; * stdout.flush() in Python; * flush(output) in Pascal; * See the documentation for other languages . Hacking. To hack someone just print one binary string with length up to 1000, containing at least one '0' and at least one '1'. Example Input 3 2 1 3 2 1 0 Output ? 000 ? 001 ? 010 ? 011 ? 100 ? 101 ! 2 1 Note Hamming distance definition: <https://en.wikipedia.org/wiki/Hamming_distance> In the first test case the hidden binary string is 101, The first query is 000, so the Hamming distance is 2. In the second query the hidden string is still 101 and query is 001, so the Hamming distance is 1. After some queries you find that symbol at position 2 is '0' and symbol at position 1 is '1', so you print "! 2 1". Submitted Solution: ``` import sys #sstr = "1"*20+"0" ls = int(input())#len(sstr) def q(s): print(s) sys.stdout.flush() def d(s): a = q("? " + s) return int(input()) #v = 0 #for i in range(min(len(sstr), len(s))): # if s[i] != sstr[i]: # v += 1 #return v d0 = d("1" * ls) l, r = 0, ls c = d0 find1 = -1 find0 = -1 while l + 1 < r: m = (l + r) // 2 k1, k2 = m - l, r - m s = l * "1" + k1 * "0" + (ls - m) * "1" ds = d(s) c0 = (k1 + d0 - ds) / 2 a, b = c0, c - c0 if a == 0 and find1 == -1: find1 = m - 1 if b == 0 and find1 == -1: find1 = m if a == k1 and find0 == -1: find0 = m - 1 if b == k2 - 1 and find0 == -1: find0 = m #print("--"*10) #print(sstr, sstr, k1, k2, l, r, m) #print(s, m * "1" + (r - m) * "0" + (ls - r) * "1", a, b, find1, find0, k1, k2) #print("--"*10) if (a < b and a != 0): r = m c = a else: l = m c = b if find1 != -1 and find0 != -1: break if find0 == -1: find0 = 0 if find1 == -1: find1 = 0 q("! {} {}".format(find0 + 1, find1 + 1)) ```
instruction
0
77,288
18
154,576
No
output
1
77,288
18
154,577
Provide a correct Python 3 solution for this coding contest problem. You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words. Constraints * s_1, s_2 and s_3 are composed of lowercase English letters. * 1 ≤ |s_i| ≤ 10 (1≤i≤3) Input Input is given from Standard Input in the following format: s_1 s_2 s_3 Output Print the answer. Examples Input atcoder beginner contest Output ABC Input resident register number Output RRN Input k nearest neighbor Output KNN Input async layered coding Output ALC
instruction
0
77,453
18
154,906
"Correct Solution: ``` S,T,U=input().split();print(S[0].upper()+T[0].upper()+U[0].upper()) ```
output
1
77,453
18
154,907
Provide a correct Python 3 solution for this coding contest problem. You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words. Constraints * s_1, s_2 and s_3 are composed of lowercase English letters. * 1 ≤ |s_i| ≤ 10 (1≤i≤3) Input Input is given from Standard Input in the following format: s_1 s_2 s_3 Output Print the answer. Examples Input atcoder beginner contest Output ABC Input resident register number Output RRN Input k nearest neighbor Output KNN Input async layered coding Output ALC
instruction
0
77,454
18
154,908
"Correct Solution: ``` s="" for x in input().split():s+=x[0] print(s.upper()) ```
output
1
77,454
18
154,909
Provide a correct Python 3 solution for this coding contest problem. You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words. Constraints * s_1, s_2 and s_3 are composed of lowercase English letters. * 1 ≤ |s_i| ≤ 10 (1≤i≤3) Input Input is given from Standard Input in the following format: s_1 s_2 s_3 Output Print the answer. Examples Input atcoder beginner contest Output ABC Input resident register number Output RRN Input k nearest neighbor Output KNN Input async layered coding Output ALC
instruction
0
77,455
18
154,910
"Correct Solution: ``` print(''.join([_[0].upper() for _ in input().split()])) ```
output
1
77,455
18
154,911
Provide a correct Python 3 solution for this coding contest problem. You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words. Constraints * s_1, s_2 and s_3 are composed of lowercase English letters. * 1 ≤ |s_i| ≤ 10 (1≤i≤3) Input Input is given from Standard Input in the following format: s_1 s_2 s_3 Output Print the answer. Examples Input atcoder beginner contest Output ABC Input resident register number Output RRN Input k nearest neighbor Output KNN Input async layered coding Output ALC
instruction
0
77,456
18
154,912
"Correct Solution: ``` a, b, c = input().split(" ") s = a[0]+b[0]+c[0] print(s.upper()) ```
output
1
77,456
18
154,913
Provide a correct Python 3 solution for this coding contest problem. You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words. Constraints * s_1, s_2 and s_3 are composed of lowercase English letters. * 1 ≤ |s_i| ≤ 10 (1≤i≤3) Input Input is given from Standard Input in the following format: s_1 s_2 s_3 Output Print the answer. Examples Input atcoder beginner contest Output ABC Input resident register number Output RRN Input k nearest neighbor Output KNN Input async layered coding Output ALC
instruction
0
77,457
18
154,914
"Correct Solution: ``` print(''.join([a[0] for a in input().upper().split()])) ```
output
1
77,457
18
154,915
Provide a correct Python 3 solution for this coding contest problem. You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words. Constraints * s_1, s_2 and s_3 are composed of lowercase English letters. * 1 ≤ |s_i| ≤ 10 (1≤i≤3) Input Input is given from Standard Input in the following format: s_1 s_2 s_3 Output Print the answer. Examples Input atcoder beginner contest Output ABC Input resident register number Output RRN Input k nearest neighbor Output KNN Input async layered coding Output ALC
instruction
0
77,458
18
154,916
"Correct Solution: ``` a,b,c=map(str,input().split());print((a[0]+b[0]+c[0]).upper()) ```
output
1
77,458
18
154,917
Provide a correct Python 3 solution for this coding contest problem. You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words. Constraints * s_1, s_2 and s_3 are composed of lowercase English letters. * 1 ≤ |s_i| ≤ 10 (1≤i≤3) Input Input is given from Standard Input in the following format: s_1 s_2 s_3 Output Print the answer. Examples Input atcoder beginner contest Output ABC Input resident register number Output RRN Input k nearest neighbor Output KNN Input async layered coding Output ALC
instruction
0
77,459
18
154,918
"Correct Solution: ``` a,b,c=input().split() x=(a[0]+b[0]+c[0]).upper() print(x) ```
output
1
77,459
18
154,919
Provide a correct Python 3 solution for this coding contest problem. You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words. Constraints * s_1, s_2 and s_3 are composed of lowercase English letters. * 1 ≤ |s_i| ≤ 10 (1≤i≤3) Input Input is given from Standard Input in the following format: s_1 s_2 s_3 Output Print the answer. Examples Input atcoder beginner contest Output ABC Input resident register number Output RRN Input k nearest neighbor Output KNN Input async layered coding Output ALC
instruction
0
77,460
18
154,920
"Correct Solution: ``` x,y,z = (input().split()) print((x[:1]+y[:1]+z[:1]).upper()) ```
output
1
77,460
18
154,921
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words. Constraints * s_1, s_2 and s_3 are composed of lowercase English letters. * 1 ≤ |s_i| ≤ 10 (1≤i≤3) Input Input is given from Standard Input in the following format: s_1 s_2 s_3 Output Print the answer. Examples Input atcoder beginner contest Output ABC Input resident register number Output RRN Input k nearest neighbor Output KNN Input async layered coding Output ALC Submitted Solution: ``` a,b,c=input().split() ans=a[0]+b[0]+c[0] ans=ans.upper() print(ans) ```
instruction
0
77,461
18
154,922
Yes
output
1
77,461
18
154,923
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words. Constraints * s_1, s_2 and s_3 are composed of lowercase English letters. * 1 ≤ |s_i| ≤ 10 (1≤i≤3) Input Input is given from Standard Input in the following format: s_1 s_2 s_3 Output Print the answer. Examples Input atcoder beginner contest Output ABC Input resident register number Output RRN Input k nearest neighbor Output KNN Input async layered coding Output ALC Submitted Solution: ``` print(''.join(map(lambda x:x[0].upper(),input().split()))) ```
instruction
0
77,462
18
154,924
Yes
output
1
77,462
18
154,925
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words. Constraints * s_1, s_2 and s_3 are composed of lowercase English letters. * 1 ≤ |s_i| ≤ 10 (1≤i≤3) Input Input is given from Standard Input in the following format: s_1 s_2 s_3 Output Print the answer. Examples Input atcoder beginner contest Output ABC Input resident register number Output RRN Input k nearest neighbor Output KNN Input async layered coding Output ALC Submitted Solution: ``` a=input().upper().split();print(a[0][0]+a[1][0]+a[2][0]) ```
instruction
0
77,463
18
154,926
Yes
output
1
77,463
18
154,927
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words. Constraints * s_1, s_2 and s_3 are composed of lowercase English letters. * 1 ≤ |s_i| ≤ 10 (1≤i≤3) Input Input is given from Standard Input in the following format: s_1 s_2 s_3 Output Print the answer. Examples Input atcoder beginner contest Output ABC Input resident register number Output RRN Input k nearest neighbor Output KNN Input async layered coding Output ALC Submitted Solution: ``` print(''.join([c[0] for c in input().split()]).upper()) ```
instruction
0
77,464
18
154,928
Yes
output
1
77,464
18
154,929
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words. Constraints * s_1, s_2 and s_3 are composed of lowercase English letters. * 1 ≤ |s_i| ≤ 10 (1≤i≤3) Input Input is given from Standard Input in the following format: s_1 s_2 s_3 Output Print the answer. Examples Input atcoder beginner contest Output ABC Input resident register number Output RRN Input k nearest neighbor Output KNN Input async layered coding Output ALC Submitted Solution: ``` s1, s2, s3 = input().split() ans = chr(ord(s1[0])-32)+chr(ord(s2[0])-32)+chr(ord(s2[0])-32) ```
instruction
0
77,465
18
154,930
No
output
1
77,465
18
154,931
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words. Constraints * s_1, s_2 and s_3 are composed of lowercase English letters. * 1 ≤ |s_i| ≤ 10 (1≤i≤3) Input Input is given from Standard Input in the following format: s_1 s_2 s_3 Output Print the answer. Examples Input atcoder beginner contest Output ABC Input resident register number Output RRN Input k nearest neighbor Output KNN Input async layered coding Output ALC Submitted Solution: ``` a,b,c = map(str, input().split()) print(str(a[0].uppercase)+str(b[0].uppercase)+str(c[0].uppercase)) ```
instruction
0
77,466
18
154,932
No
output
1
77,466
18
154,933
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words. Constraints * s_1, s_2 and s_3 are composed of lowercase English letters. * 1 ≤ |s_i| ≤ 10 (1≤i≤3) Input Input is given from Standard Input in the following format: s_1 s_2 s_3 Output Print the answer. Examples Input atcoder beginner contest Output ABC Input resident register number Output RRN Input k nearest neighbor Output KNN Input async layered coding Output ALC Submitted Solution: ``` import sys S = list(map(str,input().split())) for I in S: if not I.islower(): sys.exit() if len(I) < 0 or len(I) > 10: sys.exit() result = "" for J in S: print(J[0:1]) result = result + J[0:1] print(result.upper()) ```
instruction
0
77,467
18
154,934
No
output
1
77,467
18
154,935
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given three words s_1, s_2 and s_3, each composed of lowercase English letters, with spaces in between. Print the acronym formed from the uppercased initial letters of the words. Constraints * s_1, s_2 and s_3 are composed of lowercase English letters. * 1 ≤ |s_i| ≤ 10 (1≤i≤3) Input Input is given from Standard Input in the following format: s_1 s_2 s_3 Output Print the answer. Examples Input atcoder beginner contest Output ABC Input resident register number Output RRN Input k nearest neighbor Output KNN Input async layered coding Output ALC Submitted Solution: ``` x,y=map(int,input().split()) if abs(x-y)<=1: print('Brown') else: print('Alice') ```
instruction
0
77,468
18
154,936
No
output
1
77,468
18
154,937
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases: 1. They are equal. 2. If we split string a into two halves of the same size a1 and a2, and string b into two halves of the same size b1 and b2, then one of the following is correct: 1. a1 is equivalent to b1, and a2 is equivalent to b2 2. a1 is equivalent to b2, and a2 is equivalent to b1 As a home task, the teacher gave two strings to his students and asked to determine if they are equivalent. Gerald has already completed this home task. Now it's your turn! Input The first two lines of the input contain two strings given by the teacher. Each of them has the length from 1 to 200 000 and consists of lowercase English letters. The strings have the same length. Output Print "YES" (without the quotes), if these two strings are equivalent, and "NO" (without the quotes) otherwise. Examples Input aaba abaa Output YES Input aabb abab Output NO Note In the first sample you should split the first string into strings "aa" and "ba", the second one — into strings "ab" and "aa". "aa" is equivalent to "aa"; "ab" is equivalent to "ba" as "ab" = "a" + "b", "ba" = "b" + "a". In the second sample the first string can be splitted into strings "aa" and "bb", that are equivalent only to themselves. That's why string "aabb" is equivalent only to itself and to string "bbaa". Submitted Solution: ``` def permut(str): if len(str) % 2 != 0: return str n = len(str) s1 = permut(str[:n//2]) s2 = permut(str[n//2:]) if s1 + s2 > s2 + s1: return s1 + s2 else: return s2 + s1 s = input() t = input() if permut(s) == permut(t): print("YES") else: print("NO") ```
instruction
0
77,864
18
155,728
Yes
output
1
77,864
18
155,729
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases: 1. They are equal. 2. If we split string a into two halves of the same size a1 and a2, and string b into two halves of the same size b1 and b2, then one of the following is correct: 1. a1 is equivalent to b1, and a2 is equivalent to b2 2. a1 is equivalent to b2, and a2 is equivalent to b1 As a home task, the teacher gave two strings to his students and asked to determine if they are equivalent. Gerald has already completed this home task. Now it's your turn! Input The first two lines of the input contain two strings given by the teacher. Each of them has the length from 1 to 200 000 and consists of lowercase English letters. The strings have the same length. Output Print "YES" (without the quotes), if these two strings are equivalent, and "NO" (without the quotes) otherwise. Examples Input aaba abaa Output YES Input aabb abab Output NO Note In the first sample you should split the first string into strings "aa" and "ba", the second one — into strings "ab" and "aa". "aa" is equivalent to "aa"; "ab" is equivalent to "ba" as "ab" = "a" + "b", "ba" = "b" + "a". In the second sample the first string can be splitted into strings "aa" and "bb", that are equivalent only to themselves. That's why string "aabb" is equivalent only to itself and to string "bbaa". Submitted Solution: ``` def isEqual(a, b): for i in range(0, len(a)): if (a[i] != b[i]): return False return True def lexicographic_minimal_string(s): if (len(s) % 2 == 1): return s half = int(len(s) /2) s1 = lexicographic_minimal_string(s[:half]) s2 = lexicographic_minimal_string(s[half:]) if s1 < s2: return s1 + s2 return s2 + s1 a = input() b = input() a = lexicographic_minimal_string(a) b = lexicographic_minimal_string(b) if(isEqual(a,b)): print("YES") else: print("NO") ''' def isEqual(AS,BS,size): for i in range(0, size): if (a[AS+i] != b[BS+i]): return False return True def equivalent(AS,BS,size): global a global b if isEqual(AS,BS,size): return True half = int(size / 2) if 2*half != size: return False if (equivalent(AS,BS+half,half) and equivalent(AS+half,BS,half)): return True if (equivalent(AS,BS,half) and equivalent(AS+half,BS+half,half)): return True return False a = input() b = input() if equivalent(0,0,len(a)): print("YES") else: print("NO") ''' ''' a = input() b = input() def isEqual(a, b): for i in range(0, len(a)): if (a[i] != b[i]): return False return True def equivalent(a, b): if a == "": return True if isEqual(a, b): return True half = int(len(a) / 2) if 2*half != len(a): return False if (equivalent(a[:half], b[:half]) and equivalent(a[half:], b[half:])): return True if (equivalent(a[:half], b[half:]) and equivalent(a[half:], b[:half])): return True return False if equivalent(a,b): print("YES") else: print("NO") ''' ```
instruction
0
77,865
18
155,730
Yes
output
1
77,865
18
155,731
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases: 1. They are equal. 2. If we split string a into two halves of the same size a1 and a2, and string b into two halves of the same size b1 and b2, then one of the following is correct: 1. a1 is equivalent to b1, and a2 is equivalent to b2 2. a1 is equivalent to b2, and a2 is equivalent to b1 As a home task, the teacher gave two strings to his students and asked to determine if they are equivalent. Gerald has already completed this home task. Now it's your turn! Input The first two lines of the input contain two strings given by the teacher. Each of them has the length from 1 to 200 000 and consists of lowercase English letters. The strings have the same length. Output Print "YES" (without the quotes), if these two strings are equivalent, and "NO" (without the quotes) otherwise. Examples Input aaba abaa Output YES Input aabb abab Output NO Note In the first sample you should split the first string into strings "aa" and "ba", the second one — into strings "ab" and "aa". "aa" is equivalent to "aa"; "ab" is equivalent to "ba" as "ab" = "a" + "b", "ba" = "b" + "a". In the second sample the first string can be splitted into strings "aa" and "bb", that are equivalent only to themselves. That's why string "aabb" is equivalent only to itself and to string "bbaa". Submitted Solution: ``` x = input() y = input() def f(x, y): if x == y: return True if len(x)%2 == 1: return False mid = len(x)//2 if f(x[:mid], y[mid:]) and f(x[mid:], y[:mid]): return True if f(x[mid:], y[mid:]) and f(x[:mid], y[:mid]): return True return False if f(x, y): print("YES") quit() print("NO") ```
instruction
0
77,866
18
155,732
Yes
output
1
77,866
18
155,733
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases: 1. They are equal. 2. If we split string a into two halves of the same size a1 and a2, and string b into two halves of the same size b1 and b2, then one of the following is correct: 1. a1 is equivalent to b1, and a2 is equivalent to b2 2. a1 is equivalent to b2, and a2 is equivalent to b1 As a home task, the teacher gave two strings to his students and asked to determine if they are equivalent. Gerald has already completed this home task. Now it's your turn! Input The first two lines of the input contain two strings given by the teacher. Each of them has the length from 1 to 200 000 and consists of lowercase English letters. The strings have the same length. Output Print "YES" (without the quotes), if these two strings are equivalent, and "NO" (without the quotes) otherwise. Examples Input aaba abaa Output YES Input aabb abab Output NO Note In the first sample you should split the first string into strings "aa" and "ba", the second one — into strings "ab" and "aa". "aa" is equivalent to "aa"; "ab" is equivalent to "ba" as "ab" = "a" + "b", "ba" = "b" + "a". In the second sample the first string can be splitted into strings "aa" and "bb", that are equivalent only to themselves. That's why string "aabb" is equivalent only to itself and to string "bbaa". Submitted Solution: ``` a = input() b = input() def split(s): length = len(s) if (length % 2 == 0): s1 = split((s[:int(length / 2)])) s2 = split(s[int(length / 2):]) if (s1 < s2): return s1 + s2 else: return s2 + s1 else: return s if (split(a) == split(b)): print("YES") else: print("NO") ```
instruction
0
77,867
18
155,734
Yes
output
1
77,867
18
155,735
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases: 1. They are equal. 2. If we split string a into two halves of the same size a1 and a2, and string b into two halves of the same size b1 and b2, then one of the following is correct: 1. a1 is equivalent to b1, and a2 is equivalent to b2 2. a1 is equivalent to b2, and a2 is equivalent to b1 As a home task, the teacher gave two strings to his students and asked to determine if they are equivalent. Gerald has already completed this home task. Now it's your turn! Input The first two lines of the input contain two strings given by the teacher. Each of them has the length from 1 to 200 000 and consists of lowercase English letters. The strings have the same length. Output Print "YES" (without the quotes), if these two strings are equivalent, and "NO" (without the quotes) otherwise. Examples Input aaba abaa Output YES Input aabb abab Output NO Note In the first sample you should split the first string into strings "aa" and "ba", the second one — into strings "ab" and "aa". "aa" is equivalent to "aa"; "ab" is equivalent to "ba" as "ab" = "a" + "b", "ba" = "b" + "a". In the second sample the first string can be splitted into strings "aa" and "bb", that are equivalent only to themselves. That's why string "aabb" is equivalent only to itself and to string "bbaa". Submitted Solution: ``` #f=open('pe.in','r') a=str(input()) b=str(input()) if len(a)%2==1: if a==b: print("YES") else: print("NO") quit() x=len(a)//2 if a[:x]==b[:x] or a[:x]==b[x:]: print("YES") quit() print("NO") ```
instruction
0
77,868
18
155,736
No
output
1
77,868
18
155,737
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases: 1. They are equal. 2. If we split string a into two halves of the same size a1 and a2, and string b into two halves of the same size b1 and b2, then one of the following is correct: 1. a1 is equivalent to b1, and a2 is equivalent to b2 2. a1 is equivalent to b2, and a2 is equivalent to b1 As a home task, the teacher gave two strings to his students and asked to determine if they are equivalent. Gerald has already completed this home task. Now it's your turn! Input The first two lines of the input contain two strings given by the teacher. Each of them has the length from 1 to 200 000 and consists of lowercase English letters. The strings have the same length. Output Print "YES" (without the quotes), if these two strings are equivalent, and "NO" (without the quotes) otherwise. Examples Input aaba abaa Output YES Input aabb abab Output NO Note In the first sample you should split the first string into strings "aa" and "ba", the second one — into strings "ab" and "aa". "aa" is equivalent to "aa"; "ab" is equivalent to "ba" as "ab" = "a" + "b", "ba" = "b" + "a". In the second sample the first string can be splitted into strings "aa" and "bb", that are equivalent only to themselves. That's why string "aabb" is equivalent only to itself and to string "bbaa". Submitted Solution: ``` def branch(a,b): if a == b: return True if len(a) > 1 and len(b) > 1: midA = len(a) // 2 midB = len(b) // 2 a1 = a[:midA] a2 = a[midA:] b1 = b[:midB] b2 = b[midB:] print([a1,a2,b1,b2]) return isEquivalent(a1,a2,b1,b2) return False def isEquivalent(a1,a2,b1,b2): check1 = a1 == b1 and a2 == b2 check2 = a1 == b2 and a2 == b1 if check1 or check2: return True check11 = True check12 = True if a1 != b1: check11 = branch(a1,b1) if a2 != b2: check12 = branch(a2,b2) check1 = check11 and check12 check21 = True check22 = True if a1 != b2: check21 = branch(a1,b2) if a2 != b1: check22 = branch(a2,b1) check2 = check21 and check22 return check1 or check2 def run(): str1 = input() str2 = input() print(branch(str1, str2)) run() ```
instruction
0
77,869
18
155,738
No
output
1
77,869
18
155,739
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases: 1. They are equal. 2. If we split string a into two halves of the same size a1 and a2, and string b into two halves of the same size b1 and b2, then one of the following is correct: 1. a1 is equivalent to b1, and a2 is equivalent to b2 2. a1 is equivalent to b2, and a2 is equivalent to b1 As a home task, the teacher gave two strings to his students and asked to determine if they are equivalent. Gerald has already completed this home task. Now it's your turn! Input The first two lines of the input contain two strings given by the teacher. Each of them has the length from 1 to 200 000 and consists of lowercase English letters. The strings have the same length. Output Print "YES" (without the quotes), if these two strings are equivalent, and "NO" (without the quotes) otherwise. Examples Input aaba abaa Output YES Input aabb abab Output NO Note In the first sample you should split the first string into strings "aa" and "ba", the second one — into strings "ab" and "aa". "aa" is equivalent to "aa"; "ab" is equivalent to "ba" as "ab" = "a" + "b", "ba" = "b" + "a". In the second sample the first string can be splitted into strings "aa" and "bb", that are equivalent only to themselves. That's why string "aabb" is equivalent only to itself and to string "bbaa". Submitted Solution: ``` __author__ = 'tka4a' def ifEqual(a, b): le = len(a) if (a == b): return True else: if ((le % 2) == 0) and ifEqual(a[:le // 2], b[le // 2:]) and ifEqual(b[:le // 2], a[le // 2:]): return True else: return False a = input() b = input() if ifEqual(a, b): print("YES") else: print("NO") ```
instruction
0
77,870
18
155,740
No
output
1
77,870
18
155,741
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Today on a lecture about strings Gerald learned a new definition of string equivalency. Two strings a and b of equal length are called equivalent in one of the two cases: 1. They are equal. 2. If we split string a into two halves of the same size a1 and a2, and string b into two halves of the same size b1 and b2, then one of the following is correct: 1. a1 is equivalent to b1, and a2 is equivalent to b2 2. a1 is equivalent to b2, and a2 is equivalent to b1 As a home task, the teacher gave two strings to his students and asked to determine if they are equivalent. Gerald has already completed this home task. Now it's your turn! Input The first two lines of the input contain two strings given by the teacher. Each of them has the length from 1 to 200 000 and consists of lowercase English letters. The strings have the same length. Output Print "YES" (without the quotes), if these two strings are equivalent, and "NO" (without the quotes) otherwise. Examples Input aaba abaa Output YES Input aabb abab Output NO Note In the first sample you should split the first string into strings "aa" and "ba", the second one — into strings "ab" and "aa". "aa" is equivalent to "aa"; "ab" is equivalent to "ba" as "ab" = "a" + "b", "ba" = "b" + "a". In the second sample the first string can be splitted into strings "aa" and "bb", that are equivalent only to themselves. That's why string "aabb" is equivalent only to itself and to string "bbaa". Submitted Solution: ``` __author__ = 'tka4a' a = input() b = input() le = len(a) if (a == b): print("Yes") else: if (le % 2 == 0) and (a[:le // 2] == b[le // 2:]) and (b[:le // 2] == a[le // 2:]): print("YES") else: print("NO") ```
instruction
0
77,871
18
155,742
No
output
1
77,871
18
155,743
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a string S consisting of letters `b`, `d`, `p` and `q`. Determine whether S is a mirror string. Here, a mirror string is a string S such that the following sequence of operations on S results in the same string S: 1. Reverse the order of the characters in S. 2. Replace each occurrence of `b` by `d`, `d` by `b`, `p` by `q`, and `q` by `p`, simultaneously. Constraints * 1 \leq |S| \leq 10^5 * S consists of letters `b`, `d`, `p`, and `q`. Input The input is given from Standard Input in the following format: S Output If S is a mirror string, print `Yes`. Otherwise, print `No`. Examples Input pdbq Output Yes Input ppqb Output No Submitted Solution: ``` def transform(s): s = s[::-1] s = s.replace('b', '0').replace('d', 'b').replace('0', 'd') s = s.replace('p', '0').replace('q', 'p').replace('0', 'q') return s s = input() if s == transform(s): print('Yes') else: print('No') ```
instruction
0
78,151
18
156,302
Yes
output
1
78,151
18
156,303
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a string S consisting of letters `b`, `d`, `p` and `q`. Determine whether S is a mirror string. Here, a mirror string is a string S such that the following sequence of operations on S results in the same string S: 1. Reverse the order of the characters in S. 2. Replace each occurrence of `b` by `d`, `d` by `b`, `p` by `q`, and `q` by `p`, simultaneously. Constraints * 1 \leq |S| \leq 10^5 * S consists of letters `b`, `d`, `p`, and `q`. Input The input is given from Standard Input in the following format: S Output If S is a mirror string, print `Yes`. Otherwise, print `No`. Examples Input pdbq Output Yes Input ppqb Output No Submitted Solution: ``` # -*- coding:utf-8 -*- import sys S = list(input()) a = list(reversed(S)) for tmp in range(len(a)): if a[tmp] == 'b': a[tmp] = 'd' elif a[tmp] == 'd': a[tmp] = 'b' elif a[tmp] == 'p': a[tmp] = 'q' else: a[tmp] = 'p' if S[tmp] != a[tmp]: print("No") sys.exit() print("Yes") ```
instruction
0
78,152
18
156,304
Yes
output
1
78,152
18
156,305
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a string S consisting of letters `b`, `d`, `p` and `q`. Determine whether S is a mirror string. Here, a mirror string is a string S such that the following sequence of operations on S results in the same string S: 1. Reverse the order of the characters in S. 2. Replace each occurrence of `b` by `d`, `d` by `b`, `p` by `q`, and `q` by `p`, simultaneously. Constraints * 1 \leq |S| \leq 10^5 * S consists of letters `b`, `d`, `p`, and `q`. Input The input is given from Standard Input in the following format: S Output If S is a mirror string, print `Yes`. Otherwise, print `No`. Examples Input pdbq Output Yes Input ppqb Output No Submitted Solution: ``` s=input() if len(s)%2==0: for i in range(len(s)): if s[i]=='p' and s[-1-i]!='q' or s[i]=='q' and s[-1-i]!='p' or s[i]=='d' and s[-1-i]!='b' or s[i]=='b' and s[-1-i]!='d': print('No') break else: print('Yes') else: print('No') ```
instruction
0
78,153
18
156,306
Yes
output
1
78,153
18
156,307
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a string S consisting of letters `b`, `d`, `p` and `q`. Determine whether S is a mirror string. Here, a mirror string is a string S such that the following sequence of operations on S results in the same string S: 1. Reverse the order of the characters in S. 2. Replace each occurrence of `b` by `d`, `d` by `b`, `p` by `q`, and `q` by `p`, simultaneously. Constraints * 1 \leq |S| \leq 10^5 * S consists of letters `b`, `d`, `p`, and `q`. Input The input is given from Standard Input in the following format: S Output If S is a mirror string, print `Yes`. Otherwise, print `No`. Examples Input pdbq Output Yes Input ppqb Output No Submitted Solution: ``` mp={'b':'d','d':'b','p':'q','q':'p'};a=list(input());b=list(a[::-1]);b=[mp[x] for x in b];print("Yes" if a==b else "No"); ```
instruction
0
78,154
18
156,308
Yes
output
1
78,154
18
156,309
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a string S consisting of letters `b`, `d`, `p` and `q`. Determine whether S is a mirror string. Here, a mirror string is a string S such that the following sequence of operations on S results in the same string S: 1. Reverse the order of the characters in S. 2. Replace each occurrence of `b` by `d`, `d` by `b`, `p` by `q`, and `q` by `p`, simultaneously. Constraints * 1 \leq |S| \leq 10^5 * S consists of letters `b`, `d`, `p`, and `q`. Input The input is given from Standard Input in the following format: S Output If S is a mirror string, print `Yes`. Otherwise, print `No`. Examples Input pdbq Output Yes Input ppqb Output No Submitted Solution: ``` from collections import deque d = { 'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p' } s = deque(input()) if len(s) % 2: print("No") while len(s) > 1: l = s.popleft() r = s.pop() if r != d[l]: print("No") quit(0) print("Yes") ```
instruction
0
78,155
18
156,310
No
output
1
78,155
18
156,311
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a string S consisting of letters `b`, `d`, `p` and `q`. Determine whether S is a mirror string. Here, a mirror string is a string S such that the following sequence of operations on S results in the same string S: 1. Reverse the order of the characters in S. 2. Replace each occurrence of `b` by `d`, `d` by `b`, `p` by `q`, and `q` by `p`, simultaneously. Constraints * 1 \leq |S| \leq 10^5 * S consists of letters `b`, `d`, `p`, and `q`. Input The input is given from Standard Input in the following format: S Output If S is a mirror string, print `Yes`. Otherwise, print `No`. Examples Input pdbq Output Yes Input ppqb Output No Submitted Solution: ``` S = input() lenth = int(len(S) / 2) cnt = 0 for i in range(lenth): if ((S[i] == 'b' and S[- i - 1] == 'd') or (S[i] == 'd' and S[- i - 1] == 'b') or (S[i] == 'p' and S[- i - 1] == 'q') or (S[i] == 'q' and S[- i - 1] == 'p')): cnt += 1 if cnt == lenth: print('Yes') else: print('No') ```
instruction
0
78,156
18
156,312
No
output
1
78,156
18
156,313
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a string S consisting of letters `b`, `d`, `p` and `q`. Determine whether S is a mirror string. Here, a mirror string is a string S such that the following sequence of operations on S results in the same string S: 1. Reverse the order of the characters in S. 2. Replace each occurrence of `b` by `d`, `d` by `b`, `p` by `q`, and `q` by `p`, simultaneously. Constraints * 1 \leq |S| \leq 10^5 * S consists of letters `b`, `d`, `p`, and `q`. Input The input is given from Standard Input in the following format: S Output If S is a mirror string, print `Yes`. Otherwise, print `No`. Examples Input pdbq Output Yes Input ppqb Output No Submitted Solution: ``` from collections import deque d = { 'b': 'd', 'd': 'b', 'p': 'q', 'q': 'p' } s = deque(input()) while len(s) > 1: l = s.popleft() r = s.pop() if r != d[l]: print("No") quit(0) print("Yes") ```
instruction
0
78,157
18
156,314
No
output
1
78,157
18
156,315
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given a string S consisting of letters `b`, `d`, `p` and `q`. Determine whether S is a mirror string. Here, a mirror string is a string S such that the following sequence of operations on S results in the same string S: 1. Reverse the order of the characters in S. 2. Replace each occurrence of `b` by `d`, `d` by `b`, `p` by `q`, and `q` by `p`, simultaneously. Constraints * 1 \leq |S| \leq 10^5 * S consists of letters `b`, `d`, `p`, and `q`. Input The input is given from Standard Input in the following format: S Output If S is a mirror string, print `Yes`. Otherwise, print `No`. Examples Input pdbq Output Yes Input ppqb Output No Submitted Solution: ``` s = list(input()) t = s[::-1] for i in t: if i == "p": i = "q" elif i == "q": i = "p" if i == "b": i = "d" elif i == "d": i = "b" if s == t: ans = "Yes" else: ans = "No" print(ans) ```
instruction
0
78,158
18
156,316
No
output
1
78,158
18
156,317
Provide a correct Python 3 solution for this coding contest problem. One day, Taro received a strange email with only the number "519345213244" in the text. The email was from my cousin, who was 10 years older than me, so when I called and asked, "Oh, I sent it with a pocket bell because I was in a hurry. It's convenient. Nice to meet you!" I got it. You know this cousin, who is always busy and a little bit aggressive, and when you have no choice but to research "pager hitting" yourself, you can see that it is a method of input that prevailed in the world about 10 years ago. I understand. In "Pokebell Strike", enter one character with two numbers, such as 11 for "A" and 15 for "O" according to the conversion table shown in Fig. 1. For example, to enter the string "Naruto", type "519345". Therefore, any letter can be entered with two numbers. <image> Figure 1 When mobile phones weren't widespread, high school students used this method to send messages from payphones to their friends' pagers. Some high school girls were able to pager at a tremendous speed. Recently, my cousin, who has been busy with work, has unknowingly started typing emails with a pager. Therefore, in order to help Taro who is having a hard time deciphering every time, please write a program that converts the pager message into a character string and outputs it. However, the conversion table shown in Fig. 2 is used for conversion, and only lowercase letters, ".", "?", "!", And blanks are targeted. Output NA for messages that contain characters that cannot be converted. <image> Figure 2 Input Multiple messages are given. One message (up to 200 characters) is given on each line. The total number of messages does not exceed 50. Output For each message, output the converted message or NA on one line. Example Input 341143514535 314 143565553551655311343411652235654535651124615163 551544654451431564 4 3411 6363636363 153414 Output naruto NA do you wanna go to aizu? yes sure! NA na ????? end
instruction
0
78,175
18
156,350
"Correct Solution: ``` def message(numbers): numbers=str(numbers) message="" while(len(numbers)>0): num=numbers[:2] if len(num)==1: return "NA" if int(num[0])>6 or int(num[0])<=0: return "NA" if int(num[1])>5 or int(num[1])<=0: return "NA" code=(int(num[0])-1)*5+int(num[1]) if code>30: return "NA" if code==27: message+="." elif code==28: message+="?" elif code==29: message+="!" elif code==30: message+=" " else: message+=chr(code-1+ord('a')) numbers=numbers[2::] return message while True: try: n=input() print(message(n)) except EOFError: break ```
output
1
78,175
18
156,351
Provide a correct Python 3 solution for this coding contest problem. One day, Taro received a strange email with only the number "519345213244" in the text. The email was from my cousin, who was 10 years older than me, so when I called and asked, "Oh, I sent it with a pocket bell because I was in a hurry. It's convenient. Nice to meet you!" I got it. You know this cousin, who is always busy and a little bit aggressive, and when you have no choice but to research "pager hitting" yourself, you can see that it is a method of input that prevailed in the world about 10 years ago. I understand. In "Pokebell Strike", enter one character with two numbers, such as 11 for "A" and 15 for "O" according to the conversion table shown in Fig. 1. For example, to enter the string "Naruto", type "519345". Therefore, any letter can be entered with two numbers. <image> Figure 1 When mobile phones weren't widespread, high school students used this method to send messages from payphones to their friends' pagers. Some high school girls were able to pager at a tremendous speed. Recently, my cousin, who has been busy with work, has unknowingly started typing emails with a pager. Therefore, in order to help Taro who is having a hard time deciphering every time, please write a program that converts the pager message into a character string and outputs it. However, the conversion table shown in Fig. 2 is used for conversion, and only lowercase letters, ".", "?", "!", And blanks are targeted. Output NA for messages that contain characters that cannot be converted. <image> Figure 2 Input Multiple messages are given. One message (up to 200 characters) is given on each line. The total number of messages does not exceed 50. Output For each message, output the converted message or NA on one line. Example Input 341143514535 314 143565553551655311343411652235654535651124615163 551544654451431564 4 3411 6363636363 153414 Output naruto NA do you wanna go to aizu? yes sure! NA na ????? end
instruction
0
78,176
18
156,352
"Correct Solution: ``` # AOJ 0127 Pocket Pager Input # Python3 2018.6.18 bal4u a = ['']*100 a[11], a[12], a[13], a[14], a[15] = 'a', 'b', 'c', 'd', 'e' a[21], a[22], a[23], a[24], a[25] = 'f', 'g', 'h', 'i', 'j' a[31], a[32], a[33], a[34], a[35] = 'k', 'l', 'm', 'n', 'o' a[41], a[42], a[43], a[44], a[45] = 'p', 'q', 'r', 's', 't' a[51], a[52], a[53], a[54], a[55] = 'u', 'v', 'w', 'x', 'y' a[61], a[62], a[63], a[64], a[65] = 'z', '.', '?', '!', ' ' while True: try: buf = list(input()) except: break f = True ans = '' for i in range(0, len(buf), 2): if i+1 >= len(buf): f = False break if buf[i].isdigit() and buf[i+1].isdigit(): k = int(buf[i]+buf[i+1]) if a[k] != '': ans += a[k] else: f = False break print(ans if f else "NA") ```
output
1
78,176
18
156,353