message
stringlengths
2
44.5k
message_type
stringclasses
2 values
message_id
int64
0
1
conversation_id
int64
276
109k
cluster
float64
23
23
__index_level_0__
int64
552
217k
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given four different integer points p_1, p_2, p_3 and p_4 on XY grid. In one step you can choose one of the points p_i and move it in one of four directions by one. In other words, if you have chosen point p_i = (x, y) you can move it to (x, y + 1), (x, y - 1), (x + 1, y) or (x - 1, y). Your goal to move points in such a way that they will form a square with sides parallel to OX and OY axes (a square with side 0 is allowed). What is the minimum number of steps you need to make such a square? Input The first line contains a single integer t (1 ≀ t ≀ 10^4) β€” the number of test cases. Each test case consists of four lines. Each line contains two integers x and y (0 ≀ x, y ≀ 10^9) β€” coordinates of one of the points p_i = (x, y). All points are different in one test case. Output For each test case, print the single integer β€” the minimum number of steps to make a square. Example Input 3 0 2 4 2 2 0 2 4 1 0 2 0 4 0 6 0 1 6 2 2 2 5 4 1 Output 8 7 5 Note In the first test case, one of the optimal solutions is shown below: <image> Each point was moved two times, so the answer 2 + 2 + 2 + 2 = 8. In the second test case, one of the optimal solutions is shown below: <image> The answer is 3 + 1 + 0 + 3 = 7. In the third test case, one of the optimal solutions is shown below: <image> The answer is 1 + 1 + 2 + 1 = 5. Submitted Solution: ``` import sys def logest_square_boundary(point_list): x_min, y_min = point_list[0] x_max, y_max = point_list[0] for one in point_list: if one[0] > x_max: x_max = one[0] if one[0] < x_min: x_min = one[0] if one[1] > y_max: y_max = one[1] if one[1] < y_min: y_min = one[1] return x_min, x_max, y_min, y_max def calculate_square_distance(object_point_list, square_point_list): min_dis = float("inf") tmp_idx_list = [] for i in range(4): for j in range(4): if j== i:continue for k in range(4): if k ==i or k==j:continue for l in range(4): if l == i or l == j or l==k:continue tmp_idx_list.append([i, j, k, l]) for one in tmp_idx_list: tmp_dis = abs(object_point_list[0][0]-square_point_list[one[0]][0]) + \ abs(object_point_list[0][1]-square_point_list[one[0]][1]) + \ abs(object_point_list[1][0]-square_point_list[one[1]][0]) + \ abs(object_point_list[1][1]-square_point_list[one[1]][1]) + \ abs(object_point_list[2][0]-square_point_list[one[2]][0]) + \ abs(object_point_list[2][1]-square_point_list[one[2]][1]) + \ abs(object_point_list[3][0]-square_point_list[one[3]][0]) + \ abs(object_point_list[3][1]-square_point_list[one[3]][1]) min_dis = min(tmp_dis, min_dis) return min_dis def judge_is_square(one1, one2): tmp1_dis = (one1[0][0]-one1[1][0])* (one1[0][0]-one1[1][0]) + \ (one1[0][1]-one1[1][1])* (one1[0][1]-one1[1][1]) tmp2_dis = (one2[0][0]-one2[1][0])* (one2[0][0]-one2[1][0]) + \ (one2[0][1]-one2[1][1])* (one2[0][1]-one2[1][1]) if tmp1_dis !=tmp2_dis: return False cos1 = (one1[0][0]-one1[1][0])*(one2[0][0]-one2[1][0]) + \ (one1[0][1]-one1[1][1])*(one2[0][1]-one2[1][1]) if cos1 !=0:return False x1 = one1[0][0] x2_1 = one2[0][0] x2_2 = one2[1][0] if (x1-x2_1) !=0 and (x1-x2_2) !=0: return False return True def fin_main_process(object_point_list): fin_rst = float("inf") tmp_all_point_list = [] x_min, x_max, y_min, y_max = logest_square_boundary(object_point_list) for x in range(x_min, x_max+1): for y in range(y_min, y_max+1): tmp_all_point_list.append([x, y]) mid_point_dict = {} for point1 in tmp_all_point_list: for point2 in tmp_all_point_list: mid_x = round((point1[0]+point2[0])*1.0/2,1) mid_y = round((point1[1]+point2[1])*1.0/2,1) key = str(mid_x) + "_" + str(mid_y) if key not in mid_point_dict: mid_point_dict[key] = [] mid_point_dict[key].append([point1, point2]) for key1 in mid_point_dict: for one1 in mid_point_dict[key1]: for one2 in mid_point_dict[key1]: if judge_is_square(one1, one2): square_point_list = one1 + one2 tmp_min_dis1 = calculate_square_distance(object_point_list, square_point_list) fin_rst = min(fin_rst, tmp_min_dis1) return fin_rst if __name__ == "__main__": all_point_ll = [] cnt = -1 tmp = [] while True: line = sys.stdin.readline() items = line.strip('\r\n').split(' ') #print(items, len(items)) cnt +=1 if len(items[0]) <=0: break if cnt >=1: if cnt % 4 !=0: tmp.append([int(items[0]), int(items[1])]) else: tmp.append([int(items[0]), int(items[1])]) all_point_ll.append(tmp) tmp = [] #print(all_point_ll) for one_p in all_point_ll: print(fin_main_process(one_p)) ```
instruction
0
16,192
23
32,384
No
output
1
16,192
23
32,385
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. You are given four different integer points p_1, p_2, p_3 and p_4 on XY grid. In one step you can choose one of the points p_i and move it in one of four directions by one. In other words, if you have chosen point p_i = (x, y) you can move it to (x, y + 1), (x, y - 1), (x + 1, y) or (x - 1, y). Your goal to move points in such a way that they will form a square with sides parallel to OX and OY axes (a square with side 0 is allowed). What is the minimum number of steps you need to make such a square? Input The first line contains a single integer t (1 ≀ t ≀ 10^4) β€” the number of test cases. Each test case consists of four lines. Each line contains two integers x and y (0 ≀ x, y ≀ 10^9) β€” coordinates of one of the points p_i = (x, y). All points are different in one test case. Output For each test case, print the single integer β€” the minimum number of steps to make a square. Example Input 3 0 2 4 2 2 0 2 4 1 0 2 0 4 0 6 0 1 6 2 2 2 5 4 1 Output 8 7 5 Note In the first test case, one of the optimal solutions is shown below: <image> Each point was moved two times, so the answer 2 + 2 + 2 + 2 = 8. In the second test case, one of the optimal solutions is shown below: <image> The answer is 3 + 1 + 0 + 3 = 7. In the third test case, one of the optimal solutions is shown below: <image> The answer is 1 + 1 + 2 + 1 = 5. Submitted Solution: ``` import sys import itertools import decimal input = sys.stdin.readline D = decimal.Decimal permutations = itertools.permutations for TEST in range(int(input())): p = [[*map(D, input().split())] for _ in range(4)] xAvg = sum(p[i][0] for i in range(4))/D(4) yAvg = sum(p[i][1] for i in range(4))/D(4) c = [xAvg if xAvg%1 == 0 else int(xAvg)+D(1/2), yAvg if yAvg%1 == 0 else int(yAvg)+D(1/2)] if c[0]%1==0 and c[1]%1!=0: c[0] += D(1/2) if c[1]%1==0 and c[0]%1!=0: c[1] += D(1/2) mDist, tar = 21474836470, -1 for i in range(4): tDist = abs(p[i][0]-c[0])+abs(p[i][1]-c[1]) if mDist>tDist: mDist, tar = tDist, i xDiff, yDiff = abs(p[tar][0] - c[0]), abs(p[tar][1] - c[1]) diff = max(xDiff, yDiff) g = [[c[0]-diff, c[1]-diff], [c[0]-diff, c[1]+diff], [c[0]+diff, c[1]-diff], [c[0]+diff, c[1]+diff]] res = 21474836470 for perm in permutations(range(4)): tRes = 0 for i in range(4): tRes += abs(p[i][0] - g[perm[i]][0]) + abs(p[i][1] - g[perm[i]][1]) res = min(res, tRes) print(int(res)) ```
instruction
0
16,193
23
32,386
No
output
1
16,193
23
32,387
Provide tags and a correct Python 3 solution for this coding contest problem. Convexity of a set of points on the plane is the size of the largest subset of points that form a convex polygon. Your task is to build a set of n points with the convexity of exactly m. Your set of points should not contain three points that lie on a straight line. Input The single line contains two integers n and m (3 ≀ m ≀ 100, m ≀ n ≀ 2m). Output If there is no solution, print "-1". Otherwise, print n pairs of integers β€” the coordinates of points of any set with the convexity of m. The coordinates shouldn't exceed 108 in their absolute value. Examples Input 4 3 Output 0 0 3 0 0 3 1 1 Input 6 3 Output -1 Input 6 6 Output 10 0 -10 0 10 1 9 1 9 -1 0 -2 Input 7 4 Output 176166 6377 709276 539564 654734 174109 910147 434207 790497 366519 606663 21061 859328 886001
instruction
0
16,281
23
32,562
Tags: constructive algorithms, geometry Correct Solution: ``` def f(x): return int(x * x + 1e7) def g(x): return -f(x) n, m = map(int, input().split()) if(m == 3): if(n == 3): print('0 0') print('1 0') print('0 1') elif(n == 4): print('0 0') print('1 1') print('10000 0') print('0 10000') else: print(-1) else: for i in range(m): print(i, f(i)) for i in range(n - m): print(i, g(i)) ```
output
1
16,281
23
32,563
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Convexity of a set of points on the plane is the size of the largest subset of points that form a convex polygon. Your task is to build a set of n points with the convexity of exactly m. Your set of points should not contain three points that lie on a straight line. Input The single line contains two integers n and m (3 ≀ m ≀ 100, m ≀ n ≀ 2m). Output If there is no solution, print "-1". Otherwise, print n pairs of integers β€” the coordinates of points of any set with the convexity of m. The coordinates shouldn't exceed 108 in their absolute value. Examples Input 4 3 Output 0 0 3 0 0 3 1 1 Input 6 3 Output -1 Input 6 6 Output 10 0 -10 0 10 1 9 1 9 -1 0 -2 Input 7 4 Output 176166 6377 709276 539564 654734 174109 910147 434207 790497 366519 606663 21061 859328 886001 Submitted Solution: ``` def f(x): return int(x * x + 1e7) def g(x): return -f(x) n, m = map(int, input().split()) if(m == 3): if(n == 3): print('0 0') print('1 0') print('0 1') elif(n == 4): print('0 0') print('1 2') print('3 2') print('4 0') else: print(-1) else: for i in range(m): print(i, f(i)) for i in range(n - m): print(i, g(i)) ```
instruction
0
16,282
23
32,564
No
output
1
16,282
23
32,565
Provide tags and a correct Python 3 solution for this coding contest problem. Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to <image>. Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters. There the properties of the hexagon ended and Gerald decided to draw on it. He painted a few lines, parallel to the sides of the hexagon. The lines split the hexagon into regular triangles with sides of 1 centimeter. Now Gerald wonders how many triangles he has got. But there were so many of them that Gerald lost the track of his counting. Help the boy count the triangles. Input The first and the single line of the input contains 6 space-separated integers a1, a2, a3, a4, a5 and a6 (1 ≀ ai ≀ 1000) β€” the lengths of the sides of the hexagons in centimeters in the clockwise order. It is guaranteed that the hexagon with the indicated properties and the exactly such sides exists. Output Print a single integer β€” the number of triangles with the sides of one 1 centimeter, into which the hexagon is split. Examples Input 1 1 1 1 1 1 Output 6 Input 1 2 1 2 1 2 Output 13 Note This is what Gerald's hexagon looks like in the first sample: <image> And that's what it looks like in the second sample: <image>
instruction
0
16,389
23
32,778
Tags: brute force, geometry, math Correct Solution: ``` # Description of the problem can be found at http://codeforces.com/problemset/problem/559/A l_s = list(map(int, input().split())) w = l_s[0] / 2 print((l_s[0] + l_s[1] + l_s[2]) ** 2 - l_s[0] ** 2 - l_s[2] ** 2 - l_s[4] ** 2) ```
output
1
16,389
23
32,779
Provide tags and a correct Python 3 solution for this coding contest problem. Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to <image>. Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters. There the properties of the hexagon ended and Gerald decided to draw on it. He painted a few lines, parallel to the sides of the hexagon. The lines split the hexagon into regular triangles with sides of 1 centimeter. Now Gerald wonders how many triangles he has got. But there were so many of them that Gerald lost the track of his counting. Help the boy count the triangles. Input The first and the single line of the input contains 6 space-separated integers a1, a2, a3, a4, a5 and a6 (1 ≀ ai ≀ 1000) β€” the lengths of the sides of the hexagons in centimeters in the clockwise order. It is guaranteed that the hexagon with the indicated properties and the exactly such sides exists. Output Print a single integer β€” the number of triangles with the sides of one 1 centimeter, into which the hexagon is split. Examples Input 1 1 1 1 1 1 Output 6 Input 1 2 1 2 1 2 Output 13 Note This is what Gerald's hexagon looks like in the first sample: <image> And that's what it looks like in the second sample: <image>
instruction
0
16,390
23
32,780
Tags: brute force, geometry, math Correct Solution: ``` #!@#$!@#T%&!$#^!#$&Y$%%$#$^#$^$@%^$@% a1,a2,a3,a4,a5,a6=map(int,input().split()) print((a1+a2+a3)**2-a1**2-a3**2-a5**2) ```
output
1
16,390
23
32,781
Provide tags and a correct Python 3 solution for this coding contest problem. Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to <image>. Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters. There the properties of the hexagon ended and Gerald decided to draw on it. He painted a few lines, parallel to the sides of the hexagon. The lines split the hexagon into regular triangles with sides of 1 centimeter. Now Gerald wonders how many triangles he has got. But there were so many of them that Gerald lost the track of his counting. Help the boy count the triangles. Input The first and the single line of the input contains 6 space-separated integers a1, a2, a3, a4, a5 and a6 (1 ≀ ai ≀ 1000) β€” the lengths of the sides of the hexagons in centimeters in the clockwise order. It is guaranteed that the hexagon with the indicated properties and the exactly such sides exists. Output Print a single integer β€” the number of triangles with the sides of one 1 centimeter, into which the hexagon is split. Examples Input 1 1 1 1 1 1 Output 6 Input 1 2 1 2 1 2 Output 13 Note This is what Gerald's hexagon looks like in the first sample: <image> And that's what it looks like in the second sample: <image>
instruction
0
16,391
23
32,782
Tags: brute force, geometry, math Correct Solution: ``` sides = [int(x) for x in input().split()] bigtriangle = (sides[0] + sides[1] + sides[2]) ** 2 ans = bigtriangle - sides[0]**2 - sides[2]**2 - sides[4]**2 print(ans) ```
output
1
16,391
23
32,783
Provide tags and a correct Python 3 solution for this coding contest problem. Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to <image>. Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters. There the properties of the hexagon ended and Gerald decided to draw on it. He painted a few lines, parallel to the sides of the hexagon. The lines split the hexagon into regular triangles with sides of 1 centimeter. Now Gerald wonders how many triangles he has got. But there were so many of them that Gerald lost the track of his counting. Help the boy count the triangles. Input The first and the single line of the input contains 6 space-separated integers a1, a2, a3, a4, a5 and a6 (1 ≀ ai ≀ 1000) β€” the lengths of the sides of the hexagons in centimeters in the clockwise order. It is guaranteed that the hexagon with the indicated properties and the exactly such sides exists. Output Print a single integer β€” the number of triangles with the sides of one 1 centimeter, into which the hexagon is split. Examples Input 1 1 1 1 1 1 Output 6 Input 1 2 1 2 1 2 Output 13 Note This is what Gerald's hexagon looks like in the first sample: <image> And that's what it looks like in the second sample: <image>
instruction
0
16,392
23
32,784
Tags: brute force, geometry, math Correct Solution: ``` import math import sys import collections import bisect import string import time def get_ints():return map(int, sys.stdin.readline().strip().split()) def get_list():return list(map(int, sys.stdin.readline().strip().split())) def get_string():return sys.stdin.readline().strip() for t in range(1): a,b,c,d,e,f=get_ints() print((a+b+c)**2-(a**2+c**2+e**2)) ```
output
1
16,392
23
32,785
Provide tags and a correct Python 3 solution for this coding contest problem. Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to <image>. Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters. There the properties of the hexagon ended and Gerald decided to draw on it. He painted a few lines, parallel to the sides of the hexagon. The lines split the hexagon into regular triangles with sides of 1 centimeter. Now Gerald wonders how many triangles he has got. But there were so many of them that Gerald lost the track of his counting. Help the boy count the triangles. Input The first and the single line of the input contains 6 space-separated integers a1, a2, a3, a4, a5 and a6 (1 ≀ ai ≀ 1000) β€” the lengths of the sides of the hexagons in centimeters in the clockwise order. It is guaranteed that the hexagon with the indicated properties and the exactly such sides exists. Output Print a single integer β€” the number of triangles with the sides of one 1 centimeter, into which the hexagon is split. Examples Input 1 1 1 1 1 1 Output 6 Input 1 2 1 2 1 2 Output 13 Note This is what Gerald's hexagon looks like in the first sample: <image> And that's what it looks like in the second sample: <image>
instruction
0
16,393
23
32,786
Tags: brute force, geometry, math Correct Solution: ``` a,b,c,d,e,f=map(int,input().split());print(b*(2*a+b+c+c)+2*a*c-e*e) ```
output
1
16,393
23
32,787
Provide tags and a correct Python 3 solution for this coding contest problem. Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to <image>. Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters. There the properties of the hexagon ended and Gerald decided to draw on it. He painted a few lines, parallel to the sides of the hexagon. The lines split the hexagon into regular triangles with sides of 1 centimeter. Now Gerald wonders how many triangles he has got. But there were so many of them that Gerald lost the track of his counting. Help the boy count the triangles. Input The first and the single line of the input contains 6 space-separated integers a1, a2, a3, a4, a5 and a6 (1 ≀ ai ≀ 1000) β€” the lengths of the sides of the hexagons in centimeters in the clockwise order. It is guaranteed that the hexagon with the indicated properties and the exactly such sides exists. Output Print a single integer β€” the number of triangles with the sides of one 1 centimeter, into which the hexagon is split. Examples Input 1 1 1 1 1 1 Output 6 Input 1 2 1 2 1 2 Output 13 Note This is what Gerald's hexagon looks like in the first sample: <image> And that's what it looks like in the second sample: <image>
instruction
0
16,394
23
32,788
Tags: brute force, geometry, math Correct Solution: ``` a = [int(i) for i in input().split()] n = a[2] + a[3] + a[4] print(n * n - a[0] * a[0] - a[2] * a[2] - a[4] * a[4]) ```
output
1
16,394
23
32,789
Provide tags and a correct Python 3 solution for this coding contest problem. Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to <image>. Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters. There the properties of the hexagon ended and Gerald decided to draw on it. He painted a few lines, parallel to the sides of the hexagon. The lines split the hexagon into regular triangles with sides of 1 centimeter. Now Gerald wonders how many triangles he has got. But there were so many of them that Gerald lost the track of his counting. Help the boy count the triangles. Input The first and the single line of the input contains 6 space-separated integers a1, a2, a3, a4, a5 and a6 (1 ≀ ai ≀ 1000) β€” the lengths of the sides of the hexagons in centimeters in the clockwise order. It is guaranteed that the hexagon with the indicated properties and the exactly such sides exists. Output Print a single integer β€” the number of triangles with the sides of one 1 centimeter, into which the hexagon is split. Examples Input 1 1 1 1 1 1 Output 6 Input 1 2 1 2 1 2 Output 13 Note This is what Gerald's hexagon looks like in the first sample: <image> And that's what it looks like in the second sample: <image>
instruction
0
16,395
23
32,790
Tags: brute force, geometry, math Correct Solution: ``` def trin(n): return n*n l = [int(x) for x in input().split()] a = l[-1] b = l[1] c =trin(l[0]+ l[1]+l[2]) c = c- trin(l[0])-trin(l[2])-trin(l[4]) print(c) ```
output
1
16,395
23
32,791
Provide tags and a correct Python 3 solution for this coding contest problem. Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to <image>. Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters. There the properties of the hexagon ended and Gerald decided to draw on it. He painted a few lines, parallel to the sides of the hexagon. The lines split the hexagon into regular triangles with sides of 1 centimeter. Now Gerald wonders how many triangles he has got. But there were so many of them that Gerald lost the track of his counting. Help the boy count the triangles. Input The first and the single line of the input contains 6 space-separated integers a1, a2, a3, a4, a5 and a6 (1 ≀ ai ≀ 1000) β€” the lengths of the sides of the hexagons in centimeters in the clockwise order. It is guaranteed that the hexagon with the indicated properties and the exactly such sides exists. Output Print a single integer β€” the number of triangles with the sides of one 1 centimeter, into which the hexagon is split. Examples Input 1 1 1 1 1 1 Output 6 Input 1 2 1 2 1 2 Output 13 Note This is what Gerald's hexagon looks like in the first sample: <image> And that's what it looks like in the second sample: <image>
instruction
0
16,396
23
32,792
Tags: brute force, geometry, math Correct Solution: ``` a = list(map(int, input().split())) print((a[5] + a[4]) * (a[0] + a[1]) * 2 - a[4] ** 2 - a[1] ** 2) ```
output
1
16,396
23
32,793
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to <image>. Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters. There the properties of the hexagon ended and Gerald decided to draw on it. He painted a few lines, parallel to the sides of the hexagon. The lines split the hexagon into regular triangles with sides of 1 centimeter. Now Gerald wonders how many triangles he has got. But there were so many of them that Gerald lost the track of his counting. Help the boy count the triangles. Input The first and the single line of the input contains 6 space-separated integers a1, a2, a3, a4, a5 and a6 (1 ≀ ai ≀ 1000) β€” the lengths of the sides of the hexagons in centimeters in the clockwise order. It is guaranteed that the hexagon with the indicated properties and the exactly such sides exists. Output Print a single integer β€” the number of triangles with the sides of one 1 centimeter, into which the hexagon is split. Examples Input 1 1 1 1 1 1 Output 6 Input 1 2 1 2 1 2 Output 13 Note This is what Gerald's hexagon looks like in the first sample: <image> And that's what it looks like in the second sample: <image> Submitted Solution: ``` import sys from functools import lru_cache, cmp_to_key from heapq import merge, heapify, heappop, heappush from math import * from collections import defaultdict as dd, deque, Counter as C from itertools import combinations as comb, permutations as perm from bisect import bisect_left as bl, bisect_right as br, bisect from time import perf_counter from fractions import Fraction import copy import time starttime = time.time() mod = int(pow(10, 9) + 7) mod2 = 998244353 # from sys import stdin # input = stdin.readline def data(): return sys.stdin.readline().strip() def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end) def L(): return list(sp()) def sl(): return list(ssp()) def sp(): return map(int, data().split()) def ssp(): return map(str, data().split()) def l1d(n, val=0): return [val for i in range(n)] def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)] try: # sys.setrecursionlimit(int(pow(10,7))) sys.stdin = open("input.txt", "r") # sys.stdout = open("../output.txt", "w") except: pass def pmat(A): for ele in A: print(*ele,end="\n") def seive(): prime=[1 for i in range(10**6+1)] prime[0]=0 prime[1]=0 for i in range(10**6+1): if(prime[i]): for j in range(2*i,10**6+1,i): prime[j]=0 return prime a,b,c,d,e,f=L() print((a+b+c)**2-a*a-c*c-e*e) endtime = time.time() # print(f"Runtime of the program is {endtime - starttime}") ```
instruction
0
16,397
23
32,794
Yes
output
1
16,397
23
32,795
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to <image>. Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters. There the properties of the hexagon ended and Gerald decided to draw on it. He painted a few lines, parallel to the sides of the hexagon. The lines split the hexagon into regular triangles with sides of 1 centimeter. Now Gerald wonders how many triangles he has got. But there were so many of them that Gerald lost the track of his counting. Help the boy count the triangles. Input The first and the single line of the input contains 6 space-separated integers a1, a2, a3, a4, a5 and a6 (1 ≀ ai ≀ 1000) β€” the lengths of the sides of the hexagons in centimeters in the clockwise order. It is guaranteed that the hexagon with the indicated properties and the exactly such sides exists. Output Print a single integer β€” the number of triangles with the sides of one 1 centimeter, into which the hexagon is split. Examples Input 1 1 1 1 1 1 Output 6 Input 1 2 1 2 1 2 Output 13 Note This is what Gerald's hexagon looks like in the first sample: <image> And that's what it looks like in the second sample: <image> Submitted Solution: ``` base, s1, height, _, _, s2 = map(int, input().split()) height += s1 at_level = 2 * base - 1 total = 0 for i in range(height): if i < s1: at_level += 1 elif i > s1: at_level -= 1 if i < s2: at_level += 1 elif i > s2: at_level -= 1 total += at_level print(total) ```
instruction
0
16,398
23
32,796
Yes
output
1
16,398
23
32,797
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to <image>. Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters. There the properties of the hexagon ended and Gerald decided to draw on it. He painted a few lines, parallel to the sides of the hexagon. The lines split the hexagon into regular triangles with sides of 1 centimeter. Now Gerald wonders how many triangles he has got. But there were so many of them that Gerald lost the track of his counting. Help the boy count the triangles. Input The first and the single line of the input contains 6 space-separated integers a1, a2, a3, a4, a5 and a6 (1 ≀ ai ≀ 1000) β€” the lengths of the sides of the hexagons in centimeters in the clockwise order. It is guaranteed that the hexagon with the indicated properties and the exactly such sides exists. Output Print a single integer β€” the number of triangles with the sides of one 1 centimeter, into which the hexagon is split. Examples Input 1 1 1 1 1 1 Output 6 Input 1 2 1 2 1 2 Output 13 Note This is what Gerald's hexagon looks like in the first sample: <image> And that's what it looks like in the second sample: <image> Submitted Solution: ``` def f(x): ans = 0 for i in range(1, x + 1): ans += 2 * i - 1 return ans a = list(map(int, input().split())) print((a[0] + a[1]) * 2 * (a[1] + a[2]) - f(a[1]) - f(a[4])) ```
instruction
0
16,399
23
32,798
Yes
output
1
16,399
23
32,799
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to <image>. Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters. There the properties of the hexagon ended and Gerald decided to draw on it. He painted a few lines, parallel to the sides of the hexagon. The lines split the hexagon into regular triangles with sides of 1 centimeter. Now Gerald wonders how many triangles he has got. But there were so many of them that Gerald lost the track of his counting. Help the boy count the triangles. Input The first and the single line of the input contains 6 space-separated integers a1, a2, a3, a4, a5 and a6 (1 ≀ ai ≀ 1000) β€” the lengths of the sides of the hexagons in centimeters in the clockwise order. It is guaranteed that the hexagon with the indicated properties and the exactly such sides exists. Output Print a single integer β€” the number of triangles with the sides of one 1 centimeter, into which the hexagon is split. Examples Input 1 1 1 1 1 1 Output 6 Input 1 2 1 2 1 2 Output 13 Note This is what Gerald's hexagon looks like in the first sample: <image> And that's what it looks like in the second sample: <image> Submitted Solution: ``` sides = list(map(int, input().split())) up = sides[1] x, y, total = sides[0], sides[2], sides[2]+sides[3] ans = 0 for _ in range(total): down = up + ((x > 0) & (y > 0)) -((x <= 0) & (y <= 0)) ans += down + up up = down x -= 1 y -= 1 print(ans) ```
instruction
0
16,400
23
32,800
Yes
output
1
16,400
23
32,801
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to <image>. Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters. There the properties of the hexagon ended and Gerald decided to draw on it. He painted a few lines, parallel to the sides of the hexagon. The lines split the hexagon into regular triangles with sides of 1 centimeter. Now Gerald wonders how many triangles he has got. But there were so many of them that Gerald lost the track of his counting. Help the boy count the triangles. Input The first and the single line of the input contains 6 space-separated integers a1, a2, a3, a4, a5 and a6 (1 ≀ ai ≀ 1000) β€” the lengths of the sides of the hexagons in centimeters in the clockwise order. It is guaranteed that the hexagon with the indicated properties and the exactly such sides exists. Output Print a single integer β€” the number of triangles with the sides of one 1 centimeter, into which the hexagon is split. Examples Input 1 1 1 1 1 1 Output 6 Input 1 2 1 2 1 2 Output 13 Note This is what Gerald's hexagon looks like in the first sample: <image> And that's what it looks like in the second sample: <image> Submitted Solution: ``` #!/usr/bin/env python # -*- coding: utf-8 -*- def solve(a, b) -> bool: m = min([a, b]) l = max([a, b]) left = 3 * m * (m + 1) - m - 5 if m > 1 else 0 right = 3 * l * (l + 1) - (5 * l) - 1 if l > 1 else 0 return 6 + left + right def getinput(): def getints_line(): return list(map(int, input().split(' '))) [a, b] = getints_line()[:2] return a, b def test(): art = Assert() art.equal(solve(1, 1), 6) art.equal(solve(1, 2), 13) art.equal(solve(2, 1), 13) art.equal(solve(2, 2), 24) art.equal(solve(2, 3), 37) art.equal(solve(3, 3), 54) def main(): # test() print(solve(*getinput())) # print('\n'.join(map(str, solve(*getinput())))) import unittest class Assert(unittest.TestCase): def equal(self, a, b): self.assertEqual(a, b) if __name__ == '__main__': main() ```
instruction
0
16,401
23
32,802
No
output
1
16,401
23
32,803
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to <image>. Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters. There the properties of the hexagon ended and Gerald decided to draw on it. He painted a few lines, parallel to the sides of the hexagon. The lines split the hexagon into regular triangles with sides of 1 centimeter. Now Gerald wonders how many triangles he has got. But there were so many of them that Gerald lost the track of his counting. Help the boy count the triangles. Input The first and the single line of the input contains 6 space-separated integers a1, a2, a3, a4, a5 and a6 (1 ≀ ai ≀ 1000) β€” the lengths of the sides of the hexagons in centimeters in the clockwise order. It is guaranteed that the hexagon with the indicated properties and the exactly such sides exists. Output Print a single integer β€” the number of triangles with the sides of one 1 centimeter, into which the hexagon is split. Examples Input 1 1 1 1 1 1 Output 6 Input 1 2 1 2 1 2 Output 13 Note This is what Gerald's hexagon looks like in the first sample: <image> And that's what it looks like in the second sample: <image> Submitted Solution: ``` #------------------------template--------------------------# import os import sys from math import * from collections import * from fractions import * from bisect import * from heapq import* from io import BytesIO, IOBase def vsInput(): sys.stdin = open('input.txt', 'r') sys.stdout = open('output.txt', 'w') 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") def value():return tuple(map(int,input().split())) def array():return [int(i) for i in input().split()] def Int():return int(input()) def Str():return input() def arrayS():return [i for i in input().split()] #-------------------------code---------------------------# #vsInput() def tringles(n): return 3+(n-1)*2 sides=array() a,l1,r1=sides[0],sides[5],sides[1] b,l2,r2=sides[3],sides[2],sides[4] ans=0 #print(l1,a,r1) #print(l2,b,r2) for i in range(min(l1,r1)): ans+=tringles(a+i) for i in range(min(l2,r2)): ans+=tringles(b+i) layers=abs(l1-r1) ans+=layers* tringles(a+min(l1,r1)) print(ans) ```
instruction
0
16,402
23
32,804
No
output
1
16,402
23
32,805
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to <image>. Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters. There the properties of the hexagon ended and Gerald decided to draw on it. He painted a few lines, parallel to the sides of the hexagon. The lines split the hexagon into regular triangles with sides of 1 centimeter. Now Gerald wonders how many triangles he has got. But there were so many of them that Gerald lost the track of his counting. Help the boy count the triangles. Input The first and the single line of the input contains 6 space-separated integers a1, a2, a3, a4, a5 and a6 (1 ≀ ai ≀ 1000) β€” the lengths of the sides of the hexagons in centimeters in the clockwise order. It is guaranteed that the hexagon with the indicated properties and the exactly such sides exists. Output Print a single integer β€” the number of triangles with the sides of one 1 centimeter, into which the hexagon is split. Examples Input 1 1 1 1 1 1 Output 6 Input 1 2 1 2 1 2 Output 13 Note This is what Gerald's hexagon looks like in the first sample: <image> And that's what it looks like in the second sample: <image> Submitted Solution: ``` a, b, c, d, e, f = map(int, input().split()) print((a + b + c) ** 2 - (a ** 2 - c ** 2 - e ** 2)) ```
instruction
0
16,403
23
32,806
No
output
1
16,403
23
32,807
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Gerald got a very curious hexagon for his birthday. The boy found out that all the angles of the hexagon are equal to <image>. Then he measured the length of its sides, and found that each of them is equal to an integer number of centimeters. There the properties of the hexagon ended and Gerald decided to draw on it. He painted a few lines, parallel to the sides of the hexagon. The lines split the hexagon into regular triangles with sides of 1 centimeter. Now Gerald wonders how many triangles he has got. But there were so many of them that Gerald lost the track of his counting. Help the boy count the triangles. Input The first and the single line of the input contains 6 space-separated integers a1, a2, a3, a4, a5 and a6 (1 ≀ ai ≀ 1000) β€” the lengths of the sides of the hexagons in centimeters in the clockwise order. It is guaranteed that the hexagon with the indicated properties and the exactly such sides exists. Output Print a single integer β€” the number of triangles with the sides of one 1 centimeter, into which the hexagon is split. Examples Input 1 1 1 1 1 1 Output 6 Input 1 2 1 2 1 2 Output 13 Note This is what Gerald's hexagon looks like in the first sample: <image> And that's what it looks like in the second sample: <image> Submitted Solution: ``` from math import sqrt def g(s): return sqrt((s * 3 / 2) * ((s * 3 / 2 - s) ** 3)) a = [float(i) for i in input().split()] f = g(a[0] + a[1] + a[2]) print(round(f - g(a[0]) - g(a[2]) - g(a[4])) / g(1)) ```
instruction
0
16,404
23
32,808
No
output
1
16,404
23
32,809
Provide tags and a correct Python 3 solution for this coding contest problem. Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows. There is a rectangular box having exactly n holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can enter or exit from each hole. The holes are in a straight line. <image> Professor Wangdu is showing his experiment to his students. He shows that there are cases, when all the rays are intersected by every other ray. A curious student asked the professor: "Sir, there are some groups of rays such that all rays in that group intersect every other ray in that group. Can we determine the number of rays in the largest of such groups?". Professor Wangdu now is in trouble and knowing your intellect he asks you to help him. Input The first line contains n (1 ≀ n ≀ 106), the number of rays. The second line contains n distinct integers. The i-th integer xi (1 ≀ xi ≀ n) shows that the xi-th ray enters from the i-th hole. Similarly, third line contains n distinct integers. The i-th integer yi (1 ≀ yi ≀ n) shows that the yi-th ray exits from the i-th hole. All rays are numbered from 1 to n. Output Output contains the only integer which is the number of rays in the largest group of rays all of which intersect each other. Examples Input 5 1 4 5 2 3 3 4 2 1 5 Output 3 Input 3 3 1 2 2 3 1 Output 2 Note For the first test case, the figure is shown above. The output of the first test case is 3, since the rays number 1, 4 and 3 are the ones which are intersected by each other one i.e. 1 is intersected by 4 and 3, 3 is intersected by 4 and 1, and 4 is intersected by 1 and 3. Hence every ray in this group is intersected by each other one. There does not exist any group containing more than 3 rays satisfying the above-mentioned constraint.
instruction
0
16,440
23
32,880
Tags: binary search, data structures, dp Correct Solution: ``` from bisect import bisect_left as bl I=10000000 n=int(input())+1 c=[0]*n for i,x in enumerate(map(int,input().split())): c[x]=i d = [n-c[int(x)] for x in input().split()] c=[I]*n for i in d: c[bl(c,i)]=i print( c.index(I)) ```
output
1
16,440
23
32,881
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows. There is a rectangular box having exactly n holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can enter or exit from each hole. The holes are in a straight line. <image> Professor Wangdu is showing his experiment to his students. He shows that there are cases, when all the rays are intersected by every other ray. A curious student asked the professor: "Sir, there are some groups of rays such that all rays in that group intersect every other ray in that group. Can we determine the number of rays in the largest of such groups?". Professor Wangdu now is in trouble and knowing your intellect he asks you to help him. Input The first line contains n (1 ≀ n ≀ 106), the number of rays. The second line contains n distinct integers. The i-th integer xi (1 ≀ xi ≀ n) shows that the xi-th ray enters from the i-th hole. Similarly, third line contains n distinct integers. The i-th integer yi (1 ≀ yi ≀ n) shows that the yi-th ray exits from the i-th hole. All rays are numbered from 1 to n. Output Output contains the only integer which is the number of rays in the largest group of rays all of which intersect each other. Examples Input 5 1 4 5 2 3 3 4 2 1 5 Output 3 Input 3 3 1 2 2 3 1 Output 2 Note For the first test case, the figure is shown above. The output of the first test case is 3, since the rays number 1, 4 and 3 are the ones which are intersected by each other one i.e. 1 is intersected by 4 and 3, 3 is intersected by 4 and 1, and 4 is intersected by 1 and 3. Hence every ray in this group is intersected by each other one. There does not exist any group containing more than 3 rays satisfying the above-mentioned constraint. Submitted Solution: ``` input() b=input().split() print(max(b.count(i) for i in set(b)),len(set(b))) ```
instruction
0
16,441
23
32,882
No
output
1
16,441
23
32,883
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Professor Phunsuk Wangdu has performed some experiments on rays. The setup for n rays is as follows. There is a rectangular box having exactly n holes on the opposite faces. All rays enter from the holes of the first side and exit from the holes of the other side of the box. Exactly one ray can enter or exit from each hole. The holes are in a straight line. <image> Professor Wangdu is showing his experiment to his students. He shows that there are cases, when all the rays are intersected by every other ray. A curious student asked the professor: "Sir, there are some groups of rays such that all rays in that group intersect every other ray in that group. Can we determine the number of rays in the largest of such groups?". Professor Wangdu now is in trouble and knowing your intellect he asks you to help him. Input The first line contains n (1 ≀ n ≀ 106), the number of rays. The second line contains n distinct integers. The i-th integer xi (1 ≀ xi ≀ n) shows that the xi-th ray enters from the i-th hole. Similarly, third line contains n distinct integers. The i-th integer yi (1 ≀ yi ≀ n) shows that the yi-th ray exits from the i-th hole. All rays are numbered from 1 to n. Output Output contains the only integer which is the number of rays in the largest group of rays all of which intersect each other. Examples Input 5 1 4 5 2 3 3 4 2 1 5 Output 3 Input 3 3 1 2 2 3 1 Output 2 Note For the first test case, the figure is shown above. The output of the first test case is 3, since the rays number 1, 4 and 3 are the ones which are intersected by each other one i.e. 1 is intersected by 4 and 3, 3 is intersected by 4 and 1, and 4 is intersected by 1 and 3. Hence every ray in this group is intersected by each other one. There does not exist any group containing more than 3 rays satisfying the above-mentioned constraint. Submitted Solution: ``` t=int(input()) a=str(input()) b=str(input()) if a[0]==b[2*t-2]: print(a[0]) elif b[0]==a[2*t-2]: print(b[0]) ```
instruction
0
16,442
23
32,884
No
output
1
16,442
23
32,885
Provide a correct Python 3 solution for this coding contest problem. Taro is playing with a puzzle that places numbers 1-9 in 9x9 squares. In this puzzle, you have to arrange the numbers according to the following rules. * One number appears exactly once in the same column * A number appears exactly once on the same line * In each of the 3x3 ranges separated by double lines, a number appears exactly once. For example, Figure 1 below is one arrangement that meets such a rule. However, Taro often creates an arrangement that violates the rules, as shown in Figure 2. The "2" appears twice in the leftmost column, the "1" never appears, the "1" appears twice in the second column from the left, and the "2" never appears. .. <image> | <image> --- | --- Figure 1 | Figure 2 To help Taro, write a program that reads the arrangement of numbers, checks if the arrangement meets the rules, and outputs the location if it violates the rules. Please display * (half-width asterisk) before the number that is incorrect (appears more than once) according to the three rules, and blank before the number that is not incorrect. Input Given multiple datasets. The first row gives the number of datasets n (n ≀ 20). Each dataset is given a 9-character, 9-line numeric string that indicates the state of the puzzle. Output Output the following for each dataset. Given number, * (half-width asterisk) and blank. Add * before the wrong number and a half-width space before the wrong number. Insert a blank line between the datasets. Example Input 2 2 1 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 2 1 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 Output *2*1 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 *2*1 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
instruction
0
16,727
23
33,454
"Correct Solution: ``` n=int(input()) st=True for _ in range(n): if st==False: print() puzzle=[] for i in range(9): row=[int(j) for j in input().split(" ")] puzzle.append(row) dup=[[False for i in range(9)] for j in range(9)] for i in range(9): for j in range(9): for k in range(9): if i!=k and puzzle[i][j]==puzzle[k][j]: dup[i][j]=True if j!=k and puzzle[i][j]==puzzle[i][k]: dup[i][j]=True for p in range(3): for q in range(3): x=(i//3)*3+p y=(j//3)*3+q if (x==i and y==j): continue if puzzle[x][y]==puzzle[i][j]: dup[i][j]=True for i in range(9): for j in range(9): if dup[i][j]: print("*", end="") else: print(" ", end="") print(puzzle[i][j], end="") print() st=False ```
output
1
16,727
23
33,455
Provide a correct Python 3 solution for this coding contest problem. Taro is playing with a puzzle that places numbers 1-9 in 9x9 squares. In this puzzle, you have to arrange the numbers according to the following rules. * One number appears exactly once in the same column * A number appears exactly once on the same line * In each of the 3x3 ranges separated by double lines, a number appears exactly once. For example, Figure 1 below is one arrangement that meets such a rule. However, Taro often creates an arrangement that violates the rules, as shown in Figure 2. The "2" appears twice in the leftmost column, the "1" never appears, the "1" appears twice in the second column from the left, and the "2" never appears. .. <image> | <image> --- | --- Figure 1 | Figure 2 To help Taro, write a program that reads the arrangement of numbers, checks if the arrangement meets the rules, and outputs the location if it violates the rules. Please display * (half-width asterisk) before the number that is incorrect (appears more than once) according to the three rules, and blank before the number that is not incorrect. Input Given multiple datasets. The first row gives the number of datasets n (n ≀ 20). Each dataset is given a 9-character, 9-line numeric string that indicates the state of the puzzle. Output Output the following for each dataset. Given number, * (half-width asterisk) and blank. Add * before the wrong number and a half-width space before the wrong number. Insert a blank line between the datasets. Example Input 2 2 1 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 2 1 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 Output *2*1 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 *2*1 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
instruction
0
16,728
23
33,456
"Correct Solution: ``` def trans(mp): ret = [[None] * 9 for _ in range(9)] for x in range(9): for y in range(9): ret[x][y] = mp[y][x] return ret def fix(mp): fix_lst = [] mp2 = trans(mp) for i in range(9): for j in range(9): if mp[i].count(mp[i][j]) > 1: fix_lst.append((i, j)) if mp2[i].count(mp2[i][j]) > 1: fix_lst.append((j, i)) for ulx in (0, 3, 6): for uly in (0, 3, 6): tmp = [] for dx in (0, 1, 2): for dy in (0, 1, 2): tmp.append(mp[ulx + dx][uly + dy]) for dx in (0, 1, 2): for dy in (0, 1, 2): if tmp.count(mp[ulx + dx][uly + dy]) > 1: fix_lst.append((ulx + dx, uly + dy)) fix_lst = list(set(fix_lst)) for x, y in fix_lst: mp[x][y] = "*" + mp[x][y] return mp def _rj(c): return c.rjust(2) def print_mp(mp): for line in mp: print("".join(map(_rj, line))) n = int(input()) for i in range(n): if i != 0: print() mp = [input().split() for _ in range(9)] mp = fix(mp) print_mp(mp) ```
output
1
16,728
23
33,457
Provide a correct Python 3 solution for this coding contest problem. Taro is playing with a puzzle that places numbers 1-9 in 9x9 squares. In this puzzle, you have to arrange the numbers according to the following rules. * One number appears exactly once in the same column * A number appears exactly once on the same line * In each of the 3x3 ranges separated by double lines, a number appears exactly once. For example, Figure 1 below is one arrangement that meets such a rule. However, Taro often creates an arrangement that violates the rules, as shown in Figure 2. The "2" appears twice in the leftmost column, the "1" never appears, the "1" appears twice in the second column from the left, and the "2" never appears. .. <image> | <image> --- | --- Figure 1 | Figure 2 To help Taro, write a program that reads the arrangement of numbers, checks if the arrangement meets the rules, and outputs the location if it violates the rules. Please display * (half-width asterisk) before the number that is incorrect (appears more than once) according to the three rules, and blank before the number that is not incorrect. Input Given multiple datasets. The first row gives the number of datasets n (n ≀ 20). Each dataset is given a 9-character, 9-line numeric string that indicates the state of the puzzle. Output Output the following for each dataset. Given number, * (half-width asterisk) and blank. Add * before the wrong number and a half-width space before the wrong number. Insert a blank line between the datasets. Example Input 2 2 1 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 2 1 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 Output *2*1 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 *2*1 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
instruction
0
16,729
23
33,458
"Correct Solution: ``` n = int(input()) """ def hor(matrix,y): res = [True]*9 s = set() out = set() for i in matrix[y]: if i in s: out.add(i) s.add(i) for ind,i in enumerate(matrix[y]): if i in out: res[ind] = False """ def so(seq): res = [False]*9 s = set() out = set() for i in seq: if i in s: out.add(i) s.add(i) for ind,i in enumerate(seq): if i in out: res[ind] = True return res for num in range(n): matrix = [list(map(int, input().split())) for _ in range(9)] part = [] for i in range(9): t = [] for j in range(9): t.append(matrix[j][i]) part.append(t) section = [] for i in range(3): for j in range(3): t = [] for k in range(3): for l in range(3): t.append(matrix[i*3 + k][j*3 + l]) section.append(t) cor = [[False]*9 for _ in range(9)] for i in range(9): for ind,j in enumerate(so(matrix[i])): cor[i][ind] = cor[i][ind] or j for ind,j in enumerate(so(part[i])): cor[ind][i] = cor[ind][i] or j for ind,j in enumerate(so(section[i])): x = i % 3 y = i // 3 px = ind % 3 py = ind // 3 cor[y*3 + py][x*3 + px] = cor[y*3 + py][x*3 + px] or j for i,j in zip(cor, matrix): for k,l in zip(i,j): if k: t = '*' else: t = ' ' print(f'{t}{l}',end='') print() if num != n-1: print() ```
output
1
16,729
23
33,459
Provide a correct Python 3 solution for this coding contest problem. Taro is playing with a puzzle that places numbers 1-9 in 9x9 squares. In this puzzle, you have to arrange the numbers according to the following rules. * One number appears exactly once in the same column * A number appears exactly once on the same line * In each of the 3x3 ranges separated by double lines, a number appears exactly once. For example, Figure 1 below is one arrangement that meets such a rule. However, Taro often creates an arrangement that violates the rules, as shown in Figure 2. The "2" appears twice in the leftmost column, the "1" never appears, the "1" appears twice in the second column from the left, and the "2" never appears. .. <image> | <image> --- | --- Figure 1 | Figure 2 To help Taro, write a program that reads the arrangement of numbers, checks if the arrangement meets the rules, and outputs the location if it violates the rules. Please display * (half-width asterisk) before the number that is incorrect (appears more than once) according to the three rules, and blank before the number that is not incorrect. Input Given multiple datasets. The first row gives the number of datasets n (n ≀ 20). Each dataset is given a 9-character, 9-line numeric string that indicates the state of the puzzle. Output Output the following for each dataset. Given number, * (half-width asterisk) and blank. Add * before the wrong number and a half-width space before the wrong number. Insert a blank line between the datasets. Example Input 2 2 1 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 2 1 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 Output *2*1 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 *2*1 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
instruction
0
16,730
23
33,460
"Correct Solution: ``` from collections import Counter CounterKey = ("1", "2", "3", "4", "5", "6", "7", "8", "9") inputCount = int(input()) for _ in range(inputCount): puzzle = [] mark = [] if _ != 0: print() for lp in range(9): puzzle.append([item for item in input().split(" ")]) mark.append([item for item in " " * 9]) # ζ¨ͺ for rowIndex, row in enumerate(puzzle): counter = Counter(row) needNum = [num for num in CounterKey if 1 < counter[num]] if not needNum: continue for colIndex, item in enumerate(row): if item in needNum: mark[rowIndex][colIndex] = "*" # ηΈ¦ for colIndex, col in enumerate( zip(puzzle[0], puzzle[1], puzzle[2], puzzle[3], puzzle[4], puzzle[5], puzzle[6], puzzle[7], puzzle[8])): counter = Counter(col) needNum = [num for num in CounterKey if 1 < counter[num]] if not needNum: continue for rowIndex, item in enumerate(col): if item in needNum: mark[rowIndex][colIndex] = "*" # ε››θ§’ for lp in range(3): block = [] for blockCount, col in enumerate(zip(puzzle[lp * 3], puzzle[lp * 3 + 1], puzzle[lp * 3 + 2])): block.extend(col) if blockCount % 3 - 2 == 0: counter = Counter(block) needNum = [num for num in CounterKey if 1 < counter[num]] if needNum: for index, item in enumerate(block): if item in needNum: rowIndex, colIndex = lp * 3 + index % 3, blockCount - 2 + index // 3 mark[rowIndex][colIndex] = "*" block = [] # ε‡ΊεŠ› for p, m in zip(puzzle, mark): output = [] for num, state in zip(p, m): output.append(state) output.append(num) print("".join(output)) ```
output
1
16,730
23
33,461
Provide a correct Python 3 solution for this coding contest problem. Taro is playing with a puzzle that places numbers 1-9 in 9x9 squares. In this puzzle, you have to arrange the numbers according to the following rules. * One number appears exactly once in the same column * A number appears exactly once on the same line * In each of the 3x3 ranges separated by double lines, a number appears exactly once. For example, Figure 1 below is one arrangement that meets such a rule. However, Taro often creates an arrangement that violates the rules, as shown in Figure 2. The "2" appears twice in the leftmost column, the "1" never appears, the "1" appears twice in the second column from the left, and the "2" never appears. .. <image> | <image> --- | --- Figure 1 | Figure 2 To help Taro, write a program that reads the arrangement of numbers, checks if the arrangement meets the rules, and outputs the location if it violates the rules. Please display * (half-width asterisk) before the number that is incorrect (appears more than once) according to the three rules, and blank before the number that is not incorrect. Input Given multiple datasets. The first row gives the number of datasets n (n ≀ 20). Each dataset is given a 9-character, 9-line numeric string that indicates the state of the puzzle. Output Output the following for each dataset. Given number, * (half-width asterisk) and blank. Add * before the wrong number and a half-width space before the wrong number. Insert a blank line between the datasets. Example Input 2 2 1 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 2 1 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 Output *2*1 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 *2*1 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
instruction
0
16,731
23
33,462
"Correct Solution: ``` # Aizu Problem 00126: Puzzle # import sys, math, os, copy # read input: PYDEV = os.environ.get('PYDEV') if PYDEV=="True": sys.stdin = open("sample-input.txt", "rt") def check_puzzle(puzzle): marker = [[' ' for _ in range(9)] for __ in range(9)] # check rows: for r in range(9): row = puzzle[r] for k in range(1, 10): if row.count(k) != 1: for idx in [j for j in range(9) if row[j] == k]: marker[r][idx] = '*' # check columns: for c in range(9): col = [puzzle[r][c] for r in range(9)] for k in range(1, 10): if col.count(k) != 1: for idx in [j for j in range(9) if col[j] == k]: marker[idx][c] = '*' # check sub-squares: for rs in range(3): for rc in range(3): square = puzzle[3*rs][3*rc:3*rc+3] + puzzle[3*rs+1][3*rc:3*rc+3] + \ puzzle[3*rs+2][3*rc:3*rc+3] for k in range(1, 10): if square.count(k) != 1: for idx in [j for j in range(9) if square[j] == k]: ridx = 3 * rs + idx // 3 cidx = 3 * rc + idx % 3 marker[ridx][cidx] = '*' return marker first = True N = int(input()) for n in range(N): puzzle = [[int(_) for _ in input().split()] for __ in range(9)] marker = check_puzzle(puzzle) if first: first = False else: print() for k in range(9): out = ''.join([marker[k][j] + str(puzzle[k][j]) for j in range(9)]) print(out) ```
output
1
16,731
23
33,463
Provide a correct Python 3 solution for this coding contest problem. Taro is playing with a puzzle that places numbers 1-9 in 9x9 squares. In this puzzle, you have to arrange the numbers according to the following rules. * One number appears exactly once in the same column * A number appears exactly once on the same line * In each of the 3x3 ranges separated by double lines, a number appears exactly once. For example, Figure 1 below is one arrangement that meets such a rule. However, Taro often creates an arrangement that violates the rules, as shown in Figure 2. The "2" appears twice in the leftmost column, the "1" never appears, the "1" appears twice in the second column from the left, and the "2" never appears. .. <image> | <image> --- | --- Figure 1 | Figure 2 To help Taro, write a program that reads the arrangement of numbers, checks if the arrangement meets the rules, and outputs the location if it violates the rules. Please display * (half-width asterisk) before the number that is incorrect (appears more than once) according to the three rules, and blank before the number that is not incorrect. Input Given multiple datasets. The first row gives the number of datasets n (n ≀ 20). Each dataset is given a 9-character, 9-line numeric string that indicates the state of the puzzle. Output Output the following for each dataset. Given number, * (half-width asterisk) and blank. Add * before the wrong number and a half-width space before the wrong number. Insert a blank line between the datasets. Example Input 2 2 1 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 2 1 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 Output *2*1 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 *2*1 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
instruction
0
16,732
23
33,464
"Correct Solution: ``` n=int(input()) for i in range(n): board=[] check=[[0 for a in range(9)] for b in range(9)] for j in range(9): board.append(list(map(int,input().split()))) board_r = [list(x) for x in zip(*board)] for j in range(9): for k in range(9): if board[j].count(board[j][k])>1:check[j][k]=1 for j in range(9): for k in range(9): if board_r[j].count(board_r[j][k])>1:check[k][j]=1 for j in range(3): for k in range(3): ch_list=[] for l in range(9): ch_list.append(board[j*3+l%3][k*3+l//3]) for l in range(9): if ch_list.count(ch_list[l])>1:check[j*3+l%3][k*3+l//3]=1 for j in range(9): for k in range(9): if check[j][k]==1:print("*",end="") else:print(" ",end="") print(board[j][k],end="") print() if i<n-1:print() ```
output
1
16,732
23
33,465
Provide a correct Python 3 solution for this coding contest problem. Taro is playing with a puzzle that places numbers 1-9 in 9x9 squares. In this puzzle, you have to arrange the numbers according to the following rules. * One number appears exactly once in the same column * A number appears exactly once on the same line * In each of the 3x3 ranges separated by double lines, a number appears exactly once. For example, Figure 1 below is one arrangement that meets such a rule. However, Taro often creates an arrangement that violates the rules, as shown in Figure 2. The "2" appears twice in the leftmost column, the "1" never appears, the "1" appears twice in the second column from the left, and the "2" never appears. .. <image> | <image> --- | --- Figure 1 | Figure 2 To help Taro, write a program that reads the arrangement of numbers, checks if the arrangement meets the rules, and outputs the location if it violates the rules. Please display * (half-width asterisk) before the number that is incorrect (appears more than once) according to the three rules, and blank before the number that is not incorrect. Input Given multiple datasets. The first row gives the number of datasets n (n ≀ 20). Each dataset is given a 9-character, 9-line numeric string that indicates the state of the puzzle. Output Output the following for each dataset. Given number, * (half-width asterisk) and blank. Add * before the wrong number and a half-width space before the wrong number. Insert a blank line between the datasets. Example Input 2 2 1 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 2 1 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 Output *2*1 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 *2*1 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
instruction
0
16,733
23
33,466
"Correct Solution: ``` # -*- coding: utf-8 -*- """ http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0126 """ import sys from sys import stdin from collections import defaultdict input = stdin.readline def solve(data): status = [[' '] * 9 for _ in range(9)] # ?Β¨???????????????Β§?????? for y, row in enumerate(data): freq = defaultdict(int) for i, n in enumerate(row): if n in freq: freq[n].append(i) else: freq[n] = [i] for k, v in freq.items(): if len(v) > 1: for ind in v: status[y][ind] = '*' # ?????????????????Β§?????? for x in range(9): freq = defaultdict(int) for y in range(9): n = data[y][x] if n in freq: freq[n].append(y) else: freq[n] = [y] for k, v in freq.items(): if len(v) > 1: for ind in v: status[ind][x] = '*' # 3x3????????Β§?????? for y in range(0, 9, 3): for x in range(0, 9, 3): freq = defaultdict(int) for yy in range(3): for xx in range(3): n = data[y+yy][x+xx] if n in freq: freq[n].append((x+xx, y+yy)) else: freq[n] = [(x+xx, y+yy)] for k, v in freq.items(): if len(v) > 1: for xx, yy in v: status[yy][xx] = '*' for y in range(9): for x in range(9): print('{}{}'.format(status[y][x], data[y][x]), end='') print() def main(args): n = int(input()) for i in range(n): data = [[int(x) for x in input().split()] for _ in range(9)] result = solve(data) if i != n-1: print() if __name__ == '__main__': main(sys.argv[1:]) ```
output
1
16,733
23
33,467
Provide a correct Python 3 solution for this coding contest problem. Taro is playing with a puzzle that places numbers 1-9 in 9x9 squares. In this puzzle, you have to arrange the numbers according to the following rules. * One number appears exactly once in the same column * A number appears exactly once on the same line * In each of the 3x3 ranges separated by double lines, a number appears exactly once. For example, Figure 1 below is one arrangement that meets such a rule. However, Taro often creates an arrangement that violates the rules, as shown in Figure 2. The "2" appears twice in the leftmost column, the "1" never appears, the "1" appears twice in the second column from the left, and the "2" never appears. .. <image> | <image> --- | --- Figure 1 | Figure 2 To help Taro, write a program that reads the arrangement of numbers, checks if the arrangement meets the rules, and outputs the location if it violates the rules. Please display * (half-width asterisk) before the number that is incorrect (appears more than once) according to the three rules, and blank before the number that is not incorrect. Input Given multiple datasets. The first row gives the number of datasets n (n ≀ 20). Each dataset is given a 9-character, 9-line numeric string that indicates the state of the puzzle. Output Output the following for each dataset. Given number, * (half-width asterisk) and blank. Add * before the wrong number and a half-width space before the wrong number. Insert a blank line between the datasets. Example Input 2 2 1 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 2 1 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 Output *2*1 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 *2*1 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
instruction
0
16,734
23
33,468
"Correct Solution: ``` import math def isPutNum(board, x, y, n): for i in range(9): if board[x][i] == n: return False for i in range(9): if board[i][y] == n: return False xx = math.floor(x / 3) yy = math.floor(y / 3) for i in range(3): for j in range(3): if board[xx*3 + i][yy*3 + j] == n: return False return True N = int(input()) table = [[0 for i in range(9)] for j in range(9)] for l in range(N): if l > 0: print("") for i in range(9): table[i] = [int(j) for j in input().split()] for i in range(9): for j in range(9): tmp = table[i][j] table[i][j] = 0 if isPutNum(table, i, j, tmp): print(" ", end="") else: print("*", end="") table[i][j] = tmp print(table[i][j], end="") print("") ```
output
1
16,734
23
33,469
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. For a given set of two-dimensional points S, let's denote its extension E(S) as the result of the following algorithm: Create another set of two-dimensional points R, which is initially equal to S. Then, while there exist four numbers x_1, y_1, x_2 and y_2 such that (x_1, y_1) ∈ R, (x_1, y_2) ∈ R, (x_2, y_1) ∈ R and (x_2, y_2) βˆ‰ R, add (x_2, y_2) to R. When it is impossible to find such four integers, let R be the result of the algorithm. Now for the problem itself. You are given a set of two-dimensional points S, which is initially empty. You have to process two types of queries: add some point to S, or remove some point from it. After each query you have to compute the size of E(S). Input The first line contains one integer q (1 ≀ q ≀ 3 β‹… 10^5) β€” the number of queries. Then q lines follow, each containing two integers x_i, y_i (1 ≀ x_i, y_i ≀ 3 β‹… 10^5), denoting i-th query as follows: if (x_i, y_i) ∈ S, erase it from S, otherwise insert (x_i, y_i) into S. Output Print q integers. i-th integer should be equal to the size of E(S) after processing first i queries. Example Input 7 1 1 1 2 2 1 2 2 1 2 1 3 2 1 Output 1 2 4 4 4 6 3 Submitted Solution: ``` #!/usr/bin/env python3 def solve_it(S): ES=S.copy() for p in S: for p2 in S: if (p[0],p2[1]) in ES and (p2[0],p[1]) not in ES: if (p2[0],p[1]) not in ES: #print("Added:",(p2[0],p[1])) ES.add((p2[0],p[1])) elif (p[0],p2[1]) not in ES and (p2[0],p[1]) in ES: if (p[0],p2[1]) not in ES: #print("Added:",(p[0],p2[1])) ES.add((p[0],p2[1])) return len(ES) if __name__=="__main__": #''' n = int(input()) S=set() res=[] for i in range(n): p = tuple(map(int,input().split())) if p in S: S.remove(p) else: S.add(p) res.append(str(solve_it(S))) print(" ".join(res)) ''' res=[] S=set() ES=set() for tc in [ ((1,1),1), ((1,2),2), ((2,1),4), ((2,2),4), ((1,2),4), ((1,3),6), ((2,1),3), ]: if tc[0] in S: S.remove(tc[0]) else: S.add(tc[0]) r = solve_it(S) if r != tc[1]: print("Error for:",tc," got:",r) exit() else: print("Passed:",tc) #''' ```
instruction
0
16,894
23
33,788
No
output
1
16,894
23
33,789
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. For a given set of two-dimensional points S, let's denote its extension E(S) as the result of the following algorithm: Create another set of two-dimensional points R, which is initially equal to S. Then, while there exist four numbers x_1, y_1, x_2 and y_2 such that (x_1, y_1) ∈ R, (x_1, y_2) ∈ R, (x_2, y_1) ∈ R and (x_2, y_2) βˆ‰ R, add (x_2, y_2) to R. When it is impossible to find such four integers, let R be the result of the algorithm. Now for the problem itself. You are given a set of two-dimensional points S, which is initially empty. You have to process two types of queries: add some point to S, or remove some point from it. After each query you have to compute the size of E(S). Input The first line contains one integer q (1 ≀ q ≀ 3 β‹… 10^5) β€” the number of queries. Then q lines follow, each containing two integers x_i, y_i (1 ≀ x_i, y_i ≀ 3 β‹… 10^5), denoting i-th query as follows: if (x_i, y_i) ∈ S, erase it from S, otherwise insert (x_i, y_i) into S. Output Print q integers. i-th integer should be equal to the size of E(S) after processing first i queries. Example Input 7 1 1 1 2 2 1 2 2 1 2 1 3 2 1 Output 1 2 4 4 4 6 3 Submitted Solution: ``` print("1 2 4 4 4 6 3") ```
instruction
0
16,895
23
33,790
No
output
1
16,895
23
33,791
Provide tags and a correct Python 3 solution for this coding contest problem. Theatre Square in the capital city of Berland has a rectangular shape with the size n Γ— m meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size a Γ— a. What is the least number of flagstones needed to pave the Square? It's allowed to cover the surface larger than the Theatre Square, but the Square has to be covered. It's not allowed to break the flagstones. The sides of flagstones should be parallel to the sides of the Square. Input The input contains three positive integer numbers in the first line: n, m and a (1 ≀ n, m, a ≀ 109). Output Write the needed number of flagstones. Examples Input 6 6 4 Output 4
instruction
0
17,046
23
34,092
Tags: math Correct Solution: ``` import math def converttoint(L): for i in range(len(L)): L[i]=int(L[i]) def ceilingdivision(n,d): a=math.ceil(n/d) return a def ceilingdivision1(n,d): a=((n-d)/d) if a>0: return math.ceil(a) else: return 0 nma=input() nma=nma.split() converttoint(nma) a=ceilingdivision(nma[0],nma[2]) b=ceilingdivision1(nma[1],nma[2]) flagstones=a*(1+b) print(flagstones) ```
output
1
17,046
23
34,093
Provide tags and a correct Python 3 solution for this coding contest problem. Theatre Square in the capital city of Berland has a rectangular shape with the size n Γ— m meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size a Γ— a. What is the least number of flagstones needed to pave the Square? It's allowed to cover the surface larger than the Theatre Square, but the Square has to be covered. It's not allowed to break the flagstones. The sides of flagstones should be parallel to the sides of the Square. Input The input contains three positive integer numbers in the first line: n, m and a (1 ≀ n, m, a ≀ 109). Output Write the needed number of flagstones. Examples Input 6 6 4 Output 4
instruction
0
17,047
23
34,094
Tags: math Correct Solution: ``` n, m, a = map(int, input().split(' ')) print(str(((n-1)//a + 1)*((m -1)//a + 1))) ```
output
1
17,047
23
34,095
Provide tags and a correct Python 3 solution for this coding contest problem. Theatre Square in the capital city of Berland has a rectangular shape with the size n Γ— m meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size a Γ— a. What is the least number of flagstones needed to pave the Square? It's allowed to cover the surface larger than the Theatre Square, but the Square has to be covered. It's not allowed to break the flagstones. The sides of flagstones should be parallel to the sides of the Square. Input The input contains three positive integer numbers in the first line: n, m and a (1 ≀ n, m, a ≀ 109). Output Write the needed number of flagstones. Examples Input 6 6 4 Output 4
instruction
0
17,048
23
34,096
Tags: math Correct Solution: ``` n, m, a = map(int, input().split()) z = ((m + a - 1) // a) * ((n + a - 1) // a) print(z) ```
output
1
17,048
23
34,097
Provide tags and a correct Python 3 solution for this coding contest problem. Theatre Square in the capital city of Berland has a rectangular shape with the size n Γ— m meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size a Γ— a. What is the least number of flagstones needed to pave the Square? It's allowed to cover the surface larger than the Theatre Square, but the Square has to be covered. It's not allowed to break the flagstones. The sides of flagstones should be parallel to the sides of the Square. Input The input contains three positive integer numbers in the first line: n, m and a (1 ≀ n, m, a ≀ 109). Output Write the needed number of flagstones. Examples Input 6 6 4 Output 4
instruction
0
17,049
23
34,098
Tags: math Correct Solution: ``` n = input().split(' ') n[0]=int(n[0]) n[1]=int(n[1]) n[2]=int(n[2]) if n[0] % n[2] == 0: a = n[0] / n[2] else: a = int(n[0] / n[2]) +1 if n[1] % n[2] == 0: b = n[1] / n[2] else: b = int(n[1] / n[2]) +1 print(int(a*b)) ```
output
1
17,049
23
34,099
Provide tags and a correct Python 3 solution for this coding contest problem. Theatre Square in the capital city of Berland has a rectangular shape with the size n Γ— m meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size a Γ— a. What is the least number of flagstones needed to pave the Square? It's allowed to cover the surface larger than the Theatre Square, but the Square has to be covered. It's not allowed to break the flagstones. The sides of flagstones should be parallel to the sides of the Square. Input The input contains three positive integer numbers in the first line: n, m and a (1 ≀ n, m, a ≀ 109). Output Write the needed number of flagstones. Examples Input 6 6 4 Output 4
instruction
0
17,050
23
34,100
Tags: math Correct Solution: ``` #!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2017/3/22 0:53 # @Author : mazicwong # @File : 1A.py ''' give : n,m,a a retangle with n*m and use how many square with a*a to patch up with it (can be overlap) http://blog.csdn.net/chenguolinblog/article/details/12190689 ''' myList = input().split() n=int(myList[0]) m=int(myList[1]) a=int(myList[2]) print((n//a+(n%a>0))*(m//a+(m%a>0))) ```
output
1
17,050
23
34,101
Provide tags and a correct Python 3 solution for this coding contest problem. Theatre Square in the capital city of Berland has a rectangular shape with the size n Γ— m meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size a Γ— a. What is the least number of flagstones needed to pave the Square? It's allowed to cover the surface larger than the Theatre Square, but the Square has to be covered. It's not allowed to break the flagstones. The sides of flagstones should be parallel to the sides of the Square. Input The input contains three positive integer numbers in the first line: n, m and a (1 ≀ n, m, a ≀ 109). Output Write the needed number of flagstones. Examples Input 6 6 4 Output 4
instruction
0
17,051
23
34,102
Tags: math Correct Solution: ``` n,m,a = (int(x) for x in input().split()) e1=e2=0 if(n%a==0): e1 = n/a else: e1 = n//a+1 if(m%a==0): e2 = m/a else: e2 = m//a+1 print ("%d"%(e1*e2)) ```
output
1
17,051
23
34,103
Provide tags and a correct Python 3 solution for this coding contest problem. Theatre Square in the capital city of Berland has a rectangular shape with the size n Γ— m meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size a Γ— a. What is the least number of flagstones needed to pave the Square? It's allowed to cover the surface larger than the Theatre Square, but the Square has to be covered. It's not allowed to break the flagstones. The sides of flagstones should be parallel to the sides of the Square. Input The input contains three positive integer numbers in the first line: n, m and a (1 ≀ n, m, a ≀ 109). Output Write the needed number of flagstones. Examples Input 6 6 4 Output 4
instruction
0
17,052
23
34,104
Tags: math Correct Solution: ``` n, m, a = map(int, input().split()) i=m // a if (m % a) > 0: i=i+1 o=n // a if (n % a) > 0: o=o + 1 print(i * o) ```
output
1
17,052
23
34,105
Provide tags and a correct Python 3 solution for this coding contest problem. Theatre Square in the capital city of Berland has a rectangular shape with the size n Γ— m meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size a Γ— a. What is the least number of flagstones needed to pave the Square? It's allowed to cover the surface larger than the Theatre Square, but the Square has to be covered. It's not allowed to break the flagstones. The sides of flagstones should be parallel to the sides of the Square. Input The input contains three positive integer numbers in the first line: n, m and a (1 ≀ n, m, a ≀ 109). Output Write the needed number of flagstones. Examples Input 6 6 4 Output 4
instruction
0
17,053
23
34,106
Tags: math Correct Solution: ``` A=str(input()) list1=A.split(' ') m=int(list1[0]) n=int(list1[1]) a=int(list1[2]) if m%a==0 and n%a==0: print((m//a)*(n//a)) elif m%a!=0 and n%a==0: print((m//a+1)*(n//a)) elif n%a!=0 and m%a==0: print((n//a+1)*(m//a)) else: print((m//a+1)*(n//a+1)) ```
output
1
17,053
23
34,107
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Theatre Square in the capital city of Berland has a rectangular shape with the size n Γ— m meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size a Γ— a. What is the least number of flagstones needed to pave the Square? It's allowed to cover the surface larger than the Theatre Square, but the Square has to be covered. It's not allowed to break the flagstones. The sides of flagstones should be parallel to the sides of the Square. Input The input contains three positive integer numbers in the first line: n, m and a (1 ≀ n, m, a ≀ 109). Output Write the needed number of flagstones. Examples Input 6 6 4 Output 4 Submitted Solution: ``` #/bin/env python3 import math def main(): n, m, a = map(int, input().split()) print(math.ceil(n / a) * math.ceil(m / a)) if __name__ == "__main__": main() ```
instruction
0
17,054
23
34,108
Yes
output
1
17,054
23
34,109
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Theatre Square in the capital city of Berland has a rectangular shape with the size n Γ— m meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size a Γ— a. What is the least number of flagstones needed to pave the Square? It's allowed to cover the surface larger than the Theatre Square, but the Square has to be covered. It's not allowed to break the flagstones. The sides of flagstones should be parallel to the sides of the Square. Input The input contains three positive integer numbers in the first line: n, m and a (1 ≀ n, m, a ≀ 109). Output Write the needed number of flagstones. Examples Input 6 6 4 Output 4 Submitted Solution: ``` n,m,a = map(int, input().split()) print(((n+a-1)//a) * ((m+a-1)//a)) ```
instruction
0
17,055
23
34,110
Yes
output
1
17,055
23
34,111
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Theatre Square in the capital city of Berland has a rectangular shape with the size n Γ— m meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size a Γ— a. What is the least number of flagstones needed to pave the Square? It's allowed to cover the surface larger than the Theatre Square, but the Square has to be covered. It's not allowed to break the flagstones. The sides of flagstones should be parallel to the sides of the Square. Input The input contains three positive integer numbers in the first line: n, m and a (1 ≀ n, m, a ≀ 109). Output Write the needed number of flagstones. Examples Input 6 6 4 Output 4 Submitted Solution: ``` a = list(map(int, input().rstrip().split())) if a[0]%a[2] != 0 : c1 = a[0]//a[2] + 1 else : c1 = a[0]//a[2] if a[1]%a[2] != 0 : c2 = a[1]//a[2] + 1 else : c2 = a[1]//a[2] print (c1*c2) ```
instruction
0
17,056
23
34,112
Yes
output
1
17,056
23
34,113
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Theatre Square in the capital city of Berland has a rectangular shape with the size n Γ— m meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size a Γ— a. What is the least number of flagstones needed to pave the Square? It's allowed to cover the surface larger than the Theatre Square, but the Square has to be covered. It's not allowed to break the flagstones. The sides of flagstones should be parallel to the sides of the Square. Input The input contains three positive integer numbers in the first line: n, m and a (1 ≀ n, m, a ≀ 109). Output Write the needed number of flagstones. Examples Input 6 6 4 Output 4 Submitted Solution: ``` from math import ceil class Scanner: def __init__(self): self.currentline = "" self.current_int_array = [] def nextline(self): self.currentline = input() return self.currentline def nextints(self): self.current_int_array = list(map(int, self.nextline().split())) return self.current_int_array def nextint(self): if len(self.current_int_array) == 0: self.nextints() return self.current_int_array.pop(0) stdin = Scanner() n, m, a = stdin.nextint(), stdin.nextint(), stdin.nextint() h = ceil(n / a) v = ceil(m / a) print (h*v) ```
instruction
0
17,057
23
34,114
Yes
output
1
17,057
23
34,115
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Theatre Square in the capital city of Berland has a rectangular shape with the size n Γ— m meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size a Γ— a. What is the least number of flagstones needed to pave the Square? It's allowed to cover the surface larger than the Theatre Square, but the Square has to be covered. It's not allowed to break the flagstones. The sides of flagstones should be parallel to the sides of the Square. Input The input contains three positive integer numbers in the first line: n, m and a (1 ≀ n, m, a ≀ 109). Output Write the needed number of flagstones. Examples Input 6 6 4 Output 4 Submitted Solution: ``` n,m,a=input().split() n,m,a=int(n),int(m),int(a) x=max(n//a,m//a) print(a*x) ```
instruction
0
17,058
23
34,116
No
output
1
17,058
23
34,117
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Theatre Square in the capital city of Berland has a rectangular shape with the size n Γ— m meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size a Γ— a. What is the least number of flagstones needed to pave the Square? It's allowed to cover the surface larger than the Theatre Square, but the Square has to be covered. It's not allowed to break the flagstones. The sides of flagstones should be parallel to the sides of the Square. Input The input contains three positive integer numbers in the first line: n, m and a (1 ≀ n, m, a ≀ 109). Output Write the needed number of flagstones. Examples Input 6 6 4 Output 4 Submitted Solution: ``` m=6 n=6 a=4 x=n//a if (n%a>0): x=x+1 else: x=x y=m//a if (y%a>0): y=y+1 else: y=y print(x*y) ```
instruction
0
17,059
23
34,118
No
output
1
17,059
23
34,119
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Theatre Square in the capital city of Berland has a rectangular shape with the size n Γ— m meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size a Γ— a. What is the least number of flagstones needed to pave the Square? It's allowed to cover the surface larger than the Theatre Square, but the Square has to be covered. It's not allowed to break the flagstones. The sides of flagstones should be parallel to the sides of the Square. Input The input contains three positive integer numbers in the first line: n, m and a (1 ≀ n, m, a ≀ 109). Output Write the needed number of flagstones. Examples Input 6 6 4 Output 4 Submitted Solution: ``` import math import sys s = input().split() a = int(s[0]) b = int(s[1]) c = int(s[2]) ans = int(0) if a % c > 0: ans += int(a/c + 1) else: ans += int(a/c) if b % c > 0: ans += int(b/c + 1) else: ans += int(b/c) print(ans) ```
instruction
0
17,060
23
34,120
No
output
1
17,060
23
34,121
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Theatre Square in the capital city of Berland has a rectangular shape with the size n Γ— m meters. On the occasion of the city's anniversary, a decision was taken to pave the Square with square granite flagstones. Each flagstone is of the size a Γ— a. What is the least number of flagstones needed to pave the Square? It's allowed to cover the surface larger than the Theatre Square, but the Square has to be covered. It's not allowed to break the flagstones. The sides of flagstones should be parallel to the sides of the Square. Input The input contains three positive integer numbers in the first line: n, m and a (1 ≀ n, m, a ≀ 109). Output Write the needed number of flagstones. Examples Input 6 6 4 Output 4 Submitted Solution: ``` n, m, a = map(int, input().split()) print (n+a-1) ```
instruction
0
17,061
23
34,122
No
output
1
17,061
23
34,123
Provide a correct Python 3 solution for this coding contest problem. There is an image with a height of H pixels and a width of W pixels. Each of the pixels is represented by either `.` or `*`. The character representing the pixel at the i-th row from the top and the j-th column from the left, is denoted by C_{i,j}. Extend this image vertically so that its height is doubled. That is, print a image with a height of 2H pixels and a width of W pixels where the pixel at the i-th row and j-th column is equal to C_{(i+1)/2,j} (the result of division is rounded down). Constraints * 1≦H, W≦100 * C_{i,j} is either `.` or `*`. Input The input is given from Standard Input in the following format: H W C_{1,1}...C_{1,W} : C_{H,1}...C_{H,W} Output Print the extended image. Examples Input 2 2 *. .* Output *. *. .* .* Input 1 4 ***. Output ***. ***. Input 9 20 .....***....***..... ....*...*..*...*.... ...*.....**.....*... ...*.....*......*... ....*.....*....*.... .....**..*...**..... .......*..*.*....... ........**.*........ .........**......... Output .....***....***..... .....***....***..... ....*...*..*...*.... ....*...*..*...*.... ...*.....**.....*... ...*.....**.....*... ...*.....*......*... ...*.....*......*... ....*.....*....*.... ....*.....*....*.... .....**..*...**..... .....**..*...**..... .......*..*.*....... .......*..*.*....... ........**.*........ ........**.*........ .........**......... .........**.........
instruction
0
17,572
23
35,144
"Correct Solution: ``` h,w = map(int,input().split()) for i in range(h): str = input()+"\n" print(str*2) ```
output
1
17,572
23
35,145