Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
str_line = [i for i in input()]
a_place = []
z_place = []
result = 0
for i, stri in enumerate(str_line):
    if stri == "A":
        a_place.append(i)  
for i, stri in enumerate(str_line):
    if stri == "Z":
        z_place.append(i)   
for i in z_place:
    for j in a_place:
        if i-j+1 >= result:
            result = i-j+1
print(result)        

Fixed submission:
str_line = [i for i in input()]
a_place = []
z_place = []
result1 = 0
result2 = 10000000
for i, stri in enumerate(str_line):
    if stri == "A":
        a_place.append(i)  
for i, stri in enumerate(str_line):
    if stri == "Z":
        z_place.append(i)   
for i in z_place:
    if i >= result1:
        result1 = i
for i in a_place:
    if i <= result2:
        result2 = i
print(result1 - result2 + 1)
Buggy python submission (verdict: Time Limit Exceeded):
line = input().split()
num = int(line[0]) + 1
sum = 0
for x in range(num):
    for y in range(num):
        if -1 < int(line[1]) - (x + y) < num:
            sum += 1          
print(sum)                

Fixed submission:
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
           for y in range(k+1):
               if -1 < s-x-y < k+1:
                   ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
line = input().split()
num = int(line[0]) + 1
sum = 0
for x in range(num):
    for y in range(num):
        leave = int(line[1]) - (x + y)
        if -1 < leave < num:
            sum += 1          
print(sum)                

Fixed submission:
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
           for y in range(k+1):
               if -1 < s-x-y < k+1:
                   ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
line = input().split()
num = int(line[0]) + 1
sum = 0
for x in range(num):
    for y in range(num):
        leave = int(line[1]) -(x + y)
        if leave >= 0 and leave <= num - 1:
            sum += 1
print(sum)                

Fixed submission:
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
           for y in range(k+1):
               if -1 < s-x-y < k+1:
                   ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
line = input().split()
num = int(line[0]) + 1
sum = 0
for x in range(num):
    for y in range(num):
        for z in range(num):
            if x + y + z == int(line[1]):
                sum += 1
print(sum)                

Fixed submission:
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
           for y in range(k+1):
               if -1 < s-x-y < k+1:
                   ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
line = input().split()
num = int(line[0]) + 1
sum = 0
for x in range(num):
    for y in range(num):
        for z in range(num):
            if x + y + z == int(line[1]):
                sum += 1
print(sum)                

Fixed submission:
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
           for y in range(k+1):
               if -1 < s-x-y < k+1:
                   ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
cnt = 0
for a in range(1,N+1):
  for b in range(1,N+1):
    if a*b >= N:
      break
    cnt+=1
print(cnt)

Fixed submission:
N = int(input())
cnt = 0
for a in range(1,N+1):
  b = N // a
  if a * b == N:
    cnt = cnt + b - 1
  else:
    cnt = cnt + b
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

N,M,K=MI()
A=[0]+LI()
B=[0]+LI()
from itertools import accumulate
A=list(accumulate(A))
B=list(accumulate(B))
ans=0
for i in range(N+1):
  if A[i]>K:
    break
  for j in range(M,-1,-1):
    if A[i]+B[j]>K:
      continue
    ans=max(ans,i+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()))
A=[0]
B=[0]
ans=0
j=M
for i in range(N):
  A.append(A[i]+a[i])
for i in range(M):
  B.append(B[i]+b[i])
for i in range(N+1):
  if A[i]>K:
    break
  while A[i]+B[j]>K:
    j-=1
  ans=max(ans,i+j)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

N,M,K=MI()
A=[0]+LI()
B=[0]+LI()
from itertools import accumulate
A=list(accumulate(A))
B=list(accumulate(B))
ans=0
for i in range(N+1):
  if A[i]>K:
    continue
  for j in range(M,-1,-1):
    if A[i]+B[j]>K:
      continue
    ans=max(ans,i+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()))
A=[0]
B=[0]
ans=0
j=M
for i in range(N):
  A.append(A[i]+a[i])
for i in range(M):
  B.append(B[i]+b[i])
for i in range(N+1):
  if A[i]>K:
    break
  while A[i]+B[j]>K:
    j-=1
  ans=max(ans,i+j)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
N=int(input())
ans=0
for i in range(1,N+1):
    tmp=i*len(make_divisors(i))
    ans+=tmp
print(ans)

Fixed submission:
def calc(b,e):
  cnt=e//b
  return (b+e)*cnt//2
def II(): return int(input())
N=II()
ans=0
for i in range(1,N+1):  
  ans+=calc(i,N//i*i)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def II(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

N=II()
A=LI()
cnt=[0]*((10**6)+1)
for elem in A:
  cnt[elem]+=1
unique=[]
for i in range((10**6)+1):
  if cnt[i]==1:
    unique.append(i)
cnt=[0]*((10**6)+1)
for elem in A:
  for m in range(elem*2,10**6+1,elem):
    cnt[m]=1
ans=0
for i in unique:
  if cnt[i]==0:
    ans+=1
print(ans)  

Fixed submission:
import sys
from collections import Counter
import numpy as np
 
n, *aaa = map(int, sys.stdin.buffer.read().split())
cnt = Counter(aaa)
duplicated = {x for x, c in cnt.items() if c > 1}
aaa.sort()
 
can = np.ones(aaa[-1] + 1, np.int8)
 
ans = 0
for a in aaa:
    if can[a] == 0:
        continue
    if a not in duplicated:
        ans += 1
    can[a * 2::a] = 0
print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import deque
q=deque()
def MI(): return map(int, input().split())
N,M=MI()
g=[[] for _ in range(M+1)]
for _ in range(M):
  a,b=MI()
  g[a].append(b)
  g[b].append(a)
check=[0]*(N+1)
check[1]=1
ans=[0]*(N+1)
q.append(1)
while len(q)>0:
  v=q.popleft()
  for u in g[v]:
    if check[u]==0:
      check[u]=1
      ans[u]=v
      q.append(u)
print('Yes')
for i in range(2,N+1):
  print(ans[i])

Fixed submission:
from collections import deque
N,M=map(int,input().split())
ab=[[] for i in range(N+1)]
for i in range(M):
  a,b=map(int,input().split())
  ab[a].append(b)
  ab[b].append(a)
ans=[-1]*(N+1)
que=deque([1])
while que:
  q=que.popleft()
  for i in ab[q]:
    if ans[i]==-1:
      que.append(i)
      ans[i]=q
print('Yes')
for i in range(2,N+1):
  print(ans[i])
Buggy python submission (verdict: Runtime Error):
N,M,Q=map(int,input().split())
L=[]
for i in range(Q):
  L.append(list(map(int,input().split())))
  L[i][0]-=1
  L[i][1]-=1

import itertools
L=list(range(1,M+1))
A=list(itertools.combinations_with_replacement(L,N))
ans=0
for i in A:
  tmp=0
  for a,b,c,d in L:
    if (i[b]-i[a])==c:
      tmp+=d
  ans=max(ans,tmp)
print(ans)

Fixed submission:
N,M,Q=map(int,input().split())
L = []
for i in range(Q):
  L.append(list(map(int, input().split())))
  L[i][0]-=1
  L[i][1]-=1

import itertools

l =list(range(1,M+1))
ans=0

v=list(itertools.combinations_with_replacement(l,N))

for arr in v:
  score=0
  for a,b,c,d in L:
    if (arr[b] - arr[a])==c:
      
      score+=d
  ans=max(ans,score)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S=input()
ans=0
for i in range(len(S)+1):
  for j in range(i+3,len(S)+1):
    #print(S[i:j])
    if int(S[i:j])%2019==0:
      #print(int(S[i:j]))
      ans+=1
    
print(ans)

Fixed submission:
'''冷めたコーヒー
入力文字列として、S = 31415926535を考えます。
このとき、例えば4番目から8番目までの部分文字列15926が
2019の倍数であるか判定したいというのが本問の主題です。
特定の部分文字列が2019の倍数であるかどうかは、
int(s[[i:j+1]) % 2019 == 0とすればよいのですが、
これを逐一やっていてはO(N^2)の計算量がかかってしまいます。
そこで、この部分文字列を次のようにとらえてみます。
15926=(15926535−535)/10^3
このように考えることの利点は、10^3 が 2019 と
互いに素（最大公約数が 1）であるため、
15926 が 2019 の倍数であるかどうかは、
上式右辺の分子に着目すればよいということです。
したがって、アルゴリズムを設計する際は、
与えられた文字列の右からk番目（0～n)から最右端までの
部分文字列を保持しておけばよいことになります。
分子が 2019 の倍数かどうかは、分子を A−B としたときに、
A mod2019 と B mod2019 の値がそれぞれ等しければ、
元の整数（上式左辺）は 2019 の倍数であると言えます。
'''
s = input()[::-1] # 入力文字列を逆順でsに格納

counts = [0] * 2019#2019で割った余りの個数をカウント
counts[0] = 1#その数が、ちょうど2019で割れた時のために必要

num, d = 0, 1

for char in s:
    num += int(char) * d#1桁目から数字を作る、整数型にする
    num %= 2019
    d *= 10
    d%= 2019
    counts[num] += 1#2019で割った余りの個数を足す1

ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2
    #余りが同じものを2つ選ぶ組み合わせの数が答

print(ans) # 答えの出力

Buggy python submission (verdict: Time Limit Exceeded):
S=input()
ans=0
for i in range(len(S)+1):
  for j in range(i+3,len(S)+1):
    #print(S[i:j])
    if int(S[i:j])%2019==0:
      #print(int(S[i:j]))
      ans+=1
    
print(ans)

Fixed submission:
'''冷めたコーヒー
入力文字列として、S = 31415926535を考えます。
このとき、例えば4番目から8番目までの部分文字列15926が
2019の倍数であるか判定したいというのが本問の主題です。
特定の部分文字列が2019の倍数であるかどうかは、
int(s[[i:j+1]) % 2019 == 0とすればよいのですが、
これを逐一やっていてはO(N^2)の計算量がかかってしまいます。
そこで、この部分文字列を次のようにとらえてみます。
15926=(15926535−535)/10^3
このように考えることの利点は、10^3 が 2019 と
互いに素（最大公約数が 1）であるため、
15926 が 2019 の倍数であるかどうかは、
上式右辺の分子に着目すればよいということです。
したがって、アルゴリズムを設計する際は、
与えられた文字列の右からk番目（0～n)から最右端までの
部分文字列を保持しておけばよいことになります。
分子が 2019 の倍数かどうかは、分子を A−B としたときに、
A mod2019 と B mod2019 の値がそれぞれ等しければ、
元の整数（上式左辺）は 2019 の倍数であると言えます。
'''
s = input()[::-1] # 入力文字列を逆順でsに格納

counts = [0] * 2019#2019で割った余りの個数をカウント
counts[0] = 1#その数が、ちょうど2019で割れた時のために必要

num, d = 0, 1

for char in s:
    num += int(char) * d#1桁目から数字を作る、整数型にする
    num %= 2019
    d *= 10
    d%= 2019
    counts[num] += 1#2019で割った余りの個数を足す1

ans = 0
for cnt in counts:
    ans += cnt * (cnt - 1) // 2
    #余りが同じものを2つ選ぶ組み合わせの数が答

print(ans) # 答えの出力
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

ans=0
K=int(input())
for a in range(1,K+1):
  for b in range(1,K+1):
    for c in range(1,K+1):
      ans+=gcd(a,b,c)
print(ans)

Fixed submission:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

ans=0
K=int(input())
for a in range(1,K+1):
  for b in range(1,K+1):
    for c in range(1,K+1):
      ans+=gcd(a,b,c)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

ans=0
K=int(input())
for a in range(1,K+1):
  for b in range(1,K+1):
    for c in range(1,K+1):
      ans+=gcd(a,b,c)
print(ans)

Fixed submission:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

ans=0
K=int(input())
for a in range(1,K+1):
  for b in range(1,K+1):
    for c in range(1,K+1):
      ans+=gcd(a,b,c)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools
ans=0
N=int(sys.stdin.readline())
S=sys.stdin.readline()

for i in itertools.combinations(range(N),3):
  if (i[0]+i[2])/2 ==i[1]:
    continue
  L=(S[i[0]],S[i[1]],S[i[2]])
  if len(set(L))!=3:
    continue
  ans+=1
  
print(ans)    


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

r_cnt=S.count('R')
g_cnt=S.count('G')
b_cnt=S.count('B')

ans=r_cnt*g_cnt*b_cnt

for i in range(N):
  for d in range(N):
    j=i+d
    k=j+d
    if k>=N:break
#等号がないと範囲外参照になる、0-indexだからk=S[N]は無い      
    if S[i]!=S[j] and S[i]!=S[k] and S[k]!=S[j]:
      ans-=1
      
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import itertools
ans=0
N=int(sys.stdin.readline())
S=sys.stdin.readline()

for i in itertools.combinations(range(N),3):
  if (i[0]+i[2])/2 ==i[1]:
    continue
  L=[S[i[0]],S[i[1]],S[i[2]]]
  if len(set(L))!=3:
    continue
  ans+=1
  
print(ans)    

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

r_cnt=S.count('R')
g_cnt=S.count('G')
b_cnt=S.count('B')

ans=r_cnt*g_cnt*b_cnt

for i in range(N):
  for d in range(N):
    j=i+d
    k=j+d
    if k>=N:break
#等号がないと範囲外参照になる、0-indexだからk=S[N]は無い      
    if S[i]!=S[j] and S[i]!=S[k] and S[k]!=S[j]:
      ans-=1
      
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
ans=0
N=int(input())
S=input()

for i in itertools.combinations(range(N),3):
  if (i[0]+i[2])/2 ==i[1]:
    continue
  L=[S[i[0]],S[i[1]],S[i[2]]]
  if len(set(L))!=3:
    continue
  ans+=1
  
print(ans)   

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

r_cnt=S.count('R')
g_cnt=S.count('G')
b_cnt=S.count('B')

ans=r_cnt*g_cnt*b_cnt

for i in range(N):
  for d in range(N):
    j=i+d
    k=j+d
    if k>=N:break
#等号がないと範囲外参照になる、0-indexだからk=S[N]は無い      
    if S[i]!=S[j] and S[i]!=S[k] and S[k]!=S[j]:
      ans-=1
      
print(ans)
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
d={}
for i in range(M):
  s,t=map(int,input().split())
  if s in d:
    if d[s]!=t:
      print('-1')
      exit()
  if s==1:
    if t==0:
      if N==1:
        print('0')
        exit()     
      else:
        print('-1')
        exit()  
  d[s]=t
if N==1:
    if s==1:
      if t==0:
        print('0')
        exit()
if 1 not in d:
  d[1]=1
for i in range(2,N):
  if i not in d:
    d[i]=0
L=[]
for i in d.values():
  L.append(str(i))
print(''.join(L))

Fixed submission:
N,M=map(int,input().split())
SC=[list(map(int,input().split())) for i in range(M)]

def check(x):
  x=str(x)#文字に変換
  if len(x)!=N:
    return False
  for s,c in SC:
    if x[s-1]!=str(c):
      return False
  return True

for i in range(1000):
  if check(i):
    print(i)
    exit()
print(-1)

Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
d={}
for i in range(M):
  s,t=map(int,input().split())
  if s in d:
    if d[s]!=t:
      print('-1')
      exit()
  if s==1:
    if t==0:
      print('-1')
      exit()
  
  d[s]=t
if N==1:
    if s==1:
      if t==0:
        print('0')
        exit()
if 1 not in d:
  d[1]=1
for i in range(2,N):
  if i not in d:
    d[i]=0
L=[]
for i in d.values():
  L.append(str(i))
print(''.join(L))

Fixed submission:
N,M=map(int,input().split())
SC=[list(map(int,input().split())) for i in range(M)]

def check(x):
  x=str(x)#文字に変換
  if len(x)!=N:
    return False
  for s,c in SC:
    if x[s-1]!=str(c):
      return False
  return True

for i in range(1000):
  if check(i):
    print(i)
    exit()
print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
from operator import mul
from functools import reduce
N,a,b=map(int,input().split())
MOD=10**9+7
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
cnt=0
for i in range(1,N+1):
  cnt+=cmb(N,i)
A=cmb(N, a)
B=cmb(N, b)
cnt=cnt-A-B
ans=cnt%MOD
print(ans)

Fixed submission:
N,a,b=map(int,input().split())
MOD=10**9+7
def comb(n,k):
  tmp=1
  for i in range(n-k+1,n+1):
    tmp*=i
    tmp%=MOD
  for i in range(1,k+1):
    tmp*=pow(i,MOD-2,MOD)
    tmp%=MOD
  return tmp
ans = pow(2,N,MOD) - 1 - comb(N,a) - comb(N,b)
print(ans%MOD)

Buggy python submission (verdict: Time Limit Exceeded):
from scipy.misc import comb
N,a,b=map(int,input().split())
MOD=10**9+7
cnt=0
for i in range(1,N+1):
  cnt+=comb(N, i, exact=True)
A=comb(N, a, exact=True)
B=comb(N, b, exact=True)
cnt=cnt-A-B
ans=cnt%MOD
print(ans)

Fixed submission:
N,a,b=map(int,input().split())
MOD=10**9+7
def comb(n,k):
  tmp=1
  for i in range(n-k+1,n+1):
    tmp*=i
    tmp%=MOD
  for i in range(1,k+1):
    tmp*=pow(i,MOD-2,MOD)
    tmp%=MOD
  return tmp
ans = pow(2,N,MOD) - 1 - comb(N,a) - comb(N,b)
print(ans%MOD)
Buggy python submission (verdict: Runtime Error):
print(chr(ord(input()+1)))

Fixed submission:
C=input()
print(chr(ord(C[0])+1))

Buggy python submission (verdict: Runtime Error):
C=input()
print(chr(ord(c[0])+1))

Fixed submission:
C=input()
print(chr(ord(C[0])+1))
Buggy python submission (verdict: Runtime Error):
def II(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
ans,pena=0,0
N,M=MI()
P=[0]*N
PENA=[0]*N
for i in range(M):
  p,s=input().split()
  p=int(p)
  p-=1
  if s=='AC':
    if P[p]==0:
      ans+=1
      P[p]=1
  if s=='WA':
    if P[p]==0:
      PENA[p]+=1
for i in range(N):
  if P[p]!=1:
    PENA[p]=0
pena=sum(PENA)  
print(ans,pena)

Fixed submission:
N,M=map(int,input().split())
ac=[False]*N
wa=[0]*N
for _ in range(M):
  p,S=input().split()
  p=int(p)-1
  if S=='AC':
    ac[p]=True
  else:
    if not ac[p]:
      wa[p]+=1
a=0
b=0
for i in range(N):
  if ac[i]:
    a+=1
    b+=wa[i]
print(*[a,b])

Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
ACL=[0]*N
PL=[0]*N
AC=0
P=0
for i in range(M):
  p,S=input().split()
  p=int(p)
  if S =='AC':
    if ACL[p]==0:
      AC+=1
      P+=PL[p]
      ACL[p]=1
    else:
      PL[p]+=1
print(AC,P)
      
  

Fixed submission:
N,M=map(int,input().split())
ac=[False]*N
wa=[0]*N
for _ in range(M):
  p,S=input().split()
  p=int(p)-1
  if S=='AC':
    ac[p]=True
  else:
    if not ac[p]:
      wa[p]+=1
a=0
b=0
for i in range(N):
  if ac[i]:
    a+=1
    b+=wa[i]
print(*[a,b])
Buggy python submission (verdict: Runtime Error):
def MI(): return map(int, input().split())
from collections import deque
def bfs(field,s):
  q=deque([(0,s)])
  MOVE=[(-1,0),(0,-1),(1,0),(0,1)]
  dist=[[-1]*W for i in range(H)]
  d,i,j=-1,-1,-1  
  while q:
    d,(i,j)=q.popleft()
    if dist[i][j]!=-1:
      continue
    dist[i][j]=d
    for di,dj in MOVE:
      ni=i+di
      nj=j+dj
      if not 0<=ni<H or not 0<=nj<W:
        continue
      if field[ni][nj]=='#':
        continue
      if dist[ni][nj]!=-1:
        continue
      q.append((d+1,(ni,nj)))
  return d,i,j
H,W=MI()
field=[input() for _ in range(H)]
ans=0
for i in range(H):
  for j in range(W):
    if field[i][j]=='.':
      d,i,j=bfs(field,(i,j))
    ans=max(ans,d)
print(ans)

Fixed submission:
H, W = map(int, input().split())
S = [input() for _ in range(H)]


def f(i, j):
    t = [[-1] * W for _ in range(H)]
    t[i][j] = 0
    q = [(i, j)]
    while q:
        y, x = q.pop(0)
        if y - 1 >= 0 and S[y - 1][x] != '#' and t[y - 1][x] == -1:
            t[y - 1][x] = t[y][x] + 1
            q.append((y - 1, x))
        if y + 1 < H and S[y + 1][x] != '#' and t[y + 1][x] == -1:
            t[y + 1][x] = t[y][x] + 1
            q.append((y + 1, x))
        if x - 1 >= 0 and S[y][x - 1] != '#' and t[y][x - 1] == -1:
            t[y][x - 1] = t[y][x] + 1
            q.append((y, x - 1))
        if x + 1 < W and S[y][x + 1] != '#' and t[y][x + 1] == -1:
            t[y][x + 1] = t[y][x] + 1
            q.append((y, x + 1))
    return max(max(tt) for tt in t)


result = 0
for i in range(H):
    for j in range(W):
        if S[i][j] != '#':
            result = max(result, f(i, j))
print(result)
Buggy python submission (verdict: Runtime Error):
N=int(input())
S=input()
ans=0
for in range(N-1):
  if S[i:i+3]=='ABC':
    ans+=1
print(ans)

Fixed submission:
N=int(input())
S=input()
print(S.count('ABC'))
Buggy python submission (verdict: Time Limit Exceeded):
'''catupper
三重ループで大丈夫。関数化することでコードが読みやすくなる。
配列の使い方は基本的。ソートしなくても三重ループでOK。
'''
N=int(input())
L=list(map(int,input().split()))

def ok(A,B,C):
  return A<B+C and B<C+A and C<A+B

ans=0
for i in range(N):
  for j in range(i+1,N):
    for k in range(j+1,N):
      if ok(L[i],L[j],L[k]):
        ans+=1

print(ans)    

Fixed submission:
import bisect
n=int(input())
l=list(map(int,input().split()))
l=sorted(l)
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    idx=bisect.bisect_right(l,l[i]+l[j]-1,j+1)
    ans+=idx-(j+1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
'''catupper
三重ループで大丈夫。関数化することでコードが読みやすくなる。
配列の使い方は基本的。ソートしなくても三重ループでOK。
'''
N=int(input())
L=list(map(int,input().split()))

def ok(A,B,C):
  return A<B+C and B<C+A and C<A+B

ans=0
for i in range(N):
  for j in range(i+1,N):
    for k in range(j+1,N):
      if ok(L[i],L[j],L[k]):
        ans+=1

print(ans)    

Fixed submission:
import bisect
n=int(input())
l=list(map(int,input().split()))
l=sorted(l)
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    idx=bisect.bisect_right(l,l[i]+l[j]-1,j+1)
    ans+=idx-(j+1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N=int(input())
L=list(map(int,input().split()))
ans=0
C = list(itertools.combinations(L, 3))
for i in range(len(C)):
  if C[i][0]<C[i][1]+C[i][2]:
    if C[i][0]+C[i][1]>C[i][2]:
      if C[i][1]<C[i][0]+C[i][2]:
        ans+=1
print(ans)

Fixed submission:
import bisect
n=int(input())
l=list(map(int,input().split()))
l=sorted(l)
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    idx=bisect.bisect_right(l,l[i]+l[j]-1,j+1)
    ans+=idx-(j+1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N=int(input())
L=list(map(int,input().split()))
ans=0
C = list(itertools.combinations(L, 3))
for i in range(len(C)):
  if C[i][0]<C[i][1]+C[i][2] and C[i][0]+C[i][1]>C[i][2] and C[i][1]<C[i][0]+C[i][2]:
    ans+=1
print(ans)

Fixed submission:
import bisect
n=int(input())
l=list(map(int,input().split()))
l=sorted(l)
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    idx=bisect.bisect_right(l,l[i]+l[j]-1,j+1)
    ans+=idx-(j+1)
print(ans)
Buggy python submission (verdict: Runtime Error):
N,K,Q=map(int,input().split())
QL=[0]*Q
NL=[K-Q]*N
for i in range(Q):
  L[i]=int(input())
  NL[L[i]]+=1
for i in range(N):
  print('Yes' if NL[i]>0 else 'No')
  

Fixed submission:
N,K,Q=map(int,input().split())
QL=[0]*Q
NL=[K-Q]*N
for i in range(Q):
  QL[i]=int(input())-1
  NL[QL[i]]+=1
for i in range(N):
  print('Yes' if NL[i]>0 else 'No')
Buggy python submission (verdict: Runtime Error):
N=int(input())
B=list(map(int,input().split()))
ans=0
ans+=B[0]+B[-1]
for i in range(N-1):
  ans+=min(B[i],B[i+1])
print(ans)

Fixed submission:
N=int(input())
B=list(map(int,input().split()))
ans=0
ans+=B[0]+B[-1]
for i in range(N-2):
  ans+=min(B[i],B[i+1])
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input)
H=list(map(int,input().split()))
tmp=0
ans=0
for i in range(N-1):
  if H[i]>=H[i+1]:
    tmp+=1
    ans=max(ans,tmp)
  else:
    tmp=0
    break
print(ans)
    
  

Fixed submission:
N=int(input())
H=list(map(int,input().split()))
tmp=0
ans=0
for i in range(N-1):
  if H[i]>=H[i+1]:
    tmp+=1
    ans=max(ans,tmp)
  else:
    tmp=0
    continue
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
L=list(map(int,input().split()))
LR=sorted(L,reverse=True)
ans=0
for i range(N-1):
  ans=(L[i]+L[i+1])/2
print(ans)
  

Fixed submission:
N=int(input())
L=list(map(int,input().split()))
LR=sorted(L)
ans=LR[0]
for i in range(N-1):
  ans=(ans+LR[i+1])/2
print(ans)