TnT/CodeNet4Repair huggingface dataset:
Problem:
You are given a image with a height of H pixels and a width of W pixels. Each pixel is represented by a lowercase English letter. The pixel at the i-th row from the top and j-th column from the left is a_{ij}.  Put a box around this image and output the result. The box should consist of `#` and have a thickness of 1.

Incorrect submission (verdict: Wrong Answer):
# -*- coding: utf-8 -*-

H,W = list(map(int, input().rstrip().split()))
a_list = [list(input().strip()) for _ in range(H)]
#-----

b_list=[ ["#" for c in range(W+2)] for r in range(H+2) ]

for i in range(H):
    for j in range(W):
        b_list[i+1][j+1] = a_list[i][j]

for li in b_list:
    print(*li)


Fixed, accepted submission:
# -*- coding: utf-8 -*-

H,W = list(map(int, input().rstrip().split()))
a_list = [list(input().strip()) for _ in range(H)]
#-----

b_list=[ ["#" for c in range(W+2)] for r in range(H+2) ]

for i in range(H):
    for j in range(W):
        b_list[i+1][j+1] = a_list[i][j]

for li in b_list:
    print(*li,sep="")
Problem:
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?

Incorrect submission (verdict: Wrong Answer):
n=int(input())
print((1+n)*n/2)

Fixed, accepted submission:
n=int(input())
print(int((1+n)*n/2))
Problem:
Snuke is giving cookies to his three goats.  He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins).  Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.

Incorrect submission (verdict: Wrong Answer):
a, b  = map(int,input().split())

if (a % 3 != 0) and ( b % 3 != 0):
  print("Impossible")
  
else:
  print("Possible")
  

Fixed, accepted submission:
a, b  = map(int,input().split())

if (a % 3 == 0) or( b % 3 == 0) or ((a + b) % 3 ==0):
  print("Possible")
  
else:
  print("Impossible")
Problem:
You are parking at a parking lot. You can choose from the following two fee plans:    * Plan 1: The fee will be A×T yen (the currency of Japan) when you park for T hours.   * Plan 2: The fee will be B yen, regardless of the duration.  Find the minimum fee when you park for N hours.

Incorrect submission (verdict: Wrong Answer):
N, A, B = map(int, input().split())

print(N * A + B)

Fixed, accepted submission:
N, A, B = map(int, input().split())

ans = N * A if N * A < B else B

print(ans)
Problem:
Quickly after finishing the tutorial of the online game _ATChat_ , you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the **friendliness** of Player i is A_i.  The N players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere.  When each player, except the first one to arrive, arrives at the place, the player gets **comfort** equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of 0.  What is the maximum total comfort the N players can get by optimally choosing the order of arrivals and the positions in the circle to cut into?

Incorrect submission (verdict: Wrong Answer):
N = int(input())
A = sorted([int(i) for i in input().split()], reverse=True)

S = A[0]
step = 2

print(S)
for i in range(1,N-1):
  S += (A[(i+1)//2])
  print(S)

print(S)

Fixed, accepted submission:
N = int(input())
A = sorted([int(i) for i in input().split()], reverse=True)

S = A[0]
step = 2

for i in range(1,N-1):
  S += (A[(i+1)//2])

print(S)
Problem:
Given is a tree G with N vertices. The vertices are numbered 1 through N, and the i-th edge connects Vertex a_i and Vertex b_i.  Consider painting the edges in G with some number of colors. We want to paint them so that, for each vertex, the colors of the edges incident to that vertex are all different.  Among the colorings satisfying the condition above, construct one that uses the minimum number of colors.

Incorrect submission (verdict: Wrong Answer):
from functools import reduce
from operator import mul
N = int(input())
ab = [tuple(map(int, input().split())) for _ in range(N-1)]
print(N, ab)
E_n = {k: 0 for k in ab}
for i in range(1,N+1):
    items = {k:v for k,v in E_n.items() if i in k}
    c = 0
    for k in items.keys():
      if items[k] != 0: continue
      while True:
        c += 1
        if c not in items.values():
          items[k] = c
          break
    for k,v in items.items(): E_n[k] = v
    if reduce(mul, E_n.values()) != 0: break

print(len(set(E_n.values())))
for k in sorted(E_n.keys()): print(E_n[k])


Fixed, accepted submission:
N = int(input())
edge = {}
tree = [[] for i in range(N)]
colors = [1]*(N-1)
c_p = [[] for i in range(N)]
for i in range(N-1):
    a,b = map(int,input().split())
    a,b = a-1,b-1
    tree[a].append(b)
    edge[(a,b)] = i

for i in range(N):
    c = 1
    for v_c in tree[i]:
      while c in c_p[i]: c+=1
      colors[edge[(i,v_c)]] = c
      c_p[v_c].append(c)
      c+=1

print(max(colors))
print(*colors, sep="\n")
Problem:
Let f(n) be the number of triples of integers (x,y,z) that satisfy both of the following conditions:    * 1 \leq x,y,z   * x^2 + y^2 + z^2 + xy + yz + zx = n  Given an integer N, find each of f(1),f(2),f(3),\ldots,f(N).

Incorrect submission (verdict: Wrong Answer):
from math import trunc, sqrt

def p(x,y,z):
    return x**2+y**2+z**2+x*y+y*z+z*x

def perm(x,y,z):
    if x==y and y==z and z==x:
        return 1
    if x!=y and y!=z and z!=x:
        return 6
    return 3

def f(n):
    mn=trunc(sqrt(n // 3))+1
    k=0
    for x in range(1,mn+1):
        for y in range(x,mn+1):
            for z in range(y,mn+1):
                if p(x,y,z)==n:
                    k += perm(x,y,z)
    return k

N=int(input())

for n in range(1,N):
    print(n, f(n))
    


Fixed, accepted submission:
N=int(input())

a=[0]*N

x=1
while x*x<=N:
    y=1
    while x*x+y*y+x*y<=N:
        z=1
        while z*z+x*x+y*y+x*y+z*y+z*x<=N:
            a[z*z+x*x+y*y+x*y+z*y+z*x-1]+=1
            z+=1
        y+=1
    x+=1

for n in a:
    print(n)
Problem:
You are given a string S consisting of lowercase English letters. Another string T is initially empty. Determine whether it is possible to obtain S = T by performing the following operation an arbitrary number of times:    * Append one of the following at the end of T: `dream`, `dreamer`, `erase` and `eraser`.

Incorrect submission (verdict: Wrong Answer):
S= input()
i=0

while True:
    flag = False
    if S[i:i+7] == "dreamer":
        i += 7
        flag = True

    if S[i:i+6] == "eraser":
        i += 6
        flag = True
    
    if S[i:i+5] == "erase" or S[i:i+5] == "dream":
        i += 5
        flag = True

    if not flag:
        break

if i == len(S):
    print("Yes")
else:
    print("No")
    
    








Fixed, accepted submission:
s=input().replace("eraser","").replace("erase","").replace("dreamer","").replace("dream","")
print("YES" if len(s)==0 else "NO")
Problem:
There is a rectangle in the xy-plane, with its lower left corner at (0, 0) and its upper right corner at (W, H). Each of its sides is parallel to the x-axis or y-axis. Initially, the whole region within the rectangle is painted white.  Snuke plotted N points into the rectangle. The coordinate of the i-th (1 ≦ i ≦ N) point was (x_i, y_i).  Then, he created an integer sequence a of length N, and for each 1 ≦ i ≦ N, he painted some region within the rectangle black, as follows:    * If a_i = 1, he painted the region satisfying x < x_i within the rectangle.   * If a_i = 2, he painted the region satisfying x > x_i within the rectangle.   * If a_i = 3, he painted the region satisfying y < y_i within the rectangle.   * If a_i = 4, he painted the region satisfying y > y_i within the rectangle.  Find the area of the white region within the rectangle after he finished painting.

Incorrect submission (verdict: Wrong Answer):
w,h,n = map(int,input().split())


#print(x_list)
#print(y_list)
min_x = 0
max_x = w
min_y = 0
max_y = h
for i in range(n):
    x,y,a = map(int,input().split())
    if a==1:
        min_x = x
    elif a==2:
        max_x = x
    elif a==3:
        min_y = y
    else:
        max_y = y
if min_x > max_x or min_y > max_y:
    print(0)
else:
    print((max_x-min_y)*(max_y-min_y))

Fixed, accepted submission:
w,h,n = map(int,input().split())


#print(x_list)
#print(y_list)
min_x = 0
max_x = w
min_y = 0
max_y = h
for i in range(n):
    x,y,a = map(int,input().split())
    if a==1:
        min_x = max(min_x,x)
    elif a==2:
        max_x = min(max_x,x)
    elif a==3:
        min_y = max(min_y,y)
    else:
        max_y = min(max_y,y)
if min_x > max_x or min_y > max_y:
    print(0)
else:
    print((max_x-min_x)*(max_y-min_y))
Problem:
There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times:    * Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.  What is the largest possible sum of the integers written on the blackboard after K operations?

Incorrect submission (verdict: Wrong Answer):
l=list(map(int,input().split()))
k=int(input())

print(sum(l)+max(l)**k-max(l))


Fixed, accepted submission:
A=list(map(int,input().split()))
print(sum(A)+max(A)*(2**int(input())-1))
Problem:
You are given three integers, A, B and C.   Among them, two are the same, but the remaining one is different from the rest.   For example, when A=5,B=7,C=5, A and C are the same, but B is different.   Find the one that is different from the rest among the given three integers.

Incorrect submission (verdict: Wrong Answer):
from collections import defaultdict


def main():
    d = defaultdict(lambda: 0)
    for i in input().split():
        d[int(i)] += 1
    d = {v:k for k, v in d.items()}
    print(d[2])
    

if __name__ == "__main__":
    main()

Fixed, accepted submission:
from collections import defaultdict


def main():
    d = defaultdict(lambda: 0)
    for i in input().split():
        d[int(i)] += 1
    d = {v:k for k, v in d.items()}
    print(d[1])
    

if __name__ == "__main__":
    main()
Problem:
There are N rabbits, numbered 1 through N.  The i-th (1≤i≤N) rabbit likes rabbit a_i. Note that no rabbit can like itself, that is, a_i≠i.  For a pair of rabbits i and j (i＜j), we call the pair (i，j) a _friendly pair_ if the following condition is met.    * Rabbit i likes rabbit j and rabbit j likes rabbit i.  Calculate the number of the friendly pairs.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
line = input().split(' ')
total_list =[]
for i in range(0,n):
   total = i + int(line[i])
   total_list.append(total)
print(total_list)
answer = 0
for i in range(n *2 -1):
    if total_list.count(i) == 2:
        answer += 1
print(answer)

Fixed, accepted submission:
n = int(input())
a = input().split(' ')
t = 0
for o in range(n):
    i = o + 1
    b = int(a[o]) - i
    if i == int(a[o + b]):
      t += 1
print(int(t / 2))
Problem:
Write a program which prints $n$-th fibonacci number for a given integer $n$. The $n$-th fibonacci number is defined by the following recursive formula:  \begin{equation*} fib(n)= \left \\{ \begin{array}{ll} 1 & (n = 0) \\\ 1 & (n = 1) \\\ fib(n - 1) + fib(n - 2) & \\\ \end{array} \right. \end{equation*}

Incorrect submission (verdict: Wrong Answer):
def fib(n):
  if n < 0:
    print("error")
    exit()
  if n < 2:
    result = 1
  result = fib(n-1) + fib(n-2)
  return result

n = int(input())
fib(n)

Fixed, accepted submission:
def fibr(n):
    if arr[n] != 0:
        return arr[n]
    if n < 2:
        arr[n] = 1
    else:
        arr[n] = fibr(n-1) + fibr(n-2)
    return arr[n]

n = int(input())
arr = [0 for i in range(n+1)]
print(fibr(n))
Problem:
You are visiting a large electronics store to buy a refrigerator and a microwave.  The store sells A kinds of refrigerators and B kinds of microwaves. The i-th refrigerator ( 1 \le i \le A ) is sold at a_i yen (the currency of Japan), and the j-th microwave ( 1 \le j \le B ) is sold at b_j yen.  You have M discount tickets. With the i-th ticket ( 1 \le i \le M ), you can get a discount of c_i yen from the total price when buying the x_i-th refrigerator and the y_i-th microwave together. Only one ticket can be used at a time.  You are planning to buy one refrigerator and one microwave. Find the minimum amount of money required.

Incorrect submission (verdict: Wrong Answer):
#B
a,b,m=map(int,input().split())
al=list(map(int,input().split()))
bl=list(map(int,input().split()))
amin=min(al)
bmin=min(bl)
minp=amin+bmin
print(amin,bmin)
for i in range(m):
    num=list(map(int,input().split()))
    price=al[num[0]-1]+bl[num[1]-1]-num[2]
    minp=min(price,minp)
print(minp)

Fixed, accepted submission:
#B
a,b,m=map(int,input().split())
al=list(map(int,input().split()))
bl=list(map(int,input().split()))
amin=min(al)
bmin=min(bl)
minp=amin+bmin
for i in range(m):
    num=list(map(int,input().split()))
    price=al[num[0]-1]+bl[num[1]-1]-num[2]
    minp=min(price,minp)
print(minp)
Problem:
You have A 500-yen coins, B 100-yen coins and C 50-yen coins (yen is the currency of Japan). In how many ways can we select some of these coins so that they are X yen in total?  Coins of the same kind cannot be distinguished. Two ways to select coins are distinguished when, for some kind of coin, the numbers of that coin are different.

Incorrect submission (verdict: Wrong Answer):
#coding:utf-8

a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0
for i in range(a):
  for j in range(b):
    for k in range(c):
      p = a * 500 + b * 100 + c * 50
      if p == x:
        cnt += 1
      elif p > x:
        break
print(cnt)

Fixed, accepted submission:
#coding:utf-8
 
a = int(input())
b = int(input())
c = int(input())
x = int(input())
 
cnt = 0
for i in range(a + 1):
  for j in range(b + 1):
    for k in range(c + 1):
      p = i * 500 + j * 100 + k * 50
      if p > x:
        break
      if p == x:
        cnt += 1
print(cnt)
Problem:
Write a program which reads two integers a, b and an operator op, and then prints the value of a op b.  The operator op is '+', '-', '*' or '/' (sum, difference, product or quotient). The division should truncate any fractional part.

Incorrect submission (verdict: Time Limit Exceeded):
a, op, b = input().split()
while True:
  if op == '+' : print(a + b)
  elif op == '-' : print(a - b)
  elif op == '/' : print(a / b)
  elif op == '*' : print(a * b)
  else : break

Fixed, accepted submission:
while True:
  a, op, b = input().split()
  a = int(a)
  b = int(b)
  if op == '+': print(a + b)
  elif op == '-': print(a - b)
  elif op == '/': print(a // b)
  elif op == '*': print(a * b)
  else: break
Problem:
AtCoDeer the deer found two positive integers, a and b. Determine whether the product of a and b is even or odd.

Incorrect submission (verdict: Wrong Answer):
a, b = map(int, input().split())
if a*b == 0:
  print('Even')
else:
  print('Odd')

Fixed, accepted submission:
a, b = map(int, input().split())
if a*b%2 == 0:
  print('Even')
else:
  print('Odd')
Problem:
There are four towns, numbered 1,2,3 and 4. Also, there are three roads. The i-th road connects different towns a_i and b_i bidirectionally. No two roads connect the same pair of towns. Other than these roads, there is no way to travel between these towns, but any town can be reached from any other town using these roads.  Determine if we can visit all the towns by traversing each of the roads exactly once.

Incorrect submission (verdict: Wrong Answer):
a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())


cnt = {1: 0, 2: 0, 3: 0, 4: 0}
for i in range(4):
    if not i+1 in [a1, a2, a3, b1, b2, b3]:
        print('NO')
        exit()

lis = [a1, a2, a3, b1, b2, b3]

c = 0
for l in range(4):
    cnt = lis.count(l+1)
    if cnt > 1:
        c += 1

if c <= 2:
    print('NO')

print('YES')


Fixed, accepted submission:
a1, b1 = map(int, input().split())
a2, b2 = map(int, input().split())
a3, b3 = map(int, input().split())

cnt = {1: 0, 2: 0, 3: 0, 4: 0}
for i in range(4):
    if not i+1 in [a1, a2, a3, b1, b2, b3]:
        print('NO')
        exit()

lis = [a1, a2, a3, b1, b2, b3]

c = 0
for l in range(4):
    cnt = lis.count(l+1)
    if cnt > 1:
        c += 1

if c < 2:
    print('NO')
    exit()

print('YES')
Problem:
We have a board with H horizontal rows and W vertical columns of squares. There is a bishop at the top-left square on this board. How many squares can this bishop reach by zero or more movements?  Here the bishop can only move diagonally. More formally, the bishop can move from the square at the r_1-th row (from the top) and the c_1-th column (from the left) to the square at the r_2-th row and the c_2-th column if and only if exactly one of the following holds:    * r_1 + c_1 = r_2 + c_2   * r_1 - c_1 = r_2 - c_2  For example, in the following figure, the bishop can move to any of the red squares in one move:  

Incorrect submission (verdict: Wrong Answer):
import math

def main():
    H, W = [int(_) for _ in input().split()]
    if H % 2 == 0 or W % 2 == 0:
        m = (H * W) /2
    else:
        m = (H * W) /2
        m = int(math.ceil(m))
    print(m)
main()

Fixed, accepted submission:
import sys
import math

def main():
    H, W = [int(_) for _ in input().split()]
    if H == 1 or W == 1:
        m = 1
        print(int(m))
        sys.exit()
        
    elif H % 2 == 1 and W % 2 == 1:
        m = (H * W) // 2 + 1
    else:
        m = (H * W) // 2
    print(int(m))
main()
Problem:
When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.  You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.  Find B_i for each i = 1, 2, ..., N.

Incorrect submission (verdict: Wrong Answer):
import numpy as np
N= int(input())
a = list(map(int, input().split(' ')))
a = np.array(a)
ret = []
for i in range(N):
    ind = np.ones(N, dtype=bool)
    ind[i] = False
    tmp = a[ind]
    ret.append(int(np.median(tmp)))
print(ret)

Fixed, accepted submission:
import numpy as np
N= int(input())
a = list(map(int, input().split(' ')))
sort_a = sorted(a)
small = sort_a[N//2-1]
big = sort_a[N//2]
for aa in a:
    if aa < big:
        print(big)
    else:
        print(small)
Problem:
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year.   For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year.  In this country, a date is called _Takahashi_ when the month and the day are equal as numbers. For example, 5-5 is Takahashi.   How many days from 2018-1-1 through 2018-a-b are Takahashi?

Incorrect submission (verdict: Wrong Answer):
x, y = map(int, input().split())

cnt = 0
for i in range(1, 13):
    if x == i and y == i:
        cnt += 1
print(cnt)

Fixed, accepted submission:
x, y = map(int, input().split())

if x <= y:
  print(x)
else:
  print(x-1)
Problem:
An integer X is called a Harshad number if X is divisible by f(X), where f(X) is the sum of the digits in X when written in base 10.  Given an integer N, determine whether it is a Harshad number.

Incorrect submission (verdict: Wrong Answer):
N = input()

f = [int(i) for i in N]
if N%f == 0:
    print("Yes")
else:
    print('No')


Fixed, accepted submission:
N = input()

num = [int(i) for i in N]
f = sum(num)
if int(N)%f == 0:
    print("Yes")
else:
    print('No')
Problem:
There are N children in AtCoder Kindergarten. Mr. Evi will arrange the children in a line, then give 1 candy to the first child in the line, 2 candies to the second child, ..., N candies to the N-th child. How many candies will be necessary in total?

Incorrect submission (verdict: Wrong Answer):
N = int(input())

print((1 + N) * N / 2)

Fixed, accepted submission:
N = int(input())

print(int((1 + N) * N / 2))
Problem:
Takahashi loves numbers divisible by 2.  You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique.  Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder.  For example,    * 6 can be divided by 2 once: 6 -> 3.   * 8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1.   * 3 can be divided by 2 zero times.

Incorrect submission (verdict: Wrong Answer):
n = int(input())

x = 1
cnt = 0
list = []

for i in range(n):
    i = x
    while i % 2 == 0:
        i /= 2
        cnt += 1
    x += 1
    list.append(cnt)
    cnt = 0

print(max(list))


Fixed, accepted submission:
n = int(input())

x = 1
cnt = 0
list = []

for i in range(n):
    i = x
    while i % 2 == 0:
        i =  i//2
        cnt += 1
    x += 1
    list.append(cnt)
    cnt = 0

print(2 ** max(list))
Problem:
"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.  Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.

Incorrect submission (verdict: Wrong Answer):
a,b,c,x,y=map(int,input().split())
if a+b>=c+c:
  print(a*x+b*y)
else:
  ans=10000000000
  for i in range(0,(max(x,y)+1)//2):
    k=c*2*i+a*(x-i)+b*(y-i)
    ans=min(ans,k)
  print(ans)

Fixed, accepted submission:
a,b,c,x,y=map(int,input().split())
ans=10000000000
for i in range(0,(max(x,y)+1)):
  k=c*2*i+a*max(0,(x-i))+max(0,b*(y-i))
  ans=min(ans,k)
print(ans)
Problem:
There are N rectangular plate materials made of special metal called AtCoder Alloy. The dimensions of the i-th material are A_i \times B_i (A_i vertically and B_i horizontally).  Takahashi wants a rectangular plate made of AtCoder Alloy whose dimensions are exactly H \times W. He is trying to obtain such a plate by choosing one of the N materials and cutting it if necessary. When cutting a material, the cuts must be parallel to one of the sides of the material. Also, the materials have fixed directions and cannot be rotated. For example, a 5 \times 3 material cannot be used as a 3 \times 5 plate.  Out of the N materials, how many can produce an H \times W plate if properly cut?

Incorrect submission (verdict: Wrong Answer):
import sys
lines = [list(map(int, line.strip().split(' '))) for line in sys.stdin]
print(sum([1 for h,w in lines[1:] if h <= lines[0][1] and w <= lines[0][2]]))

Fixed, accepted submission:
import sys
lines = [list(map(int, line.strip().split(' '))) for line in sys.stdin]
print(sum([1 for h,w in lines[1:] if lines[0][1] <= h and lines[0][2] <= w]))