message
stringlengths
2
67k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
463
109k
cluster
float64
19
19
__index_level_0__
int64
926
217k
Provide tags and a correct Python 3 solution for this coding contest problem. Everyone knows that agents in Valorant decide, who will play as attackers, and who will play as defenders. To do that Raze and Breach decided to play t matches of a digit game... In each of t matches of the digit game, a positive integer is generated. It consists of n digits. The digits of this integer are numerated from 1 to n from the highest-order digit to the lowest-order digit. After this integer is announced, the match starts. Agents play in turns. Raze starts. In one turn an agent can choose any unmarked digit and mark it. Raze can choose digits on odd positions, but can not choose digits on even positions. Breach can choose digits on even positions, but can not choose digits on odd positions. The match ends, when there is only one unmarked digit left. If the single last digit is odd, then Raze wins, else Breach wins. It can be proved, that before the end of the match (for every initial integer with n digits) each agent has an ability to make a turn, i.e. there is at least one unmarked digit, that stands on a position of required parity. For each of t matches find out, which agent wins, if both of them want to win and play optimally. Input First line of input contains an integer t (1 ≀ t ≀ 100) β€” the number of matches. The first line of each match description contains an integer n (1 ≀ n ≀ 10^3) β€” the number of digits of the generated number. The second line of each match description contains an n-digit positive integer without leading zeros. Output For each match print 1, if Raze wins, and 2, if Breach wins. Example Input 4 1 2 1 3 3 102 4 2069 Output 2 1 1 2 Note In the first match no one can make a turn, the only digit left is 2, it's even, so Breach wins. In the second match the only digit left is 3, it's odd, so Raze wins. In the third match Raze can mark the last digit, after that Breach can only mark 0. 1 will be the last digit left, it's odd, so Raze wins. In the fourth match no matter how Raze plays, Breach can mark 9, and in the end there will be digit 0. It's even, so Breach wins.
instruction
0
76,063
19
152,126
Tags: games, greedy, implementation Correct Solution: ``` z,zz=input,lambda:list(map(int,z().split())) zzz=lambda:[int(i) for i in stdin.readline().split()] szz,graph,mod,szzz=lambda:sorted(zz()),{},10**9+7,lambda:sorted(zzz()) from string import * from re import * from collections import * from queue import * from sys import * from collections import * from math import * from heapq import * from itertools import * from bisect import * from collections import Counter as cc from math import factorial as f from bisect import bisect as bs from bisect import bisect_left as bsl from itertools import accumulate as ac from itertools import permutations as permu def lcd(xnum1,xnum2):return (xnum1*xnum2//gcd(xnum1,xnum2)) def prime(x): p=ceil(x**.5)+1 for i in range(2,p): if (x%i==0 and x!=2) or x==0:return 0 return 1 def dfs(u,visit,graph): visit[u]=True for i in graph[u]: if not visit[i]: dfs(i,visit,graph) ###########################---Test-Case---################################# """ """ ###########################---START-CODING---############################## num=1 num=int(z()) for _ in range( num ): n=int(z()) s=z() if n%2: for i in s[::2]: if i in '13579': print(1) break else: print(2) else: for i in s[1::2]: if i in '24680': print(2) break else: print(1) ```
output
1
76,063
19
152,127
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Everyone knows that agents in Valorant decide, who will play as attackers, and who will play as defenders. To do that Raze and Breach decided to play t matches of a digit game... In each of t matches of the digit game, a positive integer is generated. It consists of n digits. The digits of this integer are numerated from 1 to n from the highest-order digit to the lowest-order digit. After this integer is announced, the match starts. Agents play in turns. Raze starts. In one turn an agent can choose any unmarked digit and mark it. Raze can choose digits on odd positions, but can not choose digits on even positions. Breach can choose digits on even positions, but can not choose digits on odd positions. The match ends, when there is only one unmarked digit left. If the single last digit is odd, then Raze wins, else Breach wins. It can be proved, that before the end of the match (for every initial integer with n digits) each agent has an ability to make a turn, i.e. there is at least one unmarked digit, that stands on a position of required parity. For each of t matches find out, which agent wins, if both of them want to win and play optimally. Input First line of input contains an integer t (1 ≀ t ≀ 100) β€” the number of matches. The first line of each match description contains an integer n (1 ≀ n ≀ 10^3) β€” the number of digits of the generated number. The second line of each match description contains an n-digit positive integer without leading zeros. Output For each match print 1, if Raze wins, and 2, if Breach wins. Example Input 4 1 2 1 3 3 102 4 2069 Output 2 1 1 2 Note In the first match no one can make a turn, the only digit left is 2, it's even, so Breach wins. In the second match the only digit left is 3, it's odd, so Raze wins. In the third match Raze can mark the last digit, after that Breach can only mark 0. 1 will be the last digit left, it's odd, so Raze wins. In the fourth match no matter how Raze plays, Breach can mark 9, and in the end there will be digit 0. It's even, so Breach wins. Submitted Solution: ``` t = int(input()) for i in range(t): n = int(input()) digits = list(str(input())) flag = False if n % 2 == 0: for t in range(1, n, 2): if int(digits[t]) % 2 == 0: flag = True break flag = False else: for t in range(0, n, 2): if int(digits[t]) % 2: flag = False break flag = True if flag: print(2) else: print(1) ```
instruction
0
76,064
19
152,128
Yes
output
1
76,064
19
152,129
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Everyone knows that agents in Valorant decide, who will play as attackers, and who will play as defenders. To do that Raze and Breach decided to play t matches of a digit game... In each of t matches of the digit game, a positive integer is generated. It consists of n digits. The digits of this integer are numerated from 1 to n from the highest-order digit to the lowest-order digit. After this integer is announced, the match starts. Agents play in turns. Raze starts. In one turn an agent can choose any unmarked digit and mark it. Raze can choose digits on odd positions, but can not choose digits on even positions. Breach can choose digits on even positions, but can not choose digits on odd positions. The match ends, when there is only one unmarked digit left. If the single last digit is odd, then Raze wins, else Breach wins. It can be proved, that before the end of the match (for every initial integer with n digits) each agent has an ability to make a turn, i.e. there is at least one unmarked digit, that stands on a position of required parity. For each of t matches find out, which agent wins, if both of them want to win and play optimally. Input First line of input contains an integer t (1 ≀ t ≀ 100) β€” the number of matches. The first line of each match description contains an integer n (1 ≀ n ≀ 10^3) β€” the number of digits of the generated number. The second line of each match description contains an n-digit positive integer without leading zeros. Output For each match print 1, if Raze wins, and 2, if Breach wins. Example Input 4 1 2 1 3 3 102 4 2069 Output 2 1 1 2 Note In the first match no one can make a turn, the only digit left is 2, it's even, so Breach wins. In the second match the only digit left is 3, it's odd, so Raze wins. In the third match Raze can mark the last digit, after that Breach can only mark 0. 1 will be the last digit left, it's odd, so Raze wins. In the fourth match no matter how Raze plays, Breach can mark 9, and in the end there will be digit 0. It's even, so Breach wins. Submitted Solution: ``` for _ in range(int(input())): n = int(input()) f = str(input()) f = [int(i) for i in f] raz_od = 0 raz_ev = 0 va_od = 0 va_ev = 0 for i in range(n): if (i+1)%2 == 0 : if f[i]%2 == 0 : va_ev +=1 else : va_od +=1 else : if f[i]%2 == 0 : raz_ev +=1 else : raz_od +=1 if n == 1 : if f[0]%2 == 0 : print(2) else : print(1) else : while True : if raz_ev > 0: raz_ev -=1 else : raz_od -=1 if(raz_od+raz_ev + va_ev + va_od == 1): if raz_od ==1 or va_od == 1 : print(1) else : print(2) break if va_od > 0 : va_od -=1 else : va_ev -=1 if(raz_od+raz_ev + va_ev + va_od == 1): if raz_od ==1 or va_od == 1 : print(1) else : print(2) break ```
instruction
0
76,065
19
152,130
Yes
output
1
76,065
19
152,131
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Everyone knows that agents in Valorant decide, who will play as attackers, and who will play as defenders. To do that Raze and Breach decided to play t matches of a digit game... In each of t matches of the digit game, a positive integer is generated. It consists of n digits. The digits of this integer are numerated from 1 to n from the highest-order digit to the lowest-order digit. After this integer is announced, the match starts. Agents play in turns. Raze starts. In one turn an agent can choose any unmarked digit and mark it. Raze can choose digits on odd positions, but can not choose digits on even positions. Breach can choose digits on even positions, but can not choose digits on odd positions. The match ends, when there is only one unmarked digit left. If the single last digit is odd, then Raze wins, else Breach wins. It can be proved, that before the end of the match (for every initial integer with n digits) each agent has an ability to make a turn, i.e. there is at least one unmarked digit, that stands on a position of required parity. For each of t matches find out, which agent wins, if both of them want to win and play optimally. Input First line of input contains an integer t (1 ≀ t ≀ 100) β€” the number of matches. The first line of each match description contains an integer n (1 ≀ n ≀ 10^3) β€” the number of digits of the generated number. The second line of each match description contains an n-digit positive integer without leading zeros. Output For each match print 1, if Raze wins, and 2, if Breach wins. Example Input 4 1 2 1 3 3 102 4 2069 Output 2 1 1 2 Note In the first match no one can make a turn, the only digit left is 2, it's even, so Breach wins. In the second match the only digit left is 3, it's odd, so Raze wins. In the third match Raze can mark the last digit, after that Breach can only mark 0. 1 will be the last digit left, it's odd, so Raze wins. In the fourth match no matter how Raze plays, Breach can mark 9, and in the end there will be digit 0. It's even, so Breach wins. Submitted Solution: ``` t = int(input()) for _ in range(t): n = int(input()) x = input() y = int(x) if n == 1: if y % 2 == 1: print(1) else: print(2) elif n % 2 == 0: i = 1 q = 0 while i < n: if int(x[i]) % 2 == 0: q = 1 print(2) break i += 2 if q == 0: print(1) else: i = 0 q = 0 while i < n: if int(x[i]) % 2 == 1: print(1) q = 1 break i += 2 if q == 0: print(2) ```
instruction
0
76,066
19
152,132
Yes
output
1
76,066
19
152,133
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Everyone knows that agents in Valorant decide, who will play as attackers, and who will play as defenders. To do that Raze and Breach decided to play t matches of a digit game... In each of t matches of the digit game, a positive integer is generated. It consists of n digits. The digits of this integer are numerated from 1 to n from the highest-order digit to the lowest-order digit. After this integer is announced, the match starts. Agents play in turns. Raze starts. In one turn an agent can choose any unmarked digit and mark it. Raze can choose digits on odd positions, but can not choose digits on even positions. Breach can choose digits on even positions, but can not choose digits on odd positions. The match ends, when there is only one unmarked digit left. If the single last digit is odd, then Raze wins, else Breach wins. It can be proved, that before the end of the match (for every initial integer with n digits) each agent has an ability to make a turn, i.e. there is at least one unmarked digit, that stands on a position of required parity. For each of t matches find out, which agent wins, if both of them want to win and play optimally. Input First line of input contains an integer t (1 ≀ t ≀ 100) β€” the number of matches. The first line of each match description contains an integer n (1 ≀ n ≀ 10^3) β€” the number of digits of the generated number. The second line of each match description contains an n-digit positive integer without leading zeros. Output For each match print 1, if Raze wins, and 2, if Breach wins. Example Input 4 1 2 1 3 3 102 4 2069 Output 2 1 1 2 Note In the first match no one can make a turn, the only digit left is 2, it's even, so Breach wins. In the second match the only digit left is 3, it's odd, so Raze wins. In the third match Raze can mark the last digit, after that Breach can only mark 0. 1 will be the last digit left, it's odd, so Raze wins. In the fourth match no matter how Raze plays, Breach can mark 9, and in the end there will be digit 0. It's even, so Breach wins. Submitted Solution: ``` t = int(input()) for i in range (0,t): n = int(input()) num = input() arr = [int(x) for x in str(num)] c = 0 if n%2==0: for i in range (len(arr)): if i%2!=0 and arr[i]%2==0: c = 2 if c==2: print(c) else: print('1') else: for i in range (len(arr)): if i%2==0 and arr[i]%2!=0: c = 1 if c==1: print(c) else: print('2') ```
instruction
0
76,067
19
152,134
Yes
output
1
76,067
19
152,135
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Everyone knows that agents in Valorant decide, who will play as attackers, and who will play as defenders. To do that Raze and Breach decided to play t matches of a digit game... In each of t matches of the digit game, a positive integer is generated. It consists of n digits. The digits of this integer are numerated from 1 to n from the highest-order digit to the lowest-order digit. After this integer is announced, the match starts. Agents play in turns. Raze starts. In one turn an agent can choose any unmarked digit and mark it. Raze can choose digits on odd positions, but can not choose digits on even positions. Breach can choose digits on even positions, but can not choose digits on odd positions. The match ends, when there is only one unmarked digit left. If the single last digit is odd, then Raze wins, else Breach wins. It can be proved, that before the end of the match (for every initial integer with n digits) each agent has an ability to make a turn, i.e. there is at least one unmarked digit, that stands on a position of required parity. For each of t matches find out, which agent wins, if both of them want to win and play optimally. Input First line of input contains an integer t (1 ≀ t ≀ 100) β€” the number of matches. The first line of each match description contains an integer n (1 ≀ n ≀ 10^3) β€” the number of digits of the generated number. The second line of each match description contains an n-digit positive integer without leading zeros. Output For each match print 1, if Raze wins, and 2, if Breach wins. Example Input 4 1 2 1 3 3 102 4 2069 Output 2 1 1 2 Note In the first match no one can make a turn, the only digit left is 2, it's even, so Breach wins. In the second match the only digit left is 3, it's odd, so Raze wins. In the third match Raze can mark the last digit, after that Breach can only mark 0. 1 will be the last digit left, it's odd, so Raze wins. In the fourth match no matter how Raze plays, Breach can mark 9, and in the end there will be digit 0. It's even, so Breach wins. Submitted Solution: ``` for _ in range(int(input())): n=int(input()) k=str(input()) if n%2==0: ans=1 for i in range(1,n-1,2): if int(k[i])%2==0: ans=2 break else: ans=2 for j in range(0,n,2): if int(k[j])%2==1: ans=1 break print(ans) ```
instruction
0
76,068
19
152,136
No
output
1
76,068
19
152,137
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Everyone knows that agents in Valorant decide, who will play as attackers, and who will play as defenders. To do that Raze and Breach decided to play t matches of a digit game... In each of t matches of the digit game, a positive integer is generated. It consists of n digits. The digits of this integer are numerated from 1 to n from the highest-order digit to the lowest-order digit. After this integer is announced, the match starts. Agents play in turns. Raze starts. In one turn an agent can choose any unmarked digit and mark it. Raze can choose digits on odd positions, but can not choose digits on even positions. Breach can choose digits on even positions, but can not choose digits on odd positions. The match ends, when there is only one unmarked digit left. If the single last digit is odd, then Raze wins, else Breach wins. It can be proved, that before the end of the match (for every initial integer with n digits) each agent has an ability to make a turn, i.e. there is at least one unmarked digit, that stands on a position of required parity. For each of t matches find out, which agent wins, if both of them want to win and play optimally. Input First line of input contains an integer t (1 ≀ t ≀ 100) β€” the number of matches. The first line of each match description contains an integer n (1 ≀ n ≀ 10^3) β€” the number of digits of the generated number. The second line of each match description contains an n-digit positive integer without leading zeros. Output For each match print 1, if Raze wins, and 2, if Breach wins. Example Input 4 1 2 1 3 3 102 4 2069 Output 2 1 1 2 Note In the first match no one can make a turn, the only digit left is 2, it's even, so Breach wins. In the second match the only digit left is 3, it's odd, so Raze wins. In the third match Raze can mark the last digit, after that Breach can only mark 0. 1 will be the last digit left, it's odd, so Raze wins. In the fourth match no matter how Raze plays, Breach can mark 9, and in the end there will be digit 0. It's even, so Breach wins. Submitted Solution: ``` # Online Python compiler (interpreter) to run Python online. # Write Python 3 code in this online editor and run it. for _ in range (int(input())): n=int(input()) s=input() if(n%2==0): count=0 for i in s: i=int(i) if(i%2==0): print(2) count=1 break if(count==0): print(1) else: count=0 for i in s: i=int(i) if(i%2!=0): print(1) count=1 break if(count==0): print(2) ```
instruction
0
76,069
19
152,138
No
output
1
76,069
19
152,139
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Everyone knows that agents in Valorant decide, who will play as attackers, and who will play as defenders. To do that Raze and Breach decided to play t matches of a digit game... In each of t matches of the digit game, a positive integer is generated. It consists of n digits. The digits of this integer are numerated from 1 to n from the highest-order digit to the lowest-order digit. After this integer is announced, the match starts. Agents play in turns. Raze starts. In one turn an agent can choose any unmarked digit and mark it. Raze can choose digits on odd positions, but can not choose digits on even positions. Breach can choose digits on even positions, but can not choose digits on odd positions. The match ends, when there is only one unmarked digit left. If the single last digit is odd, then Raze wins, else Breach wins. It can be proved, that before the end of the match (for every initial integer with n digits) each agent has an ability to make a turn, i.e. there is at least one unmarked digit, that stands on a position of required parity. For each of t matches find out, which agent wins, if both of them want to win and play optimally. Input First line of input contains an integer t (1 ≀ t ≀ 100) β€” the number of matches. The first line of each match description contains an integer n (1 ≀ n ≀ 10^3) β€” the number of digits of the generated number. The second line of each match description contains an n-digit positive integer without leading zeros. Output For each match print 1, if Raze wins, and 2, if Breach wins. Example Input 4 1 2 1 3 3 102 4 2069 Output 2 1 1 2 Note In the first match no one can make a turn, the only digit left is 2, it's even, so Breach wins. In the second match the only digit left is 3, it's odd, so Raze wins. In the third match Raze can mark the last digit, after that Breach can only mark 0. 1 will be the last digit left, it's odd, so Raze wins. In the fourth match no matter how Raze plays, Breach can mark 9, and in the end there will be digit 0. It's even, so Breach wins. Submitted Solution: ``` import math t = int(input()) ct = [] digit = [] for i in range(t): ct.append(int(input())) digit.append(list(input())) for i in range(len(digit)): if(ct[i]==1): temp="" if(int(temp.join(digit[i]))%2==0): print('2') else: print('1') else: odd_pos_even_ct = 0 odd_pos_odd_ct = 0 even_pos_even_ct = 0 even_pos_odd_ct = 0 for j in range(len(digit[i])): if((j+1)%2==0): if(int(digit[i][j])%2==0): even_pos_even_ct+=1 else: even_pos_odd_ct+=1 else: if(int(digit[i][j])%2==0): odd_pos_even_ct+=1 else: odd_pos_odd_ct+=1 if((odd_pos_odd_ct+odd_pos_even_ct)<=(even_pos_even_ct+even_pos_odd_ct)): print('2') else: print('1') ```
instruction
0
76,070
19
152,140
No
output
1
76,070
19
152,141
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Everyone knows that agents in Valorant decide, who will play as attackers, and who will play as defenders. To do that Raze and Breach decided to play t matches of a digit game... In each of t matches of the digit game, a positive integer is generated. It consists of n digits. The digits of this integer are numerated from 1 to n from the highest-order digit to the lowest-order digit. After this integer is announced, the match starts. Agents play in turns. Raze starts. In one turn an agent can choose any unmarked digit and mark it. Raze can choose digits on odd positions, but can not choose digits on even positions. Breach can choose digits on even positions, but can not choose digits on odd positions. The match ends, when there is only one unmarked digit left. If the single last digit is odd, then Raze wins, else Breach wins. It can be proved, that before the end of the match (for every initial integer with n digits) each agent has an ability to make a turn, i.e. there is at least one unmarked digit, that stands on a position of required parity. For each of t matches find out, which agent wins, if both of them want to win and play optimally. Input First line of input contains an integer t (1 ≀ t ≀ 100) β€” the number of matches. The first line of each match description contains an integer n (1 ≀ n ≀ 10^3) β€” the number of digits of the generated number. The second line of each match description contains an n-digit positive integer without leading zeros. Output For each match print 1, if Raze wins, and 2, if Breach wins. Example Input 4 1 2 1 3 3 102 4 2069 Output 2 1 1 2 Note In the first match no one can make a turn, the only digit left is 2, it's even, so Breach wins. In the second match the only digit left is 3, it's odd, so Raze wins. In the third match Raze can mark the last digit, after that Breach can only mark 0. 1 will be the last digit left, it's odd, so Raze wins. In the fourth match no matter how Raze plays, Breach can mark 9, and in the end there will be digit 0. It's even, so Breach wins. Submitted Solution: ``` for _ in range(int(input())): l=int(input()) n=input() if(n==1): if(n%2==0): print("2") else: print("1") else: odd,even,epos,opos=0,0,0,0 for i in range(l): num=int(n[i]) if(i%2==0): if(num%2==0): even+=1 epos+=1 else: opos+=1 else: if(num%2==0): even+=1 else: opos+=1 odd+=1 if(opos>epos): print("1") elif(opos<epos): print("2") else: if(even>odd): print("1") elif(even==odd): print("2") else: print("2") ```
instruction
0
76,071
19
152,142
No
output
1
76,071
19
152,143
Provide tags and a correct Python 3 solution for this coding contest problem. Petya and Vasya decided to play a game. They have n cards (n is an even number). A single integer is written on each card. Before the game Petya will choose an integer and after that Vasya will choose another integer (different from the number that Petya chose). During the game each player takes all the cards with number he chose. For example, if Petya chose number 5 before the game he will take all cards on which 5 is written and if Vasya chose number 10 before the game he will take all cards on which 10 is written. The game is considered fair if Petya and Vasya can take all n cards, and the number of cards each player gets is the same. Determine whether Petya and Vasya can choose integer numbers before the game so that the game is fair. Input The first line contains a single integer n (2 ≀ n ≀ 100) β€” number of cards. It is guaranteed that n is an even number. The following n lines contain a sequence of integers a1, a2, ..., an (one integer per line, 1 ≀ ai ≀ 100) β€” numbers written on the n cards. Output If it is impossible for Petya and Vasya to choose numbers in such a way that the game will be fair, print "NO" (without quotes) in the first line. In this case you should not print anything more. In the other case print "YES" (without quotes) in the first line. In the second line print two distinct integers β€” number that Petya should choose and the number that Vasya should choose to make the game fair. If there are several solutions, print any of them. Examples Input 4 11 27 27 11 Output YES 11 27 Input 2 6 6 Output NO Input 6 10 20 30 20 10 20 Output NO Input 6 1 1 2 2 3 3 Output NO Note In the first example the game will be fair if, for example, Petya chooses number 11, and Vasya chooses number 27. Then the will take all cards β€” Petya will take cards 1 and 4, and Vasya will take cards 2 and 3. Thus, each of them will take exactly two cards. In the second example fair game is impossible because the numbers written on the cards are equal, but the numbers that Petya and Vasya should choose should be distinct. In the third example it is impossible to take all cards. Petya and Vasya can take at most five cards β€” for example, Petya can choose number 10 and Vasya can choose number 20. But for the game to be fair it is necessary to take 6 cards.
instruction
0
76,399
19
152,798
Tags: implementation, sortings Correct Solution: ``` from collections import defaultdict d = defaultdict(int) for _ in range(int(input())): d[int(input())] += 1 if len(d.keys()) != 2: print("NO") else: keys = list(d.keys()) if d[keys[0]] != d[keys[1]]: print("NO") else: print("YES") print("%d %d"%(keys[0], keys[1])) ```
output
1
76,399
19
152,799
Provide tags and a correct Python 3 solution for this coding contest problem. Petya and Vasya decided to play a game. They have n cards (n is an even number). A single integer is written on each card. Before the game Petya will choose an integer and after that Vasya will choose another integer (different from the number that Petya chose). During the game each player takes all the cards with number he chose. For example, if Petya chose number 5 before the game he will take all cards on which 5 is written and if Vasya chose number 10 before the game he will take all cards on which 10 is written. The game is considered fair if Petya and Vasya can take all n cards, and the number of cards each player gets is the same. Determine whether Petya and Vasya can choose integer numbers before the game so that the game is fair. Input The first line contains a single integer n (2 ≀ n ≀ 100) β€” number of cards. It is guaranteed that n is an even number. The following n lines contain a sequence of integers a1, a2, ..., an (one integer per line, 1 ≀ ai ≀ 100) β€” numbers written on the n cards. Output If it is impossible for Petya and Vasya to choose numbers in such a way that the game will be fair, print "NO" (without quotes) in the first line. In this case you should not print anything more. In the other case print "YES" (without quotes) in the first line. In the second line print two distinct integers β€” number that Petya should choose and the number that Vasya should choose to make the game fair. If there are several solutions, print any of them. Examples Input 4 11 27 27 11 Output YES 11 27 Input 2 6 6 Output NO Input 6 10 20 30 20 10 20 Output NO Input 6 1 1 2 2 3 3 Output NO Note In the first example the game will be fair if, for example, Petya chooses number 11, and Vasya chooses number 27. Then the will take all cards β€” Petya will take cards 1 and 4, and Vasya will take cards 2 and 3. Thus, each of them will take exactly two cards. In the second example fair game is impossible because the numbers written on the cards are equal, but the numbers that Petya and Vasya should choose should be distinct. In the third example it is impossible to take all cards. Petya and Vasya can take at most five cards β€” for example, Petya can choose number 10 and Vasya can choose number 20. But for the game to be fair it is necessary to take 6 cards.
instruction
0
76,400
19
152,800
Tags: implementation, sortings Correct Solution: ``` n = int(input()); a = []; for i in range(n): a.append(int(input())); a = sorted(a); x = a[0]; y = a[-1]; nb_x = 0; nb_y = 0; for i in range(n): if a[i] == x: nb_x += 1; if a[i] == y: nb_y += 1; if x != y and nb_x == nb_y and nb_x + nb_y == n: print ('YES'); print (x, y); else: print ('NO'); ```
output
1
76,400
19
152,801
Provide tags and a correct Python 3 solution for this coding contest problem. Petya and Vasya decided to play a game. They have n cards (n is an even number). A single integer is written on each card. Before the game Petya will choose an integer and after that Vasya will choose another integer (different from the number that Petya chose). During the game each player takes all the cards with number he chose. For example, if Petya chose number 5 before the game he will take all cards on which 5 is written and if Vasya chose number 10 before the game he will take all cards on which 10 is written. The game is considered fair if Petya and Vasya can take all n cards, and the number of cards each player gets is the same. Determine whether Petya and Vasya can choose integer numbers before the game so that the game is fair. Input The first line contains a single integer n (2 ≀ n ≀ 100) β€” number of cards. It is guaranteed that n is an even number. The following n lines contain a sequence of integers a1, a2, ..., an (one integer per line, 1 ≀ ai ≀ 100) β€” numbers written on the n cards. Output If it is impossible for Petya and Vasya to choose numbers in such a way that the game will be fair, print "NO" (without quotes) in the first line. In this case you should not print anything more. In the other case print "YES" (without quotes) in the first line. In the second line print two distinct integers β€” number that Petya should choose and the number that Vasya should choose to make the game fair. If there are several solutions, print any of them. Examples Input 4 11 27 27 11 Output YES 11 27 Input 2 6 6 Output NO Input 6 10 20 30 20 10 20 Output NO Input 6 1 1 2 2 3 3 Output NO Note In the first example the game will be fair if, for example, Petya chooses number 11, and Vasya chooses number 27. Then the will take all cards β€” Petya will take cards 1 and 4, and Vasya will take cards 2 and 3. Thus, each of them will take exactly two cards. In the second example fair game is impossible because the numbers written on the cards are equal, but the numbers that Petya and Vasya should choose should be distinct. In the third example it is impossible to take all cards. Petya and Vasya can take at most five cards β€” for example, Petya can choose number 10 and Vasya can choose number 20. But for the game to be fair it is necessary to take 6 cards.
instruction
0
76,401
19
152,802
Tags: implementation, sortings Correct Solution: ``` #!/usr/bin/env python3 # -*- coding: utf-8 -*- from collections import Counter def main(): N = int(input()) A = [int(input()) for _ in range(N)] cnt = Counter(A) if len(cnt) != 2: print("NO") return ps = list(cnt.items()) if ps[0][1] != ps[1][1]: print("NO") return print("YES") print(ps[0][0], ps[1][0]) if __name__ == "__main__": main() ```
output
1
76,401
19
152,803
Provide tags and a correct Python 3 solution for this coding contest problem. Petya and Vasya decided to play a game. They have n cards (n is an even number). A single integer is written on each card. Before the game Petya will choose an integer and after that Vasya will choose another integer (different from the number that Petya chose). During the game each player takes all the cards with number he chose. For example, if Petya chose number 5 before the game he will take all cards on which 5 is written and if Vasya chose number 10 before the game he will take all cards on which 10 is written. The game is considered fair if Petya and Vasya can take all n cards, and the number of cards each player gets is the same. Determine whether Petya and Vasya can choose integer numbers before the game so that the game is fair. Input The first line contains a single integer n (2 ≀ n ≀ 100) β€” number of cards. It is guaranteed that n is an even number. The following n lines contain a sequence of integers a1, a2, ..., an (one integer per line, 1 ≀ ai ≀ 100) β€” numbers written on the n cards. Output If it is impossible for Petya and Vasya to choose numbers in such a way that the game will be fair, print "NO" (without quotes) in the first line. In this case you should not print anything more. In the other case print "YES" (without quotes) in the first line. In the second line print two distinct integers β€” number that Petya should choose and the number that Vasya should choose to make the game fair. If there are several solutions, print any of them. Examples Input 4 11 27 27 11 Output YES 11 27 Input 2 6 6 Output NO Input 6 10 20 30 20 10 20 Output NO Input 6 1 1 2 2 3 3 Output NO Note In the first example the game will be fair if, for example, Petya chooses number 11, and Vasya chooses number 27. Then the will take all cards β€” Petya will take cards 1 and 4, and Vasya will take cards 2 and 3. Thus, each of them will take exactly two cards. In the second example fair game is impossible because the numbers written on the cards are equal, but the numbers that Petya and Vasya should choose should be distinct. In the third example it is impossible to take all cards. Petya and Vasya can take at most five cards β€” for example, Petya can choose number 10 and Vasya can choose number 20. But for the game to be fair it is necessary to take 6 cards.
instruction
0
76,402
19
152,804
Tags: implementation, sortings Correct Solution: ``` cardnum = int(input()) card = [] card_dict = {} for i in range(cardnum): cardPoint = int(input()) #card.append(cardPoint) card_dict[cardPoint] = card_dict.get(cardPoint, 0 ) + 1 if( len(card_dict) > 2 ): print("NO") else: point_dict = {} for k, v in card_dict.items(): if point_dict.get(v, 0) > 0: print("YES") print(point_dict[v],k) break; point_dict[v] = k; else: print("NO") ```
output
1
76,402
19
152,805
Provide tags and a correct Python 3 solution for this coding contest problem. Petya and Vasya decided to play a game. They have n cards (n is an even number). A single integer is written on each card. Before the game Petya will choose an integer and after that Vasya will choose another integer (different from the number that Petya chose). During the game each player takes all the cards with number he chose. For example, if Petya chose number 5 before the game he will take all cards on which 5 is written and if Vasya chose number 10 before the game he will take all cards on which 10 is written. The game is considered fair if Petya and Vasya can take all n cards, and the number of cards each player gets is the same. Determine whether Petya and Vasya can choose integer numbers before the game so that the game is fair. Input The first line contains a single integer n (2 ≀ n ≀ 100) β€” number of cards. It is guaranteed that n is an even number. The following n lines contain a sequence of integers a1, a2, ..., an (one integer per line, 1 ≀ ai ≀ 100) β€” numbers written on the n cards. Output If it is impossible for Petya and Vasya to choose numbers in such a way that the game will be fair, print "NO" (without quotes) in the first line. In this case you should not print anything more. In the other case print "YES" (without quotes) in the first line. In the second line print two distinct integers β€” number that Petya should choose and the number that Vasya should choose to make the game fair. If there are several solutions, print any of them. Examples Input 4 11 27 27 11 Output YES 11 27 Input 2 6 6 Output NO Input 6 10 20 30 20 10 20 Output NO Input 6 1 1 2 2 3 3 Output NO Note In the first example the game will be fair if, for example, Petya chooses number 11, and Vasya chooses number 27. Then the will take all cards β€” Petya will take cards 1 and 4, and Vasya will take cards 2 and 3. Thus, each of them will take exactly two cards. In the second example fair game is impossible because the numbers written on the cards are equal, but the numbers that Petya and Vasya should choose should be distinct. In the third example it is impossible to take all cards. Petya and Vasya can take at most five cards β€” for example, Petya can choose number 10 and Vasya can choose number 20. But for the game to be fair it is necessary to take 6 cards.
instruction
0
76,403
19
152,806
Tags: implementation, sortings Correct Solution: ``` from collections import Counter ar = [] for t in range(int(input())): i = int(input()) ar.append(i) c = Counter(ar) ar = c.most_common(len(c)) if(len(ar)>2 or len(ar)==1): print('NO') else: if(ar[0][1]==ar[1][1]): print("YES") for i in ar: print(i[0]) else: print("NO") ```
output
1
76,403
19
152,807
Provide tags and a correct Python 3 solution for this coding contest problem. Petya and Vasya decided to play a game. They have n cards (n is an even number). A single integer is written on each card. Before the game Petya will choose an integer and after that Vasya will choose another integer (different from the number that Petya chose). During the game each player takes all the cards with number he chose. For example, if Petya chose number 5 before the game he will take all cards on which 5 is written and if Vasya chose number 10 before the game he will take all cards on which 10 is written. The game is considered fair if Petya and Vasya can take all n cards, and the number of cards each player gets is the same. Determine whether Petya and Vasya can choose integer numbers before the game so that the game is fair. Input The first line contains a single integer n (2 ≀ n ≀ 100) β€” number of cards. It is guaranteed that n is an even number. The following n lines contain a sequence of integers a1, a2, ..., an (one integer per line, 1 ≀ ai ≀ 100) β€” numbers written on the n cards. Output If it is impossible for Petya and Vasya to choose numbers in such a way that the game will be fair, print "NO" (without quotes) in the first line. In this case you should not print anything more. In the other case print "YES" (without quotes) in the first line. In the second line print two distinct integers β€” number that Petya should choose and the number that Vasya should choose to make the game fair. If there are several solutions, print any of them. Examples Input 4 11 27 27 11 Output YES 11 27 Input 2 6 6 Output NO Input 6 10 20 30 20 10 20 Output NO Input 6 1 1 2 2 3 3 Output NO Note In the first example the game will be fair if, for example, Petya chooses number 11, and Vasya chooses number 27. Then the will take all cards β€” Petya will take cards 1 and 4, and Vasya will take cards 2 and 3. Thus, each of them will take exactly two cards. In the second example fair game is impossible because the numbers written on the cards are equal, but the numbers that Petya and Vasya should choose should be distinct. In the third example it is impossible to take all cards. Petya and Vasya can take at most five cards β€” for example, Petya can choose number 10 and Vasya can choose number 20. But for the game to be fair it is necessary to take 6 cards.
instruction
0
76,404
19
152,808
Tags: implementation, sortings Correct Solution: ``` n=int(input()) b=[] for i in range(n): c=int(input()) b.append(c) b.sort() if n==2: if b[0]!=b[-1]: print("YES") print(b[0],b[-1]) else: print("NO") elif b[0]==b[(n//2)-1] and b[n//2]==b[-1]: if b[0]!=b[-1]: print("YES") print(b[0],b[-1]) else: print("NO") else: print("NO") ```
output
1
76,404
19
152,809
Provide tags and a correct Python 3 solution for this coding contest problem. Petya and Vasya decided to play a game. They have n cards (n is an even number). A single integer is written on each card. Before the game Petya will choose an integer and after that Vasya will choose another integer (different from the number that Petya chose). During the game each player takes all the cards with number he chose. For example, if Petya chose number 5 before the game he will take all cards on which 5 is written and if Vasya chose number 10 before the game he will take all cards on which 10 is written. The game is considered fair if Petya and Vasya can take all n cards, and the number of cards each player gets is the same. Determine whether Petya and Vasya can choose integer numbers before the game so that the game is fair. Input The first line contains a single integer n (2 ≀ n ≀ 100) β€” number of cards. It is guaranteed that n is an even number. The following n lines contain a sequence of integers a1, a2, ..., an (one integer per line, 1 ≀ ai ≀ 100) β€” numbers written on the n cards. Output If it is impossible for Petya and Vasya to choose numbers in such a way that the game will be fair, print "NO" (without quotes) in the first line. In this case you should not print anything more. In the other case print "YES" (without quotes) in the first line. In the second line print two distinct integers β€” number that Petya should choose and the number that Vasya should choose to make the game fair. If there are several solutions, print any of them. Examples Input 4 11 27 27 11 Output YES 11 27 Input 2 6 6 Output NO Input 6 10 20 30 20 10 20 Output NO Input 6 1 1 2 2 3 3 Output NO Note In the first example the game will be fair if, for example, Petya chooses number 11, and Vasya chooses number 27. Then the will take all cards β€” Petya will take cards 1 and 4, and Vasya will take cards 2 and 3. Thus, each of them will take exactly two cards. In the second example fair game is impossible because the numbers written on the cards are equal, but the numbers that Petya and Vasya should choose should be distinct. In the third example it is impossible to take all cards. Petya and Vasya can take at most five cards β€” for example, Petya can choose number 10 and Vasya can choose number 20. But for the game to be fair it is necessary to take 6 cards.
instruction
0
76,405
19
152,810
Tags: implementation, sortings Correct Solution: ``` n=int(input()) a=[] for i in range(n): a.append(int(input())) a=sorted(a) b=a[0:int(n//2)] c=a[n//2:n] d=True if b[0]==c[0]: d=False else: for i in range(1,n//2): if b[i]!=b[0] or c[i]!=c[0]: d=False if d: print("YES") print(b[0],c[0]) else: print("NO") ```
output
1
76,405
19
152,811
Provide tags and a correct Python 3 solution for this coding contest problem. Petya and Vasya decided to play a game. They have n cards (n is an even number). A single integer is written on each card. Before the game Petya will choose an integer and after that Vasya will choose another integer (different from the number that Petya chose). During the game each player takes all the cards with number he chose. For example, if Petya chose number 5 before the game he will take all cards on which 5 is written and if Vasya chose number 10 before the game he will take all cards on which 10 is written. The game is considered fair if Petya and Vasya can take all n cards, and the number of cards each player gets is the same. Determine whether Petya and Vasya can choose integer numbers before the game so that the game is fair. Input The first line contains a single integer n (2 ≀ n ≀ 100) β€” number of cards. It is guaranteed that n is an even number. The following n lines contain a sequence of integers a1, a2, ..., an (one integer per line, 1 ≀ ai ≀ 100) β€” numbers written on the n cards. Output If it is impossible for Petya and Vasya to choose numbers in such a way that the game will be fair, print "NO" (without quotes) in the first line. In this case you should not print anything more. In the other case print "YES" (without quotes) in the first line. In the second line print two distinct integers β€” number that Petya should choose and the number that Vasya should choose to make the game fair. If there are several solutions, print any of them. Examples Input 4 11 27 27 11 Output YES 11 27 Input 2 6 6 Output NO Input 6 10 20 30 20 10 20 Output NO Input 6 1 1 2 2 3 3 Output NO Note In the first example the game will be fair if, for example, Petya chooses number 11, and Vasya chooses number 27. Then the will take all cards β€” Petya will take cards 1 and 4, and Vasya will take cards 2 and 3. Thus, each of them will take exactly two cards. In the second example fair game is impossible because the numbers written on the cards are equal, but the numbers that Petya and Vasya should choose should be distinct. In the third example it is impossible to take all cards. Petya and Vasya can take at most five cards β€” for example, Petya can choose number 10 and Vasya can choose number 20. But for the game to be fair it is necessary to take 6 cards.
instruction
0
76,406
19
152,812
Tags: implementation, sortings Correct Solution: ``` num = int(input()) cards = [] for i in range(num): cards.append(int(input())) cards.sort() dif = 1 idx = 0 out = [] for i in range(1, num): if cards[i] != cards[i - 1]: dif += 1 idx = i out.append(cards[i - 1]) out.append(cards[i]) if dif != 2: print("NO") else: if idx * 2 == num: print("YES") for i in out: print(i, end=' ') else: print("NO") ```
output
1
76,406
19
152,813
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya and Vasya decided to play a game. They have n cards (n is an even number). A single integer is written on each card. Before the game Petya will choose an integer and after that Vasya will choose another integer (different from the number that Petya chose). During the game each player takes all the cards with number he chose. For example, if Petya chose number 5 before the game he will take all cards on which 5 is written and if Vasya chose number 10 before the game he will take all cards on which 10 is written. The game is considered fair if Petya and Vasya can take all n cards, and the number of cards each player gets is the same. Determine whether Petya and Vasya can choose integer numbers before the game so that the game is fair. Input The first line contains a single integer n (2 ≀ n ≀ 100) β€” number of cards. It is guaranteed that n is an even number. The following n lines contain a sequence of integers a1, a2, ..., an (one integer per line, 1 ≀ ai ≀ 100) β€” numbers written on the n cards. Output If it is impossible for Petya and Vasya to choose numbers in such a way that the game will be fair, print "NO" (without quotes) in the first line. In this case you should not print anything more. In the other case print "YES" (without quotes) in the first line. In the second line print two distinct integers β€” number that Petya should choose and the number that Vasya should choose to make the game fair. If there are several solutions, print any of them. Examples Input 4 11 27 27 11 Output YES 11 27 Input 2 6 6 Output NO Input 6 10 20 30 20 10 20 Output NO Input 6 1 1 2 2 3 3 Output NO Note In the first example the game will be fair if, for example, Petya chooses number 11, and Vasya chooses number 27. Then the will take all cards β€” Petya will take cards 1 and 4, and Vasya will take cards 2 and 3. Thus, each of them will take exactly two cards. In the second example fair game is impossible because the numbers written on the cards are equal, but the numbers that Petya and Vasya should choose should be distinct. In the third example it is impossible to take all cards. Petya and Vasya can take at most five cards β€” for example, Petya can choose number 10 and Vasya can choose number 20. But for the game to be fair it is necessary to take 6 cards. Submitted Solution: ``` n, a = int(input()), [] for i in range(n): a.append(int(input())); a.sort(); if (a[0]!=a[-1]) and (a.count(a[0])==a.count(a[-1])) and (a.count(a[0])*2==n): print ('YES') print (a[0], a[-1]) else: print ('NO'); ```
instruction
0
76,407
19
152,814
Yes
output
1
76,407
19
152,815
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya and Vasya decided to play a game. They have n cards (n is an even number). A single integer is written on each card. Before the game Petya will choose an integer and after that Vasya will choose another integer (different from the number that Petya chose). During the game each player takes all the cards with number he chose. For example, if Petya chose number 5 before the game he will take all cards on which 5 is written and if Vasya chose number 10 before the game he will take all cards on which 10 is written. The game is considered fair if Petya and Vasya can take all n cards, and the number of cards each player gets is the same. Determine whether Petya and Vasya can choose integer numbers before the game so that the game is fair. Input The first line contains a single integer n (2 ≀ n ≀ 100) β€” number of cards. It is guaranteed that n is an even number. The following n lines contain a sequence of integers a1, a2, ..., an (one integer per line, 1 ≀ ai ≀ 100) β€” numbers written on the n cards. Output If it is impossible for Petya and Vasya to choose numbers in such a way that the game will be fair, print "NO" (without quotes) in the first line. In this case you should not print anything more. In the other case print "YES" (without quotes) in the first line. In the second line print two distinct integers β€” number that Petya should choose and the number that Vasya should choose to make the game fair. If there are several solutions, print any of them. Examples Input 4 11 27 27 11 Output YES 11 27 Input 2 6 6 Output NO Input 6 10 20 30 20 10 20 Output NO Input 6 1 1 2 2 3 3 Output NO Note In the first example the game will be fair if, for example, Petya chooses number 11, and Vasya chooses number 27. Then the will take all cards β€” Petya will take cards 1 and 4, and Vasya will take cards 2 and 3. Thus, each of them will take exactly two cards. In the second example fair game is impossible because the numbers written on the cards are equal, but the numbers that Petya and Vasya should choose should be distinct. In the third example it is impossible to take all cards. Petya and Vasya can take at most five cards β€” for example, Petya can choose number 10 and Vasya can choose number 20. But for the game to be fair it is necessary to take 6 cards. Submitted Solution: ``` # Main maut ko takiya, aur kafan ko chaadar banakar audhta hoon! n=int(input()) a=[] for i in range(n): a.append(int(input())) a=sorted(a) if(a.count(a[0])==a.count(a[n-1])==n/2): print("YES") print(a[0],a[n-1]) else: print("NO") ```
instruction
0
76,408
19
152,816
Yes
output
1
76,408
19
152,817
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya and Vasya decided to play a game. They have n cards (n is an even number). A single integer is written on each card. Before the game Petya will choose an integer and after that Vasya will choose another integer (different from the number that Petya chose). During the game each player takes all the cards with number he chose. For example, if Petya chose number 5 before the game he will take all cards on which 5 is written and if Vasya chose number 10 before the game he will take all cards on which 10 is written. The game is considered fair if Petya and Vasya can take all n cards, and the number of cards each player gets is the same. Determine whether Petya and Vasya can choose integer numbers before the game so that the game is fair. Input The first line contains a single integer n (2 ≀ n ≀ 100) β€” number of cards. It is guaranteed that n is an even number. The following n lines contain a sequence of integers a1, a2, ..., an (one integer per line, 1 ≀ ai ≀ 100) β€” numbers written on the n cards. Output If it is impossible for Petya and Vasya to choose numbers in such a way that the game will be fair, print "NO" (without quotes) in the first line. In this case you should not print anything more. In the other case print "YES" (without quotes) in the first line. In the second line print two distinct integers β€” number that Petya should choose and the number that Vasya should choose to make the game fair. If there are several solutions, print any of them. Examples Input 4 11 27 27 11 Output YES 11 27 Input 2 6 6 Output NO Input 6 10 20 30 20 10 20 Output NO Input 6 1 1 2 2 3 3 Output NO Note In the first example the game will be fair if, for example, Petya chooses number 11, and Vasya chooses number 27. Then the will take all cards β€” Petya will take cards 1 and 4, and Vasya will take cards 2 and 3. Thus, each of them will take exactly two cards. In the second example fair game is impossible because the numbers written on the cards are equal, but the numbers that Petya and Vasya should choose should be distinct. In the third example it is impossible to take all cards. Petya and Vasya can take at most five cards β€” for example, Petya can choose number 10 and Vasya can choose number 20. But for the game to be fair it is necessary to take 6 cards. Submitted Solution: ``` from collections import Counter n=int(input()) arr=[] for i in range(n): arr.append(int(input())) ctr=Counter(arr) if len(ctr)==2 : c=[] ind=[] for i in ctr: c.append(ctr[i]) ind.append(i) if c[0]==c[1]: print("YES") print(ind[0],ind[1]) else: print("NO") else: print("NO") ```
instruction
0
76,409
19
152,818
Yes
output
1
76,409
19
152,819
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya and Vasya decided to play a game. They have n cards (n is an even number). A single integer is written on each card. Before the game Petya will choose an integer and after that Vasya will choose another integer (different from the number that Petya chose). During the game each player takes all the cards with number he chose. For example, if Petya chose number 5 before the game he will take all cards on which 5 is written and if Vasya chose number 10 before the game he will take all cards on which 10 is written. The game is considered fair if Petya and Vasya can take all n cards, and the number of cards each player gets is the same. Determine whether Petya and Vasya can choose integer numbers before the game so that the game is fair. Input The first line contains a single integer n (2 ≀ n ≀ 100) β€” number of cards. It is guaranteed that n is an even number. The following n lines contain a sequence of integers a1, a2, ..., an (one integer per line, 1 ≀ ai ≀ 100) β€” numbers written on the n cards. Output If it is impossible for Petya and Vasya to choose numbers in such a way that the game will be fair, print "NO" (without quotes) in the first line. In this case you should not print anything more. In the other case print "YES" (without quotes) in the first line. In the second line print two distinct integers β€” number that Petya should choose and the number that Vasya should choose to make the game fair. If there are several solutions, print any of them. Examples Input 4 11 27 27 11 Output YES 11 27 Input 2 6 6 Output NO Input 6 10 20 30 20 10 20 Output NO Input 6 1 1 2 2 3 3 Output NO Note In the first example the game will be fair if, for example, Petya chooses number 11, and Vasya chooses number 27. Then the will take all cards β€” Petya will take cards 1 and 4, and Vasya will take cards 2 and 3. Thus, each of them will take exactly two cards. In the second example fair game is impossible because the numbers written on the cards are equal, but the numbers that Petya and Vasya should choose should be distinct. In the third example it is impossible to take all cards. Petya and Vasya can take at most five cards β€” for example, Petya can choose number 10 and Vasya can choose number 20. But for the game to be fair it is necessary to take 6 cards. Submitted Solution: ``` n=int(input()) l=[] l1=[] for i in range(n): x=int(input()) l1.append(x) if (x not in l): l.append(x) length=len(l) if (length!=2): print ('NO') else: a=l[0] b=l[1] c1=0 c2=0 for i in range(n): if (l1[i]==a): c1+=1 if (l1[i]==b): c2+=1 if (c1==c2): print ('YES', end="\n") print (a,b) else: print ('NO') ```
instruction
0
76,410
19
152,820
Yes
output
1
76,410
19
152,821
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya and Vasya decided to play a game. They have n cards (n is an even number). A single integer is written on each card. Before the game Petya will choose an integer and after that Vasya will choose another integer (different from the number that Petya chose). During the game each player takes all the cards with number he chose. For example, if Petya chose number 5 before the game he will take all cards on which 5 is written and if Vasya chose number 10 before the game he will take all cards on which 10 is written. The game is considered fair if Petya and Vasya can take all n cards, and the number of cards each player gets is the same. Determine whether Petya and Vasya can choose integer numbers before the game so that the game is fair. Input The first line contains a single integer n (2 ≀ n ≀ 100) β€” number of cards. It is guaranteed that n is an even number. The following n lines contain a sequence of integers a1, a2, ..., an (one integer per line, 1 ≀ ai ≀ 100) β€” numbers written on the n cards. Output If it is impossible for Petya and Vasya to choose numbers in such a way that the game will be fair, print "NO" (without quotes) in the first line. In this case you should not print anything more. In the other case print "YES" (without quotes) in the first line. In the second line print two distinct integers β€” number that Petya should choose and the number that Vasya should choose to make the game fair. If there are several solutions, print any of them. Examples Input 4 11 27 27 11 Output YES 11 27 Input 2 6 6 Output NO Input 6 10 20 30 20 10 20 Output NO Input 6 1 1 2 2 3 3 Output NO Note In the first example the game will be fair if, for example, Petya chooses number 11, and Vasya chooses number 27. Then the will take all cards β€” Petya will take cards 1 and 4, and Vasya will take cards 2 and 3. Thus, each of them will take exactly two cards. In the second example fair game is impossible because the numbers written on the cards are equal, but the numbers that Petya and Vasya should choose should be distinct. In the third example it is impossible to take all cards. Petya and Vasya can take at most five cards β€” for example, Petya can choose number 10 and Vasya can choose number 20. But for the game to be fair it is necessary to take 6 cards. Submitted Solution: ``` t = int(input()) a = [] for _ in range(t): n = int(input()) a.append(n) if len(set(a)) == 2: print('YES') for i in set(a): print(i,end=' ') else: print('NO') ```
instruction
0
76,411
19
152,822
No
output
1
76,411
19
152,823
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya and Vasya decided to play a game. They have n cards (n is an even number). A single integer is written on each card. Before the game Petya will choose an integer and after that Vasya will choose another integer (different from the number that Petya chose). During the game each player takes all the cards with number he chose. For example, if Petya chose number 5 before the game he will take all cards on which 5 is written and if Vasya chose number 10 before the game he will take all cards on which 10 is written. The game is considered fair if Petya and Vasya can take all n cards, and the number of cards each player gets is the same. Determine whether Petya and Vasya can choose integer numbers before the game so that the game is fair. Input The first line contains a single integer n (2 ≀ n ≀ 100) β€” number of cards. It is guaranteed that n is an even number. The following n lines contain a sequence of integers a1, a2, ..., an (one integer per line, 1 ≀ ai ≀ 100) β€” numbers written on the n cards. Output If it is impossible for Petya and Vasya to choose numbers in such a way that the game will be fair, print "NO" (without quotes) in the first line. In this case you should not print anything more. In the other case print "YES" (without quotes) in the first line. In the second line print two distinct integers β€” number that Petya should choose and the number that Vasya should choose to make the game fair. If there are several solutions, print any of them. Examples Input 4 11 27 27 11 Output YES 11 27 Input 2 6 6 Output NO Input 6 10 20 30 20 10 20 Output NO Input 6 1 1 2 2 3 3 Output NO Note In the first example the game will be fair if, for example, Petya chooses number 11, and Vasya chooses number 27. Then the will take all cards β€” Petya will take cards 1 and 4, and Vasya will take cards 2 and 3. Thus, each of them will take exactly two cards. In the second example fair game is impossible because the numbers written on the cards are equal, but the numbers that Petya and Vasya should choose should be distinct. In the third example it is impossible to take all cards. Petya and Vasya can take at most five cards β€” for example, Petya can choose number 10 and Vasya can choose number 20. But for the game to be fair it is necessary to take 6 cards. Submitted Solution: ``` num = int(input()) n1 = int(input()) n11 = 0 n2 = int(input()) n22 = 0 for i in range((num)-2): n3 = int(input()) if n3 == n2: n22 += 1 elif n3 == n1: n11 += 1 if n1 == n2: print('NO') elif n11 == n22 and (n11 + n22) == (num-2): print('YES') print(f'{n1} {n2}') else: print('NO') ```
instruction
0
76,412
19
152,824
No
output
1
76,412
19
152,825
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya and Vasya decided to play a game. They have n cards (n is an even number). A single integer is written on each card. Before the game Petya will choose an integer and after that Vasya will choose another integer (different from the number that Petya chose). During the game each player takes all the cards with number he chose. For example, if Petya chose number 5 before the game he will take all cards on which 5 is written and if Vasya chose number 10 before the game he will take all cards on which 10 is written. The game is considered fair if Petya and Vasya can take all n cards, and the number of cards each player gets is the same. Determine whether Petya and Vasya can choose integer numbers before the game so that the game is fair. Input The first line contains a single integer n (2 ≀ n ≀ 100) β€” number of cards. It is guaranteed that n is an even number. The following n lines contain a sequence of integers a1, a2, ..., an (one integer per line, 1 ≀ ai ≀ 100) β€” numbers written on the n cards. Output If it is impossible for Petya and Vasya to choose numbers in such a way that the game will be fair, print "NO" (without quotes) in the first line. In this case you should not print anything more. In the other case print "YES" (without quotes) in the first line. In the second line print two distinct integers β€” number that Petya should choose and the number that Vasya should choose to make the game fair. If there are several solutions, print any of them. Examples Input 4 11 27 27 11 Output YES 11 27 Input 2 6 6 Output NO Input 6 10 20 30 20 10 20 Output NO Input 6 1 1 2 2 3 3 Output NO Note In the first example the game will be fair if, for example, Petya chooses number 11, and Vasya chooses number 27. Then the will take all cards β€” Petya will take cards 1 and 4, and Vasya will take cards 2 and 3. Thus, each of them will take exactly two cards. In the second example fair game is impossible because the numbers written on the cards are equal, but the numbers that Petya and Vasya should choose should be distinct. In the third example it is impossible to take all cards. Petya and Vasya can take at most five cards β€” for example, Petya can choose number 10 and Vasya can choose number 20. But for the game to be fair it is necessary to take 6 cards. Submitted Solution: ``` size = int(input()) array = [] for i in range(size): array += [int(input())] setted = set(array) if (len(setted) % 2 == 0): print("YES") for i in setted: print(i, end=' ') else: print("NO") ```
instruction
0
76,413
19
152,826
No
output
1
76,413
19
152,827
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Petya and Vasya decided to play a game. They have n cards (n is an even number). A single integer is written on each card. Before the game Petya will choose an integer and after that Vasya will choose another integer (different from the number that Petya chose). During the game each player takes all the cards with number he chose. For example, if Petya chose number 5 before the game he will take all cards on which 5 is written and if Vasya chose number 10 before the game he will take all cards on which 10 is written. The game is considered fair if Petya and Vasya can take all n cards, and the number of cards each player gets is the same. Determine whether Petya and Vasya can choose integer numbers before the game so that the game is fair. Input The first line contains a single integer n (2 ≀ n ≀ 100) β€” number of cards. It is guaranteed that n is an even number. The following n lines contain a sequence of integers a1, a2, ..., an (one integer per line, 1 ≀ ai ≀ 100) β€” numbers written on the n cards. Output If it is impossible for Petya and Vasya to choose numbers in such a way that the game will be fair, print "NO" (without quotes) in the first line. In this case you should not print anything more. In the other case print "YES" (without quotes) in the first line. In the second line print two distinct integers β€” number that Petya should choose and the number that Vasya should choose to make the game fair. If there are several solutions, print any of them. Examples Input 4 11 27 27 11 Output YES 11 27 Input 2 6 6 Output NO Input 6 10 20 30 20 10 20 Output NO Input 6 1 1 2 2 3 3 Output NO Note In the first example the game will be fair if, for example, Petya chooses number 11, and Vasya chooses number 27. Then the will take all cards β€” Petya will take cards 1 and 4, and Vasya will take cards 2 and 3. Thus, each of them will take exactly two cards. In the second example fair game is impossible because the numbers written on the cards are equal, but the numbers that Petya and Vasya should choose should be distinct. In the third example it is impossible to take all cards. Petya and Vasya can take at most five cards β€” for example, Petya can choose number 10 and Vasya can choose number 20. But for the game to be fair it is necessary to take 6 cards. Submitted Solution: ``` n=int(input()) l=[] for i in range(n): x=input() l.append(x) l=set(l) l=list(l) if len(l)%2==0: print('YES') print(l[0],l[1]) else: print('NO') ```
instruction
0
76,414
19
152,828
No
output
1
76,414
19
152,829
Provide a correct Python 3 solution for this coding contest problem. I came to the summer festival with the elementary school students in my neighborhood. To put it bluntly, it plays the role of a guardian, but the smell of yakisoba and takoyaki in the store, and the sound of fireworks that can be heard from time to time, are still exciting even at this age. But today I have to keep an eye on the curious children so they don't get lost. The children seemed to be interested in opening a store. When I looked into it, I was supposed to play a game using dice with the uncle who opened the store, and if I win, I would get a prize. The game is a simple one called High & Low. Participants and uncles roll one dice each, but before that, participants predict whether their rolls will be greater or lesser than their uncle's rolls. If the prediction is correct, it is a victory, and if the same result is rolled, both roll the dice again. The tricky part of this game is that the dice of the participants and the dice of the uncle may be different. Participants can see the development of both dice in advance, so they can expect it as a hint. In other words, it's a simple probability calculation. However, the probability is in the range of high school mathematics, and it may be a little heavy for elementary school students. Even the most clever of the kids are thinking, shaking their braided hair. I'll be asking for help soon. By the way, let's show you something that seems to be an adult once in a while. Input The input consists of multiple cases. In each case, a development of the dice is given in a 21x57 grid. The first 21x28 ((0,0) is the upper left, (20,27) is the lower right) grid represents the participants' dice. The last 21x28 ((0,29) is the upper left, (20,56) is the lower right) represents the uncle's dice. Each side of the participant's dice is 7x7 with (0,7), (7,0), (7,7), (7,14), (7,21), (14,7) as the upper left. Given in the subgrid of. The numbers written on the development drawing are the original numbers. Flip horizontal Flip left and right, then rotate 90 degrees counterclockwise Flip horizontal Flip left and right, then rotate 270 degrees counterclockwise Flip horizontal Flip upside down, then flip left and right It was made to do. Each side of the uncle's dice is 7x7 with (0,36), (7,29), (7,36), (7,43), (7,50), (14,36) as the upper left. Given in the subgrid. The numbers on the uncle's dice development are drawn according to the same rules as the participants' dice. One of 1 to 9 is written on each side of the dice. The numbers are given in a 7x7 grid like this: ..... # ... |. # ..... # ... |. # ..-.. # ..-.. # ... |. # ..-.. # . | ... # ..-.. # ..-.. # ... |. # ..-.. # ... |. # ..-.. # ..... # . |. |. # ..-.. # ... |. # ..... # ..-.. # . | ... # ..-.. # ... |. # ..-.. # ..-.. # . | ... # ..-.. # . |. |. # ..-.. # ..-.. # ... |. # ..... # ... |. # ..... # ..-.. # . |. |. # ..-.. # . |. |. # ..-.. # ..-.. # . |. |. # ..-.. # ... |. # ..-.. # However, when the above numbers are rotated 90 degrees or 270 degrees, the "|" and "-" are interchanged. The end of the input is given by a single 0 line The dice given as input are always correct. Also, dice that cannot be settled are not given. Output Output the one with the higher probability in one line when it becomes "HIGH" and when it becomes "LOW". If both probabilities are the same, output "HIGH". Examples Input .......#######......................#######.............. .......#.....#......................#..-..#.............. .......#.|...#......................#.|.|.#.............. .......#.....#......................#..-..#.............. .......#.|...#......................#.|...#.............. .......#..-..#......................#..-..#.............. .......#######......................#######.............. ############################.############################ #.....##..-..##.....##..-..#.#.....##..-..##.....##..-..# #.-.-.##...|.##.-.-.##.|.|.#.#.....##.|.|.##.-.-.##.|.|.# #|.|.|##..-..##|.|.|##..-..#.#....|##..-..##|.|.|##..-..# #...-.##.|...##...-.##.|.|.#.#.-.-.##.|...##...-.##.|...# #.....##..-..##.....##..-..#.#.....##..-..##.....##..-..# ############################.############################ .......#######......................#######.............. .......#..-..#......................#..-..#.............. .......#.|...#......................#.|...#.............. .......#..-..#......................#..-..#.............. .......#.|.|.#......................#...|.#.............. .......#..-..#......................#..-..#.............. .......#######......................#######.............. .......#######......................#######.............. .......#..-..#......................#..-..#.............. .......#.|...#......................#...|.#.............. .......#..-..#......................#..-..#.............. .......#...|.#......................#.|.|.#.............. .......#..-..#......................#..-..#.............. .......#######......................#######.............. ############################.############################ #.....##..-..##.....##..-..#.#.....##..-..##.....##..-..# #.-.-.##...|.##.-.-.##.|.|.#.#...-.##...|.##.-...##.|.|.# #|.|.|##..-..##|.|.|##..-..#.#|.|.|##..-..##|.|.|##..-..# #.-.-.##.|...##...-.##.|...#.#.-...##.|.|.##.-.-.##.|...# #.....##..-..##.....##..-..#.#.....##..-..##.....##..-..# ############################.############################ .......#######......................#######.............. .......#..-..#......................#..-..#.............. .......#...|.#......................#.|...#.............. .......#..-..#......................#..-..#.............. .......#.|...#......................#...|.#.............. .......#..-..#......................#..-..#.............. .......#######......................#######.............. .......#######......................#######.............. .......#..-..#......................#..-..#.............. .......#.|...#......................#.|.|.#.............. .......#..-..#......................#..-..#.............. .......#...|.#......................#.|...#.............. .......#..-..#......................#..-..#.............. .......#######......................#######.............. ############################.############################ #.....##..-..##.....##..-..#.#.....##..-..##.....##.....# #.-.-.##.|.|.##.-.-.##...|.#.#.....##.|.|.##...-.##.|...# #|.|.|##..-..##|....##..-..#.#....|##..-..##|.|.|##.....# #.-.-.##.|.|.##.....##.|.|.#.#.-.-.##.|.|.##.-...##.|...# #.....##..-..##.....##..-..#.#.....##..-..##.....##..-..# ############################.############################ .......#######......................#######.............. .......#..-..#......................#..-..#.............. .......#.|.|.#......................#.|...#.............. .......#..-..#......................#..-..#.............. .......#...|.#......................#...|.#.............. .......#..-..#......................#..-..#.............. .......#######......................#######.............. .......#######......................#######.............. .......#..-..#......................#..-..#.............. .......#.|...#......................#.|.|.#.............. .......#..-..#......................#..-..#.............. .......#...|.#......................#.|...#.............. .......#..-..#......................#..-..#.............. .......#######......................#######.............. ############################.############################ #.....##..-..##.....##..-..#.#.....##..-..##.....##..-..# #.-.-.##...|.##.-.-.##.|.|.#.#.-...##.|.|.##.-...##.|.|.# #|.|.|##..-..##|.|.|##..-..#.#|.|.|##..-..##|.|.|##..-..# #...-.##.|...##.-.-.##.|.|.#.#.-.-.##.|...##.-.-.##.|.|.# #.....##..-..##.....##..-..#.#.....##..-..##.....##..-..# ############################.############################ .......#######......................#######.............. .......#..-..#......................#..-..#.............. .......#...|.#......................#.|.|.#.............. .......#..-..#......................#..-..#.............. .......#.|...#......................#...|.#.............. .......#..-..#......................#..-..#.............. .......#######......................#######.............. 0 Output LOW HIGH HIGH LOW Input .......#######......................#######.............. .......#.....#......................#..-..#.............. .......#.|...#......................#.|.|.#.............. .......#.....#......................#..-..#.............. .......#.|...#......................#.|...#.............. .......#..-..#......................#..-..#.............. .......#######......................#######.............. .############################ .....##..-..##.....##..-..#.#.....##..-..##.....##..-..# .-.-.##...|.##.-.-.##.|.|.#.#.....##.|.|.##.-.-.##.|.|.# |.|.|##..-..##|.|.|##..-..#.#....|##..-..##|.|.|##..-..# ...-.##.|...##...-.##.|.|.#.#.-.-.##.|...##...-.##.|...# .....##..-..##.....##..-..#.#.....##..-..##.....##..-..# .############################ .......#######......................#######.............. .......#..-..#......................#..-..#.............. .......#.|...#......................#.|...#.............. .......#..-..#......................#..-..#.............. .......#.|.|.#......................#...|.#.............. .......#..-..#......................#..-..#.............. .......#######......................#######.............. .......#######......................#######.............. .......#..-..#......................#..-..#.............. .......#.|...#......................#...|.#.............. .......#..-..#......................#..-..#.............. .......#...|.#......................#.|.|.#.............. .......#..-..#......................#..-..#.............. .......#######......................#######.............. .############################ .....##..-..##.....##..-..#.#.....##..-..##.....##..-..# .-.-.##...|.##.-.-.##.|.|.#.#...-.##...|.##.-...##.|.|.# |.|.|##..-..##|.|.|##..-..#.#|.|.|##..-..##|.|.|##..-..# .-.-.##.|...##...-.##.|...#.#.-...##.|.|.##.-.-.##.|...# .....##..-..##.....##..-..#.#.....##..-..##.....##..-..# .############################ .......#######......................#######.............. .......#..-..#......................#..-..#.............. .......#...|.#......................#.|...#.............. .......#..-..#......................#..-..#.............. .......#.|...#......................#...|.#.............. .......#..-..#......................#..-..#.............. .......#######......................#######.............. .......#######......................#######.............. .......#..-..#......................#..-..#.............. .......#.|...#......................#.|.|.#.............. .......#..-..#......................#..-..#.............. .......#...|.#......................#.|...#.............. .......#..-..#......................#..-..#.............. .......#######......................#######.............. .############################ .....##..-..##.....##..-..#.#.....##..-..##.....##.....# .-.-.##.|.|.##.-.-.##...|.#.#.....##.|.|.##...-.##.|...# |.|.|##..-..##|....##..-..#.#....|##..-..##|.|.|##.....# .-.-.##.|.|.##.....##.|.|.#.#.-.-.##.|.|.##.-...##.|...# .....##..-..##.....##..-..#.#.....##..-..##.....##..-..# .############################ .......#######......................#######.............. .......#..-..#......................#..-..#.............. .......#.|.|.#......................#.|...#.............. .......#..-..#......................#..-..#.............. .......#...|.#......................#...|.#.............. .......#..-..#......................#..-..#.............. .......#######......................#######.............. .......#######......................#######.............. .......#..-..#......................#..-..#.............. .......#.|...#......................#.|.|.#.............. .......#..-..#......................#..-..#.............. .......#...|.#......................#.|...#.............. .......#..-..#......................#..-..#.............. .......#######......................#######.............. .############################ .....##..-..##.....##..-..#.#.....##..-..##.....##..-..# .-.-.##...|.##.-.-.##.|.|.#.#.-...##.|.|.##.-...##.|.|.# |.|.|##..-..##|.|.|##..-..#.#|.|.|##..-..##|.|.|##..-..# ...-.##.|...##.-.-.##.|.|.#.#.-.-.##.|...##.-.-.##.|.|.# .....##..-..##.....##..-..#.#.....##..-..##.....##..-..# .############################ .......#######......................#######.............. .......#..-..#......................#..-..#.............. .......#...|.#......................#.|.|.#.............. .......#..-..#......................#..-..#.............. .......#.|...#......................#...|.#.............. .......#..-..#......................#..-..#.............. .......#######......................#######.............. 0 Output LOW HIGH HIGH LOW
instruction
0
76,635
19
153,270
"Correct Solution: ``` class Surface: def __init__(self, mp): self.mp = mp def mirror(self): for y in range(5): self.mp[y] = self.mp[y][::-1] def mirror_ud(self): for y in range(2): self.mp[y], self.mp[4 - y] = self.mp[4 - y], self.mp[y] def spin90(self): new_mp = [[None] * 5 for _ in range(5)] for y in range(5): for x in range(5): new_mp[x][4 - y] = self.mp[y][x] self.mp = new_mp def spin270(self): new_mp = [[None] * 5 for _ in range(5)] for y in range(5): for x in range(5): new_mp[4 - x][y] = self.mp[y][x] self.mp = new_mp def to_hash(self): ret = 0 for y in range(5): for x in range(5): if self.mp[y][x] != ".": ret += 2 ** (y * 5 + x) return ret def calc(lst): return sum([2 ** i for i in lst]) hash_dic = { calc([8, 18, 22]):1, calc([2, 8, 12, 16, 22]):2, calc([2, 8, 12, 18, 22]):3, calc([6, 8, 12, 18]):4, calc([2, 6, 12, 18, 22]):5, calc([2, 6, 12, 16, 18, 22]):6, calc([2, 8, 18]):7, calc([2, 6, 8, 12, 16, 18, 22]):8, calc([2, 6, 8, 12, 18, 22]):9 } def make_dice(drawing): dice = [] s1 = Surface([line[8:13] for line in drawing[1:6]]) s1.mirror() dice.append(hash_dic[s1.to_hash()]) s2 = Surface([line[1:6] for line in drawing[8:13]]) s2.spin90() s2.mirror() dice.append(hash_dic[s2.to_hash()]) s3 = Surface([line[8:13] for line in drawing[8:13]]) s3.mirror() dice.append(hash_dic[s3.to_hash()]) s4 = Surface([line[15:20] for line in drawing[8:13]]) s4.spin270() s4.mirror() dice.append(hash_dic[s4.to_hash()]) s5 = Surface([line[22:27] for line in drawing[8:13]]) s5.mirror() dice.append(hash_dic[s5.to_hash()]) s6 = Surface([line[8:13] for line in drawing[15:20]]) s6.mirror() s6.mirror_ud() dice.append(hash_dic[s6.to_hash()]) return dice def result(dice1, dice2): cnt1 = cnt2 = 0 for num1 in dice1: for num2 in dice2: if num1 > num2: cnt1 += 1 if num1 < num2: cnt2 += 1 print("HIGH" if cnt1 >= cnt2 else "LOW") while True: s = input() if s == "0": break drawing1, drawing2 = [s[:28]], [s[29:]] for _ in range(20): s = input() drawing1.append(s[:28]) drawing2.append(s[29:]) dice1 = make_dice(drawing1) dice2 = make_dice(drawing2) result(dice1, dice2) ```
output
1
76,635
19
153,271
Provide a correct Python 3 solution for this coding contest problem. Write a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical. Constraints * $0 \leq $ the integer assigned to a face $ \leq 100$ Input In the first line, six integers assigned to faces of a dice are given in ascending order of their corresponding labels. In the second line, six integers assigned to faces of another dice are given in ascending order of their corresponding labels. Output Print "Yes" if two dices are identical, otherwise "No" in a line. Examples Input 1 2 3 4 5 6 6 2 4 3 5 1 Output Yes Input 1 2 3 4 5 6 6 5 4 3 2 1 Output No
instruction
0
76,668
19
153,336
"Correct Solution: ``` class Dice: def __init__(self, pip): self.pip = pip def move(self, dir): if str(dir) == 'E': self.pip[0], self.pip[2], self.pip[3], self.pip[5] = \ self.pip[3], self.pip[0], self.pip[5], self.pip[2] elif str(dir) == 'W': self.pip[0], self.pip[2], self.pip[3], self.pip[5] = \ self.pip[2], self.pip[5], self.pip[0], self.pip[3] elif str(dir) == 'N': self.pip[0], self.pip[1], self.pip[4], self.pip[5] = \ self.pip[1], self.pip[5], self.pip[0], self.pip[4] elif str(dir) == 'S': self.pip[0], self.pip[1], self.pip[4], self.pip[5] = \ self.pip[4], self.pip[0], self.pip[5], self.pip[1] d1 = Dice(list(map(int, input().split()))) d2 = Dice(list(map(int, input().split()))) check = "No" for x in "EEENEEENEEESEEESEEENEEEN": if d1.pip == d2.pip: check = "Yes" break d2.move(x) print(check) ```
output
1
76,668
19
153,337
Provide a correct Python 3 solution for this coding contest problem. Write a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical. Constraints * $0 \leq $ the integer assigned to a face $ \leq 100$ Input In the first line, six integers assigned to faces of a dice are given in ascending order of their corresponding labels. In the second line, six integers assigned to faces of another dice are given in ascending order of their corresponding labels. Output Print "Yes" if two dices are identical, otherwise "No" in a line. Examples Input 1 2 3 4 5 6 6 2 4 3 5 1 Output Yes Input 1 2 3 4 5 6 6 5 4 3 2 1 Output No
instruction
0
76,669
19
153,338
"Correct Solution: ``` a=[int(i)-1 for i in input().split()] b=[int(i)-1 for i in input().split()] for _ in range(4): b[0],b[4],b[5],b[1]=b[1],b[0],b[4],b[5] for _ in range(4): b[1],b[2],b[4],b[3]=b[3],b[1],b[2],b[4] for _ in range(4): b[0],b[4],b[5],b[1]=b[1],b[0],b[4],b[5] if a==b: print('Yes') exit() print('No') ```
output
1
76,669
19
153,339
Provide a correct Python 3 solution for this coding contest problem. Write a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical. Constraints * $0 \leq $ the integer assigned to a face $ \leq 100$ Input In the first line, six integers assigned to faces of a dice are given in ascending order of their corresponding labels. In the second line, six integers assigned to faces of another dice are given in ascending order of their corresponding labels. Output Print "Yes" if two dices are identical, otherwise "No" in a line. Examples Input 1 2 3 4 5 6 6 2 4 3 5 1 Output Yes Input 1 2 3 4 5 6 6 5 4 3 2 1 Output No
instruction
0
76,670
19
153,340
"Correct Solution: ``` def dice(d, n): if n == 1: return d[1] + d[2] + d[4] + d[3] if n == 2: return d[0] + d[3] + d[5] + d[2] if n == 3: return d[0] + d[1] + d[5] + d[4] if n == 4: return d[0] + d[4] + d[5] + d[1] if n == 5: return d[0] + d[2] + d[5] + d[3] if n == 6: return d[1] + d[3] + d[4] + d[2] d1 = input().split() d2 = input().split() for i in range(6): if d1[0] == d2[i] and d1[5] == d2[5-i] and dice(d2, i+1) in dice(d1, 1)*2: print('Yes') break if i == 5: print('No') ```
output
1
76,670
19
153,341
Provide a correct Python 3 solution for this coding contest problem. Write a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical. Constraints * $0 \leq $ the integer assigned to a face $ \leq 100$ Input In the first line, six integers assigned to faces of a dice are given in ascending order of their corresponding labels. In the second line, six integers assigned to faces of another dice are given in ascending order of their corresponding labels. Output Print "Yes" if two dices are identical, otherwise "No" in a line. Examples Input 1 2 3 4 5 6 6 2 4 3 5 1 Output Yes Input 1 2 3 4 5 6 6 5 4 3 2 1 Output No
instruction
0
76,671
19
153,342
"Correct Solution: ``` import copy import random D1 = list(map(int, input().split())) D2 = list(map(int, input().split())) for x in range(1000): r = random.randint(0,3) if r == 0: Dt = copy.copy(D2) temp = Dt[0] Dt[0] = Dt[4] Dt[4] = Dt[5] Dt[5] = Dt[1] Dt[1] = temp elif r== 1: Dt = copy.copy(D2) temp = Dt[0] Dt[0] = Dt[2] Dt[2] = Dt[5] Dt[5] = Dt[3] Dt[3] = temp elif r== 2: Dt = copy.copy(D2) temp = Dt[0] Dt[0] = Dt[3] Dt[3] = Dt[5] Dt[5] = Dt[2] Dt[2] = temp elif r == 3: Dt = copy.copy(D2) temp = Dt[0] Dt[0] = Dt[1] Dt[1] = Dt[5] Dt[5] = Dt[4] Dt[4] = temp D2 = copy.copy(Dt) flag = 0 for y in range(6): if D1[y] == D2[y]: flag += 1 if flag == 6: break if flag == 6: print("Yes") else: print("No") ```
output
1
76,671
19
153,343
Provide a correct Python 3 solution for this coding contest problem. Write a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical. Constraints * $0 \leq $ the integer assigned to a face $ \leq 100$ Input In the first line, six integers assigned to faces of a dice are given in ascending order of their corresponding labels. In the second line, six integers assigned to faces of another dice are given in ascending order of their corresponding labels. Output Print "Yes" if two dices are identical, otherwise "No" in a line. Examples Input 1 2 3 4 5 6 6 2 4 3 5 1 Output Yes Input 1 2 3 4 5 6 6 5 4 3 2 1 Output No
instruction
0
76,672
19
153,344
"Correct Solution: ``` class Dice: def __init__(self, state): self.state = state def vertical(self, direction): s = self.state state = [s[1], s[5], s[0], s[4]] if direction < 0: s[0], s[1], s[4], s[5] = state elif 0 < direction: s[0], s[1], s[4], s[5] = reversed(state) return self def lateral(self, direction): s = self.state state = [s[2], s[5], s[0], s[3]] if direction < 0: s[0], s[2], s[3], s[5] = state elif 0 < direction: s[0], s[2], s[3], s[5] = reversed(state) return self def north(self): self.vertical(-1) return self def south(self): self.vertical(1) return self def east(self): self.lateral(1) return self def west(self): self.lateral(-1) return self dice1 = Dice(input().split()) dice2 = Dice(input().split()) if dice1.state == dice2.state: print('Yes') else: is_eql = False for c in list('NNNNWNNNWNNNENNNENNNWNNN'): if c == 'N': dice1.north() elif c == 'S': dice1.south() elif c == 'W': dice1.west() elif c == 'E': dice1.east() if dice1.state == dice2.state: is_eql = True break print('Yes' if is_eql else 'No') ```
output
1
76,672
19
153,345
Provide a correct Python 3 solution for this coding contest problem. Write a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical. Constraints * $0 \leq $ the integer assigned to a face $ \leq 100$ Input In the first line, six integers assigned to faces of a dice are given in ascending order of their corresponding labels. In the second line, six integers assigned to faces of another dice are given in ascending order of their corresponding labels. Output Print "Yes" if two dices are identical, otherwise "No" in a line. Examples Input 1 2 3 4 5 6 6 2 4 3 5 1 Output Yes Input 1 2 3 4 5 6 6 5 4 3 2 1 Output No
instruction
0
76,673
19
153,346
"Correct Solution: ``` import random class Dise: def __init__(self,top,flont,right,left,back,bottom): self.top,self.flont,self.right,self.left,self.back,self.bottom=top,flont,right,left,back,bottom def rot(self,d): if d=='N': self.top,self.flont,self.bottom,self.back=self.flont,self.bottom,self.back,self.top elif d=='E': self.top,self.right,self.bottom,self.left=self.left,self.top,self.right,self.bottom elif d=='S': self.top,self.flont,self.bottom,self.back=self.back,self.top,self.flont,self.bottom elif d=='W': self.top,self.right,self.bottom,self.left=self.right,self.bottom,self.left,self.top def gettop(self): return self.top def getfront(self): return self.flont def getright(self): return self.right def getleft(self): return self.left def getback(self): return self.back def getbottom(self): return self.bottom n1=list(map(int,input().split())) n2=list(map(int,input().split())) dise1=Dise(n1[0],n1[1],n1[2],n1[3],n1[4],n1[5]) dise2=Dise(n2[0],n2[1],n2[2],n2[3],n2[4],n2[5]) for j in range(1000): dise1.rot(random.choice('NESW')) if dise1.gettop()==dise2.gettop() and dise1.getfront()==dise2.getfront() and dise1.getright()==dise2.getright() and dise1.getleft()==dise2.getleft() and dise1.getback()==dise2.getback() and dise1.getbottom()==dise2.getbottom(): print("Yes") break if j==999: print("No") ```
output
1
76,673
19
153,347
Provide a correct Python 3 solution for this coding contest problem. Write a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical. Constraints * $0 \leq $ the integer assigned to a face $ \leq 100$ Input In the first line, six integers assigned to faces of a dice are given in ascending order of their corresponding labels. In the second line, six integers assigned to faces of another dice are given in ascending order of their corresponding labels. Output Print "Yes" if two dices are identical, otherwise "No" in a line. Examples Input 1 2 3 4 5 6 6 2 4 3 5 1 Output Yes Input 1 2 3 4 5 6 6 5 4 3 2 1 Output No
instruction
0
76,674
19
153,348
"Correct Solution: ``` class Dice: def __init__(self,labels): self.stat = labels def roll_E(self): self.stat[0],self.stat[2],self.stat[3],self.stat[5] = self.stat[3],self.stat[0],self.stat[5],self.stat[2] def roll_N(self): self.stat[0],self.stat[1],self.stat[5],self.stat[4] = self.stat[1],self.stat[5],self.stat[4],self.stat[0] def roll_S(self): self.stat[0],self.stat[1],self.stat[5],self.stat[4] = self.stat[4],self.stat[0],self.stat[1],self.stat[5] def roll_W(self): self.stat[0],self.stat[2],self.stat[5],self.stat[3] = self.stat[2],self.stat[5],self.stat[3],self.stat[0] def get_top(self): return self.stat[0] def get(self): return list(self.stat) dice1 = Dice(input().split()) dice2 = Dice(input().split()) #print(dice1.get()) #print(dice2.get()) flag = False for i in range(20): dice2.roll_N() #print(dice2.get()) if dice1.get() == dice2.get() : flag = True break for j in range(20): dice2.roll_E() #print(dice2.get()) if dice1.get() == dice2.get() : flag = True break for k in range(20): dice2.roll_S() #print(dice2.get()) if dice1.get() == dice2.get() : flag = True break if flag:print("Yes") else:print("No") ```
output
1
76,674
19
153,349
Provide a correct Python 3 solution for this coding contest problem. Write a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical. Constraints * $0 \leq $ the integer assigned to a face $ \leq 100$ Input In the first line, six integers assigned to faces of a dice are given in ascending order of their corresponding labels. In the second line, six integers assigned to faces of another dice are given in ascending order of their corresponding labels. Output Print "Yes" if two dices are identical, otherwise "No" in a line. Examples Input 1 2 3 4 5 6 6 2 4 3 5 1 Output Yes Input 1 2 3 4 5 6 6 5 4 3 2 1 Output No
instruction
0
76,675
19
153,350
"Correct Solution: ``` # ITP_11_C class Dice : def __init__(self, dice) : self.dice = dice def roll(self, direction): tmp = self.dice[:] if direction == "N": self.dice[0] = tmp[1] self.dice[1] = tmp[5] self.dice[4] = tmp[0] self.dice[5] = tmp[4] elif direction == "E": self.dice[0] = tmp[3] self.dice[2] = tmp[0] self.dice[3] = tmp[5] self.dice[5] = tmp[2] elif direction == "W": self.dice[0] = tmp[2] self.dice[2] = tmp[5] self.dice[3] = tmp[0] self.dice[5] = tmp[3] else: self.dice[0] = tmp[4] self.dice[1] = tmp[0] self.dice[4] = tmp[5] self.dice[5] = tmp[1] def check_dice(self, another): for dire in "NNNNWNNNWNNNENNNENNNWNNN": self.roll(dire) check = True for i in range(6): if self.dice != another.dice: check = False break if check == True: break return check def get_dice_nums(self): return(self.dice) def dice_top(self): print(self.dice[0]) dice1 = Dice(list(map(str, input().split()))) dice2 = Dice(list(map(str, input().split()))) judge = dice1.check_dice(dice2) if judge == True: print("Yes") else: print("No") ```
output
1
76,675
19
153,351
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical. Constraints * $0 \leq $ the integer assigned to a face $ \leq 100$ Input In the first line, six integers assigned to faces of a dice are given in ascending order of their corresponding labels. In the second line, six integers assigned to faces of another dice are given in ascending order of their corresponding labels. Output Print "Yes" if two dices are identical, otherwise "No" in a line. Examples Input 1 2 3 4 5 6 6 2 4 3 5 1 Output Yes Input 1 2 3 4 5 6 6 5 4 3 2 1 Output No Submitted Solution: ``` import random class dice: def __init__(self, t, S, E): self.dice = list(map(int, input().split())) self.t = t self.S = S self.E = E self.now_dice() def roll(self, order): if order == 'E': self.t, self.E = self.W, self.t elif order == 'N': self.t, self.S = self.S, self.g elif order == 'S': self.t, self.S = self.N, self.t elif order == 'W': self.t, self.E = self.E, self.g self.now_dice() def now_dice(self): self.N = 7 - self.S self.g = 7 - self.t self.W = 7 - self.E self.now = [self.t, self.S, self.E, self.N, self.W, self.g] return self.now if __name__ == '__main__': dice_1 = dice(1, 2, 3) dice_2 = dice(1, 2, 3) loop = ['N', 'N', 'N', 'E']*4 loop_2 = ['E']*5 p = 0 ans = 0 for v in loop: dice_1.roll(v) if dice_1.dice[dice_1.S-1] == dice_2.dice[dice_2.S-1]: for v in loop_2: dice_1.roll(v) p = 0 for i in range(6): if dice_1.dice[dice_1.now[i]-1] != dice_2.dice[dice_2.now[i]-1]: break p += 1 if p >= 6: ans += 1 if ans: print('Yes') else: print('No') ```
instruction
0
76,676
19
153,352
Yes
output
1
76,676
19
153,353
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical. Constraints * $0 \leq $ the integer assigned to a face $ \leq 100$ Input In the first line, six integers assigned to faces of a dice are given in ascending order of their corresponding labels. In the second line, six integers assigned to faces of another dice are given in ascending order of their corresponding labels. Output Print "Yes" if two dices are identical, otherwise "No" in a line. Examples Input 1 2 3 4 5 6 6 2 4 3 5 1 Output Yes Input 1 2 3 4 5 6 6 5 4 3 2 1 Output No Submitted Solution: ``` x = list(map(int, input().split())) y = list(map(int, input().split())) z = [[0, 1, 2, 3], [0, 2, 1, 1], [1, 0, 2, 1], [2, 0, 1, 0], [1, 2, 0, 0], [2, 1, 0, 1]] succeed = False for i in range(6): match = True order = [0, 0, 0] for j in range(3): if {x[j], x[-j-1]} != {y[z[i][j]], y[-z[i][j]-1]}: match = False break else: if x[j] == y[z[i][j]]: order[j] = 1 if x[j] == x[-j-1]: order[j] = 2 if match: if 2 in order: succeed = True break if (z[i][3] == 0 or z[i][3] == 3) and sum(order) % 2: succeed = True break if z[i][3] == 1 and not sum(order) % 2: succeed = True break if succeed: print('Yes') else: print('No') ```
instruction
0
76,677
19
153,354
Yes
output
1
76,677
19
153,355
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical. Constraints * $0 \leq $ the integer assigned to a face $ \leq 100$ Input In the first line, six integers assigned to faces of a dice are given in ascending order of their corresponding labels. In the second line, six integers assigned to faces of another dice are given in ascending order of their corresponding labels. Output Print "Yes" if two dices are identical, otherwise "No" in a line. Examples Input 1 2 3 4 5 6 6 2 4 3 5 1 Output Yes Input 1 2 3 4 5 6 6 5 4 3 2 1 Output No Submitted Solution: ``` x = list(map(int, input().split())) y = list(map(int, input().split())) z = [[0, 1, 2, 1], [0, 2, 1, 0], [2, 1, 0, 0], [1, 0, 2, 0], [2, 0, 1, 1], [1, 2, 0, 1]] for i in range(6): order = [0, 0, 0] for j in range(3): if {x[j], x[-j-1]} != {y[z[i][j]], y[-z[i][j]-1]}: break if x[j] == y[z[i][j]]: order[j] = 1 if x[j] == x[-j-1]: order[j] = 2 else: if 2 in order: print('Yes') break if z[i][3] == sum(order) % 2: print('Yes') break else: print('No') ```
instruction
0
76,678
19
153,356
Yes
output
1
76,678
19
153,357
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical. Constraints * $0 \leq $ the integer assigned to a face $ \leq 100$ Input In the first line, six integers assigned to faces of a dice are given in ascending order of their corresponding labels. In the second line, six integers assigned to faces of another dice are given in ascending order of their corresponding labels. Output Print "Yes" if two dices are identical, otherwise "No" in a line. Examples Input 1 2 3 4 5 6 6 2 4 3 5 1 Output Yes Input 1 2 3 4 5 6 6 5 4 3 2 1 Output No Submitted Solution: ``` class Dice: def __init__(self): self.dice = [ [0, 1, 2, 3, 4, 5], [0, 2, 4, 1, 3, 5], [0, 4, 3, 2, 1, 5], [0, 3, 1, 4, 2, 5], [1, 5, 2, 3, 0, 4], [1, 2, 0, 5, 3, 4], [1, 0, 3, 2, 5, 4], [1, 3, 5, 0, 2, 4], [2, 1, 5, 0, 4, 3], [2, 5, 4, 1, 0, 3], [2, 4, 0, 5, 1, 3], [2, 0, 1, 4, 5, 3], [3, 1, 0, 5, 4, 2], [3, 0, 4, 1, 5, 2], [3, 4, 5, 0, 1, 2], [3, 5, 1, 4, 0, 2], [4, 0, 2, 3, 5, 1], [4, 2, 5, 0, 3, 1], [4, 5, 3, 2, 0, 1], [4, 3, 0, 5, 2, 1], [5, 1, 3, 2, 4, 0], [5, 2, 1, 4, 3, 0], [5, 4, 2, 3, 1, 0], [5, 3, 4, 1, 2, 0]] def math(self, dice_p1, dice_p2): dice_t = [] same = "No" for dice_p in self.dice: for i in range(6): dice_t.append(dice_p1[dice_p[i]]) if dice_t == dice_p2: same = "Yes" dice_t = [] return same d = Dice() dice_p1 = [int(dice_p1) for dice_p1 in input().split()] dice_p2 = [int(dice_p2) for dice_p2 in input().split()] print(d.math(dice_p1, dice_p2)) ```
instruction
0
76,679
19
153,358
Yes
output
1
76,679
19
153,359
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical. Constraints * $0 \leq $ the integer assigned to a face $ \leq 100$ Input In the first line, six integers assigned to faces of a dice are given in ascending order of their corresponding labels. In the second line, six integers assigned to faces of another dice are given in ascending order of their corresponding labels. Output Print "Yes" if two dices are identical, otherwise "No" in a line. Examples Input 1 2 3 4 5 6 6 2 4 3 5 1 Output Yes Input 1 2 3 4 5 6 6 5 4 3 2 1 Output No Submitted Solution: ``` n1 = [int(i) for i in input().split()] n2 = [int(i) for i in input().split()] class Dice(object): def __init__(self,num): self.n = num[4] self.e = num[2] self.w = num[3] self.s = num[1] self.center = num[0] self.back = num[5] def number(self): number = [self.center, self.s, self.e, self.w, self.n, self.back] return number def move(self,str): if str == 'N': x = self.n self.n = self.center self.center = self.s self.s = self.back self.back = x return self.center elif str == 'S': x = self.s self.s = self.center self.center = self.n self.n = self.back self.back = x return self.center elif str== 'E': x = self.e self.e = self.center self.center = self.w self.w = self.back self.back = x return self.center elif str == 'W': x = self.w self.w = self.center self.center = self.e self.e = self.back self.back = x return self.center dice1 = Dice(n1) dice2 = Dice(n2) bool1 = False bool2 = False status = dice1.center for i in range(4): if dice1.number() == dice2.number(): bool1 = True break dice1.move('N') for j in range(4): if dice1.number() == dice2.number(): bool1 = True break dice1.move('E') dice1 = Dice(n1) dice2 = Dice(n2) status = dice1.center for i in range(4): if dice1.number() == dice2.number(): bool2 = True break dice1.move('E') for j in range(4): if dice1.number() == dice2.number(): bool2 = True break dice1.move('N') print('Yes') if bool1 == True or bool2 == True else print('No') ```
instruction
0
76,680
19
153,360
No
output
1
76,680
19
153,361
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical. Constraints * $0 \leq $ the integer assigned to a face $ \leq 100$ Input In the first line, six integers assigned to faces of a dice are given in ascending order of their corresponding labels. In the second line, six integers assigned to faces of another dice are given in ascending order of their corresponding labels. Output Print "Yes" if two dices are identical, otherwise "No" in a line. Examples Input 1 2 3 4 5 6 6 2 4 3 5 1 Output Yes Input 1 2 3 4 5 6 6 5 4 3 2 1 Output No Submitted Solution: ``` d = list(map(int, input().split())) d2 = list(map(int, input().split())) class Dice(): def __init__(self, d): self.dice = d def InsSN(self, one, two, five, six): self.dice[0] = one self.dice[1] = two self.dice[4] = five self.dice[5] = six def InsWE(self, one, three, four, six): self.dice[0] = one self.dice[2] = three self.dice[3] = four self.dice[5] = six def S(self): one = self.dice[4] two = self.dice[0] five = self.dice[5] six = self.dice[1] self.InsSN(one, two, five, six) def N(self): one = self.dice[1] two = self.dice[5] five = self.dice[0] six = self.dice[4] self.InsSN(one, two, five, six) def W(self): one = self.dice[2] three = self.dice[5] four = self.dice[0] six = self.dice[3] self.InsWE(one, three, four, six) def E(self): one = self.dice[3] three = self.dice[0] four = self.dice[5] six = self.dice[2] self.InsWE(one, three, four, six) def roll(self, order): if order == 'S': self.S() elif order == 'N': self.N() elif order == 'E': self.E() elif order == 'W': self.W() status = 'no' d1 = Dice(d) for order1 in 'NNN': for order2 in 'EEEE': d1.roll(order2) print(d1.dice[0], d1.dice[1], d1.dice[2], d1.dice[3], d1.dice[4], d1.dice[5]) if d1.dice == d2: print('Yes') status = 'yes' break if status == 'yes': break if status == 'no': print('No') ```
instruction
0
76,681
19
153,362
No
output
1
76,681
19
153,363
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical. Constraints * $0 \leq $ the integer assigned to a face $ \leq 100$ Input In the first line, six integers assigned to faces of a dice are given in ascending order of their corresponding labels. In the second line, six integers assigned to faces of another dice are given in ascending order of their corresponding labels. Output Print "Yes" if two dices are identical, otherwise "No" in a line. Examples Input 1 2 3 4 5 6 6 2 4 3 5 1 Output Yes Input 1 2 3 4 5 6 6 5 4 3 2 1 Output No Submitted Solution: ``` # 2???????????????????????????????????????????????????????????Β°?????? # ??????????????Β’???????????????????????? # top = 1 front = 2 right = 3 left = 4 back = 5 bottom = 6 class Dice: def __init__(self, nums): self.face = nums # 2->1->5->6 def turnSouth(self): temp = self.face[0] self.face[0] = self.face[4] self.face[4] = self.face[5] self.face[5] = self.face[1] self.face[1] = temp return self # 4->1->3->6 def turnEast(self): temp = self.face[0] self.face[0] = self.face[2] self.face[2] = self.face[5] self.face[5] = self.face[3] self.face[3] = temp return self # 3->1->4->6 def turnWest(self): temp = self.face[0] self.face[0] = self.face[3] self.face[3] = self.face[5] self.face[5] = self.face[2] self.face[2] = temp return self # 5->1->2->6 def turnNorth(self): temp = self.face[0] self.face[0] = self.face[1] self.face[1] = self.face[5] self.face[5] = self.face[4] self.face[4] = temp # 2->3->5->4 def turnRight(self): temp = self.face[1] self.face[1] = self.face[2] self.face[2] = self.face[4] self.face[4] = self.face[3] self.face[3] = temp return self # 2->4->5->3 def turnLeft(self): temp = self.face[1] self.face[1] = self.face[3] self.face[3] = self.face[4] self.face[4] = self.face[2] self.face[2] = temp return self def equals(self, another): # ?????Β’?????????????????????????????? for i in range(0, 4): if self.face[0] == another.face[0]: # ??Β£??Β’???????????????????????Β’????????????????????Β’ for j in range(0, 4): if self.face[1] == another.face[1]: if self.face == another.face: return True another.turnRight() another.turnNorth() # ?????Β’?????????????????????????????? for i in range(0, 4): if self.face[0] == another.face[0]: # ??Β£??Β’???????????????????????Β’????????????????????Β’ for j in range(0, 4): if self.face[1] == another.face[1]: if self.face == another.face: return True another.turnRight() another.turnEast() return False # Dice????????? Dice1 = Dice(input().split()) Dice2 = Dice(input().split()) if Dice1.equals(Dice2): print("Yes") else: print("No") ```
instruction
0
76,682
19
153,364
No
output
1
76,682
19
153,365
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Write a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical. Constraints * $0 \leq $ the integer assigned to a face $ \leq 100$ Input In the first line, six integers assigned to faces of a dice are given in ascending order of their corresponding labels. In the second line, six integers assigned to faces of another dice are given in ascending order of their corresponding labels. Output Print "Yes" if two dices are identical, otherwise "No" in a line. Examples Input 1 2 3 4 5 6 6 2 4 3 5 1 Output Yes Input 1 2 3 4 5 6 6 5 4 3 2 1 Output No Submitted Solution: ``` d,e=[list(map(int,input().split()))for _ in range(2)];e[3],e[4]=e[4],e[3] t=0 m={0:'012345',1:'152304',2:'215043',3:'310542',4:'402351',5:'513240'} for i in range(6): f=[d[int(j)]for j in m[i]];f[3],f[4]=f[4],f[3] if f[0]==e[0]: f=f[1:5]*2 for j in range(4): if f[j:j+4]==e[1:5]: print('Yes');break else:print('No') ```
instruction
0
76,683
19
153,366
No
output
1
76,683
19
153,367
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n players sitting at a round table. All of them have s cards of n colors in total. Besides, initially the first person had cards of only the first color, the second one had cards of only the second color and so on. They can swap the cards by the following rules: * as the players swap, a player can give a card of his color only; * a player can't accept a card of a color he already has (particularly, he can't take cards of his color, no matter whether he has given out all of them or not); * during one swap a pair of people swaps cards (each person gives one card and takes one card). The aim of all n people is as follows: each of them should give out all the cards he had initially (that is, all cards of his color). Your task is to denote whether such sequence of swaps is possible. If the answer is positive, you should list all the swaps. Input The first line contains integers n (1 ≀ n ≀ 200000) and s (1 ≀ s ≀ 200000). The second line contains n numbers, the i-th number stands for how many cards the i-th player has by the moment the game starts. It is possible that a player has no cards initially. Output On the first line print "No" if such sequence of swaps is impossible. Otherwise, print "Yes". If the answer is positive, next print number k β€” the number of the swaps. Then on k lines describe the swaps by pairs of indices of the swapping players. Print the swaps and the numbers of the swaps in any order. Examples Input 4 8 2 2 2 2 Output Yes 4 4 3 4 2 1 3 1 2 Input 6 12 1 1 2 2 3 3 Output Yes 6 6 5 6 4 6 3 5 4 5 3 2 1 Input 5 5 0 0 0 0 5 Output No Submitted Solution: ``` n,s = map(int, input().split()) nums = input().split() nums = [ [int(x),i+1] for i,x in enumerate(nums)] nums.sort() num = nums.copy() list1 = [] j=0 j = len(num)-1 while(j>0): x,i = num[j] if(x>j): print('No') exit() for k in range(x): num[j-1-k][0] -= 1 list1.append([i,num[j-1-k][1]]) if(num[j-1-k][0]==0): num.pop(j-1-k) num = num[:-1] #print(num) num.sort() #print(num) j= len(num)-1 print('Yes') print(len(list1)) for e in list1: print(e[0],e[1]) ```
instruction
0
76,863
19
153,726
No
output
1
76,863
19
153,727
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n players sitting at a round table. All of them have s cards of n colors in total. Besides, initially the first person had cards of only the first color, the second one had cards of only the second color and so on. They can swap the cards by the following rules: * as the players swap, a player can give a card of his color only; * a player can't accept a card of a color he already has (particularly, he can't take cards of his color, no matter whether he has given out all of them or not); * during one swap a pair of people swaps cards (each person gives one card and takes one card). The aim of all n people is as follows: each of them should give out all the cards he had initially (that is, all cards of his color). Your task is to denote whether such sequence of swaps is possible. If the answer is positive, you should list all the swaps. Input The first line contains integers n (1 ≀ n ≀ 200000) and s (1 ≀ s ≀ 200000). The second line contains n numbers, the i-th number stands for how many cards the i-th player has by the moment the game starts. It is possible that a player has no cards initially. Output On the first line print "No" if such sequence of swaps is impossible. Otherwise, print "Yes". If the answer is positive, next print number k β€” the number of the swaps. Then on k lines describe the swaps by pairs of indices of the swapping players. Print the swaps and the numbers of the swaps in any order. Examples Input 4 8 2 2 2 2 Output Yes 4 4 3 4 2 1 3 1 2 Input 6 12 1 1 2 2 3 3 Output Yes 6 6 5 6 4 6 3 5 4 5 3 2 1 Input 5 5 0 0 0 0 5 Output No Submitted Solution: ``` n,s = map(int, input().split()) nums = input().split() nums = [ [int(x),i+1] for i,x in enumerate(nums)] nums.sort() num = nums.copy() list1 = [] j=0 j = len(num)-1 while(j>0): x,i = num[j] if(x>j): print('No') exit() for k in range(x): num[j-1-k][0] -= 1 list1.append([i,num[j-1-k][1]]) if(num[j-1-k][0]==0): num.pop(j-1-k) num = num[:-1] #print(num) num.sort() #print(num) j= len(num)-1 print(list1) ```
instruction
0
76,864
19
153,728
No
output
1
76,864
19
153,729
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n players sitting at a round table. All of them have s cards of n colors in total. Besides, initially the first person had cards of only the first color, the second one had cards of only the second color and so on. They can swap the cards by the following rules: * as the players swap, a player can give a card of his color only; * a player can't accept a card of a color he already has (particularly, he can't take cards of his color, no matter whether he has given out all of them or not); * during one swap a pair of people swaps cards (each person gives one card and takes one card). The aim of all n people is as follows: each of them should give out all the cards he had initially (that is, all cards of his color). Your task is to denote whether such sequence of swaps is possible. If the answer is positive, you should list all the swaps. Input The first line contains integers n (1 ≀ n ≀ 200000) and s (1 ≀ s ≀ 200000). The second line contains n numbers, the i-th number stands for how many cards the i-th player has by the moment the game starts. It is possible that a player has no cards initially. Output On the first line print "No" if such sequence of swaps is impossible. Otherwise, print "Yes". If the answer is positive, next print number k β€” the number of the swaps. Then on k lines describe the swaps by pairs of indices of the swapping players. Print the swaps and the numbers of the swaps in any order. Examples Input 4 8 2 2 2 2 Output Yes 4 4 3 4 2 1 3 1 2 Input 6 12 1 1 2 2 3 3 Output Yes 6 6 5 6 4 6 3 5 4 5 3 2 1 Input 5 5 0 0 0 0 5 Output No Submitted Solution: ``` n,s = map(int, input().split()) if(n==1): print('Yes') print(0) exit() nums = input().split() nums = [ [int(x),i+1] for i,x in enumerate(nums)] nums.sort() num = nums.copy() list1 = [] j=0 j = len(num)-1 while(j>0): x,i = num[j] if(x>j): print('No') exit() for k in range(x): num[j-1-k][0] -= 1 list1.append([i,num[j-1-k][1]]) if(num[j-1-k][0]==0): num.pop(j-1-k) num = num[:-1] #print(num) num.sort() #print(num) j= len(num)-1 print('Yes') print(len(list1)) for e in list1: print(e[0],e[1]) ```
instruction
0
76,865
19
153,730
No
output
1
76,865
19
153,731
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. There are n players sitting at a round table. All of them have s cards of n colors in total. Besides, initially the first person had cards of only the first color, the second one had cards of only the second color and so on. They can swap the cards by the following rules: * as the players swap, a player can give a card of his color only; * a player can't accept a card of a color he already has (particularly, he can't take cards of his color, no matter whether he has given out all of them or not); * during one swap a pair of people swaps cards (each person gives one card and takes one card). The aim of all n people is as follows: each of them should give out all the cards he had initially (that is, all cards of his color). Your task is to denote whether such sequence of swaps is possible. If the answer is positive, you should list all the swaps. Input The first line contains integers n (1 ≀ n ≀ 200000) and s (1 ≀ s ≀ 200000). The second line contains n numbers, the i-th number stands for how many cards the i-th player has by the moment the game starts. It is possible that a player has no cards initially. Output On the first line print "No" if such sequence of swaps is impossible. Otherwise, print "Yes". If the answer is positive, next print number k β€” the number of the swaps. Then on k lines describe the swaps by pairs of indices of the swapping players. Print the swaps and the numbers of the swaps in any order. Examples Input 4 8 2 2 2 2 Output Yes 4 4 3 4 2 1 3 1 2 Input 6 12 1 1 2 2 3 3 Output Yes 6 6 5 6 4 6 3 5 4 5 3 2 1 Input 5 5 0 0 0 0 5 Output No Submitted Solution: ``` n,s = map(int, input().split()) nums = input().split() nums = [ [int(x),i+1] for i,x in enumerate(nums)] nums.sort() num = nums.copy() list1 = [] j=0 j = len(num)-1 while(j>=0): if(j==0): print('No') exit() x,i = num[j] if(x>j): print('No') exit() for k in range(x): num[j-1-k][0] -= 1 list1.append([i,num[j-1-k][1]]) if(num[j-1-k][0]==0): num.pop(j-1-k) num = num[:-1] #print(num) num.sort() #print(num) j= len(num)-1 print('Yes') print(len(list1)) for e in list1: print(e[0],e[1]) ```
instruction
0
76,866
19
153,732
No
output
1
76,866
19
153,733
Provide tags and a correct Python 3 solution for this coding contest problem. Ashishgup and FastestFinger play a game. They start with a number n and play in turns. In each turn, a player can make any one of the following moves: * Divide n by any of its odd divisors greater than 1. * Subtract 1 from n if n is greater than 1. Divisors of a number include the number itself. The player who is unable to make a move loses the game. Ashishgup moves first. Determine the winner of the game if both of them play optimally. Input The first line contains a single integer t (1 ≀ t ≀ 100) β€” the number of test cases. The description of the test cases follows. The only line of each test case contains a single integer β€” n (1 ≀ n ≀ 10^9). Output For each test case, print "Ashishgup" if he wins, and "FastestFinger" otherwise (without quotes). Example Input 7 1 2 3 4 5 6 12 Output FastestFinger Ashishgup Ashishgup FastestFinger Ashishgup FastestFinger Ashishgup Note In the first test case, n = 1, Ashishgup cannot make a move. He loses. In the second test case, n = 2, Ashishgup subtracts 1 on the first move. Now n = 1, FastestFinger cannot make a move, so he loses. In the third test case, n = 3, Ashishgup divides by 3 on the first move. Now n = 1, FastestFinger cannot make a move, so he loses. In the last test case, n = 12, Ashishgup divides it by 3. Now n = 4, FastestFinger is forced to subtract 1, and Ashishgup gets 3, so he wins by dividing it by 3.
instruction
0
76,867
19
153,734
Tags: games, math, number theory Correct Solution: ``` for s in[*open(0)][1:]:n=int(s);print(('FastestFinger','Ashishgup')[n>1and(n<3or n%2or any(n%i<1and(i|n//i)&1for i in range(3,int(n**.5)+1)))]) ```
output
1
76,867
19
153,735
Provide tags and a correct Python 3 solution for this coding contest problem. Ashishgup and FastestFinger play a game. They start with a number n and play in turns. In each turn, a player can make any one of the following moves: * Divide n by any of its odd divisors greater than 1. * Subtract 1 from n if n is greater than 1. Divisors of a number include the number itself. The player who is unable to make a move loses the game. Ashishgup moves first. Determine the winner of the game if both of them play optimally. Input The first line contains a single integer t (1 ≀ t ≀ 100) β€” the number of test cases. The description of the test cases follows. The only line of each test case contains a single integer β€” n (1 ≀ n ≀ 10^9). Output For each test case, print "Ashishgup" if he wins, and "FastestFinger" otherwise (without quotes). Example Input 7 1 2 3 4 5 6 12 Output FastestFinger Ashishgup Ashishgup FastestFinger Ashishgup FastestFinger Ashishgup Note In the first test case, n = 1, Ashishgup cannot make a move. He loses. In the second test case, n = 2, Ashishgup subtracts 1 on the first move. Now n = 1, FastestFinger cannot make a move, so he loses. In the third test case, n = 3, Ashishgup divides by 3 on the first move. Now n = 1, FastestFinger cannot make a move, so he loses. In the last test case, n = 12, Ashishgup divides it by 3. Now n = 4, FastestFinger is forced to subtract 1, and Ashishgup gets 3, so he wins by dividing it by 3.
instruction
0
76,868
19
153,736
Tags: games, math, number theory Correct Solution: ``` def power_of_two_checker(x): while x!=1: if x%2 == 1: return False x = x//2 return True for _ in range(0, int(input())): n = int(input()) if n == 1: print("FastestFinger") elif n == 2: print("Ashishgup") elif n%2 == 1: print("Ashishgup") elif power_of_two_checker(n) == True: print("FastestFinger") elif n%2 == 0 and (n//2)%2 == 1: temp = n//2 i = 3 while i*i<=temp: if n%i == 0: print("Ashishgup") break i+=2 else: print("FastestFinger") else: print("Ashishgup") ```
output
1
76,868
19
153,737
Provide tags and a correct Python 3 solution for this coding contest problem. Ashishgup and FastestFinger play a game. They start with a number n and play in turns. In each turn, a player can make any one of the following moves: * Divide n by any of its odd divisors greater than 1. * Subtract 1 from n if n is greater than 1. Divisors of a number include the number itself. The player who is unable to make a move loses the game. Ashishgup moves first. Determine the winner of the game if both of them play optimally. Input The first line contains a single integer t (1 ≀ t ≀ 100) β€” the number of test cases. The description of the test cases follows. The only line of each test case contains a single integer β€” n (1 ≀ n ≀ 10^9). Output For each test case, print "Ashishgup" if he wins, and "FastestFinger" otherwise (without quotes). Example Input 7 1 2 3 4 5 6 12 Output FastestFinger Ashishgup Ashishgup FastestFinger Ashishgup FastestFinger Ashishgup Note In the first test case, n = 1, Ashishgup cannot make a move. He loses. In the second test case, n = 2, Ashishgup subtracts 1 on the first move. Now n = 1, FastestFinger cannot make a move, so he loses. In the third test case, n = 3, Ashishgup divides by 3 on the first move. Now n = 1, FastestFinger cannot make a move, so he loses. In the last test case, n = 12, Ashishgup divides it by 3. Now n = 4, FastestFinger is forced to subtract 1, and Ashishgup gets 3, so he wins by dividing it by 3.
instruction
0
76,869
19
153,738
Tags: games, math, number theory Correct Solution: ``` def first_wins(n): if n == 1: return False if n == 2: return True _2_degree = 0 while n % 2 == 0: _2_degree += 1 n //= 2 if _2_degree == 0: return True if n == 1: return False if _2_degree > 1: return True # now _2_degree == 1 and n != 2 for i in range(3, n, 2): if i * i > n: return False if n % i == 0: return True def main(): for case in range(int(input())): print('Ashishgup' if first_wins(int(input().strip())) else 'FastestFinger') main() ```
output
1
76,869
19
153,739
Provide tags and a correct Python 3 solution for this coding contest problem. Ashishgup and FastestFinger play a game. They start with a number n and play in turns. In each turn, a player can make any one of the following moves: * Divide n by any of its odd divisors greater than 1. * Subtract 1 from n if n is greater than 1. Divisors of a number include the number itself. The player who is unable to make a move loses the game. Ashishgup moves first. Determine the winner of the game if both of them play optimally. Input The first line contains a single integer t (1 ≀ t ≀ 100) β€” the number of test cases. The description of the test cases follows. The only line of each test case contains a single integer β€” n (1 ≀ n ≀ 10^9). Output For each test case, print "Ashishgup" if he wins, and "FastestFinger" otherwise (without quotes). Example Input 7 1 2 3 4 5 6 12 Output FastestFinger Ashishgup Ashishgup FastestFinger Ashishgup FastestFinger Ashishgup Note In the first test case, n = 1, Ashishgup cannot make a move. He loses. In the second test case, n = 2, Ashishgup subtracts 1 on the first move. Now n = 1, FastestFinger cannot make a move, so he loses. In the third test case, n = 3, Ashishgup divides by 3 on the first move. Now n = 1, FastestFinger cannot make a move, so he loses. In the last test case, n = 12, Ashishgup divides it by 3. Now n = 4, FastestFinger is forced to subtract 1, and Ashishgup gets 3, so he wins by dividing it by 3.
instruction
0
76,870
19
153,740
Tags: games, math, number theory Correct Solution: ``` first = 'Ashishgup' second = 'FastestFinger' def check(x): if x <= 3: return x >= 2 if x % 2 == 0 or x % 3 == 0: return False i = 5 while i * i <= x: if x % i == 0 or x % (i + 2) == 0: return False i += 6 return True def solve(): n = int(input()) if n == 1: print(second) return if n % 2 == 1 or n == 2: print(first) return m = n while m % 2 == 0: m //= 2 if n % 4 == 0: print(first if m > 1 else second) return print(second if check(m) else first) for _ in range(int(input())): solve() ```
output
1
76,870
19
153,741