Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
h_input = list(map(int,input().split()))
A = [0]*m
B = [0]*m
for i in range(m):
    A[i],B[i] = map(int,input().split())

ans=0
for i in range(n):
    h1 = h_input[i]
    h2 = 0
    flag = True
    for j in range(m):
        if A[j]-1==i:
            h2 = h_input[B[j]-1]
        if B[j]-1==i:
            h2 = h_input[A[j]-1]
        if h2>=h1:
            flag=False
            break
    if flag:
        ans+=1
        
print(ans)

Fixed submission:
n,m = map(int,input().split())
h_inputs = [int(i) for i in input().split()]
ab_inputs = [[int(j) for j in input().split()]for i in range(m)]

map_li = [1]*n
for line in ab_inputs:
    a,b = line[0],line[1]
    if h_inputs[a-1]>h_inputs[b-1]:
        map_li[b-1]=0
    if h_inputs[a-1]<h_inputs[b-1]:
        map_li[a-1]=0
    if h_inputs[a-1]==h_inputs[b-1]:
        map_li[a-1]=0
        map_li[b-1]=0
print(sum(map_li))

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
h_inputs = [int(i) for i in input().split()]
ab_inputs = [[int(j) for j in input().split()]for i in range(m)]

map_li = [[0 for i in range(n)] for i in range(n)]
ans = 0
for line in ab_inputs:
    a,b = line[0],line[1]
    c,d = h_inputs[a-1],h_inputs[b-1]
    if c==d:
        map_li[a-1][b-1]=-1
        map_li[b-1][a-1]=-1
    else:
        map_li[a-1][b-1]=c-d
        map_li[b-1][a-1]=d-c

for i in range(n):
    if all(m>=0 for m in map_li[i]):
        ans+=1
print(ans)

Fixed submission:
n,m = map(int,input().split())
h_inputs = [int(i) for i in input().split()]
ab_inputs = [[int(j) for j in input().split()]for i in range(m)]

map_li = [1]*n
for line in ab_inputs:
    a,b = line[0],line[1]
    if h_inputs[a-1]>h_inputs[b-1]:
        map_li[b-1]=0
    if h_inputs[a-1]<h_inputs[b-1]:
        map_li[a-1]=0
    if h_inputs[a-1]==h_inputs[b-1]:
        map_li[a-1]=0
        map_li[b-1]=0
print(sum(map_li))

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
h_inputs = [int(i) for i in input().split()]
ab_inputs = [[int(j) for j in input().split()]for i in range(m)]

map_li = [[0 for i in range(n)] for i in range(n)]
ans = 0
for line in ab_inputs:
    a,b = line[0],line[1]
    map_li[a-1][b-1]=1
    map_li[b-1][a-1]=1

for i in range(n):
    tmp = 1
    for j in range(n):
        if map_li[i][j]==1:
            if h_inputs[i]<=h_inputs[j]:
                tmp=0
    if tmp==1:
        ans+=1
print(ans)


Fixed submission:
n,m = map(int,input().split())
h_inputs = [int(i) for i in input().split()]
ab_inputs = [[int(j) for j in input().split()]for i in range(m)]

map_li = [1]*n
for line in ab_inputs:
    a,b = line[0],line[1]
    if h_inputs[a-1]>h_inputs[b-1]:
        map_li[b-1]=0
    if h_inputs[a-1]<h_inputs[b-1]:
        map_li[a-1]=0
    if h_inputs[a-1]==h_inputs[b-1]:
        map_li[a-1]=0
        map_li[b-1]=0
print(sum(map_li))
Buggy python submission (verdict: Runtime Error):
x = int(input())

if x==1:
    print(0,-1);exit()

num_li = [i**5 for i in range(1,100)]

for i in range(100):
    a = num_li[i]
    if x-a in num_li:
        b = num_li.index(x-a)+1
        a = -(num_li.index(a)+1)
        break
    if x+a in num_li:
        b = num_li.index(x+a)+1
        a = num_li.index(a)+1
        break

print(b,a)

Fixed submission:
x = int(input())

if x==1:
    print(0,-1);exit()

num_li = [i**5 for i in range(1,1000)]

for i in range(1000):
    a = num_li[i]
    if x-a in num_li:
        b = num_li.index(x-a)+1
        a = -(num_li.index(a)+1)
        break
    if x+a in num_li:
        b = num_li.index(x+a)+1
        a = num_li.index(a)+1
        break

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

ans=0
for i in range(n):
    a = a_input[i]
    for idx,j in enumerate(range(i+1,n),1):
        if idx-a==a_input[j]:
            ans+=1
print(ans)

Fixed submission:
n = int(input())
a_inputs = [int(i) for i in input().split()]

dic_l={}
dic_r={}
for i in range(n):
    a = a_inputs[i]+(i+1)
    b = (i+1)-a_inputs[i]
    dic_l[a]=dic_l.get(a,0)+1
    dic_r[b]=dic_r.get(b,0)+1

ans=0
for key in dic_l.keys():
    ans+=dic_l[key]*dic_r.get(key,0)
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_inputs = [int(i) for i in input().split()]

ai_li = [a_inputs[i]+(i+1) for i in range(n)]
aj_li = [(j+1)-a_inputs[j] for j in range(n)]

ans=0
for a in ai_li:
    if a in aj_li:
        ans+=aj_li.count(a)
print(ans)

Fixed submission:
n = int(input())
a_inputs = [int(i) for i in input().split()]

dic_l={}
dic_r={}
for i in range(n):
    a = a_inputs[i]+(i+1)
    b = (i+1)-a_inputs[i]
    dic_l[a]=dic_l.get(a,0)+1
    dic_r[b]=dic_r.get(b,0)+1

ans=0
for key in dic_l.keys():
    ans+=dic_l[key]*dic_r.get(key,0)
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_inputs = [int(i) for i in input().split()]

map_li = [[0 for i in range(n)] for j in range(n)]
ans = 0
for i in range(1,n+1):
    for j in range(i,n+1):
        if abs(a_inputs[i-1]+a_inputs[j-1])==(abs(i-j)):
            ans+=1
print(ans)

Fixed submission:
n = int(input())
a_inputs = [int(i) for i in input().split()]

dic_l={}
dic_r={}
for i in range(n):
    a = a_inputs[i]+(i+1)
    b = (i+1)-a_inputs[i]
    dic_l[a]=dic_l.get(a,0)+1
    dic_r[b]=dic_r.get(b,0)+1

ans=0
for key in dic_l.keys():
    ans+=dic_l[key]*dic_r.get(key,0)
    
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
a,b,n = map(int,input().split())

for i in range(n,0,-1):
    if a*math.floor(i/b)<math.floor(a*i/b):
        ans=math.floor(a*i/b)-a*math.floor(i/b)
        break

print(ans)

Fixed submission:
import math
a,b,n = map(int,input().split())

ans = math.floor(a*min((b-1),n)/b)
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
a,b,n = map(int,input().split())

for i in range(n,1,-1):
    if a*math.floor(i/b)<math.floor(a*i/b):
        ans=math.floor(a*i/b)-a*math.floor(i/b)
        break

print(ans)

Fixed submission:
import math
a,b,n = map(int,input().split())

ans = math.floor(a*min((b-1),n)/b)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
import itertools

k = int(input())

gcd_map = [[-1 for i in range(1,k+1)]for j in range(1,k+1)]

ans = 0
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            if gcd_map[a-1][b-1]==-1:
                gab = fractions.gcd(a,b)
                gcd_map[a-1][b-1] = gab
                gcd_map[b-1][a-1] = gab
            
            else:
                gab = gcd_map[a-1][b-1]
            
            if gcd_map[gab-1][c-1]==-1:
                gbc = fractions.gcd(gab,c)
                gcd_map[gab-1][c-1] = gbc
                gcd_map[c-1][gab-1] = gbc

            else:
                gbc = gcd_map[gab-1][c-1]

            ans+=gbc
print(ans)
            


Fixed submission:
import math

k = int(input())
ans = 0
for a in range(1,k+1):
    for b in range(1,k+1):
        g = math.gcd(a,b)
        for c in range(1,k+1):
            ans += math.gcd(g,c)
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import deque
 
n = int(input())
 
def dfs(n):
  stack = deque()
  stack.append("a")
  while stack:
    q = stack.popleft()
    if len(q) == n:
      ans.append(q) 
    if len(q) < n:
      for i in range(ord("a"), ord(max(q)) + 2):
        stack.append(q + chr(i))
    print(stack)
    
ans = []
dfs(n)
 
print("\n".join(ans))

Fixed submission:
from collections import deque
 
n = int(input())
 
def dfs(n):
  stack = deque()
  stack.append("a")
  while stack:
    q = stack.popleft()
    if len(q) == n:
      ans.append(q) 
    if len(q) < n:
      for i in range(ord("a"), ord(max(q)) + 2):
        stack.append(q + chr(i))
    #print(stack)
    
ans = []
dfs(n)
 
print("\n".join(ans))
Buggy python submission (verdict: Runtime Error):
s = input()

for i in range(0,len(s),2):
    if s[i]=='h' and s[i+1]=='i':
        continue
    else:
        print('No');exit()
print('Yes')

Fixed submission:
s = input()

if len(s)%2!=0:
    print('No');exit()
for i in range(0,len(s),2):
    if s[i]=='h' and s[i+1]=='i':
        continue
    else:
        print('No');exit()
print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())

tmp = 1
for i in range(q):
    x = input()
    if x[0]==str(1):
        tmp*=-1
    else:
        t,f,c = x.split()
        t,f = int(t),int(f)
        if tmp==-1:
            if f==1:
                s = s+c
            if f==2:
                s = c+s
        if tmp==1:
            if f==1:
                s = c+s
            if f==2:
                s = s+c

print(s[::tmp])




Fixed submission:
from collections import deque
s = input()
q = int(input())
queue = deque([s])

tmp = 1
for i in range(q):
    x = input()
    if x[0]==str(1):
        tmp*=-1
    else:
        t,f,c = x.split()
        t,f = int(t),int(f)
        if tmp==-1:
            if f==1:
                queue.append(c)
            if f==2:
                queue.appendleft(c)
        if tmp==1:
            if f==1:
                queue.appendleft(c)
            if f==2:
                queue.append(c)

print(''.join(queue)[::tmp])

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())
T = [0]*q
F = [0]*q
C = ['' for i in range(q)]

for i in range(q):
    x = input()
    if x[0]==str(1):
        T[i]=1
    else:
        t,f,c = x.split()
        T[i],F[i],C[i] = int(t),int(f),c

tmp = 1
for i in range(q):
    if T[i]==1:
        tmp*=-1
    if T[i]==2:
        if tmp==-1:
            if F[i]==1:
                s = s+C[i]
            if F[i]==2:
                s = C[i]+s
        if tmp==1:
            if F[i]==1:
                s = C[i]+s
            if F[i]==2:
                s = s+C[i]

print(s[::tmp])

Fixed submission:
from collections import deque
s = input()
q = int(input())
queue = deque([s])

tmp = 1
for i in range(q):
    x = input()
    if x[0]==str(1):
        tmp*=-1
    else:
        t,f,c = x.split()
        t,f = int(t),int(f)
        if tmp==-1:
            if f==1:
                queue.append(c)
            if f==2:
                queue.appendleft(c)
        if tmp==1:
            if f==1:
                queue.appendleft(c)
            if f==2:
                queue.append(c)

print(''.join(queue)[::tmp])
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
sc_inputs = [[int(j) for j in input().split()] for i in range(m)]

dic={}
for sc in sc_inputs:
    s,c = map(int,sc)
    if s in dic and dic.get(s)!=c:
        print(-1);exit()
    dic[s]=c

if dic[1]==0:
    print(-1);exit()
ans=float('inf')
for i in range(10**(n-1),10**n):
    s = str(i)
    flag = True
    for key,value in dic.items():
        if s[key-1]!=str(value):
            flag=False
    if flag:
        ans=min(ans,int(s))
print(ans)
    




Fixed submission:
import sys
N, M = map(int, input().split())
S = [0] * M
C = [0] * M
for i in range(M):
    S[i], C[i] = map(int, input().split())

for i in range(1000):
    string = str(i)
    if len(string) != N:
        continue
    flag = True
    for j in range(M):
        if string[S[j] - 1] == str(C[j]):
            None
        else:
            flag = False
            break
    if flag:
        print(i)
        sys.exit(0)
print("-1")

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
sc_inputs = [[int(j) for j in input().split()] for i in range(m)]

dic={}
for sc in sc_inputs:
    s,c = map(int,sc)
    if s in dic and dic.get(s)!=c:
        print(-1);exit()
    dic[s]=c

if dic[1]==0:
    print(-1);exit()
for i in range(10**(n-1),10**n):
    s = str(i)
    flag = True
    for key,value in dic.items():
        if s[key-1]!=str(value):
            flag=False
    if flag:
        print(s);exit()
    




Fixed submission:
import sys
N, M = map(int, input().split())
S = [0] * M
C = [0] * M
for i in range(M):
    S[i], C[i] = map(int, input().split())

for i in range(1000):
    string = str(i)
    if len(string) != N:
        continue
    flag = True
    for j in range(M):
        if string[S[j] - 1] == str(C[j]):
            None
        else:
            flag = False
            break
    if flag:
        print(i)
        sys.exit(0)
print("-1")
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
s_inputs = [input() for i in range(n)]

s_dic = Counter(s_inputs)
print('\n'.join(sorted([k for k,v in s_dic.items() if v==max(s_dic.values())])))

Fixed submission:
from collections import Counter
n = int(input())
s_inputs = [input() for i in range(n)]

s_dic = Counter(s_inputs)
s_max = max(s_dic.values())
print('\n'.join(sorted([k for k,v in s_dic.items() if v==s_max])))
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
p_input = list(map(int,input().split()))

#p_iの期待値は(1+p_i)/2で求められる
ans=0

expected_value=[0]*n
for i in range(n-k+1):
    if i==0:
        for j in range(i+n-1):
            expected_value[j]=(1+p_input[j])/2
    expected_value[i+k-1]=(1+p_input[i+k-1])/2
    ans = max(sum(expected_value[i:i+k]),ans)

print(ans)







Fixed submission:
n,k = map(int,input().split())
p_input = list(map(lambda x:(int(x)+1)/2,input().split()))

#p_iの期待値は(1+p_i)/2で求められる
ans=0
sum_expected=[0]*(n-k+1)
for i in range(n-k+1):
    if i==0:
        sum_expected[0]=sum(p_input[:k])
    else:
        sum_expected[i]=sum_expected[i-1]-p_input[i-1]+p_input[i+k-1]

print(max(sum_expected))
Buggy python submission (verdict: Time Limit Exceeded):
h,n = map(int,input().split())

ab_input = [[int(j) for j in input().split()] for i in range(n)]
#配るdp
dp =[10**10]*(h+1)
dp[0]=0
for i in range(h):
    for a,b in ab_input:
        next_index=min(h,i+a)
        dp[next_index]=min(dp[next_index],dp[i]+b)
print(dp[-1])


    

Fixed submission:
h,n = map(int,input().split())

ab_input = [list(map(int,input().split())) for i in range(n)]
max_d = max(a for a,b in ab_input)
#配るdp
dp =[0]*(h+max_d)
for i in range(1,h+max_d):
    dp[i]=min(dp[i-a]+b for a,b in ab_input)
print(dp[h])

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

a_li = [0]*n
b_li = [0]*n

for i in range(n):
    a_li[i],b_li[i] = map(int,input().split())
#配るdp
dp =[10**10]*(h+1)
dp[0]=0
for i in range(h):
    for j in range(n):
        next_index=min(h,i+a_li[j])
        dp[next_index]=min(dp[next_index],dp[i]+b_li[j])
print(dp[-1])


Fixed submission:
h,n = map(int,input().split())

ab_input = [list(map(int,input().split())) for i in range(n)]
max_d = max(a for a,b in ab_input)
#配るdp
dp =[0]*(h+max_d)
for i in range(1,h+max_d):
    dp[i]=min(dp[i-a]+b for a,b in ab_input)
print(dp[h])

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

a_li = [0]*n
b_li = [0]*n

for i in range(n):
    a_li[i],b_li[i] = map(int,input().split())
#もらうdp
dp =[10**10]*(h+1)
dp[-1]=0
for i in range(h,-1,-1):
    for j in range(n):
        if i-a_li[j]<=0:
            d=0
        else:
            d=i-a_li[j]
        dp[d]=min(dp[d],dp[i]+b_li[j])
print(dp[0])


    

Fixed submission:
h,n = map(int,input().split())

ab_input = [list(map(int,input().split())) for i in range(n)]
max_d = max(a for a,b in ab_input)
#配るdp
dp =[0]*(h+max_d)
for i in range(1,h+max_d):
    dp[i]=min(dp[i-a]+b for a,b in ab_input)
print(dp[h])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p_inputs = [int(i) for i in input().split()]

ans=0
for i in range(n):
    if p_inputs[i]<=min(p_inputs[:i+1]):
        ans+=1
print(ans)

Fixed submission:
n = int(input())
p_inputs = [int(i) for i in input().split()]

min_num=p_inputs[0]
ans=0

for i in range(n):
    if p_inputs[i]<=min_num:
        ans+=1
        min_num=p_inputs[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import deque
h,w = map(int,input().split())
s_input = [list(input()) for i in range(h)]

mx = [0,0,1,-1]
my = [1,-1,0,0]

ans = 0
for i in range(h):
    for j in range(w):
        if s_input[i][j]=='#':
            continue
        queue = deque()
        queue.append([j,i])

        visited = [[-1]*w for i in range(h)]
        visited[i][j]=0

        res = 0
        while queue:
            y,x = queue.popleft()
            for k in range(4):
                nx = x+mx[k]
                ny = y+my[k]
                if 0<=nx<w and 0<=ny<h:
                    if visited[ny][nx]!=-1:
                        continue
                    if s_input[ny][nx]=='#':
                        continue
                    visited[ny][nx]=visited[y][x]+1
                    queue.append([nx,ny])
                    res = max(res,visited[ny][nx])
        ans = max(ans,res)
print(ans)




Fixed submission:
from collections import deque
h,w = map(int,input().split())
s_input = [list(input()) for i in range(h)]

mx = [0,0,1,-1]
my = [1,-1,0,0]

ans = 0
for i in range(h):
    for j in range(w):
        if s_input[i][j]=='#':
            continue
        queue = deque()
        queue.append([j,i])

        visited = [[-1]*w for i in range(h)]
        visited[i][j]=0

        res = 0
        while queue:
            x,y = queue.popleft()
            for k in range(4):
                nx = x+mx[k]
                ny = y+my[k]
                if 0<=nx<w and 0<=ny<h:
                    if visited[ny][nx]!=-1:
                        continue
                    if s_input[ny][nx]=='#':
                        continue
                    visited[ny][nx]=visited[y][x]+1
                    queue.append([nx,ny])
                    res = max(res,visited[ny][nx])
        ans = max(ans,res)
print(ans)
Buggy python submission (verdict: Runtime Error):
n,a,b = map(int,input().split())

#場合分けで考える
#中央にお互い移動する
#aorbが端まで移動して、その後お互いによる

dist = []
if (b-a)%2==0:
    d = (b-a)/2
    dist.append(d)
#aのほうが近い場合
if a-1<=n-b:
    a_dist = a-1
    re_b = b-a_dist
    if (re_b-1)%2==0:
        d = a_dist+(re_b-1)/2
    else:
        d = a_dist+(re_b-2)/2+1
    dist.append(d)
if a-1>n-b:
    b_dist = n-b
    re_a = a-b_dist
    if (n-re_a)%2==0:
        d = b_dist+(n-re_a)/2
    else:
        d = a_dist+(n-re_a-1)/2+1
    dist.append(d)
print(int(min(dist)))

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

#場合分けで考える
#b-aが偶数の場合、お互いに移動すればよい
#b-aが奇数の場合、末端に近いほうが端まで移動し、その後いターン消費して、距離をお互いに詰める

if (b-a)%2==0:
    ans = int((b-a)//2)
else:
    #端までの距離が近いほうの移動ステップ
    #端まで移動した際のお互いの距離は変化していない、そこから1ターン消費する
    #距離が偶数になるのでお互いに移動する
    ans = int(min(a-1,n-b)+1+(b-a-1)//2)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
x=int(input())

ans=0
for i in range(x//105+1):
    for j in range(x//104+1):
        for k in range(x//103+1):
            for l in range(x//102+1):
                for m in range(x//101+1):
                    for n in range(x//100+1):
                        if i*105+j*104+k*103+l*102+m*101+n*100==x:
                            ans=1
                            break

print(ans)

Fixed submission:
x=int(input())

num = x//100
div = x%100
ans=0

if  0<=div<=(num*5):
    ans=1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    S = input()

    import re
    num_li = [False]*1000
    for i in range(1000):
        pattern = r'{0[0]}.*{0[1]}.*{0[2]}'.format(list('{:3d}'.format(i))).replace(' ','0')
        # print(i,pattern)
        if re.search(pattern,S):
            num_li[i]=True
            
    print(sum(num_li))

if __name__=='__main__':
    main()

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    S = input()

    import re
    num_li = [False]*1000
    for i in range(10):
        first_ = S.find(str(i),0,N-2)
        if first_==-1:
            continue
        for j in range(10):
            second_ = S.find(str(j),first_+1,N-1)
            if second_==-1:
                continue
            for k in range(10):
                third_ = S.find(str(k),second_+1,N)
                if third_==-1:
                    continue
                num_li[i*100+j*10+k]=True
            
    print(sum(num_li))

if __name__=='__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_inputs = list(map(int,input().split()))
len_bar = sum(a_inputs)

gap = float('inf')
for i in range(n-1):
    g = abs(len_bar-2*sum(a_inputs[:i+1]))
    if g<gap:
        gap=g
print(gap)


Fixed submission:
n = int(input())
a_inputs = list(map(int,input().split()))
len_bar = sum(a_inputs)

cum_bar = [0]*n
cum_bar[0]=a_inputs[0]
for i in range(1,n):
    cum_bar[i]=cum_bar[i-1]+a_inputs[i]

gap = float('inf')
for i in range(n-1):
    g = abs(len_bar-2*cum_bar[i])
    if g<gap:
        gap=g
print(gap)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s)

s='|'+s+'|'

dp=[0]*(n+1)

#数列aの各項a_iについて、左右に連続する'<<<','>>>'の数をそれぞれカウント、
#その最大がa_iの最小値となる
for i in range(n+1):
    max_l=0
    max_r=0
    for l in range(i,-1,-1):
        if s[l]!='<':
            break
        max_l+=1
    for r in range(i+1,n+2):
        if s[r]!='>':
            break
        max_r+=1
    dp[i]=max(max_l,max_r)
#print(dp)
print(sum(dp))



Fixed submission:
s = input()
n = len(s)

s='|'+s+'|'

dp=[0]*(n+1)

#数列aの各項a_iについて、左右に連続する'<<<','>>>'の数をそれぞれカウント、
#その最大がa_iの最小値となる
R = [0]*(n+1)
L = [0]*(n+1)

#left count <<<
for i in range(1,n+1):
    if s[i]=='<':
        L[i] = L[i-1]+1
    else:
        L[i]=0
#right count >>>
for i in range(n-1,-1,-1):
    if s[i+1]=='>':
        R[i] = R[i+1]+1
    else:
        R[i]=0
ans=0
for i in range(n+1):
    ans+=max(R[i],L[i])
#print(L,R,s)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
L = list(map(int,input().split()))

ans = 0
for i in range(n):
    a = L[i]
    for j in range(i+1,n):
        b = L[j]
        for k in range(j+1,n):
            c = L[k]
            if a<b+c and b<c+a and c<a+b:
                ans+=1
print(ans)

Fixed submission:
import bisect
n = int(input())
L = list(map(int,input().split()))

#棒の長さa,bを固定して、あとはc<a+bとなるcを2部探索で探せばよい
L.sort()
ans = 0
for i in range(n-2):
    a = L[i]
    for j in range(i+1,n):
        b = L[j]
        tmp = bisect.bisect_left(L,a+b)
        if j<tmp:
            ans+=tmp-j-1
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import Counter

s = list(input())
k = int(input())

ans = 0
s_d = s*2
for i in range(1,len(s_d)):
    if s[i-1]==s[i]:
        s[i] = '_'
        if i>=len(s)//2:
            ans+=k-1
        else:
            ans+=1
s_s = set(s)
if len(s_s)==1 and len(s)%2!=0:
    ans = len(s)*(k//2)+(k%2==1)*(len(s)//2)
print(ans) 


Fixed submission:
from collections import Counter

s = list(input())
k = int(input())

ans = 0
s_d = s*2
for i in range(1,len(s_d)):
    if s_d[i-1]==s_d[i]:
        s_d[i] = '_'
        if i>=len(s_d)//2:
            ans+=k-1
        else:
            ans+=1
s_s = set(s)
if len(s_s)==1 and len(s)%2!=0:
    ans = len(s)*(k//2)+(k%2==1)*(len(s)//2)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k,q = map(int,input().split())
a_inputs = [int(input())-1 for i in range(q)]

ans_li = [True]*n
score_li = [k]*n


for a in a_inputs:
    score_li[a]+=1
    score_li = list(map(lambda x:x-1,score_li))
    for i in range(n):
        if score_li[i]<=0:
            ans_li[i]=False

for member in ans_li:
    if member:
        print('Yes')
    else:
        print('No')



Fixed submission:
from collections import Counter 

n,k,q = map(int,input().split())
a_inputs = [int(input())-1 for i in range(q)]

a_dic = Counter(a_inputs)

score_li = [k]*n
for key,value in a_dic.items():
    score_li[key]+=value
score_li = list(map(lambda x:x-q,score_li))

for member in score_li:
    if member<=0:
        print('No')
    else:
        print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

ans_li = [i for i in range(1,n)]
print(sum(ans_li))

Fixed submission:
n = int(input())

ans=0
if (n-1)%2==0:
    ans+=n*((n-1)//2)
else:
    ans+=n*((n-1)//2)+n//2
print(ans)