TnT/CodeNet4Repair huggingface dataset:
Problem:
Iroha loves _Haiku_. Haiku is a short form of Japanese poetry. A Haiku consists of three phrases with 5, 7 and 5 syllables, in this order.  To create a Haiku, Iroha has come up with three different phrases. These phrases have A, B and C syllables, respectively. Determine whether she can construct a Haiku by using each of the phrases once, in some order.

Incorrect submission (verdict: Wrong Answer):
list = list(input().split())
list.sort()

if list[0] == 5 and list[1] == 5 and list[7] == 7:
    print('Yes')
else:
    print('No')


Fixed, accepted submission:

list = list(map(int, input().split()))

list.sort()

if list[0] == 5 and list[1] == 5 and list[2] == 7:
    print('YES')
else:
    print('NO')
Problem:
Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.  Write a program which computes the amount of the debt in n weeks.

Incorrect submission (verdict: Wrong Answer):
import math
n = int(input())
print(n)
money = int(100)
for i in range(n):
    money *= 1.05
    money = math.ceil(money)
print(int(money) * 1000)
    


Fixed, accepted submission:
import math
money = int(100)
for i in range(int(input())):
    money *= 1.05
    money = math.ceil(money)
print(int(money) * 1000)
Problem:
You are given an H × W grid.   The squares in the grid are described by H strings, S_1,...,S_H.   The j-th character in the string S_i corresponds to the square at the i-th row from the top and j-th column from the left (1 \leq i \leq H,1 \leq j \leq W).   `.` stands for an empty square, and `#` stands for a square containing a bomb.  Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square.   (Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.)   He decides to replace each `.` in our H strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square.  Print the strings after the process.

Incorrect submission (verdict: Wrong Answer):
h, w = map(int, input().split())
s = ["a"*(w+2)] + ["a" + input() + "a" for i in range(h)] + ["a"*(w+2)]

ans = []
for i in range(1, h+1):
  for j in range(1, w+1):
    if s[i][j] == "#":
      ans.append("#")
    else:
      c = [s[i-1][j-1], s[i-1][j], s[i-1][j+1], s[i][j-1], s[i][j+1], s[i+1][j-1], s[i+1][j], s[i+1][j+1]]
      ans.append(c.count("#"))
      
print(ans)
for i in range(h):
  print("".join(list(map(str, ans[i*w:(i+1)*w]))))

Fixed, accepted submission:
h, w = map(int, input().split())
s = [["a"]*(w+2)] + [["a"] + list(input()) + ["a"] for i in range(h)] + [["a"]*(w+2)]

for i in range(1, h+1):
  for j in range(1, w+1):
    if s[i][j] != "#":
      c = [s[i-1][j-1], s[i-1][j], s[i-1][j+1], s[i][j-1], s[i][j+1], s[i+1][j-1], s[i+1][j], s[i+1][j+1]]
      s[i][j] = str(c.count("#"))
      
for i in range(1,h+1):
  print("".join(s[i][1:-1]))
Problem:
太郎君はよくJOI雑貨店で買い物をする． JOI雑貨店には硬貨は500円，100円，50円，10円，5円，1円が十分な数だけあり，いつも最も枚数が少なくなるようなおつりの支払い方をする．太郎君がJOI雑貨店で買い物をしてレジで1000円札を1枚出した時，もらうおつりに含まれる硬貨の枚数を求めるプログラムを作成せよ．  例えば入力例1の場合は下の図に示すように，4を出力しなければならない．  

Incorrect submission (verdict: Wrong Answer):
#!/usr/bin/env python
#coding:utf-8

coin = [500,100,50,10,5,1]
oturi = 1000 - int(input())
ret = 0
for c in coin:
    ret += oturi // c
    oturi %= c
print(ret)

Fixed, accepted submission:
#!/usr/bin/env python
#coding:utf-8

while True:
    coin = [500,100,50,10,5,1]
    oturi = 1000 - int(input())
    if oturi == 1000:
        break
    ret = 0
    for c in coin:
        ret += oturi // c
        oturi %= c
    print(ret)
Problem:
For a string S consisting of the uppercase English letters `P` and `D`, let the _doctoral and postdoctoral quotient_ of S be the total number of occurrences of `D` and `PD` in S as contiguous substrings. For example, if S = `PPDDP`, it contains two occurrences of `D` and one occurrence of `PD` as contiguous substrings, so the doctoral and postdoctoral quotient of S is 3.  We have a string T consisting of `P`, `D`, and `?`.  Among the strings that can be obtained by replacing each `?` in T with `P` or `D`, find one with the maximum possible doctoral and postdoctoral quotient.

Incorrect submission (verdict: Wrong Answer):
s=input()
for i in range(len(s)):
    if s[i]=="?" and s[i-1]=='D':
        s=s.replace("?","P")
    elif s[i]=="?" and s[i-1]=='P':
        s=s.replace("?","D")
print(s)

Fixed, accepted submission:
s=input()
s2=list(s)
s1=""
if s2[-1]=="?":
    s2[-1]="D"
if s2[0]=="?" and s2[1]=="D":
    s2[0]="P"
elif s2[0]=="?" and (s2[1]=="P" or s2[1]=="?"):
    s2[0]="D"
for i in range(1,len(s2)-1):
    if s2[i]=='?':
        if s2[i-1]=="D" and (s2[i+1]=="D" or s2[i+1]=="?"):
           s2[i]="P"
        else:
            s2[i]="D"
for i in s2:
    s1+=i
print(s1)
Problem:
You are given an undirected connected graph with N vertices and M edges that does not contain self-loops and double edges.   The i-th edge (1 \leq i \leq M) connects Vertex a_i and Vertex b_i.  An edge whose removal disconnects the graph is called a _bridge_.   Find the number of the edges that are bridges among the M edges.

Incorrect submission (verdict: Wrong Answer):
import numpy as np

N, M = (list(map(int, input().split())))
a = np.array([0]*M)
b = np.array([0]*M)
for i in range(M):
  a[i], b[i] = (input().split())
ans = 0
C = set()
D = set()
for i in range(M):
  count = 0
  boo = True
  while(boo):
    for j in range(M):
      if i != j:
        if(count == 0):
          C.add(a[j])
          C.add(b[j])
          count += 1
        if C <= {a[j]} or C <= {b[j]}:
          C.add(a[j])
          C.add(b[j])
    if(C & D == C):
      print("aaa")
      boo = False
      break
    else:
      D = C
  if(len(C) == N):
    ans += 1
print(ans)

Fixed, accepted submission:
import numpy as np
 
N, M = (list(map(int, input().split())))
a = np.array([0]*M)
b = np.array([0]*M)
for i in range(M):
  a[i], b[i] = (input().split())
ans = M
for i in range(M):
  C = set()
  D = set()
  count = 0
  while(True):
    for j in range(M):
      if not i == j:
        if(count == 0):
          C.add(a[j]) 
          C.add(b[j])
          count += 1  
        if a[j] in C or b[j] in C:
          C.add(a[j])
          C.add(b[j])
    if(C == D):
      break
    else:
      D = C.union(D)
  if(len(C) == N):
    ans -= 1
print(ans)
Problem:
N persons are standing in a row. The height of the i-th person from the front is A_i.  We want to have each person stand on a stool of some heights - at least zero - so that the following condition is satisfied for every person:  Condition: Nobody in front of the person is taller than the person. Here, the height of a person includes the stool.  Find the minimum total height of the stools needed to meet this goal.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
members = list(map(int, input().strip().split()))
stands = []

for i, member in enumerate(members):
  if i>0:
    if members[i] > members[i-1]:
      stands.append(0)
    else:
      stands.append(members[i-1] - members[i])
      
print(sum(stands))

Fixed, accepted submission:
N = int(input())
members = list(map(int, input().strip().split()))
stands = []
stands.append(0)

for i, member in enumerate(members):
  if i>0:
    if members[i] > members[i-1] + stands[i-1]:
      stands.append(0)
    else:
      stands.append(members[i-1] + stands[i-1] - members[i])
      
print(sum(stands))
Problem:
We have an H-by-W matrix. Let a_{ij} be the element at the i-th row from the top and j-th column from the left. In this matrix, each a_{ij} is a lowercase English letter.  Snuke is creating another H-by-W matrix, A', by freely rearranging the elements in A. Here, he wants to satisfy the following condition:    * Every row and column in A' can be read as a palindrome.  Determine whether he can create a matrix satisfying the condition.

Incorrect submission (verdict: Wrong Answer):
h,w = map(int,input().split())
a = [input() for _ in range(h)]
alpha = [0]*26
for i in range(h):
    for j in range(w):
        alpha[ord(a[i][j])-ord("a")] += 1

ans = "Yes"
odd = 0
cnt = 0

for i in range(26):
    if alpha[i]%2 != 0:
        odd += 1
        alpha[i] -= 1
    if alpha[i]%4 != 0: cnt += 1
    
if odd > 1: ans = "No"
elif h%2 == 1 and w%2 == 1:
    if cnt > h//2+w//2: ans = "No"
elif h%2 == 1:
    if cnt > h//2: ans = "No"
elif w%2 == 1:
    if cnt > w//2: ans = "No"
else:
    if cnt > 0: ans = "No"
print(ans)

Fixed, accepted submission:
h,w = map(int,input().split())
a = [input() for _ in range(h)]
alpha = [0]*26
for i in range(h):
    for j in range(w):
        alpha[ord(a[i][j])-ord("a")] += 1

ans = "Yes"
odd = 0
cnt = 0

for i in range(26):
    if alpha[i]%2 != 0:
        odd += 1
        alpha[i] -= 1
    if alpha[i]%4 != 0: cnt += 1

if odd > 1: ans = "No"
elif h%2 == 1 and w%2 == 1:
    if cnt > h//2+w//2: ans = "No"
elif h%2 == 1:
    if cnt > w//2: ans = "No"
elif w%2 == 1:
    if cnt > h/2: ans = "No"
else:
    if cnt > 0: ans = "No"
print(ans)
Problem:
Print all the integers that satisfies the following in ascending order:    * Among the integers between A and B (inclusive), it is either within the K smallest integers or within the K largest integers.

Incorrect submission (verdict: Wrong Answer):
A,B,K=map(int,input().split())
L=list(i for i in range(A,B+1))
print(L)
for i in range(B-A+1):
    if L[i] in L[:K] or L[i] in L[-K:]:
        print(L[i])

Fixed, accepted submission:
a,b,k=map(int,input().split())
r1=[i for i in range(a,min(b+1,a+k))]
r2=[i for i in range(max(a,b-k+1),b+1)]
r1.extend(r2)
result=set(r1)
for i in sorted(result):
    print(i)
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())
cnt=1
a=2
while a<=N:
    a*=2
    if a<=N:
        cnt+=1
if N==1:
    print(0)
else:
    print(cnt)


Fixed, accepted submission:
N=int(input())
cnt=1
a=2
while a<=N:
    a*=2
    if a<=N:
        cnt+=1
if N==1:
    print(1)
else:
    print(2**cnt)
Problem:
We will buy a product for N yen (the currency of Japan) at a shop.  If we use only 1000-yen bills to pay the price, how much change will we receive?  Assume we use the minimum number of bills required.

Incorrect submission (verdict: Wrong Answer):
print(int(input()) % 1000)

Fixed, accepted submission:
print(-int(input()) % 1000)
Problem:
Given a lowercase English letter c, determine whether it is a vowel. Here, there are five vowels in the English alphabet: `a`, `e`, `i`, `o` and `u`.

Incorrect submission (verdict: Wrong Answer):
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    C = input()
    if C in ['a', 'i', 'u', 'e', 'o']:
        print('vouel')
    else:
        print('consonant')


if __name__ == '__main__':
    main()


Fixed, accepted submission:
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    C = input()
    if C in ['a', 'i', 'u', 'e', 'o']:
        print('vowel')
    else:
        print('consonant')


if __name__ == '__main__':
    main()
Problem:
Takahashi is competing in a sumo tournament. The tournament lasts for 15 days, during which he performs in one match per day. If he wins 8 or more matches, he can also participate in the next tournament.  The matches for the first k days have finished. You are given the results of Takahashi's matches as a string S consisting of `o` and `x`. If the i-th character in S is `o`, it means that Takahashi won the match on the i-th day; if that character is `x`, it means that Takahashi lost the match on the i-th day.  Print `YES` if there is a possibility that Takahashi can participate in the next tournament, and print `NO` if there is no such possibility.

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

xCount = 0
for s in S:
    if s == "x":
        xCount += 1

if xCount >= 8:
    print("No")
else:
    print("Yes")

Fixed, accepted submission:
S = input()

xCount = 0
for s in S:
    if s == "x":
        xCount += 1

if xCount >= 8:
    print("NO")
else:
    print("YES")
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())
d = a*x + b*y
e = 0
f = 0
g = 0
h = 0
if x > y and y % 2 == 0:
    e = c*2*y + a*(x-y)
elif x > y and y % 2 != 0:
    f = c*2*(y-1) + b + a*(x-y+1)
elif x < y and x % 2 == 0:
    g = c*2*x + b*(y-x)
elif x < y and x % 2 != 0:
    h = c*2*(x-1) + a + b*(y-x+1)
l = [d,e,f,g,h]
print(sorted(l)[3])
print(l)

Fixed, accepted submission:
a,b,c,x,y = map(int,input().split())
d = 2*c*min(x,y) + a*max(0,x-y) + b*max(0,y-x)
e = 2*c*max(x,y)
f = a*x + b*y
print(min(d,e,f))
Problem:
You are given a trapezoid. The lengths of its upper base, lower base, and height are a, b, and h, respectively.    An example of a trapezoid  Find the area of this trapezoid.

Incorrect submission (verdict: Wrong Answer):
a, b, h = map(int, [input() for i in range(3)])
print((a + b) * h / 2)


Fixed, accepted submission:
a, b, h = map(int, [input() for i in range(3)])
print(int((a + b) * h / 2))
Problem:
Iroha has a sequence of N strings S_1, S_2, ..., S_N. The length of each string is L.  She will concatenate all of the strings in some order, to produce a long string.  Among all strings that she can produce in this way, find the lexicographically smallest one.  Here, a string s=s_1s_2s_3...s_n is _lexicographically smaller_ than another string t=t_1t_2t_3...t_m if and only if one of the following holds:    * There exists an index i(1≦i≦min(n,m)), such that s_j = t_j for all indices j(1≦j<i), and s_i<t_i.   * s_i = t_i for all integers i(1≦i≦min(n,m)), and n<m.

Incorrect submission (verdict: Wrong Answer):
n, l = map(int, input().split())
ans = "z" * 100
for _ in range(n):
  ans = min(ans, input())
print(ans)

Fixed, accepted submission:
n, l = map(int, input().split())
A = [input() for _ in range(n)]
A.sort()
print("".join(A))
Problem:
There are three houses on a number line: House 1, 2 and 3, with coordinates A, B and C, respectively. Print `Yes` if we pass the coordinate of House 3 on the straight way from House 1 to House 2 without making a detour, and print `No` otherwise.

Incorrect submission (verdict: Wrong Answer):
a, b, c = input().split(" ")

if a > b and b > c:
  print("Yes")
elif c > b and b > a:
  print("Yes")
else:
  print("No")

Fixed, accepted submission:
a, b, c = [int(x) for x in input().split(" ")]

if a > c and c > b:
  print("Yes")
elif b > c and c > a:
  print("Yes")
else:
  print("No")
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: Wrong Answer):
while True:
    a = input()
    if '?' in a:
        break
    print("{0}".format(eval(a)))

Fixed, accepted submission:
while True:
    a = input()
    if '?' in a:
        break
    print("{0}".format(eval(a.replace('/', '//'))))
Problem:
We have a 3×3 square grid, where each square contains a lowercase English letters. The letter in the square at the i-th row from the top and j-th column from the left is c_{ij}.  Print the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.

Incorrect submission (verdict: Wrong Answer):
A,B,C = [input() for i in range(3)]
a = [A[:1], A[1:2], A[2:]]
b = [B[:1], B[1:2], B[2:]]
c = [C[:1], C[1:2], C[2:]]
print(a.pop(0), b.pop(1), c.pop(2))

Fixed, accepted submission:
A,B,C = [input() for i in range(3)]
a = [A[:1], A[1:2], A[2:]]
b = [B[:1], B[1:2], B[2:]]
c = [C[:1], C[1:2], C[2:]]
print(a.pop(0) + b.pop(1) + c.pop(2))
Problem:
We have a tree with N vertices numbered 1 to N. The i-th edge in the tree connects Vertex u_i and Vertex v_i, and its length is w_i. Your objective is to paint each vertex in the tree white or black (it is fine to paint all vertices the same color) so that the following condition is satisfied:    * For any two vertices painted in the same color, the distance between them is an even number.  Find a coloring of the vertices that satisfies the condition and print it. It can be proved that at least one such coloring exists under the constraints of this problem.

Incorrect submission (verdict: Wrong Answer):
N = int(input())
for i in range(N):
  print(0)

Fixed, accepted submission:
from collections import deque
N = int(input())
uvw = [[]for i in range(N)]
for i in range(N-1):
    u,v,w = list(map(int,input().split()))
    uvw[u-1].append([v-1,w%2])
    uvw[v-1].append([u-1,w%2])    
color = [-1 for i in range(N)]
color[0] = 0
que = deque()
que.append(0)
while que:
    q = que.popleft()
    colorq = color[q]
    for i in uvw[q]:
        if color[i[0]] == -1:
            que.append(i[0])
            if i[1] == 0:
                color[i[0]] = colorq
            else:
                color[i[0]] = abs(colorq-1)
for i in color:
    print(i)
Problem:
You are given a string s consisting of lowercase English letters. Extract all the characters in the odd-indexed positions and print the string obtained by concatenating them. Here, the leftmost character is assigned the index 1.

Incorrect submission (verdict: Wrong Answer):
S = input()
s = []
for i in range(len(S)):
    if (i + 1) % 2 == 1:
        s.append(S[i])
        print(i)

print(('').join(s))

Fixed, accepted submission:
S = input()
s = []
for i in range(len(S)):
    if (i + 1) % 2 == 1:
        s.append(S[i])

print(('').join(s))
Problem:
In Takahashi Kingdom, there is an archipelago of N islands, called Takahashi Islands. For convenience, we will call them Island 1, Island 2, ..., Island N.  There are M kinds of regular boat services between these islands. Each service connects two islands. The i-th service connects Island a_i and Island b_i.  Cat Snuke is on Island 1 now, and wants to go to Island N. However, it turned out that there is no boat service from Island 1 to Island N, so he wants to know whether it is possible to go to Island N by using two boat services.  Help him.

Incorrect submission (verdict: Wrong Answer):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline


def main():
    N, M = map(int, readline().split())
    m = map(int, read().split())
    AB = list(zip(m, m))

    p1 = []
    p2 = []
    for a, b in AB:
        if a == 1:
            p1.append(b)
        if b == N:
            p2.append(a)

    if len(list(set(p1) & set(p2))) >= 1:
        print('POSSIVLE')
    else:
        print('IMPOSSIVLE')


main()


Fixed, accepted submission:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline


def main():
    N, M = map(int, readline().split())
    m = map(int, read().split())
    AB = list(zip(m, m))

    p1 = []
    p2 = []
    for a, b in AB:
        if a == 1:
            p1.append(b)
        if b == N:
            p2.append(a)

    if len(list(set(p1) & set(p2))) >= 1:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')


main()
Problem:
We have a 3 \times 3 grid. A number c_{i, j} is written in the square (i, j), where (i, j) denotes the square at the i-th row from the top and the j-th column from the left.   According to Takahashi, there are six integers a_1, a_2, a_3, b_1, b_2, b_3 whose values are fixed, and the number written in the square (i, j) is equal to a_i + b_j.   Determine if he is correct.

Incorrect submission (verdict: Wrong Answer):
c=[[0 for i in range(3)] for j in range(3)]
a=[0]*3
b=[0]*3

for i in range(3):
  c[i]=list(map(int,input().split()))

for i in range(-500,500):
  a[0]=i
  b[0]=c[0][0]-a[0]
  b[1]=c[0][1]-a[0]
  b[2]=c[0][2]-a[0]
  a[1]=c[1][0]-b[0]
  a[2]=c[2][0]-b[0]
  
  if c[1][1]==a[1]+b[1] and c[1][2]==a[1]+b[2] and c[2][1]==a[2]+b[1] and (c[2][2]==a[2]+b[2]):
    print("Yes")
    print(a,b)
    break
    
  if c[1][1]!=a[1]+b[1] or c[1][2]!=a[1]+b[2] or c[2][1]!=a[2]+b[1] or (c[2][2]!=a[2]+b[2]):
    if i==499:
      print("No")

Fixed, accepted submission:
c=[[0 for i in range(3)] for j in range(3)]
a=[0]*3
b=[0]*3

for i in range(3):
  c[i]=list(map(int,input().split()))

for i in range(-500,500):
  a[0]=i
  b[0]=c[0][0]-a[0]
  b[1]=c[0][1]-a[0]
  b[2]=c[0][2]-a[0]
  a[1]=c[1][0]-b[0]
  a[2]=c[2][0]-b[0]
  
  if c[1][1]==a[1]+b[1] and c[1][2]==a[1]+b[2] and c[2][1]==a[2]+b[1] and (c[2][2]==a[2]+b[2]):
    print("Yes")
   
    break
    
  if c[1][1]!=a[1]+b[1] or c[1][2]!=a[1]+b[2] or c[2][1]!=a[2]+b[1] or (c[2][2]!=a[2]+b[2]):
    if i==499:
      print("No")
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())

if N * A >= B:
    print(B)

else:
    print(A)


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

print(min(A*N, B))
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):
H,W=map(int,input().split())
if H%2==1 and W%2==1:
    print((H*W+1)/2)
else:
    print(H*W/2)

Fixed, accepted submission:
H,W=map(int,input().split())
if H==1 or W==1:
    print(1)
else:
    if H%2==1 and W%2==1:
        print((H*W)//2+1)
    else:
        print(H*W//2)
Problem:
There are N stones arranged in a row. Every stone is painted white or black. A string S represents the color of the stones. The i-th stone from the left is white if the i-th character of S is `.`, and the stone is black if the character is `#`.  Takahashi wants to change the colors of some stones to black or white so that there will be no white stone immediately to the right of a black stone. Find the minimum number of stones that needs to be recolored.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
s=list(input())
ans=10**10
for i in range(n):
    cost_w=s[:i+1].count("#")
    cost_b=s[i+1:].count(".")
    print(s[:i+1],s[i:])
    ans=min(ans,cost_w+cost_b)
print(ans)

Fixed, accepted submission:
n=int(input())
s=list(input())
INF=10**10
cost_w=0
cost_b=s.count(".")
ans=[INF for i in range(n+1)]
ans[0]=cost_b
for i in range(n):
    if s[i]=="#":
        cost_w+=1
    else:
        cost_b-=1
    ans[i+1]=cost_w+cost_b
print(min(ans))