Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

N, W = map(int, input().split())
wv = [list(map(int, input().split())) for i in range(N)]

value = [[-1 for j in range(W + 1)] for i in range(N + 1)]

value[0] = [0 for j in range(W + 1)]
for i in range(1, N + 1):
    for j in range(W + 1):
        w, v = wv[i-1]
        if j >= w:
            value[i][j] = max(value[i-1][j], value[i-1][j-w] + v)
        else:
            value[i][j] = value[i-1][j]

ans = max(value[N])
print(ans)


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

import sys
input = sys.stdin.readline

N, W = map(int, input().split())
wv = [list(map(int, input().split())) for i in range(N)]

value = [[-1 for j in range(W + 1)] for i in range(N + 1)]

value[0] = [0 for j in range(W + 1)]
for i in range(1, N + 1):
    for j in range(W + 1):
        w, v = wv[i-1]
        if j >= w:
            value[i][j] = max(value[i-1][j], value[i-1][j-w] + v)
        else:
            value[i][j] = value[i-1][j]

ans = max(value[N])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline

N, W = map(int, input().split())
wv = [list(map(int, input().split())) for i in range(N)]

value = [[-1 for j in range(W + 1)] for i in range(N + 1)]

value[0] = [0 for j in range(W + 1)]
for i in range(1, N + 1):
    for j in range(W + 1):
        w, v = wv[i-1]
        if j >= w:
            value[i][j] = max(value[i-1][j], value[i-1][j-w] + v)
        else:
            value[i][j] = value[i-1][j]

ans = max(max(value))
print(ans)


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

import sys
input = sys.stdin.readline

N, W = map(int, input().split())
wv = [list(map(int, input().split())) for i in range(N)]

value = [[-1 for j in range(W + 1)] for i in range(N + 1)]

value[0] = [0 for j in range(W + 1)]
for i in range(1, N + 1):
    for j in range(W + 1):
        w, v = wv[i-1]
        if j >= w:
            value[i][j] = max(value[i-1][j], value[i-1][j-w] + v)
        else:
            value[i][j] = value[i-1][j]

ans = max(value[N])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

N, W = map(int, input().split())
wv = [list(map(int, input().split())) for i in range(N)]

value = [[-1 for j in range(W + 1)] for i in range(N + 1)]

value[0] = [0 for j in range(W + 1)]
for i in range(1, N + 1):
    for j in range(W + 1):
        w, v = wv[i-1]
        if j >= w:
            value[i][j] = max(value[i-1][j], value[i-1][j-w] + v)
        else:
            value[i][j] = value[i-1][j]

ans = max(max(value))
print(ans)


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

import sys
input = sys.stdin.readline

N, W = map(int, input().split())
wv = [list(map(int, input().split())) for i in range(N)]

value = [[-1 for j in range(W + 1)] for i in range(N + 1)]

value[0] = [0 for j in range(W + 1)]
for i in range(1, N + 1):
    for j in range(W + 1):
        w, v = wv[i-1]
        if j >= w:
            value[i][j] = max(value[i-1][j], value[i-1][j-w] + v)
        else:
            value[i][j] = value[i-1][j]

ans = max(value[N])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

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

ans = 0
while 1:
    new_a = [a // 2 if a % 2 == 0 else -1 for a in A]
    if -1 in new_a:
        break
    ans += 1

print(ans)


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

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

ans = 0
new_a = A.copy()
while 1:
    new_a = [a // 2 if a % 2 == 0 else -1 for a in new_a]
    if -1 in new_a:
        print(ans)
        exit()
    ans += 1

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

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

ans = 0
new_a = A.copy()
while 1:
    new_a = [a // 2 if a % 2 == 0 else -1 for a in new_a]
    if -1 in new_a:
        print(ans)
        exit()
    ans += 1

print(ans)


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

S = input()
dream_set = {"dream", "dreamer", "erase", "eraser"}
# 感動的計画法やるぞ

while len(S) > 0:
    if S.endswith("dream") or S.endswith("erase"):
        S = S[:-5]
    elif S.endswith("eraser"):
        S = S[:-6]
    elif S.endswith("dreamer"):
        S = S[:-7]
    else:
        print("NO")
        exit()

print("YES")
Buggy python submission (verdict: Runtime Error):
n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
 
l = []
for i in range(min(n, m)):
  l.append(min(a[i], b[i]))
  l.append(max(a[i], b[i]))

for i in range(min(n, m), max(n, m)):
  if n > m:
    l.append(a[i])
  else:
    l.append(b[i])

total = 0
cnt = 0
for i in range(n+m):
  if total+l[i] > k:
    break
  total += l[i]
  cnt += 1
print(cnt)

Fixed submission:
s = int(input())
print(s + s**2 + s**3)
Buggy python submission (verdict: Runtime Error):
n = int(input())
data = [26 ** x for x in range(1, 11)]

d = 0
r = 0
for i in range(len(data)):
    d += data[i]
    if n <= d:
        r = i+1
        break

kurai = [26 **  x for x in range(r)][::-1]
ans = [0] * r
for i in range(r):
    ans[i]= n // kurai[i]
    n %= kurai[i]

alpha = [chr(i) for i in range(97, 97+26)] 
ans = [alpha[a - 1] for a in ans]
print("".join(ans))

Fixed submission:
n = int(input())
data = [26 ** x for x in range(1, 12)]

d = 0
r = 0
for i in range(len(data)):
    if n <= d + data[i]:
        r = i+1
        n -= (d + 1)
        break
    
    d += data[i]

kurai = [26 **  x for x in range(r)][::-1]
ans = [0] * r
for i in range(r):
    ans[i]= min(n // kurai[i], 25)
    n -= kurai[i] * ans[i]

alpha = [chr(i) for i in range(97, 97+26)] 
ans = [alpha[a] for a in ans]
print("".join(ans))
Buggy python submission (verdict: Runtime Error):
x, n = list(map(int, input().split()))

if n != 0:
  p = list(map(int, input().split()))
  lists = []
  for i in range(1, 101):
    if i in p:
      continue
    lists.append(i)

  ans = lists[0]
  dist = abs(lists[0]-x)
  for i in range(len(lists)):
    if dist > abs(lists[i]-x):
      ans = lists[i]
      dist = abs(lists[i]-x)
  print(ans)
  
else:
  print(x)

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

if n != 0:
  p = list(map(int, input().split()))
  lists = []
  for i in range(0, 102):
    if i in p:
      continue
    lists.append(i)

  ans = lists[0]
  mins = abs(lists[0] - x)
  for i in range(1, len(lists)):
    dist = abs(lists[i]-x)
    if mins > dist:
      ans = lists[i]
      mins = dist
      
  print(ans)
else:
  print(x)
Buggy python submission (verdict: Runtime Error):
t = input()

l = [_ for i in range(len(t))]
for i in range(0, len(t)):
    if t[i] =="?":
        l[i] = "D"
    
    else:
        l[i] = t[i]

print("".join(l))

Fixed submission:
t = input()

l = ["" for i in range(len(t))]
for i in range(0, len(t)):
    if t[i] =="?":
        l[i] = "D"
    
    else:
        l[i] = t[i]

print("".join(l))

Buggy python submission (verdict: Runtime Error):
t = input()

l = [_ for i in range(len(t))]
r = [] * (len(t))
print(l)
for i in range(0, len(t)):
    print(i)
    if t[i] =="?":
        l[i] = "D"
    
    else:
        l[i] = t[i]

print("".join(l))

Fixed submission:
t = input()

l = ["" for i in range(len(t))]
for i in range(0, len(t)):
    if t[i] =="?":
        l[i] = "D"
    
    else:
        l[i] = t[i]

print("".join(l))
Buggy python submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))
H = list(map(int, input().split()))
ab = [list(map(int, input().split())) for i in range(m)]

ans = [1] * (n)
route = [1] * (n)
for i in range(len(ab)):
    a, b = ab[i]
    if H[a-1] <= H[b-1]:
      ans[a-1] = 0

    elif H[b-1] <= H[a-1]:
      ans[b-1] = 0
    
print(sum(cnt))

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

ans = [1] * (n)
route = [1] * (n)
for i in range(len(ab)):
    a, b = ab[i]
    if H[a-1] <= H[b-1]:
      ans[a-1] = 0

    if H[b-1] <= H[a-1]:
      ans[b-1] = 0
    
print(sum(ans))
Buggy python submission (verdict: Runtime Error):
s = input()

cnt = 0
for i in range(len(s)):
    for j in range(i+1, len(s)+1):
        if int(s[i:j]) % 2019 == 0:
            cnt += 1
print(cnt)

Fixed submission:
s, w = list(map(int, input().split()))

print("unsafe" if s <= w else "safe")
Buggy python submission (verdict: Runtime Error):
k = int(input())

from functools import reduce
def gcd_list(numbers):
  return reduce(math.gcd, numbers)

total = 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 and j == k and i == k:
        x = 1
      elif i != j and i != k and j != k:
        x = 6
      else:
        x = 3
        
      total += x * gcd_list([i, j, k])
print(total)

Fixed submission:
from itertools import combinations
import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

n = int(input())

total = 0
for i in range(1, n+1):
    for j in range(i, n+1):
        for k in range(j, n+1):
            if  i == j and j == k and i == k:
                x = 1
            elif i != j and j != k and i != k:
                x = 6
            else:
                x = 3
            
            total += x * gcd_list([i, j, k])
        
print(total)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

n = int(input())

a = []
for i in range(1, n+1):
    a += [i, i, i]

x = list(set(combinations(a, 3)))

total = 0
for i, j, k in x:
    if i == j and j == k and k == i:
        total += gcd_list([i, j, k])

    elif i != j and j != k and i != k:
        total += 6 * gcd_list([i, j, k])
    
    else:
        total += 3 * gcd_list([i, j, k])
        
print(total)

Fixed submission:
from itertools import combinations
import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

n = int(input())

total = 0
for i in range(1, n+1):
    for j in range(i, n+1):
        for k in range(j, n+1):
            if  i == j and j == k and i == k:
                x = 1
            elif i != j and j != k and i != k:
                x = 6
            else:
                x = 3
            
            total += x * gcd_list([i, j, k])
        
print(total)
Buggy python submission (verdict: Runtime Error):
N, x, y = [int(i) for i in input().split()]

cnt = [0] * N
for i in range(1, N+1):
  for j in range(i+1, N+1):
    temp = min(abs(j-i), abs(x-i) + 1 + abs(j-y), abs(y-i) + 1 + abs(j-x))
    cnt[temp] += 1

for i in range(1, N):
  print(cnt[i])

Fixed submission:
s = input()
print("Yes" if s[2] == s[3] and s[4] == s[5] else "No")
Buggy python submission (verdict: Time Limit Exceeded):
N, x, y = list(map(int, input().split()))

cnt = [0] * (N)
for i in range(1, N+1):
  for j in range(i+1, N+1):
    temp = min(abs(x-i) + 1 + abs(j-y), abs(y-i) + 1 + abs(j-x))
    cnt[min(abs(j-i), temp)] += 1

for i in range(1, N):
  print(cnt[i])

Fixed submission:
N, x, y = [int(i) for i in input().split()]

cnt = [0] * N
for i in range(1, N+1):
  for j in range(i+1, N+1):
    temp = min(abs(j-i), abs(x-i) + 1 + abs(j-y), abs(y-i) + 1 + abs(j-x))
    cnt[temp] += 1

for i in range(1, N):
  print(cnt[i])
Buggy python submission (verdict: Time Limit Exceeded):
import collections

def choose(c):
  return c * (c - 1) // 2

n = int(input())
a = [int(e) for e in input().split()]
cnt = collections.Counter(a)

for i in a:
  temp = cnt.copy()
  temp[i] -= 1
  print(sum([choose(c) for c in temp.values()]))
 

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

import collections

cnt = collections.Counter(s)
ans = sum([(v * (v-1)) // 2 for k, v in cnt.items()])

for i in range(len(s)):
  print(ans - cnt[s[i]] + 1)

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

n = int(input())
a = [int(e) for e in input().split()]
cnt = collections.Counter(a)

for i in a:
  temp = [v if k != i else v - 1 for k, v in cnt.items()]
  print(sum([ c * (c-1) for c in temp])//2)
 

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

import collections

cnt = collections.Counter(s)
ans = sum([(v * (v-1)) // 2 for k, v in cnt.items()])

for i in range(len(s)):
  print(ans - cnt[s[i]] + 1)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(e) for e in input().split()]

for i in range(n):
  temp = [a[k] for k in range(n) if k != i]
  cnt = [temp.count(k) for k in list(set(temp))]
  print(sum([ c * (c-1) for c in cnt]) // 2)
 

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

import collections

cnt = collections.Counter(s)
ans = sum([(v * (v-1)) // 2 for k, v in cnt.items()])

for i in range(len(s)):
  print(ans - cnt[s[i]] + 1)
Buggy python submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))
sc = [list(map(int,input().split())) for i in range(m)]

for i in range(0, 10**n):
  str_i = str(i)
  if len(str_i) != n: continue

  chk = True
  for s, c in sc:
    cnt &= str_i[s-1] == str(c)
  if chk:
    print(i)
    exit()

  print(-1)
     

Fixed submission:
from sys import stdin
import sys
import numpy as np
import collections
from functools import cmp_to_key
import heapq
 
##  input functions for me
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def rip(sep = ''):
    if sep == '' :
        return map(int, input().split()) 
    else: return map(int, input().split(sep))
def ria(sep = ''): 
    return list(rip(sep))
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##
def main():
    N, M = rip()
    S = [0] * M
    C = [0] * M
    for i in range(M):
        S[i], C[i] = rip()
 
    for i in range(1000):
        s = str(i)
        if len(s) != N: continue
        chk = True
        for j in range(M):
            chk &= s[S[j] - 1] == str(C[j])
        if chk:
            print(i)
            sys.exit(0)
    
    print(-1)
 
 
if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
exp = [sum([(pi + 1) / 2 for pi in p[i:i+k]]) for i in range(n-k+1)]
print(max(exp))

Fixed submission:
a, b = input().split()
a1, b1 = list(map(int, input().split()))

print(str(a1) + " " + str(b1 - 1) if input() == b else str(a1 - 1) + " " + str(b1))

Buggy python submission (verdict: Runtime Error):
a, b = input().split()
a1, b1 = list(map(int, input().split()))

print(str(a1) + " " + str(b1 - 1) if input() == b else str(a1 - 1) + " " + b1)

Fixed submission:
a, b = input().split()
a1, b1 = list(map(int, input().split()))

print(str(a1) + " " + str(b1 - 1) if input() == b else str(a1 - 1) + " " + str(b1))
Buggy python submission (verdict: Time Limit Exceeded):
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))
exp = [sum([(pi + 1) / 2 for pi in p[i:i+k]]) for i in range(n-k+1)]
print(max(exp))

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

rsum = [(p[0] + 1) / 2]
for i in range(1, n):
  rsum.append((p[i] + 1) / 2 + rsum[i-1])
  
result = 0
if (n == k):
  result = rsum[-1]

else:
  for i in range(n-k):
    if result < rsum[i+k] - rsum[i]:
      result = rsum[i+k] - rsum[i]

print(result)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))

em = 0
exp = []
for i in range(n-k+1):
  temp = sum(p[i:i+k])
  if em <= temp:
    em = temp
    exp = p[i:i+k]

    
print(sum([(pi + 1) / 2 for pi in exp]))

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

rsum = [(p[0] + 1) / 2]
for i in range(1, n):
  rsum.append((p[i] + 1) / 2 + rsum[i-1])
  
result = 0
if (n == k):
  result = rsum[-1]

else:
  for i in range(n-k):
    if result < rsum[i+k] - rsum[i]:
      result = rsum[i+k] - rsum[i]

print(result)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = list(map(int, input().split()))
p = list(map(int, input().split()))

expect = [(pi+1) / 2 for pi in p]

em = 0
for i in range(n-k+1):
  em = max(em, sum(expect[i:i+k]))

print(em)

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

rsum = [(p[0] + 1) / 2]
for i in range(1, n):
  rsum.append((p[i] + 1) / 2 + rsum[i-1])
  
result = 0
if (n == k):
  result = rsum[-1]

else:
  for i in range(n-k):
    if result < rsum[i+k] - rsum[i]:
      result = rsum[i+k] - rsum[i]

print(result)
Buggy python submission (verdict: Runtime Error):
a, b, k = [int(i) for i in input().split()]
maxs = (0, a - k)


print(str(maxs) + " " + str(b - maxs))

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

if a < k:
  a1 = k - a
  a2 = b - a1 if b > a1 else 0
  print('0 ' + str(a2))
        
else:
  print(str(a-k) + ' ' + str(b))
Buggy python submission (verdict: Runtime Error):
x = int(input())

def isPrime(x):
  for i in range(2, x**2+1):
    if x % i == 0:
	  return False
    
  return True

for i in range(x, 10**5 + 1):
  if isPrime(i):
    print(i)
    break

Fixed submission:
import math

def is_prime(x):
  if(x <= 1):
    return False
 
  for i in range(2, int(math.sqrt(x))):
    if(x % i == 0):
      return False

  return True

x = int(input())
while is_prime(x) is False:
  x += 1

print(x)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
 
ans = 0
for i in range(1, n+1):
  if n in list(range(100 * i, 105 * i + 1)):
    ans = 1
print(ans)


Fixed submission:
x = int(input())

flag = False
for c in range(1,x+1):
  if c * 100 <= x and x <= c * 105:
    flag = True
    break
print(1 if flag else 0)

Buggy python submission (verdict: Runtime Error):
n = int(input())
 
ans = 0
for i in range(1, n+1):
  if n in list(range(100 * i, 105 * i + 1))
    ans = 1
print(ans)


Fixed submission:
x = int(input())

flag = False
for c in range(1,x+1):
  if c * 100 <= x and x <= c * 105:
    flag = True
    break
print(1 if flag else 0)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
 
ans = 0
for i in range(1, n+1):
  for x in range(100 * i, 105 * i + 1):
    if n == x:
      ans = 1
print(ans)

Fixed submission:
x = int(input())

flag = False
for c in range(1,x+1):
  if c * 100 <= x and x <= c * 105:
    flag = True
    break
print(1 if flag else 0)

Buggy python submission (verdict: Runtime Error):
n = int(input())

ans = 0
for i in range(1, n+1):
  for x in range(100 * x, 105 * x + 1):
    if n == x:
      ans = 1
print(ans)

Fixed submission:
x = int(input())

flag = False
for c in range(1,x+1):
  if c * 100 <= x and x <= c * 105:
    flag = True
    break
print(1 if flag else 0)
Buggy python submission (verdict: Runtime Error):
import numpy as np
import pandas as pd


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

if a < 10 and b < 10:
    print( a * b)
else :
    print(-1)

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

if a < 10 and b < 10:
    print( a * b)
else :
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
h = list(map(int, input().split()))

maxs = 0
for i in range(len(h)):
  
  cnt = 0
  for j in range(i+1, len(h)):
    if h[j-1] < h[j]:
      break
      
    cnt += 1
  maxs = max(maxs, cnt)
  
print(maxs)
    

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

maxs = 0
cnt = 0
index = 1
for i in range(1, len(h)):
  if h[i-1] >= h[i]:
    cnt += 1
  else:
    maxs = max(cnt, maxs)
    cnt = 0

print(max(maxs, cnt))
Buggy python submission (verdict: Runtime Error):
n = int(input())
print(sum(list(range(1, n))) if n != 0 else 0)

Fixed submission:
n = int(input())
print((n-1)*n // 2)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
dicts = {}
for i in range(N):
    s = "".join(sorted(input()))
    dicts[s] = dicts[s] + 1 if s in list(dicts.keys()) else 1

num = 0
for k, v in dicts.items():
  num += v * (v-1) // 2
print(num)

Fixed submission:
N = int(input())
dicts = {}
for i in range(N):
    s = "".join(sorted(input()))
    dicts[s] = dicts[s] + 1 if s in dicts.keys() else 1

num = 0
for k, v in dicts.items():
  num += v * (v-1) // 2
print(num)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
def count(string):
    sets = list(set(string))
    return {s: string.count(s) for s in sets}

def infer(match):
    match_num = 0
    for x, y in itertools.combinations(match, 2):
        if x == y:
            match_num += 1
    
    return match_num

N = int(input())
sents = [count(input()) for i in range(N)]
ans = infer(sents)
print(ans)

Fixed submission:
N = int(input())
dicts = {}
for i in range(N):
    s = "".join(sorted(input()))
    dicts[s] = dicts[s] + 1 if s in dicts.keys() else 1

num = 0
for k, v in dicts.items():
  num += v * (v-1) // 2
print(num)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
def count(string):
    sets = sorted(list(set(string)))
    return {s: string.count(s) for s in sets}

def infer(match):
    match_num = 0
    for x, y in itertools.combinations(match, 2):
        if x == y:
            match_num += 1
    
    return match_num

N = int(input())
sents = [input() for i in range(N)]
match = [count(sents[i]) for i in range(N)]
ans = infer(match)
print(ans)

Fixed submission:
N = int(input())
dicts = {}
for i in range(N):
    s = "".join(sorted(input()))
    dicts[s] = dicts[s] + 1 if s in dicts.keys() else 1

num = 0
for k, v in dicts.items():
  num += v * (v-1) // 2
print(num)
Buggy python submission (verdict: Runtime Error):
def hoge(x, y):
    return y if x >= y else y - 1

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

flag = 0
for i in range(N - 1):
    H[i + 1] = hoge(H[i], H[i + 1])
    print(H)
    if H[i] < H[i + 1]:
        print("No")
        flag = 1
        break

if flag == 0:
    print("Yes")


Fixed submission:
def hoge(x, y):
    return y if x >= y else y - 1

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

flag = 0
for i in range(N - 1):
    H[i + 1] = hoge(H[i], H[i + 1])
    if H[i] < H[i + 1]:
        flag = 1
        print("No")
        break

if flag == 0:
    print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
a = [int(input()) for i in range(n)]

cnt = Counter(a)
for i in range(n):
  temp = cnt.copy()
  temp[a[i]] -= 1
  if temp[a[i]] == 0:
    del temp[a[i]]

  print(max(temp.keys()))




Fixed submission:
from collections import Counter
n = int(input())
a = [int(input()) for i in range(n)]

cnt = Counter(a)
maxs = sorted(list(set(a)))[::-1]
for ai in a:
  if ai == maxs[0]:
    if cnt[ai] > 1:
      print(ai)
    else:
      print(maxs[1])
  else:
    print(maxs[0])
Buggy python submission (verdict: Runtime Error):
import numpy as np 

L, R = list(map(int, input().split()))
data = np.array([x for x in range(L, R+1)]) % 2019

if np.where(data == 0):
    print(0)

else: 
    data = np.sort(data)
    min_mod = (data[0] * data[1]) % 2019
    print(min_mod)

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

tac = N * A
train = B

if tac < train:
    print(tac)

else:
    print(train)
Buggy python submission (verdict: Runtime Error):
N = int(input())
data = list(map(int, input().split()))
pn = [x for x in range(1, N-1)]

cnt = 0
for p in pn:
    p_t = np.sort([data[p - 1], data[p], data[p + 1]])
    cnt = cnt + 1 if p_t[1] == data[p] else cnt
    
print(cnt)

Fixed submission:
import numpy as np

N = int(input())
data = list(map(int, input().split()))
pn = [x for x in range(1, N-1)]

cnt = 0
for p in pn:
    p_t = np.sort([data[p - 1], data[p], data[p + 1]])
    cnt = cnt + 1 if p_t[1] == data[p] else cnt
    
print(cnt)