Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
arr=[list(map(int,input().split())) for i in range(3)]

count=0

for i in range(N):
    for j in range(N):

        if arr[0][i]<arr[1][j]:
            for k in range(N):

                if arr[1][j]<arr[2][k]:
                    count+=1

print(count)
                

Fixed submission:
N=int(input())
A,B,C=[list(sorted(map(int,input().split()))) for i in range(3)]

count=0

def bs_l(lis,x):
    low,high=0,len(lis)
    while low<high:
        mid=(low+high)//2
        if lis[mid]<x:
            low=mid+1
        else:
            high=mid
    return low        

def bs_r(lis,x):
    low,high=0,len(lis)
    while low<high:
        mid=(low+high)//2
        if lis[mid]>x:
            high=mid
        else:
            low=mid+1
    return low        

for i in B:
    count+=bs_l(A,i)*(N-bs_r(C,i))


print(count)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations, combinations_with_replacement
from math import sqrt


n = int(input())
ans = [0] * (n + 1)
for x, y, z in combinations_with_replacement(range(1, int(sqrt(n)) + n // 10), 3):
    i = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
    if i <= n:
        if x == y == z:
            ans[i] += 1
        elif all([not(s != t) for s, t in combinations([x, y, z], 2)]):
            ans[i] += 6
        else:
            ans[i] += 3

for i in range(1, n + 1):
    print(ans[i])


Fixed submission:
from itertools import combinations, combinations_with_replacement
from math import sqrt


n = int(input())
ans = [0] * (n + 1)
for x, y, z in combinations_with_replacement(range(1, int(sqrt(n))), 3):
    i = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
    if i <= n:
        if x == y == z:
            ans[i] += 1
        elif all([(s != t) for s, t in combinations([x, y, z], 2)]):
            ans[i] += 6
        else:
            ans[i] += 3

for i in range(1, n + 1):
    print(ans[i])

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations_with_replacement
from math import sqrt


n = int(input())
for i in range(1, n + 1):
    ans = 0
    for x, y, z in combinations_with_replacement(range(1, int(sqrt(n))), 3):
        if x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x == i:
            if x == y == z:
                ans += 1
            else:
                ans += 3
    print(ans)


Fixed submission:
from itertools import combinations, combinations_with_replacement
from math import sqrt


n = int(input())
ans = [0] * (n + 1)
for x, y, z in combinations_with_replacement(range(1, int(sqrt(n))), 3):
    i = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
    if i <= n:
        if x == y == z:
            ans[i] += 1
        elif all([(s != t) for s, t in combinations([x, y, z], 2)]):
            ans[i] += 6
        else:
            ans[i] += 3

for i in range(1, n + 1):
    print(ans[i])
Buggy python submission (verdict: Runtime Error):
s = input()

for idx in range(len(s)):
    if s[idx] == '?':
        s[idx] = 'D'

print(s)
 

Fixed submission:
s = input()

for idx in range(len(s)):
    if s[idx] == '?':
        print('D', end='')
    else:
        print(s[idx], end='')

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

s = 10000
for i in range(-s, s):
    flag = False
    for j in range(-s, s):
        tmp = i ** 5 - j ** 5
        if tmp == x:
            print('{} {}'.format(i, j))
            flag = True
            break
    if flag:
        break



Fixed submission:
x = int(input())

for i in range(-1000, 1000):
    flag = False
    for j in range(-1000, 1000):
        tmp = i ** 5 - j ** 5
        if tmp == x:
            print('{} {}'.format(i, j))
            flag = True
            break
    if flag:
        break
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import pprint
import math

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

s = min(n, b)
max_num = 0
for x in range(s + 1):
    tmp = math.floor(a * x / b) - a * math.floor(x / b)
    max_num = max(max_num, tmp)

print(max_num)


Fixed submission:
import numpy as np
import pprint
import math

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

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

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from decimal import *
import sys

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

N = int(input())

A = [Decimal(input()) for i in range(N)]

nanachi = [[0, 0] for i in range(N)]

eprint(A)

def is_integer(n: Decimal):
  return n == n.to_integral_value()

for i, a in enumerate(A):
  t = 0
  while not is_integer(a):
    a *= 10
    t += 1
  nanachi[i][0] = -t
  nanachi[i][1] = -t
  while a % 2 == 0:
    a = a / 2
    nanachi[i][0] += 1
  while a % 5 == 0:
    a = a / 5
    nanachi[i][1] += 1

eprint(nanachi)

tmp = min(map(min, nanachi))

for i in range(N):
  nanachi[i][0] -= tmp
  nanachi[i][1] -= tmp

eprint(nanachi)

aaa = [[0] * 200 for i in range(200)]

for a in nanachi:
  aaa[a[0]][a[1]] += 1

acc = [[0] * 201 for i in range(201)]

for i in reversed(range(0, 200)):
  for k in reversed(range(0, 200)):
    acc[i][k] = acc[i+1][k] + acc[i][k+1] - acc[i+1][k+1] + aaa[i][k]

res = 0

for a in nanachi:
  i = max(0, - (a[0] + 2*tmp))
  k = max(0, - (a[1] + 2*tmp))
  res += acc[i][k]
  if a[0] >= -tmp and a[1] >= -tmp:
    res -= 1

res = res // 2

print(res)


Fixed submission:
from decimal import *
import sys

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

N = int(input())

A = [Decimal(input()) for i in range(N)]

nanachi = [[0, 0] for i in range(N)]

eprint(A)

def is_integer(n: Decimal):
  return n == n.to_integral_value()

for i, a in enumerate(A):
  t = 0
  while not is_integer(a):
    a *= 10
    t += 1
  nanachi[i][0] = -t
  nanachi[i][1] = -t
  while a % 2 == 0:
    a = a / 2
    nanachi[i][0] += 1
  while a % 5 == 0:
    a = a / 5
    nanachi[i][1] += 1

eprint(nanachi)

tmp = min(map(min, nanachi))

for i in range(N):
  nanachi[i][0] -= tmp
  nanachi[i][1] -= tmp

eprint(nanachi)

aaa = [[0] * 200 for i in range(200)]

for a in nanachi:
  aaa[a[0]][a[1]] += 1

acc = [[0] * 201 for i in range(201)]

for i in reversed(range(0, 200)):
  for k in reversed(range(0, 200)):
    acc[i][k] = acc[i+1][k] + acc[i][k+1] - acc[i+1][k+1] + aaa[i][k]

res = 0

for a in nanachi:
  i = max(0, - (a[0] + 2*tmp))
  k = max(0, - (a[1] + 2*tmp))
  res += acc[i][k]
  if a[0] >= -tmp and a[1] >= -tmp:
    res -= 1

res = res // 2

print(res)
Buggy python submission (verdict: Runtime Error):
from subprocess import run
from os import path

if not path.exists("./tmp215378912379"):
  with open("./tmp215378912379.cpp", mode='w') as f:
    f.write("""
  #include <bits/stdc++.h>
  template <class T>
  concept Integral = std::is_integral_v<T>;

  int main() {
    auto f = []<Integral T>(T a, T b) { return a * b; };
    int a, b;
    std::cin >> a >> b;
    std::cout << f(a, b) << std::endl;
  }
  """)

  run("g++ -o ./tmp215378912379 -std=gnu++2a fconcepts ./tmp215378912379.cpp")

run("./tmp215378912379")

Fixed submission:
from subprocess import run

with open("./tmp215378912379.cpp", mode='w') as f:
  f.write("""
#include <bits/stdc++.h>
template <class T>
concept Integral = std::is_integral_v<T>;

int main() {
  auto f = []<Integral T>(T a, T b) { return a * b; };
  int a, b;
  std::cin >> a >> b;
  std::cout << f(a, b) << std::endl;
}
""")

run("g++ -o ./tmp215378912379 -std=gnu++2a -fconcepts ./tmp215378912379.cpp && ./tmp215378912379", shell=True)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
from fractions import gcd
from functools import reduce

N = int(input())

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

L = reduce((lambda x, y: x // gcd(x, y) * y), A)

res = 0

MOD = 10**9+7

for a in A:
  res = (res + L//a % MOD) % MOD

print(res)


Fixed submission:
#!/usr/bin/env python3
from fractions import gcd
from functools import reduce

N = int(input())

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

MOD = 10**9+7

L = reduce((lambda x, y: x // gcd(x, y) * y), A) % MOD

res = 0

def modulo(x, y):
  tmp = x % y
  if tmp < 0: tmp += y
  return tmp

def extgcd(x, y):
  if x < y:
    a, b = extgcd(y, x)
    return b, a
  if y == 0 or x % y == 0: return 0, 1
  a, b = extgcd(y, modulo(x , y))
  return (b, -(x // y) * b + a)

def inv(x):
  a, _ = extgcd(x,MOD)
  return modulo(a, MOD)

for a in A:
  res = (res + L* inv(a) % MOD) % MOD

print(res)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
from fractions import gcd
from functools import reduce

N = int(input())

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

L = reduce((lambda x, y: x // gcd(x, y) * y), A)

res = 0

MOD = 10**9+7

for a in A:
  res = (res + L//a % MOD) % MOD

print(res)

Fixed submission:
#!/usr/bin/env python3
from fractions import gcd
from functools import reduce

N = int(input())

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

MOD = 10**9+7

L = reduce((lambda x, y: x // gcd(x, y) * y), A) % MOD

res = 0

def modulo(x, y):
  tmp = x % y
  if tmp < 0: tmp += y
  return tmp

def extgcd(x, y):
  if x < y:
    a, b = extgcd(y, x)
    return b, a
  if y == 0 or x % y == 0: return 0, 1
  a, b = extgcd(y, modulo(x , y))
  return (b, -(x // y) * b + a)

def inv(x):
  a, _ = extgcd(x,MOD)
  return modulo(a, MOD)

for a in A:
  res = (res + L* inv(a) % MOD) % MOD

print(res)
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
H=sorted(list(map(int,input().split())),reverse=True)
for i in range(K):H[i]=0
print(sum(H))


Fixed submission:
N,K=map(int,input().split())
H=sorted(list(map(int,input().split())),reverse=True)
if N<K:K=N
for i in range(K):H[i]=0
print(sum(H))
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N,M=[int(i) for i in input().split()]
A = sorted([int(i) for i in input().split()])
for i in range(M):
  A2=A[N-1]//2
  A.pop(N-1)
  A.insert(bisect.bisect_left(A, A2), A2)
print(sum(A))


Fixed submission:
import heapq
N,M=[int(i) for i in input().split()]
A=sorted([-int(i) for i in input().split()])
for i in range(M):heapq.heappush(A,-(-heapq.heappop(A)//2))
print(-sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N,M=[int(i) for i in input().split()]
A = sorted([int(i) for i in input().split()])
for i in range(M):
  A2=A[N-1]//2
  A.pop(N-1)
  bisect.insort_left(A,A2)
print(sum(A))

Fixed submission:
import heapq
N,M=[int(i) for i in input().split()]
A=sorted([-int(i) for i in input().split()])
for i in range(M):heapq.heappush(A,-(-heapq.heappop(A)//2))
print(-sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
N,M=[int(i) for i in input().split()]
A = [int(i) for i in input().split()]
for i in range(M):
  l=A.index(max(A))
  A[l]//=2
print(sum(A))

Fixed submission:
import heapq
N,M=[int(i) for i in input().split()]
A=sorted([-int(i) for i in input().split()])
for i in range(M):heapq.heappush(A,-(-heapq.heappop(A)//2))
print(-sum(A))
Buggy python submission (verdict: Runtime Error):
A = [input() for i in range(N)]
maxA = max(A)
secA = sorted(A)[-2]
num=A.count(maxA)
#print(N,A,maxA,secA,num)

for i in range(N):
  if num>1:
    print(maxA)
  elif A[i]==maxA:
    print(secA)
  else:
    print(maxA)

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
maxA = max(A)
secA = sorted(A)[-2]
num=A.count(maxA)
#print(N,A,maxA,secA,num)
 
for i in range(N):
  if num>1:print(maxA)
  elif A[i]==maxA:print(secA)
  else:print(maxA)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [input() for i in range(N)]
maxA = max(A)
secA = sorted(set(A))[-2]
num=A.count(maxA)
#print(N,A,maxA,secA,num)

for i in range(N):
  if num>1:
    print(maxA)
  elif A[i]==maxA:
    print(secA)
  else:
    print(maxA)

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
maxA = max(A)
secA = sorted(A)[-2]
num=A.count(maxA)
#print(N,A,maxA,secA,num)
 
for i in range(N):
  if num>1:print(maxA)
  elif A[i]==maxA:print(secA)
  else:print(maxA)
Buggy python submission (verdict: Time Limit Exceeded):
R,G,B,N=[int(i) for i in input().split()]
num = 0
for i in range(N//R+1):
  for j in range(N//G+1):
#    print(i*R,j*G)
    if i*R+j*G<=N:
      if (N-i*R-j*G)%B==0:
#        print((N-i*R-j*G))
        num+=1
print(num)

Fixed submission:
R,G,B,N=[int(i) for i in input().split()]
num = 0
for i in range(N//R+1):
  for j in range(N//G+1):
#    print(i*R,j*G)
    if i*R+j*G<=N:
      if (N-i*R-j*G)%B==0:
#        print((N-i*R-j*G))
        num+=1
print(num)
Buggy python submission (verdict: Runtime Error):
N = int(input())
num = 0
for i in range(1,int(N**0.5)+1):
  m = N//i-1
#  print(i,m)
  if (N//m) == (N % m):num += m
print(num)


Fixed submission:
N = int(input())
num = 0
for i in range(1,int(N**0.5)+1):
  m = N//i-1
  if m!=0 :
#  print(i,m)
    if (N//m) == (N % m):num += m
print(num)
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)

N = (int(input())+1)
A = [int(i) for i in input().split()]
max = 0

for i in range(N-1):
  G = 0
  for j in range(N-1):
    if i==j : continue
    if G==0 : G = A[j] ; continue
    else : G = gcd(G,A[j])
  if max<G :max = G

print(max)

Fixed submission:
def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)
 
N = (int(input()))
A = [int(i) for i in input().split()]

A1 = [0] * (N)
A2 = [0] * (N)
A3 = [0] * (N)
A1[0] = A[0]
A2[N-1] = A[N-1]

for i in range(N):
  if i==0 : continue
  A1[i] = gcd(A1[i-1],A[i])
  A2[N-1-i] = gcd(A2[N-i],A[N-1-i])
  
for i in range(N):
  if i==0 : A3[i] = A2[i+1] ; continue
  if i==N-1 : A3[i] = A1[i-1] ; continue
  A3[i] = gcd(A1[i-1],A2[i+1])

print(max(A3))
Buggy python submission (verdict: Time Limit Exceeded):
N,Y=[int(i) for i in input().split()]
#a=万 b=五千 c=千
a=0
while a*10000<=Y:
  c=0
  while a*10000+c*1000<=Y:
    B=Y-a*10000-c*1000
    if B%5000==0:
      b=B//5000
      if a+b+c==N:
        print(a,b,c)
        exit()
    c+=1
  a+=1
else :print(-1,-1,-1)

Fixed submission:
N,Y=[int(i) for i in input().split()]
#a=万 b=五千 c=千
a=0
while a*10000<=Y:
  c=0
  while a*10000+c*1000<=Y:
    if a+c>N:break
    B=Y-a*10000-c*1000
    if B%5000==0:
      b=B//5000
      if a+b+c==N:
        print(a,b,c)
        exit()
    c+=1
  a+=1
else :print(-1,-1,-1)
Buggy python submission (verdict: Runtime Error):
S = int(input())
from math import factorial
ans = 0


m = S // 3 #最大桁数

print(m)

for p in range(1,m+1):
    x = S - 3*(p) #p桁 自由度x
    a = factorial(x+p-1) 
    b = factorial(p-1) 
    c = factorial(x)
    ans += ( a / b / c )%(10**9+7)


print(int((ans)%(10**9+7)))




Fixed submission:
S = int(input())
from math import factorial
ans = 0


m = S // 3 #最大桁数

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



for p in range(1,m+1):
    x = S - 3*(p) #p桁 自由度x
    """
    a = factorial(x+p-1) 
    b = factorial(p-1) 
    c = factorial(x)
    ans += ( a / b / c )%(10**9+7)
    """
    ans += cmb(x+p-1,p-1)


print(int((ans)%(10**9+7)))
Buggy python submission (verdict: Runtime Error):
K = int(input())
a = ""
ans = 0
amari = 10

if K%2 == 0:
    print(-1)
elif K%5 == 0:
    print(-1)
elif K%7 == 0:
    L = 9*K//7
else:
    L = 9*K

for p in range(10**6):
    if amari % L == 1:
        print(p+1)
        break
    else:
        amari = (amari*10)%L

Fixed submission:
K = int(input())
a = ""
ans = 0
amari = 10

if K%2 == 0:
    print(-1)
elif K%5 == 0:
    print(-1)

else:
    if K%7 == 0:
        L = 9*K//7
    else:
        L = 9*K

    for p in range(10**6):
        if amari % L == 1:
            print(p+1)
            break
        else:
            amari = (amari*10)%L

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
a = ""
ans = 0

if K%2 == 0:
    print(-1)
elif K%5 == 0:
    print(-1)

else:
    while True:
        a += "7"
        ans += 1
        if int(a)%K == 0:
            break
    print(ans)

Fixed submission:
K = int(input())
a = ""
ans = 0
amari = 10

if K%2 == 0:
    print(-1)
elif K%5 == 0:
    print(-1)

else:
    if K%7 == 0:
        L = 9*K//7
    else:
        L = 9*K

    for p in range(10**6):
        if amari % L == 1:
            print(p+1)
            break
        else:
            amari = (amari*10)%L

Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
a = ""
ans = 0

if K%2 == 0:
    print(-1)

else:
    while True:
        a += "7"
        ans += 1
        if int(a)%K == 0:
            break
    print(ans)

Fixed submission:
K = int(input())
a = ""
ans = 0
amari = 10

if K%2 == 0:
    print(-1)
elif K%5 == 0:
    print(-1)

else:
    if K%7 == 0:
        L = 9*K//7
    else:
        L = 9*K

    for p in range(10**6):
        if amari % L == 1:
            print(p+1)
            break
        else:
            amari = (amari*10)%L
Buggy python submission (verdict: Runtime Error):
x, n = map(int,input().split())
p = [int(s) for s in input().split()]
k= 100

for r in range (1,101):
    if (r not in p):
        if (abs(x - int(r)) < k):
            A = int(r)
            k = abs(x - int(r))
if (A > x):
    if (2*x-A not in p):
        A = 2*x-A

print (A)





Fixed submission:
x, n = map(int,input().split())
p = [int(s) for s in input().split()]
k= 100

for r in range (0,102):
    if (r not in p):
        if (abs(x - int(r)) < k):
            A = int(r)
            k = abs(x - int(r))
if (A > x):
    if (2*x-A not in p):
        A = 2*x-A

print (A)
Buggy python submission (verdict: Runtime Error):
A, V = map(int,input(),split())
B, W = map(int,input(),split())
T = input()
if (V <= W):
    print("NO")
elif(T < abs(A - B)/(V-W)):
    print("NO")
else:
    print("YES")


Fixed submission:
A, V = map(int,input().split())
B, W = map(int,input().split())
T = int(input())
if (V <= W):
    print("NO")
elif(T < abs(A - B)/(V-W)):
    print("NO")
else:
    print("YES")

Buggy python submission (verdict: Runtime Error):
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())
time = 0
timeyosou = abs(B-A)/(V-W)

if (V <= W):
    if (A < B):
        time = (10**9-A)/V
    else:
        time = (10**9+A)/V
else:
    if (A < B):
        if ((10**9 - B)/W > timeyosou):
           time = timeyosou
        else:
            time = (10**9 - A)/V
    if (A > B):
        if ((10**9 + B)/W > timeyosou):
           time = timeyosou
        else:
            time = (10**9 + A)/V
if (T > time):
    print ("YES")
else:
    print("NO")


Fixed submission:
A, V = map(int,input().split())
B, W = map(int,input().split())
T = int(input())
if (V <= W):
    print("NO")
elif(T < abs(A - B)/(V-W)):
    print("NO")
else:
    print("YES")

Buggy python submission (verdict: Runtime Error):
A, V = map(int, input().split())
B, W = map(int, input().split())
T = input()
time = 0
timeyosou = abs(B-A)/(V-W)

if (V <= W):
    if (A < B):
        time = (10**9-A)/V
    else:
        time = (10**9+A)/V
else:
   if (A < B):
       if ((10**9 - B)/W > timeyosou):
           time = timeyosou
        else:
            time = (10**9 - A)/V
    if (A > B):
        if ((10**9 + B)/W > timeyosou):
           time = timeyosou
        else:
            time = (10**9 + A)/V



Fixed submission:
A, V = map(int,input().split())
B, W = map(int,input().split())
T = int(input())
if (V <= W):
    print("NO")
elif(T < abs(A - B)/(V-W)):
    print("NO")
else:
    print("YES")
Buggy python submission (verdict: Time Limit Exceeded):
N,X,M=map(int,input().split())
table=[X]

ans=X

for i in range(N-1):
    nx=table[i]**2
    nx%=M
    if nx in table:
        first=table.index(nx)
        oneloop=i+1-first
        rest=N-i-1
        loops=rest//oneloop
        totalofoneloop=sum(table[first:])
        ans+=totalofoneloop*loops
        remain=rest%oneloop
        ans+=sum(table[first:first+remain])
        print(ans)
        exit()
    else:
        table.append(nx)
        ans+=nx
 

print(ans)

Fixed submission:
N,X,M=map(int,input().split())
table=[X]
visited=[-1]*M
visited[X]=1

ans=X

for i in range(N-1):
    nx=table[i]**2
    nx%=M
    if visited[nx]>0:
        first=table.index(nx)
        oneloop=i+1-first
        rest=N-i-1
        loops=rest//oneloop
        totalofoneloop=sum(table[first:])
        ans+=totalofoneloop*loops
        remain=rest%oneloop
        ans+=sum(table[first:first+remain])
        print(ans)
        exit()
    else:
        table.append(nx)
        visited[nx]=1
        ans+=nx
 

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))

ans=0
inf=10**9+7
flag=True
for i in range(N-1):
    if A[i]!=0:
        for j in range(i+1,N):
            temp=(A[i]*A[j])%inf
            ans+=temp
            ans%=inf
 
          
print(ans)

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

ans=0
inf=10**9+7
flag=True
total=0
for i in range(N):
    total+=A[i]
    total%=inf

for i in range(N): 
    total-=A[i]
    ans+=A[i]*total
    ans%=inf    
          
print(ans)

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

ans=0
inf=10**9+7
for i in range(N-1):
    if A[i]!=0:
        for j in range(i+1,N):
            ans+=A[i]*A[j]
        ans=ans%inf    
print(ans)

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

ans=0
inf=10**9+7
flag=True
total=0
for i in range(N):
    total+=A[i]
    total%=inf

for i in range(N): 
    total-=A[i]
    ans+=A[i]*total
    ans%=inf    
          
print(ans)

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

ans=0
inf=10**9+7
for i in range(N-1):
    for j in range(i+1,N):
        ans+=A[i]*A[j]
        ans=ans%inf
print(ans)

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

ans=0
inf=10**9+7
flag=True
total=0
for i in range(N):
    total+=A[i]
    total%=inf

for i in range(N): 
    total-=A[i]
    ans+=A[i]*total
    ans%=inf    
          
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))

for i in range(n):
    if a[0]<a[i]:
        up=True
        nin=a[0]
        break
    elif a[0]>a[i]:
        up=False
        break
    if i==n-1:
        print(1000)
        exit()

total=1000

for i in range(1,n-1):
    if up:
        if a[i-1]<=a[i] and a[i]>a[i+1]:
            total+=(total//nin)*(a[i]-nin)
            up=False
    else:
        if a[i-1]>=a[i] and a[i]<a[i+1]:
            nin=a[i]
            up=True
if nin<a[n-1]:
    total+=(total//nin)*(a[n-1]-nin)
print(total)

Fixed submission:
x=int(input())

if 400<=x and x<=599:
    print(8)
elif 600<=x and x<=799:
    print(7)
elif 800<=x and x<=999:
    print(6)
elif 1000<=x and x<=1199:
    print(5)
elif 1200<=x and x<=1399:
    print(4)
elif 1400<=x and x<=1599:
    print(3)
elif 1600<=x and x<=1799:
    print(2)
elif 1800<=x and x<=1999:
    print(1)

Buggy python submission (verdict: Runtime Error):
x=int(input())

if 400<=x and x<=599:
    print(8)
elif:
    600<=x and x<=799:
    print(7)
elif:
    800<=x and x<=999:
    print(6)
elif:
    1000<=x and x<=1199:
    print(5)
elif:
    1200<=x and x<=1399:
    print(4)
elif:
    1400<=x and x<=1599:
    print(3)
elif:
    1600<=x and x<=1799:
    print(2)
elif:
    1800<=x and x<=1999:
    print(1)    

Fixed submission:
x=int(input())

if 400<=x and x<=599:
    print(8)
elif 600<=x and x<=799:
    print(7)
elif 800<=x and x<=999:
    print(6)
elif 1000<=x and x<=1199:
    print(5)
elif 1200<=x and x<=1399:
    print(4)
elif 1400<=x and x<=1599:
    print(3)
elif 1600<=x and x<=1799:
    print(2)
elif 1800<=x and x<=1999:
    print(1)