Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
mod = 10**9 + 7
bits = [0]*60
for x in a:
    i = 0
    while x > 0:
        if x % 2 == 1:
            bits[i] += 1
        x //= 2
        i += 1
ans = 0
for i in range(60):
    ans += (bits[i] * (n-bits[i])) * pow(2, i, mod)
    ans %= mod
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
mod = 10**9 + 7
bits = [0]*60
for x in a:
    i = 0
    while x > 0:
        if x % 2 == 1:
            bits[i] += 1
        x //= 2
        i += 1
ans = 0
for i in range(60):
    ans += (bits[i] * (n-bits[i])) * pow(2, i, mod)
    ans %= mod
print(ans)
Buggy python submission (verdict: Runtime Error):
x,y = map(int, input().split())
d = {1:300000, 2:200000, 3:100000}
if x == y == 1:
  print(1000000)
  exit()
a = 0, b = 0
if 1 <= x <= 3:
  a = d[x]
if 1 <= y <= 3:
  b = d[x]

print(a+b)

Fixed submission:
x,y = map(int, input().split())
d = {1:300000, 2:200000, 3:100000}
if x == y == 1:
  print(1000000)
  exit()
a = 0
b = 0
if 1 <= x <= 3:
  a = d[x]
if 1 <= y <= 3:
  b = d[y]

print(a+b)
Buggy python submission (verdict: Runtime Error):
m = int(input())
d = []
c = []
s = 0
ans = -1
for i in range(m):
  d,c = map(int,input().split())
  s += d*c
  ans += c + (d*c) // 10 - len(str(d*c)) + 1

while s >= 10:
  tmp = s
  l = []
  while tmp > 0:
    l.append(tmp%10)
    tmp //= 10
  ans += len(l) - 1 + sum(l)//10 - len(str(sum(l))) + 1
  s = sum(l)
print(ans)

Fixed submission:
h, w, k = map(int, input().split())
a = []
ans = []
no = [True] * h
for i in range(h):
    a.append(input())
    ans.append([0] * w)

color = 1
last_i = 0
for i in range(h):
    last_j = 0
    found = False
    for j in range(w):
        if a[i][j] == '#':
            for k in range(last_i, i+1):
                for l in range(last_j, j+1):
                    ans[k][l] = color
            last_j = j+1
            color += 1
            found = True
    if found:
        last_i = i+1

for i in range(h):
    for j in range(w-1):
        if ans[i][j+1] == 0:
            ans[i][j+1] = ans[i][j]
for i in range(h-1):
    for j in range(w):
        if ans[i+1][j] == 0:
            ans[i+1][j] = ans[i][j]

for i in range(h):
    for j in range(w):
        print(ans[i][j], end=' ')
    print('')
Buggy python submission (verdict: Time Limit Exceeded):
x,y = map(int,input().split())
if (2*x - y) % 3 != 0 or (2*y-x) % 3 != 0 or 2 * min(x,y) < max(x,y):
    print(0)
    exit()

mod = 10**9 + 7
n = (x+y) // 3
a = (max(x,y)*2 - min(x,y)) // 3

fact = [1]
finv = [1]
for i in range(1, n+1):
    fact += [(fact[i-1] * i) % mod]
    finv += [pow(fact[i], mod-2, mod)]
print((fact[n]*finv[a]*finv[n-a]) % mod)

Fixed submission:
x,y = map(int,input().split())
if (2*x - y) % 3 != 0 or (2*y-x) % 3 != 0 or 2 * min(x,y) < max(x,y):
    print(0)
    exit()

mod = 10**9 + 7
n = (x+y) // 3
a = (max(x,y)*2 - min(x,y)) // 3

fact = [1]
finv = [1]
for i in range(1, n+1):
    fact += [(fact[i-1] * i) % mod]
    finv += [pow(fact[i], mod-2, mod)]
print((fact[n]*finv[a]*finv[n-a]) % mod)
Buggy python submission (verdict: Runtime Error):
import math
a,b,x = map(int, input().split())
if x / a / a >= b / 2:
  print(90 - math.degrees(math.atan(a/2/(b-(x/a/a)))))
else:
  print(90 - math.degrees(math.atan(2*x/a/b/b)))

Fixed submission:
import math
a,b,x = map(int, input().split())
if a * a * b == x:
  print(0)
  exit()
if x / a / a >= b / 2:
  print(90 - math.degrees(math.atan(a/2/(b-(x/a/a)))))
else:
  print(90 - math.degrees(math.atan(2*x/a/b/b)))

Buggy python submission (verdict: Runtime Error):
import math
a,b,x = map(int, input().split())
if x / a / a >= b / 2:
  print(90 - math.degrees(math.atan(a/2/(b-(x/a/a)))))
else:
  print(90 - math.degrees(math.atan(2*x/a/b/b)))

Fixed submission:
import math
a,b,x = map(int, input().split())
if a * a * b == x:
  print(0)
  exit()
if x / a / a >= b / 2:
  print(90 - math.degrees(math.atan(a/2/(b-(x/a/a)))))
else:
  print(90 - math.degrees(math.atan(2*x/a/b/b)))

Buggy python submission (verdict: Runtime Error):
a,b,x = map(int, input().split())
if x / a / a >= b / 2:
  print(90 - math.degrees(math.atan(a/2/(b-(x/a/a)))))
else:
  print(90 - math.degrees(math.atan(2*x/a/b/b)))

Fixed submission:
import math
a,b,x = map(int, input().split())
if a * a * b == x:
  print(0)
  exit()
if x / a / a >= b / 2:
  print(90 - math.degrees(math.atan(a/2/(b-(x/a/a)))))
else:
  print(90 - math.degrees(math.atan(2*x/a/b/b)))

Buggy python submission (verdict: Runtime Error):
a,b,x = map(int, input().split())
if x / a / a >= b / 2:
  print(90 - math.degrees(math.atan(a/2/(b-(x/a/a)))))
else:
  print(math.degrees(math.atan(2*x/a/b/b)))

Fixed submission:
import math
a,b,x = map(int, input().split())
if a * a * b == x:
  print(0)
  exit()
if x / a / a >= b / 2:
  print(90 - math.degrees(math.atan(a/2/(b-(x/a/a)))))
else:
  print(90 - math.degrees(math.atan(2*x/a/b/b)))
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int, input().split())
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort(reverse=True)
f.sort()
af = [a[i]*f[i] for i in range(n)]
lower = 0
upper = max(af)
prev = 0
now = upper // 2
while now != prev:
  count = 0
  for i in range(n):
    if a[i]*f[i] > now:
      count += a[i] - now // f[i]
  if count <= k:
    upper = now
  else:
    lower = now
  prev = now
  now = (lower + upper) // 2

print(upper)

Fixed submission:
n,k = map(int, input().split())
a = list(map(int, input().split()))
f = list(map(int, input().split()))
a.sort(reverse=True)
f.sort()
af = [a[i]*f[i] for i in range(n)]
lower = 0
upper = max(af)
prev = 0
now = upper // 2
while now != prev:
  count = 0
  for i in range(n):
    if a[i]*f[i] > now:
      count += a[i] - now // f[i]
  if count <= k:
    upper = now
  else:
    lower = now
  prev = now
  now = (lower + upper) // 2

print(upper)
Buggy python submission (verdict: Runtime Error):
from bisect import bisect
from bisect import bisect_left
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n):
  for j in range(i+1, n):
    left = abs(a-b)
    right = a+b
    ans += max(0, bisect_left(l, right) - bisect(l,left))
    if left < a < right:
      ans -= 1
    if left < b < right:
      ans -= 1
print(ans)

Fixed submission:
from bisect import bisect
from bisect import bisect_left
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n):
  for j in range(i+1, n):
    left = l[j]-l[i]
    right = l[i]+l[j]
    ans += max(0, bisect_left(l, right) - max(j+1, bisect(l,left)))
print(ans)
Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
ans = 0
for i in range(n):
  if int(input()) >= k:
    ans += 1
print(ans)

Fixed submission:
n,k = map(int, input().split())
h = list(map(int, input().split()))
ans = 0
for i in h:
  if i >= k:
    ans += 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n,k = map(int, input())
ans = 0
for i in range(n):
  if int(input()) >= k:
    ans += 1
print(ans)

Fixed submission:
n,k = map(int, input().split())
h = list(map(int, input().split()))
ans = 0
for i in h:
  if i >= k:
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = {}
for i in range(n):
  b.add((a[i], i+1))
for x,y in sorted(b):
  print(y, end=" ")
  

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
  b.append((a[i], i+1))
for x,y in sorted(b):
  print(y, end=" ")
Buggy python submission (verdict: Runtime Error):
s = input()
for i in range(len()s):
  if i % 2 == 0 and s[i] == "R":
    print("No")
    exit()
  elif i % 2 == 1 and s[i] == "L":
    print("No")
    exit()
print("Yes")

Fixed submission:
s = input()
for i in range(len(s)):
  if i % 2 == 0 and s[i] == "L":
    print("No")
    exit()
  elif i % 2 == 1 and s[i] == "R":
    print("No")
    exit()
print("Yes")

Buggy python submission (verdict: Runtime Error):
s = input()
for i in range(len()s):
  if i % 2 == 0 and s[i] == "R":
    print("No")
    exit()
  elif i % 2 == 1 and s[i] == "L":
    print("No")
    exit()
print("Yes")

Fixed submission:
s = input()
for i in range(len(s)):
  if i % 2 == 0 and s[i] == "L":
    print("No")
    exit()
  elif i % 2 == 1 and s[i] == "R":
    print("No")
    exit()
print("Yes")

Buggy python submission (verdict: Runtime Error):
s = input()
for i in range(len()s):
  if i % 2 == 0 && s[i] == "R":
    print("No")
    exit()
  elif i % 2 == 1 && s[i] == "L":
    print("No")
    exit()
print("Yes")

Fixed submission:
s = input()
for i in range(len(s)):
  if i % 2 == 0 and s[i] == "L":
    print("No")
    exit()
  elif i % 2 == 1 and s[i] == "R":
    print("No")
    exit()
print("Yes")

Buggy python submission (verdict: Runtime Error):
s = input()
for i in range(len()s):
  if i % 2 == 0 && s[i] == "R":
    print("No")
    exit()
  elif i % 2 == 1 %% s[i] == "L":
    print("No")
    exit()
print("Yes")

Fixed submission:
s = input()
for i in range(len(s)):
  if i % 2 == 0 and s[i] == "L":
    print("No")
    exit()
  elif i % 2 == 1 and s[i] == "R":
    print("No")
    exit()
print("Yes")
Buggy python submission (verdict: Runtime Error):
n,k,q = map(int, input().split())
a = [0]*n
for i in range(n):
  a[int(input())-1] += 1

for x in a:
  if k - q + x > 0:
    print("Yes")
  else:
    print("No")

Fixed submission:
n,k,q = map(int, input().split())
a = [0]*n
for i in range(q):
  a[int(input())-1] += 1

for x in a:
  if k - q + x > 0:
    print("Yes")
  else:
    print("No")

Buggy python submission (verdict: Runtime Error):
n,k,q = map(int, input().split())
a = [0]*n
for i in range(n):
  a[int(input())] += 1

for x in a:
  if k - q + x > 0:
    print("Yes")
  else:
    print("No")

Fixed submission:
n,k,q = map(int, input().split())
a = [0]*n
for i in range(q):
  a[int(input())-1] += 1

for x in a:
  if k - q + x > 0:
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import heapq
n,m = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n):
  a[i] = -a[i]
heapq.heapify(a)

for _ in range(m):
  x = heapq.heappop(a)
  x = -1 * (-1 * x // 2)
  heapq.heappush(x, a)
print(-sum(a))

Fixed submission:
import heapq
n,m = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n):
  a[i] = -a[i]
heapq.heapify(a)

for _ in range(m):
  x = heapq.heappop(a)
  x = -1 * (-1 * x // 2)
  heapq.heappush(a, x)
print(-sum(a))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = map(int, input().split())
b = map(int, input().split())
c = map(int, input().split())

ans = 0
for i in range(n-1):
  if a[i] + 1 == a[i+1]:
    ans += c[i]
  
print(ans + sum(b))  

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

ans = 0
for i in range(n - 1):
    if a[i] + 1 == a[i + 1]:
        ans += c[a[i]-1]

print(ans + sum(b))
Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
s = input()

if n == 1:
  print(0)
  exit()

two = 0
pre = s[0]
cont = 1
for c in s[1:]:
  if c != pre:
    if c == s[0]:
      two += 1
    ans += cont-1
    cont = 1
    pre = c
  else:
    cont += 1
ans += cont-1

if s[0] != s[1]:
  ans += 1
print(ans + 2*min(k,two))

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

if n == 1:
    print(0)
    exit()

two = 0
pre = s[0]
cont = 1
ans = 0
for c in s[1:]:
    if c != pre:
        if c == s[0]:
            two += 1
        ans += cont - 1
        cont = 1
        pre = c
    else:
        cont += 1
ans += cont - 1

if s[0] != s[-1] and k > two:
    ans += 1
print(ans + 2 * min(k, two))

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

if n == 1:
  print(0)
  exit()

pre = s[0]
cont = 1
for c in s[1:]:
  if c != pre:
    if c == s[0]:
      two += 1
    ans += cont-1
    cont = 1
    pre = c
  else:
    cont += 1
ans += cont-1

if s[0] != s[1]:
  ans += 1
print(ans + 2*min(k,two))

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

if n == 1:
    print(0)
    exit()

two = 0
pre = s[0]
cont = 1
ans = 0
for c in s[1:]:
    if c != pre:
        if c == s[0]:
            two += 1
        ans += cont - 1
        cont = 1
        pre = c
    else:
        cont += 1
ans += cont - 1

if s[0] != s[-1] and k > two:
    ans += 1
print(ans + 2 * min(k, two))

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

pre = s[0]
cont = 1
for c in s[1:]:
  if c != pre:
    if c == s[0]:
      two += 1
    ans += cont-1
    cont = 1
  else:
    cont += 1
ans += cont-1

print(ans)      
  

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

if n == 1:
    print(0)
    exit()

two = 0
pre = s[0]
cont = 1
ans = 0
for c in s[1:]:
    if c != pre:
        if c == s[0]:
            two += 1
        ans += cont - 1
        cont = 1
        pre = c
    else:
        cont += 1
ans += cont - 1

if s[0] != s[-1] and k > two:
    ans += 1
print(ans + 2 * min(k, two))
Buggy python submission (verdict: Runtime Error):
a,b = map(input().split())
print(math.ceil(((b-1)/(a-1))))

Fixed submission:
import math
a,b = map(int, input().split())
print(math.ceil(((b-1)/(a-1))))

Buggy python submission (verdict: Runtime Error):
a,b = map(input().split())
print(math.ceil(((b-1)/(a-1)))

Fixed submission:
import math
a,b = map(int, input().split())
print(math.ceil(((b-1)/(a-1))))
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))
ans = 0
move = 0
for i in range(n):
  if h[i] >= h[i+1]:
    move += 1
    ans = max(ans, move)
  else:
    move = 0
print(ans)

Fixed submission:
n = int(input())
h = list(map(int, input().split()))
ans = 0
move = 0
for i in range(n-1):
  if h[i] >= h[i+1]:
    move += 1
    ans = max(ans, move)
  else:
    move = 0
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

ans = 0
for i in a:
  ans += 1/a
  
print(1/ans)

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

ans = 0
for i in a:
  ans += 1/i
  
print(1/ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []
for i in range(n):
    s.append(''.join(sorted(list(input()))))

b = [False] * n
ans = 0
count = 1

for i in range(n):
    if b[i]:
        continue
    for j in range(i + 1, n):
        if s[i] == s[j]:
            count += 1
            b[j] = True
    ans += int(count * (count - 1) / 2)
    count = 1
    b[i] = True

print(int(ans))

Fixed submission:
n = int(input())
s = []
for i in range(n):
    s.append(''.join(sorted(list(input()))))
s.sort()

ans = 0
count = 1
s_pre = s[0]

for i in range(1, n):
    if s_pre == s[i]:
        count += 1
    else:
        ans += int(count * (count - 1) / 2)
        s_pre = s[i]
        count = 1

ans += int(count * (count - 1) / 2)
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []
for i in range(n):
    s.append(input())

b = [False] * n
ans = 0
count = 1

def ana(s1, s2):
    b = [False] * len(s1)
    for i in range(len(s1)):
        for j in range(len(s2)):
            if b[j]:
                continue
            if s1[i] == s2[j]:
                b[j] = True
    for i in range(len(s1)):
        if not b[i]:
            return False
    return True

for i in range(n):
    if b[i]:
        continue
    for j in range(i + 1, n):
        if ana(s[i], s[j]):
            count += 1
            b[j] = True
    ans += count * (count - 1) / 2
    count = 1
    b[i] = True

print(int(ans))


Fixed submission:
n = int(input())
s = []
for i in range(n):
    s.append(''.join(sorted(list(input()))))
s.sort()

ans = 0
count = 1
s_pre = s[0]

for i in range(1, n):
    if s_pre == s[i]:
        count += 1
    else:
        ans += int(count * (count - 1) / 2)
        s_pre = s[i]
        count = 1

ans += int(count * (count - 1) / 2)
print(int(ans))

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = []
for i in range(n):
  s.append(input())

b = [False]*n
ans = 0
count = 1

for i in range(n):
  if b[i]:
    continue
  for j in range(i+1, n):
    if ana(s[i], s[j]):
      count += 1
      b[j] = True
  ans += count * (count-1) / 2
  count = 1
  b[i] = True
  
print(ans)
  
def ana(s1, s2):
  b = [False] * len(s1)
  for i in range(len(s1)):
    for j in range(len(s2)):
      if b[j]:
        continue
      if s1[i] == s2[j]:
        b[j] = True
  for i in range(len(s1)):
    if not b[i]:
      return False
  return True

Fixed submission:
n = int(input())
s = []
for i in range(n):
    s.append(''.join(sorted(list(input()))))
s.sort()

ans = 0
count = 1
s_pre = s[0]

for i in range(1, n):
    if s_pre == s[i]:
        count += 1
    else:
        ans += int(count * (count - 1) / 2)
        s_pre = s[i]
        count = 1

ans += int(count * (count - 1) / 2)
print(int(ans))
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))

minimum = 1000000000
for i in range(n-1, -1, -1):
  minimum = min(s[i], minimum)
  if s[i] > minimum + 1:
    print("No")
print("Yes")

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

minimum = 1000000000
for i in range(n-1, -1, -1):
  minimum = min(h[i], minimum)
  if h[i] > minimum + 1:
    print("No")
    exit()
print("Yes")

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

minimum = 1000000000
for i in range(n-1, -1, -1):
  minimum = min(s[i], minimum)
  if s[i] > minimum + 1:
    print("No")
print("Yes")

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

minimum = 1000000000
for i in range(n-1, -1, -1):
  minimum = min(h[i], minimum)
  if h[i] > minimum + 1:
    print("No")
    exit()
print("Yes")
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = map(int, input().split())

ans = 0
for i in range(len(a)):
  if i != a[i]-1:
    ans += 1
    
if ans <= 2:
  print("YES")
else:
  print("NO")

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

ans = 0
for i in range(len(a)):
  if i != a[i]-1:
    ans += 1
    
if ans <= 2:
  print("YES")
else:
  print("NO")

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

ans = 0
for i in a:
  if i != a[i]-1:
    ans += 1
    
if ans <= 2:
  print("YES")
else:
  print("NO")

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

ans = 0
for i in range(len(a)):
  if i != a[i]-1:
    ans += 1
    
if ans <= 2:
  print("YES")
else:
  print("NO")

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

ans = 0
for i in a:
  if i != a[i]:
    ans += 1
    
if ans <= 2:
  print("YES")
else:
  print("NO")

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

ans = 0
for i in range(len(a)):
  if i != a[i]-1:
    ans += 1
    
if ans <= 2:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
n = int(input())
d = list(map(int, input().split()))
d.sort()

print(d[n/2] - d[n/2-1])

Fixed submission:
n = int(input())
d = list(map(int, input().split()))
d.sort()
print(d[int(n/2)] - d[int(n/2)-1])
Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d = map(int, input().split())
cd = math.gcd(c, d)
 
def f(x,y,div):
  return int(max(x,y)/div) - int((min(x,y)-1) / div)
print(a-b+1- f(a,b,c) - f(a,b,d) + f(a,b,cd))

Fixed submission:
a, b, c, d = map(int, input().split())
 
def gcd(x, y):
    if x % y == 0:
        return y
    return gcd(y, x%y)
 
cd = c // gcd(c,d) * d

a -= 1
a_ = a - a//c - a//d + a//cd
b_ = b - b//c - b//d + b//cd
 
print(b_ - a_)

Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d = map(int, input().split())
cd = math.gcd(cd)
 
def f(x,y,div):
  return int(max(x,y)/div) - int((min(x,y)-1) / div)
print(a-b+1- f(a,b,c) - f(a,b,d) + f(a,b,cd))

Fixed submission:
a, b, c, d = map(int, input().split())
 
def gcd(x, y):
    if x % y == 0:
        return y
    return gcd(y, x%y)
 
cd = c // gcd(c,d) * d

a -= 1
a_ = a - a//c - a//d + a//cd
b_ = b - b//c - b//d + b//cd
 
print(b_ - a_)

Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d = map(int, input().split())
cd = gcd(cd)

def f(x,y,div):
  return int(max(x,y)/div) - int((min(x,y)-1) / div)
print(a-b+1- f(a,b,c) - f(a,b,d) + f(a,b,cd))

Fixed submission:
a, b, c, d = map(int, input().split())
 
def gcd(x, y):
    if x % y == 0:
        return y
    return gcd(y, x%y)
 
cd = c // gcd(c,d) * d

a -= 1
a_ = a - a//c - a//d + a//cd
b_ = b - b//c - b//d + b//cd
 
print(b_ - a_)
Buggy python submission (verdict: Runtime Error):
n = int(input())
w = list(map(int, input().split()))
s2 = ans = sum(w)
s1 = 0
for i in range(n-1):
  s2 -= w[i]
  s1 += w[i]
  if ans < abs(s2-s1):
    break
  else:
	ans = abs(s2-s1)

print(ans)

Fixed submission:
n = int(input())
w = list(map(int, input().split()))
s2 = ans = sum(w)
s1 = 0
for i in range(n-1):
  s2 -= w[i]
  s1 += w[i]
  if ans < abs(s2-s1):
    break
  else:
    ans = abs(s2-s1)

print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
w = list(map(int, input().split()))
s2 = ans = sum(w)
s1 = 0
for i in range(n-1):
  s2 -= w[i]
  s1 += w[i]
  if ans < abs(s2-s1):
    break:
  else:
	ans = abs(s2-s1)

print(ans)

Fixed submission:
n = int(input())
w = list(map(int, input().split()))
s2 = ans = sum(w)
s1 = 0
for i in range(n-1):
  s2 -= w[i]
  s1 += w[i]
  if ans < abs(s2-s1):
    break
  else:
    ans = abs(s2-s1)

print(ans)
Buggy python submission (verdict: Runtime Error):
n,m = map(int, input())
a = set()
for i in range(m):
  a.add(int(input()))
  
b = [0]* (n+1)
b[0] = 1
if 1 not in a:
  b[1] = 1
for i in range(2, n+1):
  if i in a:
    b[i] = 0
  else:
    b[i] = b[i-1] + b[i-2]
print(b[n] % 1000000007)

Fixed submission:
n, m = map(int, input().split())
a = set()
for i in range(m):
    a.add(int(input()))

b = [0] * (n + 1)
b[0] = 1
if 1 not in a:
    b[1] = 1
for i in range(2, n + 1):
    if i in a:
        b[i] = 0
    else:
        b[i] = b[i - 1] + b[i - 2]
print(b[n] % 1000000007)

Buggy python submission (verdict: Runtime Error):
n,m = map(int, input())
a = set()
for i in range(m):
  a.add(int(input()))
  
b = [0]* (n+1)
b[0] = 1
if 1 not in a:
  b[1] = 1
for i in range(2, n+2):
  if i in a:
    b[i] = 0
  else:
    b[i] = b[i-1] + b[i-2]
print(b[n] % 1000000007)

Fixed submission:
n, m = map(int, input().split())
a = set()
for i in range(m):
    a.add(int(input()))

b = [0] * (n + 1)
b[0] = 1
if 1 not in a:
    b[1] = 1
for i in range(2, n + 1):
    if i in a:
        b[i] = 0
    else:
        b[i] = b[i - 1] + b[i - 2]
print(b[n] % 1000000007)
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
a = []
a.append(list(map(int, input().split())))
def gcd(x,y):
  if y == 0:
    return x
  return gcd(y, x % y)

pow_2 = 1
exp = 0
while pow_2 < n:
  pow_2 *= 2
  exp += 1

a[0].extend([0]*(pow_2 - n))
for i in range(1, exp):
  a.append([])
  for j in range(pow_2 / math.pow(2, i)):
    a[i].append(gcd(a[i-1][2*j], a[i-1][2*j+1]))

ans = [0]*n
for i in range(n):
  g = 0
  for j in range(0,exp):
    if (i >> j) % 2 == 0:
      bit = 1
    else:
      bit = -1
    g = gcd(a[j][(i>>j)+bit], g)
  ans[i] = g
print(sorted(ans)[n-1])

Fixed submission:
import math
n = int(input())
a = []
a.append(list(map(int, input().split())))
def gcd(x,y):
  if y == 0:
    return x
  return gcd(y, x % y)

pow_2 = 1
exp = 0
while pow_2 < n:
  pow_2 *= 2
  exp += 1

a[0].extend([0]*(pow_2 - n))
for i in range(1, exp):
  a.append([])
  for j in range(int(pow_2 / math.pow(2, i))):
    a[i].append(gcd(a[i-1][2*j], a[i-1][2*j+1]))

ans = [0]*n
for i in range(n):
  g = 0
  for j in range(0,exp):
    if (i >> j) % 2 == 0:
      bit = 1
    else:
      bit = -1
    g = gcd(a[j][(i>>j)+bit], g)
  ans[i] = g
print(sorted(ans)[n-1])