Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
k, n = map(int,input().split())
length = list(map(int,input().split()))
distance =[]
for i in range(n):
  distance.append(length[i+1]-length[i])
distance.append(k-length[n-1])
print(k-max(distance))

Fixed submission:
k, n = map(int,input().split())
length = list(map(int,input().split()))
length.append(k+length[0])
distance =[]
for i in range(n):
  distance.append(length[i+1]-length[i])
print(k-max(distance))

Buggy python submission (verdict: Runtime Error):
k, n = map(int,input().split())
length = list(map(int,input.split())
distance =[]
for i in range(n-1):
  diatance.append(lenght[i+1]-lenght[i])
distance.append(k-length[n-1])
print(k-max(distance))

Fixed submission:
k, n = map(int,input().split())
length = list(map(int,input().split()))
length.append(k+length[0])
distance =[]
for i in range(n):
  distance.append(length[i+1]-length[i])
print(k-max(distance))

Buggy python submission (verdict: Runtime Error):
k, n = map(int,input().split())
length = list(map(int,input.split())
distance =[]
for i in range(n):
  diatance.append(lenght[i+1]-lenght[i])
distance.append(k-length[n-1])
print(k-max(distance))

Fixed submission:
k, n = map(int,input().split())
length = list(map(int,input().split()))
length.append(k+length[0])
distance =[]
for i in range(n):
  distance.append(length[i+1]-length[i])
print(k-max(distance))
Buggy python submission (verdict: Runtime Error):
from collections import deque

s = deque(list(input()))

q = int(input())

reverse = 0

for i in range(q):
  query = list(input().split())
  if query[0] == '1':
    reverse ^= 1
    continue
  else:
    if query[1] == '1':
      if reverse:
        s.append(query[2])
      else:
        s.appendleft(query[2])
    else:
      if reverse:
        s.appendleft(query[2])
      else:
        s.append(query[2])
if reverse:
  s = s[::-1]
print(''.join(s))

Fixed submission:
from collections import deque

s = deque(list(input()))

q = int(input())

reverse = 0

for i in range(q):
  query = list(input().split())
  if query[0] == '1':
    reverse ^= 1
    continue
  else:
    if query[1] == '1':
      if reverse:
        s.append(query[2])
      else:
        s.appendleft(query[2])
    else:
      if reverse:
        s.appendleft(query[2])
      else:
        s.append(query[2])
if reverse:
  print(''.join(s)[::-1])
else:
  print(''.join(s))

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

q = int(input())

reverse = 0

for i in range(q):
  query = list(input().split())
  if query[0] == '1':
    reverse ^= 1
    continue
  else:
    if query[1] == '1':
      if reverse:
        s.append(query[2])
      else:
        s.appendleft(query[2])
    else:
      if reverse:
        s.appendleft(query[2])
      else:
        s.append(query[2])
if reverse:
  s = s[::-1]
print(''.join(s))


Fixed submission:
from collections import deque

s = deque(list(input()))

q = int(input())

reverse = 0

for i in range(q):
  query = list(input().split())
  if query[0] == '1':
    reverse ^= 1
    continue
  else:
    if query[1] == '1':
      if reverse:
        s.append(query[2])
      else:
        s.appendleft(query[2])
    else:
      if reverse:
        s.appendleft(query[2])
      else:
        s.append(query[2])
if reverse:
  print(''.join(s)[::-1])
else:
  print(''.join(s))

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())

q = int(input())

reverse = 0

for i in range(q):
  query = list(input().split())
  if query[0] == '1':
    reverse ^= 1
    continue
  else:
    if query[1] == '1':
      if reverse:
        s.append(query[2])
      else:
        s.insert(0, query[2])
    else:
      if reverse:
        s.insert(0, query[2])
      else:
        s.append(query[2])
if reverse:
  s = s[::-1]
print(''.join(s))

Fixed submission:
from collections import deque

s = deque(list(input()))

q = int(input())

reverse = 0

for i in range(q):
  query = list(input().split())
  if query[0] == '1':
    reverse ^= 1
    continue
  else:
    if query[1] == '1':
      if reverse:
        s.append(query[2])
      else:
        s.appendleft(query[2])
    else:
      if reverse:
        s.appendleft(query[2])
      else:
        s.append(query[2])
if reverse:
  print(''.join(s)[::-1])
else:
  print(''.join(s))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
 
forbidden = []
for i in range(m):
  forbidden.append(int(input()))
forbidden = set(forbidden) 
ans = [0]*n
ans[0] = 1
if 1 not in forbidden:
  ans[1] = 1
for i in range(2,n):
  if i not in forbidden:
    ans[i] += ans[i - 1] + ans[i - 2]
    ans[i] %= 1000000007
print(ans[-1])

Fixed submission:
n, m = map(int, input().split())
 
forbidden = []
for i in range(m):
  forbidden.append(int(input()))
forbidden = set(forbidden) 
ans = [0]*(n+1)
ans[0] = 1
if 1 not in forbidden:
  ans[1] = 1
for i in range(2,n+1):
  if i not in forbidden:
    ans[i] += ans[i - 1] + ans[i - 2]
    ans[i] %= 1000000007
print(ans[-1])

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

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

ans = [1, 1]
if 1 in forbidden:
  ans[-1] = 0
for i in range(2,n+1):
  if i in forbbidden:
    ans.append(0)
  else:
    ans.append(ans[-1]+[ans[-2]])
  if ans[-1] == 0 and ans[-2] == 0:
    print(0)
  if i == n:
    print(ans[-1])

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

res = []
for i in range(n):
  city, value = input().split()
  value = int(value)
  res.append([city, value, i])
res_s = sorted(res, key = lambda x: (x[0], -x[1]))
for i in range(n):
  print(ans[i][2])

Fixed submission:
n = int(input())

res = []
for i in range(n):
  city, value = input().split()
  value = int(value)
  res.append([city, value, i+1])
res_s = sorted(res, key = lambda x: (x[0], -x[1]))
for i in range(n):
  print(res_s[i][2])
Buggy python submission (verdict: Runtime Error):
import math
n, k = map(int, input().split())
ans = 0.0
if n >= k:
  ans += (n-k+1)/n
  
for i in range(1, min(n+1, k)):
  ans+= (1/2)**(floor(math.log2(k/i))+1)
print(ans)

Fixed submission:
import math
n, k = map(int, input().split())
ans = 0.0
if n >= k:
  ans += (n-k+1)/n
  
for i in range(1, min(n+1, k)):
  now = i
  p = 1/n
  while(now <k):
    now *= 2
    p /= 2
  ans += p
  
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

mx = 0
for i in range(1, n):
    t = 0
    for j in range(n - i):
        t = t + 1 if s[j] == s[j + i] else 0
        mx = max(mx, min(i, t))

print(mx)

Fixed submission:
n = int(input())
s = input()

mx = 0
for i in range(1, n):
    t = 0
    for j in range(n - i):
        t = t + 1 if s[j] == s[j + i] else 0
        mx = max(mx, min(i, t))

print(mx)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

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

diff = sorted([t[1]-t[0] for t in combinations(a, 2)], reverse=True)

print(diff.count(diff[0]))

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

mn = a[0]
l = []

for x in a:
    l.append(x-mn)
    mn = min(mn, x)

l.sort()
print(l.count(l[-1]))
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())

if k > (n-1)*(n-2)//2:
  print(-1)
else:
  ans = []
  for i in range(n-1):
    ans.append("{} {}".format(0, i+1))
  u = 1
  v = 2
  for i in range((n-1)*(n-2)//2 - k):
    ans.append("{} {}".format(u, v))
    v += 1
    if (v > n):
      u += 1
      v = u + 1

print(len(ans))
for s in ans:
  print(s)


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

if k > (n-1)*(n-2)//2:
  print(-1)
else:
  ans = []
  for i in range(n-1):
    ans.append("{} {}".format(1, i+2))
  u = 2
  v = 3
  for _ in range((n-1)*(n-2)//2 - k):
    ans.append("{} {}".format(u, v))
    v += 1
    if (v > n):
      u += 1
      v = u + 1

  print(len(ans))
  for s in ans:
    print(s)

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

if k > (n-1)(n-2)//2:
  print(-1)
else:
  ans = []
  for i in range(n-1):
    ans.push_back("{} {}".format(0, i+1))
  u = 1
  v = 2
  for i in range((n-1)(n-2)//2 - k):
    ans.push_back("{} {}".format(u, v))
    v += 1
    if (v > n):
      u += 1
      v = u + 1

print(len(ans))
for s in ans:
  print(s)

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

if k > (n-1)*(n-2)//2:
  print(-1)
else:
  ans = []
  for i in range(n-1):
    ans.append("{} {}".format(1, i+2))
  u = 2
  v = 3
  for _ in range((n-1)*(n-2)//2 - k):
    ans.append("{} {}".format(u, v))
    v += 1
    if (v > n):
      u += 1
      v = u + 1

  print(len(ans))
  for s in ans:
    print(s)
Buggy python submission (verdict: Runtime Error):
from collections import deque
import sys
sys.setrecursionlimit(100000000)
 
h,w=map(int, input().split())  
s=[list(input()) for i in range(h)]
v=[]
def bfs():
    d = [[float("inf")] * w for i in range(h)]
    que = deque([])
    #黒だったらスタートキューに入れる
    for i in range(h):
        for j in range(w):
            if s[i][j]=='#':
                que.append((i, j))
                d[i][j]=0
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    
    
    while que:
        p = que.popleft()
         # 黒にする4方向をループ
        for i in range(4):
            ny = p[0] + dx[i]
            nx = p[1] + dy[i]
 
            if 0<=nx<w and 0<=ny<h and d[nx][ny] == float("inf"):
                que.append((ny, nx))
                d[nx][ny] = d[p[0]][p[1]] + 1
                
    for i in range(h):
        v.append(max(d[i]))
    return max(v)
res=bfs()
print(res)
        


Fixed submission:
from collections import deque

h, w = map(int, input().split())
s = [input() for i in range(h)]

d = [[h+w for j in range(w)] for i in range(h)]
que = deque()

#黒だったらスタートキューに入れる
for i in range(h):
  for j in range(w):
    if s[i][j]=='#':
        que.append((i, j))
        d[i][j] = 0

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]


while que:
    p = que.popleft()
    # 黒にする4方向をループ
    for i in range(4):
        nx = p[1] + dx[i]
        ny = p[0] + dy[i]

        if (0<=nx<w) and (0<=ny<h) and (d[ny][nx]==h+w):
            que.append((ny, nx))
            d[ny][nx] = d[p[0]][p[1]] + 1

res = max(map(max, d))
print(res)
Buggy python submission (verdict: Runtime Error):
n, t = input().split()
ret = 1001
for i in range(n):
  a, b = map(int, input().split())
  if b <= t:
    ret = min(a, ret)
    
if ret == 1001:
  print('TLE')
else:
  print(ret)

Fixed submission:
n, t = map(int, input().split())
ret = 1001
for i in range(n):
  a, b = map(int, input().split())
  if b <= t:
    ret = min(a, ret)
    
if ret == 1001:
  print('TLE')
else:
  print(ret)

Buggy python submission (verdict: Runtime Error):
n, t = input().split()
ret = 1001
for i in range(n):
  a, b = input().split()
  if b <= t:
    ret = min(a, ret)
    
if ret == 1001:
  print('TLE')
else:
  print(ret)

Fixed submission:
n, t = map(int, input().split())
ret = 1001
for i in range(n):
  a, b = map(int, input().split())
  if b <= t:
    ret = min(a, ret)
    
if ret == 1001:
  print('TLE')
else:
  print(ret)

Buggy python submission (verdict: Runtime Error):
n, t = split(input())
ret = 1001
for i in range(n):
  a, b = split(input())
  if b <= t:
    ret = min(a, ret)
    
if ret == 1001:
  print('TLE')
else:
  print(ret)

Fixed submission:
n, t = map(int, input().split())
ret = 1001
for i in range(n):
  a, b = map(int, input().split())
  if b <= t:
    ret = min(a, ret)
    
if ret == 1001:
  print('TLE')
else:
  print(ret)
Buggy python submission (verdict: Runtime Error):
import itertools
import numpy as np

n,m,q=map(int, input().split())  
a=[list(map(int, input().split())) for i in range(m)]
b=[list(map(int, input().split())) for i in range(q)]

x=np.zeros(501, 501)

for i in range(m):
    x[a[i][0]][a[i][1]]+=1

x= np.cumsum(x, axis=0)
x= np.cumsum(x, axis=1)

for i in range(q):
    v1=b[i][0]
    v2=b[i][1]
    
    a1=x[v2,v2]
    a2=x[v2,v1-1]
    a3=x[v1-1,v2]
    a4=x[v1-1,v1-1]
    print(a1-a2-a3+a4)

Fixed submission:
import numpy as np

n,m,q=map(int, input().split())  
a=[list(map(int, input().split())) for i in range(m)]
b=[list(map(int, input().split())) for i in range(q)]

x=np.zeros((501, 501), dtype=np.int)

for i in range(m):
    x[a[i][0], a[i][1]]+=1

x = np.cumsum(x, axis=0)
x = np.cumsum(x, axis=1)

for i in range(q):
    v1=b[i][0]
    v2=b[i][1]
    
    a1=x[v2, v2]
    a2=x[v2, v1-1]
    a3=x[v1-1, v2]
    a4=x[v1-1, v1-1]
    print(a1-a2-a3+a4)
Buggy python submission (verdict: Runtime Error):
x = list(map(input().split(), int))

print(x.max() - x.min())

Fixed submission:
x = list(map(int, input().split()))
print(max(x) - min(x))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
e = []
for i in range(m):
  e.append(list(map(int, input, split())))

e.sort(key=lambda x:x[1])
ret = 0

l = 0
for i in range(m):
  if e[i][0] < l:
    continue
  else:
    l = e[i][1]
    ret += 1
    
print(ret)

Fixed submission:
n, m = map(int, input().split())
e = []
for i in range(m):
  e.append(list(map(int, input().split())))

e.sort(key=lambda x:x[1])
ret = 0

l = 0
for i in range(m):
  if e[i][0] < l:
    continue
  else:
    l = e[i][1]
    ret += 1
    
print(ret)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N = int(input())
A = deque(map(int, input().split()))
ans = 1
for i in range(N):
    ans *= A.pop()
if ans > 10 ** 18:
    print(-1)
else:
    print(ans)

Fixed submission:
#from collections import deque
def hanbun(L):
    N = len(L)
    flag = N % 2
    N = N // 2
    ans = []
    for i in range(N):
        ans.append(L[2 * i] * L[2 * i + 1])
    if flag == 1:
        ans.append(L[-1])
    return(ans)

N = int(input())
A = list(map(int, input().split()))
while len(A) > 1:
    A = hanbun(A)
ans = A[0]
if ans > 10 ** 18:
    print(-1)
else:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
ans = 1
for a in A:
    ans *= a
if ans > 10 ** 18:
    print(-1)
else:
    print(ans)

Fixed submission:
#from collections import deque
def hanbun(L):
    N = len(L)
    flag = N % 2
    N = N // 2
    ans = []
    for i in range(N):
        ans.append(L[2 * i] * L[2 * i + 1])
    if flag == 1:
        ans.append(L[-1])
    return(ans)

N = int(input())
A = list(map(int, input().split()))
while len(A) > 1:
    A = hanbun(A)
ans = A[0]
if ans > 10 ** 18:
    print(-1)
else:
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
B = []
for i in range(1, N + 1):
    print(A.count(i))


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = [0 for i in range(N)]
for i in A:
    B[i - 1] += 1
for i in B:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
import math
def gcd(a, b, c):
    x = math.gcd(a, b)
    return(math.gcd(x, c))

K = int(input())
sum = 0
for i in range(K):
    for j in range(K):
        for k in range(K):
            sum += gcd(i + 1, j + 1, k + 1)
print(sum)


Fixed submission:
import math
def gcd(a, b, c):
    x = math.gcd(a, b)
    return(math.gcd(x, c))
K = int(input())
sum = 0
for i in range(1, K + 1):
    for j in range(i, K + 1):
        for k in range(j, K + 1):
            if i == j == k:
                sum += gcd(i, j, k)
            elif i == j or j == k or k == i:
                sum += 3 * gcd(i, j, k)
            else:
                sum += 6 * gcd(i, j, k)
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
import copy

def count(dic, key):
    ans = 0
    for i in key:
        d = dic[i]
        ans += d * (d - 1) // 2
    return(ans)

N = int(input())
A = list(map(int, input().split()))
a = dict(Counter(A))
k = list(a.keys())
dic = {}
for i in k:
    a2 = copy.copy(a)
    a2[i] -= 1
    dic[i] = count(a2, k)
for i in range(N):
    print(dic[A[i]])


Fixed submission:
from collections import Counter
import copy

def count(dic, key):
    ans = 0
    for i in key:
        d = dic[i]
        ans += d * (d - 1) // 2
    return(ans)

N = int(input())
A = list(map(int, input().split()))
a = dict(Counter(A))
k = list(a.keys())
m = count(a, k)
dic = {}
for i in k:
    dic[i] = m - a[i] + 1
for i in range(N):
    print(dic[A[i]])

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
import copy

def count(dic, key):
    ans = 0
    for i in key:
        d = dic[i]
        ans += d * (d - 1) // 2
    return(ans)

N = int(input())
A = list(map(int, input().split()))
a = dict(Counter(A))
k = list(a.keys())
for i in range(N):
    a2 = copy.copy(a)
    a2[A[i]] -= 1
    print(count(a2, k))


Fixed submission:
from collections import Counter
import copy

def count(dic, key):
    ans = 0
    for i in key:
        d = dic[i]
        ans += d * (d - 1) // 2
    return(ans)

N = int(input())
A = list(map(int, input().split()))
a = dict(Counter(A))
k = list(a.keys())
m = count(a, k)
dic = {}
for i in k:
    dic[i] = m - a[i] + 1
for i in range(N):
    print(dic[A[i]])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
rain_sum = sum(A) // 2
for i in range(N):
    rain_other = 0
    for j in range((N - 1) // 2):
        rain_other += A[(i + 1 + 2 * j) % N]
    print((rain_sum - rain_other) * 2, end = ' ')


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
rain_sum = sum(A) // 2
rain_other = 0
for i in range((N - 1) // 2):
    rain_other += A[(2 * i + 1) % N]
rain_before = (rain_sum - rain_other) * 2
print(rain_before, end = ' ')
for i in range(N - 1):
    rain_before = 2 * A[i] - rain_before
    print(rain_before, end = ' ')
Buggy python submission (verdict: Runtime Error):
import sys
N, X = map(int,input().split())
x = 0
L.append(list(map(int,input().split())))
count = 1
for i in range(N):
    if x + L[i] <= X:
        count = count + 1
        x = x + L[i]
    else:
        print(count)
        sys.exit()
print(count)


Fixed submission:
import sys
N, X = map(int,input().split())
x = 0
L = list(map(int,input().split()))
count = 1
for i in range(N):
    if x + L[i] <= X:
        count = count + 1
        x = x + L[i]
    else:
        print(count)
        sys.exit()
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
if k % 2 == 0:
	print(-1)
	exit()
i = 7
cnt = 1
while i % k != 0:
	if i % k != i:
		i = i % k
	i = i * 10 + 7
	cnt += 1
print(cnt)

Fixed submission:
k = int(input())
j = 7

for i in range(k):
	if j % k < 1:
		print(i + 1)
		exit()
	j = (j * 10 + 7) % k
print(-1)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)
 
def resolve():
    def dfs(num, p=-1):
        for i in to[num]:
            if p == i:
                continue
            ns[i] += ns[num]
            dfs(i, num)
 
    n, q = map(int, input().split())
 
    to = [[] for _ in range(n)]
 
    for _ in range(n-1):
        a,b = map(int, input().split())
        a -= 1
        b -= 1
        to[a].append(b)
        to[b].append(a)
 
    ns = [0 for _ in range(n)]
    for _ in range(q):
        p, x = map(int, input().split())
        p -= 1
        ns[p] += x
 
    dfs(0)
    print(*ns)
resolve()

Fixed submission:
def resolve():
    a = int(input())
    s = input()

    if a >= 3200:
        print(s)
    else:
        print('red')
resolve()
Buggy python submission (verdict: Time Limit Exceeded):

def resolve():
    n, m = map(int, input().split())
    jobs = []
    for i in range(n):
        days, reward = map(int, input().split())
        jobs.append([reward, days])

    jobs = sorted(jobs, reverse=True)
    res = 0
    # 残りi日の時点でどの仕事をするか
    for i in range(m+1):
        for j in jobs:
            if j[1] <= i:
                res += j[0]
                j[1] = 100001
                break

    print(res)
resolve()

Fixed submission:
from heapq import heappush, heappop

def resolve():
    n, m = map(int, input().split())
    jobs = [[] for _ in range(m+1)]
    for i in range(n):
        days, reward = map(int, input().split())
        if days <= m:
            jobs[days].append(-reward)

    res = 0
    heap = []
    # 残りi日の時点でどの仕事をするか
    for i in range(m+1):
        for j in jobs[i]:
            heappush(heap, j)
        if len(heap) > 0:
            res += -heappop(heap)

    print(res)
resolve()

Buggy python submission (verdict: Time Limit Exceeded):
def resolve():
    n, m = map(int, input().split())
    jobs = []
    for i in range(n):
        days, reward = map(int, input().split())
        jobs.append((days, reward))

    jobs = sorted(jobs, key=lambda item: item[1], reverse=True)
    res = 0
    # 残りi日の時点でどの仕事をするか
    for i in range(m+1):
        for j in jobs:
            if j[0] <= i:
                res += j[1]
                jobs.remove(j)
                break

    print(res)
resolve()

Fixed submission:
from heapq import heappush, heappop

def resolve():
    n, m = map(int, input().split())
    jobs = [[] for _ in range(m+1)]
    for i in range(n):
        days, reward = map(int, input().split())
        if days <= m:
            jobs[days].append(-reward)

    res = 0
    heap = []
    # 残りi日の時点でどの仕事をするか
    for i in range(m+1):
        for j in jobs[i]:
            heappush(heap, j)
        if len(heap) > 0:
            res += -heappop(heap)

    print(res)
resolve()
Buggy python submission (verdict: Runtime Error):
def resolve():
    a,b,c,d = map(int,input().split())

    dividable_by_c = b // c - (a-1) // c
    dividable_by_d = b // d - (a-1) // d
    lcm = c * d // fractions.gcd(c,d)
    dividable_by_c_and_d = b // lcm - (a-1) // lcm

    result = (b - a + 1) - dividable_by_c - dividable_by_d + dividable_by_c_and_d
    print(result)
resolve()

Fixed submission:
import fractions

def resolve():
    a,b,c,d = map(int,input().split())
 
    dividable_by_c = b // c - (a-1) // c
    dividable_by_d = b // d - (a-1) // d
    lcm = c * d // fractions.gcd(c,d)
    dividable_by_c_and_d = b // lcm - (a-1) // lcm
 
    result = (b - a + 1) - dividable_by_c - dividable_by_d + dividable_by_c_and_d
    print(result)
resolve()
Buggy python submission (verdict: Time Limit Exceeded):
# ここから
import sys
input = sys.stdin.readline

def resolve():
    n, m = map(int, input().split())
    aa = [int(input()) for _ in range(m)]
    dp = [0] * (n+1)
    dp[0] = 1
    dp[1] = 0 if 1 in aa else 1

    for i in range(2, n+1):
        if i in aa:
            dp[i] = 0
        else:
            dp[i] = (dp[i-2] + dp[i-1]) % 1000000007

    print(dp[n])



resolve()

Fixed submission:
# ここから
import sys
input = sys.stdin.readline

def resolve():
    n, m = map(int, input().split())
    aa = [False] * (n+1)

    for i in range(m):
        a = int(input())
        aa[a] = True

    dp = [0] * (n+1)
    dp[0] = 1
    dp[1] = 0 if aa[1] else 1

    for i in range(2, n+1):
        if aa[i]:
            dp[i] = 0
        else:
            dp[i] = (dp[i-2] + dp[i-1]) % 1000000007

    print(dp[n])



resolve()
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
l = [0]*(n)
l[1] = 1
for i in range(n):
    l[a[i]-1] = i + 1
print(" ".join(map(str, l)))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
l = [0]*(n)
for i in range(n):
    l[a[i]-1] = i + 1
print(" ".join(map(str, l)))