TnT/CodeNet4Repair huggingface dataset:
Problem:
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.  The problem has N test cases.  For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.  See the Output section for the output format.

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

countAC=0
countWA=0
countTLE=0
countRE=0

for i in range(n):
    s=input()
    if s=="AC":
        countAC += 1
    elif s=="WA":
        countWA += 1
    elif s=="TLE":
        countTLE += 1
    else:
        countRE += 1

print("AC × " + str(countAC))
print("WA × " + str(countWA))
print("TLE × " + str(countTLE))
print("RE × " + str(countRE))

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

countAC=0
countWA=0
countTLE=0
countRE=0

for i in range(n):
    s=input()
    if s=="AC":
        countAC += 1
    elif s=="WA":
        countWA += 1
    elif s=="TLE":
        countTLE += 1
    else:
        countRE += 1

print("AC x " + str(countAC))
print("WA x " + str(countWA))
print("TLE x " + str(countTLE))
print("RE x " + str(countRE))
Problem:
We ask you to select some number of positive integers, and calculate the sum of them.  It is allowed to select as many integers as you like, and as large integers as you wish. You have to follow these, however: each selected integer needs to be a multiple of A, and you need to select at least one integer.  Your objective is to make the sum congruent to C modulo B. Determine whether this is possible.  If the objective is achievable, print `YES`. Otherwise, print `NO`.

Incorrect submission (verdict: Wrong Answer):
a, b, c = map(int, input().split())
print('No' if all((a*i)%b != c for i in range(1,b+1)) else 'Yes')

Fixed, accepted submission:
a, b, c = map(int, input().split())
print('NO' if all((a*i)%b != c for i in range(1,b+1)) else 'YES')
Problem:
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.  The problem has N test cases.  For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.  See the Output section for the output format.

Incorrect submission (verdict: Wrong Answer):
N=int(input())
a=[]
d=dict(AC=0, WA=0, TLE=0, RE=0)
for _ in range(N):
  a=input()
  d[a]+=1
for k, v in d.items():
  ans=k+" × "+str(v)
  print(ans)

Fixed, accepted submission:
N=int(input())
a=[]
d=dict(AC=0, WA=0, TLE=0, RE=0)
for _ in range(N):
  a=input()
  d[a]+=1
for k, v in d.items():
  ans=k+" x "+str(v)
  print(ans)
Problem:
For an integer n not less than 0, let us define f(n) as follows:    * f(n) = 1 (if n < 2)   * f(n) = n f(n-2) (if n \geq 2)  Given is an integer N. Find the number of trailing zeros in the decimal notation of f(N).

Incorrect submission (verdict: Wrong Answer):
n=int(input())
if n%2==1:
  print(0)
else:
  now=1
  ans=0
  while 1:
    if n%(10**now)!=0:
      break
    else:
      ans+=n%(10**now)
      now+=1
  print(ans)

Fixed, accepted submission:
n=int(input())
if n%2==1:
  print(0)
else:
  now=1
  ans=0
  while 1:
    if (n//(5**now))//2==0:
      break
    else:
      ans+=(n//(5**now))//2
      now+=1
  
  print(ans)
Problem:
Square1001 has seen an electric bulletin board displaying the integer 1. He can perform the following operations A and B to change this value:    * Operation A: The displayed value is doubled.   * Operation B: The displayed value increases by K.  Square1001 needs to perform these operations N times in total. Find the minimum possible value displayed in the board after N operations.

Incorrect submission (verdict: Wrong Answer):
N=int(input())
K=int(input())
ans=[]
for i in range(N):
    ans.append((i+1)*2+(N-i-1))
print(min(ans))

Fixed, accepted submission:
N=int(input())
K=int(input())
ans=1
for i in range(N):
    ans=min(ans*2,ans+K)
print(ans)
Problem:
In the online judge system, a judge file may include multiple datasets to check whether the submitted program outputs a correct answer for each test case. This task is to practice solving a problem with multiple datasets.  Write a program which reads an integer x and print it as is. Note that multiple datasets are given for this problem.

Incorrect submission (verdict: Wrong Answer):
x=int(input())
if x != 0 :
 print("Case i: ", x)

Fixed, accepted submission:
i = 0

while True:
 n = int(input())
 i += 1
 if n == 0:
  break
 print("Case {}: {}".format(i, n))
Problem:
For an integer n not less than 0, let us define f(n) as follows:    * f(n) = 1 (if n < 2)   * f(n) = n f(n-2) (if n \geq 2)  Given is an integer N. Find the number of trailing zeros in the decimal notation of f(N).

Incorrect submission (verdict: Wrong Answer):
N = int(input())
if N%2==1:
    print(0)
    quit()

x = N
fives = 0
i = 0
while x:
    if i % 2 == 1:
        i +=1
        continue
    i += 1
    x //= 5
    fives += x
    print(x, fives)
    
print(fives)

Fixed, accepted submission:
N = int(input())
if N%2==1:
    print(0)
    quit()

x = N
fives = 0
while x:
    x //= 5
    fives += (x//2)
    # print(x, fives)
    
print(fives)
Problem:
You are given a string S of length N consisting of lowercase English letters. We will cut this string at one position into two strings X and Y. Here, we would like to maximize the number of different letters contained in both X and Y. Find the largest possible number of different letters contained in both X and Y when we cut the string at the optimal position.

Incorrect submission (verdict: Wrong Answer):

Fixed, accepted submission:
n = int(input())
s = input()
c = 0
list_s = [sorted(list(set(s[:i]))) for i in range(1,n)]
list_l = [sorted(list(set(s[i:]))) for i in range(1,n)]
print(max([sum([1 if list_s[j][i] in list_l[j] else 0 for i in range(len(list_s[j]))]) for j in range(n-1)]))
Problem:
AtCoDeer the deer found two rectangles lying on the table, each with height 1 and width W. If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of   AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle. Find the minimum distance it needs to be moved.

Incorrect submission (verdict: Wrong Answer):
w,a,b=map(int,input().split())
if min(a,b) + w >= max(a,b):
  print(0)
else:
  ans = max(a,b) - min(a,b) + w
  print(ans)

Fixed, accepted submission:
w,a,b=map(int,input().split())
if min(a,b) + w >= max(a,b):
  print(0)
else:
  ans = max(a,b) - min(a,b) - w
  print(ans)
Problem:
We call a 4-digit integer with three or more consecutive same digits, such as 1118, **good**.  You are given a 4-digit integer N. Answer the question: Is N **good**?

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

print(N)

if N[0] == N[1] and N[1] == N[2]:
    print('Yes')
elif N[1] == N[2] and N[2] == N[3]:
    print('Yes')
else:
    print('No')

Fixed, accepted submission:
# coding: utf-8
# Your code here!

N = input()

# print(N)

if N[0] == N[1] and N[1] == N[2]:
    print('Yes')
elif N[1] == N[2] and N[2] == N[3]:
    print('Yes')
else:
    print('No')
Problem:
You are given a string S.  Takahashi can insert the character `A` at any position in this string any number of times.  Can he change S into `AKIHABARA`?

Incorrect submission (verdict: Wrong Answer):
import sys
input = sys.stdin.readline

# A - AKIBA
substring = ['', 'KIH', 'B', 'R']
akihabara = []

for i in range(16):
	b = format(i, 'b')
	bin_str = b.zfill(4)
	s = ''

	for j in range(4):
		s += substring[j]
		
		if bin_str[j] == '1':
			s += 'A'

	akihabara.append(s)

if input() in akihabara:
	print('YES')
else:
	print('NO')

Fixed, accepted submission:
# A - AKIBA
substring = ['', 'KIH', 'B', 'R']
akihabara = []

for i in range(16):
	b = format(i, 'b')
	bin_str = b.zfill(4)
	s = ''

	for j in range(4):
		s += substring[j]
		
		if bin_str[j] == '1':
			s += 'A'

	akihabara.append(s)

if input() in akihabara:
	print('YES')
else:
	print('NO')
Problem:
In the beginning, Takahashi has A cookies, and Aoki has B cookies. They will perform the following operation alternately, starting from Takahashi:    * If the number of cookies in his hand is odd, eat one of those cookies; if the number is even, do nothing. Then, give one-half of the cookies in his hand to the other person.  Find the numbers of cookies Takahashi and Aoki respectively have after performing K operations in total.

Incorrect submission (verdict: Wrong Answer):
a,b,k = map(int,input().split())
for i in range(k):
    if i % 2 == 1:
        if a %  2 == 1:
            a = (a - 1) // 2
            b += a
    else:
        if b % 2 == 1:
            b = (b - 1) // 2
            a += b
            
print(a,b)

Fixed, accepted submission:
a,b,k = map(int,input().split())
for i in range(k):
    if i % 2 == 0:
        if a %  2 == 1:
            a -= 1
        a = a // 2
        b += a
    else:
        if b % 2 == 1:
            b = b - 1
        b = b // 2
        a += b
            
print(a,b)
Problem:
AtCoDeer the deer recently bought three paint cans. The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c. Here, the color of each paint can is represented by an integer between 1 and 100, inclusive.  Since he is forgetful, he might have bought more than one paint can in the same color. Count the number of different kinds of colors of these paint cans and tell him.

Incorrect submission (verdict: Wrong Answer):
a,b,c=map(int, input().split())
if(a+b==c)or(b+c==a)or(a+c==b):
    print("Yes")
else:
    print("No")

Fixed, accepted submission:
a,b,c=map(int,input().split())
if a==b==c:
    print(1)
elif a==b or a==c or b==c:
    print(2)
elif a!=b and a!=c and b!=c:
    print(3)
Problem:
AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0, 0) at time 0, then for each i between 1 and N (inclusive), he will visit point (x_i,y_i) at time t_i.  If AtCoDeer is at point (x, y) at time t, he can be at one of the following points at time t+1: (x+1,y), (x-1,y), (x,y+1) and (x,y-1). Note that **he cannot stay at his place**. Determine whether he can carry out his plan.

Incorrect submission (verdict: Wrong Answer):
# 10
import sys
N = int(input())
for _ in range(N):
    t, x, y = map(int, input().split())
    if ((x + y) % 2) != (t % 2):
        print('NO')
        sys.exit()
    if t < x + y:
        print('NO')
        sys.exit()
print('YES')


Fixed, accepted submission:
# 10
import sys
N = int(input())
for _ in range(N):
    t, x, y = map(int, input().split())
    if ((x + y) % 2) != (t % 2):
        print('No')
        sys.exit()
    if t < x + y:
        print('No')
        sys.exit()
print('Yes')
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=list(map(int,input().split()))

for i in range(1,n):
	j=i-1
	while j>=0 and a[j]>a[i]:
		a[j+1]=a[j]
		j-=1
	a[j+1]=a[i]

	print(*a)



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

for i in range(n):
	v=a[i]
	j=i-1
	while j>=0 and a[j]>v:
		a[j+1]=a[j]
		j-=1
	a[j+1]=v

	print(*a)
Problem:
Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.  The problem has N test cases.  For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is `AC`, `WA`, `TLE`, and `RE`, respectively.  See the Output section for the output format.

Incorrect submission (verdict: Wrong Answer):
n = int(input())
s = []
c1 = 0 
c2 = 0
c3 = 0
c4 = 0
for i in range(n):
    s.append(input()) 
    if s[i] == 'AC':
        c1 += 1
    elif s[i] == 'WA':
        c2 += 1
    elif s[i] == 'TLE':
        c3 += 1
    elif s[i] == 'RE':
        c4 += 1

print('AC ×',c1)
print('WA ×',c2)
print('TLE ×',c3)
print('RE ×',c4)

Fixed, accepted submission:
n = int(input())
s = []
c1 = 0 
c2 = 0
c3 = 0
c4 = 0
for i in range(n):
    s.append(input()) 
    if s[i] == 'AC':
        c1 += 1
    elif s[i] == 'WA':
        c2 += 1
    elif s[i] == 'TLE':
        c3 += 1
    elif s[i] == 'RE':
        c4 += 1

print('AC x',c1)
print('WA x',c2)
print('TLE x',c3)
print('RE x',c4)
Problem:
Find the largest square number not exceeding N. Here, a _square number_ is an integer that can be represented as the square of an integer.

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

print(int(N**0.5))

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

print(int(N**0.5)**2)
Problem:
There are N positive integers written on a blackboard: A_1, ..., A_N.  Snuke can perform the following operation when all integers on the blackboard are even:    * Replace each integer X on the blackboard by X divided by 2.  Find the maximum possible number of operations that Snuke can perform.

Incorrect submission (verdict: Wrong Answer):
n=int(input())
l=list(map(int,input().split()))
c=0
while True:
    for i in range(n):
        if l[i]%2 !=0:
            print(c)
            exit(0)
        else:
            l[i] = l[i]//2
            c+=1


Fixed, accepted submission:
n=int(input())
l=list(map(int,input().split()))
c=0
while True:
    for i in range(n):
        if l[i]%2 !=0:
            print(c)
            exit(0)
        else:
            l[i] = l[i]//2
    c+=1
Problem:
E869120 has A 1-yen coins and infinitely many 500-yen coins.   Determine if he can pay exactly N yen using only these coins.

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

if (N - A) // 500 == 0:
  print('Yes')
else:
  print('No')

Fixed, accepted submission:
n = int(input())
a = int(input())
n%=500

if n<=a:
  print('Yes')
else:
  print('No')
Problem:
Write a program which reads a sequence and prints it in the reverse order.

Incorrect submission (verdict: Wrong Answer):
input()
list1 = list(map(int, input().split()))
list1.sort()
result=""
for i in range(0,len(list1)):
    result += str(list1[i])+" "
print(result)

Fixed, accepted submission:
input()
print(*input().split()[::-1])
Problem:
Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.

Incorrect submission (verdict: Wrong Answer):
import bisect
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
ai = a[-1]
idx = bisect.bisect_left(a, ai//2)
if abs(ai//2-a[idx]) >= abs(ai//2-a[idx-1]):
    print(ai, a[idx-1])
else:
    print(ai, a[idx])

Fixed, accepted submission:
import bisect
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
ai = a[-1]
idx = bisect.bisect_left(a, ai//2)
if abs(ai//2-a[idx]) == abs(ai//2-a[idx-1]):
    if ai % 2 == 0 or idx == len(a)-1:
        print(ai, a[idx-1])
    else:
        print(ai, a[idx])
elif abs(ai//2-a[idx]) > abs(ai//2-a[idx-1]):
    print(ai, a[idx-1])
else:
    print(ai, a[idx])
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):
a,b,c = map(int, input().split())
print('Yes' if a+b+c ==17 else 'No')

Fixed, accepted submission:
a = [int(_) for _ in input().split()]
a.sort()
print('YES' if a[0]==a[1]==5 and a[2]==7 else 'NO')
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())
for i in range(a, min(a + k, b + 1)):
    print(i)
for j in range(max(i + 1, b - k + 1), b + 1):
    print(i)

Fixed, accepted submission:
a, b, k = map(int, input().split())
for i in range(a, min(a + k, b + 1)):
    print(i)
for j in range(max(i + 1, b - k + 1), b + 1):
    print(j)
Problem:
Joisino is working as a receptionist at a theater.  The theater has 100000 seats, numbered from 1 to 100000.  According to her memo, N groups of audiences have come so far, and the i-th group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).  How many people are sitting at the theater now?

Incorrect submission (verdict: Wrong Answer):
n = int(input())
x = 0
for i in range(n):
  a, b = map(int, input().split())
  x += a - b +1
print(x)

Fixed, accepted submission:
n = int(input())
x = 0
for i in range(n):
  a, b = map(int, input().split())
  x += b-a +1
print(x)
Problem:
Takahashi is organizing a party.  At the party, each guest will receive one or more snack pieces.  Takahashi predicts that the number of guests at this party will be A or B.  Find the minimum number of pieces that can be evenly distributed to the guests in both of the cases predicted.  We assume that a piece cannot be divided and distributed to multiple guests.

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

cnt = max(A,B)
for cnt in range(max(A,B),A*B) :
  if cnt%A == 0 and cnt%B == 0:
    break
  else:
    cnt == cnt +1
  
print(cnt)

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

cnt = 1

for cnt in range(1,A*B) :
  if cnt*min(A,B)%A == 0 and cnt*min(A,B)%B == 0:
    break
  else:
    cnt = cnt +1
  
print(cnt*min(A,B))
Problem:
A country has a budget of more than 81 trillion yen. We want to process such data, but conventional integer type which uses signed 32 bit can represent up to 2,147,483,647.  Your task is to write a program which reads two integers (more than or equal to zero), and prints a sum of these integers.  If given integers or the sum have more than 80 digits, print "overflow".

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

    for i in range(n):
        val1 = int(input())
        val2 = int(input())
        print(str(val1 + val2))

if __name__ == '__main__':
    main()

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

    for i in range(n):
        result = str(int(input()) + int(input()))

        if len(result) > 80:
            print("overflow")
        else:
            print(result)

if __name__ == '__main__':
    main()
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=int(input())
b=int(input())
h=int(input())
print((a+b)*h/2)

Fixed, accepted submission:
a=int(input())
b=int(input())
h=int(input())
print(round(((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, *inputs = input().split()

inputs.sort()
"".join(inputs)
print(inputs);


Fixed, accepted submission:
N, L = input().split()

inputs = [input() for i in range(int(N))]

inputs.sort()
result = "".join(inputs)
print(result)
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):
n = int(input())
print(int(n*800-(n/15)*200))

Fixed, accepted submission:
n = int(input())
print(int(n*800-(n//15)*200))
Problem:
You are given three integers A, B and C. Determine whether C is not less than A and not greater than B.

Incorrect submission (verdict: Wrong Answer):

a, b, c = map(int, input().split())


if a <= c <= b :
    print("YES")
else :
    print("NO")


Fixed, accepted submission:

a, b, c = map(int, input().split())


if a <= c <= b :
    print("Yes")
else :
    print("No")
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 = input()
T = input()

slen = len(s)
Tlen = len(T)
ans = "UNRESTORABLE"
if slen >= Tlen:
    for i in range(slen - Tlen + 1)[::-1]:
        for j in range(Tlen):
            if not s[i+j] in ("?", T[j]):
                break
        else:
            ans = s
            ans = ans[:i] + T + ans[i+Tlen:]
            ans = ans.replace("?", "a")
            print(ans)
            break

print(ans)

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

flag = False
def dfs(x, y):
    if y >= len(T):
        global flag
        flag = True
        return
    elif not S[x] in (T[y], '?'):
        return
    
    dfs(x+1, y+1)


ans = "UNRESTORABLE"
for i in range(len(S) - len(T) + 1)[::-1]:
    if S[i] in (T[0], '?'):
        dfs(i, 0)
        if flag:
            ans = S[:i] + T + S[i+len(T):]
            ans = ans.replace('?', 'a')
            break

print(ans)
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()
for i in range(0, len(s), 2):
 print(s[i])

Fixed, accepted submission:
s = input()
for i in range(0, len(s), 2):
	print(s[i], end = '')
print()
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())
s=list(input())
ans=0
for i in range(n):
    if s[i]=="I":
        ans+=1
    else:
        ans-=1
print(ans)     

Fixed, accepted submission:
n=int(input())
s=list(input())
ans=0
l=[0,]
for i in range(n):
    if s[i]=="I":
        ans+=1
        l.append(ans)
    else:
        ans-=1
        l.append(ans)
print(max(l))