ZhenlongDai/ACPR huggingface dataset:
Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=input()
s=list(input())
x=0
for i in s:
    if i=="I":
        x+=1
    elif i=="D":
        x-=1
print(x)

Failing test case input:
7
IDDDIID

Expected output:
1


Actual output:
-1


Fixed submission (verdict: Accepted):
n=input()
s=list(input())
x=0
l=[0]
for i in s:
    if i=="I":
        x+=1
    elif i=="D":
        x-=1
    l.append(x)
print(max(l))

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
I, D = [], []
for i in range(len(s)):
    I.append(s[0:i].count('I'))
    D.append(s[0:i].count('D'))
print(max([i - d for i, d in zip(I, D)]))


Failing test case input:
5
DIDII

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
I, D = [], []
for i in range(len(s)+1):
    I.append(s[0:i].count('I'))
    D.append(s[0:i].count('D'))
print(max([i - d for i, d in zip(I, D)]))

Problem: p03827
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
x = int(input())
s = input()
li = []
c = 0
for i in range(x):
    if s[i] == "I":
        c += 1
        li.append(c)
    else:
        c -= 1
        li.append(c)
print(max(li))

Failing test case input:
7
DDDDIII

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
x = int(input())
s = input()
li = [0]
c = 0
for i in range(x):
    if s[i] == "I":
        c += 1
        li.append(c)
    else:
        c -= 1
        li.append(c)
print(max(li))

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
N = int(input())
S = list(input().rstrip())
maxx = -(10 ** 9)
x = 0
for i in S:
    if i == "I":
        x += 1
    else:
        x -= 1
    if x > maxx:
        maxx = x
print(x)

Failing test case input:
7
DIDDIID

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
N = int(input())
S = list(input().rstrip())
ans = [0]
x = 0
for i in S:
    if i == "I":
        x += 1
    else:
        x -= 1
    ans.append(x)
print(max(ans))

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
S=input()
ans = 0
for c in S:
    if c == "I":
        ans += 1
    else:
        ans -= 1
print(ans)

Failing test case input:
7
DIIDDID

Expected output:
1


Actual output:
-1


Fixed submission (verdict: Accepted):
input()
m=0
x=0
for c in input():
    if c == "I":
        x += 1
    else:
        x -= 1
    m = max(x,m)
print(m)

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,s=int(input()),input()
print(max([s[0:i].count('I')-s[0:i].count('D') for i in range(n)]))

Failing test case input:
5
DDIII

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
n,s=int(input()),input()
print(max([s[0:i].count('I')-s[0:i].count('D') for i in range(n+1)]))
Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s = input()

x = 0
max_x = 0
for i in s:
  if i == "D":
    x -= 1
  else:
    x += 1
  max_x = max(x, max_x)
print(max_x)

Failing test case input:
5
IIIDD

Expected output:
3


Actual output:
1


Fixed submission (verdict: Accepted):
n = input()
s = input()

x = 0
max_x = 0
for i in s:
  if i == "D":
    x -= 1
  else:
    x += 1
  max_x = max(x, max_x)
print(max_x)

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
input()
x = 0
for a in input():
  x += int(a.replace('I','1').replace('D','-1'))

print(max([0,x]))

Failing test case input:
7
IIDIDDD

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
input()
tmp = x = 0
for a in input():
  x += int(a.replace('I','1').replace('D','-1'))
  if tmp < x:
    tmp = x

print(max([0,tmp]))

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

N = int(input())
S = input()

I_count = [i for i, x in enumerate(S) if x == 'I']
D_count = [i for i, x in enumerate(S) if x == 'D']

tmp = [0] * N
for i in I_count:
    tmp[i] = 1
for i in D_count:
    tmp[i] = -1

ans = 0
List = []
for i in range(N):
    ans += tmp[i]
    List.append(ans)
    
print(max(0, ans))

Failing test case input:
7
DDIIIDD

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):

N = int(input())
S = input()

I_count = [i for i, x in enumerate(S) if x == 'I']
D_count = [i for i, x in enumerate(S) if x == 'D']

tmp = [0] * N
for i in I_count:
    tmp[i] = 1
for i in D_count:
    tmp[i] = -1

ans = 0
List = []
for i in range(N):
    ans += tmp[i]
    List.append(ans)

print(max(0, max(List)))

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


import sys
import itertools



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

N = int(readline())
S = readline().decode('utf8')

print(max(0, S.count('I') - S.count('D')))


Failing test case input:
7
IDDDIID

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):


import sys
import itertools



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

N = int(readline())
S = readline().decode('utf8')

ans = 0
cnt=0
for i in S:
    
    if i == 'I':
        cnt += 1
    else:
        cnt -= 1

    ans=max(ans, cnt)
print(ans)

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
s=input()
d=list(map(int,'0'*(n+1)))
for i in range(n):
  d[i+1]=1+d[i] if s[i]=='I'else -1
print(max(d))

Failing test case input:
7
DIDDDII

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
n=int(input())
s=input()
d=list(map(int,'0'*(n+1)))
for i in range(n):
  d[i+1]=1+d[i] if s[i]=='I'else -1+d[i]
print(max(d))
Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
count = 0
l = []
for i in s:
  if i == "I":
    count += 1
    l.append(count)
  else:
    count -= 1
    l.append(count)
print(max(l))

Failing test case input:
7
DDDIDII

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
count = 0
l = [0]
for i in s:
  if i == "I":
    count += 1
    l.append(count)
  else:
    count -= 1
    l.append(count)
print(max(l))

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
print(max([s[:i].count('I')-s[:i].count('D') for i in range(n)]))

Failing test case input:
5
DIDII

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
print(max([s[:i].count('I')-s[:i].count('D') for i in range(n+1)]))

Problem: p03827
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
s = input()
count = 0
count_list = []

for i in range(len(s)):
    if s[i] == "I":
        count += 1
        count_list.append(count)
    else:
        count -= 1
        count_list.append(count)

print(max(count_list))

Failing test case input:
7
DDIDDII

Expected output:
0

Actual output:
-1


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
count = 0
count_list = [0]

for i in range(len(s)):
    if s[i] == "I":
        count += 1
        count_list.append(count)
    else:
        count -= 1
        count_list.append(count)

print(max(count_list))

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=input()
s=list(input())
x=0
l=[]
for i in s:
    if i=="I":
        x+=1
    elif i=="D":
        x-=1
    l.append(x)
print(max(l))


Failing test case input:
7
DDDDIII

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
n=input()
s=list(input())
x=0
l=[0]
for i in s:
    if i=="I":
        x+=1
    elif i=="D":
        x-=1
    l.append(x)
print(max(l))

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
S=input()
x=0
for i in S:
  if i=="I":
    x+=1
  elif i=="D":
    x-=1
print(x)

Failing test case input:
7
DIIDDDI

Expected output:
1


Actual output:
-1


Fixed submission (verdict: Accepted):
N=int(input())
S=input()
x=0
ans=[0]
for i in S:
  if i=="I":
    x+=1
  elif i=="D":
    x-=1
  ans.append(x)
print(max(ans))

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
a = 0
for i in range(len(s)):
    if s[i] == "I":
        a += 1
    elif s[i] == "D":
        a += -1
    ans = max(a,0)
print(ans)

Failing test case input:
5
IIIDD

Expected output:
3


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
now = 0
ans = 0
for i in s:
  if i == "I":
    now += 1
  else:
    now -= 1
  ans = max(ans,now)
print(ans)
Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = input()
n = int(n)
str = input()
val = []
x = 0
for _ in range(n):
  o = str[:1]
  if o == 'D':
    x -= 1
  else:
    x += 1
  val.append(x)
  str = str[1:]
print(max(val))

Failing test case input:
7
DDIDIDI

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
n = input()
n = int(n)
str = input()
val = [0]
x = 0
for _ in range(n):
  o = str[:1]
  if o == 'D':
    x -= 1
  else:
    x += 1
  val.append(x)
  str = str[1:]
print(max(val))

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
I, D = [], []
for i in range(1, len(s)+1):
    I.append(s[0:i].count('I'))
    D.append(s[0:i].count('D'))
print(max([i - d for i, d in zip(I, D)]))


Failing test case input:
7
DDDDIII

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
I, D = [], []
for i in range(len(s)+1):
    I.append(s[0:i].count('I'))
    D.append(s[0:i].count('D'))
print(max([i - d for i, d in zip(I, D)]))

Problem: p03827
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
s = list(input())
count = 0
max = 0
for i in range(n):
  if max < count:
    max = count
  if s[i] == "I":
    count += 1  
  elif s[i] == "D":
    count -= 1
print(max)

Failing test case input:
5
DIDII

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
s = list(input())
count = 0
max = 0
for i in range(n):
  
  if s[i] == "I":
    count += 1
    if max < count:
      max = count
  elif s[i] == "D":
    count -= 1
print(max)

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()

ma = 0
x = 0
for i in range(len(s)):
    if ma < x:
        ma = x

    if s[i] == 'I':
        x += 1
    else:
        x -= 1

print(ma)

Failing test case input:
5
DIDII

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
s = input()

ma = 0
x = 0
for i in range(len(s)):
    if s[i] == 'I':
        x += 1
    else:
        x -= 1

    if ma < x:
        ma = x


print(ma)

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
s=input()
x=0
a=[]
for i in range(n):
    if s[i]=="I":
        x+=1
    else:
        x-=1
    a.append(x)
print(max(a))

Failing test case input:
7
DDIDIDI

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
n=int(input())
s=input()
x=0
a=[0]
for i in range(n):
    if s[i]=="I":
        x+=1
    else:
        x-=1
    a.append(x)
print(max(a))

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=input()
ans=0
k=0
for i in s:
    if i=='I':
        k+=1
        ans=max(ans,k)
    elif i=='D':
        k-=1
print(ans)





Failing test case input:
7
IIDDDID

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
n=int(input())
s=input()
ans=0
k=0
for i in s:
    if i=='I':
        k+=1
        ans=max(ans,k)
    else:
        k-=1
print(ans)
Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,s=input(),input()
c,m=0,0
for i in range(len(s)):
    if s[i]=="I":c,m=c+1,max(c,m)
    if s[i]=="D":c,m=c-1,max(c,m)
print(max(0,m))

Failing test case input:
5
DDIII

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
input()
s=input()
c,m=0,0
for i in range(len(s)):
    if s[i]=="I":
        c+=1
        m=max(c,m)
    if s[i]=="D":
        c=c-1
        m=max(c,m)
print(m)

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = str(input())
x = 0
lst = []
for i in range(len(s)):
    if s[i]=='I':
        x += 1
    else:
        x -= 1
    lst.append(x)
print(max(lst))

Failing test case input:
7
DDDIIDI

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
n = int(input())
s = str(input())
x = 0
lst = [0]
for i in range(len(s)):
    if s[i]=='I':
        x += 1
    else:
        x -= 1
    lst.append(x)
print(max(lst))

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=int(input())
t=str(input())
t=list(t)
ans=0
temp=0
for i in range(0,s):
  if t=="I":
    ans=ans+1
  else:
    ans=ans-1
  temp=max(ans,temp)
print(temp)

Failing test case input:
7
DIIDDID

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
s=int(input())
t=str(input())
t=list(t)
ans=0
temp=0
for i in range(0,s):
  if t[i]=="I":
    ans=ans+1
  else:
    ans=ans-1
  temp=max(ans,temp)
print(temp)

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
if __name__ == '__main__':
    a = int(input())
    s = input()
    count =0
    for i in s:
        if i == "I":
            count +=1
        else:
            count -=1
    print(count)
        

Failing test case input:
7
IIDIDDD

Expected output:
2


Actual output:
-1


Fixed submission (verdict: Accepted):
if __name__ == '__main__':
    a = int(input())
    s = input()
    count =0
    max = 0
    for i in s:
        if i == "I":
            count +=1
        else:
            count -=1

        if max < count:
            max = count
    print(max)

Problem: p03827
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
A = list(input())
B = [0]*N
C = [0]*N
for i in range(N):
  if A[i] == "I":
    B[i] = 1
  else:
    B[i] = -1
C[0] = B[0]
for i in range(1, N):
  C[i] = C[i-1]+B[i]
print(max(C))

Failing test case input:
7
DDDIIDI

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
N = int(input())
A = list(input())
B = [0]*N
C = [0]*N
for i in range(N):
  if A[i] == "I":
    B[i] = 1
  else:
    B[i] = -1
C[0] = B[0]
for i in range(1, N):
  C[i] = C[i-1]+B[i]
if max(C) < 0:
    print(0)
else:
    print(max(C))
Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = str(input())
count = 0
ans = 0

for i in range(N):
    if S[i:1] == "I":
        count += 1
        ans = max(ans,count)
    else:
        count -= 1

print(ans)

Failing test case input:
5
IIIDD

Expected output:
3


Actual output:
1


Fixed submission (verdict: Accepted):
N = int(input())
S = str(input())
count = 0
ans = 0

for i in range(N):
    if S[i:i+1] == "I":
        count += 1
        ans = max(ans,count)
    else:
        count -= 1

print(ans)

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
s=input()
x=0
L=[]
for i in range(n):
    if s[i]=="I":
        x+=1
    elif s[i]=="D":
        x-=1
    L.append(x)
print(max(L))

Failing test case input:
7
DDDIDII

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
n=int(input())
s=input()
x=0
L=[0]
for i in range(n):
    if s[i]=="I":
        x+=1
    elif s[i]=="D":
        x-=1
    L.append(x)
print(max(L))

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
input()
n=input()
a=c=0
for i in n:
  if i=='I':a+=1
  else:a-=1
  c=max(a,c)
print(a)

Failing test case input:
7
DIDDIID

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
input()
s=input()
a=c=0
for i in s:
  if i=='I':a+=1
  else:a-=1
  c=max(a,c)
print(c)

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
count = 0
l = []
for i in s:
  if s == "I":
    count += 1
    l.append(count)
  else:
    count -= 1
    l.append(count)
print(max(l))

Failing test case input:
7
DIDDIDI

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
count = 0
l = [0]
for i in s:
  if i == "I":
    count += 1
    l.append(count)
  else:
    count -= 1
    l.append(count)
print(max(l))

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
s=input()
t=0
m=-1
for i in range(len(s)):
    if s[i]=="I":
        t+=1
    else:
        t-=1
    if m<t:
        m=t
print(m)


Failing test case input:
7
DDIDIDI

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
n=int(input())
s=input()
t=0
m=0
for i in range(len(s)):
    if s[i]=="I":
        t+=1
    else:
        t-=1
    if m<t:
        m=t
print(m)

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
S=input()
ans=0
li=[]
for s in S:
  if s=="I":
    ans+=1
    li.append(ans)
  else:
    ans-=1
    li.append(ans)
print(max(li)) 

Failing test case input:
7
DDIDDII

Expected output:
0

Actual output:
-1


Fixed submission (verdict: Accepted):
N=int(input())
S=input()
ans=0
li=[0]
for s in S:
  if s=="I":
    ans+=1
    li.append(ans)
  else:
    ans-=1
    li.append(ans)
print(max(li))
Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A = int(input())
S = input()
s = -1
count = 0
for i in S:
  if (s<=count)and(i == 'I'):
    count += 1
    s = count
  elif i == 'I':
    count += 1
  else:
    count += -1
print(s)

Failing test case input:
7
DDIDIDI

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
A = int(input())
S = input()
s = 0
count = 0
for i in S:
  if (s<=count)and(i == 'I'):
    count += 1
    s = count
  elif i == 'I':
    count += 1
  else:
    count += -1
print(s)

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
s=str(input())
x=0
l=[]
for i in range(n):
  if s[i]=='I':
    x+=1
    l.append(x)
  else:
    x-=1
    l.append(x)
print(max(l))


Failing test case input:
7
DDDDIII

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
n=int(input())
s=str(input())
x=0
l=[0]
for i in range(n):
  if s[i]=='I':
    x+=1
    l.append(x)
  else:
    x-=1
    l.append(x)
print(max(l))

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = str(input())

ans = 0
for i in range(0, n):
    if s[i]=="I":
        ans+=1
    else:
        ans-=1
print(ans)

Failing test case input:
7
DDIDDII

Expected output:
0

Actual output:
-1


Fixed submission (verdict: Accepted):
n = int(input())
s = input()

ans = 0
x = 0
for i in range(n):
    if s[i]=="I":
        ans+=1
        x = max(ans, x)
    else:
        ans-=1
        x = max(ans, x)
print(x)

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
S=input()
total=0
X=[]
for i in S:
  X.append(total)
  if i=="I":
    total+=1
  elif i=="D":
    total-=1
print(max(X))
    

Failing test case input:
5
DIDII

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
N=int(input())
S=input()
x=0
ans=[0]
for i in S:
  if i=="I":
    x+=1
  elif i=="D":
    x-=1
  ans.append(x)
print(max(ans))

Problem: p03827
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
ans = list(input())
count = 0
a = set()
for i in range(n):
    if ans[i] == 'I':
        count += 1
        a.add(count)
    elif ans[i] == 'D':
        count -= 1
        a.add(count)

print(max(a))

Failing test case input:
7
DDIDIDI

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
n = int(input())
ans = list(input())
count = 0
a = set()
for i in range(n):
    if ans[i] == 'I':
        count += 1
        a.add(count)
    elif ans[i] == 'D':
        count -= 1
        a.add(count)

print(max(max(a), 0))

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
d = {"I": 1, "D": -1}
x = 0
N = int(input())
S = input()
ans = -1000
for Si in S:
    x += d[Si]
    ans = max(ans, x)
print(ans)


Failing test case input:
7
DDIDIDI

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
d = {"I": 1, "D": -1}
x = 0
N = int(input())
S = input()
ans = 0
for Si in S:
    x += d[Si]
    ans = max(ans, x)
print(ans)
Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = list(input())
s = [1 if i =='I' else -1 for i in s]
l = [sum(s[:i]) for i in range(1,n)]
l.append(0)
l
print(max(l))


Failing test case input:
5
DIDII

Expected output:
1


Actual output:
0


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

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = list(input())

A = []

for i in range(n):
    ans = s[:i]
    A.append(ans.count('I') - ans.count('D'))

print(max(A))

Failing test case input:
5
DIDII

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
s = list(input())

A = []

for i in range(n+1):
    ans = s[:i]
    A.append(ans.count('I') - ans.count('D'))

print(max(A))

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = str(input())
l = []
c = 0
for i in range(len(s)):
    if s.count("I") < s.count("D"):
        print(0)
    elif s[i] == "I":
        c += 1
    elif s[i] == "D":
        c -= 1
    l.append(c)
print(max(l))

Failing test case input:
7
IDDDIID

Expected output:
1


Actual output:
0
0
0
0
0
0
0
0


Fixed submission (verdict: Accepted):
n = int(input())
s = str(input())
l = []
c = 0
for i in range(len(s)):
    if s[i] == "I":
        c += 1
    elif s[i] == "D":
        c -= 1
    l.append(c)
print(max(max(l),0))

Problem: p03827
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
input()

ans = 0
x = 0
for c in input():
  if c == 'D':
    x += 1
  else:
    x -= 1
  ans = max(ans, x)
  
print(ans)

Failing test case input:
5
IDIID

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
input()

ans = 0
x = 0
for c in input():
  if c == 'I':
    x += 1
  else:
    x -= 1
  ans = max(ans, x)
  
print(ans)

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = input()
x = 0
ans = []

for i in range(N):
  if S[i] == "I":
    x += 1
    ans.append(x)
  else:
    x -= 1
    ans.append(x)

print(max(ans))

Failing test case input:
7
DDDDIII

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
N = int(input())
S = input()
x = 0
ans = []
ans.append(x)

for i in range(N):
  if S[i] == "I":
    x += 1
    ans.append(x)
  else:
    x -= 1
    ans.append(x)

print(max(ans))

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A = int(input())
S = input()
s = 0
count = 0
for i in S:
  if i == 'I':
    count += 1
    if s < count:
      s = count
  else:
    count = 0
print(s)

Failing test case input:
7
DIDIDID

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
A = int(input())
S = input()
s = 0
count = 0
for i in S:
  if (s<=count)and(i == 'I'):
    count += 1
    s = count
  elif i == 'I':
    count += 1
  else:
    count += -1
print(s)
Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = input()
maxi = 0
now = 0
for c in a:
  if c == 'I':
    now += 1
  else:
    now -= 1
  if now > maxi:
    maxi = now
print(maxi)


Failing test case input:
7
DIIDIDD

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
input()
a = input()
maxi = 0
now = 0
for c in a:
  if c == 'I':
    now += 1
  else:
    now -= 1
  maxi = max(now, maxi)
print(maxi)

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
input()
s =input()
a = []
n = 0
for i in s :
  if i == 'I':
    n +=1
  else :
    n-=1
  a.append(n)
print(max(a))

Failing test case input:
7
DDIDDII

Expected output:
0

Actual output:
-1


Fixed submission (verdict: Accepted):
input()
s =input()
a = [0]
n = 0
for i in s :
  if i == 'I':
    n +=1
  else :
    n-=1
  a.append(n)
print(max(a))

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = str(input())
x = 0
tmpmax = 0
for char in s:
  if s == 'I':
    x += 1
    if x > tmpmax:
      tmpmax = x
  else:
    x -= 1
print (tmpmax)

Failing test case input:
7
IDDIDID

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
s = str(input())
x = 0
tmpmax = 0
for char in s:
  if char == 'I':
    x += 1
    if x > tmpmax:
      tmpmax = x
  else:
    x -= 1
print (tmpmax)

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
s=input()
a=[1]
for i in range(1,n+1):
	if s[i-1]=="I":
		a.append(a[i-1]+1)
	else:
		a.append(a[i-1]-1)
print(max(a))

Failing test case input:
7
DIIDIDD

Expected output:
1


Actual output:
2


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

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = input()

ans = -10000
for i in range(1,N+1):
  ans = max(S[:i].count('I')-S[:i].count('D'),ans)

print(ans)

Failing test case input:
7
DDDDIII

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
N = int(input())
S = input()

ans = 0
for i in range(1,N+1):
  ans = max(S[:i].count('I')-S[:i].count('D'),ans)

print(ans)

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = list(input())
count = 0

for i in range(N):
    if i == "I":
        count += 1
    if i == "D":
        count -= 1
else:
    print(count)


Failing test case input:
7
DIIDDDI

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
S = list(input())
count = 0
max_count = 0
for i in S:
    if i == "I":
        count += 1
    if i == "D":
        count -= 1
    if max_count < count:
        max_count = count
else:
    print(max_count)
Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


import sys
import itertools



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

N = int(readline())
S = readline().decode('utf8')

ans = 0
cnt=0
for i in S:
    
    if i == 'I':
        cnt += 1
    else:
        cnt -= 1

    ans=max(ans, cnt)


Failing test case input:
5
IDDII

Expected output:
1


Actual output:

Fixed submission (verdict: Accepted):


import sys
import itertools



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

N = int(readline())
S = readline().decode('utf8')

ans = 0
cnt=0
for i in S:
    
    if i == 'I':
        cnt += 1
    else:
        cnt -= 1

    ans=max(ans, cnt)
print(ans)

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = input()
X = []
x = 0
for s in S:
  if s == 'I':
    x += 1
    X.append(x)
  else:
    x -= 1
    X.append(x)
X.sort(reverse = True)
print(X[0])

Failing test case input:
7
DDDIIDI

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
N = int(input())
S = input()
X = [0]
x = 0
for s in S:
  if s == 'I':
    x += 1
    X.append(x)
  else:
    x -= 1
    X.append(x)
X.sort(reverse = True)
print(X[0])

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = input()

x = 0
M = 0
for s in list(S):
  pre = x
  if s == "I":
    x += 1
  elif s == "D":
    x -= 1
  M = max(pre, x)
print(M)


Failing test case input:
7
IIDIDDD

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
S = input()
 
x = 0
M = 0
for s in list(S):
  if s == "I":
    x += 1
  elif s == "D":
    x -= 1
  M = max(M, x)
print(M)

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
a = 0
for i in s:
    if i == "I":
        a += 1
    else:
        a -= 1
    ans = max(a,0)
print(ans)

Failing test case input:
7
DIDIIDD

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
now = 0
ans = 0
for i in s:
  if i == "I":
    now += 1
  else:
    now -= 1
  ans = max(ans,now)
print(ans)

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = list(input())
x = 0
for i in s:
   if i =="I":
      x += 1
   else:
       x -= 1
print(x)


Failing test case input:
7
IDDIDDI

Expected output:
1


Actual output:
-1


Fixed submission (verdict: Accepted):
n = int(input())
s = list(input())
x = 0
l = []
l.append(x)
for i in s:
   if i =="I":
      x += 1
   elif i =="D":
      x -= 1
   l.append(x)
print(max(l))
Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = input()
x = 0
max_x = 0
for i in range(N):
    if S[i] == "I":
        x += 1
    else:
        x -= 1
    max_x - max(max_x, x)
print(max_x)


Failing test case input:
7
IIDDDID

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
S = input()
x = 0
max_x = 0
for i in range(N):
    if S[i] == "I":
        x += 1
    else:
        x -= 1
    max_x = max(max_x, x)
print(max_x)

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
x = 0
for i in range(n):
    if s[i] == "I":
        x += 1
    elif s[i] == "D":
        x -= 1
print(x)


Failing test case input:
7
IIDDDID

Expected output:
2


Actual output:
-1


Fixed submission (verdict: Accepted):
n = int(input())
s = input()

x = 0
ans = 0
for i in range(n):
    if s[i] == "I":
        x += 1
    elif s[i] == "D":
        x -= 1
    ans = max(ans, x)
print(ans)

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
a = 0
b = 0
for i in s:
    if i == "I":
        a += 1
    else:
        a -= 1
    ans = max(a,b)
print(ans)

Failing test case input:
7
IIDDIDD

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
now = 0
ans = 0
for i in s:
  if i == "I":
    now += 1
  else:
    now -= 1
  ans = max(ans,now)
print(ans)

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
s=input()
x=0
ans=-300
for i in s:
    if i=='I':
        x+=1
    else:
        x-=1
    if x>ans:
        ans=x
print(ans) 

Failing test case input:
7
DDDIDII

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
n=int(input())
s=input()
x=0
ans=0
for i in range(len(s)):
    if s[i]=='I':
        x+=1
    else:
        x-=1
    if x>ans:
        ans=x
print(ans)

Problem: p03827
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
S = input()
x = 0
A = []
for i in range(N):
    if S[i] == "I":
        x += 1
    else:
        x -= 1
    A.append(x)
print(max(A), 0)

Failing test case input:
7
DDIDDII

Expected output:
0

Actual output:
-1 0


Fixed submission (verdict: Accepted):
N = int(input())
S = input()
x = 0
A = [0]
for i in range(N):
    if S[i] == "I":
        x += 1
    else:
        x -= 1
    A.append(x)
print(max(A))

Problem: p03827
Buggy submission (Python (3.8.2), 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))

Failing test case input:
7
DIIDDDI

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
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))
Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
a = 0
for i in s:
    if i == "I":
        a += 1
    elif i == "D":
        a -= 1
    ans = max(a,0)
print(ans)

Failing test case input:
7
DIIDDID

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
now = 0
ans = 0
for i in s:
  if i == "I":
    now += 1
  else:
    now -= 1
  ans = max(ans,now)
print(ans)

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
ans = [0]
for i in range(n):
    if s[i] == 'I':
        ans.append(ans[i-1] +1)
    else:
        ans.append(ans[i-1] -1)
print(max(ans))
    

Failing test case input:
7
DDIIDID

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
ans = []
if s[0] == 'I':
    ans.append(1)
else:
    ans.append(-1)
for i in range(1,n):
    if s[i] == 'I':
        ans.append(ans[i-1] +1)
    else:
        ans.append(ans[i-1] -1)
if max(ans) < 0:
    print('0')
else:
    print(max(ans))

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
x=0
s=input()
ans=0
for i in range(n):
    if s[i]=="I":
        x=x+1
    else:
        x=x-1
    ans=max(ans,x)
print(x)

Failing test case input:
7
IIDIDDD

Expected output:
2


Actual output:
-1


Fixed submission (verdict: Accepted):
n = int(input())
x=0
s=input()
ans=0
for i in range(n):
    if s[i]=="I":
        x=x+1
    else:
        x=x-1
    ans=max(ans,x)
print(ans)

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = str(input())
lst_for_ans = []
for i in range(len(S)):
    I_count = S[:i].count("I")
    D_count = S[:i].count("D")
    lst_for_ans.append(I_count - D_count)

print(max(lst_for_ans))

Failing test case input:
5
DIDII

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
S = str(input())
lst_for_ans = []
for i in range(len(S)+1):
       I_count = S[:i].count("I")
       D_count = S[:i].count("D")
       lst_for_ans.append(I_count - D_count)

print(max(max(lst_for_ans),0))

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S=input()
max_v =0
v =0
for i in S:
  if i=="I":
    v+=1
    if v>max_v:
      max_v=v
  else:
    v-=1


Failing test case input:
7
IDIDIDD

Expected output:
1


Actual output:

Fixed submission (verdict: Accepted):
N=input()
S=input()
max_v =0
v =0
for i in S:
  if i=="I":
    v+=1
    if v>max_v:
      max_v=v
  else:
    v-=1
print(max_v)

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = list(input())
x = 0
ans = []
for i in s:
    if i == 'I':
        x += 1
    if i == 'D':
        x -= 1
    ans.append(x)

print(max(ans))

Failing test case input:
7
DDDIIDI

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
n = int(input())
s = list(input())
x = 0
ans = [0]
for i in s:
    if i == 'I':
        x += 1
    if i == 'D':
        x -= 1
    ans.append(x)

print(max(ans))
Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = ""
current_num = 0
max_num = 0
for c in s:
  current_num += 1 if c == 'I' else -1
  max_num = max(max_num, current_num)
print(max_num)
  

Failing test case input:
5
IIIDD

Expected output:
3


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
current_num = 0
max_num = 0
for c in s:
  current_num += 1 if c == 'I' else -1
  max_num = max(max_num, current_num)
print(max_num)

Problem: p03827
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
s = input()

ans = 0
for n in range(N):
  if s[n]=="I":
    ans += 1
  else:
    ans -= 1
print(ans)

Failing test case input:
7
DDIIDID

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
N = int(input())
s = input()

sum_ = 0
ans = 0
for n in range(N):
  if s[n]=="I":
    sum_ += 1
  else:
    sum_ -= 1
  if ans < sum_:
    ans = sum_
print(ans)

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = input()
K = []
ans = 0
for i in range(N):
  if S[i] == "I":
    ans += 1
    K.append(ans)
  else:
    ans -= 1
    K.append(ans)
print(max(K))


Failing test case input:
7
DDDDIII

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
N = int(input())
S = input()
K = []
ans = 0
K.append(0)
for i in range(N):
  if S[i] == "I":
    ans += 1
    K.append(ans)
  else:
    ans -= 1
    K.append(ans)
print(max(K))

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
input()
temp=0
maxV=-1
for s in input():
  temp+=1 if s=="I" else -1
  if maxV<temp:maxV=temp 
print(maxV)

Failing test case input:
7
DDIDIDI

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
input()
temp=0
maxV=0
for s in input():
  temp+=1 if s=="I" else -1
  if maxV<temp:maxV=temp 
print(maxV)

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = input()
L = []
x = 0
for c in S:
  if c == 'I':
    x += 1
    L.append(x)
  elif c == 'D':
    x -= 1
    L.append(x)
print(max(L))

Failing test case input:
7
DDIDIDI

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
N = int(input())
S = input()
L = [0]
x = 0
for c in S:
  if c == 'I':
    x += 1
    L.append(x)
  elif c == 'D':
    x -= 1
    L.append(x)
print(max(L))

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

n = int(input())
s = input()
ans = []
temp = 0

for i in range(len(s)-1):
    n+=temp
    ans.append(n)
    if s[i]=='I':
        temp=1
    else:
        temp=-1

print(ans.index((max(ans))))

Failing test case input:
7
DIIDDDI

Expected output:
1


Actual output:
3


Fixed submission (verdict: Accepted):

n = int(input())
s = input()
ans = [0]

for i in s:
    if i=='I':
        ans.append(ans[-1]+1)
    else:
        ans.append(ans[-1]-1)


print(max(ans))
Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
I, D = [], []
for i in range(len(s)):
    I.append(s[0:i+1].count('I'))
    D.append(s[0:i+1].count('D'))
print(max([i - d for i, d in zip(I, D)]))


Failing test case input:
7
DDIDDII

Expected output:
0

Actual output:
-1


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
I, D = [], []
for i in range(len(s)+1):
    I.append(s[0:i].count('I'))
    D.append(s[0:i].count('D'))
print(max([i - d for i, d in zip(I, D)]))

Problem: p03827
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
s = input()
x = 0
l_x = []
for c in s:
  x += 1 if c == 'I' else -1
  l_x.append(x)
    
print(max(l_x))

Failing test case input:
7
DDDIIDI

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
s = input()
s = input()
x = 0
l_x = [0]
for c in s:
  x += 1 if c == 'I' else -1
  l_x.append(x)
    
print(max(l_x))

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
peak = []
x = 0
for i in range(n):
  if s[i] == "I":
    x += 1
    peak.append(x)
    
  elif s[i]=="D":
    x -= 1
    peak.append(x)

peak.sort()
print(peak[-1])

Failing test case input:
7
DDDIIDI

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
peak = [0]
x = 0
for i in range(n):
  if s[i] == "I":
    x += 1
    peak.append(x)
    
  elif s[i]=="D":
    x -= 1
    peak.append(x)

peak.sort()
print(peak[-1])

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = input()
x = 0
l = []
for s in S:
  if s == 'I':
    x += 1
  elif s == 'D':
    x -= 1
  l.append(x)
l.sort()
print(l[-1])

Failing test case input:
7
DDIDIDI

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
N = int(input())
S = input()
x = 0
l = [0]
for s in S:
  if s == 'I':
    x += 1
  elif s == 'D':
    x -= 1
  l.append(x)
l.sort()
print(l[-1])

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = list(input())
ans = 0
maxNum = 0
for i in s:
    if ans < maxNum:
        ans = maxNum
    if i == "I":
        maxNum += 1
    else:
        maxNum -= 1
print(ans)

Failing test case input:
5
DDIII

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
s = list(input())
ans = 0
maxNum = 0
for i in s:
    if i == "I":
        maxNum += 1
    else:
        maxNum -= 1
    if ans < maxNum:
        ans = maxNum
print(ans)

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
A = int(input())
S = input()
s = 0
count = 0
for i in S:
  if (s<=count)and(i == 'I'):
    count += 1
    s = count
  else:
    count = -1
print(s)

Failing test case input:
7
DIIDDID

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
A = int(input())
S = input()
s = 0
count = 0
for i in S:
  if (s<=count)and(i == 'I'):
    count += 1
    s = count
  elif i == 'I':
    count += 1
  else:
    count += -1
print(s)
Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
input = sys.stdin.readline
N = int(input())
S = list(input().rstrip())
ans = []
x = 0
for i in S:
    if i == "I":
        x += 1
    else:
        x -= 1
    ans.append(x)
print(max(ans))

Failing test case input:
7
DDIDDII

Expected output:
0

Actual output:
-1


Fixed submission (verdict: Accepted):
import sys
input = sys.stdin.readline
N = int(input())
S = list(input().rstrip())
ans = [0]
x = 0
for i in S:
    if i == "I":
        x += 1
    else:
        x -= 1
    ans.append(x)
print(max(ans))

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = str(input())
l = []
c = 0
for i in range(len(s)):
    if s[i] == "I":
        c += 1
    elif s[i] == "D":
        c -= 1
    l.append(c)
print(max(l))

Failing test case input:
7
DDDIDII

Expected output:
0


Actual output:
-1


Fixed submission (verdict: Accepted):
n = int(input())
s = str(input())
l = []
c = 0
for i in range(len(s)):
    if s[i] == "I":
        c += 1
    elif s[i] == "D":
        c -= 1
    l.append(c)
print(max(max(l),0))

Problem: p03827
Buggy submission (Python (3.4.3), 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)     

Failing test case input:
7
IIDDDDI

Expected output:
2


Actual output:
-1


Fixed submission (verdict: Accepted):
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))

Problem: p03827
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
s = str(input())
ans = 0
ans_lis = []

for i in range(n):
    if s[i] == "I":
        ans += 1
        ans_lis.append(ans)
    else:
        ans -= 1
        ans_lis.append(ans)

print(max(ans_lis))

Failing test case input:
7
DDIDDII

Expected output:
0

Actual output:
-1


Fixed submission (verdict: Accepted):
n = int(input())
s = str(input())
ans = 0
ans_lis = [0]

for i in range(n):
    if s[i] == "I":
        ans += 1
        ans_lis.append(ans)
    else:
        ans -= 1
        ans_lis.append(ans)

print(max(ans_lis))

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = input()

x = 0
ans = 0
for i in range(N):
	if S[i:i+1]=='I':
		ans = max(ans, x)
		x += 1
	elif S[i:i+1]=='D':
		x -= 1

print(ans)

Failing test case input:
5
IIIDD

Expected output:
3


Actual output:
2


Fixed submission (verdict: Accepted):
N = int(input())
S = input()

x = 0
ans = 0
for i in range(N):
	if S[i:i+1]=='I':
		x += 1
		ans = max(ans, x)
	elif S[i:i+1]=='D':
		x -= 1

print(ans)
Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
s=input()
x=0
y=0
for i in range(n-1):
    if (s[i]=="I"):
        x+=1
        y=max(x,y)
    else:
        x-=1
print(y)

Failing test case input:
5
DIDII

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
n=int(input())
s=input()
x=0
y=0
for i in range(n):
    if (s[i]=="I"):
        x+=1
        y=max(x,y)
    elif (s[i]=="D"):
        x-=1
print(y)

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def main():
    n = int(input())
    s = list(input().split())

    ans = 0
    now = 0
    for i, i_d in enumerate(s):
        if i_d == 'I':
            now += 1
            ans = max(ans, now)
        else:
            now -= 1

    print(ans)
if __name__ == '__main__':
    main()


Failing test case input:
5
IIDDI

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
def main():
    n = int(input())
    s = list(input())

    ans = 0
    now = 0
    for i, i_d in enumerate(s):
        if i_d == 'I':
            now += 1
            ans = max(ans, now)
        else:
            now -= 1

    print(ans)
if __name__ == '__main__':
    main()

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):


import sys
import itertools



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

N = int(readline())
S = readline().decode('utf8')

ans = 0
for i in S:
    cnt = 0
    if i == 'I':
        cnt += 1
    else:
        cnt -= 1

    ans=max(ans, cnt)


Failing test case input:
7
DDIDDII

Expected output:
0

Actual output:

Fixed submission (verdict: Accepted):


import sys
import itertools



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

N = int(readline())
S = readline().decode('utf8')

ans = 0
cnt=0
for i in S:
    
    if i == 'I':
        cnt += 1
    else:
        cnt -= 1

    ans=max(ans, cnt)
print(ans)

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N=int(input())
S=input()
cnt=0
ans=0
for s in S:
    if s=="I":
        cnt+=1
        ans=cnt
    if s=="D":
        cnt-=1
print(max(0,ans))

Failing test case input:
7
DIIDDDI

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
N=int(input())
S=input()
cnt=0
ans=0
for s in S:
    if s=="I":
        cnt+=1
        ans=max(ans,cnt)
    if s=="D":
        cnt-=1
print(max(0,ans))

Problem: p03827
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = input()

ans = 0
x = 0
for s in S:
  v = 1 if s == 'I' else 0
  x += v
  ans = max(ans, x)
print(ans)


Failing test case input:
7
IDDIDDI

Expected output:
1


Actual output:
3


Fixed submission (verdict: Accepted):
N = int(input())
S = input()

ans = 0
x = 0
for s in S:
  v = 1 if s == 'I' else -1
  x += v
  ans = max(ans, x)
print(ans)