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

Fixed submission:
import math

N = int(input())
memo = [0]*(N+1)
memo[0] = 0

for i in range(1,N+1):
	memo[i] = memo[i-1]+1
	j = 1
	while pow(6,j) <= i:  
		memo[i] = min(memo[i],memo[i-pow(6,j)]+1)
		j += 1
	j = 1
	while pow(9,j) <= i:
		memo[i] = min(memo[i],memo[i-pow(9,j)]+1)
		j += 1

print(memo[-1])

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
memo = [0]*(N+1)
memo[0] = 0

for i in range(1,N+1):
	memo[i] = memo[i-1]+1
	for j in range(1,iny(math.log(i,6))+1):
		memo[i] = min(memo[i],memo[i-pow(6,j)]+1)
	for j in range(1,int(math.log(i,9))+1):
		memo[i] = min(memo[i],memo[i-pow(9,j)]+1)

print(memo[-1])
Problem p02835 (python)

Fixed submission:
a, b, c = map(int, input().split())
if a+b+c >= 22 :
    print("bust")
else:
    print("win")

Buggy submission (verdict: Runtime Error):
def checker(bbit,listN,N):
    i = 0
    j = 0
    ng = False
    #print(N)
    #print(listN)
    #print(bin(bbit))
    while N > i :
        j=0
        checkFig = 3
        ibit = 1 << i
        while N > j :
            cbit = 1 << j
            if bbit & cbit == 0 :
                #print("A:{} {}".format(j,i))
                pass
            elif listN[j][i] == 3 :
                #print("B:{} {}".format(j,i))
                pass
            elif (listN[j][i] == 0) and (bbit & ibit != 0):
                ng = True
                break
            elif checkFig == 3 :
                #print("C:{} {}".format(j,i))
                checkFig = listN[j][i]
            elif checkFig != listN[j][i] :
                ng = True
                #print("D:{} {}".format(j,i))
                break
            j += 1
        if ng :
            #print(ng)
            break
        else :
            i +=1
    return (not ng)


def main():
    N = int(input())
    listA = [[3 for j in range(N)] for k in range(N)]
    n = 0
    while N > n :
        a = int(input())
        i = 0
        while a > i:
           x,y  = map(int,input().split())
           listA[n][x-1] = y
           i += 1
        n += 1
        
    honestBit = pow(2, N)-1
    honest = 0
    
    while honestBit > 0:
        ok = checker(honestBit,listA,N)
        if ok :
            okbit = honestBit
            oknum = 0
            while okbit > 0 :
                oknum += (okbit % 2) 
                okbit /= 2
            
            if oknum > honest :
                honest = oknum 
        honestBit -= 1
    

main()
Problem p02831 (python)

Fixed submission:
a, b = map(int, input().split())
gcd = 0

x = max(a, b)
y = min(a, b)
if x % y == 0:
    gcd = y
else:
    while x % y != 0:
        z = x % y
        x = y
        y = z
    gcd = z

ans = a * b / gcd

print(int(ans))

Buggy submission (verdict: Runtime Error):
import math

a, b = map(int, input().split())
ans = a*b / math.gcd(a, b)
print(int(ans))
Problem p02835 (python)

Fixed submission:
a,b,c = map(int,input().split())

x = a+b+c

if int(x) <= 21:
    print('win')

else:
    print('bust')

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
c = input()

x = int(a)+int(b)+int(c)

print(x)

if int(x) <= 21:
    print('win')

else:
    print('bust')
Problem p02831 (python)

Fixed submission:
import math
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
def lcm(x, y):
    return (x * y) // gcd(x, y)
A,B=map(int,input().split())
print(lcm(A, B))

Buggy 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))
Problem p02829 (python)

Fixed submission:
a=int(input())
b=int(input())
c=1
for i in range(3):
  if a==c or b==c:
    c=c+1
  else:
    print(c)
    break

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=1
for i in round(3):
  if a==c or b==c:
    c=c+1
  else:
    print(c)
    break
Problem p03073 (python)

Fixed submission:
S = input()
from collections import Counter as c

od,ev = [],[]#od=奇数 ev=偶数
for s,i in zip(S,range(1,len(S)+1)):
    if i%2 == 0:
        ev.append(s)
    else:
        od.append(s)
odd = c(od).most_common(2)
eve = c(ev).most_common(2)
N = len(S)
N,odd,eve
if len(odd) != 2:
    odd.append(('9',0))
if len(eve) != 2:
    eve.append(('9',0))
if N == 1:
    ans = 0
elif odd[0][0] != eve[0][0]:
    ans = N-odd[0][1]-eve[0][1]
else:
    if len(odd) == len(eve) == 1:
        ans = N//2
    else:
        ans = N-max(odd[0][1]+eve[1][1],odd[1][1]+eve[0][1])
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
def func():
    from collections import Counter as c
    ev,od = [],[]
    for i in range(len(S)):
        ev.append(S[i]) if i%2 == 0 else 0
        od.append(S[i]) if i%2 == 1 else 0
    ev = c(ev).most_common()
    od = c(od).most_common()
    if len(od) == 0:
        return 0
    if ev[0][0] != od[0][0]:
        return len(S)-ev[0][1]-od[0][1]
    else:
        if len(ev) == 1 or len(od) == 1:
            return len(S)//2
        else:
            return max(ans,len(S)-ev[0][1]-od[1][1],len(S)-ev[1][1]-od[0][1])
print(func())
Problem p03077 (python)

Fixed submission:
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
if N%min(A,B,C,D,E) == 0:z = 4
else:z = 5
print(int(z+N/min(A,B,C,D,E)))

Buggy submission (verdict: Runtime Error):
ABC = [N,0,0,0,0]
time = 0
flag = 0
i = 0
while ABC[4] > 0 or flag == 0:
    print(ABC)
    if i >= 4:
        if ABC[4] >= E:
            ABC[4]-=E
        else:
            ABC[4]=0
    if i >= 3:
        if ABC[3] >= D:
            ABC[3]-=D
            ABC[4]+=D
            flag = 1
        else:
            ABC[4]+=ABC[3]
            flag = 1
            ABC[3]=0
    if i >= 2:
        if ABC[2] >= C:
            ABC[2]-=C
            ABC[3]+=C
        else:
            ABC[3]+=ABC[2]
            ABC[2]=0
    if i >= 1:
        if ABC[1] >= B:
            ABC[1]-=B
            ABC[2]+=B
        else:
            ABC[2]+=ABC[1]
            ABC[1]=0
    if ABC[0] >= A:
        ABC[0]-=A
        ABC[1]+=A
    else:
        ABC[1]+=ABC[0]
        ABC[0]=0
        
        
    time += 1
    i += 1
print('end',ABC)
print(time)
Problem p03104 (python)

Fixed submission:
def xor(x):
    res = [x,1,x+1,0]
    return res[x%4]

A,B = map(int,input().split())
print(xor(A-1)^xor(B))

Buggy submission (verdict: Runtime Error):
A,B = map(int,input().split())
start = time.time()
if 0 <= A <= B <= 10**12:
    #A,B = bin(A),bin(B)
    total = A
    a,b,c = A+1,B+1,1
    for i in range(a,b,c):
        total ^= i
    print(total)
Problem p03107 (python)

Fixed submission:
S = input()
i = 0
total = 0
while i < len(S):
    if S[i:i+2] == '01'or S[i:i+2] == '10':
        Sa = S[:i]
        Sb = S[i+2:]
        S = Sa+Sb
        total += 1
        i -= 1
    else:
        i += 1
print(total*2)

Buggy submission (verdict: Runtime Error):
S = input()
ans = 0
while i < len(S):
    if any(['01' in S[i:i+2],'10' in S[i:i+2]]):
        S = S[:i]+S[i+2:]
        ans += 2
        i -= 1
    else:
        i += 1
print(ans)

Buggy submission (verdict: Runtime Error):
i = 0
total = 0
while i < len(S):
    if S[i:i+2] == '01'or S[i:i+2] == '10':
        Sa = S[:i]
        Sb = S[i+2:]
        S = Sa+Sb
        total += 1
        i -= 1
    else:
        i += 1
print(total*2)
Problem p03137 (python)

Fixed submission:
N,M = map(int,input().split())
X = sorted(map(int,input().split()))
L = sorted([X[i+1]-X[i] for i in range(M-1)])
if M < N:print(0)
else:print(sum(L[:(M-N)]))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
X = sorted(map(int,input().split()))
L = sorted([X[i+1]-X[i] for i in range(M-1)])
if M < L:print(0)
else:print(sum(L[:(M-N)]))
Problem p03209 (python)

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

A = [1]
P = [1]
for i in range(n):
	A.append(A[i]*2+3)
	P.append(P[i]*2+1)
# print(A,P)

def func(n,x):
	if x == 1:
		return 0 if n != 0 else 1
	elif x <= 1+A[n-1]:
		return func(n-1,x-1)
	elif x == 2+A[n-1]:
		return P[n-1]+1
	elif x <= 2+2*A[n-1]:
		return P[n-1]+1+func(n-1,x-2-A[n-1])
	else:
		return 2*P[n-1]+1

print(func(n,x))

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

A = [1]
P = [1]
for i in range(n):
	A.append(A[i]*2+3)
	P.append(P[i]*2+1)
print(A,P)

def func(n,x):
	elif x == 1:
		return 0 if n != 0 else 1
	elif x <= 1+A[n-1]:
		return func(n-1,x-1)
	elif x == 2+A[n-1]:
		return P[n-1]+1
	elif x <= 2+2*A[n-1]:
		return P[n-1]+1+func(n-1,x-2-A[n-1])
	else:
		return 2*P[n-1]+1

print(func(n,x))
Problem p03221 (python)

Fixed submission:
N,M = map(int,input().split())
PY = [list(map(int,input().split())) for _ in range(M)]
for i in range(M):
    PY[i].append(i)
PY.sort(key=lambda x:x[1])
ans = [0]*M
num = [0]*N
for p,y,i in PY:
    ans[i] = str(p).zfill(6) + str(num[p-1]+1).zfill(6)
    num[p-1] += 1
for s in ans:print(s)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
PY = [list(map(int,input().split())) for _ in range(M)]
for i in range(M):
    PY[i].append(i)
PY.sort(key=lambda x:x[1])
ans = [0]*M
num = [0]*max(N,M)
for p,y,i in PY:
    ans[i] = str(p).zfill(6) + str(num[p]+1).zfill(6)
    num[p] += 1
for s in ans:print(s)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
PY = [list(map(int,input().split())) for _ in range(M)]
for i in range(M):
    PY[i].append(i)
PY.sort(key=lambda x:x[1])
ans = [0]*M
num = [0]*N
for p,y,i in PY:
    ans[i] = str(p).zfill(6) + str(num[p]+1).zfill(6)
    num[p] += 1
for s in ans:print(s)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
PY = [list(map(int,input().split())) for _ in range(M)]
for i in range(M):
    PY[i].append(i)
PY.sort(key=lambda x:x[1])
ans = [0]*M
num = [0]*M
for p,y,i in PY:
    ans[i] = str(p).zfill(6) + str(num[p]+1).zfill(6)
    num[p] += 1
for s in ans:print(s)
Problem p03329 (python)

Fixed submission:
N = int(input())

def f9(a,i):
    if a < 9**i:
        return i-1
    return f9(a,i+1)

def f6(a,i):
    if a < 6**i:
        return i-1
    return f6(a,i+1)

def func(a,ans):
    if a < 6:
        return ans+a
    elif a < 9:
        return ans+1+(a-6)
    return min(func(a-6**f6(a,0),ans+1),func(a-9**f9(a,0),ans+1))

print(func(N,0))

Buggy submission (verdict: Runtime Error):
%%timeit
def f9(a,i):
    if a < 9**i:
        return i-1
    return f9(a,i+1)

def f6(a,i):
    if a < 6**i:
        return i-1
    return f6(a,i+1)

def func(a,ans):
    if a < 6:
        return ans+a
    elif a < 9:
        return ans+1+(a-6)
    return min(func(a-6**f6(a,0),ans+1),func(a-9**f9(a,0),ans+1))

print(func(N,0))
Problem p02916 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = sum(b)
for i in range(len(a)-1):
    if a[i+1] - a[i] == 1:
        ans += c[a[i]-1]
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = sum(b)
for i in range(len(a)-1):
    if a[i+1] - a[i] == 1:
        if a[i] == 1:
            ans += c[0]
        else:
            ans += c[i+1]
print(ans)
Problem p02987 (python)

Fixed submission:
s = input()
a = []
for n in s:
    a.append(n)
if a.count(a[0]) == 2 and a.count(a[1]) == 2 and a.count(a[2]) == 2 and a.count(a[3]) == 2:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
cnt = 0
for i in range(n-2):
    if a[i] < a[i+1] < a[i+2] or a[i+2] < a[i+1] < a[i]
        cnt += 1
print(cnt)
Problem p03835 (python)

Fixed submission:
K, S = map(int,input().split())
ans = 0
for x in range(K+1):
    for y in range(K+1):
        if S - x - y >= 0 and S - x - y <= K:
            ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
K, S = map(int,input().split())
ans = 0
for x in range(K+1):
    for y in range(K+1):
        z = S - x - y
        if z >= 0 and Z <= K:
            ans += 1
print(ans)
Problem p02933 (python)

Fixed submission:
a=int(input())
s=input()
if a>=3200:
    print(s)
else:
    print('red')

Buggy submission (verdict: Runtime Error):
N=int(input())
a=[int(x) for x in input().split()]
b=0
for i in range(N):
    b+=1/a[i]
    
print(1/b)
Problem p02933 (python)

Fixed submission:
a = int(input())
s =input()

if a >= 3200:
	print(s)
else:
	print('red')

Buggy submission (verdict: Runtime Error):
a = int(input())
s = int(input())

if a >= 3200:
	print(s)
else:
	print('red')a = int(input())
s =input()

if a >= 3200:
	print(s)
else:
	print('red')
Problem p02831 (python)

Fixed submission:
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

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

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

Buggy submission (verdict: Runtime Error):
import math

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

print((a * b) // math.gcd(a, b))
Problem p02831 (python)

Fixed submission:
import fractions
s, t = input().split()
s = int(s)
t = int(t)
result = s * t / fractions.gcd(s,t)
print(int(result))

Buggy submission (verdict: Runtime Error):
import math
s, t = input().split()
s = int(s)
t = int(t)
result = s * t / math.gcd(s,t)
print(int(result))

Buggy submission (verdict: Runtime Error):
import math
s, t = input().split()
s = int(s)
t = int(t)
result = s * t // math.gcd(s,t)
print(result)
Problem p02879 (python)

Fixed submission:
a, b = map(int, input().split())
if a >= 10 or b >= 10:
    print(-1)
else:
    print(a*b)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split()
if a >= 10 or b >= 10:
    print(-1)
else:
    print(a*b)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
if a >= 10 or b >= 10:
    print(-1)
else:
    print(a*b)
Problem p02831 (python)

Fixed submission:

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

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



def lcm(a,b):
  return a*b//gcd(a,b)


print(lcm(a, b))

Buggy submission (verdict: Runtime Error):
import math

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

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))

Buggy submission (verdict: Runtime Error):
import math

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

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))
Problem p02847 (python)

Fixed submission:
n = input()

if(n == "SUN"):
    print(7)
elif (n == "MON"):
    print(6)
elif (n == "TUE"):
    print(5)
elif (n == "WED"):
    print(4)
elif (n == "THU"):
    print(3)
elif (n == "FRI"):
    print(2)
elif (n == "SAT"):
    print(1)

Buggy submission (verdict: Runtime Error):
weekday = [SUN,MON,TUE,WED,THU,FRI,SAT]
s = input()

if(s == "SUN"):
    print("7")
if(s == "MON"):
    print("6")
if(s == "TUE"):
    print("5")
if(s == "WED"):
    print("4")
if(s == "THU"):
    print("3")
if(s == "FRI"):
    print("2")
if(s == "SAT"):
    print("1")
Problem p02860 (python)

Fixed submission:
i = int(input())
s = input()
n = i // 2
s1 = s[0:n]
s2 = s[n:i]

if((i % 2 == 0)and(s1 == s2)):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
i = int(input())
s = input()
n = i // 2
s1 = s[0:n]
s2 = s[n:i]
#print(s1)
#print(s2)

if((i % 2 == 0)and(s1 == s2)):
    print("Yes")
e6lse:
    print("No")
Problem p02831 (python)

Fixed submission:
def q3(a,b):
  x = a*b
  if(a<b):
    tmp = a
    a=b
    b=tmp
  r=a%b
  while(not(r==0)):
    a=b
    b=r
    r=a%b
  return int(x/b)


ans = input().split()
a = int(ans[0])
b = int(ans[1])
print(q3(a,b))

Buggy submission (verdict: Runtime Error):
import numpy as np
def q3(a,b):
    return np.lcm(a,b)

ans = input().split()
a = int(ans[0])
b = int(ans[1])
print(q3(a,b))
Problem p02831 (python)

Fixed submission:
import fractions as fr

a, b= map(int, input().split())
def lcm(x,y):
    return (x*y/fr.gcd(x,y))

print(int(lcm(a,b)))

Buggy submission (verdict: Runtime Error):
import numpy as np

a, b= map(int, input().split())
def lcm(x,y):
    return (x*y/np.gcd(x,y))

print(int(lcm(a,b)))

Buggy submission (verdict: Runtime Error):
import math

a, b= map(int, input().split())
def lcm(x,y):
    return (x*y/math.gcd(x,y))

print(int(lcm(a,b)))

Buggy submission (verdict: Runtime Error):
import math

a, b= map(int, input().split())
def lcm(x,y):
    return (x*y/math.gcd(x, y))

print(int(lcm(a, b)))

Buggy submission (verdict: Runtime Error):
import math

a, b= map(int, input().split())
def lcm(x,y):
    return x*y/math.gcd(x, y)

print(int(lcm(a, b)))

Buggy submission (verdict: Runtime Error):
import math

a, b= map(int, input().split())
def lcm(x, y):
    return (x * y)/math.gcd(x, y)

print(int(lcm(a, b)))

Buggy submission (verdict: Runtime Error):
import math

a, b= map(int, input().split())
def lcm(x, y):
    return (x * y)//math.gcd(x, y)

print(lcm(a, b))

Buggy submission (verdict: Runtime Error):
import math

a, b= map(int, input().split())
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))

Buggy submission (verdict: Runtime Error):
import math

a, b= map(int, input().split())
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))
Problem p02912 (python)

Fixed submission:
import heapq

tmp = list(map(int,(input().split())))
n = tmp[0]
m = tmp[1]

ai = []
tmp = list(map(int,(input().split())))
for i in range(n):
  heapq.heappush(ai, -tmp[i])

for i in range(m):
  maxp = - heapq.heappop(ai)
  maxp = maxp // 2
  heapq.heappush(ai, -maxp)
  
sum = 0
for i in range(n):
  sum += -ai[i]

#print(ai)
print(sum)

Buggy submission (verdict: Runtime Error):
tmp = list(map(int,(input().split())))
n = tmp[0]
m = tmp[1]

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

while (m > 0): 
  ai.sort(reverse=True)
  for i in range(n-1):
    if ai[i] >= ai[i+1] :
      m -= 1
      ai[i] = ai[i] // 2

for i in range(n):
  sum += ai[i]

# print(ai)
print(sum)
Problem p02990 (python)

Fixed submission:
MOD = 1000000007
tmp = list(map(int, input().split()))
n = tmp[0]
k = tmp[1]

co = 1
ci = 1
for i in range(k):
  co *= (n-k+1-i)
  co //= (i+1)
  if i == 0:
    ci *= 1
  else:
    ci *= (k-i)
    ci //= (i)
#  print (str(ci)+' '+str(co)+' '+str(int(co * ci) % MOD))
  print (int(co * ci) % MOD)

Buggy submission (verdict: Runtime Error):
tmp = list(map(int, input().split()))
n = tmp[0]
k = tmp[1]

c = 1
for i in range(1, k+1):
  co = 1
  for j in range(i):
    co *= (n-k+1-j) / (j+1)
  ci = 1
  for j in range(i-1):
    ci *= (k-1-j) / (j+1)

  print (int(co * ci) % (10**9+7))
Problem p03038 (python)

Fixed submission:
import heapq

tmp = list(map(int, input().split()))
n = tmp[0]
m = tmp[1]
a = list(map(int, input().split()))

heapq.heapify(a)

cb = []
for j in range(m):
  tmp = list(map(int, input().split()))
  cb.append((tmp[1], tmp[0]))
cb.sort(reverse=True)

for j in range(m):
  if cb[j][0] < a[0]:
    break
  for k in range(cb[j][1]):
    if a[0] < cb[j][0]:
      heapq.heappop(a)
      heapq.heappush(a, cb[j][0])
    else:
      break

print(sum(a))

Buggy submission (verdict: Runtime Error):
tmp = list(map(int, input().split()))
n = tmp[0]
m = tmp[1]
a = list(map(int, input().split()))

ha = []
for i in range(n):
  heapq.heappush(ha, a[i])

for j in range(m):
  tmp = list(map(int, input().split()))
  b = tmp[0]
  c = tmp[1]

  for k in range(b):
    if ha[0] < c:
      heapq.heappop(ha)
      heapq.heappush(ha, c)
    else:
      break

print(sum(ha))
Problem p03077 (python)

Fixed submission:
import math

n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

neck = min(a,b,c,d,e)

cnt = 5 + math.ceil(n / neck) - 1

print(cnt)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

neck = min(a,b,c,d,e)

cnt = 5 + math.ceil(n / neck) - 1

print(cnt)
Problem p02832 (python)

Fixed submission:
N = int(input())
X = tuple(map(int, input().split()))

c = 0
for x in X:
    if x == c+1:
        c+=1
if c == 0:
    ans = -1
else:
    ans = N-c
print(ans)

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

Y = X[::-1]

li = set(range(N))

for k in li:
    print(Y)
    try:
        i = Y.index(k+1)
        Y = Y[:i]
    except:
        i = -1
        leng = k
        break
    leng = k + 1

if leng == 0:
    ans = -1
else:
    ans = N - leng
print(ans)
Problem p03221 (python)

Fixed submission:
N, M = map(int, input().split())
import sys
PY = [list(map(int,sys.stdin.readline().rstrip().split())) for _ in range(M)]

# ken = {p[0] for p in PY}
# ken_d = {k:[] for k in ken}
ken_d = [[] for _ in range(N+1)]

rankdic = {} # 通し番号：県における順位

for i, p in enumerate(PY):
    # print(p)
    ken_d[p[0]].append([i, p[1]])

for k in range(N+1):
    ken_d[k].sort(key=lambda x:x[1])
    for i, v in enumerate(ken_d[k]):
        rankdic[v[0]] = i # 通し番号辞書に入れる

for i, p in enumerate(PY):
    x = rankdic[i] + 1
    print(str(p[0]).zfill(6) + str(x).zfill(6))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
PY = [None for _ range(M)]
ken_d = {k:[]  for k in range(1, N+1)}

for i in range(M):
    p = list(map(int,input().split()))
    PY[i] = p
    ken_d[p[0]].append(p[1])

for k in ken_d.keys():
    ken_d[k].sort()

for p in PY:
    x = ken_d[p[0]].index(p[1]) + 1
    print(str(p[0]).zfill(6) + str(x).zfill(6))
Problem p02833 (python)

Fixed submission:
n = int(input())
p = 10
su = 0
while p <= n:
   su += n//p
   p*=5

if n%2==1:
    print(0)
else:
    print(su)

Buggy submission (verdict: Runtime Error):
n = int(input())
p = 10
su = 0
while p <= n:
   su += math.floor(n//p)
   p*=5

if n%2==1:
    print(0)
else:
    print(su)
Problem p02831 (python)

Fixed submission:
import sys
import fractions
input  = sys.stdin.readline


def solve():
    A,B = map(int,input().strip().split())
    print( int((A * B) / fractions.gcd(A, B)) )


if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):
import sys
import math
input  = sys.stdin.readline


def solve():
    A,B = map(int,input().strip().split())
    print( int((A * B) / math.gcd(A, B)) )


if __name__ == '__main__':
    solve()
Problem p03107 (python)

Fixed submission:
S = input()

c0=0
c1=0
for i in S:
  if i == '0':
    c0+=1
  else:
    c1+=1

print(2*min(c0,c1))

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

c0=0
c1=0
for i in S:
  if i == '0':
    c0+=1
  elif:
    c1+=1

print(2*min(c0,c1))
Problem p02859 (python)

Fixed submission:
# coding: utf-8
i = int(input())
print(i * i)

Buggy submission (verdict: Runtime Error):
# coding: utf-8
i = input()
print(i * i)
Problem p02860 (python)

Fixed submission:
# coding: utf-8
n = int(input())
s = input()
if n % 2:
	print('No')
else:
	if s[0:int(n/2)] == s[int(n/2):n]:
		print('Yes')
	else:
		print('No')

Buggy submission (verdict: Runtime Error):
# coding: utf-8
n = int(input())
s = input()
if n % 2:
	print('No')
else:
	if s[0:(n/2)] == s[(n/2):n]:
		print('Yes')
	else:
		print('No')
Problem p02831 (python)

Fixed submission:
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

inp = input().split()
A = int(inp[0])
B = int(inp[1])

print(int(A*B/gcd(A, B)))

Buggy submission (verdict: Runtime Error):
import math
inp = input().split()
A = int(inp[0])
B = int(inp[1])

print(int(A*B/math.gcd(A, B)))