Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03636 (python)

Fixed submission:
S=str(input())
size=len(S)

print(S[0]+str(int(size)-2)+S[-1])

Buggy submission (verdict: Runtime Error):
S=str(input())
size=len(S)

print(S[0]+int(int(size)-2)+S[-1])

Buggy submission (verdict: Runtime Error):
S=str(input())
size=len(S)

print(S[0]+(int(size)-2)+S[-1])

Buggy submission (verdict: Runtime Error):
S=str(input())

print(S[0:]+(S.count(S)-2)+S[-1:])

Buggy submission (verdict: Runtime Error):
S=str(input())

print(S[0]+(S.count(S)-2)+S[-1])

Buggy submission (verdict: Runtime Error):
S=str(input())

print(S[0]+(S.count(S)-2)+S[-0])
Problem p03644 (python)

Fixed submission:
n=int(input())

for i in range(1,8):
  if 2**i>n:
    n=2**(i-1)
    break
  if 1==n:
    break
  if 2**i==n:
    break
    
print(n)

Buggy submission (verdict: Runtime Error):
n=int(input())

for i in (1,n):
  if 2**i>n
    print(2**(i-1))
Problem p03814 (python)

Fixed submission:
s=str(input())
S=int()
G=int()

#Sに最初のAのインデックスを取得
for i in range(len(s)):
  if s[i]=='A':
    S=s.index(s[i])
    break
    
ss=s[::-1]

#Gに最後のZのインデックスを取得
for j in range(len(ss)):
  if ss[j]=='Z':
    G=len(ss)-j-1
    break
print(G-S+1)

Buggy submission (verdict: Runtime Error):
s=str(input())
S=int()
G=int()

#Sに最初のAのインデックスを取得
for i in range(len(s)):
  if s[i]=='A':
    S=s.index(s[i])
    break
    
ss=s[::-1]

#Gに最後のZのインデックスを取得
for j in range(len(ss)):
  if ss[j]=='Z':
    G=len(ss)-j-1
    break
print(G-S+1

Buggy submission (verdict: Runtime Error):
s=str(input())
S=int()
G=int()

for i in range(len(s)):
  if s[i]=='a':
    S=s.index(s[i])
    break
for i in reversed(range(len(s))):
  if s[i]=='z':
    G=s.index(s[i])
    break
print(G-S+1

Buggy submission (verdict: Runtime Error):
s=str(input())

for i in range(len(s)):
  if s[i]=='a':
    S=s.index(s[i])
    break
for j in reversed(range(len(s)):
  if s[j]=='z':
    G=s.index(s[j])
    break
print(G-S+1)
Problem p02830 (python)

Fixed submission:
N=input()
S,T=input().split()
strings=[]
for i in range(int(N)):
    strings.append(S[i]+T[i])
print(''.join(strings))

Buggy submission (verdict: Runtime Error):
A,B = input().split()
A=int(A)
B =int(B)
for i in range(1,B+1):
  if A*i%B ==0:
    print(A*i)

Buggy submission (verdict: Runtime Error):

N=input()
S=input()
T=input()

strings=[]
for i in range(int(N)):
    strings.append(S[i]+T[i])
    
print(''.join(strings))

Buggy submission (verdict: Runtime Error):
N=input()
S=input()
T=input()

strings=[]
for s,t in zip(S,T):
    strings.append(s+t)
print(''.join( strings))
Problem p02830 (python)

Fixed submission:
n = int(input())
A, B = input().split()
c = ""

for i in range(n):
  c = c+A[i]
  c = c+B[i]

print(c)

Buggy submission (verdict: Runtime Error):
n = input()
A, B = input().split()
c = ""

for i in range(n):
  c = c+A[i]
  c = c+B[i]

print(c)

Buggy submission (verdict: Runtime Error):
n = int(input())
s, t = input().split()

for i in range (n):
  a.append(s[n])
  a.append(t[n])
  
print(n)
Problem p02969 (python)

Fixed submission:
a = int(input())
b=3*a*a
print (b)

Buggy submission (verdict: Runtime Error):
a = input()
b=3*a*a
print (b)
Problem p02830 (python)

Fixed submission:
n=int(input())

s,t=input().split()
c=''
i=0
j=0
f=0
for _ in range(len(s)+len(t)):
          if f==0:
             c+=s[i]
             i+=1
             f=1
          else:
              c+=t[j]
              j+=1
              f=0
print(c)

Buggy submission (verdict: Runtime Error):
n=int(input())
for _ in range(n):
     s,t=input().split()
     c=''
     i=0
     j=0
     f=0
     for _ in range(len(s)+len(t)):
         if f==0:
             c+=s[i]
             i+=1
             f=1
         else:
             c+=t[j]
             j+=1
             f=0
     print(c)
Problem p02853 (python)

Fixed submission:
x,y=map(int,input().split())
m={1:300000,2:200000,3:100000}
ans=0
if x<=3:
   ans=m[x]
if y<=3:
    ans+=m[y]
if x==y and y==1:
    ans+=400000
print(ans)

Buggy submission (verdict: Runtime Error):
x,y=map(int,input().split())
m={1:300000,2:200000,3:100000}
ans=m[x]+m[y]
if x==y:
    ans+=400000
print(ans)
Problem p03160 (python)

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
dp=[0 for _ in range(n)]
dp[0]=0
dp[1]=abs(h[0]-h[1])
for i in range(2,n):
    x=dp[i-1]+abs(h[i-1]-h[i])
    x1 = dp[i - 2] + abs(h[i - 2] - h[i])
    dp[i]=min(x,x1)
print(dp[-1])

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(20000)
def getMax(d,n,c):
    global bs
    if len(d[n])==0:
        bs=max(bs,c)

    for k in d[n]:
        getMax(d,k,c+1)

n,m=map(int,input().split())
d={}
for j in range(1,n+1):
    d[j]=[]
for i in range(m):
    a,b=map(int,input().split())
    d[a].append(b)
bs=-1
for i in range(1,n+1):
    c=0
    getMax(d,i,c)
print(bs)

Buggy submission (verdict: Runtime Error):
def recur(n,h,s,j):
    #print(s,j)
    if s==n:
        return abs(h[n-1]-h[n-2])
    if s==n-1:
     #   print("ret")
        return abs(h[n-1]-h[s-j])
    else:
         
          return abs(h[s]-h[s-j])+min(recur(n,h,s+1,1),recur(n,h,s+2,2))
        
    
n=int(input())
h=list(map(int,input().split()))
print(min(recur(n,h,1,1),recur(n,h,2,2)))
Problem p03162 (python)

Fixed submission:
n=int(input())
a=[[0,0,0] for _ in range(n)]
for j in range(n):
  a[j][0],a[j][1],a[j][2]=map(int,input().split())
dp=[[0,0,0] for _ in range(n)]
dp[0][0]=a[0][0]
dp[0][1]=a[0][1]
dp[0][2]=a[0][2]
for i in range(1,n):
    dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2])
    dp[i][1] = a[i][1] + max(dp[i - 1][0], dp[i - 1][2])
    dp[i][2] = a[i][2] + max(dp[i - 1][1], dp[i - 1][0])
print(max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])))

Buggy submission (verdict: Runtime Error):
n=int(input())
def recuur(g,x,y,z):
     global n

     if z==n-1:
        return y
     if x==1:
         return y+max(recuur(g,2,g[z+1][2],z+1),recuur(g,0,g[z+1][0],z+1))
     if x==2:
         return y+max(recuur(g,1,g[z+1][1],z+1),recuur(g,0,g[z+1][0],z+1))
     if x==0:
         return y+max(recuur(g,2,g[z+1][2],z+1),recuur(g,1,g[z+1][1],z+1))

g=[[0,0,0] for _ in range(n)]
for u in range(n):
    a,b,c=map(int,input().split())
    g[u][1],g[u][2],g[u][0]=b,c,a
dp=[ [0,0] for _ in range(n)]
dp[0]=[max(g[0]),g[0].index(max(g[0]))]
print(recuur(g,dp[0][1],dp[0][0],0))
Problem p03163 (python)

Fixed submission:
n,w=map(int,input().split())
val=[]
we=[]
for i in range(n):
  a,b=map(int,input().split())
  we.append(a)
  val.append(b)
dp=[[0 for _ in range(w+1)]for _ in range(n+1)]
for i in range(n+1):
  for j in range(w+1):
    if i==0 or j==0:
      continue
    if we[i-1]>j:
      dp[i][j]=dp[i-1][j]
    else:
      dp[i][j]=max(dp[i-1][j],val[i-1]+dp[i-1][j-we[i-1]])
print(dp[n][w])

Buggy submission (verdict: Runtime Error):
n,w=map(int,input().split())
a=[[0,0] for _ in range(n)]
vw=[[0,0] for _ in range(n)]
for j in range(n):
    a[j][0],a[j][1]=map(int,input().split())
    vw[j][0],vw[j][1]=a[j][1]/a[j][0],j
vw.sort(reverse=True)
print(vw,a)
j=0
v=0
while(w>0):
    print(w,a[vw[j][1]][0],a)
    d=min(w,a[vw[j][1]][0])
    print(d)
    v=v+d*vw[j][0]
    w=w-d
    a[j][1]-=d
    print(v, w, a[j][1],vw[j][0]*d)
    j+=1
  #  print(v,w,a[j][1])
print(int(v))
Problem p03166 (python)

Fixed submission:
import sys

sys.setrecursionlimit(20000)


def getMax(d, n):
    if len(d[n]) == 0:
        return 0
    if not dp[n] == -1:
      
        return dp[n]
    for k in d[n]:
        dp[n] = max(dp[n], 1 + getMax(d, k))
    return dp[n]


n, m = map(int, input().split())
d = {}
dp = [-1 for _ in range(n + 1)]
for j in range(1, n + 1):
    d[j] = []
for i in range(m):
    a, b = map(int, input().split())
    d[a].append(b)
bs = -1
for i in range(1, n + 1):
    bs = max(bs, getMax(d,i))
print(bs)

Buggy submission (verdict: Runtime Error):
def getMax(d,n,c):
    global bs
    if len(d[n])==0:
        bs=max(bs,c)

    for k in d[n]:
        getMax(d,k,c+1)

n,m=map(int,input().split())
d={}
for j in range(1,n+1):
    d[j]=[]
for i in range(m):
    a,b=map(int,input().split())
    d[a].append(b)
bs=-1
for i in range(1,n+1):
    c=0
    getMax(d,i,c)
print(bs)
Problem p03543 (python)

Fixed submission:
i = input()
if i[0] == i[1] == i[2]:
    print('Yes')
elif i[1] == i[2] == i[3]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
i = input()
if i[0] == i[1] == i[2]:
    print('Yes')
elif i[1] == i[2] == i[e]:
    print('Yes')
else:
    print('No')
Problem p02842 (python)

Fixed submission:
import math
N=int(input())
if ((N+1)/1.08).is_integer():
  X=math.floor((N+1)/1.08)-1
else:
  X=math.floor((N+1)/1.08)
if X < N/1.08:
  print(":(")
else:
  print(X)

Buggy submission (verdict: Runtime Error):
import math
N=int(input())
if isinstance(i(N+1)/1.08, int):
  X=math.floor((N+1)/1.08))-1
else:
  X=math.floor((N+1)/1.08))
if X < N/1.08:
  print(":(")
else:
  print(X)
Problem p03090 (python)

Fixed submission:
# coding: utf-8
# Your code here!
import sys

N = int(input())

ans = []

if N % 2 == 0:
    tmp = N + 1
else:
    tmp = N
    
for i in range(1,N+1):
    for j in range(i+1,N+1):
        if i + j != tmp:
            ans.append(str(i)+' '+str(j))
            
print(len(ans))

for a in ans:
    print(a)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# Your code here!
import sys

N = int(input())

if N % 2 == 0:
    print((N-2)*(N-1)//2)
    for i in range(N):
        for j in range(i,N):
            if (i+1+j+1) != (N+1):
            print((i+1)+' '(j+1))
else:
    print((N-2)*(N-1)//2)
    for i in range(N):
        for j in range(i,N):
            if (i+1+j+1) != (N):
            print((i+1)+' '(j+1))
Problem p03293 (python)

Fixed submission:
# your code goes here
S = list(input())
T = list(input())

ans = False
for i in range(len(S)):
	if S == T:
		ans = True
		break
	S.insert(0,S[-1])
	del S[-1]
		
if ans:
	print('Yes')
else:
	print('No')

Buggy submission (verdict: Runtime Error):
# your code goes here
S = input()
T = input()

ans = False
for i in range(len(T)):
	if S[0] == T[i]:
		flag = True
		for j in range(len(S)):
			if S[j] != T[(i+j)%len(T)]:
				flag = False
				break
	if flag:
		ans = True
		break
		
if ans:
	print('Yes')
else:
	print('No')
Problem p03407 (python)

Fixed submission:
a, b, c = map(int, input().split())
if a + b >= c:
  print("Yes\n")
else :
  print("No\n")

Buggy submission (verdict: Runtime Error):
a, b, c = map(int(), input().split())
if a + b >= c:
  print("Yes\n")
else :
  print("No\n")
Problem p02830 (python)

Fixed submission:
n=int(input())
a,b=[s for s in input().split()]
c=''
for i in range(n):
  c=c+a[i]+b[i]
  
print(c)

Buggy submission (verdict: Runtime Error):
n=int(input())
a,b=[s for s in input().split()]
c=None
for i in range(n):
  c=c+a[i]+b[i]
  
print(c)
Problem p02842 (python)

Fixed submission:
n=int(input())
import math
m=math.ceil(n/1.08)
if int(m*1.08)==n:
  print(m)
else:
  print(':(')

Buggy submission (verdict: Runtime Error):
n=int(input())
m=math.ceil(n/1.08)
if int(m*1.08)==n:
  print(m)
else:
  print(':(')
Problem p03434 (python)

Fixed submission:
n=int(input())
a = [int(i) for i in input().split()] 
A=0
B=0
C=0
k=0
for i in range(n):
  if i%2==0:
    k=max(a)
    A += k
    del a[a.index(k)]
  else :
    k=max(a)      
    B += k
    del a[a.index(k)]   
  
C=A-B          
print(C)

Buggy submission (verdict: Runtime Error):
n=int(input())
a = [int(i) for i in input().split()] 
A=0
B=0
C=0
k=0
for i in range(n):
  if i%2==0:
    k=max(a)
    A += k
    del a(a.index(k))
  else :
    k=max(a)      
    B += k
    del a(a.index(k))   
  
C=A-B          
print(C)

Buggy submission (verdict: Runtime Error):
n=int(input())
a = [int(i) for i in input().split()] 
A=0
B=0
C=0
k=0
for i in range(n):
  if i%2==0:
    k=max(a)
    A += k
    del a(a.index(k)
  else :
    k=max(a)      
    B += k
    del a(a.index(k)      
  
C=A-B          
print(C)

Buggy submission (verdict: Runtime Error):
n=int(input())
a = [int(i) for i in input().split()] 
A=0
B=0
C=0
for i in range(n):
  if i%2==0:
    A += max(a)
    del a(a.index(max(a))
  else :
    B += max(a)
    del a(a.index(max(a))      
  
C=A-B          
print(C)

Buggy submission (verdict: Runtime Error):
n=int(input())
a = [int(i) for i in input().split()] 
A=0
B=0
for i in range(n):
  if i%2==0:
    A += max(a)
    del a(a.index(max(a))
  else :
    B += max(a)
    del a(a.index(max(a))      
          
print(A-B)
Problem p03455 (python)

Fixed submission:
a,b = map(int,input().split())
s = a*b
if s%2==0:
  print("Even")
else :
  print("Odd")

Buggy submission (verdict: Runtime Error):

s = a*b
if s%2==0:
  print("Even")
else :
  print("Odd")

Buggy submission (verdict: Runtime Error):
a,b
s = a*b
if s%2==0:
  print("Even")
else :
  print("Odd")
Problem p03471 (python)

Fixed submission:
n, y = (int(i) for i in input().split())  
a=-1
b=-1
c=-1
for i in range(n+1):
  for j in range(n-i+1):
      if 10000*i+5000*j+1000*(n-i-j)==y:
        a=i
        b=j
        c=n-i-j
        break

print(a ,b ,c)

Buggy submission (verdict: Runtime Error):
n, y = (int(i) for i in input().split())  
a=-1
b=-1
c=-1
for i in range(n+1):
  for j in range(n-i+1):
      if 10000*i+5000*j+1000*(n-i-j+1)==y:
        a=i
        b=j
        c=n-i+j+1
        break

print(a b c)

Buggy submission (verdict: Runtime Error):
n,y = (int(_) for _ in input().split())  
a=-1
b=-1
c=-1
for i in range(n+1):
  for j in range(n-i+1):
      if 10000*i+5000*j+1000*(n-i-j+1)==y:
        a=i
        b=j
        c=n-i+j+1
        break

print(a b c)

Buggy submission (verdict: Runtime Error):
n=int(input())
y=int(input())
a=-1
b=-1
c=-1
for i in range(n+1):
  for j in range(n-i+1):
      if 10000*i+5000*j+1000*(n-i-j+1)==y:
        a=i
        b=j
        c=n-i+j+1
        break

print(a b c)

Buggy submission (verdict: Runtime Error):
n=int(input())
y=int(input())
a=-1
b=-1
c=-1
for i in range(n+1):
  for j in range(n+1):
    for k in range(n+1):
      if n==i+j+k and 10000*i+5000*j+1000*k==y:
        a=i
        b=j
        c=k
        break

print(a b c)

Buggy submission (verdict: Runtime Error):
n=int(input())
y=int(input())
a=-1
b=-1
c=-1
for i in range(n+1):
  for j in range(n+1):
    for k in range(n+1):
      if n==i+j+k and 10000*i+5000*j+1000*k==y:
        a=i
        b=j
        c=k
        break

print(a b c)

Buggy submission (verdict: Runtime Error):
n=int(input())
y=int(input())
a=-1
b=-1
c=-1
for i in range(n):
  for j in range(n):
    for k in range(n):
      if n==i+j+k and 10000*i+5000*j+1000*k==y:
        a=i
        b=j
        c=k
        break

print(a b c)
Problem p03478 (python)

Fixed submission:
n, a, b = (int(i) for i in input().split())
s=0
h=0
f=0
for i in range(1,n+1):
  j=0
  s=0
  f=i
  while j<5:
    s += i%10
    i = int(i/10)
    j=j+1
    #if i==0:
     # break
  if s>=a and s<=b:
    h = h + f
    
print(h)

Buggy submission (verdict: Runtime Error):
n, a, b = (int(i) for i in input().split())
s=0
h=0
for i in range(1,n):
  j=0
  s=0
  while j<5:
    s += i%10
    i = i%10
  if s>=a && s<=b:
    h += s
    

print(h)
Problem p03493 (python)

Fixed submission:
N=input()
s=0
for i in N:
  if i=="1":
    s=s+1

print(s)

Buggy submission (verdict: Runtime Error):
N=input()
s=0
for i in N:
  if i=="1":
    s++

print(s)

Buggy submission (verdict: Runtime Error):
N=input()
s=0
for i in N:
  if i=='1':
    s++

print(s)
Problem p02901 (python)

Fixed submission:
n,m = map(int,input().split())
vals = []
inf = float("inf")
res = [inf]*2**n

for i in range(m):
	a,b = map(int,input().split())
	C = list(map(int,input().split()))
	cur = 0
	for c in C:
		cur |= 2**(c-1)
	res[cur] = min(res[cur],a)

ans = []
for i,r in enumerate(res):
	if res[i] == inf:
		continue
	ans.append([i,r])


for i,a in ans:
	for j in range(2**n):
		res[i|j] = min(res[i|j],res[i]+res[j])

if res[-1] == inf:
	print(-1)
else:
	print(res[-1])

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())

inf = float("inf")
ans = [inf]*n**2
for _ in range(m):
    a,b = map(int,input().split())
    C = list(map(int,input().split()))
    res = 0
    for c in C:
        res |= 2**(c-1)
    ans[res] = a

aa = []
for i,a in enumerate(ans):
    if a == inf:continue
    aa.append([i,a])

for i,a in aa:
    for j,b in aa:
        ans[i|j] = min(ans[i|j],a+b)
print(ans[-1])
Problem p03061 (python)

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

def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)

L,R = [A[0]],[A[-1]]
Lg = A[0]
Rg = A[-1]
for i in range(N-1):
    Lg = gcd(Lg,A[i+1])
    L.append(Lg)
for i in range(N-1,0,-1):
    Rg = gcd(Rg,A[i-1])
    R.append(Rg)
L.append(A[-1])
R.append(A[0])

res = 0
for i in range(N):
    if i == 0:
        res = max(res,R[-3])
    elif i == N-1:
        res = max(res,L[-3])
    else:
        res = max(res,gcd(L[i-1],R[-i-3]))
        
print(res)

Buggy submission (verdict: Runtime Error):
import math
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
L = [math.gcd(A[-1],A[-2])]
flag = 0
for i in range(N-2,-1,-1):
    L.append(math.gcd(A[i],A[i-1]))
    flag += 1 if L[-1]%L[-2] != 0 else 0
if flag >= 2:
    L2 = []
    for j in range(len(L)-1,-1,-1):
        L2.append(math.gcd(L[i],L[i-1]))
    L = L2
print(max(L))

Buggy submission (verdict: Runtime Error):
import math
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
L = [0]*(N-3)
for i in range(N-1,-1,-1):
    L.append(math.gcd(A[i],A[i-1]))
if L.count(min(L)) == 2 and len(L) > 2:
    L.sort()
    ans = L[2]
else:
    ans = L[0]
print(ans)
Problem p03074 (python)

Fixed submission:
N,K = map(int,input().split())
S = input()
L = [0]
ans = 0
res = '1'
i = 0
for s in S:
    if s != res:
        L.append(i)
        i += 1
    else:
        i += 1
    res = s
L.append(i)
L.append(i)
if len(L)<=2*K+1:
    ans = N
for i in range(0,len(L)-K*2-1,2):
    ans = max(ans,L[i+K*2+1]-L[i])
print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
S = input()
L = [0]
res = '1'
i = 0
for s in S:
    if s != res:
        L.append(i)
        i += 1
    else:
        i += 1
    res = s
L.append(i)
if len(L)<=2*k+1:
    ans = N
for i in range(0,len(L)-k*2-2,2):
    ans = L[i+K*2+1]-L[i]
print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
S = input()+'2'
L = []
if S[0] == '0':
    L.append(1)
for i in range(1,N):
    if S[i] != S[i+1]:
        L.append(i+1)
for i in range(0,len(L)-K*2,2):
    ans = L[i+K*2]-(L[i]-1)#L[i-1]?
ans = 1 if N == 1 else ans
ans = 3 if N == 3 else ans
ans = 2 if N == 2 or S == '010' else ans
print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
S = input()
L = [0]
for i in range(N):
    if S[i] == '0'and a != S[i]:
        L.append(i)
    a = S[i]
L.append(N)
for i in range(len(L)-(K+1)):
    ans = (L[i+(K+1)]-1)-(L[i])
if N == 1:
    ans = 1
elif N == 2 or S == '010':
    ans = 2
elif N == 3:
    ans = 3
    
print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
S = input()
L = [0]
for i in range(N):
    if S[i] == '0'and a != S[i]:
        L.append(i)
    a = S[i]
L.append(N)
for i in range(len(L)-3):
    ans = (L[i+3]-1)-(L[i])
if N == 1:
    ans = 1
elif N == 2 or S == '010':
    ans = 2
elif N == 3:
    ans = 3
    
print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
S = '9'+input()+'9'
S = [int(s) for s in S]
a = S[0]
L = []
for s  in S:
    if s != a:
        L.append(1)
        a = s
    else:
        L.append(0)
        a = S[0]
for i in range(N):
    if N == 1:
        ans = 1
        break
    elif N == 2:
        ans = 2
        break
    if a != S[i]:
        for j in range(i,N):
            if sum(S[i:j]) > K*2:
                ans = j-i
                break

print(ans)
Problem p03076 (python)

Fixed submission:
A = input()
B = input()
C = input()
D = input()
E = input()
ABC = [A,B,C,D,E]
sort_abc = []
time = 0
m = 9
for abc in ABC:
    if m < int(abc[-1]) or abc[-1] == '0':
        sort_abc.insert(0,abc)
    else:
        m = int(abc[-1])
        sort_abc.append(abc)
sort_abc = list(map(int,sort_abc))
for i in range(5):
    abc = sort_abc[i]
    if i == 4:
        time += abc
    else:
        if abc%10 == 0:
            time += abc
        elif abc%10 != 0 and abc >= 10:
            time += abc + (10-abc%10)
        else:
            time += 10       
print(time)

Buggy submission (verdict: Runtime Error):
a = [int(input()) for _ in range(5)]
ans = 0
for i in a:
    ans += i if i%10 == 0 else i+(10-i%10)
    mod = max(mod,i%10) if i%10 == 0 else max(mod,10-i%10)
print(ans-mod)
Problem p03081 (python)

Fixed submission:
N,Q = map(int,input().split())
S = '_'+input()+'_'
td = [input().split() for _ in range(Q)]
R = N+1
L = 0
for i in range(Q-1,-1,-1):
    t,d = td[i]
    if t == S[R-1] and d == 'R':
        R -= 1
    elif t == S[R] and d == 'L':
        R += 1
    if t == S[L+1] and d == 'L':
        L += 1
    elif t == S[L] and d == 'R':
        L -= 1
print(max(0,R-L-1))

Buggy submission (verdict: Runtime Error):
import sys
N,Q = map(int,input().split())
if N > Q:
    max = N
else:
    max = Q
if 1 > max or max > 2*10^5:
    sys.exit()
s = input()
if s.islower() or len(s) != N:
    sys.exit()
mass_list,mond_list = [mass for mass in s],['1' for hoge in range(len(s))]
for i in range(Q):
    index_list = []
    index_num = 0
    t,d = input().split()
    if t.islower():
        sys.exit()
    if d == 'R':
        d = 1
    elif d == 'L':
        d = -1
    else:
        sys.exit()
    for mass in mass_list:
        if mass == t:
            index_list.append(index_num)
        index_num += 1
    if d == 1:
        index_list.reverse()
    for index_num in index_list:
        if mons_list[index_num] > 0:
            if 0 > index_num+d or index_num+d > N-1:
                next
            else:
                mons_list[index_num+d] += mons_list[index_num]
            mons_list[index_num] = 0
print(sum(mons_list))
Problem p03103 (python)

Fixed submission:
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
AB.sort()
ans = 0
while M > 0:
    ab = AB[0]
    if ab[1] <= M:
        M-= ab[1]
        ans += ab[0] * ab[1]
        AB.pop(0)
    else:
        ans += ab[0] * M
        M -= M
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict

N,M = map(int,input().split())
AB =defaultdict(list)
total = 0
for _ in range(N):
    A,B = map(int,input().split())
    AB[A].append(B)
while M > 0:
    minAB = AB[min(AB)]
    if minAB[0] <= M:
        #print('あと{}'.format(M))
        M -= minAB[0]
        total += min(AB) * minAB[0]
        del AB[min(AB)]
    else:
        #print('残り{}'.format(M))
        total += min(AB) * M
        M -= M
print(total)
Problem p03147 (python)

Fixed submission:
input()
S = list(map(int,input().split()))
i = 0
ans = 0
while True:
    if i >= len(S):
        #print('終わり！')
        break
    for j in range(i+1,len(S)+1):
        #print(S[i:j])
        a = max(S[i:j])
        if j >= len(S):
            #print(1,S[i:j],i,j,ans)
            ans += max(S[i:j])
            i += j
            break
        elif a <= S[j]:
            #print(2,i,j,ans)
            continue
        else:
            #print(3,S[i:j],i,j,ans)
            ans += max(S[i:j])
            ans -= S[j]
            i = j
            break
print(ans)

Buggy submission (verdict: Runtime Error):
i = 0
ans = 0
while True:
    if i >= len(S):
        #print('終わり！')
        break
    for j in range(i+1,len(S)+1):
        #print(S[i:j])
        a = max(S[i:j])
        if j >= len(S):
            #print(1,S[i:j],i,j,ans)
            ans += max(S[i:j])
            i += j
            break
        elif a <= S[j]:
            #print(2,i,j,ans)
            continue
        else:
            #print(3,S[i:j],i,j,ans)
            ans += max(S[i:j])
            ans -= S[j]
            i = j
            break
print(ans)