Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
h, w = map(int, input().split())
s = [input() for _ in range(h)]
hrz = [[0] * w for _ in range(h)]
vrt = [[0] * w for _ in range(h)]
for i in range(h):
    cnt = 0
    for j in range(w + 1):
        if j < w and s[i][j] == '.':
            if cnt == 0:
                start = j
            cnt += 1
        elif cnt > 0:
            for k in range(start, j):
                hrz[i][k] = cnt
            cnt = 0
for j in range(w):
    cnt = 0
    for i in range(h + 1):
        if i < h and s[i][j] == '.':
            if cnt == 0:
                start = i
            cnt += 1
        elif cnt > 0:
            for k in range(start, i):
                vrt[k][j] = cnt
            cnt = 0
ans = max(hrz[i][j] + vrt[i][j] - 1 for i in range(h) for j in range(w))
print(ans)


Fixed submission:
h, w = map(int, input().split())
s = [input() for _ in range(h)]
hrz = [[0] * w for _ in range(h)]
vrt = [[0] * w for _ in range(h)]
for i in range(h):
    cnt = 0
    for j in range(w + 1):
        if j < w and s[i][j] == '.':
            if cnt == 0:
                start = j
            cnt += 1
        elif cnt > 0:
            for k in range(start, j):
                hrz[i][k] = cnt
            cnt = 0
for j in range(w):
    cnt = 0
    for i in range(h + 1):
        if i < h and s[i][j] == '.':
            if cnt == 0:
                start = i
            cnt += 1
        elif cnt > 0:
            for k in range(start, i):
                vrt[k][j] = cnt
            cnt = 0
ans = max(hrz[i][j] + vrt[i][j] - 1 for i in range(h) for j in range(w))
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
to = [[] for _ in range(n)]
for _ in range(n - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    to[u].append((v, w))
    to[v].append((u, w))
ans = [-1] * n
def dfs(u=0, c=0, parent=-1):
    ans[u] = c
    for v, w in to[u]:
        if v == parent:
            continue
        dfs(v, (c + w) & 1, u)

dfs()
print(*ans, sep='\n')


Fixed submission:
import sys
sys.setrecursionlimit(10**7)
n = int(input())
to = [[] for _ in range(n)]
for _ in range(n - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    to[u].append((v, w))
    to[v].append((u, w))
ans = [-1] * n
def dfs(u=0, c=0, parent=-1):
    ans[u] = c
    for v, w in to[u]:
        if v == parent:
            continue
        dfs(v, (c + w) & 1, u)

dfs()
print(*ans, sep='\n')
Buggy python submission (verdict: Time Limit Exceeded):
x, y, z, k = map(int, input().split())
a = map(int, input().split())
b = list(map(int, input().split()))
c = map(int, input().split())
d = sorted((ai + bi for ai in a for bi in b), reverse=True)[:k]
e = sorted((ci + di for ci in c for di in d), reverse=True)
i = 0
while i != k:
    print(e[i])
    i += 1


Fixed submission:
x, y, z, k = map(int, input().split())
a = map(int, input().split())
b = list(map(int, input().split()))
c = map(int, input().split())
d = sorted((ai + bi for ai in a for bi in b), reverse=True)[:k]
e = sorted((ci + di for ci in c for di in d), reverse=True)[:k]
print(*e)

Buggy python submission (verdict: Time Limit Exceeded):
def islice(it, cnt):
    for x in it:
        if cnt:
            yield x
            cnt -= 1
        else:
            return

x, y, z, k = map(int, input().split())
a = map(int, input().split())
b = list(map(int, input().split()))
c = map(int, input().split())
d = sorted((ai + bi for ai in a for bi in b), reverse=True)
e = sorted((ci + di for ci in c for di in islice(d, k)), reverse=True)
print('\n'.join(map(str, islice(e, k))))

Fixed submission:
x, y, z, k = map(int, input().split())
a = map(int, input().split())
b = list(map(int, input().split()))
c = map(int, input().split())
d = sorted((ai + bi for ai in a for bi in b), reverse=True)[:k]
e = sorted((ci + di for ci in c for di in d), reverse=True)[:k]
print(*e)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import islice
x, y, z, k = map(int, input().split())
a = map(int, input().split())
b = list(map(int, input().split()))
c = map(int, input().split())
d = sorted((ai + bi for ai in a for bi in b), reverse=True)
e = sorted((ci + di for ci in c for di in islice(d, k)), reverse=True)
print(*islice(e, k), sep='\n')

Fixed submission:
x, y, z, k = map(int, input().split())
a = map(int, input().split())
b = list(map(int, input().split()))
c = map(int, input().split())
d = sorted((ai + bi for ai in a for bi in b), reverse=True)[:k]
e = sorted((ci + di for ci in c for di in d), reverse=True)[:k]
print(*e)

Buggy python submission (verdict: Time Limit Exceeded):
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
d = sorted((ai + bi for ai in a for bi in b), reverse=True)[:k]
e = sorted((ci + di for ci in c for di in d), reverse=True)[:k]
print(*e, sep='\n')

Fixed submission:
x, y, z, k = map(int, input().split())
a = map(int, input().split())
b = list(map(int, input().split()))
c = map(int, input().split())
d = sorted((ai + bi for ai in a for bi in b), reverse=True)[:k]
e = sorted((ci + di for ci in c for di in d), reverse=True)[:k]
print(*e)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [1001001001001001001] * n
dp[0] = 0
for i in range(n):
    for j in range(i + 1, min(i + k + 1, n)):
        dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]))
print(dp[n-1])

Fixed submission:
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [1001001001001001001] * n
dp[0] = 0
for i in range(n):
    for j in range(i + 1, min(i + k + 1, n)):
        dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]))
print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
n = int(input())
d = [int(input()) for _ in range(n)]
r = {v: i for i, v in enumerate(d)}
sz = [1] * n
dsorted = sorted(((di, i) for i, di in enumerate(d)), reverse=True)
ans = []
to = [[] for _ in range(n)]
for di, i in dsorted[:n-1]:
    nd = di + (sz[i] - 1) - (n - 2 - (sz[i] - 1))
    if not nd in r:
        print(-1)
        exit()
    p = r[nd]
    to[p].append(i)
    sz[p] += sz[i]
    ans.append((i+1, p+1))

root = dsorted[-1][1]
def dfs(u, cur=0):
    rv = cur
    for v in to[u]:
        rv += dfs(v, cur + 1)
    return rv

if dfs(root) != d[root]:
    print(-1)
    exit()

for u, v in ans:
    print(u, v)


Fixed submission:
import sys
sys.setrecursionlimit(10**7)
n = int(input())
d = [int(input()) for _ in range(n)]
r = {v: i for i, v in enumerate(d)}
sz = [1] * n
dsorted = sorted(((di, i) for i, di in enumerate(d)), reverse=True)
ans = []
to = [[] for _ in range(n)]
for di, i in dsorted[:n-1]:
    nd = di + (sz[i] - 1) - (n - 2 - (sz[i] - 1))
    if not nd in r:
        print(-1)
        exit()
    p = r[nd]
    to[p].append(i)
    sz[p] += sz[i]
    ans.append((i+1, p+1))

root = dsorted[-1][1]
def dfs(u, cur=0):
    rv = cur
    for v in to[u]:
        rv += dfs(v, cur + 1)
    return rv

if dfs(root) != d[root]:
    print(-1)
    exit()

for u, v in ans:
    print(u, v)
Buggy python submission (verdict: Runtime Error):
a, b = input().split()
if a < b:
    print('<')
elsif a > b:
 	print('>')
else:
  	print('=')

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

if a < b:
  print('<')
elif a>b:
  print('>')
else:
  print('=')

Buggy python submission (verdict: Runtime Error):
a, b = input().split()
if a < b :
  print('<')
elsif a > b:
  print('>')
else :
  print('=')

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

if a < b:
  print('<')
elif a>b:
  print('>')
else:
  print('=')

Buggy python submission (verdict: Runtime Error):
a, b = input().split()

if ( a < b) :
    print('<')
elsif (a > b):
    print('>')
else :
    print('=')
    

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

if a < b:
  print('<')
elif a>b:
  print('>')
else:
  print('=')

Buggy python submission (verdict: Runtime Error):
a,b=input().split()
if (a<b):
    print("<")
elsif (a>b):
    print(">")
else:
    print("=")

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

if a < b:
  print('<')
elif a>b:
  print('>')
else:
  print('=')

Buggy python submission (verdict: Runtime Error):
a,b=input().split()
if (a<b):
  print("<")
elsif (a>b):
  print(">")
else:
  print("=")

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

if a < b:
  print('<')
elif a>b:
  print('>')
else:
  print('=')
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
s.reverse()

if s==t :
  print("YES")
else:
  print("NO")

Fixed submission:
s=input()
t=input()
t=t[::-1]
if s==t:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
ans=[0 for _ in range(n*3)]
ans[1]=1

idou=[]

for _ in range(k):
  a=list(map(int,input().split()))
  idou.append(a)
  
    
mod=998244353

rui=[0 for _ in range(n+1)]
rui[1]=1
  
for i in range(2,n+1):
  for g in idou:
    x,y=g
    left=max(0,i-y-1)
    right=max(0,i-x)
    ans[i]+=rui[right]-rui[left]

    
  rui[i]+=((rui[i-1]+ans[i]))

    
    

print(ans[n]%mod)
  

Fixed submission:
n,k=map(int,input().split())
ans=[0 for _ in range(n*3)]
ans[1]=1

idou=[]

for _ in range(k):
  a=list(map(int,input().split()))
  idou.append(a)
  
    
mod=998244353

rui=[0 for _ in range(n+1)]
rui[1]=1
  
for i in range(2,n+1):
  for g in idou:
    x,y=g
    left=max(0,i-y-1)
    right=max(0,i-x)
    ans[i]+=(rui[right]-rui[left])%mod

    
  rui[i]+=((rui[i-1]+ans[i]))%mod

    
    

print(ans[n]%mod)

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
ans=[0 for _ in range(n*3)]
ans[1]=1

idou=[]

for _ in range(k):
  a=list(map(int,input().split()))
  idou.append(a)
  
    
mod=998244353

rui=[0 for _ in range(n+1)]
rui[1]=1
  
for i in range(2,n+1):
  for g in idou:
    x,y=g
    left=max(0,i-y-1)
    right=max(0,i-x)
    ans[i]+=rui[right]-rui[left]

    
  rui[i]+=((rui[i-1]+ans[i]))

    
    

print(ans[n]%mod)
  

Fixed submission:
n,k=map(int,input().split())
ans=[0 for _ in range(n*3)]
ans[1]=1

idou=[]

for _ in range(k):
  a=list(map(int,input().split()))
  idou.append(a)
  
    
mod=998244353

rui=[0 for _ in range(n+1)]
rui[1]=1
  
for i in range(2,n+1):
  for g in idou:
    x,y=g
    left=max(0,i-y-1)
    right=max(0,i-x)
    ans[i]+=(rui[right]-rui[left])%mod

    
  rui[i]+=((rui[i-1]+ans[i]))%mod

    
    

print(ans[n]%mod)
Buggy python submission (verdict: Runtime Error):
n,x,t=map(int,input().split())

if n%x==0:
  print(t*(n//x))
  
esle:
  print(t*(n//x+1))

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

if n%x==0:
  print(t*(n//x))
  
else:
  print(t*(n//x+1))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

h,w=map(int,input().split())
cy,cx=map(int,input().split())
gy,gx=map(int,input().split())
inf=float('inf')
maze=[]
for _ in range(h):
  s=list(input())
  for i in range(w):
    if s[i]=='.':
      s[i]=inf
  maze.append(s)
  
def solve(maze,cy,cx,gy,gx):
  [sy,sx]=[cy-1,cx-1]
  qu=deque([[sy,sx]])
  maze[sy][sx]=0
  T=0
  while qu:
    y,x=qu.popleft()
    t=maze[y][x]
      
    for i in ([1,0],[0,1],[-1,0],[0,-1]):
      ny=y-i[0]
      nx=x-i[1]
      if 0<=ny<=h-1 and 0<=nx<=w-1 and maze[ny][nx]!='#':
        if maze[ny][nx]>t:
          maze[ny][nx]=t
          qu.appendleft([ny,nx])
    for j in range(-2,3):
      for k in range(-2,3):
        ny=y-j
        nx=x-k
        if 0<=ny<=h-1 and 0<=nx<=w-1 and maze[ny][nx]!='#':
          if maze[ny][nx]>t:
            maze[ny][nx]=t+1
            qu.append([ny,nx])
            
  return maze[gy-1][gx-1]
  
if solve(maze,cy,cx,gy,gx)==inf:
  print(-1)
  
else:
  print(solve(maze,cy,cx,gy,gx))
    
  

Fixed submission:
from collections import deque
import copy

h,w=map(int,input().split())
cy,cx=map(int,input().split())
gy,gx=map(int,input().split())
inf=float('inf')
maze=[]
for _ in range(h):
  s=list(input())
  for i in range(w):
    if s[i]=='.':
      s[i]=inf
  maze.append(s)
  
def solve(maze,cy,cx,gy,gx):
  maze1=copy.deepcopy(maze)
  [sy,sx]=[cy-1,cx-1]
  qu=deque([[sy,sx]])
  maze[sy][sx]=0
  T=0
  while qu:
    y,x=qu.popleft()
    t=maze[y][x]
    
    if maze1[y][x]!=1:
      
      for i in ([1,0],[0,1],[-1,0],[0,-1]):
        ny=y-i[0]
        nx=x-i[1]
        if 0<=ny<=h-1 and 0<=nx<=w-1 and maze[ny][nx]!='#':
          if maze[ny][nx]>t:
            maze[ny][nx]=t
            qu.appendleft([ny,nx])
          
      
      for j in range(-2,3):
        for k in range(-2,3):
          ny=y-j
          nx=x-k
          if 0<=ny<=h-1 and 0<=nx<=w-1 and maze[ny][nx]!='#':
            if maze[ny][nx]>t:
              maze[ny][nx]=t+1
              qu.append([ny,nx])
      maze1[y][x]=1
            
  return maze[gy-1][gx-1]
  
if solve(maze,cy,cx,gy,gx)==inf:
  print(-1)
  
else:
  print(solve(maze,cy,cx,gy,gx))
Buggy python submission (verdict: Time Limit Exceeded):
k=int(input())
ans=1
mod=7%k
mod1=7%k
if k%2==0:
  print(-1)
  
else:
  
  while mod1!=0:
    mod=(mod*10)%k
    mod1=mod1+mod
    if mod1>=k:
      mod1=mod1%k
    ans+=1
  
  print(ans)
    



Fixed submission:
import sys
k=int(input())
d={}
ans=1
mod=7%k
mod1=7%k
d[mod1]=1
ch=0
  
while mod1!=0:
  mod=(mod*10)%k
  mod1=mod1+mod
  if mod1>=k:
    mod1=mod1%k
  if mod1 in d:
    ch+=1
    break
  if mod1 not in d:
    d[mod1]=1
  ans+=1
  
if ch==0:
  print(ans)
else:
  print(-1)

Buggy python submission (verdict: Time Limit Exceeded):
k=int(input())
ans=1
mod=7%k
mod1=7%k
while mod1!=0:
  mod=(mod*10)%k
  mod1=mod1+mod
  if mod1>=k:
    mod1=mod1%k
  ans+=1
  
print(ans)
    

Fixed submission:
import sys
k=int(input())
d={}
ans=1
mod=7%k
mod1=7%k
d[mod1]=1
ch=0
  
while mod1!=0:
  mod=(mod*10)%k
  mod1=mod1+mod
  if mod1>=k:
    mod1=mod1%k
  if mod1 in d:
    ch+=1
    break
  if mod1 not in d:
    d[mod1]=1
  ans+=1
  
if ch==0:
  print(ans)
else:
  print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
import math

n=int(input())

for x in range(1,n+1):
  ans=0
  b=int(math.sqrt(x))
  for q in range(1,b+1):
    c=int(math.sqrt(x-q*q))
    for r in range(1,c+1):
      d=x-q*q-r*r-q*r
      if d>0:
        
        e=int(math.sqrt(d))
        for s in range(1,e+1):
          if q*q+r*r+s*s+q*r+r*s+s*q==x:
            ans+=1
      
  print(ans)


Fixed submission:
n=int(input())

a=[0]*n

for x in range(1,101):
  for y in range(1,101):
    for z in range(1,101):
      k=x*x+y*y+z*z+x*y+y*z+z*x
      if k <=n:
        a[k-1]+=1
        
for q in range(n):
  print(a[q])

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

n=int(input())

for x in range(1,n+1):
  ans=0
  b=int(math.sqrt(x))
  for q in range(1,b+1):
    c=int(math.sqrt(n-q*q))
    for r in range(1,c+1):
      d=x-q*q-r*r-q*r
      if d>0:
        
        e=int(math.sqrt(d))
        for s in range(1,e+1):
          if q*q+r*r+s*s+q*r+r*s+s*q==x:
            ans+=1
      
  print(ans)

Fixed submission:
n=int(input())

a=[0]*n

for x in range(1,101):
  for y in range(1,101):
    for z in range(1,101):
      k=x*x+y*y+z*z+x*y+y*z+z*x
      if k <=n:
        a[k-1]+=1
        
for q in range(n):
  print(a[q])

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

n=int(input())

for x in range(1,n+1):
  ans=0
  b=int(math.sqrt(x))
  for q in range(1,b+1):
    c=int(math.sqrt(n-q*q))
    for r in range(1,c+1):
      d=x-q*q-r*r-q*r
      if d>0:
        
        e=int(math.sqrt(d))
        for s in range(1,e+1):
          if q*q+r*r+s*s+q*r+r*s+s*q==x:
            ans+=1
      
  print(ans)

Fixed submission:
n=int(input())

a=[0]*n

for x in range(1,101):
  for y in range(1,101):
    for z in range(1,101):
      k=x*x+y*y+z*z+x*y+y*z+z*x
      if k <=n:
        a[k-1]+=1
        
for q in range(n):
  print(a[q])
Buggy python submission (verdict: Runtime Error):
d=int(input())
a=[]
for x in range(d+1):
  b=list(map(int,input().split()))
  a.append(b)

for n in range(d):
  print(random.randint(1:27))

Fixed submission:
d=int(input())
a=[]
for x in range(d+1):
  b=list(map(int,input().split()))
  a.append(b)

import random
for n in range(d):
  print(random.randint(1,26))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
ans=0
for x in range(1,n+1):
  b=n//x
  c=x*b
  ans1=(x+c)*b//2
  ans+=ans1

print(ans)

Fixed submission:
n=int(input())
ans=0
for x in range(1,n+1):
  b=n//x
  c=x*b
  ans1=(x+c)*b//2
  ans+=ans1

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

a=list(map(int,input().split()))

bit=[0 for _ in range(30)]
b=[]

for x in a:
  y=[0 for _ in range(30)]
  for i in range(30):
    if (x>>i)&1:
      y[i]+=1
      bit[i]+=1
  b.append(y)
     
ans1=[]
for g in b:
  ans=0
  for j in range(30):
    if (bit[j]%2)!=(g[j]):
      ans+=2**j
  ans1.append(str(ans))
  
print(' '.join(ans1))

Fixed submission:
n=int(input())

a=list(map(int,input().split()))

bit=[0 for _ in range(30)]
b=[]

for x in a:
  y=[0 for _ in range(30)]
  for i in range(30):
    if (x>>i)&1:
      y[i]+=1
      bit[i]+=1
  b.append(y)
     
ans1=[]
for g in b:
  ans=0
  for j in range(30):
    if (bit[j]%2)!=(g[j]):
      ans+=2**j
  ans1.append(str(ans))
  
print(' '.join(ans1))
Buggy python submission (verdict: Runtime Error):
n,d=map(int,input().split())
ans=0
for _ in range(n):
  a,b=map(int,input().split())
  if (a*a+b*b) <= d*d:
    ans+=1
    
print(ans)

Fixed submission:
x,y=map(int,input().split())

if y%2 ==1:
  print("No")
elif 2*x > y:
  print("No")
elif 4*x < y:
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Runtime Error):
x,n=map(int,input().split())
try:
  a=list(map(int,input().split()))
except:
  rr=0
  





if n==0:
  print(x)
  
a=sorted(a)

if x<a[0]:
  print(x)
if x>a[-1]:
  print(x)
  
b=list(range((a[0]),(a[-1]+1)))

for n in range(n):
  b.remove(a[n])
  
f=len(b)


d=abs(x-int(b[0]))
ans=b[0]

for n in range(f):
  c=abs(x-int(b[n]))
  if d>c:
    ans=b[n]
    d=c
  
print(ans)

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

if n==0:
  print(x)
  
else:
  a=list(map(int,input().split()))

  for i in range(100):
    if x-i not in a:
      ans=x-i
      break
    elif x+i not in a:
      ans=x+i
      break
    
  print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))

ans=1
for i in a:
  ans=ans*i
  if str(ans)>18:
    ans=-1
    break
    
print(ans)

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

ans=1
for i in a:
  ans=ans*i
  if ans>(10**18):
    ans=-1
    break
    
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort()

ans=1
for i in a:
  ans=ans*i
  if ans>10**18:
    ans=-1
    break
    
print(ans)


Fixed submission:
a,b=map(str,input().split())
b=b.replace('.','')
ans=int(a)*int(b)//100
print(ans)

Buggy python submission (verdict: Runtime Error):
a,b=map(input().split())
b.replace('.','')
ans=int(a)*int(b)//100
print(ans)

Fixed submission:
a,b=map(str,input().split())
b=b.replace('.','')
ans=int(a)*int(b)//100
print(ans)

Buggy python submission (verdict: Runtime Error):
a,b=map(int,input().split())
b=int(b*100)
ans=a*b//100
print(ans)

Fixed submission:
a,b=map(str,input().split())
b=b.replace('.','')
ans=int(a)*int(b)//100
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
ans=0

for i in range(1,n):
  for j in range(0,i):
    st=j
    while st+i<=n-1:
      x=a[st]
      y=a[st+i]
      if x+y==i:
        ans+=1
      st=st+i
      
print(ans)

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

l=[]
r=[]

for i in range(n):
  nu=i+1
  x=a[i]
  l.append(x+nu)
  r.append(nu-x)
  
di1={}
di2={}

for i in range(0,n):
  if i==n-1:
    continue
  else:
    if l[i] not in di1:
      di1[l[i]]=0
    di1[l[i]]+=1
    if r[i+1] not in di2:
      di2[r[i+1]]=0
    di2[r[i+1]]+=1
    if r[i+1] in di1:
      ans+=di1[r[i+1]]
      
print(ans)

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

for i in range(1,n):
  for j in range(0,i):
    st=j
    while st+i<=n-1:
      x=a[st]
      y=a[st+i]
      if x+y==i:
        ans+=1
      st=st+i
      
print(ans)

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

l=[]
r=[]

for i in range(n):
  nu=i+1
  x=a[i]
  l.append(x+nu)
  r.append(nu-x)
  
di1={}
di2={}

for i in range(0,n):
  if i==n-1:
    continue
  else:
    if l[i] not in di1:
      di1[l[i]]=0
    di1[l[i]]+=1
    if r[i+1] not in di2:
      di2[r[i+1]]=0
    di2[r[i+1]]+=1
    if r[i+1] in di1:
      ans+=di1[r[i+1]]
      
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=list(input())

rn=s.count('R')
gn=s.count('G')
bn=n-rn-gn

ans=0
if n>2:
  
  for x in range(len(s)-2):
    if s[x]=='R':
      rn-=1
      ans+=gn*bn
    elif s[x]=='G':
      gn-=1
      ans+=rn*bn
    else:
      bn-=1
      ans+=gn*rn
    y=(n-1-x)//2
    for i in range(1,y+1):
      if  (not s[x]==s[x+i]) & (not s[x]==s[x+i+i]) & (not s[x+i]==s[x+i+i]):
        ans-=1
        
  print(ans)
    
else:
  print(0)


Fixed submission:
n=list(input())

if '7' in n:
  print('Yes')
  
else:
  print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import sys

input = sys.stdin.readline

n=int(input())
s=list(input())

rn=s.count('R')
gn=s.count('G')
bn=n-rn-gn

ans=bn*gn*rn
if n>2:
  
  for x in range(n-2):
    
    y=(n-1-x)//2
    for i in range(1,y+1):
      if  (not s[x]==s[x+i]) & (not s[x]==s[x+i+i]) & (not s[x+i]==s[x+i+i]):
        ans-=1
        
  print(ans)
    
else:
  print(0)


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

rn=s.count('R')
gn=s.count('G')
bn=n-rn-gn

ans=bn*gn*rn
if n>2:
  
  for x in range(n-2):
    
    y=(n-1-x)//2
    for i in range(1,y+1):
      if  (not s[x]==s[x+i]) & (not s[x]==s[x+i+i]) & (not s[x+i]==s[x+i+i]):
        ans-=1
        
  print(ans)
    
else:
  print(0)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=list(input())

rn=s.count('R')
gn=s.count('G')
bn=n-rn-gn

ans=bn*gn*rn
if n>2:
  
  for x in range(n-2):
    
    y=(n-1-x)//2
    for i in range(1,y+1):
      if  (not s[x]==s[x+i]) & (not s[x]==s[x+i+i]) & (not s[x+i]==s[x+i+i]):
        ans-=1
        
  print(ans)
    
else:
  print(0)


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

rn=s.count('R')
gn=s.count('G')
bn=n-rn-gn

ans=bn*gn*rn
if n>2:
  
  for x in range(n-2):
    
    y=(n-1-x)//2
    for i in range(1,y+1):
      if  (not s[x]==s[x+i]) & (not s[x]==s[x+i+i]) & (not s[x+i]==s[x+i+i]):
        ans-=1
        
  print(ans)
    
else:
  print(0)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=list(input())

rn=s.count('R')
gn=s.count('G')
bn=n-rn-gn

ans=0
if n>2:
  
  for x in range(n-2):
    if s[x]=='R':
      rn-=1
      ans+=gn*bn
    elif s[x]=='G':
      gn-=1
      ans+=rn*bn
    else:
      bn-=1
      ans+=gn*rn
    y=(n-1-x)//2
    for i in range(1,y+1):
      if  (not s[x]==s[x+i]) & (not s[x]==s[x+i+i]) & (not s[x+i]==s[x+i+i]):
        ans-=1
        
  print(ans)
    
else:
  print(0)

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

rn=s.count('R')
gn=s.count('G')
bn=n-rn-gn

ans=bn*gn*rn
if n>2:
  
  for x in range(n-2):
    
    y=(n-1-x)//2
    for i in range(1,y+1):
      if  (not s[x]==s[x+i]) & (not s[x]==s[x+i+i]) & (not s[x+i]==s[x+i+i]):
        ans-=1
        
  print(ans)
    
else:
  print(0)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=list(input())

rn=s.count('R')
gn=s.count('G')
bn=s.count('B')

ll=len(s)
ans=0
if ll>2:
  
  for x in range(len(s)-2):
    if s[x]=='R':
      rn-=1
      ans+=gn*bn
    elif s[x]=='G':
      gn-=1
      ans+=rn*bn
    else:
      bn-=1
      ans+=gn*rn
    y=(n-1-x)//2
    for i in range(1,y+1):
      if  (not s[x]==s[x+i]) & (not s[x]==s[x+i+i]) & (not s[x+i]==s[x+i+i]):
        ans-=1
        
  print(ans)
    
else:
  print(0)

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

rn=s.count('R')
gn=s.count('G')
bn=n-rn-gn

ans=bn*gn*rn
if n>2:
  
  for x in range(n-2):
    
    y=(n-1-x)//2
    for i in range(1,y+1):
      if  (not s[x]==s[x+i]) & (not s[x]==s[x+i+i]) & (not s[x+i]==s[x+i+i]):
        ans-=1
        
  print(ans)
    
else:
  print(0)