问题

### Instructions: You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. You will NOT return anything except for the program.
### Question:
There is a 9\times 9 grid A, where each cell contains an integer between 1 and 9, inclusive.
Specifically, the cell at the i-th row from the top and j-th column from the left contains A_{i,j}.
If A satisfies all of the following conditions, print Yes. Otherwise, print No.

- For each row of A, the nine cells in that row contain each integer from 1 to 9 exactly once.
- For each column of A, the nine cells in that column contain each integer from 1 to 9 exactly once.
- Divide the rows of A into three groups, each of three rows, from top to bottom, and similarly divide the columns into three groups, each of three columns, from left to right.
Each 3\times 3 grid obtained from A in this way contains each integer from 1 to 9 exactly once.

Input

The input is given from Standard Input in the following format:
A_{1,1} A_{1,2} \ldots A_{1,9}
A_{2,1} A_{2,2} \ldots A_{2,9}
\vdots
A_{9,1} A_{9,2} \ldots A_{9,9}

Output

If the grid A satisfies all the conditions in the problem statement, print Yes; otherwise, print No.

Constraints


- 1\leq A_{i,j}\leq 9
- All input values are integers.

Sample Input 1

1 2 3 4 5 6 7 8 9
4 5 6 7 8 9 1 2 3
7 8 9 1 2 3 4 5 6
2 3 4 5 6 7 8 9 1
5 6 7 8 9 1 2 3 4
8 9 1 2 3 4 5 6 7
3 4 5 6 7 8 9 1 2
6 7 8 9 1 2 3 4 5
9 1 2 3 4 5 6 7 8

Sample Output 1

Yes

The grid A is shown below.

The grid A satisfies all three conditions, so print Yes.

Sample Input 2

1 2 3 4 5 6 7 8 9
2 3 4 5 6 7 8 9 1
3 4 5 6 7 8 9 1 2
4 5 6 7 8 9 1 2 3
5 6 7 8 9 1 2 3 4
6 7 8 9 1 2 3 4 5
7 8 9 1 2 3 4 5 6
8 9 1 2 3 4 5 6 7
9 1 2 3 4 5 6 7 8

Sample Output 2

No

The grid A is shown below.

For example, if you look at the top left 3\times 3 grid, you can see that the third condition is unsatisfied, so print No.

Sample Input 3

1 2 3 4 5 6 7 8 9
4 5 6 7 8 9 1 2 3
7 8 9 1 2 3 4 5 6
1 2 3 4 5 6 7 8 9
4 5 6 7 8 9 1 2 3
7 8 9 1 2 3 4 5 6
1 2 3 4 5 6 7 8 9
4 5 6 7 8 9 1 2 3
7 8 9 1 2 3 4 5 6

Sample Output 3

No

The grid A is shown below.

For example, if you look at the leftmost column, you can see that the second condition is unsatisfied, so print No.

### Format: Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within delimiters as follows.
```python
# YOUR CODE HERE
```

### Answer: (use the provided format with backticks)

答案

模型 模型答案 正确答案
金声玉亮2.0 ```python
# YOUR CODE HERE
def is_valid_sudoku(grid):
def is_valid_block(block):
return sorted(block) == list(range(1, 10))

# Check rows and columns
for i in range(9):
if not is_valid_block(grid[i]):
return False
if not is_valid_block([grid[j][i] for j in range(9)]):
return False

# Check 3x3 sub-grids
for i in range(0, 9, 3):
for j in range(0, 9, 3):
block = [grid[x][y] for x in range(i, i + 3) for y in range(j, j + 3)]
if not is_valid_block(block):
return False

return True

# Read input
grid = [list(map(int, input().split())) for _ in range(9)]

# Check if the grid is a valid Sudoku and print the result
if is_valid_sudoku(grid):
print("Yes")
else:
print("No")
```
[{"input": "1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n2 3 4 5 6 7 8 9 1\n5 6 7 8 9 1 2 3 4\n8 9 1 2 3 4 5 6 7\n3 4 5 6 7 8 9 1 2\n6 7 8 9 1 2 3 4 5\n9 1 2 3 4 5 6 7 8\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "1 2 3 4 5 6 7 8 9\n2 3 4 5 6 7 8 9 1\n3 4 5 6 7 8 9 1 2\n4 5 6 7 8 9 1 2 3\n5 6 7 8 9 1 2 3 4\n6 7 8 9 1 2 3 4 5\n7 8 9 1 2 3 4 5 6\n8 9 1 2 3 4 5 6 7\n9 1 2 3 4 5 6 7 8\n", "output": "No\n", "testtype": "stdin"}, {"input": "1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n", "output": "No\n", "testtype": "stdin"}]
deepseek-r1

```python
# Read the 9x9 grid from input
grid = [list(map(int, input().split())) for _ in range(9)]

# Check each row
for row in grid:
if set(row) != set(range(1, 10)):
print("No")
exit()

# Check each column
for col in range(9):
column = [grid[row][col] for row in range(9)]
if set(column) != set(range(1, 10)):
print("No")
exit()

# Check each 3x3 subgrid
for i in range(0, 9, 3):
for j in range(0, 9, 3):
subgrid = []
for x in range(i, i+3):
for y in range(j, j+3):
subgrid.append(grid[x][y])
if set(subgrid) != set(range(1, 10)):
print("No")
exit()

# If all checks passed
print("Yes")
```
[{"input": "1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n2 3 4 5 6 7 8 9 1\n5 6 7 8 9 1 2 3 4\n8 9 1 2 3 4 5 6 7\n3 4 5 6 7 8 9 1 2\n6 7 8 9 1 2 3 4 5\n9 1 2 3 4 5 6 7 8\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "1 2 3 4 5 6 7 8 9\n2 3 4 5 6 7 8 9 1\n3 4 5 6 7 8 9 1 2\n4 5 6 7 8 9 1 2 3\n5 6 7 8 9 1 2 3 4\n6 7 8 9 1 2 3 4 5\n7 8 9 1 2 3 4 5 6\n8 9 1 2 3 4 5 6 7\n9 1 2 3 4 5 6 7 8\n", "output": "No\n", "testtype": "stdin"}, {"input": "1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n", "output": "No\n", "testtype": "stdin"}]
gpto1 ```python
# YOUR CODE HERE
import sys

grid = [list(map(int, sys.stdin.readline().split())) for _ in range(9)]

digits = set(range(1, 10))

# Check rows
for row in grid:
if set(row) != digits:
print("No")
sys.exit()

# Check columns
for col in zip(*grid):
if set(col) != digits:
print("No")
sys.exit()

# Check 3x3 subgrids
for i in range(0, 9, 3):
for j in range(0, 9, 3):
block = [grid[x][y] for x in range(i, i + 3) for y in range(j, j + 3)]
if set(block) != digits:
print("No")
sys.exit()

print("Yes")
```
[{"input": "1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n2 3 4 5 6 7 8 9 1\n5 6 7 8 9 1 2 3 4\n8 9 1 2 3 4 5 6 7\n3 4 5 6 7 8 9 1 2\n6 7 8 9 1 2 3 4 5\n9 1 2 3 4 5 6 7 8\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "1 2 3 4 5 6 7 8 9\n2 3 4 5 6 7 8 9 1\n3 4 5 6 7 8 9 1 2\n4 5 6 7 8 9 1 2 3\n5 6 7 8 9 1 2 3 4\n6 7 8 9 1 2 3 4 5\n7 8 9 1 2 3 4 5 6\n8 9 1 2 3 4 5 6 7\n9 1 2 3 4 5 6 7 8\n", "output": "No\n", "testtype": "stdin"}, {"input": "1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n", "output": "No\n", "testtype": "stdin"}]
gpt-4o-2024-08-06 ```python
# YOUR CODE HERE
def is_valid_sudoku(grid):
# Check each row
for row in grid:
if sorted(row) != list(range(1, 10)):
return False

# Check each column
for col in range(9):
if sorted(grid[row][col] for row in range(9)) != list(range(1, 10)):
return False

# Check each 3x3 subgrid
for box_row in range(0, 9, 3):
for box_col in range(0, 9, 3):
subgrid = []
for i in range(3):
for j in range(3):
subgrid.append(grid[box_row + i][box_col + j])
if sorted(subgrid) != list(range(1, 10)):
return False

return True

def main():
import sys
input = sys.stdin.read
data = input().strip().split()

# Convert input data to a 9x9 grid
grid = []
for i in range(9):
grid.append(list(map(int, data[i*9:(i+1)*9])))

# Check if the grid is a valid Sudoku
if is_valid_sudoku(grid):
print("Yes")
else:
print("No")

if __name__ == "__main__":
main()
```
[{"input": "1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n2 3 4 5 6 7 8 9 1\n5 6 7 8 9 1 2 3 4\n8 9 1 2 3 4 5 6 7\n3 4 5 6 7 8 9 1 2\n6 7 8 9 1 2 3 4 5\n9 1 2 3 4 5 6 7 8\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "1 2 3 4 5 6 7 8 9\n2 3 4 5 6 7 8 9 1\n3 4 5 6 7 8 9 1 2\n4 5 6 7 8 9 1 2 3\n5 6 7 8 9 1 2 3 4\n6 7 8 9 1 2 3 4 5\n7 8 9 1 2 3 4 5 6\n8 9 1 2 3 4 5 6 7\n9 1 2 3 4 5 6 7 8\n", "output": "No\n", "testtype": "stdin"}, {"input": "1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n", "output": "No\n", "testtype": "stdin"}]
Qwen2-72B-Instruct ```python
from collections import Counter

def check_sudoku(grid):
# Check rows and columns
for i in range(9):
if len(set(grid[i])) != 9 or len(set(row[i] for row in grid)) != 9:
return False

# Check 3x3 subgrids
for i in range(0, 9, 3):
for j in range(0, 9, 3):
subgrid = [grid[x][y] for x in range(i, i+3) for y in range(j, j+3)]
if len(set(subgrid)) != 9:
return False

return True

if __name__ == "__main__":
grid = []
for _ in range(9):
row = list(map(int, input().split()))
grid.append(row)

print("Yes" if check_sudoku(grid) else "No")
```
```
[{"input": "1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n2 3 4 5 6 7 8 9 1\n5 6 7 8 9 1 2 3 4\n8 9 1 2 3 4 5 6 7\n3 4 5 6 7 8 9 1 2\n6 7 8 9 1 2 3 4 5\n9 1 2 3 4 5 6 7 8\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "1 2 3 4 5 6 7 8 9\n2 3 4 5 6 7 8 9 1\n3 4 5 6 7 8 9 1 2\n4 5 6 7 8 9 1 2 3\n5 6 7 8 9 1 2 3 4\n6 7 8 9 1 2 3 4 5\n7 8 9 1 2 3 4 5 6\n8 9 1 2 3 4 5 6 7\n9 1 2 3 4 5 6 7 8\n", "output": "No\n", "testtype": "stdin"}, {"input": "1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n", "output": "No\n", "testtype": "stdin"}]
DeepSeek-Coder-V2-Lite-Instruct ```python
# YOUR CODE HERE
def is_valid_sudoku(grid):
# Check rows
for row in grid:
if len(set(row)) != 9 or min(row) < 1 or max(row) > 9:
return "No"

# Check columns
for col in range(9):
if len(set(grid[row][col] for row in range(9))) != 9:
return "No"

# Check 3x3 subgrids
for i in range(0, 9, 3):
for j in range(0, 9, 3):
nums = [grid[x][y] for x in range(i, i + 3) for y in range(j, j + 3)]
if len(set(nums)) != 9:
return "No"

return "Yes"

# Read input
grid = [list(map(int, input().split())) for _ in range(9)]

# Check and print the result
print(is_valid_sudoku(grid))
```
[{"input": "1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n2 3 4 5 6 7 8 9 1\n5 6 7 8 9 1 2 3 4\n8 9 1 2 3 4 5 6 7\n3 4 5 6 7 8 9 1 2\n6 7 8 9 1 2 3 4 5\n9 1 2 3 4 5 6 7 8\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "1 2 3 4 5 6 7 8 9\n2 3 4 5 6 7 8 9 1\n3 4 5 6 7 8 9 1 2\n4 5 6 7 8 9 1 2 3\n5 6 7 8 9 1 2 3 4\n6 7 8 9 1 2 3 4 5\n7 8 9 1 2 3 4 5 6\n8 9 1 2 3 4 5 6 7\n9 1 2 3 4 5 6 7 8\n", "output": "No\n", "testtype": "stdin"}, {"input": "1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n", "output": "No\n", "testtype": "stdin"}]
Meta-Llama-3.1-405B-Instruct-Turbo ```python
import sys

def check_sudoku(grid):
# Check rows
for row in grid:
if sorted(row) != list(range(1, 10)):
return False

# Check columns
for col in range(9):
if sorted([grid[row][col] for row in range(9)]) != list(range(1, 10)):
return False

# Check 3x3 sub-grids
for i in range(0, 9, 3):
for j in range(0, 9, 3):
sub_grid = [grid[x][y] for x in range(i, i+3) for y in range(j, j+3)]
if sorted(sub_grid) != list(range(1, 10)):
return False

return True

grid = []
for _ in range(9):
row = list(map(int, sys.stdin.readline().split()))
grid.append(row)

if check_sudoku(grid):
print("Yes")
else:
print("No")
```
[{"input": "1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n2 3 4 5 6 7 8 9 1\n5 6 7 8 9 1 2 3 4\n8 9 1 2 3 4 5 6 7\n3 4 5 6 7 8 9 1 2\n6 7 8 9 1 2 3 4 5\n9 1 2 3 4 5 6 7 8\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "1 2 3 4 5 6 7 8 9\n2 3 4 5 6 7 8 9 1\n3 4 5 6 7 8 9 1 2\n4 5 6 7 8 9 1 2 3\n5 6 7 8 9 1 2 3 4\n6 7 8 9 1 2 3 4 5\n7 8 9 1 2 3 4 5 6\n8 9 1 2 3 4 5 6 7\n9 1 2 3 4 5 6 7 8\n", "output": "No\n", "testtype": "stdin"}, {"input": "1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n", "output": "No\n", "testtype": "stdin"}]
Meta-Llama-3.1-70B-Instruct-Turbo ```python
import sys

def main():
grid = [list(map(int, sys.stdin.readline().split())) for _ in range(9)]

for i in range(9):
if sorted(grid[i]) != list(range(1, 10)):
print("No")
return

for j in range(9):
column = [grid[i][j] for i in range(9)]
if sorted(column) != list(range(1, 10)):
print("No")
return

for i in range(0, 9, 3):
for j in range(0, 9, 3):
subgrid = [grid[x][y] for x in range(i, i+3) for y in range(j, j+3)]
if sorted(subgrid) != list(range(1, 10)):
print("No")
return

print("Yes")

if __name__ == "__main__":
main()
```
[{"input": "1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n2 3 4 5 6 7 8 9 1\n5 6 7 8 9 1 2 3 4\n8 9 1 2 3 4 5 6 7\n3 4 5 6 7 8 9 1 2\n6 7 8 9 1 2 3 4 5\n9 1 2 3 4 5 6 7 8\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "1 2 3 4 5 6 7 8 9\n2 3 4 5 6 7 8 9 1\n3 4 5 6 7 8 9 1 2\n4 5 6 7 8 9 1 2 3\n5 6 7 8 9 1 2 3 4\n6 7 8 9 1 2 3 4 5\n7 8 9 1 2 3 4 5 6\n8 9 1 2 3 4 5 6 7\n9 1 2 3 4 5 6 7 8\n", "output": "No\n", "testtype": "stdin"}, {"input": "1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n", "output": "No\n", "testtype": "stdin"}]
baichuan4 ```python
# YOUR CODE HERE

def is_valid_sudoku(grid):
# Check rows and columns
for i in range(9):
row_set = set()
col_set = set()
for j in range(9):
if grid[i][j] in row_set or grid[j][i] in col_set:
return "No"
row_set.add(grid[i][j])
col_set.add(grid[j][i])

# Check 3x3 subgrids
for i in range(0, 9, 3):
for j in range(0, 9, 3):
subgrid_set = set()
for x in range(3):
for y in range(3):
if grid[i+x][j+y] in subgrid_set:
return "No"
subgrid_set.add(grid[i+x][j+y])

return "Yes"

# Read input and convert to 2D list
grid = []
for _ in range(9):
row = list(map(int, input().split()))
grid.append(row)

# Check if the sudoku is valid
print(is_valid_sudoku(grid))
```
```
[{"input": "1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n2 3 4 5 6 7 8 9 1\n5 6 7 8 9 1 2 3 4\n8 9 1 2 3 4 5 6 7\n3 4 5 6 7 8 9 1 2\n6 7 8 9 1 2 3 4 5\n9 1 2 3 4 5 6 7 8\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "1 2 3 4 5 6 7 8 9\n2 3 4 5 6 7 8 9 1\n3 4 5 6 7 8 9 1 2\n4 5 6 7 8 9 1 2 3\n5 6 7 8 9 1 2 3 4\n6 7 8 9 1 2 3 4 5\n7 8 9 1 2 3 4 5 6\n8 9 1 2 3 4 5 6 7\n9 1 2 3 4 5 6 7 8\n", "output": "No\n", "testtype": "stdin"}, {"input": "1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n", "output": "No\n", "testtype": "stdin"}]
doubao ```python
def check_grid():
grid = [list(map(int, input().split())) for _ in range(9)]
for i in range(9):
row_set = set()
col_set = set()
for j in range(9):
row_set.add(grid[i][j])
col_set.add(grid[j][i])
if len(row_set)!= 9 or len(col_set)!= 9:
return "No"
for i in range(0, 9, 3):
for j in range(0, 9, 3):
subgrid_set = set()
for x in range(i, i + 3):
for y in range(j, j + 3):
subgrid_set.add(grid[x][y])
if len(subgrid_set)!= 9:
return "No"
return "Yes"

print(check_grid())
```
[{"input": "1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n2 3 4 5 6 7 8 9 1\n5 6 7 8 9 1 2 3 4\n8 9 1 2 3 4 5 6 7\n3 4 5 6 7 8 9 1 2\n6 7 8 9 1 2 3 4 5\n9 1 2 3 4 5 6 7 8\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "1 2 3 4 5 6 7 8 9\n2 3 4 5 6 7 8 9 1\n3 4 5 6 7 8 9 1 2\n4 5 6 7 8 9 1 2 3\n5 6 7 8 9 1 2 3 4\n6 7 8 9 1 2 3 4 5\n7 8 9 1 2 3 4 5 6\n8 9 1 2 3 4 5 6 7\n9 1 2 3 4 5 6 7 8\n", "output": "No\n", "testtype": "stdin"}, {"input": "1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n", "output": "No\n", "testtype": "stdin"}]
gpto1 ```python
# YOUR CODE HERE
import sys

grid = [list(map(int, sys.stdin.readline().split())) for _ in range(9)]

digits = set(range(1, 10))

# Check rows
for row in grid:
if set(row) != digits:
print("No")
sys.exit()

# Check columns
for col in zip(*grid):
if set(col) != digits:
print("No")
sys.exit()

# Check 3x3 subgrids
for i in range(0, 9, 3):
for j in range(0, 9, 3):
block = [grid[x][y] for x in range(i, i + 3) for y in range(j, j + 3)]
if set(block) != digits:
print("No")
sys.exit()

print("Yes")
```
[{"input": "1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n2 3 4 5 6 7 8 9 1\n5 6 7 8 9 1 2 3 4\n8 9 1 2 3 4 5 6 7\n3 4 5 6 7 8 9 1 2\n6 7 8 9 1 2 3 4 5\n9 1 2 3 4 5 6 7 8\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "1 2 3 4 5 6 7 8 9\n2 3 4 5 6 7 8 9 1\n3 4 5 6 7 8 9 1 2\n4 5 6 7 8 9 1 2 3\n5 6 7 8 9 1 2 3 4\n6 7 8 9 1 2 3 4 5\n7 8 9 1 2 3 4 5 6\n8 9 1 2 3 4 5 6 7\n9 1 2 3 4 5 6 7 8\n", "output": "No\n", "testtype": "stdin"}, {"input": "1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n", "output": "No\n", "testtype": "stdin"}]
kimi ```python
import sys
input = sys.stdin.readline

def check(A, i, j, n):
s = set()
for x in range(i, i + 3):
for y in range(j, j + 3):
s.add(A[x][y])
return len(s) == 9

def main():
A = [list(map(int, input().split())) for _ in range(9)]
for i in range(9):
s = set()
for j in range(9):
s.add(A[i][j])
if len(s) != 9:
print('No')
return
for j in range(9):
s = set()
for i in range(9):
s.add(A[i][j])
if len(s) != 9:
print('No')
return
for i in range(0, 9, 3):
for j in range(0, 9, 3):
if not check(A, i, j, 3):
print('No')
return
print('Yes')
main()
```
[{"input": "1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n2 3 4 5 6 7 8 9 1\n5 6 7 8 9 1 2 3 4\n8 9 1 2 3 4 5 6 7\n3 4 5 6 7 8 9 1 2\n6 7 8 9 1 2 3 4 5\n9 1 2 3 4 5 6 7 8\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "1 2 3 4 5 6 7 8 9\n2 3 4 5 6 7 8 9 1\n3 4 5 6 7 8 9 1 2\n4 5 6 7 8 9 1 2 3\n5 6 7 8 9 1 2 3 4\n6 7 8 9 1 2 3 4 5\n7 8 9 1 2 3 4 5 6\n8 9 1 2 3 4 5 6 7\n9 1 2 3 4 5 6 7 8\n", "output": "No\n", "testtype": "stdin"}, {"input": "1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n", "output": "No\n", "testtype": "stdin"}]
minimax ```python
# YOUR CODE HERE
import sys

def check_sudoku(grid):
# Check rows and columns
for i in range(9):
if sorted(grid[i]) != sorted(range(1, 10)) or sorted(grid[j][i] for j in range(9)) != sorted(range(1, 10)):
return "No"

# Check 3x3 sub-grids
for row in range(0, 9, 3):
for col in range(0, 9, 3):
block = [grid[r][c] for r in range(row, row + 3) for c in range(col, col + 3)]
if sorted(block) != sorted(range(1, 10)):
return "No"

return "Yes"

# Read the grid from stdin
grid = [list(map(int, input().split())) for _ in range(9)]

# Print the result
print(check_sudoku(grid))
```
[{"input": "1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n2 3 4 5 6 7 8 9 1\n5 6 7 8 9 1 2 3 4\n8 9 1 2 3 4 5 6 7\n3 4 5 6 7 8 9 1 2\n6 7 8 9 1 2 3 4 5\n9 1 2 3 4 5 6 7 8\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "1 2 3 4 5 6 7 8 9\n2 3 4 5 6 7 8 9 1\n3 4 5 6 7 8 9 1 2\n4 5 6 7 8 9 1 2 3\n5 6 7 8 9 1 2 3 4\n6 7 8 9 1 2 3 4 5\n7 8 9 1 2 3 4 5 6\n8 9 1 2 3 4 5 6 7\n9 1 2 3 4 5 6 7 8\n", "output": "No\n", "testtype": "stdin"}, {"input": "1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n", "output": "No\n", "testtype": "stdin"}]
wenxinyiyan ```python
# Read the input grid
grid = []
for _ in range(9):
row = list(map(int, input().split()))
grid.append(row)

# Check rows
def check_rows(grid):
for row in grid:
if sorted(row) != list(range(1, 10)):
return False
return True

# Check columns
def check_columns(grid):
for col in range(9):
column = [grid[row][col] for row in range(9)]
if sorted(column) != list(range(1, 10)):
return False
return True

# Check 3x3 grids
def check_3x3_grids(grid):
for i in range(0, 9, 3):
for j in range(0, 9, 3):
subgrid = [grid[x][y] for x in range(i, i+3) for y in range(j, j+3)]
if sorted(subgrid) != list(range(1, 10)):
return False
return True

# Perform all checks
if check_rows(grid) and check_columns(grid) and check_3x3_grids(grid):
print("Yes")
else:
print("No")
```
[{"input": "1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n2 3 4 5 6 7 8 9 1\n5 6 7 8 9 1 2 3 4\n8 9 1 2 3 4 5 6 7\n3 4 5 6 7 8 9 1 2\n6 7 8 9 1 2 3 4 5\n9 1 2 3 4 5 6 7 8\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "1 2 3 4 5 6 7 8 9\n2 3 4 5 6 7 8 9 1\n3 4 5 6 7 8 9 1 2\n4 5 6 7 8 9 1 2 3\n5 6 7 8 9 1 2 3 4\n6 7 8 9 1 2 3 4 5\n7 8 9 1 2 3 4 5 6\n8 9 1 2 3 4 5 6 7\n9 1 2 3 4 5 6 7 8\n", "output": "No\n", "testtype": "stdin"}, {"input": "1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n", "output": "No\n", "testtype": "stdin"}]
zhipu ```python
def is_valid_sudoku(grid):
# Check rows
for row in grid:
if len(set(row)) != 9:
return False

# Check columns
for col in range(9):
column = [grid[row][col] for row in range(9)]
if len(set(column)) != 9:
return False

# Check 3x3 subgrids
for i in range(0, 9, 3):
for j in range(0, 9, 3):
subgrid = [grid[x][y] for x in range(i, i + 3) for y in range(j, j + 3)]
if len(set(subgrid)) != 9:
return False

return True

def main():
import sys
input = sys.stdin.read
data = input().split()

# Parse the input into a 9x9 grid
grid = [list(map(int, data[i * 9:(i + 1) * 9])) for i in range(9)]

# Validate the Sudoku grid
if is_valid_sudoku(grid):
print("Yes")
else:
print("No")

if __name__ == "__main__":
main()
```
[{"input": "1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n2 3 4 5 6 7 8 9 1\n5 6 7 8 9 1 2 3 4\n8 9 1 2 3 4 5 6 7\n3 4 5 6 7 8 9 1 2\n6 7 8 9 1 2 3 4 5\n9 1 2 3 4 5 6 7 8\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "1 2 3 4 5 6 7 8 9\n2 3 4 5 6 7 8 9 1\n3 4 5 6 7 8 9 1 2\n4 5 6 7 8 9 1 2 3\n5 6 7 8 9 1 2 3 4\n6 7 8 9 1 2 3 4 5\n7 8 9 1 2 3 4 5 6\n8 9 1 2 3 4 5 6 7\n9 1 2 3 4 5 6 7 8\n", "output": "No\n", "testtype": "stdin"}, {"input": "1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n", "output": "No\n", "testtype": "stdin"}]
deepseek-v3 ```python
# YOUR CODE HERE
def is_valid_sudoku(grid):
# Check rows
for row in grid:
if sorted(row) != list(range(1, 10)):
return False
# Check columns
for col in range(9):
column = [grid[row][col] for row in range(9)]
if sorted(column) != list(range(1, 10)):
return False
# Check 3x3 subgrids
for i in range(0, 9, 3):
for j in range(0, 9, 3):
subgrid = []
for x in range(i, i+3):
for y in range(j, j+3):
subgrid.append(grid[x][y])
if sorted(subgrid) != list(range(1, 10)):
return False
return True

# Read the grid
grid = []
for _ in range(9):
row = list(map(int, input().split()))
grid.append(row)

# Check if the grid is valid
if is_valid_sudoku(grid):
print("Yes")
else:
print("No")
```
[{"input": "1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n2 3 4 5 6 7 8 9 1\n5 6 7 8 9 1 2 3 4\n8 9 1 2 3 4 5 6 7\n3 4 5 6 7 8 9 1 2\n6 7 8 9 1 2 3 4 5\n9 1 2 3 4 5 6 7 8\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "1 2 3 4 5 6 7 8 9\n2 3 4 5 6 7 8 9 1\n3 4 5 6 7 8 9 1 2\n4 5 6 7 8 9 1 2 3\n5 6 7 8 9 1 2 3 4\n6 7 8 9 1 2 3 4 5\n7 8 9 1 2 3 4 5 6\n8 9 1 2 3 4 5 6 7\n9 1 2 3 4 5 6 7 8\n", "output": "No\n", "testtype": "stdin"}, {"input": "1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n1 2 3 4 5 6 7 8 9\n4 5 6 7 8 9 1 2 3\n7 8 9 1 2 3 4 5 6\n", "output": "No\n", "testtype": "stdin"}]