Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
"""from collections import *
from itertools import *
from bisect import *
from heapq import *

import math
from fractions import gcd"""

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

data=[[] for i in range(N+1)]
for m,(l,r,d) in enumerate(LRD):
    data[l].append([r,d,m])
    data[r].append([l,-d,m])
data2=[set([m[1] for m in data[i]]) for i in range(N+1)]
Mlst=set([i for i in range(M)])

visited=set()
X=[0 for i in range(N+1)]
while Mlst:
    stack=[LRD[Mlst.pop()][0]]
    while stack:
        l=stack.pop()
        visited.add(l)
        for r,d,m in data[l]:
            if not r in visited:
                visited.add(r)
                X[r]=X[l]+d
                stack.append(r)
                if m in Mlst:
                    Mlst.remove(m)
            else:
                if X[r]!=X[l]+d:
                    print("No")
                    exit()

print("Yes")


Fixed submission:
"""from collections import *
from itertools import *
from bisect import *
from heapq import *

import math
from fractions import gcd"""

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

data=[[] for i in range(N+1)]
for m,(l,r,d) in enumerate(LRD):
    data[l].append([r,d,m])
    data[r].append([l,-d,m])
data2=[set([m[1] for m in data[i]]) for i in range(N+1)]
Nlst=set([i for i in range(1,N)])
Mlst=set([i for i in range(M)])
visited=set()
X=[0 for i in range(N+1)]
while Mlst:
    stack=[Nlst.pop()]
    while stack:
        l=stack.pop()
        visited.add(l)
        for r,d,m in data[l]:
            if m in Mlst:
                Mlst.remove(m)
                if not r in visited:
                    visited.add(r)
                    X[r]=X[l]+d
                    stack.append(r)

                else:
                    if X[r]!=X[l]+d:
                        print("No")
                        exit()

print("Yes")
Buggy python submission (verdict: Runtime Error):
"""from collections import *
from itertools import *
from bisect import *
from heapq import *

import math
from fractions import gcd"""
import sys
#input = sys.stdin.readline

import copy

N=int(input())
Amoto=list(map(int,input().split()))
A=copy.copy(Amoto)
_min=A[0]
minidx=0
for i in range(1,N):
    if _min>A[i]:
        _min=A[i]
        minidx=i


lst=[]
if _min<0:
    for i in range(N)[::-1]:
        while _min<A[i] and len(lst)<=2*N+1:
            A[i]+=_min
            lst.append([minidx+1,i+1])
        minidx=i
        _min=A[i]

if not len(lst)>2*N:
    print(len(lst))
    for i in lst:
        print(" ".join([str(x) for x in i ]))
    exit()
A=copy.copy(Amoto)
_max=A[0]
maxidx=0
for i in range(1,N):
    if _max<A[i]:
        _max=A[i]
        maxidx=i
if _max>0:
    for i in range(N):
        while _max>A[i] and len(lst)<=2*N+1:
            A[i]+=_max
            lst.append([maxidx+1,i+1])
        maxidx=i
        _max=A[i]
if not len(lst)>2*N:
    print(len(lst))
    for i in lst:
        print(" ".join([str(x) for x in i ]))
    exit()
else:
    print(unko)


Fixed submission:
"""from collections import *
from itertools import *
from bisect import *
from heapq import *

import math
from fractions import gcd"""
import sys
#input = sys.stdin.readline

import copy

N=int(input())
Amoto=list(map(int,input().split()))
lst=[]
A=copy.copy(Amoto)
_min=A[0]
minidx=0
for i in range(1,N):
    if _min>A[i]:
        _min=A[i]
        minidx=i
if _min<0:
    for i in range(N)[::-1]:
        while _min<A[i] and len(lst)<=2*N+1:
            A[i]+=_min
            lst.append([minidx+1,i+1])
        minidx=i
        _min=A[i]

    if  len(lst)<=2*N:
        print(len(lst))
        for i in lst:
            print(" ".join([str(x) for x in i ]))
        exit()
A=copy.copy(Amoto)
_max=A[0]
maxidx=0
lst=[]
for i in range(1,N):
    if _max<A[i]:
        _max=A[i]
        maxidx=i
if _max>0:
    for i in range(N):
        while _max>A[i] and len(lst)<=2*N+1:
            A[i]+=_max
            lst.append([maxidx+1,i+1])
        maxidx=i
        _max=A[i]
    if  len(lst)<=2*N:
        print(len(lst))
        for i in lst:
            print(" ".join([str(x) for x in i ]))
        exit()
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
Sz=list(input())
T=list(input())

for i in range(len(Sz)-len(T),-1,-1):
    Flag=1
    for s in range(len(T)):

        if not (Sz[i+s]=="?" or Sz[i+s]==T[s]):
            Flag=0
            break
    if Flag:
        for s in range(len(T)):
             Sz[i+s]=T[s]
        break
for i in range(len(Sz)):
    if Sz[i]=="?":Sz[i]="a"

if Flag:print("".join(Sz))
else:print("UNRESTORABLE ")


Fixed submission:
Sz=list(input())
T=list(input())
Flag=0

for i in range(len(Sz)-len(T),-1,-1):
    Flag=1
    for s in range(len(T)):

        if not (Sz[i+s]=="?" or Sz[i+s]==T[s]):
            Flag=0
            break
    if Flag:
        for s in range(len(T)):
             Sz[i+s]=T[s]
        break
for i in range(len(Sz)):
    if Sz[i]=="?":Sz[i]="a"

if Flag:print("".join(Sz))
else:print("UNRESTORABLE ")
Buggy python submission (verdict: Time Limit Exceeded):
"""from collections import *
from itertools import *
from bisect import *
from heapq import *

import math
from fractions import gcd"""
from heapq import*
N=int(input())
A=[list(map(int,input().split())) for i in range(N)]
data=[[] for i in range(N)]

for i in range(N):
    for m in range(N):
        if i==m:
            continue
        data[i].append([m,A[i][m],i*300+m])



visited={0}
stack=[]
dic={}
for p,c,i in data[0]:
    if c in dic:
        dic[c].append([p,i])
    else:
        dic[c]=[[p,i]]
    stack.append(c)
heapify(stack)
value=0
usedpath=set()
while stack:
    m=heappop(stack)
    a,i=dic[m].pop()
    if not a in visited:
        visited.add(a)
        usedpath.add(i)
        value+=m
        for p,c,i in data[a]:
            if not p in visited:
                if c in dic:
                    dic[c].append([p,i])
                else:
                    dic[c]=[[p,i]]
                heappush(stack,c)

idle_max=10**18
d=[[idle_max for i in range(N)] for m in range(N)]
for i in range(N):
    d[i][i]=0
for i in usedpath:
    i,m=i//300,i%300
    d[i][m]=A[i][m]
    d[m][i]=A[m][i]

for k in range(N):
    for i in range(N):
        for j in range(N):
             d[i][j] = min(d[i][j], d[i][k] + d[k][j])
Alst=[[A[i][m],i,m] for i in range(N) for m in range(N)]
Alst=sorted(Alst,key=lambda x:x[0])
for B,i,m in Alst:
    if d[i][m]<A[i][m]:
        print(-1)
        exit()
    if d[i][m]>A[i][m]:
        d[i][m]=A[i][m]
        d[m][i]=A[m][i]
        value+=A[i][m]

        for i1 in range(N):
            for j in range(N):
                 d[i1][j] = min(d[i1][j], d[i1][i] + d[i][j])
                 d[i1][j] = min(d[i1][j], d[i1][m] + d[m][j])


print(value)


Fixed submission:
"""from collections import *
from itertools import *
from bisect import *
from heapq import *

import math
from fractions import gcd"""
from heapq import*
N=int(input())
A=[list(map(int,input().split())) for i in range(N)]
for k in range(N):
    for i in range(N):
        for j in range(N):
            if A[i][j]>A[i][k]+A[k][j]:
                print(-1)
                exit()
res = 0
for i in range(N-1):
    for j in range(i+1, N):
        for k in range(N):
            if k==i or k == j:
                continue
            if A[i][j]==A[i][k]+A[k][j]:
                break
        else:
            res += A[i][j]
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
data=[int(input()) for i in range(int(input()))]
print(len([m for m in data if data.count(m)%2==1]))


Fixed submission:
data=[int(input()) for i in range(int(input()))]
data.sort()
count=-1
value=1
predata=None
for i in range(0,len(data)):
    if predata!=data[i]:
        count+=value%2
        value=1
    else:
        value+=1
    predata=data[i]
count+=value%2
print(count)
Buggy python submission (verdict: Runtime Error):
N=int(input())
P=list(map(int,input().split()))
count=0
flag=0
for i in range(N):
    if flag:
        flag=0
        continue
    if P[i]==i+1:
        count+=1
        if P[i+1]==i+2:
            flag=1
print(count)


Fixed submission:
N=int(input())
P=list(map(int,input().split()))
count=0
flag=0
for i in range(N):
    if flag:
        flag=0
        continue
    if P[i]==i+1:
        count+=1
        if i!=N-1:
            if P[i+1]==i+2:
                flag=1
print(count)
Buggy python submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)


N=int(input())
T=[int(input()) for i in range(N)]
temp=T[0]
for i in range(1,N):
    temp=lcm(temp,T[i])

print(temp)


Fixed submission:
import fractions
def lcm(x, y):
    return (x * y) // fractions .gcd(x, y)


N=int(input())
T=[int(input()) for i in range(N)]
temp=T[0]
for i in range(1,N):
    temp=lcm(temp,T[i])

print(temp)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


N=int(input())
T=[int(input()) for i in range(N)]
lst1={}
for t in T:
    Z=Counter(prime_factorize(t))
    #print(Z)
    for z in Z:

        if str(z) not in lst1:
            lst1.update({str(z):Z[z]})
        else:
            lst1[str(z)]=max(lst1[str(z)],Z[z])
#print(lst1)
count=1
for l in lst1:
    count*=int(l)**lst1[l]
print(count)


Fixed submission:
import fractions
def lcm(x, y):
    return (x * y) // fractions .gcd(x, y)


N=int(input())
T=[int(input()) for i in range(N)]
temp=T[0]
for i in range(1,N):
    temp=lcm(temp,T[i])

print(temp)
Buggy python submission (verdict: Runtime Error):
N,K=map(int,input().split())
A=sorted(list(map(int,input().split())))
if K in A:
    print("POSSIBLE")
    exit()
s=A[1]-A[0]
for i in range(1,N-1):
    if A[i+1]-A[i]!=s:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")


Fixed submission:
import collections
import fractions
N,K=map(int,input().split())
A=sorted(list(map(int,input().split())))
if K in A:
    print("POSSIBLE")
    exit()
if max(A)<K or len(A)==1:
    print("IMPOSSIBLE")
    exit()
S=collections.Counter([A[i+1]-A[0] for i in range(N-1)])
gcd=S[0]
for s in S:
    gcd=fractions.gcd(gcd,s)


if K%gcd==A[0]%gcd:
    print("POSSIBLE")
    exit()
print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
from scipy.special import comb
N,P=map(int,input().split())
A=list(map(int,input().split()))
A=[i%2 for i in A]
A0,A1=A.count(0),A.count(1)
if P==1:
    if not A1:
        print(0)
        exit()
value0=0
for i in range(0,A0+1):
    value0+=comb(A0, i, exact=True)
value1=0
for i in range(2-P,A1+1,2):
    value1+=comb(A1, i, exact=True)
print(value0*value1+(1 if not P else 0))


Fixed submission:
from operator import mul
from functools import reduce

def comb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N,P=map(int,input().split())
A=list(map(lambda x:int(x)%2,input().split()))
A0,A1=A.count(0),A.count(1)
if P==1:
    if not A1:
        print(0)
        exit()
value0=0
for i in range(0,A0+1):
    value0+=comb(A0, i)
value1=(1 if not P else 0)
for i in range(2-P,A1+1,2):
    value1+=comb(A1, i)
print(value0*value1)

Buggy python submission (verdict: Runtime Error):
from scipy.special import comb
N,P=map(int,input().split())
A=list(map(lambda x:int(x)%2,input().split()))
A0,A1=A.count(0),A.count(1)
if P==1:
    if not A1:
        print(0)
        exit()
value0=0
for i in range(0,A0+1):
    value0+=comb(A0, i, exact=True)
value1=0
for i in range(2-P,A1+1,2):
    value1+=comb(A1, i, exact=True)
print(value0*value1+(1 if not P else 0))


Fixed submission:
from operator import mul
from functools import reduce

def comb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N,P=map(int,input().split())
A=list(map(lambda x:int(x)%2,input().split()))
A0,A1=A.count(0),A.count(1)
if P==1:
    if not A1:
        print(0)
        exit()
value0=0
for i in range(0,A0+1):
    value0+=comb(A0, i)
value1=(1 if not P else 0)
for i in range(2-P,A1+1,2):
    value1+=comb(A1, i)
print(value0*value1)

Buggy python submission (verdict: Runtime Error):
from scipy.special import comb
N,P=map(int,input().split())
A=list(map(lambda x:int(x)%2,input().split()))
A0,A1=A.count(0),A.count(1)
if P==1:
    if not A1:
        print(0)
        exit()
value0=0
for i in range(0,A0+1):
    #print(value0)
    value0+=comb(A0, i, exact=True)
value1=0
for i in range(2-P,A1+1,2):
    #print(value1,i)
    #print(comb(A1, i, exact=True))
    value1+=comb(A1, i, exact=True)
print(value0*value1+(1 if not P else 0))


Fixed submission:
from operator import mul
from functools import reduce

def comb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N,P=map(int,input().split())
A=list(map(lambda x:int(x)%2,input().split()))
A0,A1=A.count(0),A.count(1)
if P==1:
    if not A1:
        print(0)
        exit()
value0=0
for i in range(0,A0+1):
    value0+=comb(A0, i)
value1=(1 if not P else 0)
for i in range(2-P,A1+1,2):
    value1+=comb(A1, i)
print(value0*value1)
Buggy python submission (verdict: Runtime Error):
H,W=map(int,input().split())
if H%3==0 or W%3==0:
    print(0)

elif H%2==0 or W%2==0:
    if W%2==0:
        H,W=W,H
    A1=(H//2 )* W
    A3=0
    value=A1-A3
    for i in range(1,W//2 +):
        A3+=H
        A1-=H//2
        value=min(int(abs(A1-A3)),value)
    print(value)
else:
    A1=(H//2 +1)* W
    A2=(H//2)* W
    A3=0
    value=max(A1,A2,A3)-min(A1,A2,A3)
    for i in range(1,W//2):
        A3+=H
        A1-=H//2 + 1
        A2-=H//2
        value=min(max(A1,A2,A3)-min(A1,A2,A3),value)

    H,W=H,W
    A1=(H//2 +1)* W
    A2=(H//2) * W
    A3=0
    value=min(max(A1,A2,A3)-min(A1,A2,A3),value)
    for i in range(1,W//2):
        A3+=H
        A1-=H//2 + 1
        A2-=H//2
        value=min(max(A1,A2,A3)-min(A1,A2,A3),value)
    print(value)


Fixed submission:
H,W=map(int,input().split())
if H%3==0 or W%3==0:
    print(0)

else:
    for m in range(2):
        H,W=W,H
        if H%2==0:
            A1=(H//2)* W
        else:
            A1=(H//2 +1)* W
        A2=(H//2)* W
        A3=0
        if m == 0:
            value=max(A1,A2,A3)-min(A1,A2,A3)
        else:
            value=min(max(A1,A2,A3)-min(A1,A2,A3),value)
        for i in range(W):
            A3+=H
            if H%2==0:
                A1-=H//2
            else:
                A1-=H//2 + 1
            A2-=H//2
            value=min(max(A1,A2,A3)-min(A1,A2,A3),value)
    value=min(value,H,W)



    print(value)
Buggy python submission (verdict: Runtime Error):
from collections import *
from itertools import *
from bisect import *
from heapq import *
import copy
import math

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

lst=A[:N]
_sum=sum(lst)
heapify(lst)

sumlst=[0 for i in range(N*3)]
sumlst[0]=_sum
for i in range(N,2*N):
    heappush(lst,A[i])
    a=heappop(lst)
    _sum+=A[i]-a
    sumlst[i-N+1]=_sum
lst=A[N*2:]
_sum=sum(lst)
lst=[-i for i in lst]
heapify(lst)
sumlst[-1]=_sum
for i in range(2*N-1,N-1,-1):
    heappush(lst,-A[i])
    a=heappop(lst)
    _sum-=-a
    _sum+=A[i]
    sumlst[i+N-1]=_sum

print(max([sumlst[i]-sumlst[2*N-1+i] for i in range(3*N//2)]))


Fixed submission:
from collections import *
from itertools import *
from bisect import *
from heapq import *
import copy
import math

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

lst=A[:N]
_sum=sum(lst)
heapify(lst)

sumlstleft=[0 for i in range(N+1)]
sumlstleft[0]=_sum
for i in range(N,2*N):
    heappush(lst,A[i])
    a=heappop(lst)
    _sum+=A[i]-a
    sumlstleft[i-N+1]=_sum
lst=A[N*2:]
_sum=sum(lst)
lst=[-i for i in lst]
heapify(lst)
sumlstright=[0 for i in range(N+1)]
sumlstright[-1]=_sum
for i in range(2*N-1,N-1,-1):
    heappush(lst,-A[i])
    a=heappop(lst)
    _sum-=-a
    _sum+=A[i]
    sumlstright[i-N]=_sum
print(max([sumlstleft[i]-sumlstright[i] for i in range(N+1)]))
Buggy python submission (verdict: Runtime Error):
[[print(ab[[index for index in [SumI if NK[1]<=sum([ab[1][I] for I in range(SumI)]) else -1 for SumI in range(NK[0])] if index!=-1][0]][0]) for ab in [sorted([list(map(int,(input().split()))) for i in range(NK[0])],key=lambda x:x[0])]] for NK in [list(map(int,(input().split())))]]


Fixed submission:
N,K=map(int,(input().split()))
ab=[list(map(int,(input().split()))) for i in range(N)]
ab=sorted(ab,key=lambda x:x[0])
count=0
for i in ab:
    count+=i[1]
    if count>=K:
        print(i[0])
        exit()
Buggy python submission (verdict: Runtime Error):
from bisect import *
from collections import *
from fractions import gcd
from math import factorial
from itertools import *
from heapq import *
import copy
#input()
N,M=map(int,input().split())
ABC=[list(map(int,input().split())) for i in range(M)]
data=[[] for i in range(N+1)]
for a,b,c in ABC:
    data[a].append([b,c])

stack=[[1,0,set([1]),0,{1:0}]]#p,nagasa,visited,flag
ac=[]
while stack:
    p,m,miti,flag,dic=stack.pop()
    if not flag:
        for np,value in data[p]:
            if p in miti and m+value>dic[np]:
                flag=1
                if N in miti:
                    print("inf")
                    exit()
                break
    for np,value in data[p]:
        if np==N:

            if not flag:
                ac.append(m+value)
            else:
                print("inf")
                exit()
        if not np in miti:
            tempm=m+value
            tempmiti=copy.copy(miti)
            tempmiti.add(np)
            dic=copy.copy(dic)
            dic.update({np:tempm})
            stack.append([np,tempm,tempmiti,flag,dic])
print(max(ac))


Fixed submission:
from bisect import *
from collections import *
from fractions import gcd
from math import factorial
from itertools import *
from heapq import *
import copy
#input()
N,M=map(int,input().split())
ABC=[list(map(int,input().split())) for i in range(M)]

idle_max=10**18+1

dist=[idle_max for i in range(N+1)]
dist[1]=0


for loop in range(N-1):
    for a,b,c in ABC:
        c=-c
        if dist[a] != idle_max:
            dist[b]=min(dist[a] + c,dist[b])

value=dist[N]
for loop in range(N):
    for a,b,c in ABC:
        c=-c
        if dist[a] != idle_max:
            dist[b]=min(dist[a] + c,dist[b])
if value!=dist[N]:
    print("inf")
else:
    print(-value)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import *
from heapq import *
from itertools import *
from fractions import gcd
import sys
from decimal import *
import copy
from bisect import *
input=lambda :sys.stdin.readline().rstrip()
N,W=map(int,input().split())
WV=[list(map(int,input().split())) for i in range(N)]

lst=[]
for w,v in WV:
    for i in range(len(lst)):
        w1,v1=lst[i]
        if w1:
            lst.append([w1+w,v1+v])
    lst.append([w,v])

    lst=sorted(lst,key=lambda x:x[0],reverse=True)
    while lst and lst[-1][0]==0:
        lst.pop()

    w,v=lst[-1]
    for i in range(len(lst)-1)[::-1]:
        w1,v1=lst[i]
        if v1<=v:
            lst[i][0]=0
            lst[i][1]=0
        else:
            v1=v
print(max([v for w,v in lst if w<=W]))


Fixed submission:
"""from collections import *
from itertools import *
from bisect import *
from heapq import *

import math
from fractions import gcd"""
import sys
input = sys.stdin.readline
from heapq import*


N,W=map(int,input().split())
WV=[list(map(int,input().split())) for i in range(N)]
dp=[[0 for i in range(301*(N+1))] for n in range(N)]
Z=WV[0][0]

for i in range(N):
    WV[i][0]-=Z
for n in range(N):
    for i in range(len(dp[0])):
        w,v=WV[n]
        if n==0:
            dp[n][w+301]=v
        else:
            dp[n][w+301]=max(dp[n-1][w+301],v)
            if i>=w+301:
                if dp[n-1][i-(w+301)]:
                    dp[n][i]=max(dp[n-1][i-(w+301)]+v,dp[n-1][i])
                else:
                    dp[n][i]=dp[n-1][i]
            else:
                dp[n][i]=dp[n-1][i]


print(max([max([dp[n][i] for i in range(len(dp[0])) if W>=i//301*Z+i%301]) for n in range(N)]))
Buggy python submission (verdict: Runtime Error):
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
# import functools
# import itertools
# import math

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


temp=A[0]
if temp<0:
    flag=0
if temp>0:
    flag=1

count=0
for i in range(1,n):
    temp+=A[i]


    if flag:
        if temp>=0:
            count+=temp-(-1)
            temp=-1
        flag=0
    else:
        if temp<=0:
            count+=1-temp
            temp=1
        flag=1
    #print(temp,flag)

print(count)


Fixed submission:
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *
# import functools
# import itertools
# import math

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

def main(c,temp):

    if temp>0:
        flag=1
    elif temp<0:
        flag=0
    for i in range(1,n):
        temp+=A[i]
        if flag:
            if temp>=0:
                c+=temp-(-1)
                temp=-1
            flag=0
        else:
            if temp<=0:
                c+=1-temp
                temp=1
            flag=1
    return(c)

temp=A[0]
if temp:
    a=main(0,temp)
    if temp>0:
        b=main(temp - (-1),-1)
    else:
        b=main(1-temp,1)
    print(min(a,b))
else:
    temp=1
    a=main(1,temp)
    temp=-1
    b=main(1,temp)
    print(min(a,b))
Buggy python submission (verdict: Runtime Error):
N=int(input())
M=int((N**(1/2)))

print(min([max([len(str(i)),len(str(int(N/i)))]) for i in range(int(N/2)-M,int(N/2)+M) if N%i==0]))

Fixed submission:
N=int(input())
M=int((N**(1/2)))
mult=0
while 1:
    for i in [-1,1]:
        x=M+i*mult
        if not N%x:
            print(max([len(str(x)),len(str(int(N/x)))]))
            exit()
    mult+=1

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
print(min([max([len(str(i)),len(str(int(N/i)))]) for i in range(1,N+1) if N%i==0]))


Fixed submission:
N=int(input())
M=int((N**(1/2)))
mult=0
while 1:
    for i in [-1,1]:
        x=M+i*mult
        if not N%x:
            print(max([len(str(x)),len(str(int(N/x)))]))
            exit()
    mult+=1
Buggy python submission (verdict: Runtime Error):
4 1
....
....
....
....
#


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

for X in range(N-M+1):
    for Y in range(N-M+1):
        flag=1
        for x in range(M):
            for y in range(M):
                if B[x][y]!=A[x+X][y+Y]:
                    flag=0
                    break
            if not flag:
                break
        if flag:
            print("Yes")
            exit()
print("No")
Buggy python submission (verdict: Runtime Error):
x=int(input())
print(max(int(x/11)*2+(x%11>0)+(x%11>5)),1)


Fixed submission:
x=int(input())
print(int(x/11)*2+(x%11>0)+(x%11>6))
Buggy python submission (verdict: Runtime Error):
print([" " if i=="," or i for i in input()])


Fixed submission:
print("".join([" " if i=="," else i for i in input()]))
Buggy python submission (verdict: Time Limit Exceeded):
K,S=map(int,input().split())
count=0
for X in range(K+1):
    for Y in range(K+1):
        for Z in range(K+1):
            count+=S==X+Y+Z

print(count)


Fixed submission:
K,S=map(int,input().split())
count=0
for X in range(K+1):
    for Y in range(K+1):
        count+=X+Y<=S<=X+Y+K

print(count)
Buggy python submission (verdict: Runtime Error):
a=input.split()
print(int(a[0])+int(a[1]) if a[1]="+" else int(a[0])-int(a[1]))

Fixed submission:
a=input().split()
print(int(a[0])+int(a[2]) if a[1]=="+" else int(a[0])-int(a[2]))

Buggy python submission (verdict: Runtime Error):
a=input.split()
print(int(a[0])+int(a[1]) if a[1]="+" else int(a[0])-int(a[1]))

Fixed submission:
a=input().split()
print(int(a[0])+int(a[2]) if a[1]=="+" else int(a[0])-int(a[2]))