qyliang/CodeNanoFix huggingface dataset:
Buggy code:
import sys

N = int(sys.stdin.readline())
Hs = sys.stdin.readline().strip().split()
Hs = [int(h) for h in Hs]
curr_max = 0
count = 1
for i in range(len(Hs) - 1):
    if Hs[i + 1] <= Hs[i]:
        count += 1
    else:
        curr_max = max(curr_max, count)
        count = 1
    curr_max = max(curr_max, count - 1)

print(curr_max)


Fixed code:
import sys

N = int(sys.stdin.readline())
Hs = sys.stdin.readline().strip().split()
Hs = [int(h) for h in Hs]
curr_max = 0
count = 0 
for i in range(len(Hs) - 1):
    if Hs[i + 1] <= Hs[i]:
        count += 1
    else:
        curr_max = max(curr_max, count)
        count = 0
else:
    curr_max = max(curr_max, count)
print(curr_max)
Buggy code:
N = int(input())
H = list(map(int, input().split()))
count = 0
counts = []

for i in range(N-1):
    if H[i] >= H[i+1]:
        count += 1
    else:
        counts.append(count)
        count = 0

print(max(counts))

Fixed code:
N = int(input())
H = list(map(int, input().split()))
count = 0
counts = []

if N <= 1:
    counts.append(0)
else:
    for i in range(N-1):
        if H[i] >= H[i+1]:
            count += 1
        else:
            counts.append(count)
            count = 0
    else:
        counts.append(count)

print(max(counts))
Buggy code:
n=int(input())
hs=list(map(int,input().split()))
temp=0
ans=0

for i in range(n-1):
  if hs[i+1] >= hs[i]:
    temp+=1
    ans=max(ans,temp)
  else:
    temp=0
    
print(ans)

Fixed code:
n=int(input())
hs=list(map(int,input().split()))
temp=0
ans=0

for i in range(n-1):
  if hs[i+1] <= hs[i]:
    temp+=1
    ans=max(ans,temp)
  else:
    temp=0
    
print(ans)
Buggy code:
def func():
    N = int(input())
    H = list(map(int, input().split()))

    prev = H[0]
    count = 0
    mx = 0
    mxIdx = 0
    startIdx = 0
    for i in range(N-1):
        now = H[i+1]
        if prev >= now:
            count += 1
            if i == N - 2:
                if mx < count:
                    mx = count
                    mxIdx = i

        else:
            if mx < count:
                mx = count
                mxIdx = startIdx
            count = 0
            startIdx = i

        prev = now

    print(mxIdx)


if __name__ == '__main__':
    func()


Fixed code:
def func():
    N = int(input())
    H = list(map(int, input().split()))

    prev = H[0]
    count = 0
    mx = 0
    mxIdx = 0
    startIdx = 0
    for i in range(N-1):
        now = H[i+1]
        if prev >= now:
            count += 1
            if i == N - 2:
                if mx < count:
                    mx = count
                    mxIdx = i

        else:
            if mx < count:
                mx = count
                mxIdx = startIdx
            count = 0
            startIdx = i+1

        prev = now

    print(mx)


if __name__ == '__main__':
    func()
Buggy code:
n = int(input())
h = [int(i) for i in input().split()]
c = 1
max = 0
for i in range(n-1):
    if h[i] < h[i-1]:
        c+= 1 
    else:
        if max < c:
            max = c
        c = 1
print(max)        

Fixed code:
n = int(input())
h = [int(i) for i in input().split()]
c = 0
max = 0
for i in range(n-1):
    if h[i] >= h[i+1]:
        c+= 1 
    else:
        if max < c:
            max = c
        c = 0
if max < c:
    max = c
print(max)
Buggy code:
N = int(input())
H = list(map(lambda h: int(h), input().split(" ")))

lower = [0]
movable = 0
for i in range(len(H) - 1):
  if H[i] >= H[i + 1]:
    movable += 1
  else:
    lower.append(movable)
    movable = 0

print(max(lower))

Fixed code:
N = int(input())
H = list(map(lambda h: int(h), input().split(" ")))
 
lower = [0]
movable = 0
for i in range(len(H) - 1):
  if H[i] >= H[i + 1]:
    movable += 1
  else:
    lower.append(movable)
    movable = 0
else:
  lower.append(movable)

print(max(lower))
Buggy code:
n=int(input())
h=[map(int,input().split())]
dp=[0]*(n+1)
count=0
for i in range(1,n+1):
  if h[i-1]>=h[i]:
    dp[i]=dp[i-1]+1
print(max(dp))


Fixed code:
n = int(input())
h = list(map(int, input().split()))
dp = [0] * n
for i in range(1, n):
    if h[i-1] >= h[i]:
        dp[i] = dp[i-1] + 1
print(max(dp))
Buggy code:
N=int(input())
H=list(map(int,input().split()))
x=0
l=[]
for i in range(N-1):
    if H[i]>=H[i+1]:
        x+=1
    else:
        l.append(x)
        x=0
l.append(x)
print(l)

Fixed code:
N=int(input())
H=list(map(int,input().split()))
x=0
l=[]
for i in range(N-1):
    if H[i]>=H[i+1]:
        x+=1
    else:
        l.append(x)
        x=0
l.append(x)
print(max(l))
Buggy code:
N = int(input())
h = list(map(int,input().split()))
L = [0] * (N-1)

for i in range(N-2,-1,-1):
  if h[i] >= h[i+1]:
    L[i+1] = L[i] + 1
    
print(max(L))    

Fixed code:
N = int(input())
h =list(map(int,input().split()))
L = [0] * N

for i in range(N-2,-1,-1):
  if h[i] >= h[i+1]:
    L[i] = L[i+1] + 1
    
print(max(L))
Buggy code:
N = int(input())
H = [int(x) for x in input().split()]
x = 0
ans = 1

for i in range(1,len(H)):
    if H[i] <= H[i-1]:
        x += 1
        if x > ans:
            ans = x
    else:
        x = 0
print(ans)

Fixed code:
N = int(input())
H = [int(x) for x in input().split()]
x = 0
ans = 0

for i in range(1,len(H)):
    if H[i] <= H[i-1]:
        x += 1
        if x > ans:
            ans = x
    else:
        x = 0
print(ans)
Buggy code:
n = int(input())
h = list(map(int, input().split()))

ans = 0
c = 0

for j, i in zip(h, h[1:]):
    print(j, i)
    if j - i >= 0:
        c += 1 
    else:
        c = 0
    ans = max(ans, c)
print(ans)

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

ans = 0
c = 0

for j, i in zip(h, h[1:]):
    if j - i >= 0:
        c += 1 
    else:
        c = 0
    ans = max(ans, c)
print(ans)
Buggy code:
import re

N = int(input())
H = list(map(int, input().split()))

X = []

for n in range(N-1):
    if H[n] >= H[n+1]:
        X.append('T')
    else:
        X.append('F')

XX = ''.join(X)

T = re.findall('T*T', XX)

Y=[]
for y in T:
    Y.append(len(y))

print(max(Y))

Fixed code:
import re

N = int(input())
H = list(map(int, input().split()))
X = []

if N == 1:
    print('0')
else:
    for n in range(N-1):
        if H[n] >= H[n+1]:
            X.append('T')
        else:
            X.append('F')

    XX = ''.join(X)

    if XX.find('T') == -1:
        print('0')
    else:
        T = re.findall('T*T', XX)

        Y=[]
        for y in T:
            Y.append(len(y))

        print(max(Y))
Buggy code:
n = int(input())
h = list(map(input().split()))

count
max_count = 0
for i in range(n-1):
  if h[i]>=h[i+1]:
    count += 1
  else: count = 0
  
  if count > max_count: max_count = count
print(max_count)

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

count = 0
max_count = 0
for i in range(n-1):
  if h[i]>=h[i+1]:
    count += 1
  else: count = 0
  
  if count > max_count: max_count = count
print(max_count)
Buggy code:
#coding:utf-8
n = int(input())
h = list(map(int, input().split()))

ans = []
count = 0

for i in range(0, n-1):
    if h[i] >= h[i+1]:
        count += 1
    else:
        ans.append(count)
        count = 0

print(max(ans))

Fixed code:
# coding:utf-8
n = int(input())
h = list(map(int, input().split()))

ans = 0
tmp = 0

for i in range(0, n - 1):
    if h[i] >= h[i + 1]:
        tmp += 1
    else:
        ans = max(tmp, ans)
        tmp = 0

ans = max(tmp, ans)
print(ans)
Buggy code:
n = int(input())
h = list(map(int,input().split()))

count=0
ans=0
h.reverse()

print(h)
for i in range(n-1):
    if h[i]<=h[i+1]:
        count += 1
    else:
        count = 0
    
    ans = max(ans,count)
print(ans)


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

count=0
ans=0
h.reverse()


for i in range(n-1):
    if h[i]<=h[i+1]:
        count += 1
    else:
        count = 0
    
    ans = max(ans,count)
print(ans)
Buggy code:

N = int(input())
X = list(map(int, input().split()))

ans = 0
cnt = 0
cur = X[0]
for i in range(1, N):
    if cur >= X[i]:
        cnt += 1
    else:
        ans = max(ans, cnt + 1)
        cnt = 0
    cur = X[i]

print(ans)


Fixed code:

N = int(input())
X = list(map(int, input().split()))

ans = 0
cnt = 0
cur = X[0]
for i in range(1, N):
    if cur < X[i]:
        ans = max(ans, cnt)
        cnt = 0
    else:
        cnt += 1
    cur = X[i]

print(max(ans, cnt))
Buggy code:
N = int(input())
*H, = map(int, input().split())
sub, ans = 0, 0
for i in range(N-1):
    if H[i] > H[i+1]:
        sub += 1
    else:
        sub = 0
    ans = max(ans, sub)
print(ans)

Fixed code:
N = int(input())
*H, = map(int, input().split())
sub, ans = 0, 0
for i in range(N-1):
    if H[i] >= H[i+1]:
        sub += 1
    else:
        sub = 0
    ans = max(ans, sub)
print(ans)
Buggy code:
n = int(input())
heights = [int(h) for h in input().split()]

record = 0
current = heights[0]
cnt = 0
for h in heights[1:]:
    if current >= h:
        cnt += 1
        current = h
    else:
        record = cnt if cnt > record else record
        current = h
        cnt = 0
record = cnt if cnt > record else record

Fixed code:
n = int(input())
heights = [int(h) for h in input().split()]

record = 0
current = heights[0]
cnt = 0
for h in heights[1:]:
    if current >= h:
        cnt += 1
        current = h
    else:
        record = cnt if cnt > record else record
        current = h
        cnt = 0
record = cnt if cnt > record else record
print(record)
Buggy code:
N = int(input())

answer = (N-1)*N/2
print(answer)


Fixed code:
N = int(input())

answer = (N-1)*N//2
print(answer)
Buggy code:
n = int(input())


print((n - 1) * n // 2))

Fixed code:
n = int(input())
print(((n*(n+1))//2 - n))
Buggy code:

def main():
    n = int(input())
    print(n*(n-1)/2)


if __name__ == '__main__':
    main()


Fixed code:
def main():
    n = int(input())
    print(n*(n-1)//2)


if __name__ == '__main__':
    main()
Buggy code:
n = int(input())
if n % 2 == 0:
    sum = n/2
    sum = sum *(n-1)

else:
    sum = (n-1)/2
    sum = sum * n

print(sum)


Fixed code:
n = int(input())
if n % 2 == 0:
    sum = int(n/2)
    sum = sum *(n-1)

else:
    sum = int((n-1)/2)
    sum = sum * n

print(int(sum))
Buggy code:
N = int(input())
print(N * (N+1) /2)

Fixed code:
N = int(input())
print(((N-1)+1)*(N-1)//2)
Buggy code:
n=int(input())
print((n-1)*n/2)

Fixed code:
n = int(input())
n -= 1
print(n * (n + 1) // 2)
Buggy code:
N = int(input())
if N == 1:
    print("0")
else:
    print(N * (N - 1) / 2)


Fixed code:
N = int(input())
if N == 1:
    print("0")
else:
    print(N * (N - 1) // 2)
Buggy code:
N = int(input())
print(((N-1) * N) / 2)

Fixed code:
N = int(input())
nsum = N * (N-1) //2
print(nsum)
Buggy code:
n = int(input())
if n == 1:
  print(0)
else:
  print(n(n-1)//2)

Fixed code:
n = int(input())
if n == 1:
  print(0)
else:
  print(n*(n-1)//2)
Buggy code:
n = int(input())
print(int((n-1)*(n-2)//2))

Fixed code:
n = int(input())
a = (n - 1) * n // 2
print(int(a))
Buggy code:
n = int(input())
sum = n * (n - 1) / 2
print(sum)

Fixed code:
n = int(input())
sum = n * (n - 1) // 2
print(sum)
Buggy code:
# Problem D - ModSum

# input
N = int(input())

# initialization
ans = ((N - 1) * N) / 2

# output
print(ans)


Fixed code:
# Problem D - ModSum

# input
N = int(input())

# initialization
ans = ((N - 1) * N) // 2

# output
print(ans)
Buggy code:
N=int(input())
N-=1
print((N+1)*N/2)

Fixed code:
N=int(input())
print(int((N-1)*N//2))
Buggy code:
import math
N = int(input())
print(N * (N - 1) / 2)

Fixed code:

import math
N = int(input())
print(int(N * (N - 1) // 2))
Buggy code:
n = int(input())

print(((n-1)+1) /2 *(n-1))

Fixed code:
n = int(input())
print( int((n*(n-1)) // 2) )
Buggy code:
N = int(input())
print(N * (N-1) / 2)

Fixed code:
N = int(input())
 
ans = N * (N-1) // 2
print(int(ans))
Buggy code:
n = int(input())
print((n*(n-1))/2)


Fixed code:
n = int(input())

ans = n*(n-1) // 2
print(ans)
Buggy code:
a=int(input())
print(a*(a+1)//2)



Fixed code:
a=int(input())
print(a*(a+1)//2-a)
Buggy code:
n=int(input())
k=n*n/2-n/2
print(k)

Fixed code:
n=int(input())
k=(n*n-n)//2
print(round(k))
Buggy code:
N=int(input())
if N%2 == 0:
    print(round(N/2*(N-1)))
else:
    print(round((N-1)/2*N)))

Fixed code:
N=int(input())
#print(round(N*(N-1)/2))
if N%2 == 0:
    print(int(N/2)*(N-1))
else:
    print(int((N-1)/2)*N)
Buggy code:
n = int(input())
n -= 1
print(n * (n + 1) / 2)

Fixed code:
n = int(input())
print(int(n * (n - 1) // 2))
Buggy code:
N = int(input())
S = N*(N-1)/2
print(S)

Fixed code:
N = int(input())
print(N*(N-1)//2)
Buggy code:
n=int(input())
ans=n*(n-1)/2
print(ans)

Fixed code:
n=int(input())
ans=n*(n-1)//2

print(ans)
Buggy code:
n = int(input())

print((n - 1) * n / 2)

Fixed code:
n = int(input())

f = n*(n-1)//2
print(f)
Buggy code:
N = int(input())

print(N * (N - 1) / 2)

Fixed code:
N = int(input())
 
print(N * (N - 1) // 2)
Buggy code:
n = int(input())
n = n-1
print(n*(n+1)/2)

Fixed code:
n=int(input())
ans=n*(n+1)//2-n
print(ans)
Buggy code:
def main():
    n = int(input())
    ans = 0 if n % 2 == 0 else n / 2 + 1
    ans += (n - 1) * (n // 2)
    print(int(ans))

if __name__ == '__main__':
    main()

Fixed code:
def main():
    n = int(input())
    ans = 0
    ans += n * (n - 1) // 2
    print(int(ans))

if __name__ == '__main__':
    main()
Buggy code:
n = int(input())
print(n * (n + 1) // 2)

Fixed code:
n = int(input()) - 1
print(int(n*(n+1)//2))
Buggy code:
n = int(input())

ans = (n - 1) * (n) / 2

print(ans)

Fixed code:
n = int(input())

print((n-1)* n // 2)
Buggy code:
N=int(input())
print(N * (N+1) // 2)

Fixed code:
N = int(input())

print(N*(N+1)//2-N)
Buggy code:
N = int(input())
print(int((N-1)*N/2)-1)


Fixed code:
N = int(input())

ans = N * (N - 1) // 2
print(ans)
Buggy code:
i = int(input())
print(int(n*(n-1)/2))

Fixed code:
i = int(input())
print((i-1)*i//2)
Buggy code:
def main():
    n = int(input())
    print(n * (n - 1) / 2)


main()


Fixed code:
def main():
    n = int(input())
    print((n - 1) * n // 2)


main()
Buggy code:
n = int(input())

ans = n * (n-1) / 2
print(ans)

Fixed code:
n = int(input())

print(n*(n-1) // 2)
Buggy code:
S=int(input())
#print(sum([i for i in range(S)]))
s=S-1
"""
if s%2==0:
  ans=(1+s)*(s/2)
else:
  ans=(1+s)*int(s/2)+(int(s/2)+1)
"""
print(s*(s+1)/2)

Fixed code:
import math
N=int(input())
#print(sum([i for i in range(S)]))
"""
if s%2==0:
  ans=(1+s)*(s/2)
else:
  ans=(1+s)*int(s/2)+(int(s/2)+1)
"""
print(int(N*(N-1)//2))
Buggy code:
n = int(input())
print(n * (n - 1) / 2)


Fixed code:
n = int(input())

print(n*(n - 1)//2)
Buggy code:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    print((n-1) // 2 * n)

if __name__ == '__main__':
    main()


Fixed code:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    print((n-1) * n // 2)

if __name__ == '__main__':
    main()
Buggy code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.buffer.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

print((ri() * (ri() - 1)) // 2)

Fixed code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.buffer.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.buffer.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.buffer.readline().split()))

a = ri()
print((a * (a - 1)) // 2)
Buggy code:
N = int(input())
print((N * (N-1)) / 2)

Fixed code:
N = int(input())
N -= 1
print((N*(N+1))//2)
Buggy code:
n = int(input())
ans = n * (n + 1) / 2
print(ans - n)

Fixed code:
n=int(input())

ans=(n)*(n-1)//2
print(ans)
Buggy code:
n = int(input())
print((n-1)*n/2)


Fixed code:
n = int(input())

s = n* (n-1)//2
print(s)
Buggy code:
n = int(input().strip())
print(n * (n - 1) * 2)


Fixed code:
n = int(input().strip())
print(int(n * (n - 1) // 2))
Buggy code:
N = int(input())
N=N-1

if N == 0:
    print(1)
else:
    print(int(N * (N + 1) / 2))


Fixed code:
N=int(input())-1
if N%2==0:
	print(int(N/2)*(N+1))
else:
  	print((N)*int((N+1)/2))
Buggy code:
n = int(input())

print(n(n-1)//2)

Fixed code:
n=int(input())
print( (n*(n-1))//2 )
Buggy code:
N = int(input())

if N == 1:
    print(0)
elif N == 2:
    print(0)
else:
    print((N-1)*(N-2)//2)



Fixed code:
N = int(input())

if N == 1:
    print(0)
else:
    print((N)*(N-1)//2)
Buggy code:
a=int(input())

print(long((a - 1) * a / 2))

Fixed code:
a=int(input())

print(((a - 1) * a // 2))
Buggy code:
#n = int(input())
#L = list(map(int, input().split()))
import math
import sys
import fractions
N = int(input())
print(N*(N-1)/2)


Fixed code:
#n = int(input())
#L = list(map(int, input().split()))
import math
import sys
import fractions
N = int(input())
print(N*(N-1)//2)
Buggy code:
N = int(input())

print(N*((N-1)//2))

Fixed code:
N = int(input())

print((1 + (N-1)) * (N-1) // 2)
Buggy code:
n = int(input())
print((n-1)*n/2)

Fixed code:
n = int(input());

print(n*(n-1)//2);
Buggy code:
N=int(input())
if(N==1):
    print(0)
    exit()
if((N-1)%2==0):
    print((N-1)/2*(N))
else:
    print((N-2)/2*(N-1)+N-1)

Fixed code:
N=int(input())
if(N==1):
    print(0)
    exit()
if((N-1)%2==0):
    print(((N-1)*N//2))
else:
    print((N-2)*(N-1)//2+N-1)
Buggy code:
if __name__ == '__main__':
    n = int(input())
    t = (1 + (n - 1) * (n - 1)) / 2
    print(t)

Fixed code:
if __name__ == '__main__':
    n = int(input())
    t = (1 + n) * n // 2
    print(t - n)
Buggy code:
N = int(input())
print(N*(N-1) / 2)

Fixed code:
N = int(input())
print((N-1)*(1 + N-1) // 2)
Buggy code:
n = int(input())
ans=0
ans = (n-1)*(n)//2
print(ians)

Fixed code:
n = int(input())
ans=0
ans = (n-1)*(n)//2
print(ans)
Buggy code:
n=int(input())
n-=1

print((n+1)*n/2)

Fixed code:
n=int(input())
n-=1

print(((n+1)*n) // 2)
Buggy code:
N = int(input())

answer = N*(N-1)/2
print(answer)


Fixed code:
N = int(input())

print((N)*(N-1)//2)
Buggy code:
n = int(input())
d, m = divmod(n,2)
if m != 0
    print(n*d)

else:
    print(n*(d - 1) + d)

Fixed code:
n = int(input())
d,m = divmod(n,2)
if m != 0:
    print(n*d)

else:
    print(n*(d - 1) + d)
Buggy code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def solve(inp):
    N = int(inp.readline().strip())

    r = (N * (N - 1)) / 2
    return int(r)


def main():
    import sys
    result = solve(sys.stdin)
    if result:
        print(result)


if __name__ == '__main__':
    main()


Fixed code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def solve(inp):
    N = int(inp.readline().strip())

    r = (N * (N - 1)) // 2
    return int(r)


def main():
    import sys
    result = solve(sys.stdin)
    if result is not None and result != '':
        print(result)


if __name__ == '__main__':
    main()
Buggy code:
n = int(input())
if n % 2 == 0:
        print(((n-1)+1)*((n-1)//2) + ((n-1)/2+1))
else:
        print(((n-1)+1)*((n-1)/2))

Fixed code:

n = int(input())
if n % 2 == 0:
        print(int(((n-1)+1)*((n-1)//2) + ((n-1)//2+1)))
else:
        print(int(((n-1)+1)*((n-1)//2)))
Buggy code:
n = int(input())
print(((n-1)*n)/2)

Fixed code:
n = int(input())
print((n)*(n-1) // 2)
Buggy code:
s=input()
a=int(s)
b=0
if a==1:
  print(0)
else:
  b=((a-1)*a)/2
  print(b)

Fixed code:
s=input()
a=int(s)
b=0
if a==1:
  print(0)
else:
  b=((a-1)*a)//2
  print(b)
Buggy code:
n = int(input())

print(((1 + n - 1)*(n - 1)/2))

Fixed code:
n=int(input())
n-=1
print(n*(n+1)//2)
Buggy code:
n = int(input())
n -= 1

if n % 2 == 0:
    print(int((n+1)*n/2))
else:
    n -= 1
    print((int(n+1)*n/2 + n + 1))


Fixed code:
n =int(input())
if n%2 == 0:
    print(int(n/2)*(n-1))
else:
    print(n*int((n-1)/2))
Buggy code:
N = int(input())
N = N-1
print(N*(N+1)/2)

Fixed code:
N = int(input())
ans = (1+(N-1))*(N-1)//2
print(ans)
Buggy code:
n=int(input())

ans=n*(n-1)/2

print(ans)

Fixed code:
n = int(input())

ans  = (n*(n-1))//2

print(ans)
Buggy code:
n=int(input())
if n==1:
    print(0)
else:
    if n%2==1:
        print(n**2//2)
    else:
        print((n**2-n)//2)

Fixed code:
n=int(input())
if n==1:
    print(0)
else:
    if n%2==1:
        print(n*(n//2))
    else:
        print((n**2-n)//2)
Buggy code:
N=int(input())

print(N*(N-1)/2)

Fixed code:
N = int(input())

print (N*(N-1)//2)
Buggy code:
N=int(input())
print(N*(N-1)/2)


Fixed code:
N=int(input())
print((N*(N-1)//2))
Buggy code:
n = int(input())
print(n*(n-1)/2)


Fixed code:
n = int(input())
print((n*n-n)//2)
Buggy code:
N = int(input())

ans =  ( (N-1)//2 ) * (1 + (N-1))

print(int(ans))


Fixed code:
N = int(input())

ans =  (N*(N-1)) // 2
print(int(ans))
Buggy code:
N = int(input())

ans = (N-1) * N / 2
print(ans)

Fixed code:
N = int(input())
ans = (N*(N-1))//2
print(ans)
Buggy code:
n = int(input())
print(n*(n-1)/2)



Fixed code:
n = int(input())
print(int(n*(n-1)//2))
Buggy code:
n = int(input())
if n == 1:
  print(0)
if n == 2:
  print(1)
else:
  print(n * (n-1)//2)

Fixed code:
n = int(input())
if n == 1:
  print(0)
else:
  print( n*(n-1)//2)
Buggy code:
N = int(input())
print(int(N*(N-1)/2+1))

Fixed code:
N = int(input())

print ((N * (N - 1)) // 2)
Buggy code:
n = int(input())
mod_sum = n * (n - 1) / 2
print(mod_sum)


Fixed code:
n = int(input())
mod_sum = n * (n - 1) // 2
print(mod_sum)
Buggy code:
n = int(input())

res = n*(n+1)
res = res/2

print(res)

Fixed code:
n = int(input())
n = n-1
res = n*(n+1)
res = res//2

print(res)
Buggy code:
n = int(input())
ans = n(n-1) // 2    
print(ans)

Fixed code:
n = int(input())
ans = n * (n-1) // 2    
print(ans)
Buggy code:
import math
import queue

mod = 1e9+7

def swap(a,b):
    return (b,a)

def gcd(a,b):
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def divisors(a):
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def main():
    n = 1e9
    ans = n*((n+1)/2)-n
    print(int(ans))
    return

if __name__ == '__main__':
    main()

Fixed code:
import math
import queue

mod = 1e9+7

def swap(a,b):
    return (b,a)

def gcd(a,b):
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def divisors(a):
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def main():
    n = int(input())
    ans = n*(n+1)//2-n
    print(int(ans))
    return

if __name__ == '__main__':
    main()
Buggy code:
n = int(input())
 
if(n % 2 == 0):
  print((n / 2) * (n - 1))
else:
  print(((n-1) / 2) * n)

Fixed code:
n=int(input())
if n==1: print(0)
else: print(n*(n-1)//2)
Buggy code:
n = int(input())

print((n-1) * (n) / 2)

Fixed code:
n = int(input())

print(n * (n - 1) //2)
Buggy code:
N = int(input())

if(N%2==1):
    print(N*(N-1)/2)
else:
    print(N*(N/2-1)+N/2)


Fixed code:
N = int(input())

if(N%2==1):
    print(N*(N-1)//2)
else:
    print(N*(N//2-1)+N//2)
Buggy code:
n=int(input())
print(1/2(n)(n-1))

Fixed code:
n = int(input())
print(int((n-1)*(n)//2))
Buggy code:
N = int(input())
    print(int((N*(N-1))//2))

Fixed code:
N = int(input())
res = (N*(N-1))//2
print(res)
Buggy code:
n = int(input())

print((n*(n-1)/2))

Fixed code:
n = int(input()) - 1
print(n*(n+1)//2)
Buggy code:
N=int(input())
print((N-1)*N/2)

Fixed code:
N = int(input())
print( (N-1)*N //2 )
Buggy code:
n = int(input())
sum = n*(n-1)/2
print(sum)


Fixed code:
n = int(input())
print( n * (n - 1) // 2)
Buggy code:
import sys
import heapq


input = sys.stdin.readline
n = int(input())
result = n //2 * (n-1) 
print(result)

Fixed code:
import sys
import heapq


input = sys.stdin.readline
n = int(input())
result = n*(n-1)//2
print(result)
Buggy code:
N=int(input())

print((N-1)*N/2)

Fixed code:
N = int(input())
print((N*(N-1))//2)
Buggy code:
import math
N=int(input())
N=N*N-1
N=N/2
print(N)

Fixed code:
import math
N=int(input())
N=N*(N-1)
N=N//2
print(N)
Buggy code:
    n = int(input())
    count = (n-1)*n//2
    print(count)

Fixed code:
n = int(input())
count = (n-1)*n//2
print(count)