Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N, D = list(map(int, input()))

cnt = 0

for i in range(N):
  x, y = list(map(int, input()))
  
  if x**2 + y**2 <= D**2:
    cnt += 1

print(cnt)

Fixed submission:
N, D = list(map(int, input().split()))
 
cnt = 0
 
for i in range(N):
  x, y = list(map(int, input().split()))
  
  if x**2 + y**2 <= D**2:
    cnt += 1
 
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = [tuple(map(int, input().split())) for i in range(N)]

s.sort(key=lambda x: x[1])

t = list(map(lambda j:(j[0]-j[1]+1, j[0]+j[1]-1), s))
NN = len(t)
dobon = []

for k in range(NN):
  for l in range(k+1, NN):
    if l not in dobon:
      if int(t[k][1]) <= int(t[l][1]):
        if (t[l][0] <= t[k][1]) and (t[k][1] <= t[l][1]):
          N -= 1
          dobon.append(l)
          break
      else:
        if (t[l][0] <= t[k][0]) and (t[k][0] <= t[l][1]):
          N -= 1
          dobon.append(l)
          break

print(N)

Fixed submission:
N = int(input())
S = [tuple(map(int, input().split())) for i in range(N)]
T = list(map(lambda j:(j[0]-j[1], j[0]+j[1]), S))

T.sort(key=lambda x: x[1])

for i, t in enumerate(T):
  if i>0:
    if end <= t[0]:
      res += 1
      start = t[0]
      end = t[1]
  else:
    start = t[0]
    end = t[1]
    res = 1

print(res)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
s = [tuple(map(int, input().split())) for i in range(N)]

s.sort(key=lambda x: x[1])

t = list(map(lambda j:(j[0]-j[1]+1, j[0]+j[1]-1), s))
NN = len(t)
dobon = []

for k in range(NN):
  for l in range(k+1, NN):
    if l not in dobon:
      if int(t[k][1]) <= int(t[l][1]):
        if (t[l][0] <= t[k][1]) and (t[k][1] <= t[l][1]):
          N -= 1
          dobon.append(l)
          break
      else:
        if (t[l][0] <= t[k][0]) and (t[k][0] <= t[l][1]):
          N -= 1
          dobon.append(l)
          break

print(N)

Fixed submission:
N = int(input())
S = [tuple(map(int, input().split())) for i in range(N)]
T = list(map(lambda j:(j[0]-j[1], j[0]+j[1]), S))

T.sort(key=lambda x: x[1])

for i, t in enumerate(T):
  if i>0:
    if end <= t[0]:
      res += 1
      start = t[0]
      end = t[1]
  else:
    start = t[0]
    end = t[1]
    res = 1

print(res)
Buggy python submission (verdict: Runtime Error):
N = int(input())
s = [tuple(map(int, input().split())) for i in range(N)]

s.sort(key=lambda x: x[1])

t = list(map(lambda j:(j[0]-j[1]+1, j[0]+j[1]-1), s))
NN = len(t)
dobon = []

for k, k_l in enumerate(t):
  if k in dobon:
    break
  for l in range(k+1, NN):
    if l in dobon:
      pass
    else:
      if int(k_l[1]) <= int(t[l][1]):
        if (t[l][0] <= k_l[1]) and (k_l[1] <= t[l][1]):
          N -= 1
          dobon.append(l)
          break
      else:
        if (t[l][0] <= k_l[0]) and (k_l[0] <= t[l][1]):
          N -= 1
          dobon.append(l)
          break

print(N)

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

if S != 10**9:
  res = [S]*K + [10**9]*(N-K)
else:
  res = [10**9]*K + [1]*(N-K)
  
print(*res)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N,K,Q = map(int, input().split())

points = np.array([K] * N)

for i in range(Q):
  ans = int(input())
  points -= 1
  points[ans-1] += 1

for i in range(N):
  if points[i] > 0:
    print('Yes')
  else:
    print('No')

Fixed submission:
import numpy as np
N,K,Q = map(int, input().split())

points = np.array([K-Q] * N)
getpoints = np.array([0] * N)

for i in range(Q):
  ans = int(input())
  getpoints[ans-1] +=1

points += getpoints

for i in range(N):
  if points[i] > 0:
    print('Yes')
  else:
    print('No')
Buggy python submission (verdict: Runtime Error):
x = int(input())
s = set([])
primes = [2,3,5,7,11,13,17,19,23,29,31]
for b in primes:
    for p in range(2,10):
        if b**p <= x:
            s.add(b**p)
        else:
            break
print(sorted(list(s))[-1])

Fixed submission:
x = int(input())
s = set([1])
for b in range(32):
    for p in range(2,10):
        if b**p <= x:
            s.add(b**p)
print(sorted(list(s))[-1])
Buggy python submission (verdict: Time Limit Exceeded):
m = int(input())
def calc(m):
    for h in range(1, 3500):
        for n in range(1, 3500):
            for w in range(1, 3500):
                if 4 * h * n * w == m * (w * n + w * h  + h * n):
                    return h, n, w
print('{0[0]} {0[1]} {0[2]}'.format(calc(m)))

Fixed submission:
N = int(input())
def calc(N):
    for h in range(1, 3500):
        for n in range(1, 3500):
            if 4 * h * n - N * n - N * h > 0 and (N * h * n) % (4 * h * n - N * n - N * h) == 0:
                w = (N * h * n) / (4 * h * n - N * n - N * h)
                return h, n, int(w)
print('{0[0]} {0[1]} {0[2]}'.format(calc(N)))
Buggy python submission (verdict: Runtime Error):
x, a, b = map(int, input().split())
if b - a < 0:
    print("delicious")
elif 0 <= b - a =< x:
    print("safe")
else:
    print("dangerous")


Fixed submission:
x, a, b = map(int, input().split())
if b - a <= 0:
    print("delicious")
elif 0 < b - a <= x:
    print("safe")
else:
    print("dangerous")
Buggy python submission (verdict: Runtime Error):

sa, sb, sc = [list(input()) for i in range(3)]
now = sa.pop(0)
while 1:
    #print(now, sa, sb, sc)
    if now == "a":
        now = sa.pop(0)
    elif now == "b":
        now = sb.pop(0)
    else:
        now = sc.pop(0)
    
    if sa == [] and now == "a" :
        print("A")
        break
    elif sb == [] and now == "b":
        print("B")
        break
    elif sc == [] and now == "c":
        print("C")
        break

Fixed submission:
# coding: utf-8
# Here your code !

sa, sb, sc = [list(input()) for i in range(3)]
now = sa.pop(0)
while 1:
    #print(now, sa, sb, sc)
    if now == "a":
        if sa == []:
            pass
        else:
            now = sa.pop(0)
    elif now == "b":
        now = sb.pop(0)
    else:
        now = sc.pop(0)
    
    if sa == [] and now == "a" :
        print("A")
        break
    elif sb == [] and now == "b":
        print("B")
        break
    elif sc == [] and now == "c":
        print("C")
        break
Buggy python submission (verdict: Runtime Error):
# coding: utf-8

S = input()
cnt = 0
ls = []
for i in range(2**(len(S)-1)):
    #print(str(bin(i))[2:].zfill(len(S)-1))
    bi = list(str(bin(i))[2:].zfill(len(S)-1))
    ls.append(bi)

for item in ls:
    s = S[0]
    for inx, bi in enumerate(item):
        if bi == "0":
            pass
        else:
            s = s+"+"
        s = s + S[inx+1]
    cnt += sum(map(int, s.split("+")))
print(cnt)

Fixed submission:
# coding: utf-8

S = input()
cnt = 0
ls = []
for i in range(2**(len(S)-1)):
    #print(str(bin(i))[2:].zfill(len(S)-1))
    bi = list(str(bin(i))[2:].zfill(len(S)-1))
    ls.append(bi)

for item in ls:
    s = S[0]
    for inx, bi in enumerate(item):
        if bi == "0":
            pass
        else:
            s = s+"+"
        if len(S) != 1:
            s = s + S[inx+1]
        else:
            s = S
    cnt += sum(map(int, s.split("+")))
print(cnt)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8
import itertools
n, k = map(int, raw_input().split())
ls = map(int, raw_input().split())
kls = []
for i in range(10):
    if i not in ls:
        kls.append(i)
#print ls,kls
ans_list = []
for element in itertools.product(kls, repeat=len(str(n))):
    a = int("".join(map(str,element)))
    if a >= n:
        ans_list.append(a)
print ans_list[0]

Fixed submission:
# coding: utf-8
import itertools
n, k = map(int, raw_input().split())
ls = map(int, raw_input().split())
kls = []
for i in range(10):
    if i not in ls:
        kls.append(i)
#print ls,kls
ans_list = []
repeat_len = len(str(n))
while not ans_list:
    for element in itertools.product(kls, repeat=repeat_len):
        a = int("".join(map(str,element)))
        if a >= n:
            ans_list.append(a)
    repeat_len += 1
print ans_list[0]
Buggy python submission (verdict: Runtime Error):
import sys
a,b,c,k=map(int,input().split())
ans=0
if a<=k:
    ans=a
    k=k-a
else:
    print(k)
    sys.exit()
if k!=0:
    k=k-b
else:
    print(a)
    sys.exit()
if k>0:
    ans=ans-k
    print(ans)
else:
    print(a)

Fixed submission:
s=input()
t=input()
print("Yes" if t[:len(s)]==s and len(s)+1==len(t) else "No")
Buggy python submission (verdict: Runtime Error):
a=int(input())
*b,=map(open(0))
s=set(b)
print(min(a,len(s)))

Fixed submission:
a,*b=map(str, open(0).read().split())
s=set(b)
print(min(int(a),len(s)))

Buggy python submission (verdict: Runtime Error):
a=int(input())
b=[input() for _ in range(10)]
s=set(b)
print(min(a,len(s)-1) if '' in b else min(a,len(s)))

Fixed submission:
a,*b=map(str, open(0).read().split())
s=set(b)
print(min(int(a),len(s)))
Buggy python submission (verdict: Runtime Error):
n,x=map(int,input().split())
l=list(map(int,input().split()))
i=z=0
while z<=x:
    z+=l[i]
    i+=1
print(i)

Fixed submission:
n,x=map(int,input().split())
l=list(map(int,input().split()))
i=z=0
while z<=x and i<n:
    z+=l[i]
    i+=1
if z<=x:
    i+=1
print(i)
Buggy python submission (verdict: Runtime Error):
import math as m
n=int(input())
print((2*n)//m.gcd(2,n))

Fixed submission:
import fractions
n=int(input())
print((2*n)//fractions.gcd(2,n))

Buggy python submission (verdict: Runtime Error):
import math
n=int(input())
print((2*n)//math.gcd(2,n))

Fixed submission:
import fractions
n=int(input())
print((2*n)//fractions.gcd(2,n))
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
ans=[]
for i in range(1,n-1):
    ans.append(len(set((s[:i]))&(set(s[i:]))))
print(max(ans))

Fixed submission:
n=int(input())
s=input()
ans=[]
for i in range(n):
    ans.append(len(set((s[:i]))&(set(s[i:]))))
print(max(ans))
Buggy python submission (verdict: Runtime Error):
s=int(input())
two=[]
for i in range(7):
    two.append(2**i)
ans=0
if s in two:
    print(s)
else:
    while s>two[ans]:
        ans+=1
    print(2**(ans-1))

Fixed submission:
s=int(input())
two=[]
for i in range(8):
    two.append(2**i)
ans=0
if s in two:
    print(s)
else:
    while s>two[ans]:
        ans+=1
    print(2**(ans-1))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
i=1
j=1
while j!=n+1:
    i=i*j
    j+=1
print(i%(10**9+7))

Fixed submission:
n=int(input())
i=1
j=1
while j!=n+1:
    i=(i*j)%(10**9+7)
    j+=1
print(i)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

k,s=map(int,input().split())
K=list(range(k+1))
ans=0
for team in itertools.product(K,repeat=3):
    if sum(team)==s:
        ans+=1
print(ans)

Fixed submission:
k,s=map(int,input().split())
ans=0
for i in range(k+1):
    for j in range(k+1):
        if 0<=s-i-j<=k:
            ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
def takahashi(n, k, x, y):
    if n > k:
        return (n-k+1)*x + (k-1)*y
    else:
        return n*x
    


n,k,x,y = list(map(int, input().split()))
takahashi(n,k,x,y)

Fixed submission:
n=int(input())
k=int(input())
x=int(input())
y=int(input())

if n > k:
    print(k*x + (n-k)*y)
else:
    print(n*x)
Buggy python submission (verdict: Runtime Error):
#import numpy as np
import math
#from decimal import *
#from numba import njit

#@njit
def main():
    N,K = map(int, input().split())
    A = list(map(int, input().split()))

    def check(x):
        return N+K >= sum(map(lambda a: math.ceil(a/x), A))

    s = max(A)//2
    h = s//2
    c = check(s)
    while h > 0 or not c:
        if c:
            s -= h
        else:
            s += max(1,h)
        h //= 2
        c = check(s)
    print(s)

main()


Fixed submission:
#import numpy as np
import math
#from decimal import *
#from numba import njit

#@njit
def main():
    N,K = map(int, input().split())
    A = list(map(int, input().split()))

    def check(x):
        if x <= 0:
            return False
        else:
            return N+K >= sum(map(lambda a: math.ceil(a/x), A))

    s = max(A)//2
    h = s//2
    c = check(s)
    last = c
    while True:
        if c:
            s -= max(1,h)
        else:
            s += max(1,h)
        h //= 2
        last = c
        c = check(s)
        if h <= 0 and last != c:
            if last:
                s += 1
            break
    print(s)

main()
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
#from numba import njit

def getVar():
    return map(int, input().split())
def getArray():
    return np.array(list(map(int, input().split())))

(X,N) = getVar()
p = getArray()

if (len(p) == 0):
  print(X)
else:
  subp = p - X
  i = 0
  while (True):
    if (not i in subp):
      break
  print(X - i)

Fixed submission:
import numpy as np
#from numba import njit

def getVar():
    return map(int, input().split())
def getArray():
    return np.array(list(map(int, input().split())))

(X,N) = getVar()
p = getArray()

if (len(p) == 0):
  print(X)
else:
  subp = p - X
  i = 0
  while (True):
    if (not -i in subp):
      print(X - i)
      break
    if (not i in subp):
      print(X + i)
      break
    i += 1
Buggy python submission (verdict: Runtime Error):
(A, V) = map(lambda a: double(a), input().split())
(B, W) = map(lambda a: double(a), input().split())
T = double(input())

D = abs(A - B)
X = abs(V - W)

if (X*T >= D):
  print("YES")
else:
  print("NO")



Fixed submission:
(A, V) = map(lambda a: float(a), input().split())
(B, W) = map(lambda a: float(a), input().split())
T = float(input())

D = abs(A - B)
X = V - W

if (X*T >= D):
  print("YES")
else:
  print("NO")

Buggy python submission (verdict: Runtime Error):
(A, V) = input().split()
(B, W) = input().split()
T = input()

D = abs(A - B)
X = abs(x - Y)

if (X*T >= D):
  print("OK")
else:
  print("NG")


Fixed submission:
(A, V) = map(lambda a: float(a), input().split())
(B, W) = map(lambda a: float(a), input().split())
T = float(input())

D = abs(A - B)
X = V - W

if (X*T >= D):
  print("YES")
else:
  print("NO")

Buggy python submission (verdict: Runtime Error):
(A, V) = input().split()
(B, W) = input().split()
T = input()

D = abs(A - B)
X = abs(x - Y)

if X*T >= D:
  print("OK")
else:
  print("NG")

Fixed submission:
(A, V) = map(lambda a: float(a), input().split())
(B, W) = map(lambda a: float(a), input().split())
T = float(input())

D = abs(A - B)
X = V - W

if (X*T >= D):
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
import numpy as np
import math
from decimal import *
#from numba import njit

def getVar():
    return map(int, input().split())
def getArray():
    return list(map(int, input().split()))
def getNumpy():
    return np.array(list(map(int, input().split())), dtype='int64')

def factorization(n):
    d = {}
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            d.append({i, cnt})

    if temp!=1:
        d.append({temp, 1})

    if d==[]:
        d.append({n, 1})

    return d

def main():
    N = int(input())
    d = factorization(N)
    count = 0

    for v in d.values():
        i = 1
        while(v >= i):
            v -= i
            i += 1
            count += 1
        
    print(count)


main()

Fixed submission:
import numpy as np
import math
from decimal import *
#from numba import njit

def getVar():
    return map(int, input().split())
def getArray():
    return list(map(int, input().split()))
def getNumpy():
    return np.array(list(map(int, input().split())), dtype='int64')

def factorization(n):
    d = {}
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            d.update({i: cnt})

    if temp!=1:
        d.update({temp: 1})

    if d==[]:
        d.update({n:1})

    return d

def main():
    N = int(input())
    d = factorization(N)
    count = 0

    for v in d.values():
        i = 1
        while(v >= i):
            v -= i
            i += 1
            count += 1
        
    print(count)


main()

Buggy python submission (verdict: Runtime Error):
import numpy as np
import math
from decimal import *
import sympy
#from numba import njit

def getVar():
    return map(int, input().split())
def getArray():
    return list(map(int, input().split()))
def getNumpy():
    return np.array(list(map(int, input().split())), dtype='int64')

def main():
    N = int(input())
    d = sympy.factorint(N)
    count = 0

    for v in d.values():
        i = 1
        while(v >= i):
            v -= i
            i += 1
            count += 1
        
    print(count)


main()

Fixed submission:
import numpy as np
import math
from decimal import *
#from numba import njit

def getVar():
    return map(int, input().split())
def getArray():
    return list(map(int, input().split()))
def getNumpy():
    return np.array(list(map(int, input().split())), dtype='int64')

def factorization(n):
    d = {}
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            d.update({i: cnt})

    if temp!=1:
        d.update({temp: 1})

    if d==[]:
        d.update({n:1})

    return d

def main():
    N = int(input())
    d = factorization(N)
    count = 0

    for v in d.values():
        i = 1
        while(v >= i):
            v -= i
            i += 1
            count += 1
        
    print(count)


main()
Buggy python submission (verdict: Time Limit Exceeded):
#import numpy as np
import math
#from decimal import *
#from numba import njit
#@njit
def main():
    (N, M, K) = map(int, input().split())

    c = [0]*(K+1)
    def comb(k):
        if k == 0:
            ans = 1
        else:
            ans = c[k-1]*(N-k)//k
        c[k] = ans
        return ans

    ans = 0
    for k in range(K+1):
        ans += (comb(k)*M*pow(M-1, N-k-1, 998244353))%998244353

    print(ans%998244353)

main()


Fixed submission:
#import numpy as np
import math
#from decimal import *
#from numba import njit
#@njit
def main():
    (N, M, K) = map(int, input().split())
    MOD = 998244353
    
    fact = [1]*(N+1)
    factinv = [1]*(N+1)
    for i in range(1,N+1):
        fact[i] = fact[i-1]*i % MOD
        factinv[i] = pow(fact[i], MOD-2, MOD)
    def comb(n, k):
        return fact[n] * factinv[k] * factinv[n-k] % MOD

    ans = 0
    for k in range(K+1):
        ans += (comb(N-1,k)*M*pow(M-1, N-k-1, MOD))%MOD

    print(ans%MOD)

main()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import math
#from decimal import *
#from numba import njit
#@njit
def main():
    (N, M, K) = map(int, input().split())
    MOD = 998244353
    
    c = [0]*(K+1)
    def comb(k):
        if k == 0:
            ans = 1
        else:
            ans = c[k-1]*(N-k)//k
        c[k] = ans
        return ans

    ans = 0
    for k in range(K+1):
        ans += M * comb(k) * pow(M - 1, N - 1 - k, MOD) % MOD
        ans %= MOD

    print(ans)

main()


Fixed submission:
#import numpy as np
import math
#from decimal import *
#from numba import njit
#@njit
def main():
    (N, M, K) = map(int, input().split())
    MOD = 998244353
    
    fact = [1]*(N+1)
    factinv = [1]*(N+1)
    for i in range(1,N+1):
        fact[i] = fact[i-1]*i % MOD
        factinv[i] = pow(fact[i], MOD-2, MOD)
    def comb(n, k):
        return fact[n] * factinv[k] * factinv[n-k] % MOD

    ans = 0
    for k in range(K+1):
        ans += (comb(N-1,k)*M*pow(M-1, N-k-1, MOD))%MOD

    print(ans%MOD)

main()
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
#import math
#from decimal import *
#from numba import njit

#@njit
def main():
    N = int(input())
    A = np.array(list(map(int, input().split())))
    B = np.zeros(N, dtype='int32')
    count = 0
    C = {}
    for i in range(N):
        x = i - A[i]
        cx = C.get(x, ([],[]))
        C[x] = (cx[0], cx[1] + [i])
        x = i + A[i]
        cx = C.get(x, ([],[]))
        C[x] = (cx[0] + [i], cx[1])
    for a,b in C.values():
        count += len(a) * len(b)

    print(count)
main()


Fixed submission:
#import numpy as np
#import math
#from decimal import *
#from numba import njit
from collections import Counter

#@njit
def main():
    N = int(input())
    A = list(map(int, input().split()))
    count = 0
    r = []
    l = []
    for i in range(N):
        r += i - A[i],
        l += i + A[i],

    c = Counter(l)
    for i in r:
        count += c[i]

    print(count)
main()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
#import math
#from decimal import *
#from numba import njit

#@njit
def main():
    N = int(input())
    A = np.array(list(map(int, input().split())))
    B = np.zeros(N, dtype='int32')
    count = 0
    i = 0
    for j in range(i+1, N):
        B[j] = A[i] + A[j] - j
    count += np.count_nonzero(B[i+1:] == 0)
    for i in range(1, N-1):
        count += np.count_nonzero(B[i+1:] == -(-A[0] + A[i] + i))
    print(count)
main()


Fixed submission:
#import numpy as np
#import math
#from decimal import *
#from numba import njit
from collections import Counter

#@njit
def main():
    N = int(input())
    A = list(map(int, input().split()))
    count = 0
    r = []
    l = []
    for i in range(N):
        r += i - A[i],
        l += i + A[i],

    c = Counter(l)
    for i in r:
        count += c[i]

    print(count)
main()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
#import math
#from decimal import *
#from numba import njit

#@njit
def main():
    N = int(input())
    A = np.array(list(map(int, input().split())))
    B = np.zeros(N, dtype='int32')
    count = 0
    i = 0
    for j in range(i+1, N):
        B[j] = A[i] + A[j] - (j - i)
    count += np.count_nonzero(B[i+1:] == 0)
    for i in range(1, N-1):
        B += A[i] - A[i-1] # 身長
        B += 1 # 番号
        count += np.count_nonzero(B[i+1:] == 0)
    print(count)
main()


Fixed submission:
#import numpy as np
#import math
#from decimal import *
#from numba import njit
from collections import Counter

#@njit
def main():
    N = int(input())
    A = list(map(int, input().split()))
    count = 0
    r = []
    l = []
    for i in range(N):
        r += i - A[i],
        l += i + A[i],

    c = Counter(l)
    for i in r:
        count += c[i]

    print(count)
main()