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

Fixed submission:
import sys
if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def MAP(): return [int(s) for s in input().split()]

N = int(input())
A = [[False,MAP()] for _ in range(N)]
B = [[False,MAP()] for _ in range(N)]

A = sorted(A, key=lambda x:-x[1][1])
B = sorted(B, key=lambda x:x[1])

#after reading answer
count = 0
for b in B:
	cand = []
	for a in A:
		if b[0] or a[0] : continue
		#print(b[1],a[1])
		if b[1][0] > a[1][0] and b[1][1] > a[1][1]:
			#print('make pair')
			b[0] = True
			a[0] = True
			count += 1

print(count)

Buggy submission (verdict: Runtime Error):
import sys
import copy
if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def MAP(): return [int(s) for s in input().split()]

N = int(input())
A = [[False,MAP()] for _ in range(N)]
B = [[False,MAP()] for _ in range(N)]

#print(sorted(B))

#below is incorrect 
#count = 0
#for b in B:
#	delta = []
#	for a in A:
#		delta.append([a,[b[1][0] - a[1][0], b[1][1] - a[1][1]]])
	#print(b,delta)
#	cand = [[d[1][0]+d[1][1],d[0][1]] for d in delta if not d[0][0] and d[1][0] > 0 and d[1][1] > 0]
#	if cand:
#		cand = sorted(cand)
#		print(cand)
#		b[0] = True
#		A[A.index([False,cand[0][1]])][0] = True
#		count += 1

#after reading answer
count = 0
for b in B:
	cand = []
	for a in A:
		if b[1][0] > a[1][0] and b[1][1] > a[1][1] not a[0]:
			cand.append(a)
	cand = sorted(cand, key=lambda x:x[1][1], reverse=True)
	if cand:
		#print(b, cand[0])
		b[0] = True
		cand[0][0] = True
		count += 1

print(count)

Buggy submission (verdict: Runtime Error):
import sys
import copy
if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def MAP(): return [int(s) for s in input().split()]

N = int(input())
A = [[False,MAP()] for _ in range(N)]
B = [[False,MAP()] for _ in range(N)]

#print(sorted(B))

#below is incorrect 
#count = 0
#for b in B:
#	delta = []
#	for a in A:
#		delta.append([a,[b[1][0] - a[1][0], b[1][1] - a[1][1]]])
	#print(b,delta)
#	cand = [[d[1][0]+d[1][1],d[0][1]] for d in delta if not d[0][0] and d[1][0] > 0 and d[1][1] > 0]
#	if cand:
#		cand = sorted(cand)
#		print(cand)
#		b[0] = True
#		A[A.index([False,cand[0][1]])][0] = True
#		count += 1

#after reading answer
count = 0
for b in B:
	cand = []
	for a in A:
		if b[1][0] > a[1][0] and b[1][1] > a[1][1] not a[0]:
			cand.append(a)
	cand = sorted(cand, key=lambda x:x[1][1], reverse=True)
	if cand:
		#print(b, cand[0])
		b[0] = True
		cand[0][0] = True
		count += 1

print(count)
Problem p03425 (python)

Fixed submission:
import sys
from operator import mul
from functools import reduce

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

MARCH = 'MARCH'
def cmb(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 = INT()
S = [input().rstrip() for _ in range(N)]

S = [s for s in S if s[0] in MARCH]

A = [0]*5
for s in S:
	A[MARCH.index(s[0])] += 1

#print(A)

if sum(A) < 3:
	print(0)
	sys.exit()

ans = cmb(sum(A), 3)
#print(ans)

for a in A:
	if a<=1:continue
	if a>=3:
		ans -= cmb(a, 3)
	ans -= cmb(a, 2) * (sum(A)-a)

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
from operator import mul
from functools import reduce

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

MARCH = 'MARCH'
def cmb(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 = INT()
S = [input().rstrip() for _ in range(N)]

S = [s for s in S if s[0] in MARCH]

A = [0]*N
for s in S:
	A[MARCH.index(s[0])] += 1

#print(A)

if sum(A) <= 3:
	print(0)
	sys.exit()

ans = cmb(sum(A), 3)
#print(ans)

for a in A:
	if a<=1:continue
	if a>=3:
		ans -= cmb(a, 3)
	ans -= cmb(a, 2) * (sum(A)-a)

print(ans)
Problem p03575 (python)

Fixed submission:
import sys

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def dfs(G, v):
	seen[v] += 1
	#print('v :', v)
	
	for nv in G[v]:
		if seen[nv]: continue
		#print('v nv :', v, nv, 'Recursion')
		dfs(G, nv)

N, M = MAP()
A = [MAP() for _ in range(M)]

#print(A)

ans = 0
for i in range(M):
	G = [[] for _ in range(N)]
	for j, m in enumerate(A):
		# i!=jのとき辺を追加しない
		if i != j:
			a, b = m
			G[a-1].append(b-1)
			G[b-1].append(a-1)
		
	seen = [0] * N
	dfs(G, 1)
	#print(i, j, seen)
	
	if sum(seen) != N: ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
import sys

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def dfs(G, v):
	seen[v] += 1
	#print('v :', v)
	
	for nv in G[v]:
		if seen[nv]: continue
		#print('v nv :', v, nv, 'Recursion')
		dfs(G, nv)

N, M = MAP()
A = [MAP() for _ in range(M)]

#print(A)

ans = 0
for i in range(M):
	G = [[] for _ in range(N)]
	for j, m in enumerate(A):
		# i!=jのとき辺を追加しない
		if i != j:
			a, b = m
			G[a-1].append(b-1)
			G[b-1].append(a-1)
		
	seen = [0] * N
	dfs(G, 1)
	#print(i, j, seen)
	
	if sum(seen) != N: ans += 1

print(ans)import sys

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def dfs(G, v):
	seen[v] += 1
	#print('v :', v)
	
	for nv in G[v]:
		if seen[nv]: continue
		#print('v nv :', v, nv, 'Recursion')
		dfs(G, nv)

N, M = MAP()
A = [MAP() for _ in range(M)]

#print(A)

ans = 0
for i in range(M):
	G = [[] for _ in range(N)]
	for j, m in enumerate(A):
		# i!=jのとき辺を追加しない
		if i != j:
			a, b = m
			G[a-1].append(b-1)
			G[b-1].append(a-1)
		
	seen = [0] * N
	dfs(G, 1)
	#print(i, j, seen)
	
	if sum(seen) != N: ans += 1

print(ans)
Problem p03612 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	N = INT()
	A = MAP()

	i = 0
	cnt = 0
	while i < N:
		if A[i] == i+1:
			cnt += 1
			if i < N-1 and A[i+1] == i+2:
				i += 2
			else:
				i += 1
		else:
			i += 1
	
	print(cnt)

if __name__ == '__main__':
	main()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

def main():
	N = INT()
	A = MAP()

	i = 0
	cnt = 0
	while i < N:
		if A[i] == i+1:
			cnt += 1
			if A[i+1] == i+2:
				i += 2
			else:
				i += 1
		else:
			i += 1
	
	print(cnt)

if __name__ == '__main__':
	main()
Problem p03807 (python)

Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]

odd_list = [i for i in a if i%2]
odd_count = len(odd_list)

if (odd_count == 0 or odd_count %2 == 0):
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(x) for x in input().split()]

odds = [i for i in a if 2%i]
print("No" if 2%len(odds) else "Yes")
Problem p02801 (python)

Fixed submission:
character=input()


print(chr(ord(character)+1))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
 
WA=[0]*n
AC=[0]*n
 
for i in range(m):
    problem,status=input().split()
    problem=int(problem)
 
    if status=='WA':
        if AC[problem-1]==1:
            continue
        else:
            WA[problem-1]+=1
    elif status=='AC':
        AC[problem-1]=1

for i in range(n):
    if AC[i]==0:
        WA[i]=0
print(sum(AC),sum(WA))

Buggy submission (verdict: Runtime Error):

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

WA=[0]*n
AC=[0]*n

for i in range(m):
    problem,status=input().split()
    problem=int(problem)

    if status=='WA' and AC[problem-1]==0:
        WA[problem-1]+=1
    elif status=='AC':
        AC[problem-1]=1
print(sum(WA),sum(AC))
Problem p02639 (python)

Fixed submission:
a = list(map(int, input().split()))
n = 0
for i in range(5):
  if a[n] == 0:
    print(n+1)
    break
  else:
    n += 1

Buggy submission (verdict: Runtime Error):
a = input().split()
for i in range(4):
  if a[i] = 0:
    print(i)

Buggy submission (verdict: Runtime Error):
a = input().split()
for i in range(4):
  if i = 0:
    print(i)
Problem p02658 (python)

Fixed submission:
N=int(input())
s=list(map(int,input().split()))
ans=1
if s.count(0)>0:
  print('0')
  exit()
for i in s:
  ans*=i
  if ans>1000000000000000000:
    print('-1')
    exit()

print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input)
s=list(map(int,input().split()))
ans=1
for i in s:
  ans*=i
  if ans>10e18:
    print('-1')
    break
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input)
s=list(map(input().split()))
ans=1
for i in s:
  ans*=i
  if ans>10e18:
    print('-1')
    break
print(ans)
Problem p02534 (python)

Fixed submission:
K = int(input())
print('ACL'*K)

Buggy submission (verdict: Runtime Error):
K = int(input())
print('ACL'*k)
Problem p02582 (python)

Fixed submission:
print(max(map(len, input().split('S'))))

Buggy submission (verdict: Runtime Error):
x, k, d = map(int, input().split())
if x < 0:
    x *= -1
if x - k // d >= 0:
    print(x-k*d)
else:
    k -= x // d
    x %= d
    if k % 2 == 0:
        print(x)
    else:
        print(abs(x-d))
Problem p02681 (python)

Fixed submission:
s=str(input())
t=str(input())
r=t[:len(t)-1]

if(s==r):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s=str(input())
t=str(input())
t.depend(-1)
if(s==t):
  print("Yes")
else:
  print("No")
Problem p02783 (python)

Fixed submission:
import math
h,a=map(int,input().split())
print (math.ceil(h/a))

Buggy submission (verdict: Runtime Error):
h,a=map(int,input(),split())

n=h/a+1

print (int(n))
Problem p02830 (python)

Fixed submission:
n=int(input())
s,t=map(str,input().split())
j=0
k=0
r=[0 for i in range(2*n)]
for i in range(0,2*n,2):
  r[i]=s[j]
  j+=1
  
for i in range(1,2*n+1,2):
  r[i]=t[k]
  k+=1
  
print("".join(r))

Buggy submission (verdict: Runtime Error):
n=int(input())
s,t=map(int,input().split())
j=0
k=0
r=[0 for i in range(2*n)]
for i in range(0,2*n,2):
  r[i]=s[j]
  j+=1
  
for i in range(1,2*n+1,2):
  r[i]=t[k]
  k+=1
  
print("".join(r))
Problem p02952 (python)

Fixed submission:
n=int(input())
if(n<10):
  x=n
elif(n<100):
  x=9
elif(n<1000):
  x=n-90
elif(n<10000):
  x=9+900
elif(n<100000):
  x=n-90-9000
elif(n==100000):
  x=90909
print(x)

Buggy submission (verdict: Runtime Error):
n=int(input())
if(n<10):
  x=n
elif(n<100):
  x=9
elif(n<1000):
  x=n-90
elif(n<10000):
  x=
elif(x<100000):
  x=n-90-9000
Problem p02994 (python)

Fixed submission:
n,l=map(int,input().split())
a=list(range(l,l+n,1))
x=sum(a)
if(0 in a):
  a.remove(0)
  print(sum(a))
elif(x<0):
  a.remove(max(a))
  print(sum(a))
elif(x>0):
  a.remove(min(a))
  print(sum(a))

Buggy submission (verdict: Runtime Error):
n,l=map(int,input().split())
a=list(range(l,l+n,1))
x=sum(a)
if(a in 0):
  a.remove(0)
  print(sum(a))
elif(x<0):
  a.remove(max(a))
  print(sum(a))
elif(x>0):
  a.remove(min(a))
  print(sum(a))
Problem p03495 (python)

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
x=[0 for i in range(n)]
y=[]
s=0
for i in range(n):
  x[a[i]-1]+=1
    
for i in range(n):
  if x[i]:
    y.append(x[i])
y.sort()
z=len(y)
i=0
while(z>k):
  s+=y[i]
  z-=1
  i+=1
print(s)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
x=[0 for i in range(n)]
y=[]
s=0
for i in range(n):
  if a[i] in a:
    x[a[i]-1]+=1
    
for i in range(n):
  if x[i]:
    y.append(x[i])
y.sort()
i=0
while(len(y)>k):
  s+=y[i]
  y.pop(i)
  i+=1
print(s)
Problem p02534 (python)

Fixed submission:
k = int(input())
ans=[]
for i in range(k):
  ans.append("ACL")

print("".join(ans))

Buggy submission (verdict: Runtime Error):
k=input()
ans=[]
for i in range(int(k)):
  ans.append("ACL")

print("".joint(ans))

Buggy submission (verdict: Runtime Error):
import sys
k=sys.stdin
ans=[]
for i in range(int(k)):
  ans.append("ACL")

print("".joint(ans))

Buggy submission (verdict: Runtime Error):
k=sys.stdin
ans=[]
for i in range(int(k)):
  ans.append("ACL")

print("".joint(ans))

Buggy submission (verdict: Runtime Error):
k=input()
ans=[]
for i in range(k):
  ans.append("ACL")

print("".joint(ans))

Buggy submission (verdict: Runtime Error):
k=input()
ans=[]
for i in range(k):
  ans.append("ACL")
 
print("".joint(ans))
Problem p02585 (python)

Fixed submission:
n,k = map(int, input().split())
p = [0]+[int(x) for x in input().split()]
c = [0]+[int(x) for x in input().split()]

ans=-10**18

for saisyo in range(1,n+1):
    tensuulist=[]
    genzaiti=saisyo

    while(True):
        genzaiti=p[genzaiti]
        tensuulist.append(c[genzaiti])
        if genzaiti==saisyo:
            break

    goukei=sum(tensuulist)
    nagasa=len(tensuulist)
    kaisuu=k
    syou=kaisuu//nagasa
    amari=kaisuu%nagasa

    tensuu=0
    nokorikaisuu=0

    if goukei<=0:
        for i in range(nagasa):
            tensuu+=tensuulist[i]
            ans=max(ans,tensuu)
    else:
        if 3*nagasa<kaisuu:
            tensuu+=goukei*(syou-1)
            nokorikaisuu=nagasa+amari
            for i in range(nokorikaisuu):
                tensuu+=tensuulist[(i%nagasa)]
                ans=max(ans,tensuu)
        else:
            for i in range(kaisuu):
                tensuu+=tensuulist[(i%nagasa)]
                ans=max(ans,tensuu)

print(ans)

Buggy submission (verdict: Runtime Error):

            break

    if sum(tensuulist)<=0:
        continue
    else:
        syuki=len(tensuulist)
        tensuu+=(nokoriidoukaisuu//syuki)*sum(tensuulist)
        nokoriidoukaisuu%=syuki
        for i in range(nokoriidoukaisuu):
            tensuu+=tensuulist[i]
            ans=max(ans,tensuu)

print(ans)

Buggy submission (verdict: Runtime Error):

            break

    if sum(tensuulist)<=0:
        continue
    else:
        syuki=len(tensuulist)
        tensuu+=(nokoriidoukaisuu//syuki)*sum(tensuulist)
        nokoriidoukaisuu%=syuki
        for i in range(nokoriidoukaisuu):
            tensuu+=tensuulist[i]
            ans=max(ans,tensuu)

print(ans)
Problem p02630 (python)

Fixed submission:
n = int(input())
a = [int(x) for x in input().split()]
q = int(input())
bc=[]
for i in range(q):
    bc.append([int(x) for x in input().split()])

a_cnt=[0]*(10**5+1)

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

a_goukei=sum(a)

for gyou in range(q):
	a_goukei+=(bc[gyou][1]-bc[gyou][0])*a_cnt[bc[gyou][0]]
	print(a_goukei)
	a_cnt[bc[gyou][1]]+=a_cnt[bc[gyou][0]]
	a_cnt[bc[gyou][0]]=0

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(x) for x in input().split()]
q = int(input())
bc=[]
for i in range(q):
    bc.append([int(x) for x in input().split()])

a_cnt=[0]*(10**5)

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

a_goukei=sum(a)

for gyou in range(q):
	a_goukei+=(bc[gyou][1]-bc[gyou][0])*a_cnt[bc[gyou][0]]
	print(a_goukei)
	a_cnt[bc[gyou][1]]+=a_cnt[bc[gyou][0]]
	a_cnt[bc[gyou][0]]=0

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(x) for x in input().split()]
q = int(input())
bc=[]
for i in range(q):
    bc.append([int(x) for x in input().split()])

a_cnt=[0]*(10**5)

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

a_goukei=sum(a)

for gyou in range(q):
	a_goukei+=(bc[gyou][1]-bc[gyou][0])*a_cnt[bc[gyou][0]]
	print(a_goukei)
	a_cnt[bc[gyou][1]]+=a_cnt[bc[gyou][0]]
	a_cnt[bc[gyou][0]]=0

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(x) for x in input().split()]
q = int(input())
bc=[]
for i in range(q):
    bc.append([int(x) for x in input().split()])

a_cnt=[0]*(10**5)

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

a_goukei=sum(a)

for gyou in range(q):
	a_goukei+=(bc[gyou][1]-bc[gyou][0])*a_cnt[bc[gyou][0]]
	print(a_goukei)
	a_cnt[bc[gyou][1]]+=a_cnt[bc[gyou][0]]
	a_cnt[bc[gyou][0]]=0
Problem p02642 (python)

Fixed submission:
n = int(input())

a = [int(x) for x in input().split()]

baisuu=[0]*(10**6+1)

for i in a:
	if baisuu[i]>=1:
		baisuu[i]=2
		continue

	for j in range(i,10**6+1,i):
		baisuu[j]+=1

ans=0

for i in a:
	if baisuu[i]==1:
		ans+=1

print(ans)

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

a = [int(x) for x in input().split()]

a.sort()
if a[0]==a[1]:
	ans=0
else:
	ans=1

for i in range(0,len(a)):
	for j in range(len(a)):
		if a[i]%a[j]==0:
			break
		if j==i-1:
			ans+=1
			break

print(ans)
Problem p02658 (python)

Fixed submission:
def main():
    N = int(input())
    A = list(map(int,input().split()))
    if 0 in A:
        print(0)
        return
    prod = 1
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1)
            return
    print(prod)
    
main()

Buggy submission (verdict: Runtime Error):
def main():
N = int(input())
A = list(map(int,input().split()))
if 0 in A:
    print(0)
    return
prod = 1
for a in A:
    prod *= a
    if prod > 1000000000000000000:
        print(-1)
        return
print(prod)
main()

Buggy submission (verdict: Runtime Error):
def main():
N = int(input())
A = list(map(int,input().split()))
if 0 in A:
    print(0)
    return
prod = 1
for a in A:
    prod *= a
if prod > 1000000000000000000:
    print(-1)
    return
print(prod)
main()

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(x) for x in input().split()]

if 0 in A:
    print(0)
    return

prod = 1
for a in A:
prod *= a
if prod > 10**18:
    print(-1)
    return

print(prod)

Buggy submission (verdict: Runtime Error):
N = input()
A = [int(x) for x in input().split()]

a=1
b=False
for i in range(N):
    a=a*A[i]
    if a>10^18:
        b=True
        continue

if b==False:
    print(a)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
N = input()
A = [int(x) for x in input().split()]

a=1
b=False
for i in range(N):
    a=a*A[i]
    if a>10^18:
        b=True
        continue

if b==False:
    print(a)
else:
    print(-1)
Problem p02850 (python)

Fixed submission:
n=int(input())
kotaezyun=[]
renketu=[[] for i in range(n+1)]
ans_dict={}
for i in range(n-1):
    a,b=map(int, input().split())
    renketu[a].append(b)
    kotaezyun.append([a,b])

from collections import deque
que=deque()

que.append(1)

iro=[-1]*(n+1)
iro[1]=0
irokazu=0

tansaku_moto=[1]

while que:
    tansaku_moto=que.popleft()
    ironuri=1
    for tansaku_saki in renketu[tansaku_moto]:
        if ironuri==iro[tansaku_moto]:
            ironuri+=1
        iro[tansaku_saki]=ironuri
        ans_dict[tansaku_moto,tansaku_saki]=ironuri
        que.append(tansaku_saki)
        irokazu=max(irokazu,ironuri)
        ironuri+=1
        
print(irokazu)
for i in range(n-1):
    tmp=(kotaezyun[i][0],kotaezyun[i][1])
    print(ans_dict[tmp])

Buggy submission (verdict: Runtime Error):
n=int(input())
ans_list=[[0]*(n+1) for i in range(n+1)]
kotaezyun=[]
renketu=[[] for i in range(n+1)]
for i in range(n-1):
    a,b=map(int, input().split())
    renketu[a].append(b)
    kotaezyun.append([a,b])

from collections import deque
que=deque()

que.append(1)

iro=[-1]*(n+1)
iro[1]=0
irokazu=0

tansaku_moto=[1]

while que:
    tansaku_moto=que.popleft()
    ironuri=1
    for tansaku_saki in renketu[tansaku_moto]:
        if ironuri==iro[tansaku_moto]:
            ironuri+=1
        ans_list[tansaku_moto][tansaku_saki]=ironuri
        iro[tansaku_saki]=ironuri
        que.append(tansaku_saki)
        irokazu=max(irokazu,ironuri)
        ironuri+=1
        
print(irokazu)
for i in range(n-1):
    print(ans_list[kotaezyun[i][0]][kotaezyun[i][1]])
Problem p02918 (python)

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

s_list=[]
for i in s:
    if i=="L":s_list.append(0)
    else:s_list.append(1)
start_num=s_list[0]
i=0
while k>0:
    if i>=n:break
    if s_list[i]!=start_num:
        k-=1
        while i<n and s_list[i]!=start_num:
            s_list[i]=start_num
            i+=1
    i+=1
ans=0
for i in range(n):
    if i+1<n and s_list[i]==1 and s_list[i+1]==1:
        ans+=1
    if i-1>=0 and s_list[i]==0 and s_list[i-1]==0:
        ans+=1
print(ans)

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

s_list=[]
for i in s:
    if i=="L":s_list.append(0)
    else:s_list.append(1)
start_num=s_list[0]
i=0
while k>0:
    if s_list[i]!=start_num:
        k-=1
        while i<n and s_list[i]!=start_num:
            s_list[i]=start_num
            i+=1
    i+=1
ans=0
for i in range(n):
    if i+1<n and s_list[i]==1 and s_list[i+1]==1:
        ans+=1
    if i-1>=0 and s_list[i]==0 and s_list[i-1]==0:
        ans+=1
print(ans)
Problem p03071 (python)

Fixed submission:
a, b= (int(i) for i in input().split())  

if a>=b:
    k=a
    a=a-1
else:
    k=b
    b=b-1

if a>=b:
    k=k+a
else:
    k=k+b

print(k)

Buggy submission (verdict: Runtime Error):
if a>=b:
    k=a
    a=a-1
else:
    k=b
    b=b-1

if a>=b:
    k=k+a
else:
    k=k+b

print(k)
Problem p02584 (python)

Fixed submission:
X, K,D = map(int, input().split())

if X >= K * D:
    print(X - K * D)
elif X <= K * (- D):
    print(abs(X + K * D))
else:
    if X >= 0:
        pos = X % D
        neg = X % D - D
        if K % 2 == (X // D) % 2:
            print(pos)
        else:
            print(abs(neg))
    elif X <= 0:
        pos = D - (abs(X) % D)
        neg = - (abs(X) % D)
        if K % 2 == (abs(X) // D) % 2:
            print(abs(neg))
        else:
            print(pos)

Buggy submission (verdict: Runtime Error):
X, K,D = map(int, input().split())

if X >= K * D:
    print(X - K * D)
elif X <= K * (- D):
    print(abs(X + K * D))
else:
    if X >= 0:
        pos = X % D
        neg = X % D - D
        if K % 2 == (X // D) % 2:
            print(pos)
        else:
            print(abs(neg))
    if X <= 0:
        pos = D - (abs(X) % D)
        neg = - (abs(X) % D)
        if K % 2 == (X // D) % 2:
            print(abs(neg)
        else:
            print(pos))
Problem p02806 (python)

Fixed submission:
N = int(input())
s = ["" for i in range(N)]
t = [0 for i in range(N)]
for i in range(N):
    s_str, t_str = input().split()
    s[i] = s_str
    t[i] = int(t_str)
    
X = input()
ans = 0
count = False
for i in range(N):
    if count:
        ans += t[i]
    if s[i] == X:
        count = True
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
s = ["" for i in range(N)]
t = [0 for i in range(N)]
for i in range(N):
    s_str, t_str = input().split()
    s[i] = s_str
    t[i] = int(t_str)
    
X = input()
ans = 0
count = False
for i in range(X):
    if count:
        ans += t[i]
    if s[i] == X:
        count = True
print(ans)