Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
s = list(input())
a = ['0','1','2','3','4','5','6','7','8','9']
cnt=0
for i in list(itertools.product(a, repeat=3)):
  d =0
  e =0
  while d < n:
    if s[d] == i[e]:
      e+=1
    d+=1
    if e==3:
      cnt+=1
      break
print(cnt)

Fixed submission:
n = int(input())
s = list(input())
a = ['0','1','2','3','4','5','6','7','8','9']
g = []
for i in a:
  for j in a:
    for k in a:
      g.append([i,j,k])
cnt=0
for i in g:
  d =0
  e =0
  while d < n:
    if s[d] == i[e]:
      e+=1
    d+=1
    if e==3:
      cnt+=1
      break
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))
cnt = 0
for i in range(n):
  for j in range(i):
    a = l[i]+l[j]
    for k in l:
      if a > k:
        continue
      cnt += 1
print(n*(n-1)*(n-2)//6-cnt)

Fixed submission:
n = int(input())
l = sorted(map(int, input().split()))
cnt = 0
m = n-1
g = []
for i in range(n):
  for j in range(i):
    g.append(l[i]+l[j])
g = sorted(g,reverse = True)
for i in g:
  while l[m] >= i:
    m-=1
  cnt += n-m-1
print(n*(n-1)*(n-2)//6-cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))
cnt = 0
for i in range(n):
  for j in range(i):
    a = l[i]+l[j]
    for k in l:
      if a > k:
        continue
      cnt += 1
print(n*(n-1)*(n-2)//6-cnt)

Fixed submission:
n = int(input())
l = sorted(map(int, input().split()))
cnt = 0
m = n-1
g = []
for i in range(n):
  for j in range(i):
    g.append(l[i]+l[j])
g = sorted(g,reverse = True)
for i in g:
  while l[m] >= i:
    m-=1
  cnt += n-m-1
print(n*(n-1)*(n-2)//6-cnt)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
n, q = map(int, input().split())
g = [[] for i in range(n)]
k = []
for i in range(n-1):
  a,b = map(int, input().split())
  g[a-1].append(b-1)
  g[b-1].append(a-1)
for i in range(q):
  a,b = map(int, input().split())
  k.append([a-1,b])
m = [-1]*n
m[0] = 0
q = deque()
q.append(0)
while len(q):
  d = q.popleft()
  for i in g[d]:
    if m[i] == -1:
      m[i] = m[d]+1
      q.append(i)
kyori = [[] for i in range(max(m)+1)]
for i,j in enumerate(m):
  kyori[j].append(i)
ans= [0]*n
for i,j in k:
  t = m[i]
  ans[i]+=j
  for r in range(t+1,len(kyori)):
    for z in kyori[r]:
      ans[z]+=j
print(' '.join(map(str,ans)))

Fixed submission:
from collections import deque
n, q = map(int, input().split())
g = [[] for i in range(n)]
k = []
for i in range(n-1):
  a,b = map(int, input().split())
  g[a-1].append(b-1)
  g[b-1].append(a-1)
for i in range(q):
  a,b = map(int, input().split())
  k.append([a-1,b])
m = [-1]*n
m[0] = 0
m1 = [-1]*n
m1[0] = 0
q = deque()
q.append(0)
while len(q):
  d = q.popleft()
  for i in g[d]:
    if m[i] == -1:
      m[i] = m[d]+1
    if m1[i] == -1:
      m1[i] = d
      q.append(i)
kyori = [[] for i in range(max(m)+1)]
for i,j in enumerate(m):
  kyori[j].append(i)
ans= [0]*n
for i,j in k:
  ans[i]+=j
for i in kyori[1:]:
  for j in i:
    ans[j] = ans[j] + ans[m1[j]]
print(' '.join(map(str,ans)))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
n, q = map(int, input().split())
g = [[] for i in range(n)]
k = []
for i in range(n-1):
  a,b = map(int, input().split())
  g[a-1].append(b-1)
  g[b-1].append(a-1)
for i in range(q):
  a,b = map(int, input().split())
  k.append([a-1,b])
m = [-1]*n
m[0] = 0
q = deque()
q.append(0)
while len(q):
  d = q.popleft()
  for i in g[d]:
    if m[i] == -1:
      m[i] = m[d]+1
      q.append(i)
ans = [0]*n
for i,j in k:
  t = m[i]
  for x,y in enumerate(m):
    if i == x or t < y:
      ans[x]+=j
print(' '.join(map(str,ans)))


Fixed submission:
from collections import deque
n, q = map(int, input().split())
g = [[] for i in range(n)]
k = []
for i in range(n-1):
  a,b = map(int, input().split())
  g[a-1].append(b-1)
  g[b-1].append(a-1)
for i in range(q):
  a,b = map(int, input().split())
  k.append([a-1,b])
m = [-1]*n
m[0] = 0
m1 = [-1]*n
m1[0] = 0
q = deque()
q.append(0)
while len(q):
  d = q.popleft()
  for i in g[d]:
    if m[i] == -1:
      m[i] = m[d]+1
    if m1[i] == -1:
      m1[i] = d
      q.append(i)
kyori = [[] for i in range(max(m)+1)]
for i,j in enumerate(m):
  kyori[j].append(i)
ans= [0]*n
for i,j in k:
  ans[i]+=j
for i in kyori[1:]:
  for j in i:
    ans[j] = ans[j] + ans[m1[j]]
print(' '.join(map(str,ans)))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
h,w = map(int, input().split())
s = [input() for i in range(h)]
root = [[0,1],[1,0],[0,-1],[-1,0]]
def bfs(x,y):
  v = [[0 for i in range(w)] for j in range(h)]
  v[x][y]=1
  cnt=0
  d = deque([[x,y]])
  while len(d):
    e,f = d.popleft()
    c = s[e][f]
    for a,b in root:
      x1 = e+a
      y1 = f+b
      if x1>=0 and x1<h and y1>=0 and y1 <w and v[x1][y1]==0:
        if c == '.' and s[x1][y1]=='#':
          v[x1][y1]=1
          d.append([x1,y1])
        if c == '#' and s[x1][y1]=='.':
          v[x1][y1]=1
          d.append([x1,y1])
          cnt+=1
  return cnt

ans=0
for i in range(h):
  for j in range(w):
    if s[i][j]=='#':
      ans+= bfs(i,j)
      
print(ans)

Fixed submission:
from collections import deque
h,w = map(int, input().split())
s = [input() for i in range(h)]
root = [[0,1],[1,0],[0,-1],[-1,0]]
def bfs(x,y):
  v[x][y]=1
  cnt=1
  cnt1=0
  d = deque([[x,y]])
  while len(d):
    e,f = d.popleft()
    c = s[e][f]
    for a,b in root:
      x1 = e+a
      y1 = f+b
      if x1>=0 and x1<h and y1>=0 and y1 <w and v[x1][y1]==0:
        if c == '.' and s[x1][y1]=='#':
          v[x1][y1]=1
          d.append([x1,y1])
          cnt+=1
        if c == '#' and s[x1][y1]=='.':
          v[x1][y1]=1
          d.append([x1,y1])
          cnt1+=1
  return cnt*cnt1
v = [[0 for i in range(w)] for j in range(h)]
ans=0
for i in range(h):
  for j in range(w):
    if v[i][j]:
      continue
    if s[i][j]=='#':
      ans+= bfs(i,j)
print(ans)
Buggy python submission (verdict: Runtime Error):
n,p = map(int, input().split())
if n==1:
    print(p)
    exit()
elif p==1:
    print(1)
    exit()

a = int(p**(1/n)+1)
for i in range(a,0,-1):
  if p%(i**n)==0:
    print(i)
    exit()

Fixed submission:
n,p = map(int, input().split())
a = round(p**(1/n))
for i in range(a,-1,-1):
  if p%(i**n)==0:
    print(i)
    exit()

Buggy python submission (verdict: Runtime Error):
n,p = map(int, input().split())
a = int(p**(1/n))+1
for i in range(a,0,-1):
  if p%(i**n)==0:
    print(i)
    exit()

Fixed submission:
n,p = map(int, input().split())
a = round(p**(1/n))
for i in range(a,-1,-1):
  if p%(i**n)==0:
    print(i)
    exit()

Buggy python submission (verdict: Time Limit Exceeded):
n,p = map(int, input().split())
if n == 1:
  print(p)
  exit()
a = int(p**(1/n)+2)
for i in range(a,0,-1):
  if p%(i**n)==0:
    print(i)
    exit()

Fixed submission:
n,p = map(int, input().split())
a = round(p**(1/n))
for i in range(a,-1,-1):
  if p%(i**n)==0:
    print(i)
    exit()

Buggy python submission (verdict: Runtime Error):
n,p = map(int, input().split())
if n == 1:
  print(p)
  exit()
a = int(p**(1/n)+2)
for i in range(a)[::-1]:
  if p%(i**n)==0:
    print(i)
    exit()

Fixed submission:
n,p = map(int, input().split())
a = round(p**(1/n))
for i in range(a,-1,-1):
  if p%(i**n)==0:
    print(i)
    exit()

Buggy python submission (verdict: Runtime Error):
n,p = map(int, input().split())
if n == 1:
  print(p)
  exit(0)
a = int(p**(1/n)+1)
for i in range(a,0,-1):
  if p%(i**n)==0:
    print(i)
    exit(0)

Fixed submission:
n,p = map(int, input().split())
a = round(p**(1/n))
for i in range(a,-1,-1):
  if p%(i**n)==0:
    print(i)
    exit()

Buggy python submission (verdict: Time Limit Exceeded):
n,p = map(int, input().split())
if n == 1:
  print(p)
  exit(0)
a = int((p)**(1/n)+1)
for i in range(a,0,-1):
  if p%(i**n)==0:
    print(i)
    exit(0)

Fixed submission:
n,p = map(int, input().split())
a = round(p**(1/n))
for i in range(a,-1,-1):
  if p%(i**n)==0:
    print(i)
    exit()

Buggy python submission (verdict: Time Limit Exceeded):
n,p = map(int, input().split())
a = int((p)**(1/n)+1)
for i in range(a,0,-1):
  if p%(i**n)==0:
    print(i)
    exit(0)

Fixed submission:
n,p = map(int, input().split())
a = round(p**(1/n))
for i in range(a,-1,-1):
  if p%(i**n)==0:
    print(i)
    exit()
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = [0]*10**5+3
c = [0]*10**5+3
for i in range(n):
  if i%2==0:
    b[a[i]]+=1
  else:
    c[a[i]]+=1
bm=max(b)
cm=max(c)
if b.index(max(b))==c.index(max(c)):
  b[b.index(max(b))]=0
  c[c.index(max(c))]=0
  bm2=max(b)
  cm2=max(c)
  print(min(n-bm-cm2,n-cm-bm2))
else:
  print(n-bm-cm)
  


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = [0]*(10**5+3)
c = [0]*(10**5+3)
for i in range(n):
  if i%2==0:
    b[a[i]]+=1
  else:
    c[a[i]]+=1
bm=max(b)
cm=max(c)
if b.index(max(b))==c.index(max(c)):
  b[b.index(max(b))]=0
  c[c.index(max(c))]=0
  bm2=max(b)
  cm2=max(c)
  print(min(n-bm-cm2,n-cm-bm2))
else:
  print(n-bm-cm)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = [0]*10**5
c = [0]*10**5
for i in range(n):
  if i%2==0:
    b[a[i]]+=1
  else:
    c[a[i]]+=1
bm=max(b)
cm=max(c)
if b.index(max(b))==c.index(max(c)):
  b[b.index(max(b))]=0
  c[c.index(max(c))]=0
  bm2=max(b)
  cm2=max(c)
  print(min(n-bm-cm2,n-cm-bm2))
else:
  print(n-bm-cm)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = [0]*(10**5+3)
c = [0]*(10**5+3)
for i in range(n):
  if i%2==0:
    b[a[i]]+=1
  else:
    c[a[i]]+=1
bm=max(b)
cm=max(c)
if b.index(max(b))==c.index(max(c)):
  b[b.index(max(b))]=0
  c[c.index(max(c))]=0
  bm2=max(b)
  cm2=max(c)
  print(min(n-bm-cm2,n-cm-bm2))
else:
  print(n-bm-cm)
Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
if n==1:
  print(abs(int(input())))
  exit()
a = list(map(int, input().split()))
g = []
for i in range(n-k):
  b = a[i]
  c = a[i+k-1]
  if c<=0:
    g.append(-b)
  elif b>=0:
    g.append(c)
  else:
    g.append(c-b+min(abs(b),abs(c)))
print(min(g))

Fixed submission:
n,k = map(int, input().split())
if n==1:
  print(abs(int(input())))
  exit()
a = list(map(int, input().split()))
g = []
for i in range(n-k+1):
  b = a[i]
  c = a[i+k-1]
  if c<=0:
    g.append(-b)
  elif b>=0:
    g.append(c)
  else:
    g.append(c-b+min(abs(b),abs(c)))
print(min(g))

Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
a = list(map(int, input().split()))
if n==1:
  print(*a)
  exit()
g = []
for i in range(n-k):
  b = a[i]
  c = a[i+k-1]
  if c<=0:
    g.append(-b)
  elif b>=0:
    g.append(c)
  else:
    g.append(c-b+min(abs(b),abs(c)))
print(min(g))

Fixed submission:
n,k = map(int, input().split())
if n==1:
  print(abs(int(input())))
  exit()
a = list(map(int, input().split()))
g = []
for i in range(n-k+1):
  b = a[i]
  c = a[i+k-1]
  if c<=0:
    g.append(-b)
  elif b>=0:
    g.append(c)
  else:
    g.append(c-b+min(abs(b),abs(c)))
print(min(g))
Buggy python submission (verdict: Time Limit Exceeded):
n,m,d = map(int, input().split())
if d ==0:
  print((n*n**(m-2)*(m-1))/n**m)
else:
  a =(n-d)*2*n**(m-2)*(m-1)
  print(a/n**m)

Fixed submission:
n,m,d = map(int, input().split())
if d ==0:
  print(n*(m-1)/n**2)
else:
  print((n-d)*2*(m-1)/n**2)
Buggy python submission (verdict: Time Limit Exceeded):
n,c1 = map(int, input().split())
g = []
c = [0]
d = [0]
a = 0
ans=[]
for i in range(n):
  x,v = map(int, input().split())
  g.append([x,v])
  a+=v
  c.append(a-x)
  d.append(a-2*x)
b = 0
e = [0]
f = [0]
for i,j in reversed(g):
  b+=j
  e.append(b-(c1-i))
  f.append(b-2*(c1-i))
for i in range(1,n+2):
  ans.append(max(c[:i])+f[-i])
  ans.append(max(d[:i])+e[-i])
print(max(ans))

Fixed submission:
n,c1 = map(int, input().split())
g = []
c = [0]
d = [0]
a = 0
ans=[]
m1=0
m2=0
for i in range(n):
  x,v = map(int, input().split())
  g.append([x,v])
  a+=v
  m1= max(a-x,m1)
  m2= max(a-2*x,m2)
  c.append(m1)
  d.append(m2)
b = 0
e = [0]
f = [0]
for i,j in reversed(g):
  b+=j
  e.append(b-(c1-i))
  f.append(b-2*(c1-i))
for i in range(n+1):
  ans.append(c[i]+f[-i-1])
  ans.append(d[i]+e[-i-1])
print(max(ans))
Buggy python submission (verdict: Runtime Error):
n =int(input())
import fraction
ans = 1
for _ in range(n):
    t = int(input())
    ans = ans * t // fraction.gcd(ans, t)
print(ans)

Fixed submission:
n =int(input())
import fractions
ans = 1
for _ in range(n):
    t = int(input())
    ans = ans * t // fractions.gcd(ans, t)
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
T = list(int(input()) for _ in range(N))
ans = T[0]
for i in range(1, N):
    ans = ans * T[i] // math.gcd(ans, T[i])
print(ans)

Fixed submission:
n =int(input())
import fractions
ans = 1
for _ in range(n):
    t = int(input())
    ans = ans * t // fractions.gcd(ans, t)
print(ans)

Buggy python submission (verdict: Runtime Error):
n =int(input())
import math
ans = 1
for _ in range(n):
    t = int(input())
    ans = ans * t // math.gcd(ans, t)
print(ans)


Fixed submission:
n =int(input())
import fractions
ans = 1
for _ in range(n):
    t = int(input())
    ans = ans * t // fractions.gcd(ans, t)
print(ans)

Buggy python submission (verdict: Runtime Error):
n =int(input())
import math
ans = 1
for _ in range(n):
    t = int(input())
    ans = ans * t // math.gcd(ans, t)
print(ans)

Fixed submission:
n =int(input())
import fractions
ans = 1
for _ in range(n):
    t = int(input())
    ans = ans * t // fractions.gcd(ans, t)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = list(map(int, input().split()))
S = input()

D = []
count = 0
mode = 1
if S[0] == "0":
    D.append(0)
    mode = 0

for i in range(len(S)):
    if int(S[i]) == mode:
        count += 1
    else:
        D.append(count)
        count = 1
        mode = 1 - mode
    if i == len(S)-1:
        D.append(count)

if S[-1] == "0":
    D.append(0)

lk = int((len(D)-1)/2)
if K > lk:
    K = lk
ans = 0
for i in range(int((len(D)-2*K-1)/2)+1):
    j = 2*i
    k = 2*K + 2*i + 1
    sumd = sum(D[j:k])
    if sumd > ans:
        ans = sumd

print(ans)


Fixed submission:
N, K = list(map(int, input().split()))
S = input()

D = []
count = 0
mode = 1
if S[0] == "0":
    D.append(0)
    mode = 0

for i in range(N):
    if int(S[i]) == mode:
        count += 1
    else:
        D.append(count)
        count = 1
        mode = 1 - mode
    if i == N-1:
        D.append(count)

if S[-1] == "0":
    D.append(0)
lk = int((len(D)-1)/2)
if K > lk:
    K = lk
ans = sum(D[:(2*K+1)])
sumd = ans
for i in range(int((len(D)-2*K-1)/2)):
    sumd += D[2*K+2*i+1]+D[2*K+2*i+2]-D[2*i]-D[2*i+1]
    if sumd > ans:
        ans = sumd

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = list(map(int, input().split()))
S = input()

D = []
count = 0
mode = 1
if S[0] == "0":
    D.append(0)
    mode = 0

for i in range(len(S)):
    if int(S[i]) == mode:
        count += 1
    else:
        D.append(count)
        count = 1
        mode = 1 - mode
    if i == len(S)-1:
        D.append(count)

if S[-1] == "0":
    D.append(0)
    mode = 0

if K > int((len(D)-1)/2):
    K = int((len(D)-1)/2)
ans = 0
for i in range(int((len(D)-2*K-1)/2)+1):
    j = 2*i
    k = 2*K + 2*i + 1
    if sum(D[j:k]) > ans:
        ans = sum(D[j:k])

print(ans)


Fixed submission:
N, K = list(map(int, input().split()))
S = input()

D = []
count = 0
mode = 1
if S[0] == "0":
    D.append(0)
    mode = 0

for i in range(N):
    if int(S[i]) == mode:
        count += 1
    else:
        D.append(count)
        count = 1
        mode = 1 - mode
    if i == N-1:
        D.append(count)

if S[-1] == "0":
    D.append(0)
lk = int((len(D)-1)/2)
if K > lk:
    K = lk
ans = sum(D[:(2*K+1)])
sumd = ans
for i in range(int((len(D)-2*K-1)/2)):
    sumd += D[2*K+2*i+1]+D[2*K+2*i+2]-D[2*i]-D[2*i+1]
    if sumd > ans:
        ans = sumd

print(ans)
Buggy python submission (verdict: Runtime Error):
strS = input()
strT = input()

maxRange = 0
l = 0
while l <= (len(strS)-len(strT)):
    m = 0
    count = 0
    while m < (len(strT)):
        if strS[l+m] != strT[m]:
            count += 1
        m += 1
    if maxRange > count:
        maxRange = count
    l += 1

print(maxRange)





Fixed submission:
dts = input().split()
D = int(dts[0])
T = int(dts[1])
S = int(dts[2])

if T*S >= D:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
strings = input().splitlines()

# 一致している数の最大値を取得する。
# そして、その一致している数と、Tの数を比較する。足りない文字数を補うと良い

strS = list(strings[0])
strT = list(strings[1])

maxRange = 0
l = 0
while l < (len(strS)-len(strT)):
    m = 0
    count = 0
    while m < (len(strT)):
        if strS[l+m] == strT[m]:
            count += 1
        m += 1
    if maxRange < count:
        maxRange = count
    l += 1
print(len(strT)-maxRange)





Fixed submission:
dts = input().split()
D = int(dts[0])
T = int(dts[1])
S = int(dts[2])

if T*S >= D:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())
ans = 0
for i in range(1,n):
    ans += (n-1) // i
print(ans)

Fixed submission:
N = int(input())
ans = 0
for i in range(1,N):
    ans += (N - 1) // i
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
for i in range(1,n):
    ans += (n-1) // i
print(ans)

Fixed submission:
N = int(input())
ans = 0
for i in range(1,N):
    ans += (N - 1) // i
print(ans)

Buggy python submission (verdict: Runtime Error):
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    t = (arr[0][1]+1)*(arr[1][1]+1)
    print(t) 

    return arr

factorization(int(input())) 

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

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
mod = (10**9) + 7
t = 0
sum = 0
for i in range(1,n):
    sum += A[i]
for i in range(n-1):
    t += (A[i]*sum)%mod
    sum -=  A[i+1]
t = t%mod
print(t)

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

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
mod = (10**9) + 7
t = 0
sum = 0
for i in range(1,n):
    sum += A[i]
for i in range(n-1):
    t += (A[i]*sum)%mod
    sum -=  A[i+1]
t = t%mod
print(t)

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

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
mod = (10**9) + 7
t = 0
sum = 0
for i in range(1,n):
    sum += A[i]
for i in range(n-1):
    t += (A[i]*sum)%mod
    sum -=  A[i+1]
t = t%mod
print(t)

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

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
mod = (10**9) + 7
t = 0
sum = 0
for i in range(1,n):
    sum += A[i]
for i in range(n-1):
    t += (A[i]*sum)%mod
    sum -=  A[i+1]
t = t%mod
print(t)

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

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
mod = (10**9) + 7
t = 0
sum = 0
for i in range(1,n):
    sum += A[i]
for i in range(n-1):
    t += (A[i]*sum)%mod
    sum -=  A[i+1]
t = t%mod
print(t)

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

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
mod = (10**9) + 7
t = 0
sum = 0
for i in range(1,n):
    sum += A[i]
for i in range(n-1):
    t += (A[i]*sum)%mod
    sum -=  A[i+1]
t = t%mod
print(t)
Buggy python submission (verdict: Runtime Error):
n = input()
list_n = list(n)
list_n = [int(s) for s in list_n]
sum_list = 0
for i in list_n:
    sum_list += list_n[i]
if sum_list%9 ==0:
    print('Yes')
else:
    print('No')

Fixed submission:
n = input()
list_n = list(n)
list_n = [int(s) for s in list_n]
sum_list = 0
for i in range(len(list_n)):
    sum_list += list_n[i]
if sum_list%9 ==0:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
#移動の最小値(高速化問題)
x,k,d = map(int,input().split())
x = abs(x)
if (x//d) >=k:
    ans = x - d*k
else:
    y = x-(x//d)*d
    if k- (x//d)%2 != 0:
        ans = y
    else:
        ans = y-d
print(abs(ans))

Fixed submission:
S = input()
list_s = list(S)
count = 0
x = []
for i in range(3):
    if list_s[i] == 'R':
        count +=1
    elif list_s[i] == 'S':
        x.append(count)
        count = 0
x.append(count)
print(max(x))

Buggy python submission (verdict: Runtime Error):
S = input()
    list_s = list(S)
    count = 0
if 1<len(list_s)<4
for i in range(2):
    if list_s[i] == 'R':
        count +=1
    elif list_s[i] == 'S':
        count = 0
print(count)

Fixed submission:
S = input()
list_s = list(S)
count = 0
x = []
for i in range(3):
    if list_s[i] == 'R':
        count +=1
    elif list_s[i] == 'S':
        x.append(count)
        count = 0
x.append(count)
print(max(x))

Buggy python submission (verdict: Runtime Error):
S = input()
if 1< S <4:
    list_s = list(S)
    count = 0
    for i in range(3):
        if list_s[i] == 'R':
            count +=1
        elif list_s[i] == 'S':
            count = 0
    print(count)

Fixed submission:
S = input()
list_s = list(S)
count = 0
x = []
for i in range(3):
    if list_s[i] == 'R':
        count +=1
    elif list_s[i] == 'S':
        x.append(count)
        count = 0
x.append(count)
print(max(x))

Buggy python submission (verdict: Runtime Error):
S = input()
if S<4:
    list_s = list(S)
    count = 0
    for i in range(3):
        if list_s[i] == 'R':
            count +=1
        elif list_s[i] == 'S':
            count = 0
    print(count)

Fixed submission:
S = input()
list_s = list(S)
count = 0
x = []
for i in range(3):
    if list_s[i] == 'R':
        count +=1
    elif list_s[i] == 'S':
        x.append(count)
        count = 0
x.append(count)
print(max(x))
Buggy python submission (verdict: Runtime Error):
#移動の最小値(高速化問題)
x,k,d = map(int,input().split())
x = abs(x)
if (x//d) >=k:
    ans = x - d*k
y = x-(x//d)*d
elif k- (x//d)%2 != 0:
    ans = y
else:
    ans = y-d
print(abs(ans))

Fixed submission:
#移動の最小値(高速化問題)
x,k,d = map(int,input().split())
x = abs(x)
if (x//d) > k:
    ans = x - d*k
elif (k-(x//d))%2 == 0:
    y = x-(x//d)*d
    ans = y
else:
    y = x-(x//d)*d
    ans = y-d
print(abs(ans))

Buggy python submission (verdict: Time Limit Exceeded):
x,k,d = map(int,input().split())
for i in range(k):
    if x >= 0:
        x -=d
    elif x < 0:
        x +=d
print(abs(x))


Fixed submission:
#移動の最小値(高速化問題)
x,k,d = map(int,input().split())
x = abs(x)
if (x//d) > k:
    ans = x - d*k
elif (k-(x//d))%2 == 0:
    y = x-(x//d)*d
    ans = y
else:
    y = x-(x//d)*d
    ans = y-d
print(abs(ans))