Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from collections import deque
h, w = map(int, input().split())
chiz = [[] for _ in range(w)]
cnt = 0
for _ in range(h):
    tmp_list = input()
    for i in range(w):
        if tmp_list[i]=='.':
            cnt += 1
        chiz[i].append(tmp_list[i])
dq = deque([(0,0)])
chiz[0][0] = 0
while dq:
    i,j = dq.popleft()
    for e in [(1,0),(-1,0),(0,-1),(0,1)]:
        if i+e[0]>=0 and i+e[0]<w and j+e[1]>=0 and j+e[1]<h:
            if chiz[i+e[0]][j+e[1]] == '.':
                chiz[i+e[0]][j+e[1]] = chiz[i][j] + 1
                dq.append((i+e[0],j+e[1]))
print(cnt-chiz[w-1][h-1]-1)

Fixed submission:
from collections import deque
h, w = map(int, input().split())
chiz = [[] for _ in range(w)]
cnt = 0
for _ in range(h):
    tmp_list = input()
    for i in range(w):
        if tmp_list[i]=='.':
            cnt += 1
        chiz[i].append(tmp_list[i])
dq = deque([(0,0)])
chiz[0][0] = 0
while dq:
    i,j = dq.popleft()
    for e in [(1,0),(-1,0),(0,-1),(0,1)]:
        if i+e[0]>=0 and i+e[0]<w and j+e[1]>=0 and j+e[1]<h:
            if chiz[i+e[0]][j+e[1]] == '.':
                chiz[i+e[0]][j+e[1]] = chiz[i][j] + 1
                dq.append((i+e[0],j+e[1]))
try:
    print(cnt-chiz[w-1][h-1]-1)
except:
    print(-1)
Buggy python submission (verdict: Runtime Error):
, m = map(int, input().split())
nl=[]
ml=[]
for i in range(n):
    nl.append(input())
for i in range(m):
    ml.append(input())

cnt=0
Yes=False
for i in nl:
    if(ml[0] in i):
        idx = i.find(ml[0])
        cnt2=cnt+1
        for j in range(1,m):
            if cnt2>n-1:
                ok = False
                break
            elif(not ml[j]==nl[cnt2][idx:idx+m]):
                ok=False
                break
            elif(j==m-1):
                Yes = True
                break
            cnt2+=1
    if(Yes):
        break
    cnt+=1
if Yes:
    print("Yes")
else:
    print("No")

Fixed submission:
n, m = map(int, input().split())
nl=[]
ml=[]
for i in range(n):
    nl.append(input())
for i in range(m):
    ml.append(input())

cnt=0
Yes=False
for i in nl:
    if(ml[0] in i):
        idx = i.find(ml[0])
        cnt2=cnt+1
        if m==1:
            Yes = True
            break
        for j in range(1,m):
            if cnt2>n-1:
                break
            elif(not ml[j]==nl[cnt2][idx:idx+m]):
                break
            elif(j==m-1):
                Yes = True
                break
            cnt2+=1
    if(Yes):
        break
    cnt+=1
if Yes:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
xpy_max = 0
xpy_min = 10 ** 9 + 3
xmy_max = 0
xmy_min = 10 ** 9 + 3
for i in range(N):
    x, y = map(int, input().split())
    if x + y <= xpy_min:
        xpy_min = x + y
        a = (x, y)
    if x + y >= xpy_max:
        xpy_max = x + y
        b = (x, y)
    if x - y >= xmy_max:
        xmy_max = x - y
        c = (x, y)
    if x - y <= xmy_min:
        xmy_min = x - y
        d = (x, y)
ans = max(b[0] - a[0] + b[1] - a[1], c[0] - d[0] + c[1] - d[1])
print(ans)








Fixed submission:
N = int(input())
a = - (10 ** 9 + 3)  # max(x + y)
b = 10 ** 9 + 3  # min(x + y)
c = - (10 ** 9 + 3)  # max(x - y)
d = 10 ** 9 + 3  # min(x - y)
for i in range(N):
    x, y = map(int, input().split())
    a = max(a, x + y)
    b = min(b, x + y)
    c = max(c, x - y)
    d = min(d, x - y)
ans = max([a - b, c - d])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
ans = 0
for i in range(len(A)):
    ans += A[i] * sum(A[0:i])
ans = ans % 1000000007
print(ans)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = 0
a_sum = 0
for i in range(len(A)):
    ans += A[i] * a_sum
    a_sum += A[i]
ans = ans % 1000000007
print(ans)
Buggy python submission (verdict: Runtime Error):
ans = 0
answer = []
S = input()
for s in S:
    if s == "R":
        ans += 1
    else:
        answer.append(ans)
        ans = 0
print(max(answer))

Fixed submission:
ans = 0
answer = []
S = input()
for s in S:
    if s == "R":
        ans += 1
    else:
        answer.append(ans)
        ans = 0
answer.append(ans)
print(max(answer))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
strategy = ["stay"] * len(A)

trend = "down"
for i in range(len(A)):
    if i == len(A) - 1:
        new_trend = "down"
        strategy[i] = "sell"
    else:
        if A[i] < A[i+1]:
            new_trend = "up"
            if trend != new_trend:
                strategy[i] = "buy"
        elif A[i] > A[i+1]:
            new_trend = "down"
            if trend != new_trend:
                strategy[i] = "sell"
        else:
            strategy[i] = "stay"
    trend = new_trend


money = 1000
stock = 0
for s in range(len(strategy)):
    if strategy[s] == "sell":
        money = money + stock * A[s]
        stock = 0
    elif strategy[s] == "buy":
        stock = money // A[s]
        money = money - A[s] * stock
    else:
        continue
print(money)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
strategy = ["stay"] * len(A)

trend = "down"
for i in range(len(A)):
    if i == len(A) - 1:
        new_trend = "down"
        strategy[i] = "sell"
    else:
        if A[i] < A[i+1]:
            new_trend = "up"
            if trend != new_trend:
                strategy[i] = "buy"
        elif A[i] > A[i+1]:
            new_trend = "down"
            if trend != new_trend:
                strategy[i] = "sell"
        else:
            strategy[i] = "stay"
            new_trend = trend
    trend = new_trend


money = 1000
stock = 0
for s in range(len(strategy)):
    if strategy[s] == "sell":
        money = money + stock * A[s]
        stock = 0
    elif strategy[s] == "buy":
        stock = money // A[s]
        money = money - A[s] * stock
    else:
        continue
print(money)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [0] * 10000
for x in range(1, int(pow(N, 0.5))):
    for y in range(1, int(pow(N, 0.5))):
        for z in range(1, int(pow(N, 0.5))):
            value = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if value > 10000:
                break
            A[value] += 1
for a in A[:N]:
    print(a)

Fixed submission:
N = int(input())
A = [0] * 10001
for x in range(1, int(pow(N, 0.5))):
    for y in range(1, int(pow(N, 0.5))):
        for z in range(1, int(pow(N, 0.5))):
            value = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if value > 10000:
                break
            A[value] += 1
for a in A[1:N+1]:
    print(a)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
for n in range(1, N + 1):
    ans = 0
    for x in range(1, int(pow(n, 0.5))):
        for y in range(1, int(pow(n - x ** 2, 0.5))):
            for z in range(1, int(pow(n - x ** 2 - y ** 2, 0.5))):
                if x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x == n:
                    ans += 1
    print(ans)

Fixed submission:
N = int(input())
A = [0] * 10001
for x in range(1, int(pow(N, 0.5))):
    for y in range(1, int(pow(N, 0.5))):
        for z in range(1, int(pow(N, 0.5))):
            value = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if value > 10000:
                break
            A[value] += 1
for a in A[1:N+1]:
    print(a)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
for n in range(1, N + 1):
    ans = 0
    for x in range(1, int(pow(n, 0.5))):
        if x ** 2 + 2 * x > n:
            break
        for y in range(1, int(pow(n, 0.5))):
            if x ** 2 + y ** 2 + x * y + y + x > n:
                break
            for z in range(1, int(pow(n, 0.5))):
                if x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x > n:
                    break
                if x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x == n:
                    ans += 1
    print(ans)

Fixed submission:
N = int(input())
A = [0] * 10001
for x in range(1, int(pow(N, 0.5))):
    for y in range(1, int(pow(N, 0.5))):
        for z in range(1, int(pow(N, 0.5))):
            value = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if value > 10000:
                break
            A[value] += 1
for a in A[1:N+1]:
    print(a)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
for n in range(1, N + 1):
    ans = 0
    for x in range(1, int(pow(n, 0.5))):
        for y in range(1, int(pow(n, 0.5))):
            for z in range(1, int(pow(n, 0.5))):
                if x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x == n:
                    ans += 1
    print(ans)

Fixed submission:
N = int(input())
A = [0] * 10001
for x in range(1, int(pow(N, 0.5))):
    for y in range(1, int(pow(N, 0.5))):
        for z in range(1, int(pow(N, 0.5))):
            value = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if value > 10000:
                break
            A[value] += 1
for a in A[1:N+1]:
    print(a)
Buggy python submission (verdict: Runtime Error):
from itertools import combinations
import numpy as np
ans = -1

N, M, X = map(int, input().split())
A = np.ndarray(shape=(N, M), dtype=int)
C = np.ndarray(shape=(N, ), dtype=int)
ans = []
costs = []
money = []
for i in range(N):
    inp = list(map(int, input().split()))
    C[i] = inp[0]
    A[i] = inp[1:]
for r in range(N):
    for c in combinations(range(N), r + 1):
        if min(np.sum(A[list(c)], axis=0)) >= X:
            costs.append(np.sum(C[list(c)]))
if len(costs) == 0:
    print(-1)
else:
    print(min(costs))

Fixed submission:
from itertools import combinations
import numpy as np
ans = -1

N, M, X = map(int, input().split())
A = np.ndarray(shape=(N, M), dtype=int)
C = np.ndarray(shape=(N, ), dtype=int)
ans = []
costs = []
money = []
for i in range(N):
    inp = list(map(int, input().split()))
    C[i] = inp[0]
    A[i] = inp[1:]
for r in range(N):
    for c in combinations(range(N), r + 1):
        if min(np.sum(A[list(c)], axis=0)) >= X:
            costs.append(np.sum(C[list(c)]))
if len(costs) == 0:
    print(-1)
else:
    print(min(costs))
Buggy python submission (verdict: Runtime Error):
S, W = map(int, input().split())
if S <= W:
    print("unsafe")
else:
    print("safe")

Fixed submission:
N = int(input())

items = set()
for i in range(N):
    item = input()
    items.add(item)
print(len(items))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
employee = list(map(int, input().split()))
for i in range(1, N+1):
    print(employee.count(i))

Fixed submission:
N = int(input())
employee = list(map(int, input().split()))
subordinate = [0] * N
for i in range(N-1):
    subordinate[employee[i]-1] += 1
for s in subordinate:
    print(s)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
employee = list(map(int, input().split()))
for i in range(1, N+1):
    print(employee.count(i))

Fixed submission:
N = int(input())
employee = list(map(int, input().split()))
subordinate = [0] * N
for i in range(N-1):
    subordinate[employee[i]-1] += 1
for s in subordinate:
    print(s)
Buggy python submission (verdict: Runtime Error):
s = input()


def reverse(text):
    return text == ''.join(list(reversed(text)))


N = len(s)

if reverse(s) and reverse(s[:(N-1)/2]) and reverse(s[(N+3)/2 - 1:]):
    print('Yes')
else:
    print('No')

Fixed submission:
s = input()


def reverse(text):
    return text == ''.join(list(reversed(text)))


N = len(s)

if reverse(s) and reverse(s[:int((N-1)/2)]) and reverse(s[int((N+3)/2) - 1:]):
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
step = list(map(int, input().split()))
dp = [float('inf')] * N
dp[0] = 0
for i, s in enumerate(step):
  for k in range(1, K + 1):
    if i < k:
      break
    dp[i] = min(dp[i], dp[i - k] + abs(step[i - k] - step[i]))
print(dp[N - 1])

Fixed submission:
N, K = map(int, input().split())
step = list(map(int, input().split()))
dp = [float('inf')] * N
dp[0] = 0
for i, s in enumerate(step):
  for k in range(1, K + 1):
    if i < k:
      break
    dp[i] = min(dp[i], dp[i - k] + abs(step[i - k] - step[i]))
print(dp[N - 1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ls = [int(l) for l in input().split()]

Ls = list(set(ls))
Ls.sort()

if len(Ls) < 3:
  print(0)
else:
  ans = 0
  LsR = sorted(Ls)
  while len(LsR) >= 3:
    L1 = LsR[0]
    Ls1 = LsR[1:]
    while len(Ls1) >= 2:
      L2 = Ls1[0]
      Ls2 = Ls1[1:]
      for L3 in Ls2:
        if L3 < L1 + L2 and L3 > abs(L1-L2):
          n1 = sum([l == L1 for l in ls])
          n2 = sum([l == L2 for l in ls])
          n3 = sum([l == L3 for l in ls])
          ans += n1 * n2 * n3
      Ls1 = Ls1[1:]
    LsR = LsR[1:]
  print(ans)

Fixed submission:
n = int(input())
ls = [int(l) for l in input().split()]

import collections
c = collections.Counter(ls)

Ls = list(set(ls))
Ls.sort()

if len(Ls) < 3:
  print(0)
else:
  ans = 0
  LsR = sorted(Ls)
  while len(LsR) >= 3:
    L1 = LsR[0]
    Ls1 = LsR[1:]
    while len(Ls1) >= 2:
      L2 = Ls1[0]
      Ls2 = Ls1[1:]
      for L3 in Ls2:
        if L3 < L1 + L2 and L3 > abs(L1-L2):
          ans += c[L1] * c[L2] * c[L3]
      Ls1 = Ls1[1:]
    LsR = LsR[1:]
  print(ans)
Buggy python submission (verdict: Runtime Error):
import math

n = int(input())
ans = [0]*n
max = int(math.sqrt(n-2))

for x in range(1,max):
  for y in range(1,max):
    for z in range(1,max):
      ns = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if ns < n:
        ans[ns-1] += 1
for a in range(n):
  print(ans[a])


Fixed submission:
import math

n = int(input())
ans = [0]*n
max = int(math.sqrt(max(n,1)))+1

for x in range(1,max):
  for y in range(1,max):
    for z in range(1,max):
      ns = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if ns <= n:
        ans[ns-1] += 1
for a in range(n):
  print(ans[a])
Buggy python submission (verdict: Runtime Error):
c = input()
if c = c.lower():
  print('a')
else:
  print('A')
    


Fixed submission:
c = input()
if c == c.lower():
  print('a')
else:
  print('A')

Buggy python submission (verdict: Runtime Error):
c = input()
if c = c.lower():
  	print('a')
else:
  print('A')
    

Fixed submission:
c = input()
if c == c.lower():
  print('a')
else:
  print('A')
Buggy python submission (verdict: Runtime Error):
r = int(input())
print(2*pi*r)

Fixed submission:
r = int(input())
print(2*3.1415*r)
Buggy python submission (verdict: Runtime Error):
print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51][int(input())+1])

Fixed submission:
print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51][int(input())-1])
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = [int(str) for str in input().split()]
c = [0,0,0,0,0]

for n in range(a):
  if b[n]%2 == 0:
    if b[n]%3 != 0 and b[n]%5 != 0:
      c[n] = 1

if sum(c) == 0:
  print('APPROVED')
else:
  print('DENIED')

Fixed submission:
a = int(input())
b = [int(str) for str in input().split()]
c = [0]*a

for n in range(a):
  if b[n]%2 == 0:
    if b[n]%3 != 0 and b[n]%5 != 0:
      c[n] = 1

if sum(c) == 0:
  print('APPROVED')
else:
  print('DENIED')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
v = list(range(n))
for x in range(n):
  v[x] = input()

import collections
c = collections.Counter(v)
values, counts = zip(*c.most_common())
num = 0

for y in list(counts):
  if y == max(counts):
    num += 1
answers = list(values[:num])
answers.sort()
for z in range(num):
  print(answers[z])

Fixed submission:
n = int(input())
v = list(range(n))
for x in range(n):
  v[x] = input()

import collections
c = collections.Counter(v)
values, counts = zip(*c.most_common())
num = list(counts).count(max(counts))
answers = list(values[:num])
answers.sort()
for z in range(num):
  print(answers[z])
Buggy python submission (verdict: Time Limit Exceeded):
nk = [int(s) for s in input().split()]
n = nk[0]
k = nk[1]

p = [int(s) for s in input().split()]
t = 0
for x in range(n-k+1):
  if sum(p[x:x+k]) >= t:
    t = sum(p[x:x+k])

print((t+k)/2)
  

Fixed submission:
nk = [int(s) for s in input().split()]
n = nk[0]
k = nk[1]

p = [int(s)+1 for s in input().split()]
l = [sum(p[:k])]

for x in range(n-k):
  l.append(l[x]-p[x]+p[x+k])
print(max(l)/2)
Buggy python submission (verdict: Runtime Error):
def main():
    x, n = map(int, input().split())
    
    if n==0:
        print(x)
    else:
        p = list(map(int, input().split()))
        truefalse = [True]*100
        for i in range(n):
            truefalse[p[i]-1] = False
        
        a = 0
        while 1:
            if truefalse[x-a-1]:
                print(x-a)
                break
            elif truefalse[x+a-1]:
                print(x+a)
                break
            else:
                a += 1

if __name__ == "__main__":
    main()

Fixed submission:
def main():
    x, n = map(int, input().split())
    
    if n==0:
        print(x)
    else:
        p = list(map(int, input().split()))
        #p = [i+1 for i in range(100)]
        truefalse = [True]*101
        for i in range(n):
            truefalse[p[i]-1] = False
        
        a = 0
        while 1:
            if truefalse[x-a-1]:
                print(x-a)
                break
            elif truefalse[x+a-1]:
                print(x+a)
                break
            else:
                a += 1

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
if __name__ == "__main__":
    a = '1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51'
    k = list(a.split(', '))
    i = int(input())
    print(k[i+1])

Fixed submission:
if __name__ == "__main__":
    a = '1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51'
    k = list(a.split(', '))
    i = int(input())
    print(k[i-1])
Buggy python submission (verdict: Runtime Error):
input = input(“天気を入力：”)
items = {'Sunny': 'Cloudy', 'Cloudy':'Rainy', 'Rainy': 'Sunny'}
print( items[input] )

Fixed submission:
input = input()
items = {'Sunny': 'Cloudy', 'Cloudy':'Rainy', 'Rainy': 'Sunny'}
print( items[input] )

Buggy python submission (verdict: Runtime Error):
input = input(“天気を入力：”)
items = {'Sunny': 'Cloudy', 'Cloudy': ‘Rainy’, 'Rainy': 'Sunny'}
print( items[input] )

Fixed submission:
input = input()
items = {'Sunny': 'Cloudy', 'Cloudy':'Rainy', 'Rainy': 'Sunny'}
print( items[input] )

Buggy python submission (verdict: Runtime Error):
input = input(“天気を入力：”)
items = {'apple': 100, 'banana': 200, 'orange': 400}
print( items[input] )

Fixed submission:
input = input()
items = {'Sunny': 'Cloudy', 'Cloudy':'Rainy', 'Rainy': 'Sunny'}
print( items[input] )
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
s=int(input())
max_count=s//3
if max_count==0:
    print(0)
else:
    ans=0
    for i in range(1,max_count+1):
        data=[j for j in range(1,i+1)]
        amari=s-3*i
        ans+=len(list(itertools.combinations_with_replacement(data,amari)))
        ans%=10**9+7
    print(ans)

Fixed submission:
from operator import mul
from functools import reduce

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

s=int(input())
max_count=s//3
if max_count==0:
    print(0)
else:
    ans=0
    for i in range(1,max_count+1):
        data=[j for j in range(1,i+1)]
        amari=s-3*i
        ans+=cmb(i+amari-1,amari)
        ans%=10**9+7
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from numba import jit
n=int(input())
data=[]
for _ in range(n):
    data.append(list(map(int,input().split())))
    
@jit
def main():
    ans=0
    for i in range(0,n-1):
        for j in range(i+1,n):
            d=abs(data[i][0]-data[j][0])+abs(data[i][1]-data[j][1])
            ans=max(ans,d)
    print(ans)
    
if __name__=="__main__":
    main()

Fixed submission:
n=int(input())
data=[]
for _ in range(n):
    data.append(list(map(int,input().split())))

data_sum=[]
for i in range(n):
    data_sum.append(data[i][0]+data[i][1])


data_sum_1=[]
for i in range(n):
    data_sum_1.append(data[i][1]-data[i][0])

d_1=max(data_sum)-min(data_sum)
d_2=max(data_sum_1)-min(data_sum_1)

print(max(d_1,d_2))

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
data=[]
for _ in range(n):
    data.append(list(map(int,input().split())))
ans=0
for i in range(0,n-1):
    for j in range(i+1,n):
        d=abs(data[i][0]-data[j][0])+abs(data[i][1]-data[j][1])
        ans=max(ans,d)
print(ans)

Fixed submission:
n=int(input())
data=[]
for _ in range(n):
    data.append(list(map(int,input().split())))

data_sum=[]
for i in range(n):
    data_sum.append(data[i][0]+data[i][1])


data_sum_1=[]
for i in range(n):
    data_sum_1.append(data[i][1]-data[i][0])

d_1=max(data_sum)-min(data_sum)
d_2=max(data_sum_1)-min(data_sum_1)

print(max(d_1,d_2))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
A=list(map(int,input().split()))
mod=10**9+7
sum_=0
for i in range(n-1):
    for j in range(n-i-1):
        sum_ += A[i]*A[i+j+1]
        sum_ %= mod
print(sum_)

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
mod=10**9+7
s=sum(A)
ans=0
for a in A:
    ans += a*(s-a)
print((ans//2)%mod)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
A=list(map(int,input().split()))
mod=10**9+7
for i in range(n):
    if A[i] >= mod:
        A[i] %= mod
sum_=0
for i in range(n-1):
    for j in range(n-i-1):
        sum_ += A[i]*A[i+j+1]
        sum_ %= mod
print(sum_)

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
mod=10**9+7
s=sum(A)
ans=0
for a in A:
    ans += a*(s-a)
print((ans//2)%mod)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
A=list(map(int,input().split()))
gokei=0
for i in range(1,n):
    if max(A[:i]) > A[i]:
        gokei += max(A[:i])-A[i]
    else:
        pass
print(gokei)

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
gokei=0
max_=A[0]
for i in range(1,n):
    if max_ > A[i]:
        gokei += max_-A[i]
    else:
        max_=A[i]
print(gokei)
Buggy python submission (verdict: Runtime Error):
from numba import jit
@jit
def main():
    n,k = map(int,input().split())
    p = list(map(int,input().split()))
    c = list(map(int,input().split()))

    ans=-10**18
    for i in range(n):
        start,count=i,1
        val=c[start]
        while p[start]-1 != i:
            start = p[start]-1
            count += 1
            val += c[start]
        start = i
        if val > 0:
            a = (k//count-1)*val
            ans=max(a,ans)
            num=count+k%count
        else:
            a=0
            num=min(k,count)
        for _ in range(num):
            a += c[start]
            start=p[start]-1
            ans=max(a,ans)
    print(ans)
main()

Fixed submission:
s=list(input())
count=0
for d in s:
    if d=="R":
        count += 1
if count == 2:
    if s[1]=="S":
        print(1)
    else:
        print(2)
else:
    print(count)

Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
p = list(map(int,input().split()))
c = list(map(int,input().split()))

ans=-10**18
for i in range(n):
    start,count=i,1
    val=c[start]
    while p[start]-1 != i:
        start = p[start]-1
        count += 1
        val += c[start]
    start = i
    if val > 0:
        a = (k//count-1)*val
        ans=max(a,ans)
        num=count+k%count
    else:
        a=0
        num=min(k,count)
    for _ in range(num):
        a += c[start]
        start=p[start]-1
        ans=max(a,ans)
print(ans)

Fixed submission:
s=list(input())
count=0
for d in s:
    if d=="R":
        count += 1
if count == 2:
    if s[1]=="S":
        print(1)
    else:
        print(2)
else:
    print(count)