TnT/CodeNet4Repair huggingface dataset:
Problem:
あなたの友達は最近 UT-Rummy というカードゲームを思いついた．  このゲームで使うカードには赤・緑・青のいずれかの色と1から9までのいずれかの番号が つけられている． このゲームのプレイヤーはそれぞれ9枚の手札を持ち， 自分のターンに手札から1枚選んで捨てて， 代わりに山札から1枚引いてくるということを繰り返す． このように順番にターンを進めていき， 最初に手持ちのカードに3枚ずつ3つの「セット」を作ったプレイヤーが勝ちとなる． セットとは，同じ色の3枚のカードからなる組で，すべて同じ数を持っているか 連番をなしているもののことを言う． 連番に関しては，番号の巡回は認められない． 例えば，7, 8, 9は連番であるが 9, 1, 2は連番ではない．  あなたの友達はこのゲームをコンピュータゲームとして売り出すという計画を立てて， その一環としてあなたに勝利条件の判定部分を作成して欲しいと頼んできた． あなたの仕事は，手札が勝利条件を満たしているかどうかを判定する プログラムを書くことである．

Incorrect submission (verdict: Wrong Answer):
for _ in range(int(input())):
    n, c = map(int, input().split()), input().split()
    c = list(zip(c, n))
    c.sort(key = lambda x:x[1])
    c.sort(key = lambda x:x[0])
    print(c)
    while c != []:
        if c[-1] == c[-2] == c[-3]:
            c = c[:-3]
        elif (c[-1][0], c[-1][1] -1) in c and (c[-1][0], c[-1][1] -2) in c :
            c.remove((c[-1][0], c[-1][1] -1))
            c.remove((c[-1][0], c[-1][1] -2))
            c.pop()
        else:print(0);break
    else:print(1)


Fixed, accepted submission:
for _ in range(int(input())):
    n, c = map(int, input().split()), input().split()
    c = list(zip(c, n))
    c.sort(key = lambda x:x[1])
    c.sort(key = lambda x:x[0])
    while c != []:
        if c[-1] == c[-2] == c[-3]:
            c = c[:-3]
        elif (c[-1][0], c[-1][1] -1) in c and (c[-1][0], c[-1][1] -2) in c :
            c.remove((c[-1][0], c[-1][1] -1))
            c.remove((c[-1][0], c[-1][1] -2))
            c.pop()
        else:print(0);break
    else:print(1)
Problem:
AtCoDeer has three cards, one red, one green and one blue.   An integer between 1 and 9 (inclusive) is written on each card: r on the red card, g on the green card and b on the blue card.   We will arrange the cards in the order red, green and blue from left to right, and read them as a three-digit integer.   Is this integer a multiple of 4?

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

r, g, b = S_list[0], S_list[1], S_list[2]
if (100 * r + 10 * g + b) % 4 == 0 :
    result = "Yes"
else:
    result = "No"
print(result)


Fixed, accepted submission:
a, b, c = map(str, input().split())
num = int(a + b + c)
 
if num % 4 == 0:
    print("YES")
else:
    print("NO")
Problem:
On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i).  A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point.  At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs.

Incorrect submission (verdict: Wrong Answer):
from operator import itemgetter
# N = 5
# R = [[0, 0],
#      [7, 3],
#      [2, 2],
#      [4, 8],
#      [1, 6]]

# B = [[8, 5], 
#      [6, 9], 
#      [5, 4], 
#      [9, 1],
#      [3, 7]]
N = int(input())
R = []
for i in range(N):
    a, b = map(int, input().split())
    R.append([a, b])
B = []
for i in range(N):
    c, d = map(int, input().split())
    B.append([c, d])
R.sort(key=itemgetter(0))
B.sort(key=itemgetter(0))
print(R)
print(B)
res = 0
for r in R:
    rx, ry = r[0], r[1]
    flag1 = False
    flag2 = False
    
    for i, b in enumerate(B):
        if b[0] > rx:
            flag1 = True
            break
    
    if flag1:
        B_tmp = B.copy()[i:]
        B_tmp.sort(key=itemgetter(1))
        for ii, b in enumerate(B_tmp):
            if b[1] > ry:
                flag2 = True
                break
        if flag2:
            res += 1
            B.remove(b)
print(res)

Fixed, accepted submission:
from operator import itemgetter
# N = 5
# R = [[0, 0],
#      [7, 3],
#      [2, 2],
#      [4, 8],
#      [1, 6]]

# B = [[8, 5], 
#      [6, 9], 
#      [5, 4], 
#      [9, 1],
#      [3, 7]]
N = int(input())
R = []
for i in range(N):
    a, b = map(int, input().split())
    R.append([a, b])
B = []
for i in range(N):
    c, d = map(int, input().split())
    B.append([c, d])
R.sort(key=itemgetter(0))
B.sort(key=itemgetter(0))
# print(R)

res = 0
for r in R[::-1]:
    rx, ry = r[0], r[1]
    flag1 = False
    flag2 = False
    
    for i, b in enumerate(B):
        if b[0] > rx:
            flag1 = True
            break
    
    if flag1:
        B_tmp = B.copy()[i:]
        B_tmp.sort(key=itemgetter(1))
        for ii, b in enumerate(B_tmp):
            if b[1] > ry:
                flag2 = True
                break
        if flag2:
            res += 1
            B.remove(b)
print(res)
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):
S1=str(input())
S2=str(input())
S3=str(input())
print(S1[0]+S1[1]+S2[2])

Fixed, accepted submission:
S1=str(input())
S2=str(input())
S3=str(input())
print(S1[0]+S2[1]+S3[2])
Problem:
Takahashi has come to a party as a special guest. There are N ordinary guests at the party. The i-th ordinary guest has a _power_ of A_i.  Takahashi has decided to perform M _handshakes_ to increase the _happiness_ of the party (let the current happiness be 0). A handshake will be performed as follows:    * Takahashi chooses one (ordinary) guest x for his left hand and another guest y for his right hand (x and y can be the same).   * Then, he shakes the left hand of Guest x and the right hand of Guest y simultaneously to increase the happiness by A_x+A_y.  However, Takahashi should not perform the same handshake more than once. Formally, the following condition must hold:    * Assume that, in the k-th handshake, Takahashi shakes the left hand of Guest x_k and the right hand of Guest y_k. Then, there is no pair p, q (1 \leq p < q \leq M) such that (x_p,y_p)=(x_q,y_q).  What is the maximum possible happiness after M handshakes?

Incorrect submission (verdict: Wrong Answer):
n,m=map(int,input().split())
arr=list(map(int,input().split()))
arr=sorted(arr,reverse=True)
acum=[arr[0]]
for i in range(1,n):
  acum.append(acum[-1]+arr[i])
print(acum)
l=0
r=2*10**5+1
while r-l!=1:
  mid=(l+r)//2
  tmp=0
  cnt=0
  pos=n-1
  for i in range(n):
    while pos!=-1:
      if arr[i]+arr[pos]>=mid:
        cnt+=pos+1
        tmp+=arr[i]*(pos+1)+acum[pos]
        break
      else:
        pos-=1
        if pos==-1:
          break
  if cnt<=m:
    r=mid
  else:
    l=mid
tmp+=(m-cnt)*l
print(tmp)

Fixed, accepted submission:
n,m=map(int,input().split())
arr=list(map(int,input().split()))
arr=sorted(arr,reverse=True)
acum=[arr[0]]
for i in range(1,n):
  acum.append(acum[-1]+arr[i])
l=0
r=2*10**5+1
while r-l!=1:
  mid=(l+r)//2
  tmp=0
  cnt=0
  pos=n-1
  for i in range(n):
    while pos!=-1:
      if arr[i]+arr[pos]>=mid:
        cnt+=pos+1
        tmp+=arr[i]*(pos+1)+acum[pos]
        break
      else:
        pos-=1
        if pos==-1:
          break
  if cnt<=m:
    r=mid
  else:
    l=mid
tmp+=(m-cnt)*l
print(tmp)
Problem:
It is September 9 in Japan now.  You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?

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

if N[0] == 9 or N[1] == 9:
    print("Yes")
else:
    print("No")


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

if N[0] == "9" or N[1] == "9":
    print("Yes")
else:
    print("No")
Problem:
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:                 for i = 1 to A.length-1     key = A[i]     /* insert A[i] into the sorted sequence A[0,...,j-1] */     j = i - 1     while j >= 0 and A[j] > key         A[j+1] = A[j]         j--     A[j+1] = key   Note that, indices for array elements are based on 0-origin.  To illustrate the algorithms, your program should trace intermediate result for each step.

Incorrect submission (verdict: Wrong Answer):
N=int(input())
A=[0 for i in range(N)]
A=input().split()
for i in range(N):
    A[i]=(int)(A[i])
for i in range(N):
    v=A[i]
    j = i-1
    while j>=0 and A[j]>v:
        A[j+1]=A[j]
        j=j-1
        A[j+1]=v
    print(A)


Fixed, accepted submission:
N=int(input())
A=[0 for i in range(N)]
A=input().split()
for i in range(N):
    A[i]=(int)(A[i])
for i in range(N):
    v=A[i]
    j = i-1
    while j>=0 and A[j]>v:
        A[j+1]=A[j]
        j=j-1
        A[j+1]=v
    for k in range(N):
        if k<N-1:
            print(A[k],end=" ")
        if k==N-1:
            print(A[k])
Problem:
Given is an integer sequence of length N+1: A_0, A_1, A_2, \ldots, A_N. Is there a binary tree of depth N such that, for each d = 0, 1, \ldots, N, there are exactly A_d leaves at depth d? If such a tree exists, print the maximum possible number of vertices in such a tree; otherwise, print -1.

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

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

#print(a)

if a[0] != 0:
    print(-1)
    exit(0)

b=1
count=1

for i in range(n-1):
    if a[i+1] > 2*b:
        print(-1)
        exit(0)
    else:
        b= 2*b-a[i+1]
        count += 2*b


print(count)

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

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

if n == 0 and a[0]==1:
    print(1)
    exit(0)

if a[0] != 0:
    print(-1)
    exit(0)

b=1
count=1
asum =sum(a)
alim = asum

for i in range(n):
    if a[i+1] > 2*b:
        print(-1)
        exit(0)
    else:
        alim = alim - a[i+1]
        b= min(2*b-a[i+1], alim)

        count += b

print(count+ asum)
Problem:
You are given a grid with 2 rows and 3 columns of squares. The color of the square at the i-th row and j-th column is represented by the character C_{ij}.  Write a program that prints `YES` if this grid remains the same when rotated 180 degrees, and prints `NO` otherwise.

Incorrect submission (verdict: Wrong Answer):
a = input()
b = input()
if a[0]==b[2] and a[1]==b[1] and a[2]==b[0]:
	print('Yes')
else:
	print('No')

Fixed, accepted submission:
a = input()
b = input()
if a[0]==b[2] and a[1]==b[1] and a[2]==b[0]:
	print('YES')
else:
	print('NO')
Problem:
You are given two positive integers A and B. Compare the magnitudes of these numbers.

Incorrect submission (verdict: Wrong Answer):
a=input()
b=input()

if len(a)>len(b):
    print("GREATER")
elif len(a)<len(b):
    print("LESS")
else:
    print("EQUAL")
    

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

if a>b:
    print("GREATER")
elif a<b:
    print("LESS")
else:
    print("EQUAL")
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==0 or W%2==0:
  ans = int(H*W/2)
else:
  ans = (H*W//2)+1

Fixed, accepted submission:
H, W = map(int, input().split())

if H==1 or W==1:
  
  ans = 1

elif H%2==0 or W%2==0:
  ans = int(H*W/2)

else:
  ans = int((H*W+1)/2)

print(ans)
Problem:
There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0. During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right. That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i. The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible. Find the earliest possible time to reach coordinate X.

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

A = [0]
c = 0
while True:
    c += 1
    k = A[-1] + c
    if k > X:
        break
    A.append(k)

print(c)

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

A = [0]
c = 0
while True:
    c += 1
    k = A[-1] + c
    if k >= X:
        break
    A.append(k)

print(c)
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 = list(map(int, input().split()))

ans = set([])
for i in range(a, min(a+k, b+1)):
    ans.add(i)
for i in range(max(a, b-k), b):
    ans.add(i)
for a in ans:
    print(a)

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

ans = set([])
for i in range(a, min(a+k, b+1)):
    ans.add(i)
for i in range(max(a, b-k+1), b+1):
    ans.add(i)
for a in sorted(list(ans)):
    print(a)
Problem:
Snuke has a favorite restaurant.  The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer.  So far, Snuke has ordered N meals at the restaurant. Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen. Find x-y.

Incorrect submission (verdict: Wrong Answer):
import math

n = int(input())
print(math.factorial(n)%1000000007)


Fixed, accepted submission:
n = int(input())
print(n*800-n//15*200)
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):
N = int(input())
ot = N//1000
print(N-ot*1000)

Fixed, accepted submission:
N = int(input())
ot = N//1000
if N%1000 == 0:
    print(0)
else:
    print((ot+1)*1000 - N)
Problem:
There is a cave.  The cave has N rooms and M passages. The rooms are numbered 1 to N, and the passages are numbered 1 to M. Passage i connects Room A_i and Room B_i bidirectionally. One can travel between any two rooms by traversing passages. Room 1 is a special room with an entrance from the outside.  It is dark in the cave, so we have decided to place a signpost in each room except Room 1. The signpost in each room will point to one of the rooms directly connected to that room with a passage.  Since it is dangerous in the cave, our objective is to satisfy the condition below for each room except Room 1.    * If you start in that room and repeatedly move to the room indicated by the signpost in the room you are in, you will reach Room 1 after traversing the minimum number of passages possible.  Determine whether there is a way to place signposts satisfying our objective, and print one such way if it exists.

Incorrect submission (verdict: Wrong Answer):
import sys
input = sys.stdin.readline 
sys.setrecursionlimit(10 ** 6)
N,M = map(int,input().split())
path = [[] for i in range(N)]
inf = 10 ** 6
ans = [[None,inf] for i in range(N - 1)]

for _ in range(M):
  a,b = map(int,input().split())
  a = a - 1
  b = b - 1
  if a > b:
    a,b = b,a
  path[a].append(b)
  path[b].append(a)

print(path)

def dfs(cur,par,con):
  if con == N:
    return
  for chi in path[cur]:
    if chi == par:
      continue
    if con < ans[chi - 1][1]:
      ans[chi - 1][0] = cur
      ans[chi - 1][1] = con + 1
      dfs(chi,cur,con + 1)

dfs(0,-1,0)

if all([i[0] != None for i in ans]):
  print("Yes")
  for i in range(N - 1):
    print(ans[i][0] + 1)
else:
  print("No")

Fixed, accepted submission:
from collections import deque

import sys
input = sys.stdin.readline 

N,M = map(int,input().split())
path = [[] for i in range(N)]
ans = [None for i in range(N)]
visited = [0 for i in range(N)]

for _ in range(M):
  a,b = map(int,input().split())
  a = a - 1
  b = b - 1
  path[a].append(b)
  path[b].append(a)

def bfs(path, root,visited):
  visited[root] = 1
  queue = deque([root])
  while queue:
    cur = queue.popleft()
    for chi in path[cur]:
      if visited[chi] == 1:
        continue
      else:
        ans[chi] = cur + 1
        visited[chi] = 1
        queue.append(chi)

  if all([i == 1 for i in visited]):
    return "Yes"
  else:
    return "No"
  
flag = bfs(path,0,visited)

print(flag)

if flag == "Yes":
  for i in range(1,N):
    print(ans[i])
Problem:
You are given an integer N. Find the number of the positive divisors of N!, modulo 10^9+7.

Incorrect submission (verdict: Wrong Answer):
import functools

mod = 1e9 + 7
n = int(input())
fact = [1] * (n+1)

for i in range(2, n+1):
    for j in range(2, 32):
        if i == 0:
            break
        while True:
            if i % j == 0:
                i /= j
                fact[j] += 1
            else:
                break
    if i != 0:
        fact[int(i)] += 1

print(fact)
print(int(functools.reduce(lambda x, y: (x * y) % mod, fact[2:])))


Fixed, accepted submission:
import sys
import functools

mod = 1e9 + 7
n = int(input())
if n == 1:
    print(1)
    sys.exit()

fact = [1] * (n+1)

for i in range(2, n+1):
    for j in range(2, 32):
        if i == 0:
            break
        while True:
            if i % j == 0:
                i /= j
                fact[j] += 1
            else:
                break
    if i != 0:
        fact[int(i)] += 1

print(int(functools.reduce(lambda x, y: (x * y) % mod, fact[2:])))
Problem:
You are given a string S consisting of lowercase English letters. We will write down this string, starting a new line after every w letters. Print the string obtained by concatenating the letters at the beginnings of these lines from top to bottom.

Incorrect submission (verdict: Wrong Answer):
st = input()
skpe = int(input())
st_len = len(st)
count = st_len // 3  + 1
top_list = []

for i in range(count):
    top_list.append(st[3 * i:3 * i + 3])


for x in top_list:
    try:
        print(x[0], end="")
    except IndexError:
        pass


Fixed, accepted submission:
st = input()
skpe = int(input())
st_len = len(st)
count = (st_len // skpe) + 1
top_list = []
s = ""

for i in range(count):
    top_list.append(st[skpe * i:skpe * i + skpe])


for x in top_list:
    try:
        s += x[0]
    except IndexError:
        pass
print(s)
Problem:
Takahashi received _otoshidama_ (New Year's money gifts) from N of his relatives.  You are given N values x_1, x_2, ..., x_N and N strings u_1, u_2, ..., u_N as input. Each string u_i is either `JPY` or `BTC`, and x_i and u_i represent the content of the otoshidama from the i-th relative.  For example, if x_1 = `10000` and u_1 = `JPY`, the otoshidama from the first relative is 10000 Japanese yen; if x_2 = `0.10000000` and u_2 = `BTC`, the otoshidama from the second relative is 0.1 bitcoins.  If we convert the bitcoins into yen at the rate of 380000.0 JPY per 1.0 BTC, how much are the gifts worth in total?

Incorrect submission (verdict: Wrong Answer):
N = int(input())
xu = [[] for i in range(N)]
otoshidama = 0
for i in range(N):
    xu[i] = list(input().split())
print(xu)
for i in xu:
    if i[1] == 'JPY':
        otoshidama += int(i[0])
    else:
        otoshidama += float(i[0])*380000
print(otoshidama)

Fixed, accepted submission:
N = int(input())
xu = [[] for i in range(N)]
otoshidama = 0
for i in range(N):
    xu[i] = list(input().split())
for i in xu:
    if i[1] == 'JPY':
        otoshidama += int(i[0])
    else:
        otoshidama += float(i[0])*380000
print(otoshidama)
Problem:
E869120 found a chest which is likely to contain treasure.   However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters.   He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with `?`.  One more thing he found is a sheet of paper with the following facts written on it:    * Condition 1: The string S contains a string T as a contiguous substring.   * Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1.  Print the string S.   If such a string does not exist, print `UNRESTORABLE`.

Incorrect submission (verdict: Wrong Answer):
S_prime = input()
T = input()

def judge(A,B):
    for i in range(len(A)):
        if A[i] != B[i] and A[i] != "?" and B[i] != "?":
            return False
    return True

def dec(S_prime,T):
    S_cand = []
    for i in range(len(S_prime)-len(T)+1):
        if judge(S_prime[i:i+len(T)],T):
            S_cand.append( S_prime[:i] + T + S_prime[i+len(T):] )
            print(i,S_prime[:i], T, S_prime[i+len(T):])
    return S_cand

def S_change(S):
    S = list(S)
    for i in range(len(S)):
        if S[i] == "?":
            S[i] = "a"
    S = "".join(S)
    return S

if len(dec(S_prime,T)) == 0:
    print("UNRESTORABLE")
else:
    Ans = dec(S_prime,T)
    for i in range(len(Ans)):
        Ans[i] = S_change(Ans[i])
    Ans.sort()
    print(Ans[0])
    


Fixed, accepted submission:
S_prime = input()
T = input()

def judge(A,B):
    for i in range(len(A)):
        if A[i] != B[i] and A[i] != "?" and B[i] != "?":
            return False
    return True

def dec(S_prime,T):
    S_cand = []
    for i in range(len(S_prime)-len(T)+1):
        if judge(S_prime[i:i+len(T)],T):
            S_cand.append( S_prime[:i] + T + S_prime[i+len(T):] )
    return S_cand

def S_change(S):
    S = list(S)
    for i in range(len(S)):
        if S[i] == "?":
            S[i] = "a"
    S = "".join(S)
    return S

if len(dec(S_prime,T)) == 0:
    print("UNRESTORABLE")
else:
    Ans = dec(S_prime,T)
    for i in range(len(Ans)):
        Ans[i] = S_change(Ans[i])
    Ans.sort()
    print(Ans[0])
Problem:
Write a program which reads two integers x and y, and prints them in ascending order.

Incorrect submission (verdict: Wrong Answer):
# (c) midandfeed
q = []
while(True):
	a, b = [int(x) for x in input().split()]
	if ( (a==0) and (b==0) ):
		break
	q.append((b,a))
	
q.sort()

for x in q:
	print("{} {}".format(x[0], x[1]))

Fixed, accepted submission:
# (c) midandfeed
while(True):
	a, b = [int(x) for x in input().split()]
	if ( (a==0) and (b==0) ):
		break
	print( min(a,b), max(a,b) )
Problem:
In this problem, we use the 24-hour clock.  Takahashi gets up exactly at the time H_1 : M_1 and goes to bed exactly at the time H_2 : M_2. (See Sample Inputs below for clarity.) He has decided to study for K consecutive minutes while he is up. What is the length of the period in which he can start studying?

Incorrect submission (verdict: Wrong Answer):
h1, m1, h2, m2, k = map(int, input().split())
t1 = h1 * 60 + m1
t2 = h2 * 60 + m1


Fixed, accepted submission:
h1, m1, h2, m2, k = map(int, input().split())
t1 = h1 * 60 + m1
t2 = h2 * 60 + m2

print(t2-t1 - k)
Problem:
You have an integer variable x. Initially, x=0.  Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if S_i=`I`, and decremented the value of x by 1 if S_i=`D`.  Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).

Incorrect submission (verdict: Wrong Answer):
n = int(input())
a = list(input())
xlist = []
x = 0
for i in range(n):
  if a[i]=="D":
    x+=1
  elif a[i]=="I":
    x-=1
  xlist.append(x)
print(max(xlist))

Fixed, accepted submission:
n = int(input())
a = list(input())
xlist = [0]
x = 0
for i in range(n):
  if a[i]=="D":
    x-=1
  elif a[i]=="I":
    x+=1
  xlist.append(x)
print(max(xlist))