Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03089 (python)

Fixed submission:
N=int(input())
x=[0]
inp=input().split()
for k in range(N):
  x.append(int(inp[k]))
y=[]
OK=True
for k in range(N):
  ok=False
  for i in range(len(x)-1,0,-1):
    if x[i]==i:
      y.insert(0,i)
      del x[i]
      ok=True
      break
  if ok==False:
    print(-1)
    OK=False
    break
if OK==True:
  for k in range(len(y)):
    print(y[k])

Buggy submission (verdict: Runtime Error):
inp=input().split()
for k in range(N):
  x.append(int(inp[k]))
def rec(x,y):
  if len(x)==1:
    for k in range(len(y)):
      print(y[k])
    return y
  OK=False
  for i in range(len(x)-1,0,-1):
    if x[i]==i:
      del x[i]
      y.insert(0,i)
      rec(x,y)
      OK=True
      break
  if OK==False:
    print(-1)
    return -1
rec(x,[])

Buggy submission (verdict: Runtime Error):
N=int(input())
r=[0]
inp=input().split()
for k in range(N):
  r.append(int(inp[k]))
def rec(x,y,i,N):
    if len(x)==1:
        for k in range(len(y)):
            print(y[k])
        return(y)
    if i==N+1:
        if len(y)==0:
            print(-1)
            return -1
        else:
            m=y[0]
            del y[0]
            x.insert(m,m)
            rec(x,y,m+1,N)     
    if x[i]==i:
        x.pop(i)
        y.insert(0,i)
        rec(x,y,1,N)
        
    else:
        if x[i] < i:
            rec(x,y,i+1,N)
        else:
            if len(y)>0:
                m=y[0]
                del y[0]
                x.insert(m,m)
                rec(x,y,m+1,N)  
            else:
                print(-1)
                return -1
                
                
            
        
    
rec(r,[],1,N)

Buggy submission (verdict: Runtime Error):
N=int(input())
r=[0]
inp=input().split()
for k in range(N):
  r.append(int(inp[k]))
def rec(x,y,i,N):
    if len(x)==1:
        for k in range(len(y)):
            print(y[k])
        return(y)
    if i==N+1:
        if len(y)==0:
            print(-1)
            return -1
        else:
            m=y[0]
            del y[0]
            x.insert(m,m)
            rec(x,y,m+1,N)     
    if x[i]==i:
        x.pop(i)
        y.insert(0,i)
        rec(x,y,1,N)
        
    else:
        if x[i] < i:
            rec(x,y,i+1,N)
        else:
            if len(y)>0:
                m=y[0]
                del y[0]
                x.insert(m,m)
                rec(x,y,m+1,N)  
            else:
                print(-1)
                return -1
                
                
            
        
            
        
    
rec(r,[],1,3)
Problem p02765 (python)

Fixed submission:
def main():
    K, R = map(int, input().split())

    if K >=10:
        print(R)
    else:
        print(R + 100*(10-K))

if __name__ =='__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math
def main():
    N, K = map(int, input().split())
    if K ==1:
        print(N+1)
    elif N % K == 0:
        print(math.ceil(math.log(N,K))+1)
    else:
        print(math.ceil(math.log(N,K)))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math
def main():
    N, K = map(int, input().split())
    if N % K == 0:
        print(math.ceil(math.log(N,K))+1)
    else:
        print(math.ceil(math.log(N,K)))


if __name__ == '__main__':
    main()
Problem p02765 (python)

Fixed submission:
N, R = map(int,input().split())

if N >= 10:
  print(R)
else:
  print( R+100*(10-N) )

Buggy submission (verdict: Runtime Error):
N = int(input())
x = list(map(int, input().split()))
 
n = len(x)
 
sum_a = 0
sum_b = 0
 
for xi in x:
  sum_a += xi * xi
  sum_b += xi
  
ans = sum_a - (sum_b*sum_b)/n
min_ans = 10**9
if ans < min_ans:
    ans = min_ans
 
print(int(ans+0.5))
Problem p02767 (python)

Fixed submission:
N = int(input())
x = list(map(int, input().split()))
 
n = len(x)
 
sum_a = 0
sum_b = 0
 
for xi in x:
  sum_a += (xi*xi)
  sum_b += xi

p = int(sum_b/n+0.5)
ans = sum_a - 2*sum_b*p+n*p*p

min_ans = 10**9
if ans > min_ans:
    ans = min_ans
print(int(ans))

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

sum_a = 0
sum_b = 0

for xi in x:
  sum_a += xi * xi
  sum_b += xi
  
ans = sum_a - (sum_b*sum_b)/n
min_ans = 10**9
if ans < min_ans
    ans = min_ans

print(int(ans+0.5))

Buggy submission (verdict: Runtime Error):
N = int(input())
X = list(map(int, input().split()))

n = len(X)

for xi in x:
  sum_a += xi * xi
  sum_b += xi
  
ans = sum_a - (sum_b*sum_b)/n
print(ans)
Problem p02784 (python)

Fixed submission:
H,N = map(int,input().split())
A = map(int, input().split())

sum=0
for Ai in A:
  sum += Ai

if sum >= H:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
,N = map(int,input().split())
Ai = map(int, input().split())
 
if sum(A) >= H:
  print('Yes')
else:
  print('No')
Problem p03274 (python)

Fixed submission:
# coding: utf-8

def getMin(X, K):
    minVal = float('inf')
    for l in range(len(X)-K+1):        
        minVal = min(minVal, abs(X[l]) + abs(X[K + l - 1] - X[l]))
        minVal = min(minVal, abs(X[K + l - 1]) + abs(X[l] - X[K + l - 1]))
    return minVal

if __name__ == "__main__":
    N, K = map(int, input().split())
    X = list(map(int, input().split()))
    print(getMin(X, K))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
import sys

def getMin(X, K):
    minVal = sys.maxsize
    if K == 1:
        return X[0]
    
    for l in range(0, len(X)-K):
        minVal = min(minVal, abs(X[l]) + abs(X[K + l - 1] - X[l]))
            
    return minVal

def solve(X, K):
    ans = min(getMin(X, K), getMin(X[::-1], K))
    return ans

if __name__ == "__main__":
    N, K = map(int, input().split())
    X = map(int, input().split())
    print(solve(X, K))
Problem p03310 (python)

Fixed submission:
# coding: utf-8

from itertools import accumulate

def getAccumulate(A):
    return list(accumulate(A))

def solve(A):
    accum = getAccumulate(A)
    l_index = 0
    r_index = 2
    accum_max = accum[-1]

    diff = accum_max
    for i in range(1, len(A)-2):
        while accum[i] > accum[l_index] + accum[l_index + 1]:
            l_index += 1
        while accum_max + accum[i] > accum[r_index] + accum[r_index + 1]:
            r_index += 1
        
        left = accum[l_index]
        center = accum[i] - accum[l_index]
        right = accum[r_index] - accum[i]
        last = accum_max - accum[r_index]
        diff = min(diff, max(left, center, right, last) - min(left, center, right, last))
        
    return diff

if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    print(solve(A))

Buggy submission (verdict: Runtime Error):
# coding: utf-8

from itertools import accumulate

def getAccumulate(A):
    return list(accumulate(A))

def solve(A):
    accum = getAccumulate(A)
    l_index = 0
    r_index = 2
    accum_max = accum[-1]

    diff = accum_max
    for i in range(1, len(A)-2):
        while accum[i] > accum[l_index] + accum[l_index + 1]:
            l_index += 1
        while accum_max + accum[i] > accum[r_index] + accum[r_index + 1]:
            r_index += 1
        
        print(i)
        print(accum)
        left = accum[l_index]
        center = accum[i] - accum[l_index]
        right = accum[r_index] - accum[i]
        last = accum_max - accum[r_index]
        print(accum[l_index], accum[i], accum[r_index], accum[-1])
        diff = min(diff, max(left, center, right, last) - min(left, center, right, last))
        
    return diff

if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
	print(solve(A))
Problem p02767 (python)

Fixed submission:
N = int(input())
L = [int(i) for i in input().split()]
M = max(L)
A = min(L)
Z_L = list()
for i in range(A, M + 1):
  ZZ = 0
  for j in range(N):
    Z =  pow(L[j] - i, 2)
    ZZ += Z
  Z_L.append(ZZ)
print(min(Z_L))

Buggy submission (verdict: Runtime Error):
N = int(input())
L = [int(i) for i in input().split()]
M = max(L)
A = min(L)
Z_L = list()
for i in range(A, M):
  ZZ = 0
  for j in range(N):
    Z =  pow(L[j] - i, 2)
    ZZ += Z
  Z_L.append(ZZ)
print(min(Z_L))

Buggy submission (verdict: Runtime Error):
N = int(input())
L = [int(i) for i in input().split()]
M = max(L)
Z_L = list()
for i in range(1, M):
  ZZ = 0
  for j in range(N):
    Z =  pow(L[j] - i, 2)
    ZZ += Z
  Z_L.append(ZZ)
print(min(Z_L))
Problem p02786 (python)

Fixed submission:
def calc(a):
  if a > 1:
    return 2 * calc(a // 2) + 1
  else:
    return 1

a = int(input())
i = 0
print(calc(a))

Buggy submission (verdict: Runtime Error):
import math

H, N  = map(int, input().split())
use_mp = 0
use_mp_list = list()
mag = list()
for i in range(N):
  temp = [int(j) for j in input().split()]
  mag.append([temp[0] / temp[1], temp[0], temp[1]])			#(ap, mp, dpm)
mag.sort(reverse=True)

for i in range(N):
  if H == 0:
    break
  t = H // mag[i][1]
  if t > 0:
    H = H - mag[i][1] * t
    use_mp += mag[i][2] * t
  if H == 0:
    abc = 0
  else:
    abc = (mag[i][2] * math.ceil(H / mag[i][1]))
  #print(mag)
  use_mp_list.append(use_mp + abc)
print(min(use_mp_list))

Buggy submission (verdict: Runtime Error):
import math

H, N  = map(int, input().split())
use_mp = 0
use_mp_list = list()
mag = list()
for i in range(N):
  temp = [int(j) for j in input().split()]
  mag.append([temp[0] / temp[1], temp[0], temp[1]])			#(ap, mp, dpm)
mag.sort(reverse=True)

for i in range(N):
  if H == 0:
    break
  t = H // mag[i][1]
  if t > 0:
    H = H - mag[i][1] * t
    use_mp += mag[i][2] * t
  if H == 0:
    abc = 0
  else:
    abc = (mag[i][2] * math.ceil(H / mag[i][1]))
  #print(mag)
  print(use_mp + abc, mag[i][1], mag[i][2], H, use_mp)
  use_mp_list.append(use_mp + abc)
print(min(use_mp_list))
Problem p02765 (python)

Fixed submission:
time,rate = map(int,input().split())
ans = 0
if time >= 10:
  ans = rate
else:
  ans = rate + 100*(10 - time)
print(ans)

Buggy submission (verdict: Runtime Error):
time,rate = map(int,input().split())
ans = 0
if time >= 10:
  ans = rate
else:
  ans = rate - 100*(10 − time)
print(ans)

Buggy submission (verdict: Runtime Error):
time,rate = map(int,input().split())
ans = 0
if time >= 10:
  ans = r
else:
  ans = r - 100*(10 − time)
print(ans)
Problem p02767 (python)

Fixed submission:
import sys
l = sys.stdin.readline().strip()
N = int(l)
l = sys.stdin.readline().strip()
nums = map(int, l.split())
nums = sorted(nums)
start = nums[0]
end = nums[-1] + 1
mi = float("INF")
def compute_dist(p):
  dist = 0
  for n in nums:
    dist += (n-p) ** 2
  return dist
for i in range(start, end):
  d = compute_dist(i)
  if d < mi:
    mi = d
print(mi)

Buggy submission (verdict: Runtime Error):
import sys
l = sys.stdin.readline().strip()
N = int(l)
l = sys.stdin.readline().strip()
nums = map(int, l.split())
a = sum(nums) / len(nums)
a1 = int(a)
a2 = int(a) + 1
def count(p):
    d = 0
    for n in nums:
        d += (n-p)**2
    return d
print(min(count(a1), count(a2)))
Problem p02768 (python)

Fixed submission:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from functools import reduce
mod = 10**9+7

n, a, b = map(int, input().split())


def nCk(n, k):
    numer = reduce(lambda x, y: (x * y) % mod, range(n, n - k, -1))
    denom = reduce(lambda x, y: (x * y) % mod, range(1, k + 1))
    return numer * pow(denom, mod - 2, mod) % mod


ans = pow(2, n, mod) - nCk(n, a) - nCk(n, b) - 1
ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from functools import reduce
mod = 10**9+7


def nCk(n, k):
    # c = reduce(lambda x, y: x*y % mod, range(n, n-k, -1))
    # m = reduce(lambda x, y: x*y % mod, range(1, k+1))
    c = reduce(lambda x, y: x*y % mod, range(n, n-k+1, -1))
    m = reduce(lambda x, y: x*y % mod, range(1, k))
    return c*pow(m, mod-2, mod) % mod


n, a, b = map(int, input().split())

ans = pow(2, n, mod) - nCk(n, a) - nCk(n, b) - 1
ans %= mod
print(ans)
Problem p02923 (python)

Fixed submission:
# -*- coding: utf-8 -*-

int(input())  # Skip
lst = list(map(int, input().split()))

lst_length = len(lst)
idx = max_distance = 0

while True:
    distance = 0
    current_height = lst[idx]
    for i in range(idx + 1, lst_length):
        idx = i
        if current_height >= lst[idx]:
            current_height = lst[idx]
            distance += 1
        else:
            break

        if max_distance < distance:
            max_distance = distance

    if idx == (lst_length - 1):
        if max_distance < distance:
            max_distance = distance
        break

print(max_distance)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

N, Y = map(int, input().split())

for i in range(N + 1):
    for j in range(N - i + 1):
        if i * 10000 + j * 5000 + (N - i - j) * 1000 == Y:
            print('{} {} {}'.format(i, j, N - i - j))
            exit()
print('-1 -1 -1')
Problem p02947 (python)

Fixed submission:
ss = []
N = int(input())
for n in range(N):
    s = sorted(input())
    ss.append(s)

ss = sorted(ss)

total = 0
count = 0
for n in range(N):
    if n==0:
        continue
    # print("ss["+str(n-1)+"]="+str(ss[n-1]))
    # print("ss["+str(n)+"]="+str(ss[n]))
    if ss[n-1]==ss[n]:
        count += 1
    else:
        total += int(count*(count+1)/2)
        count = 0
    # print("===")
total += int(count*(count+1)/2)
count = 0

print(int(total))

Buggy submission (verdict: Runtime Error):
count = 0
scounts = []
N = int(input())
for n in range(N):
    s = sorted(input())
    found = False
    index = -1
    for i in range(len(scounts)):
        if scounts[i][0] == s:
            found = True
            count += scounts[i][1]
            scounts[i][1] += 1
            break
        elif scounts[i][0] > s:
            index = i
            break
        else: # scounts[i][0] > s:
			pass

    print("index="+str(index))
    if not found:
        if index<0:
            scounts.append([s,1])
        else:
            scounts.insert(index, [s, 1])

        print(str(s))
        print("DONE: "+str(scounts))
    print("===")
print(count)
Problem p02909 (python)

Fixed submission:
weather = ["Sunny", "Cloudy", "Rainy", "Sunny"]
s = input()
for c, i in enumerate(weather):
    if i == s:
        print(weather[c+1])
        break

Buggy submission (verdict: Runtime Error):
weather = ["Sunny", "Cloudy", "Rainy", "Sunny"]
s = input()
for c, i in weather:
    if i == s:
        print(weather[c+1])
        break

Buggy submission (verdict: Runtime Error):
weat = ['Sunny', 'Cloudy', 'Rainy', 'Sunny']
for c in weat:
  if c == S:
    print(weat[weat.index(c)+1])
    break
Problem p02910 (python)

Fixed submission:
import re
s = input()
odd = s[::2]
eve = s[1::2]
odd_re = re.compile(r"^[RUD]*$")
eve_re = re.compile(r"^[LUD]*$")
if odd_re.findall(odd) != [] and eve_re.findall(eve) != []:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import re
s = input()
odd = s[::2]
eve = s[1::2]
odd_re = re.compile(^[RUD]*$)
eve_re = re.compile(^[LUD]*$)
if odd_re.findall(odd) != [] and eve_re.findall(eve) != []:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import re
s = input()
odd = s[::2]
eve = s[1::2]
odd_re = re.compile{^[RUD]*$}
eve_re = re.compile{^[LUD]*$}
if odd_re.findall(odd) != [] and eve_re.findall(eve) != []:
    print("Yes")
else:
    print("No")
Problem p02999 (python)

Fixed submission:
list = input().split(" ")
X = list[0]
A = list[1]
if X < A:
  print(0)
else:
  print(10)

Buggy submission (verdict: Runtime Error):
X =input()
A =input()
if X < A:
  print(0)
else:
  print(10)
Problem p02765 (python)

Fixed submission:
import sys

def main(lines):
  n, r = map(int,lines[0].split())

  if n >= 10:
    print(r)
  else:
    print(r + 100*(10-n))
  return
    
if __name__ == '__main__':
    lines = []
    for l in sys.stdin:
        lines.append(l.rstrip('\r\n'))
    main(lines)

Buggy submission (verdict: Runtime Error):
import sys

def main(lines):
  n, r = lines[0].split()
    if n >= 10:
      print(r)
    else:
      print(r + 100*(10-n))
    return
    
if __name__ == '__main__':
    lines = []
    for l in sys.stdin:
        lines.append(l.rstrip('\r\n'))
    main(lines)

Buggy submission (verdict: Runtime Error):
import sys

def main(lines):
	n, r = lines[0].split()
    if n >= 10:
      print(r)
    else:
      print(r + 100*(10-n))
    return
    
if __name__ == '__main__':
    lines = []
    for l in sys.stdin:
        lines.append(l.rstrip('\r\n'))
    main(lines)

Buggy submission (verdict: Runtime Error):
import sys

def main(lines):
	n, r = lines[0].split()
    if n >= 10:
      print(r)
    else:
      print(n + 100*(10-n))
    return
    
if __name__ == '__main__':
    lines = []
    for l in sys.stdin:
        lines.append(l.rstrip('\r\n'))
    main(lines)
Problem p03455 (python)

Fixed submission:
a, b = map(int, input().split())
c = a*b
if c % 2:
    print("Odd")
else:
    print("Even")

Buggy submission (verdict: Runtime Error):
a,b = map(int, input().split())
c = a*b
if c % 2 = 0
    print("Even")
else
    print("Odd")

Buggy submission (verdict: Runtime Error):
a,b = map(int, input())
c = a*b
if c%2 = 0,
    print("Even")
else print("Odd")
Problem p02765 (python)

Fixed submission:
n, r = map(int, input().split())
if n >= 10:
  print(r)
else:
  print(r + 1000 - 100*n)

Buggy submission (verdict: Runtime Error):
n, r = map(int, input().split())
if n >= 10:
  print(r)
 else:
  print(r + 1000 - 100*n)
Problem p02885 (python)

Fixed submission:
a, b, = map(int, input().split())
print(0 if 2*b >= a else a - 2*b)

Buggy submission (verdict: Runtime Error):
import heapq

n, m, l = map(int, input().split())
v = [[] for i in range(n)]
for i in range(m):
    a, b, c, = map(int, input().split())
    a, b, = a-1, b-1
    if c > l:
        continue
    v[a].append((c, b))
    v[b].append((c, a))


def dijkstra(home):
    visited = [False for i in range(n)]
    visited[home] = -1
    queue = []
    for edge in v[home]:
        heapq.heappush(queue, edge)


    while queue:
        value, x = heapq.heappop(queue)
        if visited[x]:
            continue
        visited[x] = value
        for new_value, new_x in v[x]:
            if not visited[new_x]:
                heapq.heappush(queue, new_value+value)

    return visited


def dijkstra2(home):
    visited = [None for _ in range(n)]
    visited[home] = 0
    queue = []
    for fuel_needed, x in v[home]:
        heapq.heappush(queue, (0, fuel_needed, x))


    while queue:
        tanked, fuel_needed, x = heapq.heappop(queue)
        fuel = l-fuel_needed
        if visited[x] is not None:
            continue
        visited[x] = tanked
        for child_value, child_x in v[x]:
            if visited[child_x] is None:
                if child_value > fuel:
                    heapq.heappush(queue, (tanked+1, child_value, child_x))
                else:
                    heapq.heappush(queue, (tanked, fuel_needed+child_value, child_x))

    return visited






visited_collection = [None for _ in range(n)]



q = int(input())
queries = []
for i in range(q):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    if visited_collection[a]:
        print(visited_collection[a][b] if visited_collection[a][b] is not None else -1)
    elif visited_collection[b]:
        print(visited_collection[b][a] if visited_collection[b][a] is not None else -1)
    else:
        visited_collection[a] = dijkstra2(a)
        print(visited_collection[a][b] if visited_collection[a][b] is not None else -1)

    # queries.append((a, b))
Problem p02888 (python)

Fixed submission:
n = int(input())
v = list(sorted(map(int, input().split())))
v.append(2000)
total = n*(n-1)*(n-2) / 6



def bs(left, s):
    right = n+1
    while left < right-1:
        m = (right+left)//2

        if v[m]>=s:
            right = m
        else:
            left = m
    return left+1






for i, x in enumerate(v[:-2]):
    for j, y in enumerate(v[i+1:-1]):
        k = bs(j+1, y+x)
        total -= (n-k)

print(int(total))

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

counts = {}
x = v[0]
c = 0
for i in v:
    if i != x:
        counts[x] = c
        x = i
        c = 0
    c += 1
counts[x] = c

v1 = list(counts)

sums = [0]
for i in range(1, 1005):
    try:
        sums.append(v1.index(i))
    except ValueError:
        sums.append(sums[-1])


total = 0
for i, x in enumerate(v1[:n-2]):
    if x == 1:
        continue
    for j, y in enumerate(v1[i+1:n-1]):
        total += (sums[min(1004, x+y-1)] - sums[y])



for i, c in counts.items():
    if c >= 2:
        total += (sums[min(1004, 2*i-1)] - sums[c])





# v3
total += sum(True if c >= 3 else False for c in counts.values())


print(total)

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

counts = {}
x = v[0]
c = 0
for i in v:
    if i != x:
        counts[x] = c
        x = i
        c = 0
    c += 1
counts[x] = c

v1 = list(counts)

sums = [0]
for i in range(1, 1005):
    try:
        sums.append(v1.index(i))
    except ValueError:
        sums.append(sums[-1])


total = 0
for i, x in enumerate(v[:n-2]):
    if x == 1:
        continue
    for j, y in enumerate(v[i+1:n-1]):
        total += (sums[min(1004, x+y-1)] - sums[y])



for i, c in counts.items():
    if c >= 2:
        total += (sums[min(1004, 2*i-1)] - sums[c])





# v3
total += sum(True if c >= 3 else False for c in counts.values())


print(total)

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

counts = {}
x = v[0]
c = 0
for i in v:
    if i != x:
        counts[x] = c
        x = i
        c = 0
    c += 1
counts[x] = c

v1 = list(counts)

sums = [0]
for i in range(1, 1001):
    try:
        sums.append(v1.index(i))
    except ValueError:
        sums.append(sums[-1])


total = 0
for i, x in enumerate(v[:n-2]):
    if x == 1:
        continue
    for j, y in enumerate(v[i+1:n-1]):
        total += (sums[min(1000, x+y-1)] - sums[y])



for i, c in counts.items():
    if c >= 2:
        total += (sums[min(1000, 2*i-1)] - sums[c])





# v3
total += sum(True if c >= 3 else False for c in counts.values())


print(total)
Problem p03062 (python)

Fixed submission:
x = int(input())
y = list(map(int, input().split(" ")))

for i in range(x - 1):
  if y[i] < 0:
    y[i] *=-1
    y[i + 1] *=-1

if y[-1] < 0 and abs(min(y[0:-1])) < abs(y[-1]) :
  y[-1] *= -1
  y[y.index(min(y[0:-1]))] *= -1

print(sum(y))

Buggy submission (verdict: Runtime Error):
x = int(input())
y = list(map(int, input().split(" ")))

for i in range(x - 1):
  if y[i] < 0:
    y[i] *=-1
    y[i + 1] *=-1

if y[-1] < 0 and abs(min(y[0:-2])) < abs(y[-1]) :
  y[-1] *= -1
  y[y.index(min(y[0:-2]))] *= -1

print(sum(y))

Buggy submission (verdict: Runtime Error):
x = int(input())
y = list(map(int, input().split(" ")))

for i in range(x - 1):
  if y[i] < 0:
    y[i] *=-1
    y[i + 1] *=-1

if y[-1] < 0:
  y[-1] *= -1
  y[y.index(min(y[0:-2]))] *= -1
  
print(sum(y))
Problem p03231 (python)

Fixed submission:
import fractions

[n, m] = list(map(int, input().split()))
s = input()
t = input()

flag = False
gcd = fractions.gcd(n, m)
lcm = n * m // gcd
if s[0] == t[0]:
    if gcd == 1:
        flag = True
    else:
        if s[::lcm//len(t)] == t[::lcm//len(s)]:
            flag = True
if flag:
    print(lcm)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
import math

[n, m] = list(map(int, input().split()))
s = input()
t = input()

flag = False
gcd = math.gcd(n, m)
lcm = n * m // gcd
if s[0] == t[0]:
    if gcd == 1:
        flag = True
    else:
        if s[::lcm//len(t)] == t[::lcm//len(s)]:
            flag = True
if flag:
    print(lcm)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
import math

[n, m] = list(map(int, input().split()))
s = input()
t = input()

flag = False
gcd = math.gcd(n, m)
lcm = n * m // gcd
if s[0] == t[0]:
    if gcd == 1:
        flag = True
    else:
        if s[::lcm//len(t)] == t[::lcm//len(s)]:
            flag = True
if flag:
    print(lcm)
else:
    print(-1)