Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())

ball=list(map(int,input().split()))

num=[0]*(N+1) #それぞれの数の個数

cnb=[-1]*(N+1) #それぞれの球を抜いた時のコンビネーション

for i in range(len(ball)):
  num[ball[i]]+=1

for i in range(len(num)):
  if num[i]>=1:
    break
  if i==len(num)+1:
    for j in range(ball):
      print("0")

for j in ball:
  
  if cnb[j]==-1:
    cnb[j]=0
    num[j]-=1

    for k in range(1,len(num)):
      n=num[k]
      if n>=2:
        cnb[j]+=int(n*(n-1)/2)

    print(cnb[j])
    num[j]+=1
  else:
    print(cnb[j])

Fixed submission:
N=int(input())

ball=list(map(int,input().split()))

num=[0]*(N+1) #それぞれの数の個数

cnb=[-1]*(N+1) #それぞれの球を抜いた時のコンビネーション

for i in range(len(ball)):
  num[ball[i]]+=1


allcnb=0
for i in num:
  if i>=2:
    allcnb+=int(i*(i-1)/2)

for i in ball:
  cnb=0

  if num[i]>=2:
    cnb=num[i]-1

  print(allcnb-cnb)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())

ball=list(map(int,input().split()))

num=[0]*(N+1) #それぞれの数の個数

cnb=[-1]*(N+1) #それぞれの球を抜いた時のコンビネーション

for i in range(len(ball)):
  num[ball[i]]+=1


for j in ball:
  
  if cnb[j]==-1:
    cnb[j]=0
    num[j]-=1

    for k in range(1,len(num)):
      n=num[k]
      if n>=2:
        cnb[j]+=int(n*(n-1)/2)

    print(cnb[j])
    num[j]+=1
  else:
    print(cnb[j])

Fixed submission:
N=int(input())

ball=list(map(int,input().split()))

num=[0]*(N+1) #それぞれの数の個数

cnb=[-1]*(N+1) #それぞれの球を抜いた時のコンビネーション

for i in range(len(ball)):
  num[ball[i]]+=1


allcnb=0
for i in num:
  if i>=2:
    allcnb+=int(i*(i-1)/2)

for i in ball:
  cnb=0

  if num[i]>=2:
    cnb=num[i]-1

  print(allcnb-cnb)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())

ball=list(map(int,input().split()))

num=[0]*(N+1) #それぞれの数の個数

cnb=[0]*(N+1) #それぞれの球を抜いた時のコンビネーション

for i in range(len(ball)):
  num[ball[i]]+=1


for j in ball:
  
  if cnb[j]==0:
    num[j]-=1

    for k in range(1,len(num)):
      n=num[k]
      if n>=2:
        cnb[j]+=int(n*(n-1)/2)

    print(cnb[j])
    num[j]+=1
  else:
    print(cnb[j])

Fixed submission:
N=int(input())

ball=list(map(int,input().split()))

num=[0]*(N+1) #それぞれの数の個数

cnb=[-1]*(N+1) #それぞれの球を抜いた時のコンビネーション

for i in range(len(ball)):
  num[ball[i]]+=1


allcnb=0
for i in num:
  if i>=2:
    allcnb+=int(i*(i-1)/2)

for i in ball:
  cnb=0

  if num[i]>=2:
    cnb=num[i]-1

  print(allcnb-cnb)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())

ball=list(map(int,input().split()))

num=[0]*(N+1)

for i in range(len(ball)):
  num[ball[i]]+=1

for j in ball:
  key=j
  num[key]-=1
  
  cnb=0
  for k in num:
    if k>=2:
      cnb+=int(k*(k-1)/2)

  print(cnb)
  num[key]+=1

Fixed submission:
N=int(input())

ball=list(map(int,input().split()))

num=[0]*(N+1) #それぞれの数の個数

cnb=[-1]*(N+1) #それぞれの球を抜いた時のコンビネーション

for i in range(len(ball)):
  num[ball[i]]+=1


allcnb=0
for i in num:
  if i>=2:
    allcnb+=int(i*(i-1)/2)

for i in ball:
  cnb=0

  if num[i]>=2:
    cnb=num[i]-1

  print(allcnb-cnb)
Buggy python submission (verdict: Runtime Error):
s=str(input())

if s=="hi" or s=="hihi" or s=="hihihi" or s=="hihihihi" or s=="hihihihihi":
  print("Yes")
elif:
  print("No")

Fixed submission:
s=str(input())

if s=="hi" or s=="hihi" or s=="hihihi" or s=="hihihihi" or s=="hihihihihi":
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
import sys

s=string(input())

for i in range(len(s)-1):
  if s[i]=="h" and s[i+1]=="i":
    print("Yes")
    sys.exit()
print("No")


Fixed submission:
s=str(input())

if s=="hi" or s=="hihi" or s=="hihihi" or s=="hihihihi" or s=="hihihihihi":
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
A,B,M=map(int,input().split())

m=[[0] * B for i in range(A)]

a=list(map(int,input().split()))
b=list(map(int,input().split()))

minc=min(a)+min(b)

for i in range(M):
  x,y,c=map(int,input().split())
  cash=a[x-1]+b[y-1]-c

  if cash<minc:
    minc=cash


print(minc)

Fixed submission:
A,B,M=map(int,input().split())

a=list(map(int,input().split()))
b=list(map(int,input().split()))

minc=min(a)+min(b)

for i in range(M):
  x,y,c=map(int,input().split())
  cash=a[x-1]+b[y-1]-c

  if cash<minc:
    minc=cash

print(minc)

Buggy python submission (verdict: Runtime Error):
A,B,M=map(int,input().split())

m=[[0] * B for i in range(A)]

a=list(map(int,input().split()))
b=list(map(int,input().split()))

minc=min(a)+min(b)

for i in range(M):
  x,y,c=map(int,input().split())
  cash=a[x]+b[y]-c

  if cash<minc:
    minc=cash


print(minc)

Fixed submission:
A,B,M=map(int,input().split())

a=list(map(int,input().split()))
b=list(map(int,input().split()))

minc=min(a)+min(b)

for i in range(M):
  x,y,c=map(int,input().split())
  cash=a[x-1]+b[y-1]-c

  if cash<minc:
    minc=cash

print(minc)
Buggy python submission (verdict: Runtime Error):
import sys

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

g=[-1]*n

for i in range(m):

  s,c=map(int,input().split())

  if g[s-1]!=-1 and g[s-1]!=c:
    print("-1")
    sys.exit()

  elif n>=2 and s==1 and c==0:
    print("-1")
    sys.exit()

  else:
    g[s-1]=c

ans=0
h=1

for i in range(m-1,-1,-1):

  if g[i]==-1:

    if n>=2 and i==0:
      g[i]=1
    else:
      g[i]=0


  ans+=int(g[i])*h
  h=h*10


print(ans)

Fixed submission:
import sys

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

g=[-1]*n

for i in range(m):

  s,c=map(int,input().split())

  if g[s-1]!=-1 and g[s-1]!=c:
    print("-1")
    sys.exit()

  elif n>=2 and s==1 and c==0:
    print("-1")
    sys.exit()

  else:
    g[s-1]=c

ans=0
h=1

for i in range(n-1,-1,-1):

  if g[i]==-1:

    if n>=2 and i==0:
      g[i]=1

    else:
      g[i]=0


  ans+=int(g[i])*h
  h=h*10

#print(g)

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys

n=int(input())

a=list(map(int,input().split()))

c=[0]*(max(a)+1)

for i in range(len(a)):
  c[a[i]]+=1

  if c[a[i]]>1:
    print("NO")
    sys.exit()

print("YES")


Fixed submission:
import sys

n=int(input())

a=list(map(int,input().split()))

a.sort()

for i in range(len(a)-1):
  if a[i]==a[i+1]:
    print("NO")
    sys.exit()

print("YES")

Buggy python submission (verdict: Runtime Error):
import sys

n=int(input())

a=list(map(int,input().split()))

c=[0]*max(a)

for i in range(len(a)):
  c[a[i]]+=1

  if c[a[i]]>1:
    print("NO")
    sys.exit()

print("YES")


Fixed submission:
import sys

n=int(input())

a=list(map(int,input().split()))

a.sort()

for i in range(len(a)-1):
  if a[i]==a[i+1]:
    print("NO")
    sys.exit()

print("YES")

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

n=int(input())

a=list(map(int,input().split()))

for i in range(len(a)-1):

  if a.count(a[i])>=2:
    print("NO")
    sys.exit()

print("YES")


Fixed submission:
import sys

n=int(input())

a=list(map(int,input().split()))

a.sort()

for i in range(len(a)-1):
  if a[i]==a[i+1]:
    print("NO")
    sys.exit()

print("YES")

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

n=int(input())

a=list(map(int,input().split()))

for i in range(len(a)-1):
  for j in range(i+1,len(a)):

    if a[i]==a[j]:
      print("NO")
      sys.exit()

print("YES")

Fixed submission:
import sys

n=int(input())

a=list(map(int,input().split()))

a.sort()

for i in range(len(a)-1):
  if a[i]==a[i+1]:
    print("NO")
    sys.exit()

print("YES")
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())

p=list(map(int,input().split()))

c=[0]*len(p) #期待値

for i in range(len(p)):
  
  c[i]=((p[i]+1)*p[i])/(2*p[i])

maxev=0

for i in range(len(p)-k+1):
  ev=0
  
  for j in range(k):
    ev+=c[i+j]

  if maxev==0 or maxev<ev:
    maxev=ev

print(maxev)


Fixed submission:
n,k=map(int,input().split())

p=list(map(int,input().split()))

c=[0]*len(p) #期待値

for i in range(len(p)):
  if i>0:
    c[i]=(((p[i]+1)*p[i])/(2*p[i]))+c[i-1]
  else:
    c[i]=(((p[i]+1)*p[i])/(2*p[i]))

maxev=0

for i in range(len(p)-k+1):
  ev=0

  if i==0:
    ev=c[i+k-1]
  else:
    ev=c[i+k-1]-c[i-1]

  if maxev==0 or maxev<ev:
    maxev=ev

print(maxev)
Buggy python submission (verdict: Runtime Error):
def attack(x):
  if x==1:
    return 1
  else:
    return (attack(-(-x/2))*2+1)

h=int(input())

print(attack(h))

Fixed submission:
def attack(x):
  if x==1:
    return 1
  else:
    return (attack(x//2)*2+1)

h=int(input())

print(attack(h))
Buggy python submission (verdict: Runtime Error):
import math

a,b=map(int,input().split())

#c=int((a*b)/math.gcd(a,b))
c=math.gcd(a,b)

print(c)

Fixed submission:
import math

a,b=map(int,input().split())

c=0

while(1):
  c+=a
  if c%b==0:
    print(c)
    break

Buggy python submission (verdict: Runtime Error):
import math

a,b=map(int,input().split())

c=int((a*b)/math.gcd(a,b))

c=0
print(c)

Fixed submission:
import math

a,b=map(int,input().split())

c=0

while(1):
  c+=a
  if c%b==0:
    print(c)
    break

Buggy python submission (verdict: Runtime Error):
import math

a,b=map(int,input().split())

c=int((a*b)/math.gcd(a,b))
print(c)

Fixed submission:
import math

a,b=map(int,input().split())

c=0

while(1):
  c+=a
  if c%b==0:
    print(c)
    break

Buggy python submission (verdict: Runtime Error):
import math

a,b=map(int,input().split())

print((a*b)//math.gcd(a,b))

Fixed submission:
import math

a,b=map(int,input().split())

c=0

while(1):
  c+=a
  if c%b==0:
    print(c)
    break

Buggy python submission (verdict: Runtime Error):
import math

a,b=map(int,input().split())

print((a*b)//math.gcd(a,b))

Fixed submission:
import math

a,b=map(int,input().split())

c=0

while(1):
  c+=a
  if c%b==0:
    print(c)
    break
Buggy python submission (verdict: Runtime Error):
N=int(input())
sum=0.0

for i in range(0,N):
  a=int(input())
  sum+=1/a

print(1/sum)


Fixed submission:
N=int(input())
sum=0.0

A=[i for i in range(N)]

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

for i in range(0,N):
  sum+=1/A[i]

print(1/sum)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
m = 0
for i in range(n):
  m += a[i]*(sum(a[i+1:])%(10**9+7))
  m = m%(10**9+7)
print(m)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = sum([(i**2) for i in a])
print(((sum(a)**2-b)//2)%(10**9+7))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
m = 0
for i in range(n):
  m += a[i]*sum(a[i+1:])
  m = m%(10**9+7)
print(m)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = sum([(i**2) for i in a])
print(((sum(a)**2-b)//2)%(10**9+7))
Buggy python submission (verdict: Runtime Error):
s = input()
if "R" in s:
  a = 1
  if "RR" in s:
    a += 1
    if "RRR" in s:
      a += 1
print(a)

Fixed submission:
s = input()
a=0
if "R" in s:
  a = 1
  if "RR" in s:
    a += 1
    if "RRR" in s:
      a += 1
print(a)
Buggy python submission (verdict: Time Limit Exceeded):
x,k,d = map(int, input().split())
y = x
for i in range(k):
  if x > 0:
    x -= d
    y = min(abs(y),abs(x))
  elif x < 0:
    x += d
    y = min(abs(y),abs(x))
  else:
    if (k-i)%2 == 1:
      y = d
    else:
      y = 0
    break
print(y)

Fixed submission:
x,k,d = map(int, input().split())

x = abs(x)
if k <= x//d:
  y = x-k*d
else:
  if (k-x//d)%2 == 0:
    y = x%d
  else:
    y = min(abs(x%d-d),abs(x%d+d))
print(y)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int, input().split())
a = list(map(int, input().split()))
b = []
for i in range(k,n+1):
  c = a[i-k:i+1]
  d = 1
  for j in range(k):
    d *= c[j]
  b.append(d)
for i in range(len(b)-1):
  if b[i+1]-b[i] > 0:
    print("Yes")
  else:
    print("No")

Fixed submission:
n,k = map(int, input().split())
a = list(map(int, input().split()))
b = []
for i in range(n-k):
  if a[i+k] > a[i]:
    print("Yes")
  else:
    print("No")

Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
a = list(map(int, input().split()))
b = []
for i in range(k,n+1):
  c = a[i-k:i+1]
  d = 1
  for j in range(k):
    d *= c[j]
  b.append(d)
for i in range(len(d)-1):
  if d[i+1]-d[i] > 0:
    print("Yes")
  else:
    print("No")

Fixed submission:
n,k = map(int, input().split())
a = list(map(int, input().split()))
b = []
for i in range(n-k):
  if a[i+k] > a[i]:
    print("Yes")
  else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = []
for i in range(n):
  s.append(int(input()))
print("AC x ",s.count("AC"))
print("WA x ",s.count("WA"))
print("TLE x ",s.count("TLE"))
print("RE x ",s.count("RE"))

Fixed submission:
n = int(input())
s = []
for i in range(n):
  s.append(input())
print("AC x ",s.count("AC"))
print("WA x ",s.count("WA"))
print("TLE x ",s.count("TLE"))
print("RE x ",s.count("RE"))
Buggy python submission (verdict: Runtime Error):
import random
d = int(input())
c = list(map(int, input().split()))
s = []
for i in range(d):
  s = list(map(int, input().split()))
  print(1+s.index(max(x)))

Fixed submission:
import random
d = int(input())
c = list(map(int, input().split()))
s = []
for i in range(d):
  s.append(list(map(int, input().split())))
for i in range(d):
  print(random.randrange(1,27))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
b = 1
for i in range(n):
  b *= a[i]
  if b > 10**18 and 0 not in a:
    b = -1
    break
print(b)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = 1
if 0 in a:
  b = 0
else:
  for i in range(n):
    b *= a[i]
    if b > 10**18:
      b = -1
      break
print(b)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
b = 1
for i in range(n):
  b *= a[i]
if b > 10**18:
  b = -1
print(b)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = 1
if 0 in a:
  b = 0
else:
  for i in range(n):
    b *= a[i]
    if b > 10**18:
      b = -1
      break
print(b)
Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
s = []
for i in range(k):
  d = int(input())
  a = list(map(int, input()))
  s += a
print(n-len(set(s)))
  

Fixed submission:
n,k = map(int, input().split())
s = []
for i in range(k):
  d = int(input())
  a = list(map(int, input().split()))
  s += a
print(n-len(set(s)))
Buggy python submission (verdict: Runtime Error):
x = int(input())
for i in range(65):
  s = (x-i**5)**0.2
  t = (x+i**5)**0.2
  if s.is_integer():
    print(int(s),-i)
    break
  elif t.is_integer():
    print(int(t), i)
    break

Fixed submission:
import math
x = int(input())
i = 0
while True:
  if (i**5 <= x):
    s = (x-i**5)**0.2
    s = math.floor(s*(10**7))/(10**7)
  t = (x+i**5)**0.2
  t = math.floor(t*(10**7))/(10**7)
  if s.is_integer() and i**5 <= x:
    print(int(s),-i)
    break
  elif t.is_integer():
    print(int(t), i)
    break
  i += 1
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
for i in range(1,n+1):
  print(a.count(i))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = [0]*n
for i in a:
  b[i-1]+=1
for i in b:
  print(i)
Buggy python submission (verdict: Runtime Error):
s = int(input())
ans = "No"
if len(s) == 6:
  if s[2]==s[3] and s[4]==s[5]:
    ans = "Yes"
print(ans)

Fixed submission:
s = input()
ans = "No"
if len(s) == 6:
  if s[2]==s[3] and s[4]==s[5]:
    ans = "Yes"
print(ans)
Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
print(len(str(int(n,k))))

Fixed submission:
n,k = map(int, input().split())
s = 1
c = 0
while n//s > 0:
  s *= k
  c += 1
print(c)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = map(int, input().split())
b = len(a)
c = len(set(a))
if b == c:
  print("YES")
else:
  print("NO")

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = len(a)
c = len(set(a))
if b == c:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
import itertools
n = int(input())
l = list(range(1,n+1))
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
r = list(itertools.permutations(l))
for i in range(len(r)):
  if r[i] == p:
    a = i
  elif r[i] == q:
    b = i
print(abs(a-b))

Fixed submission:
import itertools
n = int(input())
l = list(range(1,n+1))
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
r = list(itertools.permutations(l))
for i in range(len(r)):
  if r[i] == p:
    a = i
  if r[i] == q:
    b = i
print(abs(a-b))
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
x = [1,2,3]
del x[a-1]
del x[b-1]
print(x[0])

Fixed submission:
a = int(input())
b = int(input())
if a == 1:
  if b == 2:
    print(3)
  else:
    print(2)
elif a == 2:
  if b == 1:
    print(3)
  else:
    print(1)
elif a == 3:
  if b == 1:
    print(2)
  else:
    print(1)

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
x = [1,2,3]
del x[a]
del x[b]
print(x[0])

Fixed submission:
a = int(input())
b = int(input())
if a == 1:
  if b == 2:
    print(3)
  else:
    print(2)
elif a == 2:
  if b == 1:
    print(3)
  else:
    print(1)
elif a == 3:
  if b == 1:
    print(2)
  else:
    print(1)
Buggy python submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
a,b = map(int, input().split())
print(lcm(a, b))

Fixed submission:
import fractions
a, b = map(int, input().split())
print((a*b) // fractions.gcd(a, b))
Buggy python submission (verdict: Runtime Error):
s = input()
h = 0
for i in range(len(s)//2):
  if s[i] != s[s-i-1]:
    h += 1
print(h)

Fixed submission:
s = input()
h = 0
for i in range(len(s)//2):
  if s[i] != s[len(s)-i-1]:
    h += 1
print(h)
Buggy python submission (verdict: Runtime Error):
s = input()
k = int(input())
n = 0
j = s[0]
l = 1
p = 0
for i in range(1,len(s)):
  if s[i] == j:
    l += 1
  else:
    n += l//2
    l = 1
    j = s[i]
n += l//2
if s[0] == s[-1] and s[0] != s[1] and s[0] != s[-2]:
  p = k-1
print(n*k+p)

Fixed submission:
s = input()
k = int(input())
n = 0
j = s[0]
l = 1
p = 0
fi,la = 0,0
c = 1
if len(set(list(s))) == 1:
  print(len(s)*k//2)
else:
  for i in range(1,len(s)):
    if s[i] == j:
      l += 1
    else:
      n += l//2
      if s[i-1] == s[0] and c == 1:
        fi = l
        c = 0
      l = 1
      j = s[i]
  n += l//2
  la = l
  if s[0] == s[-1] and fi%2 == 1 and la%2 == 1:
    p = k-1
  print(n*k+p)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = []
def f(a):
  c = 0
  for i in range(n-1):
    if a[i-1] ^ a[i+1] == a[i]:
      c += 1
    else:
      c = -1
      break
  if a[0] ^ a[n-2] == a[n-1] and c > -1:
    return True
  else:
    return False
for i in range(n):
  b.append(f(a))
  c = a.pop(a[0])
  a.append(c)
if any(b):
  print("Yes")
else:
  print("No")

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = 0
for i in range(n):
  b = b^a[i]

if b == 0:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
n,x = map(int, input().split())
l = [0] + list(map(int, input().split()))
d = 0
i = 0
while d <= x and n+2 > i:
  d += l[i]
  i += 1
if n+2 <= i:
  print(n+1)
else:
  print(i-1)

Fixed submission:
n,x = map(int, input().split())
l = [0] + list(map(int, input().split()))
d = 0
i = 0
c = 0
while d <= x:
  d += l[i]
  i += 1
  if n+1 == i and d <= x:
    c = 1
    break
if c == 1:
  print(n+1)
else:
  print(i-1)

Buggy python submission (verdict: Runtime Error):
n,x = map(int, input().split())
l = [0] + list(map(int, input().split()))
m = 0
d = 0
i = 1
while d <= x:
  d += l[i]
  i += 1
  if n+1 <= i:
    i = None
    break
if i = None:
  print(n+1)
else:
  print(i-1)

Fixed submission:
n,x = map(int, input().split())
l = [0] + list(map(int, input().split()))
d = 0
i = 0
c = 0
while d <= x:
  d += l[i]
  i += 1
  if n+1 == i and d <= x:
    c = 1
    break
if c == 1:
  print(n+1)
else:
  print(i-1)

Buggy python submission (verdict: Runtime Error):
n,x = map(int, input().split())
l = [0] + list(map(int, input().split()))
m = 0
d = 0
i = 0
while d <= x:
  d += l[i]
  i += 1
print(i-1)

Fixed submission:
n,x = map(int, input().split())
l = [0] + list(map(int, input().split()))
d = 0
i = 0
c = 0
while d <= x:
  d += l[i]
  i += 1
  if n+1 == i and d <= x:
    c = 1
    break
if c == 1:
  print(n+1)
else:
  print(i-1)
Buggy python submission (verdict: Runtime Error):
l = []
for i in range(int(input())):
  s,p = map(str, input().split())
  l.append((s,100-int(p),i+1))
m = sorted(l)
for i in l:
  print(l[2])

Fixed submission:
l = []
for i in range(int(input())):
  s,p = map(str, input().split())
  l.append((s,100-int(p),i+1))
m = sorted(l)
for i in m:
  print(i[2])
Buggy python submission (verdict: Runtime Error):
n,m = map(int, input().split())
n = range(1,n+1)
for i in range(m):
  a,b = map(int, input().split())
  n = [j for j in n if a <= j <= b]
print(len(j))

Fixed submission:
n,m = map(int, input().split())
p,q = float('-inf'),float('inf')
for i in range(m):
  a,b = map(int, input().split())
  if a > p:
    p = a
  if b < q:
    q = b
if (q-p) < 0:
  print(0)
else:
  print(q-p+1)
Buggy python submission (verdict: Runtime Error):
n,k = map(int, input().split())
w = {"A":"a", "B":"b", "C":"c"}
s = input().split()
print([i if i != k-1 else w[s[i]] for i in len(s)])

Fixed submission:
n,k = map(int, input().split())
w = {"A":"a", "B":"b", "C":"c"}
s = list(input())
print(''.join([w[s[i]] if i == k-1 else s[i] for i in range(n)]))
Buggy python submission (verdict: Runtime Error):
N = input()
n = [int(N[:1]), int(N[1:])]
a = ['YYMM', 'MMYY', 'AMBIGUOUS', 'NA']
if a[0] > 12:
  if a[1] == 0:
    print(a[3])
  else:
    print(a[0])
elif a[1] > 12:
  if a[0 == 0:
    print(a[3])
  else:
    print(a[1])
else:
  print(a[2])

Fixed submission:
N = input()
n = [int(N[:2]), int(N[2:])]
a = ['YYMM', 'MMYY', 'AMBIGUOUS', 'NA']
if n[0] > 12 or n[0] == 0:
  del a[1]
  del a[1]
  if n[1] > 12 or n[1] == 0:
    del a[0]
elif n[1] > 12 or n[1] == 0:
  del a[0]
  del a[1]
else:
  a = [a[2]]
print(a[0])