Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S,W = map(int, readline())


if S > W:
  print('safe')
else:
  print('unsafe')

Fixed submission:
import sys
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
S,W = map(int, readline().split())
 
 
if S > W:
  print('safe')
else:
  print('unsafe')
Buggy python submission (verdict: Runtime Error):
N=int(input())
A=list(map(int, input().split()))
ans=[0]*N
for _i in range(N):
  ans[A[i]-1]+=1

for x in ans:
  print(x)

Fixed submission:
N=int(input())
A=list(map(int, input().split()))
ans=[0]*N

for i in range(N-1):
  ans[A[i]-1]+=1
 
for x in ans:
  print(x)
Buggy python submission (verdict: Time Limit Exceeded):
import math

K=int(input())
ans=0

for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      ans+=math.gcd(math.gcd(i,j),k)
print(ans)

Fixed submission:
import math

K=int(input())
ans=0

for i in range(1,K+1):
  for j in range(1,K+1):
    temp=math.gcd(i,j)
    for k in range(1,K+1):
      ans+=math.gcd(temp,k)
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

X,Y,Z = map(int, readline())

A,B,C = Z,X,Y

print(A,B,C)

Fixed submission:
import sys
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
X,Y,Z = map(int, readline().split())
 
A,B,C = Z,X,Y
 
print(A,B,C)
Buggy python submission (verdict: Runtime Error):
K,N=map(int,input().split())
A=list(map(int,input().split()))
temp=0
for i in range(N):
  tmep+=min(A[i],K-A[i])
print(min(A[-1]-A[0],temp)

Fixed submission:
K,N=map(int,input().split())
A=list(map(int,input().split()))
temp=10**9
for i in range(N-1):
  temp=min(temp,A[i]+K-A[i+1])

print(min(A[-1]-A[0],temp))
Buggy python submission (verdict: Runtime Error):
h,w = map(int, input().split())

a = h*w

if a%2==0:
  print(a//2)
else:
  pirnt(a//2+1)

Fixed submission:
h,w = map(int, input().split())
 
a = h*w
 
if h==1 or w==1:
  print(1)
elif a%2==0:
  print(a//2)
else:
  print(a//2+1)
Buggy python submission (verdict: Runtime Error):
N=int(input())
X=list(map(int,input().split()))
ans=10**9

for i in range(1,101):
  temp=0
  for j in range(N):
    temp+=(X[i]-j)**2
  else:
    ans=min(ans,temp)
print(ans)

Fixed submission:
N=int(input())
X=list(map(int,input().split()))
ans=10**9
 
for i in range(1,101):
  temp=0
  for j in range(N):
    temp+=(X[j]-i)**2
  else:
    ans=min(ans,temp)
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
ans = DENIED

for i in range(n):
  if a[i]%2 == 1:
    continue
  else:
    if a[i]%3==0 or a[i]%5==0:
      continue
    else:
      break
else:
  ans = APPROVED

print(ans)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 'DENIED'
 
for i in range(n):
  if a[i]%2 == 1:
    continue
  else:
    if a[i]%3==0 or a[i]%5==0:
      continue
    else:
      break
else:
  ans = 'APPROVED'
 
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
L=map(int,input().split())
ans=1
M=L[0]
for i in range(1,N):
  if M>=L[1]:
    M=L[1]
    ans+=1
  else:
    continue
print(ans)

Fixed submission:
N=int(input())
L=list(map(int,input().split()))
ans=1
M=L[0]
for i in range(1,N):
  if M>=L[i]:
    M=L[i]
    ans+=1
  else:
    continue
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int, input().split())
answer_p = set()
submit_p= set()
L=[]
count_pena=0

for _ in range(M):
  p,S= input().split()
  answer_p.add(p)
  if (p, 'AC') in L:
    continue
  L.append((p,S))

for l in L:
  if l[0] not in answer_p:
    continue
  else:
    if l[1]=='WA':
      count_pena+=1

print(len(answer_p), count_pena)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,M = map(int, readline().split())
PS = [line.split() for line in readlines()]

AC = [False] * (N+1)
WA_cnt = [0] * (N+1)

penal = 0
for p,s in PS:
  p = int(p)
  if AC[p]:
    continue
  if s== b'WA':
    WA_cnt[p] += 1
  else:
    AC[p] = True
    penal += WA_cnt[p]
    
ac = sum(AC)
print(ac, penal)
Buggy python submission (verdict: Runtime Error):
print(S,T)

Fixed submission:
S,T = input().split()
print(T,S, sep='')
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())

temp = list(A,B)

for i in range(1,4):
  if i not in temp:
    print(i)

Fixed submission:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A,B = map(int, read().split())
temp = [A,B]
 
for i in range(1,4):
  if i not in temp:
    print(i)
Buggy python submission (verdict: Runtime Error):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
S,T = map(int, readline().split())

ans = []

for i in range(N):
  ans.append(S[i])
  ans.append(T[i])

print(''.join(ans))
  

Fixed submission:
import sys
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N = int(readline())
S,T = read().decode('utf-8').rstrip().split()
 
ans = []
 
for i in range(N):
  ans.append(S[i])
  ans.append(T[i])


print(''.join(ans))
Buggy python submission (verdict: Runtime Error):
import math

A,B=map(int,input())
print(A*B // math.gcd(A,B))


Fixed submission:
import math
 
A,B=map(int,input().split())
print(A*B // math.gcd(A,B))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
L=[x for x in range(1,N+1)]
ans=0
for i in range(N):
  if A[i]!=L[0]:
    ans+=1
  else:
    L.pop(0)

if N==1 and A[0]==1:
  print(0)
elif 1 not in A:
  print(-1)
else:
  print(ans)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
L=1
ans=0
for i in range(N):
  if A[i]!=L:
    ans+=1
  else:
    L+=1

if N==1 and A[0]==1:
  print(0)
elif 1 not in A:
  print(-1)
else:
  print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N=int(input())
A=np.array(list(map(int, input().split())))

for i in range(1,N):
  try:
    dif=min(dif,abs(sum(A[:i])-sum(A[i:])))
  except:
    dif=abs(sum(A[:i])-sum(A[i:]))
print(dif)

Fixed submission:
import numpy as np

N=int(input())
A=np.array(list(map(int, input().split())))
S=sum(A)-A[0]
X=A[0]
ans=abs(S-X)
for i in range(1,N-1):
  X+=A[i]
  S-=A[i]
  ans=min(ans,abs(S-X))
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b = map(int, input())
if len(str(a)) == 1 and len(str(b)) == 1:
  print(a*b)
else:
  print(-1)

Fixed submission:
a,b = map(int, input().split())
if len(str(a)) == 1 and len(str(b)) == 1:
  print(a*b)
else:
  print(-1)
Buggy python submission (verdict: Runtime Error):
inport sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())

U = 10**6 + 100

div = np.arange(1, U, dtype=np.int64)
div = div[N%div==0]

div = np.union1d(div, N//div)

answer = (div + (N//div)).min() - 2
print(answer)

Fixed submission:
import math
n = int(input())
l = [0]

for i in range(1, int(math.sqrt(n))+1):
  if n % i == 0:
    l[0] = i

print(l[0]+(n//l[0])-2)
Buggy python submission (verdict: Runtime Error):
import bisect
n = int(input())
l = List(map(int, input().split()))
count = 0
l = sorted(l)

for i in range(n-2):
  for j in range(i+1, n-1):
    k = bisect.bisect_left(l, l[i]+l[j])
    count += k -j - 1
print(count)

Fixed submission:
import bisect
n = int(input())
l = list(map(int, input().split()))
count = 0
l = sorted(l)

for i in range(n-2):
  for j in range(i+1, n-1):
    k = bisect.bisect_left(l, l[i]+l[j])
    count += k -j - 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
ans = 0
 
for i in range(n-2):
  for j in range(i+1, n-1):
    k = 1
    while True:
      if k == n-j:
        break
      else: 
        if l[i] + l[j] > l[-k]:
          ans += n-k-j
          break
        k += 1
print(ans)

Fixed submission:
import bisect
n = int(input())
l = list(map(int, input().split()))
count = 0
l = sorted(l)

for i in range(n-2):
  for j in range(i+1, n-1):
    k = bisect.bisect_left(l, l[i]+l[j])
    count += k -j - 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
ans = 0
 
for i in range(n-2):
  for j in range(i+1, n-1):
    for k in range(1, n-j):
      if l[i] + l[j] > l[-k]:
        ans += n-k-j
        break
print(ans)

Fixed submission:
import bisect
n = int(input())
l = list(map(int, input().split()))
count = 0
l = sorted(l)

for i in range(n-2):
  for j in range(i+1, n-1):
    k = bisect.bisect_left(l, l[i]+l[j])
    count += k -j - 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import math
n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
ans = 0

for i in range(n-2):
  for j in range(i+1, n-1):
    for k in range(j+1, n):
      if l[i] + l[j] > l[k]:
        ans += 1
        continue
      else:
        break

print(ans)

Fixed submission:
import bisect
n = int(input())
l = list(map(int, input().split()))
count = 0
l = sorted(l)

for i in range(n-2):
  for j in range(i+1, n-1):
    k = bisect.bisect_left(l, l[i]+l[j])
    count += k -j - 1
print(count)
Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
s = list(x for x in input())
ans = 0

if s[0] == 'R':
  s.insert(0, 'L')
if s[-1] == 'R':
  s.append('L')
s.append(0)
l = []
r = []


for i in range(len(s)-1):
  if s[i] == 'L':
    l.append(i)
    if s[i+1] == 'L':
      ans += 1
      
for i in range(len(l)-1):
  r.append(l[i+1] - l[i] - 1)

r.sort(reverse = True)

for i in range(k):
  if r[i] != 0:
    ans += r[i] + 1
  else:
    break

if n == 1:
  print(0)
elif n == 2:
  print(1)
elif ans == n:
  print(n-1)
else:
  print(ans)


Fixed submission:
n,k = map(int, input().split())
s = input()
ans = 0
for i in range(len(s)-1):
	if s[i] == s[i+1]:
		ans += 1
ans += 2*k
 
print(min(ans, n-1))

Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
s = list(x for x in input())
ans = 0

if s[0] == 'R':
  s.insert(0, 'L')
if s[-1] == 'R':
  s.append('L')
s.append(0)
l = []
r = []


for i in range(len(s)-1):
  if s[i] == 'L':
    l.append(i)
    if s[i+1] == 'L':
      ans += 1
      
for i in range(len(l)-1):
  r.append(l[i+1] - l[i] - 1)

r.sort(reverse = True)

for i in range(k):
  if r[i] != 0:
    ans += r[i] + 1
  else:
    break

if n == 1:
  print(0)
elif ans == n:
  print(n-1)
else:
  print(ans)


Fixed submission:
n,k = map(int, input().split())
s = input()
ans = 0
for i in range(len(s)-1):
	if s[i] == s[i+1]:
		ans += 1
ans += 2*k
 
print(min(ans, n-1))

Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
s = list(x for x in input())
ans = 0

if s[0] == 'R':
  s.insert(0, 'L')
if s[-1] == 'R':
  s.append('L')
s.append(0)
l = []
r = []


for i in range(len(s)-1):
  if s[i] == 'L':
    l.append(i)
    if s[i+1] == 'L':
      ans += 1
      
for i in range(len(l)-1):
  r.append(l[i+1] - l[i] - 1)

r.sort(reverse = True)

for i in range(k):
  if r[i] != 0:
    ans += r[i] + 1

if ans == n:
  print(n-1)
else:
  print(ans)


Fixed submission:
n,k = map(int, input().split())
s = input()
ans = 0
for i in range(len(s)-1):
	if s[i] == s[i+1]:
		ans += 1
ans += 2*k
 
print(min(ans, n-1))
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))
count = [0]
ans = []

for i in range(n-1):
  if h[i] < h[i+1]:
    count.append(i+1)
  if i == n - 2:
    if h[n-2] >= h[n-1]:
      count.append(n)

for i in range(len(count) - 1):
  ans.append(count[i+1] - count[i] - 1)

print(max(ans))


Fixed submission:
n = int(input())
h = list(map(int, input().split()))
count = [0]
ans = []

for i in range(n-1):
  if h[i] < h[i+1]:
    count.append(i+1)
  if i == n - 2:
    if h[n-2] >= h[n-1]:
      count.append(n)

for i in range(len(count) - 1):
  ans.append(count[i+1] - count[i] - 1)

if n == 1:
  print(0)
else:
  print(max(ans))
Buggy python submission (verdict: Time Limit Exceeded):
n = list(x for x in range(1, int(input()) + 1))
p = [max(n)]
p.extend(n)

m = []
ans = 0

for i in range(len(n)):
  m.append(p[i] % (i+1))

for i in range(len(n)):
  ans += m[i]

print(ans)

Fixed submission:
n = int(input())
print(n*(n-1)//2)
Buggy python submission (verdict: Runtime Error):
M,D = input().split()
ans = 0
for i in range(1, M+1):
  for j in range(1, D+1):
    if j < 22:
      continue
    else:
      j = str(j)
      if M == int(j[0]) * int(j[1]):
        ans += 1
print(ans)


Fixed submission:
M,D = map(int,input().split())
ans = 0
for i in range(1, M+1):
  for j in range(1, D+1):
    if j < 22:
      continue
    else:
      j = str(j)
      d1 = int(j[0])
      d2 = int(j[1])
      if d1>=2 and d2>=2 and i == d1*d2:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
a=int(input().split())
s=input().split()
if a >= 3200:
  print(s)
else:
  print(a)

Fixed submission:
a=int(input())
s=input()
if a >= 3200:
  print(s)
else:
  print('red')

Buggy python submission (verdict: Runtime Error):
if a >= 3200:
  print(s)
elif a < 3200:
  print('red')

Fixed submission:
a=int(input())
s=input()
if a >= 3200:
  print(s)
else:
  print('red')

Buggy python submission (verdict: Runtime Error):
if a < 5000 && a >= 3200:
	print(s)
elif 2800 <= a && a < 3200:
	print('red')

Fixed submission:
a=int(input())
s=input()
if a >= 3200:
  print(s)
else:
  print('red')

Buggy python submission (verdict: Runtime Error):
if a >= 3200:
	print(s)
else:
	print('red')


Fixed submission:
a=int(input())
s=input()
if a >= 3200:
  print(s)
else:
  print('red')

Buggy python submission (verdict: Runtime Error):
if a < 3200:
	print(a)
else:
	print(s)

Fixed submission:
a=int(input())
s=input()
if a >= 3200:
  print(s)
else:
  print('red')
Buggy python submission (verdict: Runtime Error):
from collections import deque
s = deque(x for x in input())
s.append(0)
k = 0
l = [s.popleft()]
while True:
  if s[0] == 0:
    break
  elif l[k] == s[0]:
    l.append(s.popleft()+s.popleft())
  else:
    l.append(s.popleft())
  k += 1
print(len(l))

Fixed submission:
from collections import deque
s = deque(x for x in input())
s.append('END')
k = 0
l = [s.popleft()]
while True:
  if s[0] == 'END':
    break
  elif l[k] == s[0]:
    if s[1] == 'END':
      break
    else:
      l.append(s.popleft()+s.popleft())
  else:
    l.append(s.popleft())
  k += 1
print(len(l))

Buggy python submission (verdict: Runtime Error):
from collections import deque
s = deque(x for x in input())
s.append(0)
k = 0
l = [s[0]]
while True:
  if s[0] == 0:
    break
  elif l[k] == s[0]:
    l.append(s.popleft()+s.popleft())
  else:
    l.append(s.popleft())
  k += 1
print(len(l))

Fixed submission:
from collections import deque
s = deque(x for x in input())
s.append('END')
k = 0
l = [s.popleft()]
while True:
  if s[0] == 'END':
    break
  elif l[k] == s[0]:
    if s[1] == 'END':
      break
    else:
      l.append(s.popleft()+s.popleft())
  else:
    l.append(s.popleft())
  k += 1
print(len(l))

Buggy python submission (verdict: Runtime Error):
from collections import deque
s = deque(x for x in input())
s.append(0)
k = 0
l = [s[0]]
while True:
  if s[0] == 0:
    break
  elif l[k] == s[0]:
    l.append(s.popleft()+s.popleft())
  else:
    l.append(s.popleft())
  k += 1
print(k)

Fixed submission:
from collections import deque
s = deque(x for x in input())
s.append('END')
k = 0
l = [s.popleft()]
while True:
  if s[0] == 'END':
    break
  elif l[k] == s[0]:
    if s[1] == 'END':
      break
    else:
      l.append(s.popleft()+s.popleft())
  else:
    l.append(s.popleft())
  k += 1
print(len(l))
Buggy python submission (verdict: Runtime Error):
A,B = input().split()
A,B = int(A),int(B)
ans = [A+B,A-B,A*B]
sort(ans)
print(ans.pop())


Fixed submission:
A,B = input().split()
A,B = int(A),int(B)
ans = [A+B,A-B,A*B]
ans.sort()
print(ans.pop())
Buggy python submission (verdict: Runtime Error):
N = input()
s = [''.join(sorted(input())) for i in range(N)]
ans=0
dict={}
for i in s:
  if i in dict:
    ans+=dict[i]
    dict[i]+=1
  else:
    dict[i]=1
print(ans)

Fixed submission:
N = int(input())
s = [''.join(sorted(input())) for i in range(N)]
ans=0
dict={}
for i in s:
  if i in dict:
    ans+=dict[i]
    dict[i]+=1
  else:
    dict[i]=1
print(ans)

Buggy python submission (verdict: Runtime Error):
N = input()
s = [''.join(sorted(input())) for i in range(N)]
ans=0
dict={}
for i in s:
  if i in dict:
    ans+=dict
    dict[i]+=1
  else:
    dict[i]=1
print(ans)

Fixed submission:
N = int(input())
s = [''.join(sorted(input())) for i in range(N)]
ans=0
dict={}
for i in s:
  if i in dict:
    ans+=dict[i]
    dict[i]+=1
  else:
    dict[i]=1
print(ans)
Buggy python submission (verdict: Runtime Error):
n,d = map(int, input().split())
ans = 0
if n % (2d+1) == 0:
  ans = n//(2d+1)
else:
  ans = n//(2d+1) + 1
print(ans)

Fixed submission:
n,d = map(int, input().split())
ans = 0
if n % (2 * d + 1) == 0:
  ans = n // (2 * d + 1)
else:
  ans = n // (2 * d + 1) + 1
print(ans)

Buggy python submission (verdict: Runtime Error):
n,d = map(int, input().split())
ans = 0
if n % (2d+1) == 0:
  ans = n//(2d+1)
else:
  ans = n//(2d+1) + 1

Fixed submission:
n,d = map(int, input().split())
ans = 0
if n % (2 * d + 1) == 0:
  ans = n // (2 * d + 1)
else:
  ans = n // (2 * d + 1) + 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
for i in range(n):
  temp = a.pop(i)
  max_num = max(a)
  print(max_num)
  a.insert(i, temp)
    

Fixed submission:
import copy
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))

copy_a = copy.deepcopy(a)
max_num = max(a)
a.remove(max_num)
second_num = max(a)

for i in range(n):
  if copy_a[i] >= max_num:
    print(second_num)
  else:
    print(max_num)
Buggy python submission (verdict: Runtime Error):
n,a,b = map(input().split())
ans = 0
if n * a > b:
  ans += b
else:
  ans += n * a
print(ans)

Fixed submission:
n,a,b = map(int,input().split())
ans = 0
if n * a > b:
  ans = b
else:
  ans = n * a
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
l,r = map(int, input().split())
L = l % 2019
R = r % 2019
ans = []

if R - L > 0:
  for i in range(l, r+1):
    for j in range(i+1, r+1):
      ans.append(i * j % 2019)
  print(min(ans))
else:
  print(0)

Fixed submission:
l,r = map(int, input().split())
L = l % 2019
R = r % 2019
ans = []

if r - l > 2019:
  print(0)
elif R - L > 0:
  for i in range(L, R):
    for j in range(i+1, R+1):
      ans.append(i * j % 2019)
  print(min(ans))
else:
  print(0)
Buggy python submission (verdict: Runtime Error):
s = input()
dic = {}
for i in s:
  if i in dic:
    dic[i] = 1
  else:
    dic[i] += 1
if len(dic) == 2:
  print('Yes')
else:
  print('No')

Fixed submission:
s = input()
dic = {}
for i in s:
  if i in dic:
    dic[i] += 1
  else:
    dic[i] = 1
if len(dic) == 2:
  print('Yes')
else:
  print('No')

Buggy python submission (verdict: Runtime Error):
s = input()
dic = {}
for i in s:
  if i in dic:
    dic[i] = 1
  else:
    dic[i] += 1

Fixed submission:
s = input()
dic = {}
for i in s:
  if i in dic:
    dic[i] += 1
  else:
    dic[i] = 1
if len(dic) == 2:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
s = [x for x in input()]
for _ in range(3):
  if s[i] == s[i+1]:
    print('Bat')
    break
  else:
    print('Good')



Fixed submission:
s = [x for x in input()]
ans = 'Good'
for i in range(3):
  if s[i] == s[i+1]:
    ans = 'Bad'
    break
print(ans)
Buggy python submission (verdict: Runtime Error):
n,l = map(int, input().split())
a = []
ans = 0
for i in range(1, n+1):
  a.append([l + i - 1, abs(l + i - 1)])
a = sorted(a, key = lambda x:x[1], reverse = True)
a.pop()
for _ in range(n-1):
  ans += a[0]
print(ans)



Fixed submission:
n,l = map(int, input().split())
a = []
ans = 0
for i in range(1, n+1):
  a.append([l + i - 1, abs(l + i - 1)])
a = sorted(a, key = lambda x:x[1], reverse = True)
a.pop()
for i in range(n-1):
  ans += a[i][0]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
a,b,c,d = map(int, input().split())
gcd = fractions.gcd(c,d)
lcm = c * d // gcd
num = [c,d,lcm]
l = b - a + 1
temp = []

for i in range(3):
  count = 0
  if l - num[i] >= 0:
    count += l // num[i]
    if l % num[i] != 0:
      if b % num[i] < (b - (l % num[i]) + 1) % num[i]:
        count += 1
  else:
    for j in range(a,b+1):
      if j % num[i] == 0:
        count += 1
  temp.append(count)

ans = l - (temp[0] + temp[1] - temp[2])
print(ans)

Fixed submission:
import fractions
a,b,c,d = map(int, input().split())
gcd = fractions.gcd(c,d)
lcm = c * d // gcd
num = [c,d,lcm]
l = b - a + 1
temp = []

for i in range(3):
  count = 0
  if l - num[i] >= 0:
    count += l // num[i]
    if l % num[i] != 0:
      if b % num[i] < (b - (l % num[i]) + 1) % num[i]:
        count += 1
  else:
    if b % num[i] < l:
        count += 1
  temp.append(count)

ans = l - (temp[0] + temp[1] - temp[2])
print(ans)

Buggy python submission (verdict: Runtime Error):
import fractions
a,b,c,d = map(int, input().split())
gcd = fractions.gcd(c,d)
lcm = c * d / gcd
num = [c,d,lcm]
l = b - a + 1
count = 0
temp = []

for i in range(3):
  if l - num[i] >= 0:
    count += (num[i] - 1) * (l // num[i]) + (l % num[i])
  else:
    for j in range(a,b+1):
      if j % c == 0:
        count += 1
  temp.append(count)

ans = l - (count[0] + count[1] - count[2])
print(ans)

Fixed submission:
import fractions
a,b,c,d = map(int, input().split())
gcd = fractions.gcd(c,d)
lcm = c * d // gcd
num = [c,d,lcm]
l = b - a + 1
temp = []

for i in range(3):
  count = 0
  if l - num[i] >= 0:
    count += l // num[i]
    if l % num[i] != 0:
      if b % num[i] < (b - (l % num[i]) + 1) % num[i]:
        count += 1
  else:
    if b % num[i] < l:
        count += 1
  temp.append(count)

ans = l - (temp[0] + temp[1] - temp[2])
print(ans)
Buggy python submission (verdict: Runtime Error):
p = list(map(int, input().split()))
print(p[0] + p[1] + [2] - max(p))


Fixed submission:
p = list(map(int, input().split()))
print(p[0] + p[1] + p[2] - max(p))