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

Fixed submission:
from collections import deque

h, w = map(int, input().split())
inf = 10 ** 6
a = [[0] * (w + 2)] + [[0] + [inf] * w + [0] for _ in range(h)] + [[0] * (w + 2)]
d = deque()

for i in range(h):
    for j, k in enumerate(input()):
        if k == "#":
            a[i + 1][j + 1] = 0
            d.append((i + 1, j + 1))

stp = ((0, 1), (0, -1), (1, 0), (-1, 0))
res = 0

while d:
    x, y = d.popleft()
    for k, l in stp:
        nx, ny = x + k, y + l
        if a[x][y] + 1 < a[nx][ny]:
            a[nx][ny] = a[x][y] + 1
            res = max(res, a[nx][ny])
            d.append((nx, ny))
print(res)

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

h, w = map(int, input().split())
inf = 10 ** 6
a = [[0] * (w + 2), *[[0] + [inf] * w + [0] for _ in range(h)], [0] * (w + 2)]
d = deque()

for i in range(h):
    for j, k in enumerate(input()):
        if k == "#":
            a[i + 1][j + 1] = 0
            d.append((i + 1, j + 1))

stp = ((0, 1), (0, -1), (1, 0), (-1, 0))
res = 0

while d:
    x, y = d.popleft()
    for k, l in stp:
        nx, ny = x + k, y + l
        if a[x][y] + 1 < a[nx][ny]:
            a[nx][ny] = a[x][y] + 1
            res = max(res, a[nx][ny])
            d.append((nx, ny))
print(res)
Problem p03426 (python)

Fixed submission:
dic = {}
h, w, d = map(int, input().split())
lis = [list(input().split()) for _ in range(h)]
for i in range(h):
    for j in range(w):
        dic[int(lis[i][j])] = (i, j)
n = h * w
su = [0] * (n + 1)
for k in range(1, n - d + 1):
    x = dic[k + d][0] - dic[k][0]
    y = dic[k + d][1] - dic[k][1]
    su[k + d] = su[k] + abs(x) + abs(y)

q = int(input())
for i in range(q):
    s, g = map(int, input().split())
    print(su[g] - su[s])

Buggy submission (verdict: Runtime Error):
dic = {}
h, w, d = map(int, input().split())
lis = [list(input().split()) for _ in range(h)]
for i in range(h):
    for j in range(w):
        dic[int(lis[i][j])] = (i, j)
#print(dic)
n = h * w
su = [0] * n
for k in range(1, n - d):
    x = dic[k + d][0] - dic[k][0]
    y = dic[k + d][1] - dic[k][1]
    su[k + d] = su[k] + abs(x) + abs(y)
#print(su)

q = int(input())
for i in range(q):
    s, g = map(int, input().split())
    print(su[g] - su[s])
Problem p03775 (python)

Fixed submission:
n = int(input())
m = n * 1

if n == 1:
    print(1)
    exit()

sqr = int(n**0.5)
l1 = len(str(sqr))

pf = {}
for i in range(2, int(m**0.5) + 1):
    while not m % i:
        pf[i] = pf.get(i, 0) + 1
        m //= i
if m > 1:
    pf[m] = 1

ls = sorted(pf.items(), key=lambda x: x[0], reverse=True)
l2 = len(str(ls[0][0]))
other = n // ls[0][0]
l3 = len(str(other))

if l1 <= l2 < l3:
    print(l3)
else:
    print(max(l1, l2))

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

sqr = int(n**0.5)
l1 = len(str(sqr))

pf = {}
for i in range(2, int(n**0.5) + 1):
    while not n % i:
        pf[i] = pf.get(i, 0) + 1
        n //= i
if n > 1:
    pf[n] = 1

ls = sorted(pf.items(), key=lambda x: x[0], reverse=True)
l2 = len(str(ls[0][0]))

print(max(l1, l2))
Problem p02633 (python)

Fixed submission:
import math
 
k = 1
x = float(input())
while  x*k%360 != 0:
  k += 1	
print(k)

Buggy submission (verdict: Runtime Error):
import math

x = float(input())

if 360%x == 0:
  print(math.floor(k))
else:
  print(math.ceil(k))
Problem p02596 (python)

Fixed submission:
K = int(input())
if K % 2 == 0 or K % 5 == 0:
  print(-1)
else: 
    state = 7 
    state %= K
    cou = 1
    while True:
        if state == 0:
            print(cou)
            break
        state = state *  10 + 7
        state %= K 
        cou+= 1

Buggy submission (verdict: Runtime Error):
N= int(input())
state = input()

newlist = sorted(state)
goalstate = "".join(newlist)

uni = 0
for l in range(len(goalstate)):
    if goalstate[l] == "W":
        uni = l
        break

def bfs(state,goalstate):
    cur_state = deque([state])
    cou = 0
    while cur_state:
        cur = cur_state.popleft()
        if cur == goalstate:
            return cou
            break
        new= list(cur)
        temp = 0
        for i in range(len(goalstate)):
            if new[i] == "W":
                temp = i
                break
        neow= 0
        for j in range(uni-1,len(goalstate)):
            if new[j] == "R":
                neow = j
                break
        tempstr = new.pop(temp)
        temp1str = new.pop(neow-1)
        new.insert(neow,tempstr)
        new.insert(temp,temp1str)
        nowstr = "".join(new)
        cur_state.append(nowstr)
        cou += 1


goal = bfs(state, goalstate)
print(goal)

Buggy submission (verdict: Runtime Error):
from collections import deque
N= int(input())
state = input()
 
newlist = sorted(state)
goalstate = "".join(newlist)
uni = 0
for l in range(len(goalstate)):
    if goalstate[l] == "W":
        uni = l
        break
def bfs(state,goalstate):
    cur_state = deque([state])
    cou = 0
    while cur_state:
        cur = cur_state.popleft()
        if cur == goalstate:
            return cou
            break
        new= list(cur)
        temp = 0
        for i in range(len(goalstate)):
            if new[i] == "W":
                temp = i
                break
        neow= 0
        for j in range(uni-1,len(goalstate)):
            if new[j] == "R":
                neow = j
                break
        tempstr = new.pop(temp)
        temp1str = new.pop(neow-1)
        new.insert(neow,tempstr)
        new.insert(temp,temp1str)
        nowstr = "".join(new)
        cur_state.append(nowstr)
        cou += 1
 
 
goal = bfs(state, goalstate)
print(goal)
Problem p02627 (python)

Fixed submission:
n = input()
if n.isupper() == True:
    print("A")
else:
    print("a")

Buggy submission (verdict: Runtime Error):
n = "A"
if n.isupper() == True:
    print("A")
p = "a"
if p.islower() == True:
  print("a)

Buggy submission (verdict: Runtime Error):
if α.isupper() == True:
    print("A")
else:
    print("a")
Problem p02547 (python)

Fixed submission:
N= int(input())
a = [input().split() for i in range(N)]

Is = []
for i in range(N):
    Ds = a[i]
    if Ds[0] == Ds[1]:
        Is.append(i)

Boooo = False
for i in range(len(Is)-2):
    if Is[i]+1 == Is[i+1] and Is[i+1]+1 == Is[i+2]:
        Boooo = True

if Boooo:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N= int(input())
a = [input().split() for i in range(N)]

n = int(a[0])
Is = []
for i in range(N):
    Ds = list(map(int, a[i].split()))
    if Ds[0] == Ds[1]:
        Is.append(i)

Boooo = False
for i in range(len(Is)-2):
    if Is[i] == Is[i+1] and Is[i+1] == Is[i+2]:
        Boooo = True

if Boooo:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import sys
a = []
for l in sys.stdin:
    a.append(int(l))
n = a[0]
Is = []
for i in range(n):
    Ds = list(map(int, a[i+1].split()))
    if Ds[0] == Ds[1]:
        Is.append(i)

Boooo = False
for i in range(len(Is)-2):
    if Is[i] == Is[i+1] and Is[i+1] == Is[i+2]:
        Boooo = True

if Boooo:
    print("Yes")
else:
    print("No")
Problem p02659 (python)

Fixed submission:
a,b = map(str,input().split())
b100 = int(b[0]) * 100 + int(b[2]) * 10 + int(b[3])
# print(b)
# print(b100)
print((int(a)*b100)//100)

Buggy submission (verdict: Runtime Error):
def prime_factorize(n):
    a = []
    N = n
    cnt = 0
    while n % 2 == 0:
        cnt += 1
        n //= 2
    if cnt > 0:
        a.append(cnt)
        #print(2)
    f = 3
    cnt = 0
    while f * f <= n:

        if n % f == 0:
            cnt += 1
            n //= f
        else:
            f += 2
            cnt = 0
        a.append(cnt)
    if n != 1:
        a.append(1)
    return a


n = int(input())
ans = 0
lis = prime_factorize(n)
#print(lis)

for i in range(len(lis)):
    val = 1
    while val <= lis[i]:
        lis[i] -= val
        val += 1
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
a,b = map(str,input().split())
b100 = int(b[0]) * 100 + int(b[2]) * 10 + int(b[3])
# print(b)
# print(b100)
print(int(int(a)*b/100))
Problem p02793 (python)

Fixed submission:
from collections import Counter
MOD = 10**9+7
N = int(input())
A = list(map(int,input().split()))
def prime_factorize(n):
    N = n
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= N:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
prime = [0] * (10**6+5)
for i in range(N):
    c = Counter(prime_factorize(A[i]))
    for j in c.items():
        prime[j[0]] = max(j[1],prime[j[0]])
lcm = 1
for i in range(10**6+2):
    if prime[i] > 0:
        lcm *= pow(i,prime[i])
        lcm %= MOD

ans = 0
for i in range(N):
    ans += lcm * pow(A[i],MOD-2,MOD)
    ans %= MOD
print(ans)

Buggy submission (verdict: Runtime Error):
from math import gcd
MOD = 10**9+7

def LCM(n,r):
    return ((n*r) * pow(gcd(n,r), MOD-2,MOD)) % MOD
    
N = int(input())
A = list(map(int,input().split()))
lcm = LCM(A[0],A[1])
for i in range(1,N):
    lcm = LCM(lcm,A[i])

ans = 0
for i in range(N):
    ans += lcm * pow(A[i],MOD-2,MOD)
    ans %= MOD
print(ans)
Problem p02847 (python)

Fixed submission:
s = input()
if s == 'SUN':
  print(7)
elif s == 'SAT':
  print(1)
elif s == 'MON':
  print(6)
elif s == 'TUE':
  print(5)
elif s==  'WED':
  print(4)
elif s == 'THU':
  print(3)
else:
  print(2)

Buggy submission (verdict: Runtime Error):
s = input()
if s == 'SUN':
  print(7)
elif s == 'SAT':
  print(1)
elif s == 'MON':
  print(6)
elif s == 'TUE':
  print(5)
elif s==  'WED':
  print(4)
elif s == 'THU':
  print(3)
elif s == 'FRI':
  print(2)= input()

Buggy submission (verdict: Runtime Error):
s = input()
if s = 'SUN':
  print(7)
elif s = 'SAT':
  print(1)
elif s = 'MON':
  print(6)
elif s = 'TUE':
  print(5)
elif s=  'WED':
  print(4)
elif s = 'THU':
  print(3)
elif s = 'FRI':
  print(2)
Problem p02862 (python)

Fixed submission:
mod = int(1e9) + 7
x, y = map(int, input().split())

if (x + y) % 3 != 0:
    print(0)
    exit()

n = (x+y)//3
a = x - n
b = y - n
r = min(a, b)
if r < 0:
    print(0)
    exit()
val1 = 1
for i in range(a+b):
    val1 = (val1 * ((a+b) - i)) % mod
val2 = 1
for i in range(r):
    val2 = (val2 * (r-i)) % mod
for i in range(a+b-r):
    val2 = ((val2% mod) * ((a+b-r)-i)) % mod
# val1 = factorial(a+b) % mod
# val2 = (factorial(r) % mod * factorial((a+b)-r) % mod) % mod
print((val1 * pow(val2,mod-2,mod)) % mod)

Buggy submission (verdict: Runtime Error):
from math import factorial
mod = int(1e9) + 7
x, y = map(int, input().split())

if (x + y) % 3 != 0:
    print(0)
    exit()

n = (x+y)//3
a = x - n
b = y - n
r = min(a, b)
val1 = factorial(a+b) % mod
val2 = (factorial(r) % mod * factorial((a+b)-r) % mod) % mod
print(val1 * pow(val2,mod-2,mod) % mod)
Problem p02879 (python)

Fixed submission:
a, b = map(int, input().split())
c = [1,2,3,4,5,6,7,8,9]
if a in c and b in c:
  print(a*b)
else:
  print('-1')

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

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

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a and b = 1 or 2 or 3 or 4 or 5 or 6 or 7 or 8 or 9:
  print(a * b)
else:
  print('-1')
Problem p02897 (python)

Fixed submission:
N = int(input())
if N%2 ==0:
    print(0.5000000000)
else:
    print(((N // 2 )+1) /N)

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

for i in range(N):
    print(A.index(i+1) +1, end =' ')
Problem p02912 (python)

Fixed submission:
from heapq import heapify, heappop, heappush

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

for i in range(n):
    a[i] *= -1
heapify(a)
#print(a)
for i in range(m):
    maxa = heappop(a)
    heappush(a, -(-maxa//2))
#print(a)
print(-(sum(a)))

Buggy submission (verdict: Runtime Error):
from fractions import gcd
from math import ceil,sqrt
a, b = map(int, input().split())

g = gcd(a,b)

s = set()
for i in range(2,ceil(sqrt(g))+1):
    while g % i == 0:
        g //= i
        s.add(i)
if g != 1:
s.add(int(1e14))
#print(g)
#print(s)
print(len(s)+1)
Problem p02959 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cnt = 0
ans = 0

for i in range(n):
  cnt = b[i] - a[i]
  if cnt > 0:
    ans += a[i]
    if a[i+1] >= cnt:
      ans += cnt
      a[i+1] -= cnt
    else:
      ans += a[i+1]
      a[i+1] =0
      
    
  else:
    ans += b[i]

print(ans)

Buggy submission (verdict: Runtime Error):
cnt = 0
ans = 0

for i in range(n):
  cnt = b[i] - a[i]
  if cnt > 0:
    ans += a[i]
    if a[i+1] >= cnt:
      ans += cnt
      a[i+1] -= cnt
    else:
      ans += a[i+1]
      a[i+1] =0
      
    
  else:
    ans += b[i]

print(ans)
Problem p03013 (python)

Fixed submission:
n, m = map(int, input().split())
a = set()
for i in range(m):
    a.add(int(input()))
dp = [0] * (n+1)
dp[0] = 1
if not(1 in a):
    dp[1] = 1

for i in range(2,n+1):
    if i-1 in a:
        dp[i] = dp[i-2]
        dp[i-1] = 0
    else:
        dp[i] = dp[i-1] + dp[i-2]
#print(dp)
print((dp[n])%1000000007)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = set()
for i in range(m):
    a.add(int(input()))
dp = [0] * (n+1)
dp[0] = 1
if not(1 in a):
    dp[1] = 1
if not(2 in a):
    dp[2] = 1
for i in range(2,n+1):
    if i-1 in a:
        dp[i] = dp[i-2]
        dp[i-1] = 0
    else:
        dp[i] = dp[i-1] + dp[i-2]
#print(dp)
print((dp[n])%1000000007)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = set()
for i in range(m):
    a.add(int(input()))
dp = [0] * (n+1)
dp[0] = 1
if not(1 in a):
    dp[1] = 1
if not(2 in a):
    dp[2] = 1
for i in range(2,n+1):
    if i-1 in a:
        dp[i] = dp[i-2]
        dp[i-1] = 0
    else:
        dp[i] = dp[i-1] + dp[i-2]
print(dp)
print((dp[n])%1000000007)
Problem p03104 (python)

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


def f(keta, x):
    val = 2**keta
    if x < (2 ** (keta)):
        return False
    else:
        x -= (val-1)
        ans = x // (2*val) * val
        ans += min(val,x-val*2*(x//(2*val)))
        return ans
if b == 0:
    print(0)
    exit()
ans = []
i = 0
while f(i,b) != False:
    #print(i)
    val = f(i,b)
    if f(i,a-1) != False:
        val -= f(i,a-1)
    #print(val)
    ans += str(val % 2)
    i += 1

ans.reverse()
print(int(''.join(ans),2))

# print(ans)
# print(f(2, 4))
# print(f(1,4))
# print(bin(435))
# print(f(0,4),f(0,1))

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


def f(keta, x):
    val = 2**keta
    if x < (2 ** (keta)):
        return False
    else:
        x -= (val-1)
        ans = x // (2*val) * val
        ans += min(val,x-val*2*(x//(2*val)))
        return ans

ans = []
i = 0
while f(i,b) != False:
    #print(i)
    val = f(i,b)
    if f(i,a-1) != False:
        val -= f(i,a-1)
    #print(val)
    ans += str(val % 2)
    i += 1
ans.reverse()
print(int(''.join(ans),2))

# print(ans)
# print(f(2, 4))
# print(f(1,4))
# print(bin(435))
# print(f(0,4),f(0,1))
Problem p03252 (python)

Fixed submission:
s = list(input())
t = list(input())
dic = {}
flg = 'Yes'
for i in range(len(s)):
    if s[i] in dic.keys():
        if dic[s[i]] != t[i]:
            flg = 'No'
    else:
        dic[s[i]] = t[i]
dic2 = {}
for i in range(len(s)):
    if t[i] in dic2.keys():
        if dic2[t[i]] != s[i]:
            flg = 'No'
    else:
        dic2[t[i]] = s[i]
#print(dic)
print(flg)

Buggy submission (verdict: Runtime Error):
s = list(input())
t = list(input())
dic = {}
flg = 'Yes'
for i in range(len(s)):
    if s[i] in dic.keys():
        if t[i] !=  dic.values(s[i]):
            flg = 'No'
    else:
        dic[s[i]] = t[i]
print(flg)
Problem p03724 (python)

Fixed submission:
N,M = map(int,input().split())
lis = [0] * N
for i in range(M):
    a,b = map(int,input().split())
    lis[a-1] += 1
    lis[b-1] += 1
ans = 'YES'
for i in lis:
    if i % 2 == 1:
        ans = 'NO'
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
M = int(input())
for i in range(M):
    a,b = map(int,input().split())

if N % 2 == 0 and M % 2 == 0:
    print('Yes')
else:
    print('No')
Problem p02552 (python)

Fixed submission:
x = int(input())
print(1-x)

Buggy submission (verdict: Runtime Error):
print(1-input())
Problem p02623 (python)

Fixed submission:
import bisect

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

for i in range (1, N):
    A[i]+=A[i-1]

for i in range (1, M):
    B[i]+=B[i-1]

V = 0
ACount = bisect.bisect_right(A, K)
if ACount !=0:
    V = K- A[ACount-1]
else:
    V=K

AInitial = ACount

BCount = bisect.bisect_right(B, V)
final = ACount+BCount

for i in range (1, AInitial):
    V = K - A[AInitial-1-i]
    BCount = bisect.bisect_right(B, V)
    final = max(final, AInitial-i+BCount)

final = max(final, bisect.bisect_right(B,K))
print(final)

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

total_max = 0
A_count = 0
B_count = 0

P = K

for i in range (0, N):
	if A[i] < P:
		A_count+=1
		P = P-A[i]
	else:
 		break

for j in range (0, M):
	if B[i] < P:
		B_count+=1
		P = P-B[i]
	else:
 		break

totalmax = A_count+B_count

for i in range (0, A_count):
	D = P + A[A_count-1-i]
	E = D
	zencount = A_count-(i+1)
	for j in range (0, M):
		if B[j] < E:
			E-=B[j]
			zencount+=1
		else:
			break
	if zencount >= totalmax:
		totalmax = zencount

print(totalmax)
Problem p02629 (python)

Fixed submission:
N = int(input())
Alphabet = str('abcdefghijklmnopqrstuvwxyz')
import bisect

List = [0, 26, 702, 18278, 475254, 12356630, 321272406, 8353082582, 217180147158, 5646683826134, 146813779479510, 3817158266467286, 99246114928149462, 2580398988131886038, 67090373691429037014, 1744349715977154962390, 45353092615406029022166, 1179180408000556754576342, 30658690608014475618984918]
V = []

if List.count(N) == 1:
	for i in range (0, List.index(N)):
		V.append('z')
	print(*V, sep = '')
	exit()

k = 26
A = [0]
for i in range (2, 20):
	A.append(k)
	k = k+26**i
    
S = []

B = bisect.bisect_right(A, N)

N = N-A[B-1]-1
for i in range (0, B):
	S.append(Alphabet[N%26])
	N = N//26
    
S = reversed(S)
print(*S, sep = '')

Buggy submission (verdict: Runtime Error):

N = int(input())

S = str()

import math

K = [26, 702, 18278, 475254, 12356630, 321272406, 8353082582, 217180147158, 5646683826134, 146813779479510]

if K.count(N) > 0:
	for i in range (0, K.index(N)+1):
		S=S+'z'
	print(S)
	exit()

import bisect
P = bisect.bisect_right(K, N)
Mel = N- K[P-1]

for i in range (0, P):
	K = Mel//(26**(P-i))
	Mel = Mel-K*(26**(P-i))
	S=S+chr(97+K)

S=S+chr(96+Mel)

print(S)
Problem p03011 (python)

Fixed submission:
a, b, c = map(int, input().split())
print(a+b+c-max(a,b,c))

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
S = [int(input()) for _ in range(W)]
    
floor = list(range(0,H+1))

if S.count(1) >0:
	floor[1]=0
	floor[2]=1
if S.count(2) >0:
    floor[2]=0

for i in range (3, H+1):
		floor[i]=floor[i-2]*(1-S.count(i-2))+floor[i-1]*(1-S.count(i-1))
print(floor[H]%(10**9+7))
Problem p03705 (python)

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

if A == B :
	print(1)
	exit()

print(max(B*(N-1)+A-(A*(N-1)+B)+1,0))

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

if B< A:
	print(0)
elif B = A:
	print(1)
elif B-A+1 > N:
	print(0)
else:
	print((N-2)*B-(N-2)*A+1)
Problem p03077 (python)

Fixed submission:
# 2019/04/07

from numpy import array, zeros
IN_RANGE = 5


# 入力受け取り
N = int(input())
a_e = array([int(input()) for i in range(IN_RANGE)])


minute = 4 + -(- N // a_e.min())
print(minute)

Buggy submission (verdict: Runtime Error):
# 2019/04/07

from numpy import array, zeros
IN_RANGE = 5


# 入力受け取り
N = int(input())
a_e = array([int(input()) for i in range(IN_RANGE)])


# どこに人がいるか
a_e_num = zeros(IN_RANGE+1)
a_e_num[0] = N


# 1分ずつの処理
minute = 0
while a_e_num[N] < N:
    minute += 1
    move_index = (a_e_num[:N] - a_e) >= 0
    move_num = a_e_num[:N].copy()
    move_num[move_index] = a_e[move_index]
    a_e_num[:N] = a_e_num[:N] - move_num
    a_e_num[1:] = a_e_num[1:] + move_num

print(minute)
Problem p02793 (python)

Fixed submission:
from sys import stdin

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

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

readline = stdin.readline
num = int(readline())
d = list(map(int, readline().split()))
k = 1
MOD = 1000000007
ans = 0
for a in d:
    k = lcm(k, a)
for a in d:
    ans += k // a
print(ans % MOD)

Buggy submission (verdict: Runtime Error):
from math import gcd
def lcm(a, b):
    return a // gcd(a, b) * b

def main():
    num = int(input())
    d = list(map(int, input().split()))
    k = 1
    MOD = 1000000007
    ans = 0
    for a in d:
        k = lcm(k, a)
    for a in d:
        ans += k // a % MOD
    print(ans % MOD)

if __name__ == "__main__":
    main()
Problem p02570 (python)

Fixed submission:
data = input()
data = data.split()
print("Yes") if int(data[0]) / int(data[2]) <= int(data[1]) else print("No")

Buggy submission (verdict: Runtime Error):
input_data = input()
data = split(int(input_data))
d = data[0]
t = data[1]
s = data[2]
print("Yes") if d / s > t else print("No")
Problem p02596 (python)

Fixed submission:
K = int(input())
if K==7 or K==1:
  print(1)
else:
  count = 1
  x = 7%K
  for i in range(K):
    x = (x*10+7)%K
    count += 1
    if x==0:
      print(count)
      break
  if x!=0:
    print(-1)

Buggy submission (verdict: Runtime Error):
K = int(input())
if K==7 or K==1:
  print(1)
else:
  count = 1
  for i in range(K):
    x = (x % K) * 10 + 7
    count += 1
    if x==0:
      print(count)
  if x!=0:
    print(-1)
Problem p02570 (python)

Fixed submission:
d, t, s = map(int, input().split())
if d/s <= t:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**9)
n, m = map(int, input().split())

root = [-1]*n

def find(n):
    if root[n] < 0:
        return n
    else:
        root[n] = find(root[n])
        return root[n]

def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    else:
        root[x] += root[y]
        root[y] = x

for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    unite(a, b)

print(-min(root))
Problem p02689 (python)

Fixed submission:
n, m = map(int, input().split())
h = list(map(int, input().split()))
p = [False] + [True]*n
A = []
B = []
for i in range(m):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)

for i in range(m):
    if h[A[i] - 1] > h[B[i] - 1]:
        p[B[i]] = False
    if h[A[i] - 1] < h[B[i] - 1]:
        p[A[i]] = False
    if h[A[i] - 1] == h[B[i] - 1]:
        p[A[i]] = False
        p[B[i]] = False
    
ans = [i for i in range(n + 1) if p[i]]

print(len(ans))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
h = list(map(int, input().split()))
p = [False] + [True]*n
A = []
B = []
for i in range(m):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)

for i in range(m):
    if h[A[i] - 1] > h[B[i] - 1]:
        p[B[i]] = False
    if h[A[i] - 1] < h[B[i] - 1]:
        p[A[i]] = False
    if h[A[i] - 1] == h[B[i] - 1]:
        p[A[i]] = False
        p[B[i]] = False
    print(p)
ans = [i for i in range(n + 1) if p[i]]

print(len(ans))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
h = list(map(int, input().split()))
p = [False] + [True]*n
A = []
B = []
for i in range(m):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)

for i in range(m):
    if h[A[i] - 1] > h[B[i] - 1]:
        p[B[i]] = False
    elif h[A[i] - 1] < h[B[i] - 1]:
        p[A[i]] = False
    else:
        p[A[i]] = False
        p[B[i]] = False
    print(p)
ans = [i for i in range(n + 1) if p[i]]

print(len(ans))