Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
h , w = map(int,input().split())
lis = []
for i in range(w):
    lis.append(input())
print('#'*(w+2))
for i in range(h):
    print('#'+lis[i]+'#')
print('#'*(w+2))

Fixed submission:
h , w = map(int,input().split())
lis = []
for i in range(h):
    lis.append(input())
print('#'*(w+2))
for i in range(h):
    print('#'+lis[i]+'#')
print('#'*(w+2))
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
if a + b < 24:
    print(a + b)
    else:
    print(a + b -24)

Fixed submission:
a,b = map(int,input().split())
if a + b < 24:
    print(a + b)
else:
    print(a + b -24)
Buggy python submission (verdict: Runtime Error):
x = int(input())
for i in range(x):
    if i*(i+1)/2 >= x:
        ans =i
        break 
    else:
        continue
print(ans)

Fixed submission:
from math import ceil
x = int(input())
ans = ceil(((1+8*x)**.5 -1)/2)
print(ans)

Buggy python submission (verdict: Runtime Error):
x = int(input())
for i in range(x):
    if i*(i+1)/2 > x:
        ans =i
        break 
    else:
        continue
print(ans)

Fixed submission:
from math import ceil
x = int(input())
ans = ceil(((1+8*x)**.5 -1)/2)
print(ans)

Buggy python submission (verdict: Runtime Error):
# t を前から試してｘ以下か判定する
x = int(input())
for i in range(x):
    if i*(i+1)/2 > x:
        ans =i
        break 
print(ans)

Fixed submission:
from math import ceil
x = int(input())
ans = ceil(((1+8*x)**.5 -1)/2)
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, c = map(int,input(),split())
if c == a + b:
    print("Yes")
if b == a + c:
    print("Yes")
if a == b + c:
    print("Yes")
else:
    print("No")

Fixed submission:
a,b,c = map(int,input().split())
if c == a+b or b == a+c or a == b+c:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N, K = map(int,input().split())
print(K*(K-1)**(N-1))


Fixed submission:
mylist = input().split()
print(len(set(mylist)))

Buggy python submission (verdict: Runtime Error):
N, K = map(int,input().split())
print(K * ((K-1)**(N-1)))

Fixed submission:
mylist = input().split()
print(len(set(mylist)))

Buggy python submission (verdict: Runtime Error):
N, K = map(int,input().split())
print(int(K * ((K-1)**(N-1))))

Fixed submission:
mylist = input().split()
print(len(set(mylist)))

Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
print(int(K * ((K-1) ** (N-1))))

Fixed submission:
mylist = input().split()
print(len(set(mylist)))

Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
print(K * ((K-1) ** (N-1)))


Fixed submission:
mylist = input().split()
print(len(set(mylist)))
Buggy python submission (verdict: Runtime Error):
N, K = [int(input()) for _ in range(2)]
A =int((K - 1) ** N)
print(int(A * K))
 

Fixed submission:
N, K = map(int,input().split())
print(K*(K-1)**(N-1))
Buggy python submission (verdict: Runtime Error):
S = dict()
S['A'] = list(input())[::-1]
S['B'] = list(input())[::-1]
S['C'] = list(input())[::-1]

print(S)
player = 'a'

while S[player]:
    player = S[player].pop() 

ans = player.upper()
print(ans)

Fixed submission:
S = dict()
S['a'] = list(input())[::-1]
S['b'] = list(input())[::-1]
S['c'] = list(input())[::-1]

player = 'a'

while S[player]:
    player = S[player].pop() 

ans = player.upper()
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
k = int(input())
x = int(input())
y = int(input())
if n =< k:
    answer = k * x
else: 
    answer = (n-k) * y + int(answer)

print(answer) 

Fixed submission:
n = int(input())
k = int(input())
x = int(input())
y = int(input())
if n <= k:
    answer = n * x
else: 
    answer = (n-k) * y + k*x

print(answer)

Buggy python submission (verdict: Runtime Error):
n = int(input())
k = int(input())
x = int(input())
y = int(input())
if n =< K:
    answer = k * x
    else answer = k * y:
print answer 

Fixed submission:
n = int(input())
k = int(input())
x = int(input())
y = int(input())
if n <= k:
    answer = n * x
else: 
    answer = (n-k) * y + k*x

print(answer)
Buggy python submission (verdict: Runtime Error):
x = 0
y = 1
n = int(input())
if y <= n:
    for y in range(1,n+1):
    x = x + y
    print(x)
    y = y + 1
    

Fixed submission:
m = int(input())
result = 0
for i in range(1, m+1):
    result += i
print(result)

Buggy python submission (verdict: Runtime Error):
N = int(input())
result = 0
for i in range(1, N+1)
    result += i
print(result)

Fixed submission:
m = int(input())
result = 0
for i in range(1, m+1):
    result += i
print(result)
Buggy python submission (verdict: Runtime Error):
price = int(input())

comma_price = math.ceil(price / 1000)
comma_price *= comma_price

print(comma_price - price)


Fixed submission:
import math
price = int(input())
 
comma_price = math.ceil(price / 1000)
comma_price *= 1000
 
print(comma_price - price)
Buggy python submission (verdict: Time Limit Exceeded):
N = input()
A = tuple(map(int,input().split()))
N = 1
for i in range(len(A)):
    N *= A[i]

if N <= 10**18:
    print(N)
else:
    print(-1)

Fixed submission:
n = input()
A = list(map(int,input().split()))
m = 1

if 0 in A :
    print(0)
    exit()
for i in A:
    m*= i
    if m > 10**18:
        print(-1)
        exit()
print(m)

Buggy python submission (verdict: Time Limit Exceeded):
N = input()
A = list(map(int,input().split()))
N = 1
for i in range(len(A)):
    N *= A[i]

if N <= 10**18:
    print(N)
else:
    print(-1)

Fixed submission:
n = input()
A = list(map(int,input().split()))
m = 1

if 0 in A :
    print(0)
    exit()
for i in A:
    m*= i
    if m > 10**18:
        print(-1)
        exit()
print(m)
Buggy python submission (verdict: Runtime Error):
[a,b] = list(map(str,input().split()))
b.rstrip(".")
print((a*b)//100)


Fixed submission:
[a,b] = list(map(str,input().split()))
b = b[:1] + b[2:]
print((int(a)*int(b))//100)
Buggy python submission (verdict: Runtime Error):
N = input()
if N = "ABC" :
  print("ARC")
elif N = "ARC" :
  print("ABC")

Fixed submission:
N = input()
if N == "ABC" :
  print("ARC")
elif N == "ARC" :
  print("ABC")
Buggy python submission (verdict: Runtime Error):
from math import atan,degrees
a,b,x=map(int,input().split())
aab2 = a * a * b /2
if x >= aab2:
  print(90-degrees(atan(a/(b-2 *(x-aab2)/(a*a)))))
else:
  print(90-degrees(atan((2*x/(a*b)/b))))

Fixed submission:
from math import atan,degrees
a,b,x=map(int,input().split())
aab2 = a * a * b /2
if a*a*b==x:
  print(0)
elif x >= aab2:
  print(90-degrees(atan(a/(b-2 *(x-aab2)/(a*a)))))
else:
  print(90-degrees(atan((2*x/(a*b)/b))))
Buggy python submission (verdict: Runtime Error):
a,k=map(int,input().split())
L=list(map(int,input().split()))
ans=0

for i in range(min(k,n)+1):
  for j in range(min(k,n)-i+1):
    S=[0]+L[:i]+L[a-j:]
    S.sort()
    x=0
    while x < k-(j+i):
      if S[x]>=0:
        break
      x+=1
    ans=max(ans,sum(S)-sum(S[:x]))
    
print(ans)


Fixed submission:
a,k=map(int,input().split())
L=list(map(int,input().split()))
ans=0

for i in range(min(k,a)+1):
  for j in range(min(k,a)-i+1):
    S=[0]+L[:i]+L[a-j:]
    S.sort()
    x=0
    while x < k-(j+i):
      if S[x]>=0:
        break
      x+=1
    ans=max(ans,sum(S)-sum(S[:x]))
    
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 find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(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

n,m=map(int,input().split())
U=UnionFind(n)

for i in range(m):
  x,y,z=map(int,input().split())
  U.union(x-1,y-1)
ans=0
for i,j in enamurate(U.par):
  if i==j:
    ans+=1
print(ans)


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

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

    def union(self, x, y):
        x = self.find(x)
        y = self.find(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

n,m=map(int,input().split())
U=UnionFind(n)

for i in range(m):
  x,y,z=map(int,input().split())
  U.union(x-1,y-1)
ans=0
for i,j in enumerate(U.par):
  if i==j:
    ans+=1
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 find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(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

n,m=map(int,input().split())
U=UnionFind(n)

for i in range(m):
  x,y,z=map(int,input().split())
  U.union(x-1,y-1)
ans=0
for i,j in ensmurate(U.par):
  if i==j:
    ans+=1
print(ans)


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

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

    def union(self, x, y):
        x = self.find(x)
        y = self.find(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

n,m=map(int,input().split())
U=UnionFind(n)

for i in range(m):
  x,y,z=map(int,input().split())
  U.union(x-1,y-1)
ans=0
for i,j in enumerate(U.par):
  if i==j:
    ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
print([i for i in range(1,min([a,b])+1) if i%a==0 and i%b==0][-k])

Fixed submission:
a,b,k=map(int,input().split())
print([i for i in range(1,min([a,b])+1) if a%i==0 and b%i==0][-k])

Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
print([i for i in range(min([a,b])) if i%a==0 and i%b==0][-k])

Fixed submission:
a,b,k=map(int,input().split())
print([i for i in range(1,min([a,b])+1) if a%i==0 and b%i==0][-k])

Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
print([i for i in range(min(a,b)) if i%a==0 and i%b==0][-k])

Fixed submission:
a,b,k=map(int,input().split())
print([i for i in range(1,min([a,b])+1) if a%i==0 and b%i==0][-k])
Buggy python submission (verdict: Runtime Error):
a=int(input())
s=set(a)
i=1
while True:
  if a % 2==1:
    a = a * 3 + 1
  else:
    a = a//2
    
  if a in s:
    break
  s|={a}
  i+=1
print(i)

Fixed submission:
a=int(input())
s={a}
i=1
while True:
  i+=1
  if a % 2==1:
    a = a * 3 + 1
  else:
    a = a//2
    
  if a in s:
    break
  s|={a}
print(i)

Buggy python submission (verdict: Runtime Error):
a=int(input())
s=set(a)
i=1
while True:
  if a % 2==1:
    a = a * 3 + 1
  else:
    a = a//2
    
  if a in s:
    break
  s|=｛a｝
  i+=1
print(i)

Fixed submission:
a=int(input())
s={a}
i=1
while True:
  i+=1
  if a % 2==1:
    a = a * 3 + 1
  else:
    a = a//2
    
  if a in s:
    break
  s|={a}
print(i)
Buggy python submission (verdict: Runtime Error):
print('YES' if input().split().sort()==['1','4','7','9'])

Fixed submission:
print('YES' if sorted(input().split())==['1','4','7','9'] else 'NO')
Buggy python submission (verdict: Runtime Error):
import numpy as np
IN() = lambda:map(int, input().split())

n,k = IN()
dp = np.full(n*1000+1, k+1, dtype=int)
dp[0] = 0

for _ in range(n):
  w,v = IN()
  dp[v:] = np.minimum(dp[:-v]+w, dp[v:])

print(np.max(np.where(dp <= k)))


Fixed submission:
import numpy as np
IN = lambda:map(int, input().split())

n,k = IN()
dp = np.full(n*1000+1, k+1, dtype=int)
dp[0] = 0

for _ in range(n):
  w,v = IN()
  dp[v:] = np.minimum(dp[:-v]+w, dp[v:])

print(np.max(np.where(dp <= k)))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n=int(input())
P=np.array(list(map(float,input().split())))
DP=np.zeros(n+1)
DP[0]=1.0

for i in range(n):
  D=np.zeros(n+1)
  p=P[i]
  for j in range(i+2):
    D[j] = DP[j-1] * p + DP[j] * (1-p)
  DP=D
print(sum(DP[n//2+1:]))

Fixed submission:
import numpy as np
n=int(input())
P=np.array(list(map(float,input().split())))
DP=np.zeros(n+1)
DP[0]=1.0

for i in range(n):
  DP = np.roll(DP * P[i], 1) + DP * (1-P[i])
print(sum(DP[n//2+1:]))
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[int(input()) for i in n]
print(sum(a)-max(a)/2)

Fixed submission:
n=range(int(input()))
a=[int(input()) for i in n]
print(sum(a)-max(a)//2)
Buggy python submission (verdict: Runtime Error):
from collections import Counter
import math
def P(n, r):
  return math.factorial(n)//math.factorial(n-r)
def C(n, r):
  return P(n, r)//math.factorial(r)
n=int(input())
L=[]
for j in range(2,n+1):
    I=j
    s=0
    R=int(I)
    while s==0:
        for i in range(2,R+1):
            if I%i==0:
                I=I/i
                if I==1:
                    s=1
                L.append(i)
                break
c=Counter(L)
c=[0 for i in range(100)]
for i,j in c.most_common():
  c[j]+=1
 
s=0
s+=sum(c[4:])*(sum(c[4:])-1)*sum(c[2:]-2)//2
s+=sum(c[14:])*(sum(c[4:])-1)
s+=sum(c[24:])*(sum(c[2:])-1)
s+=sum(c[74:])
print(s)

Fixed submission:
from collections import Counter
import math
def P(n, r):
  return math.factorial(n)//math.factorial(n-r)
def C(n, r):
  return P(n, r)//math.factorial(r)
n=int(input())
L=[]
for j in range(2,n+1):
    I=j
    s=0
    R=int(I)
    while s==0:
        for i in range(2,R+1):
            if I%i==0:
                I=I/i
                if I==1:
                    s=1
                L.append(i)
                break
C=Counter(L)
c=[0 for i in range(100)]
for i,j in C.most_common():
  c[j]+=1
 
s=0
s+=sum(c[4:])*(sum(c[4:])-1)*(sum(c[2:])-2)//2
s+=sum(c[14:])*(sum(c[4:])-1)
s+=sum(c[24:])*(sum(c[2:])-1)
s+=sum(c[74:])
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
if n<=2:
  while True:
    w=1
  
  exit()
a=1
while ((a+1)*(a+2))//2<=n:
  if n==((a+1)*(a+2))//2:
    print('Yes')
    x=a+2
    print(x)
    break
  a+=1
else:
  print('No')
  exit()
b=[]
for i in range(1,n+1):
  b+=[i]
b=b+b

l=[[] for i in range(x)]
for i in range(x):
  if i==0:
    for j in range(x-1):
      l[i].append(b.pop())
    print(x-1,*l[i])
  else:
    for j in range(i):
      l[i].append(l[j].pop())
    for j in range(x-1-i):
      l[i].append(b.pop())
    print(x-1,*l[i])

Fixed submission:
n=int(input())
if n==1:
  print('Yes')
  print('2')
  print('1 1')
  print('1 1')
  exit()
a=1
while ((a+1)*(a+2))//2<=n:
  if n==((a+1)*(a+2))//2:
    print('Yes')
    x=a+2
    print(x)
    break
  a+=1
else:
  print('No')
  exit()
b=[]
for i in range(1,n+1):
  b+=[i]
b=b+b

l=[[] for i in range(x)]
for i in range(x):
  if i==0:
    for j in range(x-1):
      l[i].append(b.pop())
    print(x-1,*l[i])
  else:
    for j in range(i):
      l[i].append(l[j].pop())
    for j in range(x-1-i):
      l[i].append(b.pop())
    print(x-1,*l[i])
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
def lcm(x, y):
  return (x * y) // gcd(x, y)
n,m=map(int,input().split())
x=lcm(n,m)
y=x//gcd(n,m)
a=input()
b=input()

for i in range(x):
  if i==0:
    if a[0] !=b[0]:
      print(-1)
      exit()
  elif i % y ==0:
    if a[i//(x//n)] !=b[i//(x//m)]:
      print(-1)
      exit()
print(x)

Fixed submission:
from fractions import gcd
def lcm(x, y):
  return (x * y) // gcd(x, y)
n,m=map(int,input().split())
x=lcm(n,m)
y=x//gcd(n,m)
a=input()
b=input()

for i in range(x//y):
  if a[(x//m)*i] != b[(x//n)*i]:
    print(-1)
    exit()
print(x)
Buggy python submission (verdict: Runtime Error):
I=lambda:map(int,input())
n,k=I()
s=1001
for i in range(n):
  a,b=I()
  if b<=k:
    s=min(s,a)
if s==1001:
  print('TLE')
else:
  print(s)

Fixed submission:
I=lambda:map(int,input().split())
n,k=I()
s=1001
for i in range(n):
  a,b=I()
  if b<=k:
    s=min(s,a)
if s==1001:
  print('TLE')
else:
  print(s)
Buggy python submission (verdict: Runtime Error):
r = range(int(input()))
p = [[int(i) for i in input().split()] for _ in r]

a,b,c = p[0]
for x in range(101):
  for y in range(101):
    h = c+abs(a-x)+abs(b-y)
	if all(k==h-abs(i-x)-abs(j-y) for i,j,k in p):
      print(x,y,h)
      exit()

Fixed submission:
r=range(int(input()))
p=[[int(i)for i in input().split()] for _ in r]
p.sort(key=lambda x: x[2])
a,b,c=p[-1]
for x in range(101):
  for y in range(101):
    h=c+abs(a-x)+abs(b-y)
    if all(k==max(h-abs(i-x)-abs(j-y),0) for i,j,k in p):
      print(x,y,h)
      exit()
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
i=2
s=[]
while 1<m:
  j=0
  while m % (i**(j+1))==0:
    j+=1
  if j:
    m//=i**j
    s+=[j]
  i+=1
a=1
for v in s:
  c = 1
  for i in range(v):
    c = c * (n+i) // (1+i)
  a = a * c % (10**9+7)
print(a)


Fixed submission:
n,m=map(int,input().split())
i=2
s=[]
while i*i<=m:
  j=0
  while m % i == 0:
    m//=i
    j+=1 
  if j:
    s+=[j]
  i+=1
a=1
if m > 1:
  s+=[1]
  
for v in s:
  c = 1
  for i in range(v):
    c = c * (n+i) // (1+i)
  a = a * c % (10**9+7)
print(a)

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
i=2
s={}
while 1<m:
  j=0
  while m % (i**(j+1))==0:
    j+=1
  if j:
    m//=i**j
    s[i]=j
  i+=1
a=1
for v in s.values():
  c = 1
  for i in range(v):
    c = c * (n+i) // (1+i)
  a = a * c % (10**9+7)
print(a)


Fixed submission:
n,m=map(int,input().split())
i=2
s=[]
while i*i<=m:
  j=0
  while m % i == 0:
    m//=i
    j+=1 
  if j:
    s+=[j]
  i+=1
a=1
if m > 1:
  s+=[1]
  
for v in s:
  c = 1
  for i in range(v):
    c = c * (n+i) // (1+i)
  a = a * c % (10**9+7)
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n,m,q=map(int,input().split())
a=np.zeros((n+2,n+2))
for i in range(m):
  s,e=map(int,input().split())
  a[:s+1,e]+=1
b=a.cumsum(1)
for i in range(q):
  s,e=map(int,input().split())
  print(int(b[s,e]))


Fixed submission:
import numpy as np
n,m,q=map(int,input().split())
a=np.zeros((n+2,n+2))
for i in range(m):
  s,e=map(int,input().split())
  a[s,e]+=1

b=a.cumsum(1)
b=np.flipud(b)
b=b.cumsum(0)
b=np.flipud(b)

for i in range(q):
  s,e=map(int,input().split())
  print(int(b[s,e]))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n,m,q=map(int,input().split())
a=np.zeros((n+2,n+2))
for i in range(m):
  s,e=map(int,input().split())
  a[:s+1,e:]+=1
for i in range(q):
  s,e=map(int,input().split())
  print(int(a[s,e]))


Fixed submission:
import numpy as np
n,m,q=map(int,input().split())
a=np.zeros((n+2,n+2))
for i in range(m):
  s,e=map(int,input().split())
  a[s,e]+=1

b=a.cumsum(1)
b=np.flipud(b)
b=b.cumsum(0)
b=np.flipud(b)

for i in range(q):
  s,e=map(int,input().split())
  print(int(b[s,e]))
Buggy python submission (verdict: Runtime Error):
from math import ceil,floor
n=int(input())
a=[int(i) for i in input().split()]
for i in range(n):
  a[i]-=(i+1)
a.sort()

b1=a[ceil(n/2)]
b2=a[floor(n/2)]

def c1(x):
    return abs(x-b1)
def c2(x):
    return abs(x-b2)
print(min(sum(list(map(c1,a))),sum(list(map(c2,a)))))

Fixed submission:
from math import ceil,floor
n=int(input())
if n==1:
  print(0)
  exit()
a=[int(i) for i in input().split()]
for i in range(n):
  a[i]-=(i+1)
a.sort()

b1=a[ceil(n/2)]
b2=a[floor(n/2)]

def c1(x):
    return abs(x-b1)
def c2(x):
    return abs(x-b2)
print(min(sum(list(map(c1,a))),sum(list(map(c2,a)))))
Buggy python submission (verdict: Runtime Error):
from bisect import bisect
n = int(input())
a = [int(x) for x in input().split()]

r = 0
s = []
for i in a:
  r += i
  s.append(r)

def bs(x,y):
  b = bisect(x, y)
  if abs(x[b-1] - y) < abs(x[b] - y):
    b = b-1
  return b

m = 10**20
for i in range(2, n-1):
  k = bs(s, s[i] / 2)
  l = bs(s, (s[n] + s[i]) / 2)
  s4 = [s[k],s[i]-s[k],s[l]-s[i],s[n]-s[l]]
  m = min(m, max(s4) - min(s4))

print(m)

Fixed submission:
from bisect import bisect
n = int(input())
a = [int(x) for x in input().split()]
 
r = 0
s = []
for i in a:
  r += i
  s.append(r)

def bs(x,y):
  b = bisect(x, y)
  if abs(x[b-1] - y) < abs(x[b] - y):
    b = b-1
  return b
 
m = 10**20
for i in range(1, n-1):
  k = bs(s, s[i] / 2)
  l = bs(s, (s[n-1] + s[i]) / 2)
  s4 = [s[k],s[i]-s[k],s[l]-s[i],s[n-1]-s[l]]
  m = min(m, max(s4) - min(s4))

print(m)
Buggy python submission (verdict: Runtime Error):
s=input()
print("Yes" if int(s) % sum(list(s)) ==0 else "No")

Fixed submission:
s=input()
print("Yes" if int(s) % sum(list(map(int,list(s)))) ==0 else "No")
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[int(input()) for i in range(n)]

al= {}
ds=[]
ans=0
for ai in a:
  ds=
  if ai - 1 in al.keys():
    al[ai]=al[ai-1]+1
    ans=max(ans,al[ai-1]+1)   
    del al[ai-1]
  else:
    al[ai]=0
    if ai + 1 in al.keys():
      del al[ai]
print(n-ans-1)

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

al= {}
ans=0
for ai in a:
  if ai - 1 in al.keys():
    al[ai]=al[ai-1]+1
    ans=max(ans,al[ai-1]+1)   
    del al[ai-1]
  else:
    al[ai]=0
    if ai + 1 in al.keys():
      del al[ai]
print(n-ans-1)
Buggy python submission (verdict: Runtime Error):
n=int(input()):
ans=1
for i in range(1,32):
  for j in range(2,10):
    if i**j <=n and i**j >ans:
      ans=i**j
print(ans)

Fixed submission:
n=int(input())
ans=1
for i in range(1,32):
  for j in range(2,10):
    if i**j <=n and i**j >ans:
      ans=i**j
print(ans)
Buggy python submission (verdict: Runtime Error):
s=input().strip()
k=int(input())
A=[]
for i in range(len(s)):
  for j in range(1,6):
    if i+j<=len(s):
      A.append(s[i:i+j])
B=sorted(list(set(A)))
print(B[k])


Fixed submission:
s=input().strip()
k=int(input())
A=[]
for i in range(len(s)):
  for j in range(1,6):
    if i+j<=len(s):
      A.append(s[i:i+j])
B=sorted(list(set(A)))
print(B[k-1])
Buggy python submission (verdict: Runtime Error):
I=lambda:[int(i)for i in input().split()]
n,m=I()
P=I()
D={i:i for i in range(n+1)}
def U(x):
  if D[x]!=x:D[x]=U(D[x])
  return D[x]
for _ in [0]*m:
  x, y= I():D[U(x)]=U(y)
print(sum(U(i)==U(p)for i,p in enumerate(P,1)))

Fixed submission:
I=lambda:[int(i) for i in input().split()]
n, m = I()
P = I()
D = {i:i for i in range(n+1)}

def U(x):
  if D[x] != x:
    D[x] = U(D[x])
  return D[x]

for _ in range(m):
  x, y = I()
  D[U(x)] = U(y)

print(sum(U(i)==U(p) for i, p in enumerate(P,1)))