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

Fixed submission:
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
memo_yoko = []
memo_tate = []
for i in range(h):
    if "#" in a[i]:
        memo_yoko.append(i)

for j in range(w):
    if any(a[i][j] == "#" for i in range(h)):
        memo_tate.append(j)
#print(memo_yoko)
#rint(memo_tate)
for i in memo_yoko:
    for j in memo_tate:
        print(a[i][j], end="")
    print()

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
memo_yoko = [False]*w
memo_tate = [False]*h
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            memo_yoko[i] = True
            memo_tate[j] = True

for i in range(h):
    if memo_yoko[i]:
        for j in range(w):
            if memo_tate[j]:
                print(a[i][j], end="")
        print()

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
a = [input() for _ in range(h)]
memo_yoko = [False]*w
memo_tate = [False]*h
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            memo_yoko[i] = True
            memo_tate[j] = True
for i in range(h):
    if memo_yoko[i]:
        for j in range(w):
            if memo_tate[j]:
                print(a[i][j], end="")
        print()

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
a = [input() for _ in range(h)]
memo_yoko = [False]*w
memo_tate = [False]*h
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            memo_yoko[i] = True
            memo_tate[j] = True
for i in range(h):
    if memo_yoko[i]:
        for j in range(w):
            if memo_tate[j]:
                print(a[i][j], end="")
        print()
Problem p03281 (python)

Fixed submission:
n = int(input())
count = 0
ans = 0
for i in range(1, n+1):
    if i % 2 == 1:
        count = 0
        for j in range(1, i+1):
            if i % j == 0:
                count += 1
        if count == 8:
            ans += 1
        else:
            continue
    else:
        continue
print(ans)

Buggy submission (verdict: Runtime Error):
for i in range(1, n+1):
    if i % 2 == 1:
        count = 0
        for j in range(1, i+1):
            if i % j == 0:
                count += 1
            else:
                continue
        if count == 8:
            ans += 1
print(ans)
Problem p03353 (python)

Fixed submission:

s = input()
n = len(s)
k = int(input())
substr = []
for j in range(k):
    for i in range(n-j):
        sub = s[i:i+j+1]
        if sub not in substr:
            substr.append(sub)
substr.sort()
print(substr[k-1])

Buggy submission (verdict: Runtime Error):
s = input()
n = len(s)
k = int(input())
substr = []
for j in range(1, k+1):
    for i in range(n-j):
        sub = s[i:i+j]
        if sub not in substr:
            substr.append(sub)
substr.sort()
print(substr[k-1])
Problem p03557 (python)

Fixed submission:
from bisect import bisect_left, bisect_right
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
ans = 0

for j in b:
    i = bisect_left(a, j)
    k = bisect_right(c, j)
    ans += i*(n-k)
    #print(j, a, i)
    #print(j, c, k)
print(ans)

Buggy submission (verdict: Runtime Error):
from bisect import bisect_left, bisect_right
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
ans = 0
for i in a:
    j_idx = bisect_left(b, i)
    if j_idx == n:
        continue
    for j in b[j_idx:]:
        if i == j:
            continue
        k_idx = bisect_left(c, j)
        if j == c[k_idx]:
            k_idx += 1
        if k_idx == n:
            continue
        ans += (n-k_idx)
print(ans)
Problem p03633 (python)

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


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

n = int(input())
t1 = int(input())
ans = t1
for _ in range(n-1):
    t2 = int(input())
    ans = lcm(ans, t2)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
t1 = int(input())
for _ in range(n-1):
    t2 = int(input())
    ans = t1*t2 // math.gcd(t1, t2)
    t1 = ans
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
t1 = int(input())
for _ in range(n-1):
    t2 = int(input())
    ans = t1*t2 // math.gcd(t1, t2)
    t1 = ans
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
t1 = int(input())
for _ in range(n-1):
    t2 = int(input())
    ans = t1*t2 // math.gcd(t1, t2)
print(ans)
Problem p04030 (python)

Fixed submission:
s = input()
ans = []
dp = [""]*(len(s))
if s[0] != "B":
    dp[0] = s[0]
else:
    dp[0] = ""

for i in range(len(s)-1):
    if s[i+1] != "B":
        dp[i+1] = dp[i] + s[i+1]
    else:
        dp[i+1] = dp[i][:len(dp[i])-1]
print(dp[len(s)-1])

Buggy submission (verdict: Runtime Error):
s = input()
ans = []
dp = [""]*(len(s))
if s[0] != "B":
    dp[0] = s[0]
else:
    dp[0] = [""]

for i in range(len(s)-1):
    if s[i+1] != "B":
        dp[i+1] = dp[i] + s[i+1]
    else:
        dp[i+1] = dp[i][:len(dp[i])-1]
print(dp[len(s)-1])

Buggy submission (verdict: Runtime Error):
s = input()
ans = []
dp = [""]*(len(s))
if s[0] != "B":
    dp[0] = s[0]
else:
    dp[0] = [""]

#print(dp)
for i in range(len(s)-1):
    if s[i+1] != "B":
        dp[i+1] = dp[i] + s[i+1]
    else:
        dp[i+1] = dp[i][:len(dp[i])-1]
    #print(dp)
print(dp[len(s)-1])

Buggy submission (verdict: Runtime Error):
s = input()
ans = []
dp = [""]*(len(s))
if s[0] != "B":
    dp[0] = s[0]
else:
    dp[0] = [""]

#print(dp)
for i in range(len(s)-1):
    if s[i+1] != "B":
        dp[i+1] = dp[i] + s[i+1]
    else:
        dp[i+1] = dp[i][:len(dp[i])-1]
    #print(dp)
print(dp[len(s)-1])

Buggy submission (verdict: Runtime Error):
s = input()
ans = []
dp = [""]*(len(s))
if s[0] != "B":
    dp[0] = s[0]
else:
    dp[0] = [""]

#print(dp)
for i in range(len(s)-1):
    if s[i+1] != "B":
        dp[i+1] = dp[i] + s[i+1]
    else:
        dp[i+1] = dp[i][:-1]
    #print(dp)
print(dp[len(s)-1])

Buggy submission (verdict: Runtime Error):
s = input()
ans = []
dp = [""]*(len(s))
if s[0] != "B":
    dp[0] = s[0]
else:
    dp[0] = [""]

#print(dp)
for i in range(len(s)-1):
    if s[i+1] != "B":
        if dp[i] != "":
            dp[i+1] = dp[i] + s[i+1]
        else:
            dp[i+1] = s[i+1]
    else:
        if dp[i] != "":
            dp[i+1] = dp[i][:-1]
        else:
            dp[i+1] = ""
    #print(dp)
print(dp[len(s)-1])

Buggy submission (verdict: Runtime Error):
s = input()
ans = []
dp = [-1]*(len(s))
if s[0] != "B":
    dp[0] = s[0]
else:
    dp[0] = [-1]

#print(dp)
for i in range(len(s)-1):
    if s[i+1] != "B":
        if dp[i] != -1:
            dp[i+1] = dp[i] + s[i+1]
        else:
            dp[i+1] = s[i+1]
    else:
        if dp[i] != -1 and i-1 >= 0:
            dp[i+1] = dp[i-1]
        else:
            dp[i+1] = -1
print(dp[len(s)-1])
Problem p02536 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 9)

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rank = [0]*(n+1)

    def find(self, x):#親となる要素を探索
        if self.root[x] < 0:
            return x
        else:
            self.root[x] = self.find(self.root[x])#再帰
            return self.root[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return

        elif self.rank[x] > self.rank[y]:#深い木に連結
            self.root[x] += self.root[y]
            self.root[y] = x#yの親をxとする

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def issame(self, x, y):#x, yが同じ集合か判定
            return self.find(x) == self.find(y)


    def count(self, x):#要素の個数
        return (-1)*self.root[self.find(x)]

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

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

ans = set()

for i in range(n):
    ans.add(uf.find(i))

print(len(ans)-1)

Buggy submission (verdict: Runtime Error):
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
n, m = map(int, input().split())
uf = UnionFind(n)
 
for i in range(m):
    a, b = map(int, input().split())
    uf.union(a, b)
print(uf.group_count()-1)
Problem p02555 (python)

Fixed submission:
n=int(input())
mod=10**9+7
if n<3:
    print(0)


else:
    a=[0]*(n)
    a[0]=0
    a[1]=0
    a[2]=1
    for i in range(3,n):
        a[i]=(a[i-3]+a[i-1])%mod
    print(a[n-1])

Buggy submission (verdict: Runtime Error):
n=int(input())
mod=10**9+7
a=[0]*(n)
a[0]=0
a[1]=0
a[2]=1
if n<3:
    print(0)
else:
    for i in range(3,n):
        a[i]=(a[i-3]+a[i-1])%mod
    print(a[n-1])

Buggy submission (verdict: Runtime Error):
n=int(input())
mod=10**9+7
a=[0]*(n)
a[0]=0
a[1]=0
a[2]=1
if n<3:
    print(0)
else:
    for i in range(3,n):
        a[i]=(a[i-3]+a[i-1])%mod
print(a[n-1])
Problem p02660 (python)

Fixed submission:
import math
n=int(input())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

f=factorization(n) 
l=len(f)
x=0
for i in range(l):
    x+=int((-1+math.sqrt(1+8*f[i][1]))//2)
if n==1:
    x=0
print(x)

Buggy submission (verdict: Runtime Error):
import collections
import math
def wa(n):
    m=int (math.sqrt(2*n))
   
    if m*(m+1)>2*n:
        return m-1
    else:
        return m
def prime_factorize(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
N = int(input().strip())
n=prime_factorize(N)
l=len(n)
c = collections.Counter(n)
m=n[l-1]
x=0
for i in range (m+1):
    x+=int(wa(c[i]))
    

print(x)

Buggy submission (verdict: Runtime Error):
import collections
import math
def wa(n):
    m=int (math.sqrt(2*n))
   
    if m*(m+1)>2*n:
        return m-1
    else:
        return m
def prime_factorize(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
N = int(input().strip())
n=prime_factorize(N)
l=len(n)
c = collections.Counter(n)
m=n[l-1]
x=0
for i in range (m+1):
    x+=int(wa(c[i]))
    

print(x)
Problem p03760 (python)

Fixed submission:
s= input().strip()
t= input().strip()

ls=len(s)
lt=len(t)
v=''
for i in range(lt):
    v+=s[i]+t[i]
if lt!=ls:
    v+=s[-1]
print(v)

Buggy submission (verdict: Runtime Error):
s= input().strip()
t= input().strip()

ls=len(s)
lt=len(t)
v=''
for i in range(ls):
    v+=s[i]+t[i]
if lt!=ls:
    v+=t[-1]
print(v)
Problem p04033 (python)

Fixed submission:
a,b= list(map(int, input().strip().split()))
if a>0:
    print("Positive")
elif b<0:
    if (b-a)%2==0:
        print("Negative")
    else:
        print("Positive")
else:
    print("Zero")

Buggy submission (verdict: Runtime Error):
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M = map(int, readline().split())
m = map(int, read().split())

count = [1] * (N+1)
red = [0] * (N+1)
red[1] = True
for x, y in zip(m, m):
    count[x] -= 1
    count[y] += 1
    if red[x]:
        red[y] = 1
    if not count[x]:
        red[x] = 0

print(sum(red))
Problem p02555 (python)

Fixed submission:
s=int(input())
ans=0
mod=10**9+7
from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

for i in range(1,s//3+1):
    ans+=(combinations_count(s-3*i+i-1,s-3*i))%mod
print(ans%mod)

Buggy submission (verdict: Runtime Error):
s=int(input())
if s==1:
    print(0)
　　exit()
mod=10**9+7
dp=[0]*(s+1)
dp[1]=0
dp[2]=0

for i in range(3,s+1):
    for j in range(3,i+1):
        dp[i]+=(dp[i-j])%mod
    dp[i]+=1

print(dp[s]%mod)

Buggy submission (verdict: Runtime Error):
s=int(input())
mod=10**9+7
dp=[0]*(s+1)
dp[1]=0
dp[2]=0

for i in range(3,s+1):
    for j in range(3,i+1):
        dp[i]+=(dp[i-j])%mod
    dp[i]+=1

print(dp[s]%mod)
Problem p02573 (python)

Fixed submission:
from collections import deque
n,m=map(int,input().split())
nm=[[] for _ in range(n+1)]
for i in range(m):
    a,b=map(int,input().split())
    nm[a].append(b)
    nm[b].append(a)
for i in range(n):
    nm[i]=list(set(nm[i]))
visited=[0]*(n+1)
count=0
for i in range(n):
    if visited[i]==0:
        stack=deque()
        stack.append(i)
        visited[i]+=1
        temp=1
        while stack:
            x=stack.pop()
            
            for j in nm[x]:
                if visited[j]==0:
                    visited[j]+=1
                    stack.append(j)
                    temp+=1
        count=max(temp,count)
print(count)

Buggy submission (verdict: Runtime Error):
for i in range(n):
    nm[i]=list(set(nm[i]))
visited=[0]*(n+1)
count=0
for i in range(n):
    if visited[i]==0:
        stack=[]
        stack.append(i)
        visited[i]+=1
        temp=1
        while stack:
            x=stack.pop()
            
            for j in nm[x]:
                if visited[j]==0:
                    visited[j]+=1
                    stack.append(j)
                    temp+=1
        count=max(temp,count)
print(count)
Problem p02681 (python)

Fixed submission:
s=input()
t=input()
if t[:-1]==s:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a,b,c,k=map(int,input().split())
if a>=k:
  print(a)
else:
  s=k-a
  if a+b>=s:
    print(a)
  else:
    c=k-a-b
    print(a-c)

Buggy submission (verdict: Runtime Error):
a=int(input())
b,c = map(int,input.split())
s=input()
print({} {}.format(a+b+c,s))

Buggy submission (verdict: Runtime Error):
a=int(input())
b,c = map(str,input().split())
s=input()
print({} {}.format(a+b+c,s))

Buggy submission (verdict: Runtime Error):
a=str(S)
b=str(T)
del b[-1:]
if a=b:
  print"yes"
else:
  print"No"
Problem p02882 (python)

Fixed submission:
import math
from fractions import Fraction
a,b,x=map(int,input().split())
if b*(a**2)<=x*2:
    print(math.degrees(math.atan(Fraction(2*(a*a*b-x),a**3))))
else:
    print(math.degrees(math.atan(Fraction(a*b*b,2*x))))

Buggy submission (verdict: Runtime Error):
import math
from fractions import Fraction
a,b,x=map(int,input().split())
if b*(a**2)<=x*2:
    print(90-math.degrees(math.atan(Fraction(a**3,2*(a*a*b-x)))))
else:
    print(math.degrees(math.atan(Fraction(a*b*b,2*x))))
Problem p02900 (python)

Fixed submission:
import math
n,m=map(int,input().split())
gcd=math.gcd(m,n)
i=1
ans=[]
max=int(math.sqrt(gcd))
for i in range(2,max+2):
    while gcd%i==0:
        ans.append(i)
        gcd//=i
if gcd>1:
  ans.append(n)

print(len(set(ans))+1)

Buggy submission (verdict: Runtime Error):
from math import gcd
n,m=map(int,input().split())
gcd=gcd(m,n)
memory=[0]*(gcd)
count=0
for i in range(2,gcd+1):
    if memory[i-1]==0 and gcd%i==0:
        count+=1
        k=1
        while True:
            memory[k*(i)-1]+=1
            k+=1
            if k*i-1>gcd-1:
                break
print(count+1)
Problem p02917 (python)

Fixed submission:
n=int(input())
b=list(map(int,input().split()))
a=[b[0],b[n-2]]
for i in range(n-2):
  a.append(min(b[i],b[i+1]))
print(sum(a))

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

Fixed submission:
n=int(input())
stairlist=list(map(int,input().split()))
stairlist.reverse()
for i in range(n-1):
  if stairlist[i+1]-stairlist[i]==1:
    stairlist[i+1]=stairlist[i+1]-1
  elif stairlist[i+1]-stairlist[i]>1:
    print("No")
    break
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
n=int(input())
stairlist=list(map(int,input().split()))
stairlist.reverse()
for i in range(n):
  if stairlist[i+1]-stairlist[i]==1:
    stairlist[i+1]=stairlist[i+1]-1
  elif stairlist[i+1]-stairlist[i]>1:
    print("No")
    break
else:
  print("Yes")
Problem p03061 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
from collections import deque
from math import gcd
a_left=deque()

a_left.append(a[0])


a_right=deque()

a_right.append(a[-1])

for i in range(n-1):
    a_left.append(gcd(a_left[-1],a[i+1]))
    a_right.appendleft(gcd(a_right[0],a[n-i-2]))


a_right=list(a_right)
a_left=list(a_left)

count=max(a_left[-2],a_right[1])

for j in range(n-2):
    count=max(gcd(a_left[j],a_right[j+2]),count)
print(count)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
from collections import deque
from math import gcd
a_left=deque()

a_left.append(a[0])


a_right=deque()

a_right.append(a[-1])

for i in range(n-1):
    a_left.append(gcd(a_left[-1],a[i+1]))
    a_right.appendleft(gcd(a_right[0],a[n-i-2]))


a_right=list(a_right)
a_left=list(a_left)

count=max(a_left[-2],a_right[2])

for j in range(n-2):
    count=max(gcd(a_left[j],a_right[j+2]),count)
print(count)
Problem p03282 (python)

Fixed submission:
s=list(map(int,tuple(input())))
k=int(input())
i=0
if 1 in s:
  for i in range(len(s)):
    if s[i]!=1:
      break
  if i>=k:
      print(1)
  else:
      print(s[i])
else:
  print(s[0])

Buggy submission (verdict: Runtime Error):
s=list(map(int,tuple(input())))
k=int(input())
i=0
if 1 in s:
  i=s.index()
  if i+1>=k:
      print(1)
  else:
      print(s[i+1])
else:
  print(s[0])
Problem p02692 (python)

Fixed submission:
# -*- coding: utf-8 -*-

N,A,B,C=input().split()
D=dict()
D["A"]=int(A)
D["B"]=int(B)
D["C"]=int(C)

S=[]
for i in range(int(N)):
    S.append(input())

ans="Yes"
F=[]
for i,s in enumerate(S):
    if D[s[0]]==0 and D[s[1]]==0:
        ans="No"
        break
    if D[s[0]]==1 and D[s[1]]==1:
        if D["A"]+D["B"]+D["C"]==2:
            if i!=int(N)-1:
                if S[i+1] != s:
                    s0=S[i+1][0]
                    s1=S[i+1][1]
                    if s[0]==s0 or s[0]==s1:
                        F.append(s[0])
                    if s[1]==s0 or s[1]==s1:
                        F.append(s[1])
    if len(F)!=i+1:
        if D[s[0]]<D[s[1]]:
            F.append(s[0])
        if D[s[0]]>D[s[1]]:
            F.append(s[1])
        if D[s[0]]==D[s[1]]:
            F.append(s[0])

    D[F[-1]]+=1
    if s[0]==F[-1]: D[s[1]]-=1
    if s[1]==F[-1]: D[s[0]]-=1
    #print(D)
    #print(F)

print(ans)
if ans=="Yes":
    for f in F:
        print(f)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

N,A,B,C=input().split()
D=dict()
D["A"]=int(A)
D["B"]=int(B)
D["C"]=int(C)

S=[]
for i in range(int(N)):
    S.append(input())

ans="Yes"
F=[]
for i,s in enumerate(S):
    if D[s[0]]==0 and D[s[1]]==0:
        ans="No"
        break
    if D[s[0]]==0 and D[s[1]]==1:
        F.append(s[0])
    if D[s[0]]==1 and D[s[1]]==0:
        F.append(s[1])
    if D[s[0]]==1 and D[s[1]]==1:
        if D["A"]+D["B"]+D["C"]==2:
            if i!=int(N)-1:
                s0=S[i+1][0]
                s1=S[i+1][1]
                if s[0]==s0 or s[0]==s1:
                    F.append(s[0])
                if s[1]==s0 or s[1]==s1:
                    F.append(s[1])
    if len(F)!=i+1:
        if D[s[0]]<D[s[1]]:
            F.append(s[0])
        if D[s[0]]>D[s[1]]:
            F.append(s[1])
        if D[s[0]]==D[s[1]]:
            F.append(s[0])

    D[F[-1]]+=1
    if s[0]==F[-1]: D[s[1]]+=1
    if s[1]==F[-1]: D[s[0]]+=1
    print(D)
    print(F)

print(ans)
if ans=="Yes":
    for f in F:
        print(f)
Problem p03161 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 21 16:49:00 2020

@author: matsui
"""



N,K=map(int,input().split())
h=[int(num) for num in input().split()]

dp=[0]*N
dp[1]=abs(h[0]-h[1])
   
def cost(h,N,K,dp):
    for i in range(2,N):
        dp[i]=min([abs(h[i]-h[j])+dp[j] for j in range(max(0, i-K), i)])
    return dp[-1]
    
print(cost(h,N,K,dp))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 21 16:49:00 2020

@author: matsui
"""

   
def cost(h,N,K):
    dp=[0]*N
    for i in range(1,N):
        tmp=[]
        for j in range(i-1,max(0,i-K)):
            tmp.append(abs(h[i]-h[j])+dp[j])
        dp[i]=min(tmp)
    return dp[-1]

N,K=map(int,input().split())
h=[int(num) for num in input().split()]

print(cost(h,N,K))
Problem p03164 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 21 18:19:39 2020

@author: matsui
"""


N,W=map(int,input().split())
vi,wi=[],[]
for i in range(N):
    w,v=map(int,input().split())
    wi.append(w)
    vi.append(v)
    

#L = sorted([list(map(int,input().split())) for i in range(N)])

M=int(sum(vi))
dp=[W+1]*(M+1)
dp[0]=0
   
#L = sorted([list(map(int,input().split())) for i in range(N)])
s=0

for w, v in zip(wi,vi):
    s+=v
    for j in range(min(s,M),v-1,-1):
        if dp[j] > dp[j-v]+w: dp[j]=dp[j-v]+w
    #print(dp)

m=0
for i in range(M+1):
    if dp[i]<=W:
        m=i
print(m)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 21 18:19:39 2020

@author: matsui
"""


N,W=map(int,input().split())
dp=[0]*(W+1)
L = sorted([list(map(int,input().split())) for i in range(N)])
s=0

for w, v in L:
    s+=w
    for j in range(min(W,s),w-1,-1):
        if dp[j-w]+v > dp[j]: dp[j]=dp[j-w]+v
    
print(max(dp))
Problem p02600 (python)

Fixed submission:
n = int(input())

if n < 600:
    print(8)
elif n < 800:
    print(7)
elif n < 1000:
    print(6)
elif n < 1200:
    print(5)
elif n < 1400:
    print(4)
elif n < 1600:
    print(3)
elif n < 1800:
    print(2)
elif n < 2000:
    print(1)

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

rate = 600
rank = 8

while true:
    if n < rate:
        print(rank)
        break
    rate += 200
    rank -= 1
Problem p02765 (python)

Fixed submission:
n = list(map(int, input().split()))
 
if n[0] > 10:
  print(n[1])
else:
  print(n[1] + 100*(10-n[0]))

Buggy submission (verdict: Runtime Error):
n = list(map(int, input().split()))
 
if n[0] > 10:
  print(l[1])
else:
  print(n[1] + 100*(10-n[0]))

Buggy submission (verdict: Runtime Error):
l = list(map(int, input().split()))
 
if l[0] > 10:
  print(l[1])
else:
  print(100*(10-l[])))