Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

result_num = 0
words = [''.join(sorted(str(input())))]
count_dict = {}
count_dict[words[0]] = 1

for i in range(n-1):
  word = ''.join(sorted(str(input())))

  if word in words:
    result_num += count_dict[word]
    count_dict[word] += 1
  else:
    words.append(word)
    count_dict[word] = 1

print(result_num)

Fixed submission:
n = int(input())

result_num = 0
count_dict = {''.join(sorted(str(input()))): 1}

for i in range(n-1):
  word = ''.join(sorted(str(input())))

  if word in count_dict.keys():
    result_num += count_dict[word]
    count_dict[word] += 1
  else:
    count_dict[word] = 1

print(result_num)

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

result_num = 0
words = [sorted(str(input()))]
count_num = [1]

for i in range(n-1):
  word = sorted(str(input()))
  exist = 0
  
  for j, word_ in enumerate(words):
    if word == word_:
      result_num += count_num[j]
      count_num[j] += 1
      exist += 1
      
  if exist == 0:
    words.append(word)
    count_num.append(1)
  
print(result_num)

Fixed submission:
n = int(input())

result_num = 0
count_dict = {''.join(sorted(str(input()))): 1}

for i in range(n-1):
  word = ''.join(sorted(str(input())))

  if word in count_dict.keys():
    result_num += count_dict[word]
    count_dict[word] += 1
  else:
    count_dict[word] = 1

print(result_num)

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

result_num = 0
words = []
for i in range(n):
  word = sorted(str(input()))
  for word_ in words:
    if word == word_:
      result_num += 1
  words.append(word)
  
print(result_num)

Fixed submission:
n = int(input())

result_num = 0
count_dict = {''.join(sorted(str(input()))): 1}

for i in range(n-1):
  word = ''.join(sorted(str(input())))

  if word in count_dict.keys():
    result_num += count_dict[word]
    count_dict[word] += 1
  else:
    count_dict[word] = 1

print(result_num)
Buggy python submission (verdict: Time Limit Exceeded):
l, r = map(int, input().split())

mod = 2020
for i in range(l, r, 1):
  for j in range(i + 1, r + 1, 1):
    a = (i * j) % 2019
    if a < mod:
      mod = a

print(mod)

Fixed submission:
l, r = map(int, input().split())

mod = 2020
for i in range(l, r, 1):
  for j in range(i + 1, r + 1, 1):
    a = (i * j) % 2019
    if a == 0:
      mod = a
      break
    elif a < mod:
      mod = a
  else:
    continue
  break

print(mod)
Buggy python submission (verdict: Runtime Error):
n = int(input())
Ps = list(map(int, input().split()))

count = 0
for i in range(1, n - 1):
  if (p[i-1] < p[i]) and (p[i] < p[i+1]):
    count += 1
  elif (p[i-1] > p[i]) and (p[i] > p[i+1]):
    count += 1

print(count)

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

count = 0
for i in range(1, n - 1):
  if (Ps[i-1] < Ps[i]) and (Ps[i] < Ps[i+1]):
    count += 1
  elif (Ps[i-1] > Ps[i]) and (Ps[i] > Ps[i+1]):
    count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
n = int(input())

ds = list(map(int, input().split()))
ds.sort()

max_abc = ds[n/2 - 1]
min_arc = ds[n_2]

print(max_abc - min_arc)

Fixed submission:
n = int(input())

ds = list(map(int, input().split()))
ds.sort()

max_abc = ds[int(n/2 - 1)]
min_arc = ds[int(n/2)]

print(min_arc - max_abc)
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())

d = 0
for i, l in enumerate(input().split()):
  d += int(l)
  if d > x:
    print(i + 1)
    break
else:
  prin(n + 1)

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

d = 0
for i, l in enumerate(input().split()):
  d += int(l)
  if d > x:
    print(i + 1)
    break
else:
  print(n + 1)

Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())

d = 0
for i, l in enumerate(input().split()):
  d += int(l)
  if d > x:
    print(i)
    break
else:
  prin(n)

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

d = 0
for i, l in enumerate(input().split()):
  d += int(l)
  if d > x:
    print(i + 1)
    break
else:
  print(n + 1)
Buggy python submission (verdict: Runtime Error):
import sys
n, m = map(int, input().split())

if m > 0:
  As = set(map(int, sys.stdin))
else:
  As = set()

nums = [0] * (n + 1)
nums[0] = 1
if 1 in As:
  pass
else:
  nums[1] = 1
  
for i in range(2, n + 1):
  if i in As:
    continue
  else:
    nums[i] = (nums[i-1] + nums[i-2]) % 1000000007
    
print(nums[-1])

Fixed submission:
p, q, r = map(int, input().split())

print(p + q + r - max(p, q, r))

Buggy python submission (verdict: Runtime Error):
p, q, r = map(int, input().split())

print(p + q + r - map(p, q, r))

Fixed submission:
p, q, r = map(int, input().split())

print(p + q + r - max(p, q, r))
Buggy python submission (verdict: Runtime Error):
n = int(input())

nums = list(map(int, input().split()))
sums = [nums[0]]
for i in range(1, n):
  sums.append(sums[i-1] + nums[i])
  
min_diff = 100
index = 0
for sum in sums:
  if sum - (sum[-1] - sum) < min_diff:
    min_diff = sum - (sum[-1] - sum)
    
print(min_diff)

Fixed submission:
n = int(input())

nums = list(map(int, input().split()))
sums = [nums[0]]
for i in range(1, n):
  sums.append(sums[i-1] + nums[i])
  
min_diff = 100
index = 0
for sum in sums:
  if abs(sum - (sums[-1] - sum)) < min_diff:
    min_diff = abs(sum - (sums[-1] - sum))
    
print(min_diff)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
n, m = map(int, input().split())

As = []
a_ = -1
for i in range(m):
  a = int(input())
  if a == a_ + 1:
    print(0)
    sys.exit()
  As.append(a)
  a_ = a

nums = [1] + [0] * n
if 1 in As:
  pass
else:
  nums[1] = 1
  
for i in range(2, n + 1):
  if i in As:
    continue
  else:
    nums[i] = (nums[i-1] + nums[i-2]) % 1000000007
    
print(nums[-1])

Fixed submission:
import sys
n, m = map(int, input().split())

if m > 0:
  As = set(map(int, sys.stdin))
else:
  As = set()

nums = [0] * (n + 1)
nums[0] = 1
if 1 in As:
  pass
else:
  nums[1] = 1
  
for i in range(2, n + 1):
  if i in As:
    continue
  else:
    nums[i] = (nums[i-1] + nums[i-2]) % 1000000007
    
print(nums[-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
n, m = map(int, input().split())

As = []
a_ = -1
for i in range(m):
  a = int(input())
  if a == a_ + 1:
    print(0)
    sys.exit()
  As.append(a)
  a_ = a

nums = [1]
if 1 in As:
  nums.append(0)
else:
  nums.append(1)
  
for i in range(2, n + 1):
  if i in As:
    nums.append(0)
  else:
    nums.append((nums[i-1] + nums[i-2]) % 1000000007)
    
print(nums[-1])

Fixed submission:
import sys
n, m = map(int, input().split())

if m > 0:
  As = set(map(int, sys.stdin))
else:
  As = set()

nums = [0] * (n + 1)
nums[0] = 1
if 1 in As:
  pass
else:
  nums[1] = 1
  
for i in range(2, n + 1):
  if i in As:
    continue
  else:
    nums[i] = (nums[i-1] + nums[i-2]) % 1000000007
    
print(nums[-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
n, m = map(int, input().split())

As = []
a_ = -1
for i in range(m):
  a = int(input())
  if a == a_ + 1:
    print(0)
    sys.exit()
  As.append(a)
  a_ = a

nums = [1]
if 1 in As:
  nums.append(0)
else:
  nums.append(1)
  
for i in range(2, n + 1):
  if i in As:
    nums.append(0)
  else:
    nums.append(nums[i-1] + nums[i-2])
    
print(nums[-1] % 1000000007)

Fixed submission:
import sys
n, m = map(int, input().split())

if m > 0:
  As = set(map(int, sys.stdin))
else:
  As = set()

nums = [0] * (n + 1)
nums[0] = 1
if 1 in As:
  pass
else:
  nums[1] = 1
  
for i in range(2, n + 1):
  if i in As:
    continue
  else:
    nums[i] = (nums[i-1] + nums[i-2]) % 1000000007
    
print(nums[-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())

As = []
for i in range(m):
  As.append(int(input()))

nums = [1]
if 1 in As:
  nums.append(0)
else:
  nums.append(1)
  
for i in range(2, n + 1):
  if i in As:
    nums.append(0)
  else:
    nums.append(nums[i-1] + nums[i-2])
    
print(nums[-1] % 1000000007)

Fixed submission:
import sys
n, m = map(int, input().split())

if m > 0:
  As = set(map(int, sys.stdin))
else:
  As = set()

nums = [0] * (n + 1)
nums[0] = 1
if 1 in As:
  pass
else:
  nums[1] = 1
  
for i in range(2, n + 1):
  if i in As:
    continue
  else:
    nums[i] = (nums[i-1] + nums[i-2]) % 1000000007
    
print(nums[-1])
Buggy python submission (verdict: Runtime Error):
N, M = list(map(int, input().split()))

As = list(map(int, input().split()))
As.sort()

BCs = []
for _ in range(M):
  b, c = tuple(map(int, input().split()))
  BCs.append((b, c))
BCs.sort(key=lambda x: x[1], reverse=True)
  
num = 0
i = 0
for b, c in BCs:
  for j in range(b):
    a = As[i]
    if a >= c or i == len(As):
      break
    else:
      num += c
      i += 1
  if a >= c or i == len(As):
    break
num += sum(As[i: ])
    
print(num)

Fixed submission:
A, B = [int(x) for x in input().split(' ')]

if A >= 13:
  print(B)
elif 6 <= A < 13:
  print(B//2)
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
import math

N = int(input())
d_list = []

for i in range(3, int(math.sqrt(N))):
  if N % i == 0:
    d_list.append(i)
    if i != math.sqrt(N):
      d_lsit.append(N / i)

output = sum(d_list) - (len(d_list) - 2) - 3
print(output)


Fixed submission:
N, K = [int(x) for x in input().split(' ')]

output = N - K + 1

print(int(output))

Buggy python submission (verdict: Runtime Error):
N = int(input())
s_list = []
count = 0
n, m, l = 0, 0, 0

for i in range(N):
  s = input()
  s_list.append(s)
  count += s.count('AB')
  if s[0] == 'B' and s[-1] == 'A':
    n += 1
    continue
  elif s[-1] == 'A':
    m += 1
  elif s[0] == 'B':
    l += 1

if n < m and n < l:
  print(int(count + 2 * n + min(m - n, l - n)))
elif n > m and n > l:
  print(int(count + 2 * (n - max(m, l) + m + l)
else:
  print(int(count + min(n, m) + min(n, l)))

Fixed submission:
N, K = [int(x) for x in input().split(' ')]

output = N - K + 1

print(int(output))

Buggy python submission (verdict: Runtime Error):
N = int(input())
s_list = []
count = 0
n, m, l = 0, 0, 0

for i in range(N):
  s = input()
  s_list.append(s)
  count += s.count('AB')
  if s[0] == 'B' and s[-1] == 'A':
    n += 1
    continue
  elif s[-1] == 'A':
    m += 1
  elif s[0] == 'B':
    l += 1

if n < m and n < l:
  print(int(count + 2 * n + min(m - n, l - n)))
elif n > m and n > l:
  print(int(count + 2 * (n - max(m, l) + m + l)
else:
  print(int(count + min(n, m) + min(n, l)))

Fixed submission:
N, K = [int(x) for x in input().split(' ')]

output = N - K + 1

print(int(output))

Buggy python submission (verdict: Runtime Error):
N = int(input())
s_list = []
count = 0
n, m, l = 0, 0, 0

for i in range(N):
  s = input()
  s_list.append(s)
  count += s.count('AB')
  if s[0] == 'B' and s[-1] == 'A':
    n += 1
    continue
  elif s[-1] == 'A':
    m += 1
  elif s[0] == 'B':
    l += 1

if n < m and n < l:
  print(int(count + 2 * n + min(m - n, l - n)))
else:
  print(int(count + 2 * n))

  

Fixed submission:
N, K = [int(x) for x in input().split(' ')]

output = N - K + 1

print(int(output))
Buggy python submission (verdict: Runtime Error):
import math
 
N = int(input())
d_list = []
 
for i in range(3, int(math.sqrt(N))):
  if N % i == 0:
    d_list.append(i)
    if i != math.sqrt(N):
      d_lsit.append(N / i)
 
output = sum(d_list) - (len(d_list) - 2) - 3
print(output)

Fixed submission:
import math
 
N = int(input())
d_list = []
 
for i in range(1, int(math.sqrt(N)) + 1):
  if N % i == 0:
    if i != 1:
      if (N // (i - 1)) == (N % (i - 1)):
        d_list.append(i)
    if i != math.sqrt(N):
      if (N // (N / i - 1)) == (N % (N / i - 1)):
        d_list.append(N / i)
 
output = sum(d_list) - len(d_list)
print(int(output))

Buggy python submission (verdict: Runtime Error):
import math

N = int(input())
d_list = []

for i in range(3, int(math.sqrt(N))):
  if N % i == 0:
    d_list.append(i)
    if i != math.sqrt(N):
      d_lsit.append(N / i)

output = sum(d_list) - len(d_list)
print(output)

Fixed submission:
import math
 
N = int(input())
d_list = []
 
for i in range(1, int(math.sqrt(N)) + 1):
  if N % i == 0:
    if i != 1:
      if (N // (i - 1)) == (N % (i - 1)):
        d_list.append(i)
    if i != math.sqrt(N):
      if (N // (N / i - 1)) == (N % (N / i - 1)):
        d_list.append(N / i)
 
output = sum(d_list) - len(d_list)
print(int(output))
Buggy python submission (verdict: Runtime Error):
#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n,i,j;
    cin>>n;
    for(i=1;i<=9;i++)
    {
        for(j=1;j<=9;j++)
        {
            if(i*j==n)
            {
                cout<<"Yes";
            }
            
        }
    }
    cout<<"No";
    return 0;
}

Fixed submission:
n=int(input())
z="No"
for i in range(1,10):
    if n%i==0 and n/i<=9:
        z="Yes"
print(z)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

lib = [0] * n

def comb(n, r):
    if r == 0 or r == n:
        return 1
    elif r == 1:
        return n
    else:
        return (comb(n - 1, r - 1) + comb(n - 1, r))

for i in a:
    lib[i - 1] += 1

count = 0

for i in lib:
    if i >= 2:
        count += comb(i, 2)

for i in a:
    print(count - (lib[i - 1] - 1))


Fixed submission:
import math

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

lib = [0] * n

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for i in a:
    lib[i - 1] += 1

count = 0

for i in lib:
    if i >= 2:
        count += comb(i, 2)

for i in a:
    print(count - (lib[i - 1] - 1))
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin, stdout
def gmi(): return map(int, stdin.readline().strip().split())
def gms(): return map(str, stdin.readline().strip().split())
def gari(): return list(map(int, stdin.readline().strip().split()))
def gars(): return list(map(int, stdin.readline().strip().split()))
def gs(): return stdin.readline().strip()
def gls(): return list(stdin.readline())
def gi(): return int(stdin.readline())

n = gi()
ar = gari()
c = 0
ans = 0
for i in ar[:-1]:
    c += 1
    for j in ar[c:]:
        ans += i*j
print(ans%1000000007)








Fixed submission:
from sys import stdin, stdout
def gmi(): return map(int, stdin.readline().strip().split())
def gms(): return map(str, stdin.readline().strip().split())
def gari(): return list(map(int, stdin.readline().strip().split()))
def gars(): return list(map(int, stdin.readline().strip().split()))
def gs(): return stdin.readline().strip()
def gls(): return list(stdin.readline())
def gi(): return int(stdin.readline())

n = gi()
ar = gari()
c = 0
ans = 0
s = sum(ar)
sub = 0
for i in ar[:-1]:
    sub +=  ar[c]
    ans += i*(s-sub)
    c += 1
print(ans%1000000007)
Buggy python submission (verdict: Runtime Error):
n = int(input())
m = n%10
if m == 2 or m == 4 or m == 5 or m == 7 or m == 9:
  return 'hon'
elif m == 0 or m == 1 or m == 6 or m == 8:
  return 'pon'
elif m == 3:
  return 'bon'

Fixed submission:
n = int(input())
m = n%10
if m == 2 or m == 4 or m == 5 or m == 7 or m == 9:
  print('hon')
elif m == 0 or m == 1 or m == 6 or m == 8:
  print('pon')
elif m == 3:
  print('bon')
Buggy python submission (verdict: Runtime Error):
k = int(input())
n = input()

if len(n)<=k:
  print(n)
  else:
    print(n[:k] + '...')
  
  

Fixed submission:
k = int(input())
n = input()
 
if len(n)<=k:
  print(n)
else:
  print(n[:k] + '...')
Buggy python submission (verdict: Runtime Error):
s=input()
t=input()

count = []

for i in range(len(s)-len(t)):
    c=0
    for j in range(i,i+len(t)):
        if s[j] == t[j-i]:
            c+=1
    
    count.append(c)

print(len(t)-max(count))


Fixed submission:
s=input()
t=input()

count = []

for i in range(len(s)-len(t)+1):
    c=0
    for j in range(i,i+len(t)):
        if s[j] == t[j-i]:
            c+=1
    count.append(c)

# print(count)
print(len(t)-max(count))

Buggy python submission (verdict: Runtime Error):
s=input()
t=input()

count = []

for i in range(len(s)-len(t)):
    c=0
    for j in range(i,i+len(t)):
        if s[j] == t[j]:
            c+=1
    
    count.append(c)

print(len(t)-max(count))


Fixed submission:
s=input()
t=input()

count = []

for i in range(len(s)-len(t)+1):
    c=0
    for j in range(i,i+len(t)):
        if s[j] == t[j-i]:
            c+=1
    count.append(c)

# print(count)
print(len(t)-max(count))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
    ans += a[i] * sum(a[i + 1 :])

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


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 0
r = [0] * (n + 1)
for i, v in enumerate(a, start=1):
    r[i] = v + r[i - 1]

for i in range(n - 1):
    ans += a[i + 1] * r[i + 1]

print(ans % (10 ** 9 + 7))
Buggy python submission (verdict: Time Limit Exceeded):
def dsum(n):
    wa = 0
    while n > 0:
        wa += n % 10
        n //= 10
    return wa


n = int(input())

print("Yes") if dsum(n) % 9 == 0 else print("No")



Fixed submission:
n = int(input())
print("Yes") if n % 9 == 0 else print("No")
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

h, w = map(int, input().split())
sx, sy = map(int, input().split())
gx, gy = map(int, input().split())
M = [[] for _ in range(h)]
for i in range(h):
    M[i] = input()

D = [(-1, 0), (0, -1), (1, 0), (0, 1)]
dist = [[float("inf")] * w for _ in range(h)]
dist[sx - 1][sy - 1] = 0
q = deque()
q.append((sx - 1, sy - 1))
while q:
    X, Y = q.popleft()
    d = dist[X][Y]
    for dx, dy in D:
        nx, ny = X + dx, Y + dy
        if nx < 0 or ny < 0 or nx >= h or ny >= w:
            continue
        if M[nx][ny] == "#":
            continue
        if dist[nx][ny] <= d:
            continue
        dist[nx][ny] = d
        q.appendleft((nx, ny))
    for c in range(-2, 3):
        for r in range(-2, 3):
            nx, ny = X + c, Y + r
            if nx < 0 or ny < 0 or nx >= h or ny >= w:
                continue
            if M[nx][ny] == "#":
                continue
            if dist[nx][ny] <= d + 1:
                continue
            dist[nx][ny] = d + 1
            q.append((nx, ny))

ans = dist[gx - 1][gy - 1]
if ans == float("inf"):
    ans = -1

print(ans)


Fixed submission:
from collections import deque

h, w = map(int, input().split())
sx, sy = map(int, input().split())
gx, gy = map(int, input().split())
M = [[] for _ in range(h)]
for i in range(h):
    M[i] = input()

D = [(-1, 0), (0, -1), (1, 0), (0, 1)]
dist = [[float("inf")] * w for _ in range(h)]
dist[sx - 1][sy - 1] = 0
q = deque()
q.append((sx - 1, sy - 1))
while q:
    X, Y = q.popleft()
    d = dist[X][Y]
    for dx, dy in D:
        nx, ny = X + dx, Y + dy
        if nx < 0 or ny < 0 or nx >= h or ny >= w:
            continue
        if M[nx][ny] == "#":
            continue
        if dist[nx][ny] <= d:
            continue
        dist[nx][ny] = d
        q.appendleft((nx, ny))
    for c in range(-2, 3):
        for r in range(-2, 3):
            nx, ny = X + c, Y + r
            if nx < 0 or ny < 0 or nx >= h or ny >= w:
                continue
            if M[nx][ny] == "#":
                continue
            if dist[nx][ny] <= d + 1:
                continue
            dist[nx][ny] = d + 1
            q.append((nx, ny))

ans = dist[gx - 1][gy - 1]
if ans == float("inf"):
    ans = -1

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if l[i] == l[j] or l[j] == l[k] or l[k] == l[i]:
                continue

            else:
                # 3角形の成立条件
                if l[i] + l[j] > l[k] and l[j] + l[k] > l[i] and l[k] + l[i] > l[j]:
                    ans += 1
print(ans)


Fixed submission:
s = list(input())
c = s.count("R")
if c == 3:
    print(3)
elif c == 2 and s[1] != "S":
    print(2)
elif c == 0:
    print(0)
else:
    print(1)
Buggy python submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
r = [0] * (n - k + 1)
for i in range(n - k + 1):
    if a[i + k] > a[i]:
        print("Yes")
    else:
        print("No")


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

for i in range(k, n):
    if a[i - k] < a[i]:
        print("Yes")
    else:
        print("No")

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

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
r = [0] * (n - k + 1)
for i in range(n - k + 1):
    r[i] = reduce(mul, a[i : i + k])

    if i > 0:
        if r[i] > r[i - 1]:
            print("Yes") 
        else: 
            print("No")


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

for i in range(k, n):
    if a[i - k] < a[i]:
        print("Yes")
    else:
        print("No")

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

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
flag = [False] * (n - k)
r = [0] * (n - k + 1)
for i in range(n - k + 1):
    r[i] = reduce(mul, a[i : i + k])

    if i > 0:
        if r[i] > r[i - 1]:
            flag[i - 1] = True
for i in flag:
    print("Yes") if i else print("No")


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

for i in range(k, n):
    if a[i - k] < a[i]:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
mul = 1
for i in a:
    mul *= i
if mul > 10 ** 18:
    mul = -1
print(mul)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mul = 1
if 0 in a:
    mul = 0

for i in a:
    mul *= i
    if mul > 10 ** 18:
        mul = -1
        break
print(mul)
Buggy python submission (verdict: Time Limit Exceeded):
import math

n = int(input())
n += 1
ans = 0
for i in range(1, n):
    for j in range(1, n):
        for k in range(1, n):
            ans += math.gcd(i, math.gcd(j, k))

print(ans)


Fixed submission:
import math

n = int(input())
n += 1
ans = 0
for i in range(1, n):
    for j in range(1, n):
        for k in range(1, n):
            ans += math.gcd(i, math.gcd(j, k))

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = list(map(int, input().split()))
loop = True
while loop:
    if n > abs(n - k):
        if n > k:
            n = min(n, n % k)
        elif k > n:
            n = min(n, k % n)
    else:
        loop = False

print(n)


Fixed submission:
n, k = list(map(int, input().split()))
if n == k:
    n = 0
else:
    while n > abs(n - k):
        if n > k:
            n = min(n, n % k)
        elif k > n:
            n = min(n, k % n)

print(n)