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
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. One day Misha and Andrew were playing a very simple game. First, each player chooses an integer in the range from 1 to n. Let's assume that Misha chose number m, and Andrew chose number a. Then, by using a random generator they choose a random integer c in the range between 1 and n (any integer from 1 to n is chosen with the same probability), after which the winner is the player, whose number was closer to c. The boys agreed that if m and a are located on the same distance from c, Misha wins. Andrew wants to win very much, so he asks you to help him. You know the number selected by Misha, and number n. You need to determine which value of a Andrew must choose, so that the probability of his victory is the highest possible. More formally, you need to find such integer a (1 ≀ a ≀ n), that the probability that <image> is maximal, where c is the equiprobably chosen integer from 1 to n (inclusive). Input The first line contains two integers n and m (1 ≀ m ≀ n ≀ 109) β€” the range of numbers in the game, and the number selected by Misha respectively. Output Print a single number β€” such value a, that probability that Andrew wins is the highest. If there are multiple such values, print the minimum of them. Examples Input 3 1 Output 2 Input 4 3 Output 2 Note In the first sample test: Andrew wins if c is equal to 2 or 3. The probability that Andrew wins is 2 / 3. If Andrew chooses a = 3, the probability of winning will be 1 / 3. If a = 1, the probability of winning is 0. In the second sample test: Andrew wins if c is equal to 1 and 2. The probability that Andrew wins is 1 / 2. For other choices of a the probability of winning is less. Submitted Solution: ``` n, k = [int(x) for x in input().split()] if n==1: print(1) else: if k<=n/2: print(k+1) else: print(k-1) ```
instruction
0
87,983
19
175,966
Yes
output
1
87,983
19
175,967
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. One day Misha and Andrew were playing a very simple game. First, each player chooses an integer in the range from 1 to n. Let's assume that Misha chose number m, and Andrew chose number a. Then, by using a random generator they choose a random integer c in the range between 1 and n (any integer from 1 to n is chosen with the same probability), after which the winner is the player, whose number was closer to c. The boys agreed that if m and a are located on the same distance from c, Misha wins. Andrew wants to win very much, so he asks you to help him. You know the number selected by Misha, and number n. You need to determine which value of a Andrew must choose, so that the probability of his victory is the highest possible. More formally, you need to find such integer a (1 ≀ a ≀ n), that the probability that <image> is maximal, where c is the equiprobably chosen integer from 1 to n (inclusive). Input The first line contains two integers n and m (1 ≀ m ≀ n ≀ 109) β€” the range of numbers in the game, and the number selected by Misha respectively. Output Print a single number β€” such value a, that probability that Andrew wins is the highest. If there are multiple such values, print the minimum of them. Examples Input 3 1 Output 2 Input 4 3 Output 2 Note In the first sample test: Andrew wins if c is equal to 2 or 3. The probability that Andrew wins is 2 / 3. If Andrew chooses a = 3, the probability of winning will be 1 / 3. If a = 1, the probability of winning is 0. In the second sample test: Andrew wins if c is equal to 1 and 2. The probability that Andrew wins is 1 / 2. For other choices of a the probability of winning is less. Submitted Solution: ``` count1 = 0 count2 = 0 nm = input().split() n = int(nm[0]) m = int(nm[1]) if n == 1 and m == 1: print(1) elif m-1 >= (n-m): print(m-1) else: print(m + 1) ```
instruction
0
87,984
19
175,968
Yes
output
1
87,984
19
175,969
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. One day Misha and Andrew were playing a very simple game. First, each player chooses an integer in the range from 1 to n. Let's assume that Misha chose number m, and Andrew chose number a. Then, by using a random generator they choose a random integer c in the range between 1 and n (any integer from 1 to n is chosen with the same probability), after which the winner is the player, whose number was closer to c. The boys agreed that if m and a are located on the same distance from c, Misha wins. Andrew wants to win very much, so he asks you to help him. You know the number selected by Misha, and number n. You need to determine which value of a Andrew must choose, so that the probability of his victory is the highest possible. More formally, you need to find such integer a (1 ≀ a ≀ n), that the probability that <image> is maximal, where c is the equiprobably chosen integer from 1 to n (inclusive). Input The first line contains two integers n and m (1 ≀ m ≀ n ≀ 109) β€” the range of numbers in the game, and the number selected by Misha respectively. Output Print a single number β€” such value a, that probability that Andrew wins is the highest. If there are multiple such values, print the minimum of them. Examples Input 3 1 Output 2 Input 4 3 Output 2 Note In the first sample test: Andrew wins if c is equal to 2 or 3. The probability that Andrew wins is 2 / 3. If Andrew chooses a = 3, the probability of winning will be 1 / 3. If a = 1, the probability of winning is 0. In the second sample test: Andrew wins if c is equal to 1 and 2. The probability that Andrew wins is 1 / 2. For other choices of a the probability of winning is less. Submitted Solution: ``` #!/usr/bin/env python # -*- coding: utf-8 -*- n,m = map(int,input().split()) if n - m > m - 1: print(m+1) else: print(m-1) ```
instruction
0
87,985
19
175,970
No
output
1
87,985
19
175,971
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. One day Misha and Andrew were playing a very simple game. First, each player chooses an integer in the range from 1 to n. Let's assume that Misha chose number m, and Andrew chose number a. Then, by using a random generator they choose a random integer c in the range between 1 and n (any integer from 1 to n is chosen with the same probability), after which the winner is the player, whose number was closer to c. The boys agreed that if m and a are located on the same distance from c, Misha wins. Andrew wants to win very much, so he asks you to help him. You know the number selected by Misha, and number n. You need to determine which value of a Andrew must choose, so that the probability of his victory is the highest possible. More formally, you need to find such integer a (1 ≀ a ≀ n), that the probability that <image> is maximal, where c is the equiprobably chosen integer from 1 to n (inclusive). Input The first line contains two integers n and m (1 ≀ m ≀ n ≀ 109) β€” the range of numbers in the game, and the number selected by Misha respectively. Output Print a single number β€” such value a, that probability that Andrew wins is the highest. If there are multiple such values, print the minimum of them. Examples Input 3 1 Output 2 Input 4 3 Output 2 Note In the first sample test: Andrew wins if c is equal to 2 or 3. The probability that Andrew wins is 2 / 3. If Andrew chooses a = 3, the probability of winning will be 1 / 3. If a = 1, the probability of winning is 0. In the second sample test: Andrew wins if c is equal to 1 and 2. The probability that Andrew wins is 1 / 2. For other choices of a the probability of winning is less. Submitted Solution: ``` def find_best(number , misha): right = number - misha if right > misha + 1: print(misha + 1) else: print(misha - 1) if __name__ == "__main__": number , misha = input().split(" ") if int(number) == 1: print(1) else: find_best(int(number) , int(misha)) ```
instruction
0
87,986
19
175,972
No
output
1
87,986
19
175,973
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. One day Misha and Andrew were playing a very simple game. First, each player chooses an integer in the range from 1 to n. Let's assume that Misha chose number m, and Andrew chose number a. Then, by using a random generator they choose a random integer c in the range between 1 and n (any integer from 1 to n is chosen with the same probability), after which the winner is the player, whose number was closer to c. The boys agreed that if m and a are located on the same distance from c, Misha wins. Andrew wants to win very much, so he asks you to help him. You know the number selected by Misha, and number n. You need to determine which value of a Andrew must choose, so that the probability of his victory is the highest possible. More formally, you need to find such integer a (1 ≀ a ≀ n), that the probability that <image> is maximal, where c is the equiprobably chosen integer from 1 to n (inclusive). Input The first line contains two integers n and m (1 ≀ m ≀ n ≀ 109) β€” the range of numbers in the game, and the number selected by Misha respectively. Output Print a single number β€” such value a, that probability that Andrew wins is the highest. If there are multiple such values, print the minimum of them. Examples Input 3 1 Output 2 Input 4 3 Output 2 Note In the first sample test: Andrew wins if c is equal to 2 or 3. The probability that Andrew wins is 2 / 3. If Andrew chooses a = 3, the probability of winning will be 1 / 3. If a = 1, the probability of winning is 0. In the second sample test: Andrew wins if c is equal to 1 and 2. The probability that Andrew wins is 1 / 2. For other choices of a the probability of winning is less. Submitted Solution: ``` a,b=list(map(int,input().split())) if b>=a/2: print(b-1) elif b<a/2: print(b+1) ```
instruction
0
87,987
19
175,974
No
output
1
87,987
19
175,975
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. One day Misha and Andrew were playing a very simple game. First, each player chooses an integer in the range from 1 to n. Let's assume that Misha chose number m, and Andrew chose number a. Then, by using a random generator they choose a random integer c in the range between 1 and n (any integer from 1 to n is chosen with the same probability), after which the winner is the player, whose number was closer to c. The boys agreed that if m and a are located on the same distance from c, Misha wins. Andrew wants to win very much, so he asks you to help him. You know the number selected by Misha, and number n. You need to determine which value of a Andrew must choose, so that the probability of his victory is the highest possible. More formally, you need to find such integer a (1 ≀ a ≀ n), that the probability that <image> is maximal, where c is the equiprobably chosen integer from 1 to n (inclusive). Input The first line contains two integers n and m (1 ≀ m ≀ n ≀ 109) β€” the range of numbers in the game, and the number selected by Misha respectively. Output Print a single number β€” such value a, that probability that Andrew wins is the highest. If there are multiple such values, print the minimum of them. Examples Input 3 1 Output 2 Input 4 3 Output 2 Note In the first sample test: Andrew wins if c is equal to 2 or 3. The probability that Andrew wins is 2 / 3. If Andrew chooses a = 3, the probability of winning will be 1 / 3. If a = 1, the probability of winning is 0. In the second sample test: Andrew wins if c is equal to 1 and 2. The probability that Andrew wins is 1 / 2. For other choices of a the probability of winning is less. Submitted Solution: ``` # Description of the problem can be found at http://codeforces.com/problemset/problem/570/B n, m = map(int, input().split()) if n - m + 1 >= m - 1: print(m + 1) else: print(m - 1) ```
instruction
0
87,988
19
175,976
No
output
1
87,988
19
175,977
Provide a correct Python 3 solution for this coding contest problem. Let's play a new board game ``Life Line''. The number of the players is greater than 1 and less than 10. In this game, the board is a regular triangle in which many small regular triangles are arranged (See Figure l). The edges of each small triangle are of the same length. <image> Figure 1: The board The size of the board is expressed by the number of vertices on the bottom edge of the outer triangle. For example, the size of the board in Figure 1 is 4. At the beginning of the game, each player is assigned his own identification number between 1 and 9, and is given some stones on which his identification number is written. Each player puts his stone in turn on one of the ``empty'' vertices. An ``empty vertex'' is a vertex that has no stone on it. When one player puts his stone on one of the vertices during his turn, some stones might be removed from the board. The player gains points which is equal to the number of the removed stones of others, but loses points which is equal to the number of the removed stones of himself. The points of a player for a single turn is the points he gained minus the points he lost in that turn. The conditions for removing stones are as follows: * The stones on the board are divided into groups. Each group contains a set of stones whose numbers are the same and placed adjacently. That is, if the same numbered stones are placed adjacently, they belong to the same group. * If none of the stones in a group is adjacent to at least one ``empty'' vertex, all the stones in that group are removed from the board. <image> Figure 2: The groups of stones Figure 2 shows an example of the groups of stones. Suppose that the turn of the player `4' comes now. If he puts his stone on the vertex shown in Figure 3a, the conditions will be satisfied to remove some groups of stones (shadowed in Figure 3b). The player gains 6 points, because the 6 stones of others are removed from the board (See Figure 3c). <image> Figure 3a | Figure 3b | Figure 3c ---|---|--- As another example, suppose that the turn of the player `2' comes in Figure 2. If the player puts his stone on the vertex shown in Figure 4a, the conditions will be satisfied to remove some groups of stones (shadowed in Figure 4b). The player gains 4 points, because the 4 stones of others are removed. But, at the same time, he loses 3 points, because his 3 stones are removed. As the result, the player's points of this turn is 4 - 3 = 1 (See Figure 4c). <image> Figure 4a | Figure 4b | Figure 4c ---|---|--- When each player puts all of his stones on the board, the game is over. The total score of a player is the summation of the points of all of his turns. Your job is to write a program that tells you the maximum points a player can get (i.e., the points he gains - the points he loses) in his current turn. Input The input consists of multiple data. Each data represents the state of the board of the game still in progress. The format of each data is as follows. N C S1,1 S2,1 S2,2 S3,1 S3,2 S3,3 ... SN,1 ... SN,N N is the size of the board (3 ≀ N ≀ 10). C is the identification number of the player whose turn comes now (1 ≀ C ≀ 9) . That is, your program must calculate his points in this turn. Si,j is the state of the vertex on the board (0 ≀ Si,j ≀ 9) . If the value of Si,j is positive, it means that there is the stone numbered by Si,j there. If the value of Si,j is 0, it means that the vertex is ``empty''. Two zeros in a line, i.e., 0 0, represents the end of the input. Output For each data, the maximum points the player can get in the turn should be output, each in a separate line. Examples Input 4 4 2 2 3 1 0 4 1 1 4 0 4 5 2 2 3 3 0 4 1 1 4 0 4 1 2 2 3 3 0 4 1 1 4 0 4 1 1 1 1 1 1 1 1 1 1 0 4 2 1 1 1 1 1 1 1 1 1 0 4 1 0 2 2 5 0 7 0 5 7 0 4 2 0 0 3 1 0 4 0 1 0 4 4 3 0 3 3 3 2 3 0 3 0 3 4 2 0 3 3 3 2 3 0 3 0 3 6 1 1 1 2 1 1 0 6 7 6 8 0 7 6 8 2 6 6 7 2 2 0 5 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 3 3 3 2 4 3 2 4 4 0 3 3 3 3 0 3 0 0 Output 6 5 1 -10 8 -1 0 1 -1 5 0 5 Input 4 4 2 2 3 1 0 4 1 1 4 0 4 5 2 2 3 3 0 4 1 1 4 0 4 1 2 2 3 3 0 4 1 1 4 0 4 1 1 1 1 1 1 1 1 1 1 0 4 2 1 1 1 1 1 1 1 1 1 0 4 1 0 2 2 5 0 7 0 5 7 0 4 2 0 0 3 1 0 4 0 1 0 4 4 3 0 3 3 3 2 3 0 3 0 3 4 2 0 3 3 3 2 3 0 3 0 3 6 1 1 1 2 1 1 0 6 7 6 8 0 7 6 8 2 6 6 7 2 2 0 5 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 3 3 3 2 4 3 2 4 4 0 3 3 3 3 0 3 0 0 Output 6 5 1 -10 8 -1 0 1 -1 5 0 5
instruction
0
88,305
19
176,610
"Correct Solution: ``` class Tree: def __init__(self, N): self.N = N self.arr = [ [ None for _ in range(N) ] for _ in range(N) ] def duplicate(self): newTree = Tree(self.N) for i in range(N): row = self.arr[i] newTree.arr[i] = row[:] return newTree def setVal(self, row, col, val): self.arr[row][col] = val def setGroup(self, grp, val): for cell in grp: self.arr[cell[0]][cell[1]] = val def getCellPoints(self, row, col, C): val = self.arr[row][col] if val == 0 or val == -1: return 0 grp = set() self.getGroup(row, col, val, grp) isSafe = False for cell in grp: if self.hasZeroNeighbor(cell[0], cell[1]): isSafe = True break self.setGroup(grp, -1) if isSafe: return 0 if val == C: return len(grp) * -1 else: return len(grp) def calcCellPoints(self, row, col, C): neighbors = self.getNeighbors(row, col) # print("\nConsidering placing stone in", (row, col), "...") # print("These are the neighbors:") # for x in neighbors: # print(x) points = self.getCellPoints(row, col, C) for nb in neighbors: points += self.getCellPoints(nb[0], nb[1], C) return points def getNeighbors(self, row, col): neighbors = [] if row < self.N - 1: neighbors.append( (row + 1, col) ) neighbors.append( (row + 1, col + 1) ) if col <= row - 1: neighbors.append( (row, col + 1) ) neighbors.append( (row - 1, col) ) if col > 0: neighbors.append( (row, col - 1) ) neighbors.append( (row - 1, col - 1) ) return neighbors def hasZeroNeighbor(self, row, col): neighbors = self.getNeighbors(row, col) for nb in neighbors: if self.arr[nb[0]][nb[1]] == 0: return True return False def getGroup(self, row, col, v, groupCells): if (row, col) in groupCells: return if self.arr[row][col] == v: groupCells.add((row, col)) neighbors = self.getNeighbors(row, col) for nb in neighbors: self.getGroup(nb[0], nb[1], v, groupCells) if __name__ == '__main__': while True: N, C = list(map(int, input().strip().split())) if N == 0 and C == 0: break tree = Tree(N) emptySpots = [] for i in range(N): arr = [ int(x) for x in list(filter(lambda x: x != '', \ input().strip().split(' '))) ] for j in range(len(arr)): tree.setVal(i, j, arr[j]) if arr[j] == 0: emptySpots.append( (i, j) ) maxPoints = -999999999 for spot in emptySpots: newTree = tree.duplicate() newTree.setVal(spot[0], spot[1], C) maxPoints = max(maxPoints, newTree.calcCellPoints(spot[0], spot[1], C)) print(maxPoints) ```
output
1
88,305
19
176,611
Provide a correct Python 3 solution for this coding contest problem. Let's play a new board game ``Life Line''. The number of the players is greater than 1 and less than 10. In this game, the board is a regular triangle in which many small regular triangles are arranged (See Figure l). The edges of each small triangle are of the same length. <image> Figure 1: The board The size of the board is expressed by the number of vertices on the bottom edge of the outer triangle. For example, the size of the board in Figure 1 is 4. At the beginning of the game, each player is assigned his own identification number between 1 and 9, and is given some stones on which his identification number is written. Each player puts his stone in turn on one of the ``empty'' vertices. An ``empty vertex'' is a vertex that has no stone on it. When one player puts his stone on one of the vertices during his turn, some stones might be removed from the board. The player gains points which is equal to the number of the removed stones of others, but loses points which is equal to the number of the removed stones of himself. The points of a player for a single turn is the points he gained minus the points he lost in that turn. The conditions for removing stones are as follows: * The stones on the board are divided into groups. Each group contains a set of stones whose numbers are the same and placed adjacently. That is, if the same numbered stones are placed adjacently, they belong to the same group. * If none of the stones in a group is adjacent to at least one ``empty'' vertex, all the stones in that group are removed from the board. <image> Figure 2: The groups of stones Figure 2 shows an example of the groups of stones. Suppose that the turn of the player `4' comes now. If he puts his stone on the vertex shown in Figure 3a, the conditions will be satisfied to remove some groups of stones (shadowed in Figure 3b). The player gains 6 points, because the 6 stones of others are removed from the board (See Figure 3c). <image> Figure 3a | Figure 3b | Figure 3c ---|---|--- As another example, suppose that the turn of the player `2' comes in Figure 2. If the player puts his stone on the vertex shown in Figure 4a, the conditions will be satisfied to remove some groups of stones (shadowed in Figure 4b). The player gains 4 points, because the 4 stones of others are removed. But, at the same time, he loses 3 points, because his 3 stones are removed. As the result, the player's points of this turn is 4 - 3 = 1 (See Figure 4c). <image> Figure 4a | Figure 4b | Figure 4c ---|---|--- When each player puts all of his stones on the board, the game is over. The total score of a player is the summation of the points of all of his turns. Your job is to write a program that tells you the maximum points a player can get (i.e., the points he gains - the points he loses) in his current turn. Input The input consists of multiple data. Each data represents the state of the board of the game still in progress. The format of each data is as follows. N C S1,1 S2,1 S2,2 S3,1 S3,2 S3,3 ... SN,1 ... SN,N N is the size of the board (3 ≀ N ≀ 10). C is the identification number of the player whose turn comes now (1 ≀ C ≀ 9) . That is, your program must calculate his points in this turn. Si,j is the state of the vertex on the board (0 ≀ Si,j ≀ 9) . If the value of Si,j is positive, it means that there is the stone numbered by Si,j there. If the value of Si,j is 0, it means that the vertex is ``empty''. Two zeros in a line, i.e., 0 0, represents the end of the input. Output For each data, the maximum points the player can get in the turn should be output, each in a separate line. Examples Input 4 4 2 2 3 1 0 4 1 1 4 0 4 5 2 2 3 3 0 4 1 1 4 0 4 1 2 2 3 3 0 4 1 1 4 0 4 1 1 1 1 1 1 1 1 1 1 0 4 2 1 1 1 1 1 1 1 1 1 0 4 1 0 2 2 5 0 7 0 5 7 0 4 2 0 0 3 1 0 4 0 1 0 4 4 3 0 3 3 3 2 3 0 3 0 3 4 2 0 3 3 3 2 3 0 3 0 3 6 1 1 1 2 1 1 0 6 7 6 8 0 7 6 8 2 6 6 7 2 2 0 5 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 3 3 3 2 4 3 2 4 4 0 3 3 3 3 0 3 0 0 Output 6 5 1 -10 8 -1 0 1 -1 5 0 5 Input 4 4 2 2 3 1 0 4 1 1 4 0 4 5 2 2 3 3 0 4 1 1 4 0 4 1 2 2 3 3 0 4 1 1 4 0 4 1 1 1 1 1 1 1 1 1 1 0 4 2 1 1 1 1 1 1 1 1 1 0 4 1 0 2 2 5 0 7 0 5 7 0 4 2 0 0 3 1 0 4 0 1 0 4 4 3 0 3 3 3 2 3 0 3 0 3 4 2 0 3 3 3 2 3 0 3 0 3 6 1 1 1 2 1 1 0 6 7 6 8 0 7 6 8 2 6 6 7 2 2 0 5 9 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 3 3 3 2 4 3 2 4 4 0 3 3 3 3 0 3 0 0 Output 6 5 1 -10 8 -1 0 1 -1 5 0 5
instruction
0
88,306
19
176,612
"Correct Solution: ``` import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**13 mod = 10**9+7 dd = [(-1,0),(0,1),(1,0),(0,-1)] ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split() def I(): return int(sys.stdin.readline()) def F(): return float(sys.stdin.readline()) def S(): return input() def pf(s): return print(s, flush=True) def main(): rr = [] def f(n,m): a = [[-1]*(n+3)] + [[-1] + LI() + [-1]*2 for _ in range(n)] + [[-1]*(n+3)] aa = [c[:] for c in a] d = collections.defaultdict(int) def _f(i,j,c): if a[i][j] == 0: return (0, set([(i,j)])) if a[i][j] != c: return (0,set()) a[i][j] = -1 r = [1, set()] for di,dj in [(-1,-1),(-1,0),(0,-1),(0,1),(1,0),(1,1)]: t = _f(i+di,j+dj,c) r[0] += t[0] r[1] |= t[1] # print('_f',i,j,c,r) return tuple(r) for i in range(1,n+1): for j in range(1,i+1): if a[i][j] != m: continue c,s = _f(i,j,a[i][j]) if len(s) == 1: d[list(s)[0]] = -1 a = aa aa = [c[:] for c in a] for i in range(1,n+1): for j in range(1,i+1): if a[i][j] != 0: continue if (i,j) in d: continue tf = True for di,dj in [(-1,-1),(-1,0),(0,-1),(0,1),(1,0),(1,1)]: if a[i+di][j+dj] in [0,m]: tf = False break if tf: d[(i,j)] = -1 else: d[(i,j)] = 0 ts = collections.defaultdict(set) for i in range(1,n+1): for j in range(1,i+1): if a[i][j] != m: continue cc = a[i][j] sf = -1 if a[i][j] == m else 1 c,s = _f(i,j,a[i][j]) # print('res',i,j,c,s,sf,len(s)) if len(s) > 1: for sc in s: ts[sc].add(cc) d[sc] = 0 a = aa # print(d) # print('\n'.join("\t".join(map(str,_)) for _ in a)) for i in range(1,n+1): for j in range(1,i+1): if a[i][j] < 1: continue cc = a[i][j] sf = -1 if a[i][j] == m else 1 c,s = _f(i,j,a[i][j]) # print('res',i,j,c,s,sf,len(s)) if len(s) == 1 and cc not in ts[list(s)[0]]: if sf == 1: d[list(s)[0]] += c * sf else: d[list(s)[0]] += c * sf # print('\n'.join("\t".join(map(str,_)) for _ in a)) # print('\n'.join("\t".join(map(str,_)) for _ in a)) # print(d) if len(d) == 0: return 0 return max(d.values()) while True: n,m = LI() if n == 0 and m == 0: break rr.append(f(n,m)) return '\n'.join(map(str,rr)) print(main()) ```
output
1
88,306
19
176,613
Provide tags and a correct Python 3 solution for this coding contest problem. You are playing a game of Jongmah. You don't need to know the rules to solve this problem. You have n tiles in your hand. Each tile has an integer between 1 and m written on it. To win the game, you will need to form some number of triples. Each triple consists of three tiles, such that the numbers written on the tiles are either all the same or consecutive. For example, 7, 7, 7 is a valid triple, and so is 12, 13, 14, but 2,2,3 or 2,4,6 are not. You can only use the tiles in your hand to form triples. Each tile can be used in at most one triple. To determine how close you are to the win, you want to know the maximum number of triples you can form from the tiles in your hand. Input The first line contains two integers integer n and m (1 ≀ n, m ≀ 10^6) β€” the number of tiles in your hand and the number of tiles types. The second line contains integers a_1, a_2, …, a_n (1 ≀ a_i ≀ m), where a_i denotes the number written on the i-th tile. Output Print one integer: the maximum number of triples you can form. Examples Input 10 6 2 3 3 3 4 4 4 5 5 6 Output 3 Input 12 6 1 5 3 3 3 4 3 5 3 2 3 3 Output 3 Input 13 5 1 1 5 1 2 3 3 2 4 2 3 4 5 Output 4 Note In the first example, we have tiles 2, 3, 3, 3, 4, 4, 4, 5, 5, 6. We can form three triples in the following way: 2, 3, 4; 3, 4, 5; 4, 5, 6. Since there are only 10 tiles, there is no way we could form 4 triples, so the answer is 3. In the second example, we have tiles 1, 2, 3 (7 times), 4, 5 (2 times). We can form 3 triples as follows: 1, 2, 3; 3, 3, 3; 3, 4, 5. One can show that forming 4 triples is not possible.
instruction
0
88,401
19
176,802
Tags: dp Correct Solution: ``` """ x: i-2,i-1,i y: i-1,i,i+1 z: i,i+1,i+2 dp[y][z] denotes the number of triples using the first i denominations. since the number of y and z affects the number of tile i+1 and i+2, so they need to be considered. Transition: new_dp[y][z] = max(new_dp[y][z], pre_dp[x][y] + z + (a[i] - x-y-z)//3) Boundary condition: dp[0][0] = 0 """ from sys import stdin from collections import Counter n, m = map(int, input().split()) a = list(map(int, stdin.readline().strip().split())) c = Counter( a) # using counter is slow, 2074 ms compared to 1341ms of direct counter c = [0] * (m + 3) for i in a: c[i] += 1 dp = [[float('-inf')] * 3 for _ in range(3)] dp[0][0] = 0 for i in range(1, m + 1): new_dp = [[float('-inf')] * 3 for _ in range(3)] for x in range(0, 3): for y in range(0, 3): for z in range(0, 3): if c[i] >= x + y + z: remaining = c[i] - x - y - z new_dp[y][z] = max(new_dp[y][z], dp[x][y] + z + remaining // 3) dp = new_dp print(dp[0][0]) ```
output
1
88,401
19
176,803
Provide tags and a correct Python 3 solution for this coding contest problem. You are playing a game of Jongmah. You don't need to know the rules to solve this problem. You have n tiles in your hand. Each tile has an integer between 1 and m written on it. To win the game, you will need to form some number of triples. Each triple consists of three tiles, such that the numbers written on the tiles are either all the same or consecutive. For example, 7, 7, 7 is a valid triple, and so is 12, 13, 14, but 2,2,3 or 2,4,6 are not. You can only use the tiles in your hand to form triples. Each tile can be used in at most one triple. To determine how close you are to the win, you want to know the maximum number of triples you can form from the tiles in your hand. Input The first line contains two integers integer n and m (1 ≀ n, m ≀ 10^6) β€” the number of tiles in your hand and the number of tiles types. The second line contains integers a_1, a_2, …, a_n (1 ≀ a_i ≀ m), where a_i denotes the number written on the i-th tile. Output Print one integer: the maximum number of triples you can form. Examples Input 10 6 2 3 3 3 4 4 4 5 5 6 Output 3 Input 12 6 1 5 3 3 3 4 3 5 3 2 3 3 Output 3 Input 13 5 1 1 5 1 2 3 3 2 4 2 3 4 5 Output 4 Note In the first example, we have tiles 2, 3, 3, 3, 4, 4, 4, 5, 5, 6. We can form three triples in the following way: 2, 3, 4; 3, 4, 5; 4, 5, 6. Since there are only 10 tiles, there is no way we could form 4 triples, so the answer is 3. In the second example, we have tiles 1, 2, 3 (7 times), 4, 5 (2 times). We can form 3 triples as follows: 1, 2, 3; 3, 3, 3; 3, 4, 5. One can show that forming 4 triples is not possible.
instruction
0
88,402
19
176,804
Tags: dp Correct Solution: ``` n, m = map(int, input().split()) a = map(int, input().split()) c = [0] * (m+4) for x in a: c[x] += 1 d_old = [0] + [-999999] * 14 for x in range(1, m+4): p = 0 q = c[x-1] r = c[x] if x-2 >= 0: p = c[x-2] d_nu = [-999999] * 15 for i in range(5): for j in range(3): for k in range(3): if i+k <= p and j+k <= q and k <= r: idx = 3*(j+k) + k d_nu[idx] = max([d_nu[idx], k + d_old[3*i + j] + (p-i-k) // 3]) d_old = d_nu print(max(d_old)) ```
output
1
88,402
19
176,805
Provide tags and a correct Python 3 solution for this coding contest problem. You are playing a game of Jongmah. You don't need to know the rules to solve this problem. You have n tiles in your hand. Each tile has an integer between 1 and m written on it. To win the game, you will need to form some number of triples. Each triple consists of three tiles, such that the numbers written on the tiles are either all the same or consecutive. For example, 7, 7, 7 is a valid triple, and so is 12, 13, 14, but 2,2,3 or 2,4,6 are not. You can only use the tiles in your hand to form triples. Each tile can be used in at most one triple. To determine how close you are to the win, you want to know the maximum number of triples you can form from the tiles in your hand. Input The first line contains two integers integer n and m (1 ≀ n, m ≀ 10^6) β€” the number of tiles in your hand and the number of tiles types. The second line contains integers a_1, a_2, …, a_n (1 ≀ a_i ≀ m), where a_i denotes the number written on the i-th tile. Output Print one integer: the maximum number of triples you can form. Examples Input 10 6 2 3 3 3 4 4 4 5 5 6 Output 3 Input 12 6 1 5 3 3 3 4 3 5 3 2 3 3 Output 3 Input 13 5 1 1 5 1 2 3 3 2 4 2 3 4 5 Output 4 Note In the first example, we have tiles 2, 3, 3, 3, 4, 4, 4, 5, 5, 6. We can form three triples in the following way: 2, 3, 4; 3, 4, 5; 4, 5, 6. Since there are only 10 tiles, there is no way we could form 4 triples, so the answer is 3. In the second example, we have tiles 1, 2, 3 (7 times), 4, 5 (2 times). We can form 3 triples as follows: 1, 2, 3; 3, 3, 3; 3, 4, 5. One can show that forming 4 triples is not possible.
instruction
0
88,403
19
176,806
Tags: dp Correct Solution: ``` """ x: i-2,i-1,i y: i-1,i,i+1 z: i,i+1,i+2 dp[y][z] denotes the number of triples using the first i denominations. since the number of y and z affects the number of tile i+1 and i+2, so they need to be considered. Transition: new_dp[y][z] = max(new_dp[y][z], pre_dp[x][y] + z + (a[i] - x-y-z)//3) Boundary condition: dp[0][0] = 0 """ from sys import stdin from collections import Counter from copy import deepcopy n, m = map(int, input().split()) a = list(map(int, stdin.readline().strip().split())) c = Counter(a) dp = [[float('-inf')] * 3 for _ in range(3)] dp[0][0] = 0 for i in range(1, m + 1): new_dp = [[float('-inf')] * 3 for _ in range(3)] for x in range(0, 3): for y in range(0, 3): for z in range(0, 3): if c[i] >= x + y + z and c[i + 1] >= y + z and c[i + 2] >= z: remaining = c[i] - x - y - z new_dp[y][z] = max(new_dp[y][z], dp[x][y] + z + remaining // 3) dp = new_dp print(max(sum(dp, []))) ```
output
1
88,403
19
176,807
Provide tags and a correct Python 3 solution for this coding contest problem. You are playing a game of Jongmah. You don't need to know the rules to solve this problem. You have n tiles in your hand. Each tile has an integer between 1 and m written on it. To win the game, you will need to form some number of triples. Each triple consists of three tiles, such that the numbers written on the tiles are either all the same or consecutive. For example, 7, 7, 7 is a valid triple, and so is 12, 13, 14, but 2,2,3 or 2,4,6 are not. You can only use the tiles in your hand to form triples. Each tile can be used in at most one triple. To determine how close you are to the win, you want to know the maximum number of triples you can form from the tiles in your hand. Input The first line contains two integers integer n and m (1 ≀ n, m ≀ 10^6) β€” the number of tiles in your hand and the number of tiles types. The second line contains integers a_1, a_2, …, a_n (1 ≀ a_i ≀ m), where a_i denotes the number written on the i-th tile. Output Print one integer: the maximum number of triples you can form. Examples Input 10 6 2 3 3 3 4 4 4 5 5 6 Output 3 Input 12 6 1 5 3 3 3 4 3 5 3 2 3 3 Output 3 Input 13 5 1 1 5 1 2 3 3 2 4 2 3 4 5 Output 4 Note In the first example, we have tiles 2, 3, 3, 3, 4, 4, 4, 5, 5, 6. We can form three triples in the following way: 2, 3, 4; 3, 4, 5; 4, 5, 6. Since there are only 10 tiles, there is no way we could form 4 triples, so the answer is 3. In the second example, we have tiles 1, 2, 3 (7 times), 4, 5 (2 times). We can form 3 triples as follows: 1, 2, 3; 3, 3, 3; 3, 4, 5. One can show that forming 4 triples is not possible.
instruction
0
88,404
19
176,808
Tags: dp Correct Solution: ``` from collections import Counter l1 = input().split(" ") n, m = int(l1[0]), int(l1[1]) tiles = Counter(map(int, input().split(" "))) nums = sorted(tiles) dp = {(0, 0): 0} for num in nums: v0, v1 = tiles[num], tiles[num+1] new_dp = Counter() for (d0, d1), c in dp.items(): t0, t1 = v0 - d0, v1 - d1 for d in range(min(t0, t1, 2) + 1): k = (d1 + d, d) new_dp[k] = max(new_dp[k], c + d + (t0 - d) // 3) dp = new_dp print(max(dp.values())) ```
output
1
88,404
19
176,809
Provide tags and a correct Python 3 solution for this coding contest problem. You are playing a game of Jongmah. You don't need to know the rules to solve this problem. You have n tiles in your hand. Each tile has an integer between 1 and m written on it. To win the game, you will need to form some number of triples. Each triple consists of three tiles, such that the numbers written on the tiles are either all the same or consecutive. For example, 7, 7, 7 is a valid triple, and so is 12, 13, 14, but 2,2,3 or 2,4,6 are not. You can only use the tiles in your hand to form triples. Each tile can be used in at most one triple. To determine how close you are to the win, you want to know the maximum number of triples you can form from the tiles in your hand. Input The first line contains two integers integer n and m (1 ≀ n, m ≀ 10^6) β€” the number of tiles in your hand and the number of tiles types. The second line contains integers a_1, a_2, …, a_n (1 ≀ a_i ≀ m), where a_i denotes the number written on the i-th tile. Output Print one integer: the maximum number of triples you can form. Examples Input 10 6 2 3 3 3 4 4 4 5 5 6 Output 3 Input 12 6 1 5 3 3 3 4 3 5 3 2 3 3 Output 3 Input 13 5 1 1 5 1 2 3 3 2 4 2 3 4 5 Output 4 Note In the first example, we have tiles 2, 3, 3, 3, 4, 4, 4, 5, 5, 6. We can form three triples in the following way: 2, 3, 4; 3, 4, 5; 4, 5, 6. Since there are only 10 tiles, there is no way we could form 4 triples, so the answer is 3. In the second example, we have tiles 1, 2, 3 (7 times), 4, 5 (2 times). We can form 3 triples as follows: 1, 2, 3; 3, 3, 3; 3, 4, 5. One can show that forming 4 triples is not possible.
instruction
0
88,405
19
176,810
Tags: dp Correct Solution: ``` from collections import Counter n, m = map(int, input().split()) B = list(map(int, input().split())) cnt = Counter(B) A = sorted(cnt.keys()) n = len(A) dp = [[0] * 3 for _ in range(3)] for i, a in enumerate(A): dp2 = [[0] * 3 for _ in range(3)] for x in range(1 if i >= 2 and a - 2 != A[i - 2] else 3): for y in range(1 if i >= 1 and a - 1 != A[i - 1] else 3): for z in range(3): if x + y + z <= cnt[a]: dp2[y][z] = max(dp2[y][z], dp[x][y] + z + (cnt[a] - x - y - z) // 3) dp = dp2 print (dp[0][0]) ```
output
1
88,405
19
176,811
Provide tags and a correct Python 3 solution for this coding contest problem. You are playing a game of Jongmah. You don't need to know the rules to solve this problem. You have n tiles in your hand. Each tile has an integer between 1 and m written on it. To win the game, you will need to form some number of triples. Each triple consists of three tiles, such that the numbers written on the tiles are either all the same or consecutive. For example, 7, 7, 7 is a valid triple, and so is 12, 13, 14, but 2,2,3 or 2,4,6 are not. You can only use the tiles in your hand to form triples. Each tile can be used in at most one triple. To determine how close you are to the win, you want to know the maximum number of triples you can form from the tiles in your hand. Input The first line contains two integers integer n and m (1 ≀ n, m ≀ 10^6) β€” the number of tiles in your hand and the number of tiles types. The second line contains integers a_1, a_2, …, a_n (1 ≀ a_i ≀ m), where a_i denotes the number written on the i-th tile. Output Print one integer: the maximum number of triples you can form. Examples Input 10 6 2 3 3 3 4 4 4 5 5 6 Output 3 Input 12 6 1 5 3 3 3 4 3 5 3 2 3 3 Output 3 Input 13 5 1 1 5 1 2 3 3 2 4 2 3 4 5 Output 4 Note In the first example, we have tiles 2, 3, 3, 3, 4, 4, 4, 5, 5, 6. We can form three triples in the following way: 2, 3, 4; 3, 4, 5; 4, 5, 6. Since there are only 10 tiles, there is no way we could form 4 triples, so the answer is 3. In the second example, we have tiles 1, 2, 3 (7 times), 4, 5 (2 times). We can form 3 triples as follows: 1, 2, 3; 3, 3, 3; 3, 4, 5. One can show that forming 4 triples is not possible.
instruction
0
88,406
19
176,812
Tags: dp Correct Solution: ``` # by the authority of GOD author: manhar singh sachdev # import os,sys from io import BytesIO,IOBase from array import array def main(): n,m = map(int,input().split()) a = array('i',map(int,input().split())) x = array('i',[0]*(m+1)) for i in a: x[i] += 1 dp = [array('i',[-10**9]*9) for _ in range(m)] # dp[i][j][k] : number i+1 forms j 2-seg and k 1-seg for i in range(3): dp[0][i] = (x[1]-i)//3 for i in range(1,m): for j in range(3): for k in range(3): for spe in range(j+k,min(x[i+1],j+k+2)+1): dp[i][k*3+spe-j-k] = max(dp[i][k*3+spe-j-k], dp[i-1][j*3+k]+j+(x[i+1]-spe)//3) print(max(dp[m-1])) # Fast IO Region BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self,file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write if self.writable else None def read(self): while True: b = os.read(self._fd,max(os.fstat(self._fd).st_size,BUFSIZE)) if not b: break ptr = self.buffer.tell() self.buffer.seek(0,2),self.buffer.write(b),self.buffer.seek(ptr) self.newlines = 0 return self.buffer.read() def readline(self): while self.newlines == 0: b = os.read(self._fd,max(os.fstat(self._fd).st_size,BUFSIZE)) self.newlines = b.count(b"\n")+(not b) ptr = self.buffer.tell() self.buffer.seek(0,2),self.buffer.write(b),self.buffer.seek(ptr) self.newlines -= 1 return self.buffer.readline() def flush(self): if self.writable: os.write(self._fd,self.buffer.getvalue()) self.buffer.truncate(0),self.buffer.seek(0) class IOWrapper(IOBase): def __init__(self,file): self.buffer = FastIO(file) self.flush = self.buffer.flush self.writable = self.buffer.writable self.write = lambda s:self.buffer.write(s.encode("ascii")) self.read = lambda:self.buffer.read().decode("ascii") self.readline = lambda:self.buffer.readline().decode("ascii") sys.stdin,sys.stdout = IOWrapper(sys.stdin),IOWrapper(sys.stdout) input = lambda:sys.stdin.readline().rstrip("\r\n") if __name__ == "__main__": main() ```
output
1
88,406
19
176,813
Provide tags and a correct Python 3 solution for this coding contest problem. You are playing a game of Jongmah. You don't need to know the rules to solve this problem. You have n tiles in your hand. Each tile has an integer between 1 and m written on it. To win the game, you will need to form some number of triples. Each triple consists of three tiles, such that the numbers written on the tiles are either all the same or consecutive. For example, 7, 7, 7 is a valid triple, and so is 12, 13, 14, but 2,2,3 or 2,4,6 are not. You can only use the tiles in your hand to form triples. Each tile can be used in at most one triple. To determine how close you are to the win, you want to know the maximum number of triples you can form from the tiles in your hand. Input The first line contains two integers integer n and m (1 ≀ n, m ≀ 10^6) β€” the number of tiles in your hand and the number of tiles types. The second line contains integers a_1, a_2, …, a_n (1 ≀ a_i ≀ m), where a_i denotes the number written on the i-th tile. Output Print one integer: the maximum number of triples you can form. Examples Input 10 6 2 3 3 3 4 4 4 5 5 6 Output 3 Input 12 6 1 5 3 3 3 4 3 5 3 2 3 3 Output 3 Input 13 5 1 1 5 1 2 3 3 2 4 2 3 4 5 Output 4 Note In the first example, we have tiles 2, 3, 3, 3, 4, 4, 4, 5, 5, 6. We can form three triples in the following way: 2, 3, 4; 3, 4, 5; 4, 5, 6. Since there are only 10 tiles, there is no way we could form 4 triples, so the answer is 3. In the second example, we have tiles 1, 2, 3 (7 times), 4, 5 (2 times). We can form 3 triples as follows: 1, 2, 3; 3, 3, 3; 3, 4, 5. One can show that forming 4 triples is not possible.
instruction
0
88,407
19
176,814
Tags: dp Correct Solution: ``` """ x: i-2,i-1,i y: i-1,i,i+1 z: i,i+1,i+2 dp[y][z] denotes the number of triples using the first i denominations. since the number of y and z affects the number of tile i+1 and i+2, so they need to be considered. Transition: new_dp[y][z] = max(new_dp[y][z], pre_dp[x][y] + z + (a[i] - x-y-z)//3) Boundary condition: dp[0][0] = 0 """ from sys import stdin from collections import Counter n, m = map(int, input().split()) a = list(map(int, stdin.readline().strip().split())) c = [0] * (m + 3) for i in a: c[i] += 1 dp = [[float('-inf')] * 3 for _ in range(3)] dp[0][0] = 0 for i in range(1, m + 1): new_dp = [[float('-inf')] * 3 for _ in range(3)] for x in range(0, 3): for y in range(0, 3): for z in range(0, 3): if c[i] >= x + y + z and c[i + 1] >= y + z and c[i + 2] >= z: remaining = c[i] - x - y - z new_dp[y][z] = max(new_dp[y][z], dp[x][y] + z + remaining // 3) dp = new_dp print(max(sum(dp, []))) ```
output
1
88,407
19
176,815
Provide tags and a correct Python 3 solution for this coding contest problem. You are playing a game of Jongmah. You don't need to know the rules to solve this problem. You have n tiles in your hand. Each tile has an integer between 1 and m written on it. To win the game, you will need to form some number of triples. Each triple consists of three tiles, such that the numbers written on the tiles are either all the same or consecutive. For example, 7, 7, 7 is a valid triple, and so is 12, 13, 14, but 2,2,3 or 2,4,6 are not. You can only use the tiles in your hand to form triples. Each tile can be used in at most one triple. To determine how close you are to the win, you want to know the maximum number of triples you can form from the tiles in your hand. Input The first line contains two integers integer n and m (1 ≀ n, m ≀ 10^6) β€” the number of tiles in your hand and the number of tiles types. The second line contains integers a_1, a_2, …, a_n (1 ≀ a_i ≀ m), where a_i denotes the number written on the i-th tile. Output Print one integer: the maximum number of triples you can form. Examples Input 10 6 2 3 3 3 4 4 4 5 5 6 Output 3 Input 12 6 1 5 3 3 3 4 3 5 3 2 3 3 Output 3 Input 13 5 1 1 5 1 2 3 3 2 4 2 3 4 5 Output 4 Note In the first example, we have tiles 2, 3, 3, 3, 4, 4, 4, 5, 5, 6. We can form three triples in the following way: 2, 3, 4; 3, 4, 5; 4, 5, 6. Since there are only 10 tiles, there is no way we could form 4 triples, so the answer is 3. In the second example, we have tiles 1, 2, 3 (7 times), 4, 5 (2 times). We can form 3 triples as follows: 1, 2, 3; 3, 3, 3; 3, 4, 5. One can show that forming 4 triples is not possible.
instruction
0
88,408
19
176,816
Tags: dp Correct Solution: ``` # -*- coding: utf-8 -*- # @Time : 2019/2/11 11:02 # @Author : LunaFire # @Email : gilgemesh2012@gmail.com # @File : D. Jongmah.py def main(): n, m = map(int, input().split()) a = list(map(int, input().split())) counter = [0] * (m + 1) for x in a: counter[x] += 1 pre_dp = [[float('-inf')] * 3 for _ in range(3)] pre_dp[0][0] = 0 for i in range(1, m + 1): cur_dp = [[float('-inf')] * 3 for _ in range(3)] for x in range(3): for y in range(3): for z in range(3): if counter[i] >= x + y + z: remain = counter[i] - x - y - z cur_dp[y][z] = max(cur_dp[y][z], pre_dp[x][y] + z + remain // 3) pre_dp = cur_dp print(pre_dp[0][0]) if __name__ == '__main__': main() ```
output
1
88,408
19
176,817
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are playing a game of Jongmah. You don't need to know the rules to solve this problem. You have n tiles in your hand. Each tile has an integer between 1 and m written on it. To win the game, you will need to form some number of triples. Each triple consists of three tiles, such that the numbers written on the tiles are either all the same or consecutive. For example, 7, 7, 7 is a valid triple, and so is 12, 13, 14, but 2,2,3 or 2,4,6 are not. You can only use the tiles in your hand to form triples. Each tile can be used in at most one triple. To determine how close you are to the win, you want to know the maximum number of triples you can form from the tiles in your hand. Input The first line contains two integers integer n and m (1 ≀ n, m ≀ 10^6) β€” the number of tiles in your hand and the number of tiles types. The second line contains integers a_1, a_2, …, a_n (1 ≀ a_i ≀ m), where a_i denotes the number written on the i-th tile. Output Print one integer: the maximum number of triples you can form. Examples Input 10 6 2 3 3 3 4 4 4 5 5 6 Output 3 Input 12 6 1 5 3 3 3 4 3 5 3 2 3 3 Output 3 Input 13 5 1 1 5 1 2 3 3 2 4 2 3 4 5 Output 4 Note In the first example, we have tiles 2, 3, 3, 3, 4, 4, 4, 5, 5, 6. We can form three triples in the following way: 2, 3, 4; 3, 4, 5; 4, 5, 6. Since there are only 10 tiles, there is no way we could form 4 triples, so the answer is 3. In the second example, we have tiles 1, 2, 3 (7 times), 4, 5 (2 times). We can form 3 triples as follows: 1, 2, 3; 3, 3, 3; 3, 4, 5. One can show that forming 4 triples is not possible. Submitted Solution: ``` import sys class Reader: def __init__(self): self.in_strs = list(reversed(sys.stdin.read().split())) def read_int(self): out = self.in_strs.pop() return int(out) def main(): r = Reader() cc = r.read_int() n = r.read_int() a = [0 for i in range(n)] for i in range(cc): a[r.read_int() - 1] += 1 dp = [[0 for j in range(3)] for i in range(3)] for c in a: new_dp = [[0 for j in range(3)] for i in range(3)] for x in range(3): for y in range(3): for z in range(3): if x + y + z <= c: new_dp[y][z] = max([new_dp[y][z], dp[x][y] + z + (c - x - y - z) // 3]) new_dp, dp = dp, new_dp print(dp[0][0]) if __name__ == "__main__": main() ```
instruction
0
88,409
19
176,818
Yes
output
1
88,409
19
176,819
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are playing a game of Jongmah. You don't need to know the rules to solve this problem. You have n tiles in your hand. Each tile has an integer between 1 and m written on it. To win the game, you will need to form some number of triples. Each triple consists of three tiles, such that the numbers written on the tiles are either all the same or consecutive. For example, 7, 7, 7 is a valid triple, and so is 12, 13, 14, but 2,2,3 or 2,4,6 are not. You can only use the tiles in your hand to form triples. Each tile can be used in at most one triple. To determine how close you are to the win, you want to know the maximum number of triples you can form from the tiles in your hand. Input The first line contains two integers integer n and m (1 ≀ n, m ≀ 10^6) β€” the number of tiles in your hand and the number of tiles types. The second line contains integers a_1, a_2, …, a_n (1 ≀ a_i ≀ m), where a_i denotes the number written on the i-th tile. Output Print one integer: the maximum number of triples you can form. Examples Input 10 6 2 3 3 3 4 4 4 5 5 6 Output 3 Input 12 6 1 5 3 3 3 4 3 5 3 2 3 3 Output 3 Input 13 5 1 1 5 1 2 3 3 2 4 2 3 4 5 Output 4 Note In the first example, we have tiles 2, 3, 3, 3, 4, 4, 4, 5, 5, 6. We can form three triples in the following way: 2, 3, 4; 3, 4, 5; 4, 5, 6. Since there are only 10 tiles, there is no way we could form 4 triples, so the answer is 3. In the second example, we have tiles 1, 2, 3 (7 times), 4, 5 (2 times). We can form 3 triples as follows: 1, 2, 3; 3, 3, 3; 3, 4, 5. One can show that forming 4 triples is not possible. Submitted Solution: ``` """ x: i-2,i-1,i y: i-1,i,i+1 z: i,i+1,i+2 dp[y][z] denotes the number of triples using the first i denominations. since the number of y and z affects the number of tile i+1 and i+2, so they need to be considered. Transition: new_dp[y][z] = max(new_dp[y][z], pre_dp[x][y] + z + (a[i] - x-y-z)//3) Boundary condition: dp[0][0] = 0 """ from sys import stdin from collections import Counter n, m = map(int, input().split()) a = list(map(int, stdin.readline().strip().split())) # c = Counter( # a) # using counter is slow, 2074 ms compared to 1341ms of direct counter c = [0] * (m + 3) for i in a: c[i] += 1 dp = [[float('-inf')] * 3 for _ in range(3)] dp[0][0] = 0 for i in range(1, m + 1): new_dp = [[float('-inf')] * 3 for _ in range(3)] for x in range(0, 3): for y in range(0, 3): for z in range(0, 3): if c[i] >= x + y + z: remaining = c[i] - x - y - z new_dp[y][z] = max(new_dp[y][z], dp[x][y] + z + remaining // 3) dp = new_dp print(dp[0][0]) ```
instruction
0
88,410
19
176,820
Yes
output
1
88,410
19
176,821
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are playing a game of Jongmah. You don't need to know the rules to solve this problem. You have n tiles in your hand. Each tile has an integer between 1 and m written on it. To win the game, you will need to form some number of triples. Each triple consists of three tiles, such that the numbers written on the tiles are either all the same or consecutive. For example, 7, 7, 7 is a valid triple, and so is 12, 13, 14, but 2,2,3 or 2,4,6 are not. You can only use the tiles in your hand to form triples. Each tile can be used in at most one triple. To determine how close you are to the win, you want to know the maximum number of triples you can form from the tiles in your hand. Input The first line contains two integers integer n and m (1 ≀ n, m ≀ 10^6) β€” the number of tiles in your hand and the number of tiles types. The second line contains integers a_1, a_2, …, a_n (1 ≀ a_i ≀ m), where a_i denotes the number written on the i-th tile. Output Print one integer: the maximum number of triples you can form. Examples Input 10 6 2 3 3 3 4 4 4 5 5 6 Output 3 Input 12 6 1 5 3 3 3 4 3 5 3 2 3 3 Output 3 Input 13 5 1 1 5 1 2 3 3 2 4 2 3 4 5 Output 4 Note In the first example, we have tiles 2, 3, 3, 3, 4, 4, 4, 5, 5, 6. We can form three triples in the following way: 2, 3, 4; 3, 4, 5; 4, 5, 6. Since there are only 10 tiles, there is no way we could form 4 triples, so the answer is 3. In the second example, we have tiles 1, 2, 3 (7 times), 4, 5 (2 times). We can form 3 triples as follows: 1, 2, 3; 3, 3, 3; 3, 4, 5. One can show that forming 4 triples is not possible. Submitted Solution: ``` n, m = map(int, input().split()) A = list(map(int, input().split())) qu = n hek = dict() for i in range(1, m + 1): hek[i] = 0 for j in A: hek[j] += 1 cnt = 0 for u in range(1, m + 1): if hek[u]: f = 1 V = [0, 0] for i in range(1, m + 1): V.append(hek[i]) V.append(0) V.append(0) A = V for i in range(2, m + 2): z = A[i] % 3 if z == 0: continue elif z == 1: if (A[i - 1] and A[i - 2]) or (A[i - 1] and A[i + 1]) or (A[i + 1] and A[i + 2]): continue else: qu -= 1 else: if (A[i - 1] >= 2 and A[i - 2] >= 2) or (A[i - 1] >= 2 and A[i + 1] >= 2) or (A[i + 1] >= 2 and A[i + 2] >= 2): continue else: qu -= 1 if (A[i - 1] and A[i - 2]) or (A[i - 1] and A[i + 1]) or (A[i + 1] and A[i + 2]): continue else: qu -= 1 print(qu // 3) ```
instruction
0
88,411
19
176,822
No
output
1
88,411
19
176,823
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are playing a game of Jongmah. You don't need to know the rules to solve this problem. You have n tiles in your hand. Each tile has an integer between 1 and m written on it. To win the game, you will need to form some number of triples. Each triple consists of three tiles, such that the numbers written on the tiles are either all the same or consecutive. For example, 7, 7, 7 is a valid triple, and so is 12, 13, 14, but 2,2,3 or 2,4,6 are not. You can only use the tiles in your hand to form triples. Each tile can be used in at most one triple. To determine how close you are to the win, you want to know the maximum number of triples you can form from the tiles in your hand. Input The first line contains two integers integer n and m (1 ≀ n, m ≀ 10^6) β€” the number of tiles in your hand and the number of tiles types. The second line contains integers a_1, a_2, …, a_n (1 ≀ a_i ≀ m), where a_i denotes the number written on the i-th tile. Output Print one integer: the maximum number of triples you can form. Examples Input 10 6 2 3 3 3 4 4 4 5 5 6 Output 3 Input 12 6 1 5 3 3 3 4 3 5 3 2 3 3 Output 3 Input 13 5 1 1 5 1 2 3 3 2 4 2 3 4 5 Output 4 Note In the first example, we have tiles 2, 3, 3, 3, 4, 4, 4, 5, 5, 6. We can form three triples in the following way: 2, 3, 4; 3, 4, 5; 4, 5, 6. Since there are only 10 tiles, there is no way we could form 4 triples, so the answer is 3. In the second example, we have tiles 1, 2, 3 (7 times), 4, 5 (2 times). We can form 3 triples as follows: 1, 2, 3; 3, 3, 3; 3, 4, 5. One can show that forming 4 triples is not possible. Submitted Solution: ``` n,m=map(int,input().split()) s=list(map(int,input().split())) ans=0 t=[0]*(m+1) for i in range(n): t[s[i]]+=1 for i in range(1,m+1): if i+2<=m: mm = min(t[i],t[i+1],t[i+2]) if mm>0: ans+=mm t[i]-=mm t[i+1]-=mm t[i+2]-=mm ans+=(t[i]//3) print(ans) ```
instruction
0
88,412
19
176,824
No
output
1
88,412
19
176,825
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are playing a game of Jongmah. You don't need to know the rules to solve this problem. You have n tiles in your hand. Each tile has an integer between 1 and m written on it. To win the game, you will need to form some number of triples. Each triple consists of three tiles, such that the numbers written on the tiles are either all the same or consecutive. For example, 7, 7, 7 is a valid triple, and so is 12, 13, 14, but 2,2,3 or 2,4,6 are not. You can only use the tiles in your hand to form triples. Each tile can be used in at most one triple. To determine how close you are to the win, you want to know the maximum number of triples you can form from the tiles in your hand. Input The first line contains two integers integer n and m (1 ≀ n, m ≀ 10^6) β€” the number of tiles in your hand and the number of tiles types. The second line contains integers a_1, a_2, …, a_n (1 ≀ a_i ≀ m), where a_i denotes the number written on the i-th tile. Output Print one integer: the maximum number of triples you can form. Examples Input 10 6 2 3 3 3 4 4 4 5 5 6 Output 3 Input 12 6 1 5 3 3 3 4 3 5 3 2 3 3 Output 3 Input 13 5 1 1 5 1 2 3 3 2 4 2 3 4 5 Output 4 Note In the first example, we have tiles 2, 3, 3, 3, 4, 4, 4, 5, 5, 6. We can form three triples in the following way: 2, 3, 4; 3, 4, 5; 4, 5, 6. Since there are only 10 tiles, there is no way we could form 4 triples, so the answer is 3. In the second example, we have tiles 1, 2, 3 (7 times), 4, 5 (2 times). We can form 3 triples as follows: 1, 2, 3; 3, 3, 3; 3, 4, 5. One can show that forming 4 triples is not possible. Submitted Solution: ``` n,m=map(int,input().split()) s=list(map(int,input().split())) ans=0 t=[0]*(m+1) for i in range(n): t[s[i]]+=1 for i in range(1,m+1): if i+2<=m: if t[i]%3==2 and (t[i+1]%3==2 or t[i+2]%3==2): mm = min(2,t[i+1],t[i+2]) ans += mm t[i]-=mm t[i+1]-=mm t[i+2]-=mm if t[i]%3>=1 and t[i+1]%3>=1 and t[i+2]%3>=1: ans+=1 t[i]-=1 t[i+1]-=1 t[i+2]-=1 ans+=(t[i]//3) print(ans) ```
instruction
0
88,413
19
176,826
No
output
1
88,413
19
176,827
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are playing a game of Jongmah. You don't need to know the rules to solve this problem. You have n tiles in your hand. Each tile has an integer between 1 and m written on it. To win the game, you will need to form some number of triples. Each triple consists of three tiles, such that the numbers written on the tiles are either all the same or consecutive. For example, 7, 7, 7 is a valid triple, and so is 12, 13, 14, but 2,2,3 or 2,4,6 are not. You can only use the tiles in your hand to form triples. Each tile can be used in at most one triple. To determine how close you are to the win, you want to know the maximum number of triples you can form from the tiles in your hand. Input The first line contains two integers integer n and m (1 ≀ n, m ≀ 10^6) β€” the number of tiles in your hand and the number of tiles types. The second line contains integers a_1, a_2, …, a_n (1 ≀ a_i ≀ m), where a_i denotes the number written on the i-th tile. Output Print one integer: the maximum number of triples you can form. Examples Input 10 6 2 3 3 3 4 4 4 5 5 6 Output 3 Input 12 6 1 5 3 3 3 4 3 5 3 2 3 3 Output 3 Input 13 5 1 1 5 1 2 3 3 2 4 2 3 4 5 Output 4 Note In the first example, we have tiles 2, 3, 3, 3, 4, 4, 4, 5, 5, 6. We can form three triples in the following way: 2, 3, 4; 3, 4, 5; 4, 5, 6. Since there are only 10 tiles, there is no way we could form 4 triples, so the answer is 3. In the second example, we have tiles 1, 2, 3 (7 times), 4, 5 (2 times). We can form 3 triples as follows: 1, 2, 3; 3, 3, 3; 3, 4, 5. One can show that forming 4 triples is not possible. Submitted Solution: ``` from collections import Counter m,n=map(int,input().split()) mst=Counter(int(x) for x in input().split()) sst=sorted(list(mst.keys())) length=len(sst) pairs=0 if m > 2: if length==1: print(m//3) elif length==2: a,b=mst[sst[0]],mst[sst[1]] print(a//3+b//3) elif length > 2: for x in range(0,length-2): if sst[x+1]-sst[x]==sst[x+2]-sst[x+1] and mst[sst[x]]>0 and mst[sst[x+1]]>0 and mst[sst[x+2]]>0: ans=min(mst[sst[x]],mst[sst[x+1]],mst[sst[x+2]]) mst[sst[x]],mst[sst[x+1]],mst[sst[x+2]]=mst[sst[x]]-ans,mst[sst[x+1]]-ans,mst[sst[x+2]]-ans pairs+=ans if mst[sst[x]]>2: pairs+=(mst[sst[x]]//3) mst[sst[x]]%=3 elif mst[sst[x]]>2: pairs+=(mst[sst[x]]//3) mst[sst[x]]%=3 print(pairs) else: print(pairs) ```
instruction
0
88,414
19
176,828
No
output
1
88,414
19
176,829
Provide tags and a correct Python 3 solution for this coding contest problem. Misha and Vanya have played several table tennis sets. Each set consists of several serves, each serve is won by one of the players, he receives one point and the loser receives nothing. Once one of the players scores exactly k points, the score is reset and a new set begins. Across all the sets Misha scored a points in total, and Vanya scored b points. Given this information, determine the maximum number of sets they could have played, or that the situation is impossible. Note that the game consisted of several complete sets. Input The first line contains three space-separated integers k, a and b (1 ≀ k ≀ 109, 0 ≀ a, b ≀ 109, a + b > 0). Output If the situation is impossible, print a single number -1. Otherwise, print the maximum possible number of sets. Examples Input 11 11 5 Output 1 Input 11 2 3 Output -1 Note Note that the rules of the game in this problem differ from the real table tennis game, for example, the rule of "balance" (the winning player has to be at least two points ahead to win a set) has no power within the present problem.
instruction
0
88,889
19
177,778
Tags: math Correct Solution: ``` import sys read=lambda:sys.stdin.readline().strip() write=lambda x:sys.stdout.write(x+"\n") p, a, b = map(int, read().split()) qa, ra = divmod(a, p) qb, rb = divmod(b, p) if qa >= 1 and qb >= 1: write(str(qa + qb)) elif qa >= 1 and qb == 0: if ra == 0: write(str(qa)) else: write("-1") elif qb >= 1 and qa == 0: if rb == 0: write(str(qb)) else: write("-1") else: write("-1") ```
output
1
88,889
19
177,779
Provide tags and a correct Python 3 solution for this coding contest problem. Misha and Vanya have played several table tennis sets. Each set consists of several serves, each serve is won by one of the players, he receives one point and the loser receives nothing. Once one of the players scores exactly k points, the score is reset and a new set begins. Across all the sets Misha scored a points in total, and Vanya scored b points. Given this information, determine the maximum number of sets they could have played, or that the situation is impossible. Note that the game consisted of several complete sets. Input The first line contains three space-separated integers k, a and b (1 ≀ k ≀ 109, 0 ≀ a, b ≀ 109, a + b > 0). Output If the situation is impossible, print a single number -1. Otherwise, print the maximum possible number of sets. Examples Input 11 11 5 Output 1 Input 11 2 3 Output -1 Note Note that the rules of the game in this problem differ from the real table tennis game, for example, the rule of "balance" (the winning player has to be at least two points ahead to win a set) has no power within the present problem.
instruction
0
88,890
19
177,780
Tags: math Correct Solution: ``` k, a, b = map(int, input().split()) mx_a = a // k mx_b = b // k if mx_a == 0 and b % k != 0: print(-1) elif mx_b == 0 and a % k != 0: print(-1) else: print(mx_a + mx_b) ```
output
1
88,890
19
177,781
Provide tags and a correct Python 3 solution for this coding contest problem. Misha and Vanya have played several table tennis sets. Each set consists of several serves, each serve is won by one of the players, he receives one point and the loser receives nothing. Once one of the players scores exactly k points, the score is reset and a new set begins. Across all the sets Misha scored a points in total, and Vanya scored b points. Given this information, determine the maximum number of sets they could have played, or that the situation is impossible. Note that the game consisted of several complete sets. Input The first line contains three space-separated integers k, a and b (1 ≀ k ≀ 109, 0 ≀ a, b ≀ 109, a + b > 0). Output If the situation is impossible, print a single number -1. Otherwise, print the maximum possible number of sets. Examples Input 11 11 5 Output 1 Input 11 2 3 Output -1 Note Note that the rules of the game in this problem differ from the real table tennis game, for example, the rule of "balance" (the winning player has to be at least two points ahead to win a set) has no power within the present problem.
instruction
0
88,891
19
177,782
Tags: math Correct Solution: ``` k,a,b = map(int,input().split()) match = a//k + b//k if match==0 or (a%k and b//k==0) or (b%k and a//k==0): print(-1) else: print(match) ```
output
1
88,891
19
177,783
Provide tags and a correct Python 3 solution for this coding contest problem. Misha and Vanya have played several table tennis sets. Each set consists of several serves, each serve is won by one of the players, he receives one point and the loser receives nothing. Once one of the players scores exactly k points, the score is reset and a new set begins. Across all the sets Misha scored a points in total, and Vanya scored b points. Given this information, determine the maximum number of sets they could have played, or that the situation is impossible. Note that the game consisted of several complete sets. Input The first line contains three space-separated integers k, a and b (1 ≀ k ≀ 109, 0 ≀ a, b ≀ 109, a + b > 0). Output If the situation is impossible, print a single number -1. Otherwise, print the maximum possible number of sets. Examples Input 11 11 5 Output 1 Input 11 2 3 Output -1 Note Note that the rules of the game in this problem differ from the real table tennis game, for example, the rule of "balance" (the winning player has to be at least two points ahead to win a set) has no power within the present problem.
instruction
0
88,892
19
177,784
Tags: math Correct Solution: ``` k, a, b = list(map(int, input().split())) if a == 0 and (b % k != 0): print(-1) exit() if b == 0 and (a % k != 0): print(-1) exit() time_a = (b >= k) time_b = (a >= k) if a % k != 0 and not time_a: print(-1) exit() if b % k != 0 and not time_b: print(-1) exit() print(a // k + b // k) ```
output
1
88,892
19
177,785
Provide tags and a correct Python 3 solution for this coding contest problem. Misha and Vanya have played several table tennis sets. Each set consists of several serves, each serve is won by one of the players, he receives one point and the loser receives nothing. Once one of the players scores exactly k points, the score is reset and a new set begins. Across all the sets Misha scored a points in total, and Vanya scored b points. Given this information, determine the maximum number of sets they could have played, or that the situation is impossible. Note that the game consisted of several complete sets. Input The first line contains three space-separated integers k, a and b (1 ≀ k ≀ 109, 0 ≀ a, b ≀ 109, a + b > 0). Output If the situation is impossible, print a single number -1. Otherwise, print the maximum possible number of sets. Examples Input 11 11 5 Output 1 Input 11 2 3 Output -1 Note Note that the rules of the game in this problem differ from the real table tennis game, for example, the rule of "balance" (the winning player has to be at least two points ahead to win a set) has no power within the present problem.
instruction
0
88,893
19
177,786
Tags: math Correct Solution: ``` k, a, b = map(int, input().split()) if (a >= k and b >= k) or (a != 0 and a % k == 0) or(b != 0 and b % k == 0): print(a // k + b // k) else: print(-1) ```
output
1
88,893
19
177,787
Provide tags and a correct Python 3 solution for this coding contest problem. Misha and Vanya have played several table tennis sets. Each set consists of several serves, each serve is won by one of the players, he receives one point and the loser receives nothing. Once one of the players scores exactly k points, the score is reset and a new set begins. Across all the sets Misha scored a points in total, and Vanya scored b points. Given this information, determine the maximum number of sets they could have played, or that the situation is impossible. Note that the game consisted of several complete sets. Input The first line contains three space-separated integers k, a and b (1 ≀ k ≀ 109, 0 ≀ a, b ≀ 109, a + b > 0). Output If the situation is impossible, print a single number -1. Otherwise, print the maximum possible number of sets. Examples Input 11 11 5 Output 1 Input 11 2 3 Output -1 Note Note that the rules of the game in this problem differ from the real table tennis game, for example, the rule of "balance" (the winning player has to be at least two points ahead to win a set) has no power within the present problem.
instruction
0
88,894
19
177,788
Tags: math Correct Solution: ``` a, b, c = (input().split(" ")) # print(a + " " + b + " " + c) a = int(a) b = int(b) c = int(c) if a > b and a > c: print(-1) elif a > b: if c % a == 0: print(int(c/a)) else: print(-1) elif (a > c): if b % a == 0: print(int(b/a)) else: print(-1) else: print(int(b/a) + int(c/a)) ```
output
1
88,894
19
177,789
Provide tags and a correct Python 3 solution for this coding contest problem. Misha and Vanya have played several table tennis sets. Each set consists of several serves, each serve is won by one of the players, he receives one point and the loser receives nothing. Once one of the players scores exactly k points, the score is reset and a new set begins. Across all the sets Misha scored a points in total, and Vanya scored b points. Given this information, determine the maximum number of sets they could have played, or that the situation is impossible. Note that the game consisted of several complete sets. Input The first line contains three space-separated integers k, a and b (1 ≀ k ≀ 109, 0 ≀ a, b ≀ 109, a + b > 0). Output If the situation is impossible, print a single number -1. Otherwise, print the maximum possible number of sets. Examples Input 11 11 5 Output 1 Input 11 2 3 Output -1 Note Note that the rules of the game in this problem differ from the real table tennis game, for example, the rule of "balance" (the winning player has to be at least two points ahead to win a set) has no power within the present problem.
instruction
0
88,895
19
177,790
Tags: math Correct Solution: ``` c,a, b = [ int(x) for x in input().split() ] if a%c != 0 and b < c: print('-1') elif b%c != 0 and a < c: print('-1') else: print(str(a//c + b//c)) ```
output
1
88,895
19
177,791
Provide tags and a correct Python 3 solution for this coding contest problem. Misha and Vanya have played several table tennis sets. Each set consists of several serves, each serve is won by one of the players, he receives one point and the loser receives nothing. Once one of the players scores exactly k points, the score is reset and a new set begins. Across all the sets Misha scored a points in total, and Vanya scored b points. Given this information, determine the maximum number of sets they could have played, or that the situation is impossible. Note that the game consisted of several complete sets. Input The first line contains three space-separated integers k, a and b (1 ≀ k ≀ 109, 0 ≀ a, b ≀ 109, a + b > 0). Output If the situation is impossible, print a single number -1. Otherwise, print the maximum possible number of sets. Examples Input 11 11 5 Output 1 Input 11 2 3 Output -1 Note Note that the rules of the game in this problem differ from the real table tennis game, for example, the rule of "balance" (the winning player has to be at least two points ahead to win a set) has no power within the present problem.
instruction
0
88,896
19
177,792
Tags: math Correct Solution: ``` k,a,b=map(int,input().split()) print(-1 if a<k and b%k or b<k and a%k else a//k+b//k) # Made By Mostafa_Khaled ```
output
1
88,896
19
177,793
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Misha and Vanya have played several table tennis sets. Each set consists of several serves, each serve is won by one of the players, he receives one point and the loser receives nothing. Once one of the players scores exactly k points, the score is reset and a new set begins. Across all the sets Misha scored a points in total, and Vanya scored b points. Given this information, determine the maximum number of sets they could have played, or that the situation is impossible. Note that the game consisted of several complete sets. Input The first line contains three space-separated integers k, a and b (1 ≀ k ≀ 109, 0 ≀ a, b ≀ 109, a + b > 0). Output If the situation is impossible, print a single number -1. Otherwise, print the maximum possible number of sets. Examples Input 11 11 5 Output 1 Input 11 2 3 Output -1 Note Note that the rules of the game in this problem differ from the real table tennis game, for example, the rule of "balance" (the winning player has to be at least two points ahead to win a set) has no power within the present problem. Submitted Solution: ``` K, a, b = map(int, input().split()) if a >= K and b >= K: print(a//K + b//K) elif a >= K and b < K: print(-1 if a%K != 0 else a//K) elif a < K and b >= K: print(-1 if b%K != 0 else b//K) else: print(-1) ```
instruction
0
88,897
19
177,794
Yes
output
1
88,897
19
177,795
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Misha and Vanya have played several table tennis sets. Each set consists of several serves, each serve is won by one of the players, he receives one point and the loser receives nothing. Once one of the players scores exactly k points, the score is reset and a new set begins. Across all the sets Misha scored a points in total, and Vanya scored b points. Given this information, determine the maximum number of sets they could have played, or that the situation is impossible. Note that the game consisted of several complete sets. Input The first line contains three space-separated integers k, a and b (1 ≀ k ≀ 109, 0 ≀ a, b ≀ 109, a + b > 0). Output If the situation is impossible, print a single number -1. Otherwise, print the maximum possible number of sets. Examples Input 11 11 5 Output 1 Input 11 2 3 Output -1 Note Note that the rules of the game in this problem differ from the real table tennis game, for example, the rule of "balance" (the winning player has to be at least two points ahead to win a set) has no power within the present problem. Submitted Solution: ``` k,a,b = map(int,input().split()) from math import floor awin = floor(a/k) bwin = floor(b/k) if b%k > awin*(k-1) or a%k > bwin*(k-1) : print(-1) else : print(awin + bwin) ```
instruction
0
88,898
19
177,796
Yes
output
1
88,898
19
177,797
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Misha and Vanya have played several table tennis sets. Each set consists of several serves, each serve is won by one of the players, he receives one point and the loser receives nothing. Once one of the players scores exactly k points, the score is reset and a new set begins. Across all the sets Misha scored a points in total, and Vanya scored b points. Given this information, determine the maximum number of sets they could have played, or that the situation is impossible. Note that the game consisted of several complete sets. Input The first line contains three space-separated integers k, a and b (1 ≀ k ≀ 109, 0 ≀ a, b ≀ 109, a + b > 0). Output If the situation is impossible, print a single number -1. Otherwise, print the maximum possible number of sets. Examples Input 11 11 5 Output 1 Input 11 2 3 Output -1 Note Note that the rules of the game in this problem differ from the real table tennis game, for example, the rule of "balance" (the winning player has to be at least two points ahead to win a set) has no power within the present problem. Submitted Solution: ``` a,b,c=map(int,input().split()) if b<a and c<a:print(-1) elif b<a and c%a:print(-1) elif c<a and b%a:print(-1) else:print(b//a+c//a) ```
instruction
0
88,899
19
177,798
Yes
output
1
88,899
19
177,799
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Misha and Vanya have played several table tennis sets. Each set consists of several serves, each serve is won by one of the players, he receives one point and the loser receives nothing. Once one of the players scores exactly k points, the score is reset and a new set begins. Across all the sets Misha scored a points in total, and Vanya scored b points. Given this information, determine the maximum number of sets they could have played, or that the situation is impossible. Note that the game consisted of several complete sets. Input The first line contains three space-separated integers k, a and b (1 ≀ k ≀ 109, 0 ≀ a, b ≀ 109, a + b > 0). Output If the situation is impossible, print a single number -1. Otherwise, print the maximum possible number of sets. Examples Input 11 11 5 Output 1 Input 11 2 3 Output -1 Note Note that the rules of the game in this problem differ from the real table tennis game, for example, the rule of "balance" (the winning player has to be at least two points ahead to win a set) has no power within the present problem. Submitted Solution: ``` k, a, b = [int(x) for x in input().split()] result = a//k + b//k if result == 0 or (a%k != 0 and b < k) or (b%k != 0 and a < k): print('-1') else: print(result) #GTFO from my code, 612! ```
instruction
0
88,900
19
177,800
Yes
output
1
88,900
19
177,801
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Misha and Vanya have played several table tennis sets. Each set consists of several serves, each serve is won by one of the players, he receives one point and the loser receives nothing. Once one of the players scores exactly k points, the score is reset and a new set begins. Across all the sets Misha scored a points in total, and Vanya scored b points. Given this information, determine the maximum number of sets they could have played, or that the situation is impossible. Note that the game consisted of several complete sets. Input The first line contains three space-separated integers k, a and b (1 ≀ k ≀ 109, 0 ≀ a, b ≀ 109, a + b > 0). Output If the situation is impossible, print a single number -1. Otherwise, print the maximum possible number of sets. Examples Input 11 11 5 Output 1 Input 11 2 3 Output -1 Note Note that the rules of the game in this problem differ from the real table tennis game, for example, the rule of "balance" (the winning player has to be at least two points ahead to win a set) has no power within the present problem. Submitted Solution: ``` k, a, b = map(int, input().split()) if(a%k!=0 and b%k!=0): print(-1) else: print(a//k+b//k) ```
instruction
0
88,901
19
177,802
No
output
1
88,901
19
177,803
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Misha and Vanya have played several table tennis sets. Each set consists of several serves, each serve is won by one of the players, he receives one point and the loser receives nothing. Once one of the players scores exactly k points, the score is reset and a new set begins. Across all the sets Misha scored a points in total, and Vanya scored b points. Given this information, determine the maximum number of sets they could have played, or that the situation is impossible. Note that the game consisted of several complete sets. Input The first line contains three space-separated integers k, a and b (1 ≀ k ≀ 109, 0 ≀ a, b ≀ 109, a + b > 0). Output If the situation is impossible, print a single number -1. Otherwise, print the maximum possible number of sets. Examples Input 11 11 5 Output 1 Input 11 2 3 Output -1 Note Note that the rules of the game in this problem differ from the real table tennis game, for example, the rule of "balance" (the winning player has to be at least two points ahead to win a set) has no power within the present problem. Submitted Solution: ``` a, b, c = (input().split(" ")) # print(a + " " + b + " " + c) a = int(a) b = int(b) c = int(c) if a > b and a > c: print(-1) elif b % a != c % a: print(-1) else: ans = 0 ans += int(b / a) + int(c / a) print(ans) ```
instruction
0
88,902
19
177,804
No
output
1
88,902
19
177,805
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Misha and Vanya have played several table tennis sets. Each set consists of several serves, each serve is won by one of the players, he receives one point and the loser receives nothing. Once one of the players scores exactly k points, the score is reset and a new set begins. Across all the sets Misha scored a points in total, and Vanya scored b points. Given this information, determine the maximum number of sets they could have played, or that the situation is impossible. Note that the game consisted of several complete sets. Input The first line contains three space-separated integers k, a and b (1 ≀ k ≀ 109, 0 ≀ a, b ≀ 109, a + b > 0). Output If the situation is impossible, print a single number -1. Otherwise, print the maximum possible number of sets. Examples Input 11 11 5 Output 1 Input 11 2 3 Output -1 Note Note that the rules of the game in this problem differ from the real table tennis game, for example, the rule of "balance" (the winning player has to be at least two points ahead to win a set) has no power within the present problem. Submitted Solution: ``` k,a,b=map(int,input().split()) print (a//k+b//k if (a>=k and b>=k) or a%k==0 or b%k==0 else -1) ```
instruction
0
88,903
19
177,806
No
output
1
88,903
19
177,807
Provide a correct Python 3 solution for this coding contest problem. Tak performed the following action N times: rolling two dice. The result of the i-th roll is D_{i,1} and D_{i,2}. Check if doublets occurred at least three times in a row. Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold. Constraints * 3 \leq N \leq 100 * 1\leq D_{i,j} \leq 6 * All values in input are integers. Input Input is given from Standard Input in the following format: N D_{1,1} D_{1,2} \vdots D_{N,1} D_{N,2} Output Print `Yes` if doublets occurred at least three times in a row. Print `No` otherwise. Examples Input 5 1 2 6 6 4 4 3 3 3 2 Output Yes Input 5 1 1 2 2 3 4 5 5 6 6 Output No Input 6 1 1 2 2 3 3 4 4 5 5 6 6 Output Yes
instruction
0
88,991
19
177,982
"Correct Solution: ``` N=int(input()) zoro=0 res=0 for _ in [0]*N: a,b=map(int,input().split()) if a==b: zoro+=1 res=max(res,zoro) else: zoro=0 print(['No','Yes'][res>2]) ```
output
1
88,991
19
177,983
Provide a correct Python 3 solution for this coding contest problem. Tak performed the following action N times: rolling two dice. The result of the i-th roll is D_{i,1} and D_{i,2}. Check if doublets occurred at least three times in a row. Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold. Constraints * 3 \leq N \leq 100 * 1\leq D_{i,j} \leq 6 * All values in input are integers. Input Input is given from Standard Input in the following format: N D_{1,1} D_{1,2} \vdots D_{N,1} D_{N,2} Output Print `Yes` if doublets occurred at least three times in a row. Print `No` otherwise. Examples Input 5 1 2 6 6 4 4 3 3 3 2 Output Yes Input 5 1 1 2 2 3 4 5 5 6 6 Output No Input 6 1 1 2 2 3 3 4 4 5 5 6 6 Output Yes
instruction
0
88,992
19
177,984
"Correct Solution: ``` print("YNeos"["000" not in "".join([str(eval(input().replace(" ","-")))for _ in "_"*int(input())])::2]) ```
output
1
88,992
19
177,985
Provide a correct Python 3 solution for this coding contest problem. Tak performed the following action N times: rolling two dice. The result of the i-th roll is D_{i,1} and D_{i,2}. Check if doublets occurred at least three times in a row. Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold. Constraints * 3 \leq N \leq 100 * 1\leq D_{i,j} \leq 6 * All values in input are integers. Input Input is given from Standard Input in the following format: N D_{1,1} D_{1,2} \vdots D_{N,1} D_{N,2} Output Print `Yes` if doublets occurred at least three times in a row. Print `No` otherwise. Examples Input 5 1 2 6 6 4 4 3 3 3 2 Output Yes Input 5 1 1 2 2 3 4 5 5 6 6 Output No Input 6 1 1 2 2 3 3 4 4 5 5 6 6 Output Yes
instruction
0
88,993
19
177,986
"Correct Solution: ``` n = int(input()) d = [] z = 0 for i in range(n): d1, d2 = map(int, input().split()) z = z+1 if d1==d2 else 0 d.append(z) ans = 'Yes' if max(d)>=3 else 'No' print(ans) ```
output
1
88,993
19
177,987
Provide a correct Python 3 solution for this coding contest problem. Tak performed the following action N times: rolling two dice. The result of the i-th roll is D_{i,1} and D_{i,2}. Check if doublets occurred at least three times in a row. Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold. Constraints * 3 \leq N \leq 100 * 1\leq D_{i,j} \leq 6 * All values in input are integers. Input Input is given from Standard Input in the following format: N D_{1,1} D_{1,2} \vdots D_{N,1} D_{N,2} Output Print `Yes` if doublets occurred at least three times in a row. Print `No` otherwise. Examples Input 5 1 2 6 6 4 4 3 3 3 2 Output Yes Input 5 1 1 2 2 3 4 5 5 6 6 Output No Input 6 1 1 2 2 3 3 4 4 5 5 6 6 Output Yes
instruction
0
88,994
19
177,988
"Correct Solution: ``` n=int(input()) cnt=0 ans="No" for i in range(n): d1,d2=map(int,input().split()) if d1==d2: cnt+=1 else: cnt=0 if cnt>=3: ans="Yes" print(ans) ```
output
1
88,994
19
177,989
Provide a correct Python 3 solution for this coding contest problem. Tak performed the following action N times: rolling two dice. The result of the i-th roll is D_{i,1} and D_{i,2}. Check if doublets occurred at least three times in a row. Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold. Constraints * 3 \leq N \leq 100 * 1\leq D_{i,j} \leq 6 * All values in input are integers. Input Input is given from Standard Input in the following format: N D_{1,1} D_{1,2} \vdots D_{N,1} D_{N,2} Output Print `Yes` if doublets occurred at least three times in a row. Print `No` otherwise. Examples Input 5 1 2 6 6 4 4 3 3 3 2 Output Yes Input 5 1 1 2 2 3 4 5 5 6 6 Output No Input 6 1 1 2 2 3 3 4 4 5 5 6 6 Output Yes
instruction
0
88,995
19
177,990
"Correct Solution: ``` n = int(input()) cnt = 0 for i in range(n): x, y = map(int, input().split()) if x == y: cnt += 1 else: cnt = 0 if cnt == 3: print('Yes') exit(0) print('No') ```
output
1
88,995
19
177,991
Provide a correct Python 3 solution for this coding contest problem. Tak performed the following action N times: rolling two dice. The result of the i-th roll is D_{i,1} and D_{i,2}. Check if doublets occurred at least three times in a row. Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold. Constraints * 3 \leq N \leq 100 * 1\leq D_{i,j} \leq 6 * All values in input are integers. Input Input is given from Standard Input in the following format: N D_{1,1} D_{1,2} \vdots D_{N,1} D_{N,2} Output Print `Yes` if doublets occurred at least three times in a row. Print `No` otherwise. Examples Input 5 1 2 6 6 4 4 3 3 3 2 Output Yes Input 5 1 1 2 2 3 4 5 5 6 6 Output No Input 6 1 1 2 2 3 3 4 4 5 5 6 6 Output Yes
instruction
0
88,996
19
177,992
"Correct Solution: ``` n=int(input()) c=0 o="" for _ in range(n): d,d1=map(int,input().split()) if d==d1: c+=1 if c==3: o="Yes" else: c=0 if o=="": o="No" print(o) ```
output
1
88,996
19
177,993
Provide a correct Python 3 solution for this coding contest problem. Tak performed the following action N times: rolling two dice. The result of the i-th roll is D_{i,1} and D_{i,2}. Check if doublets occurred at least three times in a row. Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold. Constraints * 3 \leq N \leq 100 * 1\leq D_{i,j} \leq 6 * All values in input are integers. Input Input is given from Standard Input in the following format: N D_{1,1} D_{1,2} \vdots D_{N,1} D_{N,2} Output Print `Yes` if doublets occurred at least three times in a row. Print `No` otherwise. Examples Input 5 1 2 6 6 4 4 3 3 3 2 Output Yes Input 5 1 1 2 2 3 4 5 5 6 6 Output No Input 6 1 1 2 2 3 3 4 4 5 5 6 6 Output Yes
instruction
0
88,997
19
177,994
"Correct Solution: ``` N = int(input()) cnt = 0 ans = 'No' for i in range(N): d1,d2 = map(int, input().split()) if d1==d2: cnt += 1 if cnt==3: ans = 'Yes' else: cnt = 0 print(ans) ```
output
1
88,997
19
177,995
Provide a correct Python 3 solution for this coding contest problem. Tak performed the following action N times: rolling two dice. The result of the i-th roll is D_{i,1} and D_{i,2}. Check if doublets occurred at least three times in a row. Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold. Constraints * 3 \leq N \leq 100 * 1\leq D_{i,j} \leq 6 * All values in input are integers. Input Input is given from Standard Input in the following format: N D_{1,1} D_{1,2} \vdots D_{N,1} D_{N,2} Output Print `Yes` if doublets occurred at least three times in a row. Print `No` otherwise. Examples Input 5 1 2 6 6 4 4 3 3 3 2 Output Yes Input 5 1 1 2 2 3 4 5 5 6 6 Output No Input 6 1 1 2 2 3 3 4 4 5 5 6 6 Output Yes
instruction
0
88,998
19
177,996
"Correct Solution: ``` ng = True cnt = 0 for i in range(int(input())): a, b = map(int, input().split()) if a==b: cnt+=1 else: cnt = 0 if cnt>=3: ng = False print("YNeos"[ng::2]) ```
output
1
88,998
19
177,997
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Tak performed the following action N times: rolling two dice. The result of the i-th roll is D_{i,1} and D_{i,2}. Check if doublets occurred at least three times in a row. Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold. Constraints * 3 \leq N \leq 100 * 1\leq D_{i,j} \leq 6 * All values in input are integers. Input Input is given from Standard Input in the following format: N D_{1,1} D_{1,2} \vdots D_{N,1} D_{N,2} Output Print `Yes` if doublets occurred at least three times in a row. Print `No` otherwise. Examples Input 5 1 2 6 6 4 4 3 3 3 2 Output Yes Input 5 1 1 2 2 3 4 5 5 6 6 Output No Input 6 1 1 2 2 3 3 4 4 5 5 6 6 Output Yes Submitted Solution: ``` n=int(input()) cnt=0 for _ in range(n): d1,d2=map(int,input().split()) if d1==d2: cnt += 1 else: cnt = 0 if cnt >= 3: print('Yes') break else: print('No') ```
instruction
0
88,999
19
177,998
Yes
output
1
88,999
19
177,999
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Tak performed the following action N times: rolling two dice. The result of the i-th roll is D_{i,1} and D_{i,2}. Check if doublets occurred at least three times in a row. Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold. Constraints * 3 \leq N \leq 100 * 1\leq D_{i,j} \leq 6 * All values in input are integers. Input Input is given from Standard Input in the following format: N D_{1,1} D_{1,2} \vdots D_{N,1} D_{N,2} Output Print `Yes` if doublets occurred at least three times in a row. Print `No` otherwise. Examples Input 5 1 2 6 6 4 4 3 3 3 2 Output Yes Input 5 1 1 2 2 3 4 5 5 6 6 Output No Input 6 1 1 2 2 3 3 4 4 5 5 6 6 Output Yes Submitted Solution: ``` N = int(input()) count = 0 ans = "No" for _ in range(N): a,b = map(int,input().split()) if a == b: count += 1 else: count = 0 if count == 3: ans = "Yes" print(ans) ```
instruction
0
89,000
19
178,000
Yes
output
1
89,000
19
178,001
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Tak performed the following action N times: rolling two dice. The result of the i-th roll is D_{i,1} and D_{i,2}. Check if doublets occurred at least three times in a row. Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold. Constraints * 3 \leq N \leq 100 * 1\leq D_{i,j} \leq 6 * All values in input are integers. Input Input is given from Standard Input in the following format: N D_{1,1} D_{1,2} \vdots D_{N,1} D_{N,2} Output Print `Yes` if doublets occurred at least three times in a row. Print `No` otherwise. Examples Input 5 1 2 6 6 4 4 3 3 3 2 Output Yes Input 5 1 1 2 2 3 4 5 5 6 6 Output No Input 6 1 1 2 2 3 3 4 4 5 5 6 6 Output Yes Submitted Solution: ``` N=input() n=int(N) x=0 for s in range(n): ds1,ds2=input().split() if ds1==ds2: x+=1 else: x=0 if x==3: print("Yes") break else: print("No") ```
instruction
0
89,001
19
178,002
Yes
output
1
89,001
19
178,003
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Tak performed the following action N times: rolling two dice. The result of the i-th roll is D_{i,1} and D_{i,2}. Check if doublets occurred at least three times in a row. Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold. Constraints * 3 \leq N \leq 100 * 1\leq D_{i,j} \leq 6 * All values in input are integers. Input Input is given from Standard Input in the following format: N D_{1,1} D_{1,2} \vdots D_{N,1} D_{N,2} Output Print `Yes` if doublets occurred at least three times in a row. Print `No` otherwise. Examples Input 5 1 2 6 6 4 4 3 3 3 2 Output Yes Input 5 1 1 2 2 3 4 5 5 6 6 Output No Input 6 1 1 2 2 3 3 4 4 5 5 6 6 Output Yes Submitted Solution: ``` N = int(input()) cnt = 0 mx = 0 for _ in range(N): a,b = map(int,input().split()) if a==b: cnt+=1 mx = max(cnt,mx) else : cnt=0 print("Yes" if mx >2 else "No") ```
instruction
0
89,002
19
178,004
Yes
output
1
89,002
19
178,005
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Tak performed the following action N times: rolling two dice. The result of the i-th roll is D_{i,1} and D_{i,2}. Check if doublets occurred at least three times in a row. Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold. Constraints * 3 \leq N \leq 100 * 1\leq D_{i,j} \leq 6 * All values in input are integers. Input Input is given from Standard Input in the following format: N D_{1,1} D_{1,2} \vdots D_{N,1} D_{N,2} Output Print `Yes` if doublets occurred at least three times in a row. Print `No` otherwise. Examples Input 5 1 2 6 6 4 4 3 3 3 2 Output Yes Input 5 1 1 2 2 3 4 5 5 6 6 Output No Input 6 1 1 2 2 3 3 4 4 5 5 6 6 Output Yes Submitted Solution: ``` N=int(input()) cnt=0 for i in range(N): if cnt==3: print('Yes') break D_1,D_2=map(int,input().split()) if D_1==D_2: cnt+=1 else: cnt=0 else: print('No') ```
instruction
0
89,003
19
178,006
No
output
1
89,003
19
178,007