Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
h,w,m = map(int, input().split())
h_t = []
w_t = []
s = []
for i1 in range(h):
  h_t.append(0)
for i2 in range(w):
  w_t.append(0)
for i in range(h):
  s.append([])
  for j in range(w):
    s[i].append(0)
for i3 in range(m):
  hi,wi = map(int, input().split())
  h_t[hi-1] += 1
  w_t[wi-1] += 1
  s[hi-1][wi-1] = 1
hmax = max(h_t)
wmax = max(w_t)
hmaxi = [i for i, v in enumerate(h_t) if v == max(h_t)]
wmaxi = [i for i, v in enumerate(w_t) if v == max(w_t)]
for ht in hmaxi:
  for wt in wmaxi:
    if s[ht][wt] == 0:
      print(hmax + wmax)
      sys.exit()
print(hmax + wmax-1)


Fixed submission:
import sys
h,w,m = map(int, input().split())
h_t = [0 for _ in range(h)]
w_t = [0 for _ in range(w)]
t = []
for _ in range(m):
  hi,wi = map(int, input().split())
  h_t[hi-1] += 1
  w_t[wi-1] += 1
  t.append([hi-1,wi-1])
hmax = max(h_t)
wmax = max(w_t)
hmaxi = [i1 for i1 in range(h) if h_t[i1] == hmax]
wmaxi = [i2 for i2 in range(w) if w_t[i2] == wmax]
c = len(hmaxi)*len(wmaxi)
d = 0
for ht,wt in t:
  if h_t[ht] == hmax:
    if w_t[wt] == wmax:
      d += 1
if c ==d:
  print(hmax + wmax-1)
else:
  print(hmax + wmax)
Buggy python submission (verdict: Runtime Error):
import sys
import math
n,k = map(int,input().split())
a = list(map(int,input().split()))
if k ==0:
  print(max(a))
  sys.exit()
def check(t):
  ans = 0
  if t==0:
    return False
  for aa in a:
    if aa > t:
      ans += aa//t
  return ans <= k
max = 10**9+1
min = 0
while max-min>1:
  mid = (max+min)//2
  if check(mid):
    max = mid
  else:
    min = mid
print(math.ceil(max))

Fixed submission:
x = int(input())
if x >= 30:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
import sys
import math
n,k = map(int,input().split())
a = list(map(int,input().split()))
if k ==0:
  print(max(a))
  sys.exit()
def check(t):
  ans = 0
  for aa in a:
    if aa > t:
      ans += aa//t
  if ans > k:
    return False
  else:
    return True
max = 10**9
min = 0
while max-min>1:
  mid = (max+min)/2
  if check(mid):
    max = mid
  else:
    min = mid
print(math.ceil(max))

Fixed submission:
x = int(input())
if x >= 30:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
i = 1
if k%2 ==1:
    while True:
        s = 0
        for j in range(i):
            s += (10**j)*7
        if s % k == 0:
            print(i)
            break
        i += 1
else:
    print(-1)

Fixed submission:
import sys
k = int(input())
d = 0
for i in range(k+1):
  d = (10*d) + 7
  d %= k
  if d == 0:
    print(i+1)
    sys.exit()
print(-1)

Buggy python submission (verdict: Runtime Error):
k = int(input())
i = 1
if a%2 ==1:
    while True:
        s = 0
        for j in range(i):
            s += (10**j)*7
        if s % k == 0:
            print(i)
            break
        i += 1
else:
    print(-1)

Fixed submission:
import sys
k = int(input())
d = 0
for i in range(k+1):
  d = (10*d) + 7
  d %= k
  if d == 0:
    print(i+1)
    sys.exit()
print(-1)
Buggy python submission (verdict: Runtime Error):
wa = 0
tle = 0
re  = 0
for i in range(n):
  s = input()
  if s =="AC":
    ac += 1
  elif s == "WA":
    wa += 1
  elif s == "TLE":
    tle += 1
  elif s == "RE":
    re += 1
print("AC x "+str(ac))
print("WA x "+str(wa))
print("TLE x "+str(tle))
print("RE x "+str(re))

Fixed submission:
n = int(input())
ac = 0
wa = 0
tle = 0
re  = 0
for i in range(n):
  s = input()
  if s =="AC":
    ac += 1
  elif s == "WA":
    wa += 1
  elif s == "TLE":
    tle += 1
  elif s == "RE":
    re += 1
print("AC x "+str(ac))
print("WA x "+str(wa))
print("TLE x "+str(tle))
print("RE x "+str(re))
Buggy python submission (verdict: Runtime Error):
a,b,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
cheap = min(a) + min(b)
for _ in range(m):
  x,y,c = map(int,input().split())
  cheap = min(a[x-1]+b[x-1]-c,cheap)
print(cheap)

Fixed submission:
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
z = [list(map(int, input().split())) for i in range(M)]

price = min(a) + min(b)

for e in z:
    tmp_price = a[e[0]-1] + b[e[1]-1] - e[2]

    if(price > tmp_price):
        price = tmp_price

print(price)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = list(map(int,input().split()))
mint = 0
x.sort()
mid = int((x[0]+x[-1])/2)

def kyori(p):
  m = 0
  for i in range(n):
    m += (p-x[i])**2
  return m
while True:
  midplus = mid - 1
  midminus = mid + 1
  if kyori(mid) > kyori(midplus):
    mid = int((mid+midplus)/2)
  elif kyori(mid) > kyori(midminus):
    mid = int((mid+midminus)/2)
  else:
    break
print(kyori(mid))

Fixed submission:
n = int(input())
x = list(map(int,input().split()))
k = []
def kyori(p):
  m = 0
  for i in range(n):
    m += (p-x[i])**2
  return m
for i in range(1,101):
  k.append(kyori(i))

print(min(k))
Buggy python submission (verdict: Runtime Error):
    import math
    S = list(input())
    K = int(input())
    s = S * 2
    c1 = 0
    c2 = 0
    for i in range(len(s)-1):
        if s[i+1] == s[i]:
            if i < len(S)-1:
                c1 += 1
            c2 += 1
            s[i+1] = 0
    c = S[0]
    for s in S:
        if s != c:
            print(c1+(c2-c1)*(K-1))
            exit()
    print(math.floor(len(S)*K/2))

import math
S = list(input())
K = int(input())
s = S * 2
c1 = 0
c2 = 0
for i in range(len(s)-1):
    if s[i+1] == s[i]:
        if i < len(S)-1:
            c1 += 1
        c2 += 1
        s[i+1] = 0
c = S[0]
for s in S:
    if s != c:
        print(c1+(c2-c1)*(K-1))
        exit()
print(math.floor(len(S)*K/2))

Fixed submission:
import math
S = list(input())
K = int(input())
s = S * 2
c1 = 0
c2 = 0
for i in range(len(s)-1):
    if s[i+1] == s[i]:
        if i < len(S)-1:
            c1 += 1
        c2 += 1
        s[i+1] = 0
c = S[0]
for s in S:
    if s != c:
        print(c1+(c2-c1)*(K-1))
        exit()
print(math.floor(len(S)*K/2))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = 1
B = 1
p = 0

while A < N:
  while A * B < N:
    p += 1
    B += 1
  A += 1
  B = 1

print(p)

Fixed submission:
N = int(input())
A = 1
B = 1
d = 0
e = 0

while A < N:
  while A * B < N:
    if A == B:
      e += 1
    else:
      d += 1
    B += 1
  A += 1
  B = A

print(d*2+e)
Buggy python submission (verdict: Runtime Error):
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    def group_count(self):
        return len(self.roots())
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

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

uf = UnionFind(N)
for a,b in AB:
    uf.union(a,b)

print(uf.group_count() - 1)

Fixed submission:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    def group_count(self):
        return len(self.roots())
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

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

uf = UnionFind(N)
for a,b in AB:
    uf.union(a-1,b-1)

print(uf.group_count() - 1)
Buggy python submission (verdict: Time Limit Exceeded):
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    def group_count(self):
        return len(self.roots())
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
    
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(M)]

uf = UnionFind(N)
for i in range(M):
    uf.union(AB[i][0]-1,AB[i][1]-1)
agm = uf.all_group_members()
ufr = uf.roots()
ans = 0
for i in ufr:
    ans = max(ans,len(agm[i]))
print(ans)

Fixed submission:
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    def group_count(self):
        return len(self.roots())
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
    
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(M)]

uf = UnionFind(N)
for i in range(M):
    uf.union(AB[i][0]-1,AB[i][1]-1)
ufr = uf.roots()
ans = 0
for i in ufr:
    ans = max(ans,uf.size(i))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
ans = 1
tmp = 7
if K % 2 == 0 or K % 5 == 0:
    print(-1)
else:
    x = (9/7) * K + 1
    ans = 0
    while x != 1:
        x /= 10
        ans += 1
    print(ans)

Fixed submission:
k=int(input())
a=7
for i in range(10**6):
    if a%k==0:
        print(i+1)
        exit()
    a=(a*10+7)%k
print(-1)
Buggy python submission (verdict: Runtime Error):
T = list(input())

if T[0] == '?':
    if T[1] == 'D' or T[1] == '?':
        T[0] = 'P'
    if T[1] == 'P':
        T[0] = 'D'

for i in range(len(T)-1):
    if T[i] == '?':
        if T[i+1] == 'D' and T[i-1] == 'P':
            T[i] = 'D'
        if T[i+1] == 'D' and T[i-1] == 'D':
            T[i] = 'P'
        if T[i+1] == 'P':
            T[i] = 'D'
        if T[i+1] == '?' and T[i-1] == 'P':
            T[i] = 'D'
        if T[i+1] == '?' and T[i-1] == 'D':
            T[i] = 'P'

if T[-1] == '?':
    T[-1] = 'D'

ans = ''.join(T)
print(ans)

Fixed submission:
T = list(input())

if len(T) == 1:
    if T[0] == '?':
        T[0] = 'D'

else:
    if T[0] == '?':
        if T[1] == 'D' or T[1] == '?':
            T[0] = 'P'
        if T[1] == 'P':
            T[0] = 'D'

    for i in range(len(T)-1):
        if T[i] == '?':
            if T[i+1] == 'D' and T[i-1] == 'P':
                T[i] = 'D'
            if T[i+1] == 'D' and T[i-1] == 'D':
                T[i] = 'P'
            if T[i+1] == 'P':
                T[i] = 'D'
            if T[i+1] == '?' and T[i-1] == 'P':
                T[i] = 'D'
            if T[i+1] == '?' and T[i-1] == 'D':
                T[i] = 'P'

    if T[-1] == '?':
        T[-1] = 'D'

ans = ''.join(T)
print(ans)

Buggy python submission (verdict: Runtime Error):
T = list(input())

if T[0] == '?':
    if T[1] == 'D' or T[1] == '?':
        T[0] = 'P'
    if T[1] == 'P':
        T[0] = 'D'

for i in range(len(T)-1):
    if T[i] == '?':
        if T[i+1] == 'D':
            T[i] = 'P'
        if T[i+1] == 'P':
            T[i] = 'D'
        if T[i+1] == '?' and T[i-1] == 'P':
            T[i] = 'D'
        if T[i+1] == '?' and T[i-1] == 'D':
            T[i] = 'P'
if T[-1] == '?':
    T[-1] = 'D'

ans = ''.join(T)
print(ans)

Fixed submission:
T = list(input())

if len(T) == 1:
    if T[0] == '?':
        T[0] = 'D'

else:
    if T[0] == '?':
        if T[1] == 'D' or T[1] == '?':
            T[0] = 'P'
        if T[1] == 'P':
            T[0] = 'D'

    for i in range(len(T)-1):
        if T[i] == '?':
            if T[i+1] == 'D' and T[i-1] == 'P':
                T[i] = 'D'
            if T[i+1] == 'D' and T[i-1] == 'D':
                T[i] = 'P'
            if T[i+1] == 'P':
                T[i] = 'D'
            if T[i+1] == '?' and T[i-1] == 'P':
                T[i] = 'D'
            if T[i+1] == '?' and T[i-1] == 'D':
                T[i] = 'P'

    if T[-1] == '?':
        T[-1] = 'D'

ans = ''.join(T)
print(ans)
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(M)]

ans = [-1] * (N+1)
graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

for i in range(N+1):
    graph[i].sort()
    
from collections import deque
todo = deque([(1,0)])
while todo:
    x,parent = todo.pop()
    ans[x] = parent
    for y in graph[x]:
        if y == parent:
            continue
        if ans[y] == -1:
            todo.append((y,x))
print('Yes')
for i in range(2,N+2):
    print(ans[i])

Fixed submission:
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(M)]
 
ans = [-1] * (N+1)
graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)
    

from collections import deque
import sys
ans = [-1] * (N+1)
todo = deque([(1,0)])
while todo:
    x,parent = todo.popleft()
    # ans[x] = parent
    for y in graph[x]:
        if y == parent:
            continue
        if ans[y] != -1:
            continue
        ans[y] = x
        todo.append((y,x))
        

if -1 in ans[2:]:
    print('No')
else:
    print('Yes')
    for i in range(2,N+1):
        print(ans[i])

Buggy python submission (verdict: Runtime Error):
ans = [-1] * (N+1)
graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

for i in range(N+1):
    graph[i].sort()
    
from collections import deque
todo = deque([(1,0)])
while todo:
    x,parent = todo.pop()
    ans[x] = parent
    for y in graph[x]:
        if y == parent:
            continue
        if ans[y] == -1:
            todo.append((y,x))
print('Yes')
for i in range(2,N+2):
    print(ans[i])

Fixed submission:
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(M)]
 
ans = [-1] * (N+1)
graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)
    

from collections import deque
import sys
ans = [-1] * (N+1)
todo = deque([(1,0)])
while todo:
    x,parent = todo.popleft()
    # ans[x] = parent
    for y in graph[x]:
        if y == parent:
            continue
        if ans[y] != -1:
            continue
        ans[y] = x
        todo.append((y,x))
        

if -1 in ans[2:]:
    print('No')
else:
    print('Yes')
    for i in range(2,N+1):
        print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
H = list(map(int,input().split()))
AB = [list(map(int,input().split())) for i in range(M)]

graph={}
for i in range(1,N+1):
    graph[i]=[]
    for j in range(M):
        if AB[j][0]==i:
            graph[i].append(H[AB[j][1]-1])
        if AB[j][1]==i:
            graph[i].append(H[AB[j][0]-1])

ans = 0
for i in range(1,N+1):
    tmp = graph[i]
    if len(graph[i]) == 0:
        ans+=1
    else:
        mh = max(graph[i])
        if H[i-1] > mh:
            ans += 1
        else:
            continue
print(ans)

Fixed submission:
N,M = map(int,input().split())
H = list(map(int,input().split()))
AB = [list(map(int,input().split())) for i in range(M)]

ans = [0] * N
for i in range(M):
    if H[AB[i][0]-1] > H[AB[i][1]-1]:
        ans[AB[i][1]-1] += 1
    if H[AB[i][0]-1] < H[AB[i][1]-1]:
        ans[AB[i][0]-1] += 1
    if H[AB[i][0]-1] == H[AB[i][1]-1]:
        ans[AB[i][0]-1] += 1
        ans[AB[i][1]-1] += 1
print(ans.count(0))

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

graph={}
for i in range(1,N+1):
    graph[i]=[]
    for j in range(M):
        if AB[j][0]==i:
            graph[i].append(H[AB[j][1]-1])
        if AB[j][1]==i:
            graph[i].append(H[AB[j][0]-1])

ans = 0
for i in range(1,N+1):
    tmp = graph[i]
    if len(graph[i]) == 0:
        ans+=1
    else:
        mh = max(graph[i])
        if H[i-1] > mh:
            ans += 1
        else:
            continue
print(ans)

Fixed submission:
N,M = map(int,input().split())
H = list(map(int,input().split()))
AB = [list(map(int,input().split())) for i in range(M)]

ans = [0] * N
for i in range(M):
    if H[AB[i][0]-1] > H[AB[i][1]-1]:
        ans[AB[i][1]-1] += 1
    if H[AB[i][0]-1] < H[AB[i][1]-1]:
        ans[AB[i][0]-1] += 1
    if H[AB[i][0]-1] == H[AB[i][1]-1]:
        ans[AB[i][0]-1] += 1
        ans[AB[i][1]-1] += 1
print(ans.count(0))
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=list(map(int,input().split()))
import collections as col

for i in range(N):
    ans=0
    k=A[:i]+A[i+1:]
    sk=set(k)
    ck=col.Counter(k)
    for i in sk:
        if ck[i]==1:
            continue
        else:
            ans += (ck[i]*(ck[i]-1))//2
    print(ans)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
import collections as col

sa=set(A)
ca=col.Counter(A)
num=0
for i in sa:
    if ca[i]==1:
        continue
    else:
        num += (ca[i]*(ca[i]-1))//2
for i in A:
    ans = num - (ca[i]-1)
    print(ans)
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
def B(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
print(len(B(N,K)))

Fixed submission:
N,K=map(int,input().split())
def B(X, n):
    if (int(X/n)):
        return B(int(X/n), n)+str(X%n)
    return str(X%n)
print(len(B(N,K)))
Buggy python submission (verdict: Runtime Error):
N=int(input())
X=list(map(int,input().split()))
i=1
XT=list(map(tairyoku,X))
ans=sum(XT)
for i in range(2,101):
    XT=list(map(tairyoku,X))
    ans=min(ans,sum(XT))
print(ans)

Fixed submission:
N=int(input())
X=list(map(int,input().split()))
def tairyoku(n):
    return (n-i)**2
i=1
XT=list(map(tairyoku,X))
ans=sum(XT)
for i in range(2,101):
    XT=list(map(tairyoku,X))
    ans=min(ans,sum(XT))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
p=list(map(int,input().split()))
k=[0]*(N-K+1)
for i in range(N-K+1):
    k[i]=sum(p[i:i+K])
print((max(k)+K)/2)

Fixed submission:
N,K=map(int,input().split())
p=list(map(int,input().split()))
a=sum(p[0:K])
k=[a]+[0]*(N-K)
for i in range(N-K):
    a=a-p[i]+p[K+i]
    k[i+1]=a
print((max(k)+K)/2)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
P=list(map(int,input().split()))
ans=1
for i in range(1,N):
    if P[i]<=min(P[:i]):
        ans+=1
print(ans)

Fixed submission:
N=int(input())
P=list(map(int,input().split()))
ans=1
minP=P[0]
for i in range(1,N):
    if minP>=P[i]:
        ans+=1
        minP=P[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
N=int(input())
for i in reversed(range(int(math.sqrt(N)))):
    if N % i == 0:
        a=i
        break
print(int(a+int(N/a)-2))

Fixed submission:
N=int(input())
for i in reversed(range(int(N**0.5)+1)):
    if N % i == 0:
        print(int(i+N//i-2))
        break

Buggy python submission (verdict: Runtime Error):
N=int(input())
for i in reversed(range(int(N**0.5))):
    if N % i == 0:
        a=i
        break
print(int(a+int(N/a)-2))

Fixed submission:
N=int(input())
for i in reversed(range(int(N**0.5)+1)):
    if N % i == 0:
        print(int(i+N//i-2))
        break

Buggy python submission (verdict: Runtime Error):
N=int(input())
for i in reversed(range(int(N**0.5))):
    if N % i == 0:
        a=i
        break
print(int(a+(N/a)-2))

Fixed submission:
N=int(input())
for i in reversed(range(int(N**0.5)+1)):
    if N % i == 0:
        print(int(i+N//i-2))
        break

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

N=int(input())
for i in range(int(math.sqrt(N)),N):
    if N % i == 0:
        a=i
        break
print(int(a+(N/a)-2))

Fixed submission:
N=int(input())
for i in reversed(range(int(N**0.5)+1)):
    if N % i == 0:
        print(int(i+N//i-2))
        break
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
ans =[]
for i in range(1,N+1):
    AN = A.index(i)
    ans.append(AN+1)
ans2 = [str(ans[i]) for i in range(len(ans))]
print(" ".join(ans2))

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
AN = list(enumerate(A))
sAN = sorted(AN, key=lambda x: x[1])
ans = []
for i in range(N):
    ans.append(sAN[i][0]+1)
ans2 = [str(ans[i]) for i in range(len(ans))]
print(" ".join(ans2))
Buggy python submission (verdict: Time Limit Exceeded):
n,k,q = list(map(int,input().split()))
a = [int(input()) for i in range(q)]

for i in range(1,n+1):
    if k - (q - a.count(i)) > 0:
        print('Yes')
    else:
        print('No')

Fixed submission:
n,k,q = list(map(int,input().split()))
a = [int(input()) for i in range(q)]
np = [0]*n

for i in range(q):
    np[a[i]-1] += 1

for i in range(n):
    if k- (q - np[i]) >= 1:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
HL = list(map(int,input().split()))
HL.append(10**9+1)  #HLの最後に(最大値+1)をappend
cnt = 0
tmp_c = 0

for i in range(N):
    if HL[i] >= HL[i+1]:
        tmp_c += 1
    else:
        if cnt <= tmp_c:
            cnt = tmp_c
            tmp_c = 0
        else:
            tmp_c = 0

print(cnt)

Fixed submission:
S = input()
T = input()
ans = 0

if S[0] == T[0]:
    ans += 1
if S[1] == T[1]:
    ans += 1
if S[2] == T[2]:
    ans += 1

print(ans)