Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
p = 10**9 + 7

def modpow(a, n, p):
    if n == 1:
        ans = a % p
    else:
        if n % 2 == 0:
            ans = (modpow(a, n // 2, p) ** 2) % p
        else: # n % 2 == 1
            ans = (a * (modpow(a, n // 2, p) ** 2)) % p

    return ans

def C(N, K, p):
    X, Y = 1, 1
    for k in range(1, K + 1):
        X = X * (N - k + 1) % p
        Y = Y * k % p
    
    Z = modpow(Y, p - 2, p)
    ans = X * Z % p

    return ans

N, K = [int(x) for x in input().split()]
A = sorted([int(x) for x in input().split()])

maxS = 0
for i in range(N):
    maxS = (maxS + A[i] * C(i, K - 1, p)) % p

minS = 0
for i in range(N):
    minS = (minS + A[i] * C(N - i - 1, K - 1, p)) % p

ans = (maxS - minS) % p

print(ans)

Fixed submission:
p = 10**9 + 7

def modpow(a, n, p):
    if n == 1:
        ans = a % p
    else:
        if n % 2 == 0:
            ans = (modpow(a, n // 2, p) ** 2) % p
        else: # n % 2 == 1
            ans = (a * (modpow(a, n // 2, p) ** 2)) % p

    return ans

Fact = [[1, 1] for _ in range(10**5 + 1)]
for i in range(1, 10**5 + 1):
    Fact[i][0] = (Fact[i - 1][0] * i) % p
    Fact[i][1] = modpow(Fact[i][0], p - 2, p)

def C(a, b, p, Fact):
    if a < b:
        return 0
    else:
        ans = Fact[a][0] * Fact[b][1] * Fact[a - b][1] % p
        return ans

N, K = [int(x) for x in input().split()]
A = sorted([int(x) for x in input().split()])
 
maxS = 0
for i in range(N):
    maxS = (maxS + A[i] * C(i, K - 1, p, Fact)) % p

minS = 0
for i in range(N):
    minS = (minS + A[i] * C(N - i - 1, K - 1, p, Fact)) % p

ans = (maxS - minS) % p
 
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(100000)

N = int(input())
vertex = set()
conn = [[] for _ in range(2*10**5 + 1)]
check = [False]*(2*10**5 + 1)
for i in range(N):
    x, y = [int(x) for x in input().split()]
    vertex.add(x)
    vertex.add(y + 10**5)
    conn[x].append(y + 10**5)
    conn[y + 10**5].append(x)

count = [0] * 2
def dfs(z):
    if check[z] == True:
        return
    check[z] = True
    if z <= 10**5:
        count[0] += 1
    else:
        count[1] += 1
    for w in conn[z]:
        dfs(w)

ans = 0
for z in vertex:
    if check[z] == False:
        count = [0]*2
        dfs(z)
        X, Y = count[0], count[1]
        ans += X * Y
ans -= N

print(ans)

Fixed submission:
import sys
sys.setrecursionlimit(100000)

N = int(input())
vertex = set()
conn = [[] for _ in range(2*10**5 + 1)]
check = [False]*(2*10**5 + 1)
for i in range(N):
    x, y = [int(x) for x in input().split()]
    vertex.add(x)
    vertex.add(y + 10**5)
    conn[x].append(y + 10**5)
    conn[y + 10**5].append(x)

count = [0] * 2
def dfs(z):
    if check[z] == True:
        return
    check[z] = True
    if z <= 10**5:
        count[0] += 1
    else:
        count[1] += 1
    for w in conn[z]:
        dfs(w)

ans = 0
for z in vertex:
    if check[z] == False:
        count = [0]*2
        dfs(z)
        X, Y = count[0], count[1]
        ans += X * Y
ans -= N

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.readline
H, W = [int(x) for x in input().split()]
board = []
for _ in range(H):
    board.append(input())

L = [[0]*W for _ in range(H)]
R = [[0]*W for _ in range(H)]
U = [[0]*W for _ in range(H)]
D = [[0]*W for _ in range(H)]
for i in range(H):
    for j in range(W):
        if board[i][j] == '.':
            if j == 0:
                L[i][j] = 1
            else:
                L[i][j] = L[i][j - 1] + 1

for i in range(H):
    for j in reversed(range(W)):
        if board[i][j] == '.':
            if j == W - 1:
                R[i][j] = 1
            else:
                R[i][j] = R[i][j + 1] + 1

for j in range(W):
    for i in range(H):
        if board[i][j] == '.':
            if i == 0:
                U[i][j] = 1
            else:
                U[i][j] = U[i - 1][j] + 1

for j in range(W):
    for i in reversed(range(H)):
        if board[i][j] == '.':
            if i == H - 1:
                D[i][j] = 1
            else:
                D[i][j] = D[i + 1][j] + 1

ans = 0
for i in range(H):
    for j in range(W):
        cand = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3
        ans = max(ans, cand)
        
print(ans)

Fixed submission:
import sys
input=sys.stdin.readline
H, W = [int(x) for x in input().split()]
board = []
for _ in range(H):
    board.append(input())

L = [[0]*W for _ in range(H)]
R = [[0]*W for _ in range(H)]
U = [[0]*W for _ in range(H)]
D = [[0]*W for _ in range(H)]
for i in range(H):
    for j in range(W):
        if board[i][j] == '.':
            if j == 0:
                L[i][j] = 1
            else:
                L[i][j] = L[i][j - 1] + 1

for i in range(H):
    for j in reversed(range(W)):
        if board[i][j] == '.':
            if j == W - 1:
                R[i][j] = 1
            else:
                R[i][j] = R[i][j + 1] + 1

for j in range(W):
    for i in range(H):
        if board[i][j] == '.':
            if i == 0:
                U[i][j] = 1
            else:
                U[i][j] = U[i - 1][j] + 1

for j in range(W):
    for i in reversed(range(H)):
        if board[i][j] == '.':
            if i == H - 1:
                D[i][j] = 1
            else:
                D[i][j] = D[i + 1][j] + 1

ans = 0
for i in range(H):
    for j in range(W):
        cand = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3
        ans = max(ans, cand)
        
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def lb_str(a, K):
    n = len(a)
    if n == 0:
        return -1
    elif K <= a[0]:
        return -1
    low = 0
    high = n - 1
    while low < high:
        mid = (low + high + 1) // 2
        if a[mid] < K:
            low = mid
        else:
            high = mid - 1

    return low

N, M = [int(x) for x in input().split()]
A = sorted([int(x) for x in input().split()])

data = []
for i in range(M):
    B, C = [int(x) for x in input().split()]
    data.append([C, B])
data = sorted(data)

for i in range(M):
    C, B = data[i][0], data[i][1]
    j = lb_str(A, C)
    if j + 1 <= B:
        A = [C]*(j + 1) + A[j + 1:]
    else:
        A = A[B:j + 1] + [C]*B + A[j + 1:]
ans = sum(A)
print(ans)


Fixed submission:
N, M = [int(x) for x in input().split()]
A = sorted([int(x) for x in input().split()])

data = []
for i in range(M):
    B, C = [int(x) for x in input().split()]
    data.append([C, B])
data = sorted(data, reverse=True)

D = []
i, tot = 0, 0
while tot < N and i < M:
    C, B = data[i][0], data[i][1]
    for _ in range(B):
        D.append(C)
        tot += 1
        if tot >= N:
            break
    i += 1

i = 0
while i < min(N, len(D)) and A[i] < D[i]:
    i += 1

ans = sum(D[:i] + A[i:])
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def lb_str(a, K):
    n = len(a)
    if n == 0:
        return -1
    elif K <= a[0]:
        return -1
    low = 0
    high = n - 1
    while low < high:
        mid = (low + high + 1) // 2
        if a[mid] < K:
            low = mid
        else:
            high = mid - 1

    return low

N, M = [int(x) for x in input().split()]
A = sorted([int(x) for x in input().split()])

data = []
for i in range(M):
    B, C = [int(x) for x in input().split()]
    data.append([C, B])
data = sorted(data)

for i in range(M):
    C, B = data[i][0], data[i][1]
    j = lb_str(A, C)
    if j + 1 <= B:
        A = [C]*(j + 1) + A[j + 1:]
    else:
        A = A[B:j + 1] + [C]*B + A[j + 1:]
ans = sum(A)
print(ans)

Fixed submission:
N, M = [int(x) for x in input().split()]
A = sorted([int(x) for x in input().split()])

data = []
for i in range(M):
    B, C = [int(x) for x in input().split()]
    data.append([C, B])
data = sorted(data, reverse=True)

D = []
i, tot = 0, 0
while tot < N and i < M:
    C, B = data[i][0], data[i][1]
    for _ in range(B):
        D.append(C)
        tot += 1
        if tot >= N:
            break
    i += 1

i = 0
while i < min(N, len(D)) and A[i] < D[i]:
    i += 1

ans = sum(D[:i] + A[i:])
print(ans)
Buggy python submission (verdict: Runtime Error):
class UnionFind():
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n

    def root(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.par[x] = y
            else:
                self.par[y] = x
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1

    def samegrp(self, x, y):
        return self.root(x) == self.root(y)

from mymodules.somedatastrs import UnionFind

n, m = [int(x) for x in input().split()]
A = UnionFind(n)
ans = n
for i in range(m):
    x, y, _ = [int(z) - 1 for z in input().split()]
    if not A.samegrp(x, y):
        ans -=1
    A.union(x, y)

print(ans)

Fixed submission:
class UnionFind():
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n

    def root(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.par[x] = y
            else:
                self.par[y] = x
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1

    def samegrp(self, x, y):
        return self.root(x) == self.root(y)

n, m = [int(x) for x in input().split()]
A = UnionFind(n)
ans = n
for i in range(m):
    x, y, _ = [int(z) - 1 for z in input().split()]
    if not A.samegrp(x, y):
        ans -=1
    A.union(x, y)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

n, m = [int(x) for x in input().split()]
data = [[0]*n for _ in range(m)]
for i in range(m):
    x, y, _ = [int(x) - 1 for x in input().split()]
    data[i][x], data[i][y] = 1, -1

mat = np.array(data)
r = np.linalg.matrix_rank(mat)

ans = n - r

print(ans)

Fixed submission:
class UnionFind():
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n

    def root(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.par[x] = y
            else:
                self.par[y] = x
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1

    def samegrp(self, x, y):
        return self.root(x) == self.root(y)

n, m = [int(x) for x in input().split()]
A = UnionFind(n)
ans = n
for i in range(m):
    x, y, _ = [int(z) - 1 for z in input().split()]
    if not A.samegrp(x, y):
        ans -=1
    A.union(x, y)

print(ans)
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
if A > B:
    print(2 * A - 1)
elif A < B:
    print(2 * B - 1)
else:
    print(2 * A)

Fixed submission:
A,B=(int(x) for x in input().split())
if A > B:
    print(2 * A - 1)
elif A < B:
    print(2 * B - 1)
else:
    print(2 * A)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

X = set(A)
L = len(X)

S= []
for x in X:
    n = A.count(x)
    S.append(n)

S = sorted(S)

ans = sum(S[:max(0,L - K)])

print(ans)

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

X = [0] * N

for i in range(N):
    X[A[i] - 1] += 1

X = sorted(X, reverse=True)

S = sum(X[:K])

ans = N - S

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
K, S = [int(x) for x in input().split()]

ans = 0

for x in range(K + 1):
    for y in range(K + 1):
        for z in range(K + 1):
            if x + y + z == S:
                ans += 1

print(ans)

Fixed submission:
K, S = [int(x) for x in input().split()]

ans = 0

for x in range(max(0, S - 2 * K), min(K, S) + 1):
    ans += min(K, S - x) - max(0, S - x - K) + 1

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

n, x, m = map(int, input().split())

a_list = [x]
a = x
i = 1
while (i<n and i < m):
    a = (a*a) % m
    a_list.append(a)
    i += 1
    
#print(i)
#print(a_list)
    
if i == n:
  ans = sum(a_list)
else:
    b = a_list.index(a)
    sum1 = sum(a_list[:b+1])
    sum2 = sum(a_list[b+1:i])
    blen = i-b-1
    repeat = (n-b-1) // blen
    amari = (n-b-1) % blen
    sum3 = 0
    if amari != 0:
    	sum3 = sum(a_list[b+1:b+amari+1])
    ans = sum1 + sum2*repeat + sum3
    #print(blen)
    #print(amari)
    #print(sum1, sum2, repeat, sum3)

print(ans)

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

n, x, m = map(int, input().split())

a_list = [x]
a = x
i = 1
while (i<n and i < m+1):
    a = (a*a) % m
    a_list.append(a)
    i += 1
    
#print(i)
#print(a_list)
    
if i == n:
  ans = sum(a_list)
else:
    b = a_list.index(a)
    sum1 = sum(a_list[:b+1])
    sum2 = sum(a_list[b+1:i])
    blen = i-b-1
    repeat = (n-b-1) // blen
    amari = (n-b-1) % blen
    sum3 = 0
    if amari != 0:
    	sum3 = sum(a_list[b+1:b+amari+1])
    ans = sum1 + sum2*repeat + sum3
    #print(blen)
    #print(amari)
    #print(sum1, sum2, repeat, sum3)

print(ans)

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

n, x, m = map(int, input().split())

ans = x

i = 1
a_list = [x]
a = x
flag = 0
while(i<n):
    a = (a*a) % m
    if a in a_list:
        flag = 1
        break
    a_list.append(a)
    ans += a
    i+=1
    
if flag == 1:
    b = a_list.index(a)
    tmp_sum = 0
    for j in range(b,len(a_list)):
        tmp_sum += a_list[j]
    blen = len(a_list)-b
    ans += tmp_sum*((n-i)//blen)
    for k in range((n-i) % blen):
        ans += a_list[i+k-blen]

print(ans)

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

n, x, m = map(int, input().split())

a_list = [x]
a = x
i = 1
while (i<n and i < m+1):
    a = (a*a) % m
    a_list.append(a)
    i += 1
    
#print(i)
#print(a_list)
    
if i == n:
  ans = sum(a_list)
else:
    b = a_list.index(a)
    sum1 = sum(a_list[:b+1])
    sum2 = sum(a_list[b+1:i])
    blen = i-b-1
    repeat = (n-b-1) // blen
    amari = (n-b-1) % blen
    sum3 = 0
    if amari != 0:
    	sum3 = sum(a_list[b+1:b+amari+1])
    ans = sum1 + sum2*repeat + sum3
    #print(blen)
    #print(amari)
    #print(sum1, sum2, repeat, sum3)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
n = int(input())
numlist = list(map(int, input().split()))
dic = {}
for num in numlist:
  if num not in dic:
    dic[num] = 1
  else:
    dic[num] += 1
    
ansdic = {}
for key in dic.keys():
  n = dic[key]
  ansdic[key] = [int(n*(n-1)/2),int((n-1)*(n-2)/2)]
      
ansdic2 = {}
for key in ansdic.keys():
  sum = 0
  for key2 in ansdic.keys():
    if key == key2:
      sum += ansdic[key2][1]
    else:
      sum += ansdic[key2][0]
  ansdic2[key] = sum  
    
for num in numlist:
  print(ansdic2[num])

Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())
numlist = list(map(int, input().split()))
dic = {}
for num in numlist:
  if num not in dic:
    dic[num] = 1
  else:
    dic[num] += 1
    
tmpsum = 0
for value in dic.values():
  tmpsum += int(value*(value-1)/2)
ansdic = {}
for key in dic.keys():
  n = dic[key]
  ansdic[key] = tmpsum - n + 1      
    
for num in numlist:
  print(ansdic[num])

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
n = int(input())
numlist = list(map(int, input().split()))
dic = {}
for num in numlist:
  if num not in dic:
    dic[num] = 1
  else:
    dic[num] += 1
    
ansdick = {}
for key in dic.keys():
  n = dic[key]
  ansdick[key] = [int(n*(n-1)/2),int((n-1)*(n-2)/2)]
      
for num in numlist:
  sum = 0
  for key in dic.keys():
    if num == key:
      sum += ansdick[key][1]
    else:
      sum += ansdick[key][0]
  print(sum)


Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())
numlist = list(map(int, input().split()))
dic = {}
for num in numlist:
  if num not in dic:
    dic[num] = 1
  else:
    dic[num] += 1
    
tmpsum = 0
for value in dic.values():
  tmpsum += int(value*(value-1)/2)
ansdic = {}
for key in dic.keys():
  n = dic[key]
  ansdic[key] = tmpsum - n + 1      
    
for num in numlist:
  print(ansdic[num])

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
n = int(input())
numlist = list(map(int, input().split()))
dic = {}
for num in numlist:
  if num not in dic:
    dic[num] = 1
  else:
    dic[num] += 1
      
for num in numlist:
  sum = 0
  for key in dic.keys():
    n = dic[key]
    if num == key:
      n -= 1
    sum += int(n*(n-1)/2)
  print(sum)

Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())
numlist = list(map(int, input().split()))
dic = {}
for num in numlist:
  if num not in dic:
    dic[num] = 1
  else:
    dic[num] += 1
    
tmpsum = 0
for value in dic.values():
  tmpsum += int(value*(value-1)/2)
ansdic = {}
for key in dic.keys():
  n = dic[key]
  ansdic[key] = tmpsum - n + 1      
    
for num in numlist:
  print(ansdic[num])
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = int(input())
nt = []
for i in range(n):
  tmp = input().split()
  for j in range(n-1):
    tmp[j] = int(tmp[j])
  nt.append(tmp)

day = 0
j = []
for i in range(n):
  j.append(0)
  
while(True):
  #print(j)
  tmp = []
  for i in range(n):
    if j[i] < n-1 and nt[nt[i][j[i]]-1][j[nt[i][ j[i] ]-1]] == i+1:
      tmp.append(i)
  #print(tmp)
  if len(tmp) == 0:
    break
  for i in tmp:
    j[i] += 1
  day += 1
  
error = 0
for i in range(n):
  if j[i] != n-1:
    day = -1

print(day)

Fixed submission:
# -*- coding: utf-8 -*-
y = input()
t = input()
ylist = list(y)
tlist = list(t)
seikai = 0
for i in range(3):
  if ylist[i] == tlist[i]:
    seikai += 1
    
print(seikai)
Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
n = int(input())
h = input().split()
for i in range(n):
  h[i] = int(h[i])

ans = 0
for i in range(n-1):
  tmp = 0
  i_tmp = i
  while(i_tmp<n-1):
    if h[i_tmp+1]>h[i_tmp]:
      break
    i_tmp += 1
    tmp += 1
  if tmp > ans:
    ans = tmp
  i += 1
  
print(ans)

Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())
h = input().split()
for i in range(n):
  h[i] = int(h[i])

ans = 0
i = 0
while(i < n-1):
  tmp = 0
  i_tmp = i
  while(i_tmp<n-1):
    if h[i_tmp+1]>h[i_tmp]:
      break
    i_tmp += 1
    tmp += 1
  if tmp > ans:
    ans = tmp
  i += tmp+1
  
print(ans)
Buggy python submission (verdict: Runtime Error):
MOD = 1000000007
n = int(input())
nums = list(map(int, input().split()))
x = sum(sums)
y = sum([(x[i]**2) for i in range(n)])
print(((x**2 - y)//2)% MOD)

Fixed submission:
MOD = 1000000007
n = int(input())
nums = list(map(int, input().split()))
x = sum(nums)
y = sum([(nums[i]**2) for i in range(n)])
print(((x**2 - y)//2)% MOD)

Buggy python submission (verdict: Time Limit Exceeded):
def sekiwa(x):
    n = len(x)
    result = 0
    MOD = 1000000007
    for i in range(n-1):
        for j in range(i+1, n):
            N = nums[i]*nums[j] % MOD
            result += N
            result = result % MOD
    return result

n = int(input())
nums = list(map(int, input().split()))
print(sekiwa(nums))

Fixed submission:
MOD = 1000000007
n = int(input())
nums = list(map(int, input().split()))
x = sum(nums)
y = sum([(nums[i]**2) for i in range(n)])
print(((x**2 - y)//2)% MOD)

Buggy python submission (verdict: Time Limit Exceeded):
MOD = 1000000007
n = int(input())
nums = list(map(int, input().split()))
result = 0
for i in range(n-1):
    for j in range(i+1, n):
        N = ((nums[i] % MOD)*(nums[j] % MOD)) % MOD
        result += N
        result = result % MOD
print(result)

Fixed submission:
MOD = 1000000007
n = int(input())
nums = list(map(int, input().split()))
x = sum(nums)
y = sum([(nums[i]**2) for i in range(n)])
print(((x**2 - y)//2)% MOD)

Buggy python submission (verdict: Time Limit Exceeded):
MOD = 1000000007
n = int(input())
nums = list(map(int, input().split()))
result = 0
for i in range(n-1):
    for j in range(i+1, n):
        N = nums[i]*nums[j] % MOD
        result += N
        result = result % MOD
print(result)

Fixed submission:
MOD = 1000000007
n = int(input())
nums = list(map(int, input().split()))
x = sum(nums)
y = sum([(nums[i]**2) for i in range(n)])
print(((x**2 - y)//2)% MOD)
Buggy python submission (verdict: Runtime Error):
n = map(int, input().split())
count = 0
for i in range(n[0]):
  a, b = map(int, input().split())
  r = (a **2 + b ** 2) ** 0.5
  if r <= n[1]:
    count += 1
print(count)

Fixed submission:
N, D = map(int, input().split())
count = 0
for i in range(N):
  a, b = map(int, input().split())
  r = (a **2 + b ** 2) ** 0.5
  if r <= D:
    count += 1
print(count)

Buggy python submission (verdict: Runtime Error):
n = map(int, input())
count = 0
for i in range(n[0]):
  a, b = map(int, input())
  r = (a **2 + b ** 2) ** 0.5
  if r <= n[1]:
    count += 1
print(count)
  

Fixed submission:
N, D = map(int, input().split())
count = 0
for i in range(N):
  a, b = map(int, input().split())
  r = (a **2 + b ** 2) ** 0.5
  if r <= D:
    count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
a, b = int(input().split())
s = a - 1
t = b-1
asn = (s + t -1) // s

Fixed submission:
a, b = map(int, input().split())
print(((b - 1) + (a - 2)) // (a - 1))

Buggy python submission (verdict: Runtime Error):
S, T = input().split()
print(S + T -1) // S

Fixed submission:
a, b = map(int, input().split())
print(((b - 1) + (a - 2)) // (a - 1))

Buggy python submission (verdict: Runtime Error):
n = list(map(int, input().split(' '))
print(-(-n[1] + 1) // (n[0] -1))
         

Fixed submission:
a, b = map(int, input().split())
print(((b - 1) + (a - 2)) // (a - 1))
Buggy python submission (verdict: Runtime Error):
n = int(input())
nums = list(map(int, input.split('')))
count = 0
count2 = count
for i in range(n-1):
  if nums[i] >= nums[i+1]:
    count += 1
  else:
    count2 = max([count, count2])
    count = 0
print(max([count, count2]))

Fixed submission:
n=int(input())
h=[int(i) for i in input().split()]
c=0
d=c
for i in range(n-1):
    if h[i]>=h[i+1]:
        c+=1
    else:
        d=max([c,d])
        c=0

print(max([c,d]))

Buggy python submission (verdict: Runtime Error):
n = int(input())
nums = list(map(int, input.split('')))
count = 0
count2 = count
for i in range(n):
  if nums[i] >= nums[i+1]:
    count += 1
  else:
    count2 = max([count, count2])
    count = 0
print(max([count, count2]))

Fixed submission:
n=int(input())
h=[int(i) for i in input().split()]
c=0
d=c
for i in range(n-1):
    if h[i]>=h[i+1]:
        c+=1
    else:
        d=max([c,d])
        c=0

print(max([c,d]))

Buggy python submission (verdict: Runtime Error):
n = int(input())
nums = list(map(int, input().split(' ')))
count = []
for i in range(n):
  if num[i] > num[i+1]:
    count.append(1)
print(len(count))


Fixed submission:
n=int(input())
h=[int(i) for i in input().split()]
c=0
d=c
for i in range(n-1):
    if h[i]>=h[i+1]:
        c+=1
    else:
        d=max([c,d])
        c=0

print(max([c,d]))
Buggy python submission (verdict: Runtime Error):
n = int(input())
print(a + a**2 + a**3)

Fixed submission:
a = int(input())
print(a + a**2 + a**3)
Buggy python submission (verdict: Runtime Error):
S = int(input())

mod = 10**9+7

def dfs_memo(n):
    memo = [0]*(n+1)
    memo[3] = 1

    def dfs(n):
        if n < 3:
            return 0
        elif memo[n] != 0:
            return memo[n]
        memo[n] = dfs(n-1)+dfs(n-3)
        return memo[n]
    return dfs(n)

if S <3:
    print(0)
else:
    print(dfs_memo(S)%mod)

Fixed submission:
import sys
sys.setrecursionlimit(100000000)
S = int(input())

mod = 10**9+7

def dfs_memo(n):
    memo = [0]*(n+1)
    memo[3] = 1

    def dfs(n):
        if n < 3:
            return 0
        if memo[n] != 0:
            return memo[n]
        memo[n] = dfs(n-1)+dfs(n-3)
        return memo[n]
    return dfs(n)

if S <3:
    print(0)
else:
    print(dfs_memo(S)%mod)