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

Fixed submission:
n,ma,mb=map(int,input().split())
A=[]
for i in range(n):
  a,b,c=map(int,input().split())
  A.append([a,b,c])
DP=[[[float("inf")]*(10*n+1) for _ in range(10*n+1)] for _ in range(n+1)]
DP[0][0][0]=0
for i in range(n):
  a,b,c=A[i][0],A[i][1],A[i][2]
  for j in range(10*(i+1)+1):
    for k in range(10*(i+1)+1):
      if j>=a and k>=b:
        DP[i+1][j][k]=min(DP[i][j-a][k-b]+c,DP[i][j][k])
      else:
        DP[i+1][j][k]=DP[i][j][k]
ans=float("inf")
for i in range(10*n+1):
  for j in range(10*n+1):
    if i*mb==j*ma and i*j!=0:
      ans=min(ans,DP[n][i][j])
print(ans if ans!=float("inf") else -1)

Buggy submission (verdict: Runtime Error):
n,ma,mb=map(int,input().split())
inf=10**4
A=[]
append=A.append
for i in range(n):
  a,b,c=map(int,input().split())
  append([a,b,c])
DP=[[[inf]*(10*n+1) for _ in range(10*n+1)] for _ in range(n+1)]
DP[0][0][0]=0
for i in range(n):
  a,b,c=A[i][0],A[i][1],A[i][2]
  for j in range(10*(i+1)+1):
    for k in range(10*(i+1)+1):
      if j>=a and k>=b:
        DP[i+1][j][k]=min(DP[i][j-a][k-b]+c,DP[i][j][k])
      else:
        DP[i+1][j][k]=DP[i][j][k]
ans=inf
for i in range(1,10*n+1):
  if i*mb%ma==0:
    j=i*mb//ma
    ans=min(ans,DP[n][i][j])
print(ans if ans!=inf else -1)
Problem p03834 (python)

Fixed submission:
a,b,c=input().split(",")
print(a,b,c)

Buggy submission (verdict: Runtime Error):
a,b,c=input()split(",")
print(a,b,c)
Problem p02693 (python)

Fixed submission:
k=int(input())
a,b=map(int,input().split())
flag=False
for i in range(a,b+1):
    if i%k==0:
        flag=True
        break
if flag:
    print("OK")
else:
    print("NG")

Buggy submission (verdict: Runtime Error):
k=int(input())
a,b=map(int,input().split())
flag=False
for i in range(a,b+1):
    if i%k==0:
        flag=true
        break
if flag:
    print("OK")
else:
    print("NG")
Problem p02754 (python)

Fixed submission:
n,a,b=map(int, input().split())
count=n//(a+b)*a
n=n%(a+b)
count+=min(n,a)
print(count)

Buggy submission (verdict: Runtime Error):
n,a,b=map(int, input().split())
count=n//a+b*a
n=n%(a+b)
count+=min(n,a)
print(count)
Problem p02762 (python)

Fixed submission:
import queue

N,M,K=map(int,input().split())
friend=[[] for i in range(N)]
block=[[] for i in range(N)]
color=[-1]*N
c=0
for i in range(M):
    a,b=map(int,input().split())
    friend[a-1].append(b-1)
    friend[b-1].append(a-1)
for i in range(K):
    a,b=map(int,input().split())
    block[a-1].append(b-1)
    block[b-1].append(a-1)

q=queue.Queue()
count=[0]*N

for i in range(N):
    if color[i]==-1:
        q.put(i)
        color[i]=c
        count[c]+=1
        while not q.empty():
            s=q.get()
            for t in friend[s]:
                if color[t]==-1:
                    color[t]=c
                    count[c]+=1
                    q.put(t)
        c+=1

for i in range(N):
    block_in_color=0
    for t in block[i]:
        if color[i]==color[t]:
            block_in_color+=1
    print(count[color[i]]-len(friend[i])-block_in_color-1)

Buggy submission (verdict: Runtime Error):
import queue
 
N,M,K=map(int,input().split())
friend=[[] for i in range(N)]
block=[[] for i in range(N)]
color=[-1]*N
c=0
for i in range(M):
    a,b=map(int,input().split())
    friend[a-1].append(b-1)
    friend[b-1].append(a-1)
for i in range(K):
    c,d=map(int,input().split())
    block[c-1].append(d-1)
    block[d-1].append(c-1)
 
q=queue.Queue()
count=[0]*N
 
for i in range(N):
    if color[i]==-1:
        q.put(i)
        color[i]=c
        count[c]+=1
        while not q.empty():
            s=q.get()
            for t in friend[s]:
                if color[t]==-1:
                    color[t]=c
                    count[c]+=1
                    q.put(t)
        c+=1
 
for i in range(N):
    block_in_color=0
    for t in block[i]:
        if color[i]==color[t]:
            block_in_color+=1
    print(count[color[i]]-len(friend[i])-block_in_color-1)
Problem p02759 (python)

Fixed submission:
n = int(input())
print((n+1)//2)

Buggy submission (verdict: Runtime Error):
n = input()
print((n+1)//2)
Problem p02659 (python)

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

ans = (a*b)//100

print(ans)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = float(input)
b_int = int(b*100)

ans = a*b_int//100
print(ans
Problem p02753 (python)

Fixed submission:
s = input()
if s == 'AAA' or s =='BBB':
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
s = input()
if s = 'AAA' or s =='BBB':
    print('No')
else:
    print('Yes')
Problem p02819 (python)

Fixed submission:
import math

x = int(input())

if x == 2:
    print(2)
    exit()

elif x%2 == 0:
    ans = x+1

else:
    ans = x

#2以外の素数は奇数であることに注意

while True:
    for i in range(3, int(math.sqrt(ans))+1, 2):
        if ans%i == 0:
            ans += 2
            break
    else:
        print(ans)
        exit()

Buggy submission (verdict: Runtime Error):
import math

x = int(input())

if x == 2:
    print(3)
elif x%2 == 0:
    ans = x+1
else:
    ans = x

#2以外の素数は奇数であることに注意

while True:
    for i in range(3, int(math.sqrt(ans))+1, 2):
        if ans%i == 0:
            ans += 2
            break
    else:
        print(ans)
        exit()
Problem p02735 (python)

Fixed submission:
H, W = map(int,input().split())
board = []
for h in range(H):
    board.append(input())

dp=[[1000 for i in range(W+1)] for j in range(H+1)]
dp[0][1] = 0
dp[1][0] = 0

for h in range(H):
    for w in range(W):
        dp[h+1][w+1] = min(
            dp[h][w+1] + (board[h][w]=='#' and (h==0 or board[h-1][w]=='.')),
            dp[h+1][w] + (board[h][w]=='#' and (w==0 or board[h][w-1]=='.'))
        )

print (dp[-1][-1])

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

dp = [[1000 for _ in range(W+1)] for _ in range(H+1)]
dp[0][1] = 0
dp[1][0] = 0

for y in range(W):
    for x in range(H):
        dp[y+1][x+1] = min(
            dp[y][x+1] + (s[y][x] == '#' and (y == 0 or s[y-1][x] == '.')),
            dp[y+1][x] + (s[y][x] == '#' and (x == 0 or s[y][x-1] == '.'))
        )

print(dp[-1][-1])

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

dp = [1000 for _ in range(W+1) for _ in range(H+1)]
dp[0][1] = 0
dp[1][0] = 0

for y in range(W):
    for x in range(H):
        dp[y+1][x+1] = min(
            dp[y][x+1] + (s[y][x] == '#' and (y == 0 or s[y-1][x] == '.')),
            dp[y+1][x] + (s[y][x] == '#' and (x == 0 or s[y][x-1] == '.'))
        )

print(dp[-1][-1])

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

dp = [[float("inf")] * (W+1) for _ in range(H+1)]
dp[0][1] = 0
dp[1][0] = 0

for y in range(W):
    for x in range(H):
        dp[y+1][x+1] = min(
            dp[y][x+1] + (s[y][x] == '#' and (y == 0 or s[y-1][x] == '.')),
            dp[y+1][x] + (s[y][x] == '#' and (x == 0 or s[y][x-1] == '.'))
        )

print(dp[-1][-1])
Problem p02779 (python)

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

    is_break = False
    seen = set()
    for a in A:
        if a not in seen:
            seen.add(a)
        else:
            is_break = True
            break
    
    if is_break:
        print("NO")
    else:
        print("YES")


if __name__ == '__main__':
    main()

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

    is_break = False
    seen = []
    for a in A:
        if a not in seen:
            seen.append(a)
        else:
            is_break = True
            break:
    
    if is_break:
        print("NO")
    else:
        print("YES")


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

Fixed submission:
from collections import deque

h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]

d = [[-1] * w for _ in range(h)]
que = deque()
for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            que.append((j, i))
            d[i][j] = 0

dxdy = [(1, 0), (-1, 0), (0, 1), (0, -1)]

ans = 0
while que:
    x, y = que.popleft()
    for dx, dy in dxdy:
        nx = x + dx
        ny = y + dy
        if 0 <= nx < w and 0 <= ny < h and d[ny][nx] == -1:
            que.append((nx, ny))
            d[ny][nx] = d[y][x] + 1
            ans = max(ans, d[ny][nx])

print(ans)

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

h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]

d = [[-1] * w for _ in range(h)]
que = deque()
for i in range(h):
    for j in range(w):
        if a[i][j] == '#':
            que.append((j, i))
            d[i][j] = 0

dxdy = [(1, 0), (-1, 0), (0, 1), (0, -1)]

ans = 0
while que:
    x, y = que.popleft()
    for dx, dy in dxdy:
        nx = x + dx
        ny = y + dy
        if 0 <= nx < w and 0 <= ny < h and s[ny][nx] == -1:
            que.append((nx, ny))
            s[ny][nx] = s[y][x] + 1
            ans = max(ans, s[ny][nx])

print(ans)
Problem p03346 (python)

Fixed submission:
n = int(input())
p = [int(input()) for _ in range(n)]

q = [0] * (n+1)
for i in range(n):
    q[p[i]] = q[p[i]-1] + 1

print(n - max(q))

Buggy submission (verdict: Runtime Error):
n = int(input())
p = [int(input()) for _ in range(n)]

q = [0] * (n+1)
for i in range(n):
    q[p[i]] = q[p[i]-1] + 1

print(q - max(q))
Problem p02785 (python)

Fixed submission:

n, k = list(map(int, input().split()))

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

h.sort(reverse=True)

print(sum(h[min(n,k):]))

Buggy submission (verdict: Runtime Error):
src/contest/abc/abc153/c.py
Problem p02793 (python)

Fixed submission:
from fractions import gcd

MOD = 1000000000 + 7

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

l = 1
ans = 0
for a in A:
    g = gcd(a, l)
    l = (l // g) * a
    ans = (ans * (a // g)) % MOD
    ans = (ans + (l // a)) % MOD
print(int(ans))

Buggy submission (verdict: Runtime Error):
from fractions import gcd

MOD = 1000000000 + 7

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

l = 1
ans = 0
for a in A:
    g = gcd(a, l)
    ans = (ans * (a // g)) % MOD
    l = l * a // g
    ans = (ans + (l / a) % MOD) % MOD
print(int(ans))

Buggy submission (verdict: Runtime Error):
from fractions import gcd

MOD = 1000000000 + 7

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

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

l = 1
ans = 0
for a in A:
    g = gcd(a, l)
    ans = ((ans * a) // g) % MOD
    l = lcm(l, a)
    ans = (ans + (l / a) % MOD) % MOD
print(int(ans))

Buggy submission (verdict: Runtime Error):
import math

MOD = 1000000000 + 7

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

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

l = 1
for i in A:
    l = lcm(l, i)

ans = 0
for i in A:
    ans += (l // i) % MOD
print(int(ans % MOD))
Problem p02622 (python)

Fixed submission:
S = input()
T = input()
W = 0
for i in range(len(S)):
    if S[i] != T[i]:
        W += 1
print(W)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
W = 0
for i in range(len(S)):
    if S[i] != T[i]:
        w += 1
print(W)
Problem p02723 (python)

Fixed submission:
s = input()

if s[2] == s[3] and s[4] == s[5]:
    print("Yes")
else:
    print("No")

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

if s[2] == a[3] and s[4] == s[5]:
    print("Yes")
else:
    print("No")
Problem p02759 (python)

Fixed submission:
m = int(input())

if m%2 != 0:
    print(m//2 + 1)
else:
    print(m//2)

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


if m%2 != 0
    print(m//2 + 1)
else:
    print(m//2)
Problem p03272 (python)

Fixed submission:

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

ans = l[0] - l[1] + 1
print(ans)

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

ans = a - b + 1
print(ans)
Problem p02873 (python)

Fixed submission:
s=input()
n=len(s)
lst=[]
cnt=1

if n==2:
  print(1)
  
for i in range(n-1):
  if s[i]==s[i+1]:
    cnt+=1
  else:
    lst.append(cnt)
    cnt-=(cnt-1)

if s[n-2]!=s[n-1]:
  lst.append(1)
else:
  lst.append(cnt)
    
totl=0
l=len(lst)
if s[0]=='<':
  for j in range(l):
    if j%2==0:
      totl+=(lst[j]*(lst[j]-1))//2
      totl+=max(lst[j],lst[min(j+1,l-1)])
    else:
      totl+=(lst[j]*(lst[j]-1))//2
  print(totl)
else:
  totl+=lst[0]
  for j in range(len(lst)):
    if j%2==1:
      totl+=(lst[j]*(lst[j]-1))//2
      totl+=max(lst[j],lst[min(j+1,l-1)])
    else:
      totl+=(lst[j]*(lst[j]-1))//2
  print(totl)

Buggy submission (verdict: Runtime Error):
s=input()
n=len(s)
lst=[]
cnt=1

if n==2:
  print(1)
  
for i in range(n-2):
  if s[i]==s[i+1]:
    cnt+=1
  else:
    lst.append(cnt)
    cnt-=(cnt-1)
    
totl=0
l=len(lst)
if s[0]=='<':
  for j in range(l):
    if j%2==0:
      totl+=(lst[j]*(lst[j]-1))//2
      totl+=max(lst[j],lst[min(j+1,l-1)])
    else:
      totl+=(lst[j]*(lst[j]-1))//2
  print(totl)
else:
  totl+=lst[0]
  for j in range(len(lst)):
    if j%2==1:
      totl+=(lst[j]*(lst[j]-1))//2
      totl+=max(lst[j],lst[min(j+1,l-1)])
    else:
      totl+=(lst[j]*(lst[j]-1))//2
  print(totl)

Buggy submission (verdict: Runtime Error):
s=input()
n=len(s)
lst=[]
cnt=1

if n==2:
  print(1)
  
for i in range(n-2):
  if s[i]=s[i+1]:
    cnt+=1
  else:
    lst.append(cnt)
    cnt-=(cnt-1)
totl=0
if s[0]=='<':
  for j in range(len(lst)):
    if j%2==0:
      totl+=(lst[j]*(lst[j]-1))//2
      totl+=max(lst[j],lst[min(j+1,len(lst)-1)])
    else:
      totl+=(lst[j]*(lst[j]-1))//2
  print(totl)
else:
  totl+=lst[0]
  for j in range(len(lst)):
    if j%2==1:
      totl+=(lst[j]*(lst[j]-1))//2
      totl+=max(lst[j],lst[min(j+1,len(lst)-1)])
    else:
      totl+=(lst[j]*(lst[j]-1))//2
  print(totl)

Buggy submission (verdict: Runtime Error):
s=input()
lst=[]
cnt=1
for i in range(n-2):
  if s[i]=s[i+1]:
    cnt+=1
  else:
    lst.append(cnt)
    cnt-=(cnt-1)
totl=0
if s[0]=='<':
  for j in range(len(lst)):
    if j%2==0:
      totl+=(lst[j]*(lst[j]-1))//2
      totl+=max(lst[j],lst[min(j+1,len(lst)-1)])
    else:
      totl+=(lst[j]*(lst[j]-1))//2
  print(totl)
else:
  totl+=lst[0]
  for j in range(len(lst)):
    if j%2==1:
      totl+=(lst[j]*(lst[j]-1))//2
      totl+=max(lst[j],lst[min(j+1,len(lst)-1)])
    else:
      totl+=(lst[j]*(lst[j]-1))//2
  print(totl)
Problem p02935 (python)

Fixed submission:
n=int(input())
v=list(map(int,input().split()))
v.sort()
cnt=(v[0]+v[1])/2
if n==2:
  print((v[0]+v[1])/2)
else:
  for i in range(2,n):
    cnt=(cnt+v[i])/2
  print(cnt)

Buggy submission (verdict: Runtime Error):
n=int(input())
v=list(map(int,input().split()))
V=v.sort()
cnt=(V[0]+V[1])/2
for i in range(2,n):
  cnt=(cnt+V[i])/2
print(cnt)
Problem p02959 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
cnt=0
for i in range(n):
  if b[i]-a[i]>0:
    cnt+=a[i]
    cnt+=min(b[i]-a[i],a[i+1])
    a[i+1]=max(a[i+1]-b[i]+a[i],0)
  else:
    cnt+=b[i]
print(cnt)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
totl=min(0,a[0]-b[0])
for i in range(n):
  totl+=min(0,a[i+1]-b[i]-b[i+1])
    
print(sum(b)+totl)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
if a[0]-b[0]<0:
  totl=a[0]-b[0]
else:
  totl=0
for i in range(n):
  if b[i]+b[i+1]>a[i+1]:
    totl+=a[i+1]-b[i]-b[i+1]
    
print(sum(b)+totl)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
if a[0]-b[0]<0:
  totl=a[0]-b[0]
for i in range(n):
  if b[i]+b[i+1]>a[i+1]:
    totl+=a[i+1]-b[i]-b[i+1]
    
print(sum(b)+totl)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
totl=0
for i in range(n):
  m=min(b[i],max(a[i],a[i+1]))
  totl+=m
  del a[a.index(m)]
print(totl)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=a.sort(reverse=True)
d=b.sort(reverse=True)
totl=0
for i in range(n):
  totl+=min(c[i],d[i])
print(totl)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a_=a.sort(reverse=True)
b_=b.sort(reverse=True)
totl=0
for i in range(n):
  totl+=min(a_[i],b_[i])
print(totl)
Problem p02989 (python)

Fixed submission:
n=int(input())
d=list(map(int,input().split()))
D=sorted(d)
num=D[n//2]-D[(n//2)-1]
print(num)

Buggy submission (verdict: Runtime Error):
n=int(input())
d=list(map(int,input().split()))
D=sorted(d)
num=D[n/2]-D[(n/2)-1]
print(num)

Buggy submission (verdict: Runtime Error):
n=int(input())
d=list(map(int,input().split()))
D=sorted(d)
num=D[(n/2)]-D[(n/2)-1]
print(num)

Buggy submission (verdict: Runtime Error):
n=int(input())
d=list(map(int,input().split()))
D=sorted(d)
print(D[(n/2)]-D[(n/2)-1])

Buggy submission (verdict: Runtime Error):
n=int(input())
d=list(map(int,input().split()))
D=sorted(d)
print(D[(n/2)+1]-D[(n/2)-1])

Buggy submission (verdict: Runtime Error):
n=int(input())
d=list(map(int,input().split()))
D=sorted(d)
print(D[(n//2)+1]-D[(n//2)-1])
Problem p03013 (python)

Fixed submission:
import sys
n,m=map(int,input().split())
a=[]
for i in range(m):
  a.append(int(input()))
a.sort()
for i in range(m-1):
  if a[i+1]-a[i]==1:
    print(0)
    sys.exit()
p=10**9+7  
dp=[0]*(n+1)
dp[0]=1
if 1 not in a:
  dp[1]=1
lst=set(list(range(1,n+1)))
A=set(a)
Lst=lst-A
Lst=list(Lst)
if 1 in Lst:
  Lst.remove(1)
for i in Lst:
  dp[i]=dp[i-1]+dp[i-2]
  if p<=dp[i]:
    dp[i]=dp[i]%p
print(dp[n]%p)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[]
for i in range(m):
  a.append(int(input()))
lst=[]
lst.append(a[0])
lst.append(0)
for j in range(m-1):
  lst.append(a[j+1]-a[j]-1)
  lst.append(0)
lst.append(n-a[m-1])
l=len(lst)
for k in range(l-1):
  if lst[k]==0 and lst[k+1]==0:
    print(0)
    break
  else:
    if lst[k]>1:
      lst[k]-=1
if lst[l-1]>1:
  lst[l-1]-=1
for p in range(l):
  if lst[p]==0:
    del lst[p]
totl=1
for q in range(len(lst)):
  totl*=lst[q]
  totl=totl%1000000007
print(totl)
Problem p03072 (python)

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
cnt=1
if n>=2:
  for i in range(1,n):
    if all(h[i]>=h[j] for j in range(i)):
      cnt+=1
  print(cnt)
else:
  print(1)

Buggy submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
cnt=1
if n==1:
  print(1)
else:
  for i in range(1,n):
  if all(h[i]>=h[j] for j in range(i-1)):
    cnt+=1
  print(cnt)
Problem p03077 (python)

Fixed submission:
n=int(input())
lst=[]
for i in range(5):
  lst.append(int(input()))
if n%min(lst)==0:
  print((n//min(lst))+4)
else:
  print((n//min(lst))+5)

Buggy submission (verdict: Runtime Error):
n=int(input())
lst=[]
for i in range(5):
  lst.append(int(input()))
if n%lst(min)==0:
  print(n//lst(min)+4)
else:
  print(n//lst(min)+5)
Problem p03127 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
def gcd(x,y):
  while x%y>0:
    x,y=y,x%y
  return y
a.sort(reverse=True)
ans=a[0]
for j in range(n-1):
  ans=gcd(ans,a[j+1])
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
a=list(map(int,input().split()))
gcd=float('inf')
for i in range(n-1):
  gcd=min(gcd,math.gcd(a[i],a[i+1]))
print(gcd)

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
a=list(map(int,input().split()))
print(math.gcd(a))
Problem p03137 (python)

Fixed submission:
import sys
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
dif=[]
if m<=n:
  print(0)
  sys.exit()
else:
  for i in range(m-1):
    dif.append(x[i+1]-x[i])
  dif.sort(reverse=True)
  ans=x[m-1]-x[0]
  for j in range(n-1):
    ans-=dif[j]
  print(ans)

Buggy submission (verdict: Runtime Error):
import sys
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
dif=[]
if m<=n:
  print(0)
  sys.exit()
else:
  for i in range(n-1):
    dif.append(x[i+1]-x[i]-1)
  dif.sort(reverse=True)
  ans=x[n-1]-x[0]+1
  for j in range(n):
    ans-=dif[j]
  print(ans-n+1)
Problem p03208 (python)

Fixed submission:
n,k=map(int,input().split())
h=[int(input()) for i in range(n)]
h.sort()
d=[0]*n
for j in range(n-1):
  d[j+1]=d[j]+h[j+1]-h[j]
m=float('inf')
for l in range(n-k+1):
  m=min(m,d[l+k-1]-d[l])
print(m)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=[int(input()) for i in range(n)]
h.sort()
d=[0]*(n-1)
for j in range(n-1):
  d[j+1]=d[j]+h[j+1]-h[j]
m=float('inf')
for l in range(1,n-k+1):
  m=min(m,d[l+k-1]-d[l])
print(m)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=[int(input()) for i in range(n)]
h.sort()
d=[0]*(n-1)
for j in range(n-1):
  d[j+1]=d[j]+h[j+1]-h[j]
m=1000000001
for l in range(1,n-k+1):
  m=min(m,d[l+k-1]-d[l])
print(m)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=[int(input()) for i in range(n)]
h.sort()
d=[0]*(n-1)
for j in range(n-1):
  d[j+1]=d[j]+h[j+1]-h[j]
m=1000000001
for l in range(n-k):
  m=min(m,d[l+k-1]-d[l])
print(m)
Problem p03252 (python)

Fixed submission:
import collections
s=input()
t=input()
cnt1=1
cnt2=1
lst1=[]
lst2=[]
for i in range(len(s)-1):
  if s[i]==s[i+1]:
    cnt1+=1
  else:
    lst1.append(cnt1)
for j in range(len(t)-1):
  if t[j]==t[j+1]:
    cnt2+=1
  else:
    lst2.append(cnt2)
S=collections.Counter(s)
T=collections.Counter(t)
S_=list(S.values())
T_=list(T.values())
S_.sort()
T_.sort()
if S_==T_ and lst1==lst2:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
import sys
s=input()
t=input()
def hanten(*S,c1,c2):
  for i range(len(S)):
    if S[i]==c1:
      S[i]=c2
    if S[i]==c2:
      S[i]=c1
for j,k in s:
  if hanten(s,j,k)==t:
    print('Yes')
    sys.exit()
print('No')
Problem p03329 (python)

Fixed submission:
n=int(input())
dp=[0]*100010

for i in range(1,100010):
  dp[i]=float('inf')
  
for i in range(1,100010):
  power6=1
  while power6<=i:
    dp[i]=min(dp[i-power6]+1,dp[i])
    power6*=6
  power9=1
  while power9<=i:
    dp[i]=min(dp[i-power9]+1,dp[i])
    power9*=9

print(dp[n])

Buggy submission (verdict: Runtime Error):
n=int(input())
S=6
N=9
lst=[]
cnt=0
for i in range(16667):
  S*=6
  N*=9
  lst.append(S)
  lst.append(N)
while n>5:
  for i in len(lst):
    if lst[i]>n:
      n-=lst[i-1]
      cnt+=1
      break
print(cnt+n)
Problem p02627 (python)

Fixed submission:
#! -*- coding: utf-8 -*-
a = input()
if a.isupper():
    print('A')
else:
    print('a')

Buggy submission (verdict: Runtime Error):
a = input()
if a.isupper():
  print('A')
 else:
  print('a')
Problem p02723 (python)

Fixed submission:
#! env/bin/local python3
# -*- coding: utf-8 -*-

s = input()
if s[2] == s[3] and s[4] == s[5]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
#! env/bin/local python3
# -*- coding: utf-8 -*-

s = input()
if s[2] == s[3] and s[4] == 2[6]:
    print('Yes')
else:
    print('No')
Problem p02759 (python)

Fixed submission:
#! env/bin/local python3
# -*- coding: utf-8 -*-

n = int(input())

print(n // 2 + n % 2)

Buggy submission (verdict: Runtime Error):
#! env/bin/local python3
# -*- coding: utf-8 -*-

import numpy as np

a_1 = list(map(int, input().split()))
a_2 = list(map(int, input().split()))
a_3 = list(map(int, input().split()))
_ = input()
pickup_number = []
while True:
    try:
        pickup_number.append(int(input()))
    except EOFError:
        break

a = np.array([a_1, a_2, a_3])

for pn in pickup_number:
    a[a == pn] = -1

flag = False
if np.sum(a, axis=0)[0] == -3 or np.sum(a, axis=1)[0] == -3:
    flag = True
if np.sum(a.diagonal()) == -3 or a[0][2] + a[1][1] + a[2][0] == -3:
    flag = True

print('Yes' if flag else 'No')