Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N,W=map(int,input().split())
Wlist=[]
Vlist=[]
for i in range(N):
  w,v=map(int,input().split())
  Wlist+=[w]
  Vlist+=[v]
dp=[[0 for p in range(W+1)] for i in range(N)]
for i in range(W+1):
  if i>=Wlist[0]:
    dp[0][i]=Vlist[0]
for i in range(1,N):
  wi=Wlist[i]
  for j in range(W+1):
    if j-wi>=0:
      dp[i][j]=max(dp[i-1][j-wi]+Vlist[i],dp[i-1][j])
    else:
      dp[i][j]=max(dp[i-1][j],dp[i][j])
print(max(dp[N-1]))

Fixed submission:
N=int(input())
H=list(map(int,input().split()))
dplist=[0 for i in range(N)]
dplist[0]=0
dplist[1]=abs(H[1]-H[0])
for i in range(2,N):
  dplist[i]=min(dplist[i-1]+abs(H[i]-H[i-1]),dplist[i-2]+abs(H[i-2]-H[i]))
print(dplist[N-1])

Buggy python submission (verdict: Runtime Error):
N=int(input())
ABC=[]
for i in range(N):
  l=list(map(int,input().split()))
  ABC=ABC+[l]
dp=[0,0,0]*N#dp[i][j]はi+1日目にアクティビティjを選んだ時の活動終了時の幸福量
for i in range(3):
  dp[0][i]=ABC[0][i]
for i in range(1,N):
  dp[i][1]=max(dp[i-1][2]+ABC[i][1],dp[i-1][0]+ABC[i][1])
  dp[i][0]=max(dp[i-1][1]+ABC[i][0],dp[i-1][2]+ABC[i][0])
  dp[i][2]=max(dp[i-1][1]+ABC[i][2],dp[i-1][0]+ABC[i][2])
ans=max(dp[N-1])
print(ans)

Fixed submission:
N=int(input())
H=list(map(int,input().split()))
dplist=[0 for i in range(N)]
dplist[0]=0
dplist[1]=abs(H[1]-H[0])
for i in range(2,N):
  dplist[i]=min(dplist[i-1]+abs(H[i]-H[i-1]),dplist[i-2]+abs(H[i-2]-H[i]))
print(dplist[N-1])

Buggy python submission (verdict: Runtime Error):
N=int(input())
H=list(map(int,input().split()))
dplist=[0 for i in range(N)]
dplist[0]=0
dplist[1]=H[1]-H[0]
for i in range(2,N-1):
  dplist[i]=min(dplist(i-1)+abs(H[i]-H[i-1]),dplist(i-2)+abs(H[i-2]-H[i]))
print(dplist[N-1])

Fixed submission:
N=int(input())
H=list(map(int,input().split()))
dplist=[0 for i in range(N)]
dplist[0]=0
dplist[1]=abs(H[1]-H[0])
for i in range(2,N):
  dplist[i]=min(dplist[i-1]+abs(H[i]-H[i-1]),dplist[i-2]+abs(H[i-2]-H[i]))
print(dplist[N-1])

Buggy python submission (verdict: Runtime Error):
N=int(input())
H=list(map(int,input().split()))
dplist=[0 for i in range(N)]
dplist[0]=0
dplist[1]=H[1]-H[0]
for i in range(2,N-1):
  dplist[i]=min(dplist(i-1)+abs(H[i]-H[i-1]),dplist(i-2)+abs(H[i-2]-H[i]))
print(dolist(N-1))

Fixed submission:
N=int(input())
H=list(map(int,input().split()))
dplist=[0 for i in range(N)]
dplist[0]=0
dplist[1]=abs(H[1]-H[0])
for i in range(2,N):
  dplist[i]=min(dplist[i-1]+abs(H[i]-H[i-1]),dplist[i-2]+abs(H[i-2]-H[i]))
print(dplist[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
s=str(input())
t=str(input())
ls=len(s)
lt=len(t)

dp=[[0 for i in range(lt+1)]for j in range(ls+1)]
for i in range(ls):
  for j in range(lt):
    if s[i]==t[j]:
      dp[i+1][j+1]=dp[i][j]+1
    else:
      dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j])

ans=""
x=ls
y=lt
while x>0 and y>0:
  if dp[x][y]==dp[x-1][y]:
    x-=1
  elif dp[x][y]==dp[x][y-1]:
    y-=1
  else:
    ans=s[x-1]+ans
    x-=1
    y-=1
print(ans)

Fixed submission:
s=str(input())
t=str(input())
ls=len(s)
lt=len(t)

dp=[[0 for i in range(lt+1)]for j in range(ls+1)]
for i in range(ls):
  for j in range(lt):
    if s[i]==t[j]:
      dp[i+1][j+1]=dp[i][j]+1
    else:
      dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j])

ans=""
x=ls
y=lt
while x>0 and y>0:
  if dp[x][y]==dp[x-1][y]:
    x-=1
  elif dp[x][y]==dp[x][y-1]:
    y-=1
  else:
    ans=s[x-1]+ans
    x-=1
    y-=1
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split())
B=[0]
for i in range(N):
  B+=[B[i]+A[i]]
C=[]
asn+=1      
for i in B:
  if i in C:
     ans+=1
  else:
     C+=[i]
print(ans)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
B=[0]
for i in range(N):
  B+=[B[i]+A[i]]
C=[]
ans=0      
B.sort()
c=1
for i in range(1,N+1):
  if B[i]==B[i-1]:
    c+=1
  else:
    ans+=c*(c-1)//2
    c=1
ans+=c*(c-1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
a=list(map(int,input().split()))
a=sorted(a)
Alice=0
Bob=0
Alice_turn=0
for i in range(N):
  if Alice_turn%2==even:
    Alice+=a[N-1-i]
    Alice_turn+=1
  else:
    Bob+=a[N-1-i]
print(Alice-Bob)

Fixed submission:
N=int(input())
a=list(map(int,input().split()))
na=sorted(a)
Alice=0
Bob=0
Alice_turn=0
for i in range(N):
  if Alice_turn%2==0:
    Alice+=na[N-1-i]
    Alice_turn+=1
  else:
    Bob+=na[N-1-i]
    Alice_turn+=1
print(Alice-Bob)
Buggy python submission (verdict: Runtime Error):
N=int(input())
L=list(map(int,input().split()))
counter=0
t=0
for p in range (30):
  t=0
  for i in range(N):
    if L[i]%2==0:
      t+=1
  if t==N:
    for i in range(N):
      L[i]=int(L[i]/2)
    counter+=1
print(counter)

Fixed submission:
S=str(input())
a=0
if S[0]=="1":
  a+=1
if S[1]=="1":
  a+=1
if S[2]=="1":
  a+=1
print(a)
Buggy python submission (verdict: Runtime Error):
ABCD=input()
L=list(ABCD)

def bfs(i,j,a,c):#i,hidari,migi
  if i==3:
    if j+int(L[3])==7:
      c+=[L[0]+a[0]+L[1]+a[1]+L[2]+"+"+L[3]+"=7"]
    elif j-int(L[3])==7:
      c+=[L[0]+a[0]+L[1]+a[1]+L[2]+"-"+L[3]+"=7"]
    return 
    
  else:
    bfs(i+1,j+int(L[i]),a+"+",c)
    bfs(i+1,j-int(L[i]),a+"-",c)
    return c[0]
  


print(bfs(1,int(L[0]),"",[]))

Fixed submission:
ABCD=input()
L=list(ABCD)

def bfs(i,j,a,c):#i,hidari,migi
  if i==3:
    if j+int(L[3])==7:
      c+=[L[0]+a[0]+L[1]+a[1]+L[2]+"+"+L[3]+"=7"]
    elif j-int(L[3])==7:
      c+=[L[0]+a[0]+L[1]+a[1]+L[2]+"-"+L[3]+"=7"]
    return 
    
  else:
    bfs(i+1,j+int(L[i]),a+"+",c)
    bfs(i+1,j-int(L[i]),a+"-",c)
    return c
  

d=[]

ans=bfs(1,int(L[0]),"",d)
print(d[0])
Buggy python submission (verdict: Time Limit Exceeded):
K,S=map(int,input().split())
ans=0
for i in range(K+1):
  for j in range(i,K+1):
    for k in range(j,K+1):
      if i+j+k==S:
        if i<j<k:
          ans+=6
        elif i<j==k or  i==j<k:
          ans+=3
        else:
          ans+=1
print(ans)

Fixed submission:
K,S=map(int,input().split())
ans=0
for i in range(K+1):
  for j in range(K+1):
    k=S-(i+j)
    if 0<=k<=K:
      ans+=1
print(ans)

Buggy python submission (verdict: Runtime Error):
K,S=map(int,input().split())
asn=0
for i in range(K+1):
  for j in range(i,K+1):
    for k in range(j,K+1):
      if i+j+k==S:
        if i<j<k:
          ans+=6
        elif i<j==k or  i==j<k:
          ans+=3
        else:
          ans+=1
print(ans)
          

Fixed submission:
K,S=map(int,input().split())
ans=0
for i in range(K+1):
  for j in range(K+1):
    k=S-(i+j)
    if 0<=k<=K:
      ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
N = input()
ans = 0
while N:
    ans += int(N[:-1])
    ans = ans % 9
    N = N[:-1]
if ans == 0:
    print('Yes')
else:
    print('No')


Fixed submission:
N = input()
ans = 0
while N:
    ans += int(N[-1])
    ans = ans % 9
    N = N[:-1]
if ans == 0:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ans = 0
while N >= 1:
    ans += N % 10
    ans = ans % 9
    N = N // 10
if ans == 0:
    print('Yes')
else:
    print('No')


Fixed submission:
N = input()
ans = 0
while N:
    ans += int(N[-1])
    ans = ans % 9
    N = N[:-1]
if ans == 0:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
cs = [i for i in input()]
cur = len(cs)-1
ans = 0
for i in range(len(cs)):
    if cs[i] == 'W':
        while(cs[cur] != 'R' or cur == i):
            cur -= 1
        ans += 1
        cur -= 1
    if i >= cur:
        break
print(ans)


Fixed submission:
N = int(input())
cs = [i for i in input()]
n_R = 0
for c in cs:
    if c == 'R':
        n_R += 1
n_n_R = 0
for i in range(n_R):
    if cs[i] == 'R':
        n_n_R += 1
print(n_R - n_n_R)

Buggy python submission (verdict: Runtime Error):
N = int(input())
cs = [i for i in input()]
cur = len(cs)-1
ans = 0
for i in range(len(cs)):
    if cs[i] == 'W':
        while(cs[cur] != 'R' or cur == i):
            cur -= 1
        ans += 1
        cur -= 1
    if i >= cur:
        break
print(ans)


Fixed submission:
N = int(input())
cs = [i for i in input()]
n_R = 0
for c in cs:
    if c == 'R':
        n_R += 1
n_n_R = 0
for i in range(n_R):
    if cs[i] == 'R':
        n_n_R += 1
print(n_R - n_n_R)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))
point = 1
for i in range(N):
    if i < K:
        point = point * A[i]
    else:
        pointed = point
        point = point * A[i] // A[i-K]
        if point > pointed:
            print('Yes')
        else:
            print('No')

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N):
    if i < K:
        continue
    if A[i] > A[i-K]:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Runtime Error):
array = [0 for i in range(11)]
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

for a in A:
    array[a] += 1
souwa = sum(A)

B = []
C = []
for i in range(Q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)

for i in range(Q):
    souwa = souwa + (C[i]-B[i])*array[B[i]]
    array[C[i]] += array[B[i]]
    array[B[i]] = 0
    print(souwa)


Fixed submission:
array = [0 for i in range(100001)]
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

for a in A:
    array[a] += 1
souwa = sum(A)

B = []
C = []
for i in range(Q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)

for i in range(Q):
    souwa = souwa + (C[i]-B[i])*array[B[i]]
    array[C[i]] += array[B[i]]
    array[B[i]] = 0
    print(souwa)

Buggy python submission (verdict: Runtime Error):
array = [0 for i in range(11)]
N = int(input())
A = list(map(int, input().split()))
for a in A:
    array[a] += 1

souwa = sum(A)
Q = int(input())
for i in range(Q):
    B, C = map(int, input().split())
    souwa = souwa + (C-B)*array[B]
    array[C] += array[B]
    array[B] = 0
    print(souwa)


Fixed submission:
array = [0 for i in range(100001)]
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

for a in A:
    array[a] += 1
souwa = sum(A)

B = []
C = []
for i in range(Q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)

for i in range(Q):
    souwa = souwa + (C[i]-B[i])*array[B[i]]
    array[C[i]] += array[B[i]]
    array[B[i]] = 0
    print(souwa)
Buggy python submission (verdict: Runtime Error):
n,m,k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

suma = [0] * n
sumb = [0] * m
suma[0] = a[0]
sumb[0] = b[0]

for i in range(1,n):
    suma[i] = suma[i-1]+a[i]
for j in range(1,m):
    sumb[j] = suma[j-1]+b[j]

    
ans, cur= 0, m-1
for i in range(n):
    target = k - suma[i]
    if (i > 0) & (target <= 0):
        break
    for j in range(cur,-1,-1):
        if sumb[j] <= target:
            ans = max(ans, i+j+2)
            cur = j
            break
        else:
          	ans = i+1
print(ans)

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

suma = [0] * (n)
sumb = [0] * (m)
suma[0] = a[0]
sumb[0] = b[0]

for i in range(1,n):
    suma[i] = suma[i-1]+a[i]
for j in range(1,m):
    sumb[j] = sumb[j-1]+b[j]
    
suma.insert(0,0)
sumb.insert(0,0)

ans, cur = 0, m
for i in range(n+1):
  target = k - suma[i]
  if target < 0:
      break
  while sumb[cur] > target:
      cur -= 1
  ans = max(ans, i+cur)
print(ans)

Buggy python submission (verdict: Runtime Error):
n,m,k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

suma = [0] * n
sumb = [0] * m
suma[0] = a[0]
sumb[0] = b[0]

for i in range(1,n):
    suma[i] = suma[i-1]+a[i]
for j in range(1,m):
    sumb[j] = suma[j-1]+b[j]

    
ans, cur= 0, m-1
for i in range(n):
    target = k - suma[i]
    if target <= 0:
        break
    for j in range(cur,-1,-1):
        if sumb[j] <= target:
            ans = max(ans, i+j+2)
            cur = j
            break
print(ans)

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

suma = [0] * (n)
sumb = [0] * (m)
suma[0] = a[0]
sumb[0] = b[0]

for i in range(1,n):
    suma[i] = suma[i-1]+a[i]
for j in range(1,m):
    sumb[j] = sumb[j-1]+b[j]
    
suma.insert(0,0)
sumb.insert(0,0)

ans, cur = 0, m
for i in range(n+1):
  target = k - suma[i]
  if target < 0:
      break
  while sumb[cur] > target:
      cur -= 1
  ans = max(ans, i+cur)
print(ans)

Buggy python submission (verdict: Runtime Error):
n,m,k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

suma = [0] * n
sumb = [0] * m
suma[0] = a[0]
sumb[0] = b[0]

for i in range(1,n):
    suma[i] = suma[i-1]+a[i]
for j in range(1,m):
    sumb[j] = suma[j-1]+b[j]

ans, cur= 0, m-1
for i in range(n):
    target = k - suma[i]
    for j in range(cur,-1,-1):
        if sumb[j] <= target:
            ans = max(ans, i+j+2)
            cur = j
            break
print(ans)


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

suma = [0] * (n)
sumb = [0] * (m)
suma[0] = a[0]
sumb[0] = b[0]

for i in range(1,n):
    suma[i] = suma[i-1]+a[i]
for j in range(1,m):
    sumb[j] = sumb[j-1]+b[j]
    
suma.insert(0,0)
sumb.insert(0,0)

ans, cur = 0, m
for i in range(n+1):
  target = k - suma[i]
  if target < 0:
      break
  while sumb[cur] > target:
      cur -= 1
  ans = max(ans, i+cur)
print(ans)
Buggy python submission (verdict: Runtime Error):
x, y = map(int, input().split())
if (y-x) > =x:
  print "Yes"
else:
  print "No"

Fixed submission:
x, y = map(int, input().split())
if y%2 == 1:
  print("No")
  exit()
b = y//2 -x
a = x - b
if (a >= 0) & (b >= 0):
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
x, y = map(int, input())
if (y-x) > =x:
  print "Yes"
else:
  print "No"

Fixed submission:
x, y = map(int, input().split())
if y%2 == 1:
  print("No")
  exit()
b = y//2 -x
a = x - b
if (a >= 0) & (b >= 0):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = a[0]
for i in a[1:]:
  ans = ans*i
if ans > 10**18:
	print(-1)
else:
  	print(ans)

Fixed submission:
import sys
n = int(input())
a = list(map(int, input().split()))
if 0 in a:
  print(0)
  sys.exit()
ans = a[0]
for i in a[1:]:
    ans = ans*i
    if ans > 10**18:
        print(-1)
        break
else:
  	print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
 
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    acopy = a.copy()
    del acopy[i]
    c = collections.Counter(acopy)
    itm = c.values()
    ans = 0
    for j in itm:
        ans += j*(j-1)//2
    print(ans)

Fixed submission:
import collections
n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)
v = c.values()
s = 0
for i in v:
    s += (i*(i-1))//2

for i in range(n):
    d = c[a[i]]
    x = (d*(d-1))//2 if d > 1 else 0
    y = ((d-1)*(d-2))//2 if d > 2 else 0
    print(s-x+y)

Buggy python submission (verdict: Runtime Error):
import collections

sys.stdin = io.StringIO(_INPUT)
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    acopy = a.copy()
    del acopy[i]
    c = collections.Counter(acopy)
    itm = c.values()
    ans = 0
    for j in itm:
        ans += j*(j-1)//2
    print(ans)

Fixed submission:
import collections
n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)
v = c.values()
s = 0
for i in v:
    s += (i*(i-1))//2

for i in range(n):
    d = c[a[i]]
    x = (d*(d-1))//2 if d > 1 else 0
    y = ((d-1)*(d-2))//2 if d > 2 else 0
    print(s-x+y)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    acopy = a.copy()
    del acopy[i]
    c = collections.Counter(acopy)
    itm = c.values()
    ans = 0
    for j in itm:
        ans += j*(j-1)//2
    print(ans)


Fixed submission:
import collections
n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)
v = c.values()
s = 0
for i in v:
    s += (i*(i-1))//2

for i in range(n):
    d = c[a[i]]
    x = (d*(d-1))//2 if d > 1 else 0
    y = ((d-1)*(d-2))//2 if d > 2 else 0
    print(s-x+y)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

for i in range(n):
  ans = 0
  acopy = a.copy()
  del acopy[i]
  m = [x for x in set(acopy) if acopy.count(x) > 1]
  for j in range(len(m)):
    k = acopy.count(m[j])
    ans += k*(k-1)//2
  print(ans)

Fixed submission:
import collections
n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)
v = c.values()
s = 0
for i in v:
    s += (i*(i-1))//2

for i in range(n):
    d = c[a[i]]
    x = (d*(d-1))//2 if d > 1 else 0
    y = ((d-1)*(d-2))//2 if d > 2 else 0
    print(s-x+y)
Buggy python submission (verdict: Runtime Error):
import io
import sys

n, m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]

d = {}

for i in range(1, n + 1):
    d[i] = None

for itm in sc:
    if (d[itm[0]] == None) | (d[itm[0]] == itm[1]):
        d[itm[0]] = itm[1]
    else:
        print(-1)
        sys.exit()

l = list(d.values())
if l == [0]:
    print(0)
elif l[0] == 0:
    print(-1)
else:
    l = [0 if x == None else x for x in l]
    l[0] = [1 if x == 0 else x for x in l]
    l = map(str, l)
    print("".join(l))


Fixed submission:
n = int(input())
print((n+1)//2)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int, input().split()))

l = p[0:k]
l_sum = [sum(l)]
for i in range(k, n):
    l.pop(0)
    l.append(p[i])
    l_sum.append(sum(l))
ans = (max(l_sum)+k)/2
print(ans)


Fixed submission:
n, k = map(int, input().split())
p = list(map(int, input().split()))

p = list(map(lambda x: (1+x)/2, p))
s = [0]
num = 0
for i in range(n):
  num += p[i]
  s.append(num)
l = []
for i in range(n - k + 1):
  l.append(s[i+k]-s[i])

print(max(l))

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int, input().split()))

l = []
for i in range(n - k + 1):
    l.append(sum(p[i:i + k]))
ans = (max(l)+k)/2
print(ans)


Fixed submission:
n, k = map(int, input().split())
p = list(map(int, input().split()))

p = list(map(lambda x: (1+x)/2, p))
s = [0]
num = 0
for i in range(n):
  num += p[i]
  s.append(num)
l = []
for i in range(n - k + 1):
  l.append(s[i+k]-s[i])

print(max(l))
Buggy python submission (verdict: Time Limit Exceeded):
s = str(input())

l = [1 if c == "<" else -1 for c in list(s)]

def leftmore(i):
    num = 0
    while True:
        if i == 0:
            break
        elif s[i-1] == "<":
            i -= 1
            num += 1
        else:
            break
    return num

def rightless(i):
    num = 0
    while True:
        if i == len(s):
            break
        elif s[i] == ">":
            i += 1
            num += 1
        else:
            break
    return num

sumlist = [0] * (len(s)+1)
for i in range(len(sumlist)):
    sumlist[i] = max(leftmore(i),rightless(i))


print(sum(sumlist))

Fixed submission:
s = str(input())
#s = "<>>><<><<<<<>>><"
ans = 0
def leftmore(ln):
    ret = [0]
    cur = 0
    for c in ln:
        if c == "<":
            cur += 1
        else:
            cur = 0
        
        ret.append(cur)
    return ret

def rightless(ln):
    revl = reversed(ln)
    ret = [0]
    cur = 0
    for c in revl:
        if c == ">":
            cur += 1
        else:
            cur = 0
        ret.append(cur)
    return list(reversed(ret))

lm = leftmore(s)
rl = rightless(s)
for i in range(len(s)+1):
    ans += max(lm[i],rl[i])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = str(input())
l = [1 if c == "<" else -1 for c in list(s)]

def leftmore(i):
    num = 0
    while True:
        if i == 0:
            break
        elif s[i-1] == "<":
            i -= 1
            num += 1
        else:
            break
    return num

def rightless(i):
    num = 0
    while True:
        if i == len(s):
            break
        elif s[i] == ">":
            i += 1
            num += 1
        else:
            break
    return num

sumlist = [0] * (len(s)+1)
for i in range(len(sumlist)):
    sumlist[i] = max(leftmore(i),rightless(i))


print(sum(sumlist))

Fixed submission:
s = str(input())
#s = "<>>><<><<<<<>>><"
ans = 0
def leftmore(ln):
    ret = [0]
    cur = 0
    for c in ln:
        if c == "<":
            cur += 1
        else:
            cur = 0
        
        ret.append(cur)
    return ret

def rightless(ln):
    revl = reversed(ln)
    ret = [0]
    cur = 0
    for c in revl:
        if c == ">":
            cur += 1
        else:
            cur = 0
        ret.append(cur)
    return list(reversed(ret))

lm = leftmore(s)
rl = rightless(s)
for i in range(len(s)+1):
    ans += max(lm[i],rl[i])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())
a = list(map(int, input().split()))
for _ in range(m):
    i = a.index(max(a))
    a[i] = a[i]//2
print(sum(a))

Fixed submission:
n,m = map(int, input().split())
a = list(map(lambda x:int(x)*(-1), input().split()))
import heapq
heapq.heapify(a)
for _ in range(m):
    num = heapq.heappop(a)
    heapq.heappush(a,(-num//2)*(-1))
print(-sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())
a = list(map(int, input().split()))
for _ in range(m):
    a.sort(reverse=True)
    amax = a[0]
    a.pop(0)
    a.append(amax//2)
print(sum(a))

Fixed submission:
n,m = map(int, input().split())
a = list(map(lambda x:int(x)*(-1), input().split()))
import heapq
heapq.heapify(a)
for _ in range(m):
    num = heapq.heappop(a)
    heapq.heappush(a,(-num//2)*(-1))
print(-sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
import sys 
def get_string(): return sys.stdin.readline().strip() 
  
string = get_string()
n=int(string)
s=0
while n>0:
    s=s+n%10
    n=n//10
if s%9==0:
    print('Yes')
else:
    print('No')

Fixed submission:
import sys 
def get_string(): return sys.stdin.readline().strip() 
  
string = get_string()
s=0
while string!='':
    s=s+int(string[-1])
    string=string[:-1]
if s%9==0:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
n=long(input())
s=0
while n>0:
    s=s+n%10
    n=n//10
if s%9==0:
    print('Yes')
else:
    print('No')

Fixed submission:
import sys 
def get_string(): return sys.stdin.readline().strip() 
  
string = get_string()
s=0
while string!='':
    s=s+int(string[-1])
    string=string[:-1]
if s%9==0:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=0
while n>0:
    s=s+n%10
    n=n//10
if s%9==0:
    print('Yes')
else:
    print('No')

Fixed submission:
import sys 
def get_string(): return sys.stdin.readline().strip() 
  
string = get_string()
s=0
while string!='':
    s=s+int(string[-1])
    string=string[:-1]
if s%9==0:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
h,w,m=list(map(int,input().split()))
b=[]
r=[0]*(10**5+1)
c=[0]*(10**5+1)
for i in range(m):
    h,w=list(map(int,input().split()))
    r[h]=r[h]+1
    c[w]=c[w]+1
    b.append([h,w])
if max(r)>max(c):
    j=r.index(max(r))
    for i in range(len(b)):
        if b[i][0]==j:
            c[b[i][1]]=c[b[i][1]]-1
    i=c.index(max(c))
else:
    i=c.index(max(c))
    for j in range(len(b)):
        if b[j][1]==i:
            r[b[j][0]]=r[b[j][0]]-1
    j=r.index(max(r))
print(r[j]+c[i])

Fixed submission:
h,w,m=list(map(int,input().split()))
b=[]
r=[0]*(3*10**5+2)
c=[0]*(3*10**5+2)
for i in range(m):
    h,w=list(map(int,input().split()))
    r[h]=r[h]+1
    c[w]=c[w]+1
    b.append([h,w])
if max(r)>max(c):
    j=r.index(max(r))
    for i in range(len(b)):
        if b[i][0]==j:
            c[b[i][1]]=c[b[i][1]]-1
else:
    i=c.index(max(c))
    for j in range(len(b)):
        if b[j][1]==i:
            r[b[j][0]]=r[b[j][0]]-1
print(max(r)+max(c))