Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
L = int(input().split())
L2 = set(L) # 重複を削除

ans = 0

for i in len(L2):
  for j in range(i+1, len(L2)):
    for k in range(i+2, len(L2)):
      l = [i, j, k]
      l = sorted(l, reverse = True)
      if l[0] < l[1] + l[2]:
        ans += L.count(i) * L.count(j) * L.count(k)

print(ans)      
    


Fixed submission:
s = input().split('S')

ans = 0

for i in s:
  if len(i) > ans:
    ans = len(i)
    
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = [int(input()) for _ in range(N)]

AC = 0
WA = 0
TLE = 0
RE = 0

for i in S:
    if i == 'AC':
        AC += 1
    elif i == 'WA':
        WA += 1
    elif i == 'TLE':
        TLE += 1
    else:
        RE += 1
        
print('AC x', AC)
print('WA x', WA)
print('TLE x', TLE)
print('RE x', RE)

Fixed submission:
N = int(input())
S = [input() for _ in range(N)]

AC = 0
WA = 0
TLE = 0
RE = 0

for i in S:
    if i == 'AC':
        AC += 1
    elif i == 'WA':
        WA += 1
    elif i == 'TLE':
        TLE += 1
    else:
        RE += 1
        
print('AC x', AC)
print('WA x', WA)
print('TLE x', TLE)
print('RE x', RE)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = [int(input()) for _ in range(N)]

AC = 0
WA = 0
TLE = 0
RE = 0

for i in S:
    if i == 'AC':
        AC += 1
    elif i == 'WA':
        WA += 1
    elif i == 'TLE':
        TLE += 1
    else:
        RE += 1
        
print('AC x', AC)
print('WA x', WA)
print('TLE x', TLE)
print('RE x', RE)

Fixed submission:
N = int(input())
S = [input() for _ in range(N)]

AC = 0
WA = 0
TLE = 0
RE = 0

for i in S:
    if i == 'AC':
        AC += 1
    elif i == 'WA':
        WA += 1
    elif i == 'TLE':
        TLE += 1
    else:
        RE += 1
        
print('AC x', AC)
print('WA x', WA)
print('TLE x', TLE)
print('RE x', RE)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = [int(input()) for _ in range(N)]

AC = 0
WA = 0
TLE = 0
RE = 0

for i in S:
    if i == 'AC':
        AC += 1
    elif i == 'WA':
        WA += 1
    elif i == 'TLE':
        TLE += 1
    else:
        RE += 1
        
print('AC x', AC, '\n')
print('WA x', WA, '\n')
print('TLE x', TLE, '\n')
print('RE x', RE)
        

Fixed submission:
N = int(input())
S = [input() for _ in range(N)]

AC = 0
WA = 0
TLE = 0
RE = 0

for i in S:
    if i == 'AC':
        AC += 1
    elif i == 'WA':
        WA += 1
    elif i == 'TLE':
        TLE += 1
    else:
        RE += 1
        
print('AC x', AC)
print('WA x', WA)
print('TLE x', TLE)
print('RE x', RE)
Buggy python submission (verdict: Runtime Error):
x, n = map(int, input().split())
P = list(map(int, input().split()))

for d in range(x + 1):
    for s in [-1, +1]:
        a = x + s * d
        if p.count(a) == 0:
            print(a)
            exit(0) 

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

for d in range(x + 1):
    for s in [-1, +1]:
        a = x + s * d
        if P.count(a) == 0:
            print(a)
            exit(0)

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

P.sort()
P.append(101)

excluded = P.pop(0)

ans, absolute = None, 101

for i in range(102):
    if i == excluded:
        excluded = P.pop(0)
    else:
        if abs(i - x) < absolute:
            ans = i
            absolute = abs(i - x)
    
print(ans)
        

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

for d in range(x + 1):
    for s in [-1, +1]:
        a = x + s * d
        if P.count(a) == 0:
            print(a)
            exit(0)

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

P.sort()
P.append(101)

excluded = P.pop(0)

ans, absolute = None, 101

for i in range(0, 102):
    if i == excluded:
        excluded = P.pop(0)
    else:
        if abs(i - x) < absolute:
            ans = i
            absolute = abs(i - x)
    
print(ans)
        


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

for d in range(x + 1):
    for s in [-1, +1]:
        a = x + s * d
        if P.count(a) == 0:
            print(a)
            exit(0)

Buggy python submission (verdict: Runtime Error):
x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    P = list(map(int, input().split()))

P.sort()
P.append(101)

excluded = P.pop(0)

ans, absolute = None, 101

for i in range(1, 101):
    if i == excluded:
        excluded = P.pop(0)
    else:
        if abs(i - x) < absolute:
            ans = i
            absolute = abs(i - x)
    
print(ans)

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

for d in range(x + 1):
    for s in [-1, +1]:
        a = x + s * d
        if P.count(a) == 0:
            print(a)
            exit(0)

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

P.sort()
P.append(101)

excluded = P.pop(0)

ans, absolute = None, 101

for i in range(1, 101):
    if i == excluded:
        excluded = P.pop(0)
    else:
        if abs(i - x) < absolute:
            ans = i
            absolute = abs(i - x)
    
print(ans)

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

for d in range(x + 1):
    for s in [-1, +1]:
        a = x + s * d
        if P.count(a) == 0:
            print(a)
            exit(0)
Buggy python submission (verdict: Runtime Error):
s = int(input())

ans = "Good"

s_temp = 99

for num in s:
    if int(num) == s_temp:
        ans = "Bad"
        break
    else:
        s_temp = int(num)

print(ans)


Fixed submission:
s = input()

ans = "Good"

s_temp = 99

for num in s:
    if int(num) == s_temp:
        ans = "Bad"
        break
    else:
        s_temp = int(num)

print(ans)
Buggy python submission (verdict: Runtime Error):
import fraction

a, b, c, d = map(int, input().split())

a -= 1

lcm = c * d // fraction.gcd(c, d)

b_sum = b - (b // c) - (b // d) + (b // lcm)
a_sum = a - (a // c) - (a // d) + (a // lcm)

print(b_sum - a_sum)

Fixed submission:
import fractions

a, b, c, d = map(int, input().split())

a -= 1

lcm = c * d // fractions.gcd(c, d)

b_sum = b - (b // c) - (b // d) + (b // lcm)
a_sum = a - (a // c) - (a // d) + (a // lcm)

print(b_sum - a_sum)

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

a, b, c, d = map(int, input().split())

a -= 1

lcm = (c * d) // math.gcd(c, d)

b_sum = b - (b // c) - (b // d) + (b // lcm)
a_sum = a - (a // c) - (a // d) + (a // lcm)

print(b_sum - a_sum)

Fixed submission:
import fractions

a, b, c, d = map(int, input().split())

a -= 1

lcm = c * d // fractions.gcd(c, d)

b_sum = b - (b // c) - (b // d) + (b // lcm)
a_sum = a - (a // c) - (a // d) + (a // lcm)

print(b_sum - a_sum)

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

a, b, c, d = map(int, input().split())

a -= 1

lcm = c * d // math.gcd(c, d)

b_sum = b - (b // c) - (b // d) + (b // lcm)
a_sum = a - (a // c) - (a // d) + (a // lcm)

print(b_sum - a_sum)

Fixed submission:
import fractions

a, b, c, d = map(int, input().split())

a -= 1

lcm = c * d // fractions.gcd(c, d)

b_sum = b - (b // c) - (b // d) + (b // lcm)
a_sum = a - (a // c) - (a // d) + (a // lcm)

print(b_sum - a_sum)

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

a, b, c, d = map(int, input().split())

a -= 1

lcm = c * d // math.gcd(c, d)

b_sum = b - (b // c) - (b // d) + (b // lcm)
a_sum = a - (a // c) - (a // d) + (a // lcm)

print(b_sum - a_sum)

Fixed submission:
import fractions

a, b, c, d = map(int, input().split())

a -= 1

lcm = c * d // fractions.gcd(c, d)

b_sum = b - (b // c) - (b // d) + (b // lcm)
a_sum = a - (a // c) - (a // d) + (a // lcm)

print(b_sum - a_sum)
Buggy python submission (verdict: Runtime Error):
import math

a, p = map(int, input().sprit())

apple = 3 * a + p

ans = (math.floor(apple / 2))

print(ans)

Fixed submission:
import math

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

apple = 3 * a + p

ans = (math.floor(apple / 2))

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

score = [1] * (n - k + 1)

for i in range(k):
    score[0] *= a_list[i]

for i in range(1, n-k+1):
    score[i] = (score[i-1] / a_list[i-1]) * a_list[k+i-1]

for i in range(len(score)-1):
    if score[i+1] - score[i] > 0:
        print("Yes")
    else:
        print("No")


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

for i in range(n-k):
    if a_list[i] < a_list[k+i]:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())
ans = 0
for r in range(N // R + 1):
  for g in range(N // G + 1):
    d = N - R * r - G * g
    if d == 0 or (d > 0 and d % B == 0):
      ans += 1
print(ans)

Fixed submission:
R, G, B, N = map(int, input().split())
ans = 0
for r in range(N // R + 1):
  d = N - R * r
  for g in range(d // G + 1):
    dd = d - G * g
    if dd == 0 or (dd > 0 and dd % B == 0):
      ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
end = sorted(a)[1]

for i in range(end+1, 0, -1):
  x = 0
  for j in a:
    if j % i != 0:
      x += 1
  if x <= 1:
    print(i)
    break

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
end = sorted(a)[1]

for i in range(end+1, 0, -1):
  x = 0
  for j in a:
    if j % i != 0:
      x += 1
    if x >= 2:
      break
  if x <= 1:
    print(i)
    break

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

import fractions
from functools import reduce

for i in range(sorted(a)[1]+1, 0, -1):
  x = 0
  for j in a:
    if j % i != 0:
      x += 1
  if x <= 1:
    print(i)
    break

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
end = sorted(a)[1]

for i in range(end+1, 0, -1):
  x = 0
  for j in a:
    if j % i != 0:
      x += 1
    if x >= 2:
      break
  if x <= 1:
    print(i)
    break

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

import fractions
from functools import reduce

ans = 0
for i in range(n):
  x = a[:i] + a[i+1:]
  ans = max(ans, reduce(fractions.gcd, x))
  
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
end = sorted(a)[1]

for i in range(end+1, 0, -1):
  x = 0
  for j in a:
    if j % i != 0:
      x += 1
    if x >= 2:
      break
  if x <= 1:
    print(i)
    break

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

import fraction
from functools import reduce

ans = 0
for i in range(n):
  x = a[:i] + a[i+1:]
  ans = max(ans, reduce(fraction.gcd, x))
  
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
end = sorted(a)[1]

for i in range(end+1, 0, -1):
  x = 0
  for j in a:
    if j % i != 0:
      x += 1
    if x >= 2:
      break
  if x <= 1:
    print(i)
    break
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
s = input()
c = []
import itertools
for _, g in itertools.groupby(s):
  c.append(len(list(g)))

c = c + [0]
ans = 1

if s[0] == "1":
  for i in range(0, len(c), 2):
    if i+2*k+1 > len(c):
      ans = max(ans, sum(c[i:]))
    else:
      ans = max(ans, sum(c[i:i+2*k+1]))
else:
  c = [0] + c
  for i in range(0, len(c), 2):
    if i+2*k+1 > len(c):
      ans = max(ans, sum(c[i:]))
    else:
      ans = max(ans, sum(c[i:i+2*k+1]))

print(ans)

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

c = [0]
import itertools
for _, g in itertools.groupby(s):
  c.append(c[-1] + len(list(g)))
  
c = c[1:]
if s[0] == "1":
  c = [0] + c
else:
  c = [0,0] + c
if s[-1] == "0":
  c = c + [c[-1]]

ans = 0
for i in range(0,len(c), 2):
  end = min(i+2*k+1, len(c)-1)
  ans = max(ans, c[end]-c[i])

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
s = input() + "2"

c = []
ci = 1
for i in range(n):
  if s[i] == s[i+1]:
    ci += 1
  else:
    c.append(ci)
    ci = 1

c = c + [0]
ans = 1

if s[0] == "1":
  for i in range(0, len(c), 2):
    if i+2*k+1 > len(c):
      ans = max(ans, sum(c[i:]))
    else:
      ans = max(ans, sum(c[i:i+2*k+1]))
else:
  c = [0] + c
  for i in range(0, len(c), 2):
    if i+2*k+1 > len(c):
      ans = max(ans, sum(c[i:]))
    else:
      ans = max(ans, sum(c[i:i+2*k+1]))

print(ans)

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

c = [0]
import itertools
for _, g in itertools.groupby(s):
  c.append(c[-1] + len(list(g)))
  
c = c[1:]
if s[0] == "1":
  c = [0] + c
else:
  c = [0,0] + c
if s[-1] == "0":
  c = c + [c[-1]]

ans = 0
for i in range(0,len(c), 2):
  end = min(i+2*k+1, len(c)-1)
  ans = max(ans, c[end]-c[i])

print(ans)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

ans = 0
x = []

for i in [a,b,c,d,e]:
  if i % 10 != 0:
    ans += (i//10)*10 + 10
    x.append(i%10)
  else:
    ans += i

ans -= 10-min(x)
print(ans)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

ans = 0
x = []

for i in [a,b,c,d,e]:
  if i % 10 != 0:
    ans += (i//10)*10 + 10
    x.append(i%10)
  else:
    ans += i

if x != []:
  ans -= 10-min(x)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n, m = map(int, input().split())
money = []
for i in range(n):
  a, b = map(int, input().split())
  money += [a] * b

money.sort()
print(np.sum(money[0:m]))

Fixed submission:
n, m = map(int, input().split())
money = []
for i in range(n):
  a, b = map(int, input().split())
  money.append({"a":a, "b":b})

bsum = 0
money.sort(key=lambda x: x["a"])
for i in range(n):
  bsum0 = bsum
  bsum += money[i]["b"]
  if m <= bsum:
    num = i
    break

ans = 0
for j in range(num):
  ans += money[j]["a"] * money[j]["b"]
ans += (m-bsum0) * money[num]["a"]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
money = []
for i in range(n):
  a, b = map(int, input().split())
  money += [a] * b

print(sum(sorted(money)[0:m]))

Fixed submission:
n, m = map(int, input().split())
money = []
for i in range(n):
  a, b = map(int, input().split())
  money.append({"a":a, "b":b})

bsum = 0
money.sort(key=lambda x: x["a"])
for i in range(n):
  bsum0 = bsum
  bsum += money[i]["b"]
  if m <= bsum:
    num = i
    break

ans = 0
for j in range(num):
  ans += money[j]["a"] * money[j]["b"]
ans += (m-bsum0) * money[num]["a"]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n, m = map(int, input().split())
money = []
for i in range(n):
  a, b = map(int, input().split())
  money += [a] * b

money = sorted(money)
print(sum(money[0:m]))

Fixed submission:
n, m = map(int, input().split())
money = []
for i in range(n):
  a, b = map(int, input().split())
  money.append({"a":a, "b":b})

bsum = 0
money.sort(key=lambda x: x["a"])
for i in range(n):
  bsum0 = bsum
  bsum += money[i]["b"]
  if m <= bsum:
    num = i
    break

ans = 0
for j in range(num):
  ans += money[j]["a"] * money[j]["b"]
ans += (m-bsum0) * money[num]["a"]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0
for i in range(1,n+1,2):
    i = list(str(i))
    if set(i) == {"3","5","7"}:
        ans += 1
print(ans)

Fixed submission:
import itertools
ans = 0
n = int(input())

for k in range(1,10):
    s = itertools.product(["3","5","7"], repeat=k)
    for seq in s:
        x = set()
        for i in seq:
            x.add(i)
        if len(x) != 3:
            continue
        t = "".join(seq)
        if 1 <= int(t) <= n:
            ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0
for i in range(1,n+1):
    i = list(str(i))
    if set(i) == {"3","5","7"}:
        ans += 1
print(ans)

Fixed submission:
import itertools
ans = 0
n = int(input())

for k in range(1,10):
    s = itertools.product(["3","5","7"], repeat=k)
    for seq in s:
        x = set()
        for i in seq:
            x.add(i)
        if len(x) != 3:
            continue
        t = "".join(seq)
        if 1 <= int(t) <= n:
            ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0
for i in range(1,n+1,2):
    i = list(str(i))
    if "1" not in i:
        if "2" not in i:
            if "3" in i:
                if "4" not in i:
                    if "5" in i:
                        if "6" not in i:
                            if "7" in i:
                                if "8" not in i:
                                    if "9" not in i:
                                        if "0" not in i:
                                            ans += 1
print(ans)

Fixed submission:
import itertools
ans = 0
n = int(input())

for k in range(1,10):
    s = itertools.product(["3","5","7"], repeat=k)
    for seq in s:
        x = set()
        for i in seq:
            x.add(i)
        if len(x) != 3:
            continue
        t = "".join(seq)
        if 1 <= int(t) <= n:
            ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import itertools
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
for cx, cy in itertools.product(range(0,101), repeat=2):
  hhh = []
  for i in xyh:
    xi, yi, hi = i[0], i[1], i[2]
    if hi==0:
      if (h-abs(xi-cx)-abs(yi-cy))<=0:
        continue
      else:
        break
    h = hi + abs(xi-cx) + abs(yi-cy)
    hhh.append(h)
  if len(set(hhh)) == 1:
    print(cx, cy, h)
    break

Fixed submission:
import itertools
n = int(input())
xyh = [list(map(int, input().split())) for i in range(n)]
for cx, cy in itertools.product(range(0,101), repeat=2):
  flag = False
  hhh = []
  for i in range(n):
    if xyh[i][2] != 0:
      h = xyh[i][2] + abs(xyh[i][0]-cx) + abs(xyh[i][1]-cy)
      hhh.append(h)
  if len(set(hhh)) == 1:
    flag = True
    for i in range(n):
      if xyh[i][2] == 0:
         if hhh[0] - abs(xyh[i][0]-cx) - abs(xyh[i][1]-cy) > 0:
            flag = False
  if flag:
    print(cx, cy, hhh[0])
Buggy python submission (verdict: Runtime Error):
import collections
n = int(input())
v = list(map(int, input().split()))
v1 = v[::2]
v2 = v[1::2]
c1 = collections.Counter(v1).most_common()
c2 = collections.Counter(v2).most_common()

if c1[0][0] != c2[0][0]:
  print(len(v1)-c1[0][1] + len(v2)-c2[0][1])
else:
  if len(set(v1)) == len(set(v2)) == 1:
    print(min(len(v1), len(v2)))
  elif len(set(v1))==1:
    print(len(v2)-c2[1][1])
  elif len(set(v2))==1:
    print(len(v1)-c1[1][1])
  else:
    print(min(len(v1)-c1[0][1]+len(v2)-c2[1][1]),
                len(v1)-c1[1][1]+len(v2)-c2[0][1])

Fixed submission:
import collections
n = int(input())
v = list(map(int, input().split()))
v1 = [v[i*2+1] for i in range(n//2)]
v2 = [v[i*2] for i in range(n//2)]
c1 = collections.Counter(v1).most_common()
c2 = collections.Counter(v2).most_common()

if len(set(v1)) == len(set(v2)) == 1:
  if c1[0][0] != c2[0][0]:
    print(0)
  else:
    print(min(len(v1), len(v2)))
elif len(set(v1))==1:
  if c1[0][0] != c2[0][0]:
    print(sum([i[1] for i in c2])-c2[0][1])
  else:
    print(sum([i[1] for i in c2])-c2[1][1])
elif len(set(v2))==1:
  if c1[0][0] != c2[0][0]:
    print(sum([i[1] for i in c1])-c1[0][1])
  else:
    print(sum([i[1] for i in c1])-c1[1][1])
else:
  if c1[0][0] != c2[0][0]:
    print((sum([i[1] for i in c1])-c1[0][1]) + (sum([i[1] for i in c2])-c2[0][1]))
  else:
    print(min((sum([i[1] for i in c1])-c1[0][1])+(sum([i[1] for i in c2])-c2[1][1]),
              (sum([i[1] for i in c1])-c1[1][1])+(sum([i[1] for i in c2])-c2[0][1])))
Buggy python submission (verdict: Runtime Error):
s = np.array(list(input()))
t = np.array(list(input()))
num = 0
for i in set(t):
  if np.sum(s==i) == np.sum(t==i):
    num += 1
    continue
  if len(set(s[t==i])) == 1:
    num += 1
    continue
if num == len(set(t)):
  print("Yes")
else:
  print("No")

Fixed submission:
from collections import Counter
s = input()
t = input()

sc = Counter(s)
tc = Counter(t)

if sorted(sc.values()) == sorted(tc.values()):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n, x = map(int, input().split())
xi = list(map(int, input().split()))
xi.append(x)
xi.sort()
d = [xi[i+1]-xi[i] for i in range(n)]

import math
from functools import reduce

def gcd_list(numbers):
  return reduce(math.gcd, numbers)

print(gcd_list(d))

Fixed submission:
n, x = map(int, input().split())
xi = list(map(int, input().split()))
xi.append(x)
xi.sort()
d = [xi[i+1]-xi[i] for i in range(n)]

import fractions
from functools import reduce

def gcd_list(numbers):
  return reduce(fractions.gcd, numbers)

print(gcd_list(d))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
import itertools
ans = 0
for a, b, c in itertools.product(range(1,n+1), repeat=3):
  if (a+b)%k == 0 and (b+c)%k == 0 and (c+a)%k == 0:
    ans += 1
print(ans)

Fixed submission:
n, k = map(int, input().split())
ans = 0
temp = n // k
ans += temp ** 3

if k % 2 == 0:
  n += k // 2
  temp = n // k
  ans += temp ** 3
  
print(ans)
Buggy python submission (verdict: Runtime Error):
r = int(input())
if r < 1200:
  print("ABC")
else r < 2800:
  print("ARC")
else:
  print("AGC")

Fixed submission:
r = int(input())
if r < 1200:
  print("ABC")
elif r < 2800:
  print("ARC")
else:
  print("AGC")
Buggy python submission (verdict: Runtime Error):
s = list(input())
t = list(input())

ok = False
for i in range(len(s)):
  s = s[-1] + s[:-1]
  if s == t:
    ok = True
    break
if ok:
  print("Yes")
else:
  print("No")

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

ok = False
for i in range(len(s)):
  a = s[-1]
  s = s[:-1]
  s.insert(0, a)
  if s == t:
    ok = True
    break
if ok:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a = [a[i] - (i+1) for i in range(len(a))]

ans = float("inf")
for i in range(min(a),max(a)+1):
  b = [abs(a[ai]-i) for ai in range(len(a))]
  ans = min(ans, sum(b))
  
print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a = [a[i] - (i+1) for i in range(len(a))]

import statistics
b = int(statistics.median(a))
ans = sum([abs(i-b) for i in a])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
w = [s[:i+1].count("W") for i in range(n)]
e = [i+1-w[i] for i in range(n)]
ans = e[-1]
for i in range(1,n):
  ans = min(ans, w[i-1]+e[-1]-e[i])
print(ans)

Fixed submission:
n = int(input())
s = input()
w = []
c = 0
for i in range(n):
  if s[i] == "W":
    c += 1
  w.append(c)
e = [i+1-w[i] for i in range(n)]
ans = e[-1]
for i in range(1,n):
  ans = min(ans, w[i-1]+e[-1]-e[i])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
w = [s[:i+1].count("W") for i in range(n)]
e = [s[:i+1].count("E") for i in range(n)]

ans = e[-1]
for i in range(1,n):
  ans = min(ans, w[i-1]+e[-1]-e[i])
print(ans)

Fixed submission:
n = int(input())
s = input()
w = []
c = 0
for i in range(n):
  if s[i] == "W":
    c += 1
  w.append(c)
e = [i+1-w[i] for i in range(n)]
ans = e[-1]
for i in range(1,n):
  ans = min(ans, w[i-1]+e[-1]-e[i])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
ans = float("inf")
for i in range(n):
  ans = min(ans, s[:i].count("W")+s[i+1:].count("E"))
print(ans)

Fixed submission:
n = int(input())
s = input()
w = []
c = 0
for i in range(n):
  if s[i] == "W":
    c += 1
  w.append(c)
e = [i+1-w[i] for i in range(n)]
ans = e[-1]
for i in range(1,n):
  ans = min(ans, w[i-1]+e[-1]-e[i])
print(ans)