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

Fixed submission:
N = int(input())

alph = ['z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',\
     'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',\
         'x', 'y']

seq = []

while N > 0:
    s = N % 26
    N  = (N - 1) // 26
    seq.append(s)
L = len(seq)

name = ''

for i in range(L):
    name = alph[seq[i]] + name

print(name)

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

alph = ['z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',\
     'k', 'l', 'm', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',\
         'x', 'y']

seq = []

while N > 0:
    s = N % 26
    N //= 26
    seq.append(s)
L = len(seq)

name = ''

for i in range(L):
    name = alph[seq[i]] + name

print(name)
Problem p03033 (python)

Fixed submission:
import sys
input=sys.stdin.readline
from bisect import bisect_left
n,q=map(int,input().split())
stop=[]
for i in range(n):
	s,t,x=map(int,input().split())
	stop.append((s,t,x))
stop.sort(key=lambda x:x[2])
d=[int(input())for i in range(q)]
R=[-1]*q
ans=[-1]*q
for s,t,x in stop:
	#lからrにある区間のansをxに更新したい
	l=bisect_left(d,s-x)
	r=bisect_left(d,t-x)
	while l<r:
		if R[l]==-1:#最左がまだ確定していない場合
			ans[l]=x
			R[l]=r
			l+=1
		else:
			l=R[l]#確定しているところを飛ばす
for x in ans:
	print(x)

Buggy submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
from bisect import bisect_left
n,q=map(int,input().split())
stop=[]
for i in range(n):
	s,t,x=map(int,input().split())
	stop.append((s,t,x))
stop.sort(key=lambda x:x[2])
d=[int(input())for i in range(q)]

ans=[-1]*q
for s,t,x in stop:
	l=bisect_left(d,s-x)
	r=bisect_left(d,t-x)
    for i in range(l, r):
		if ans == -1:
			ans[i] = x
            
for x in ans:
	print(x)

Buggy submission (verdict: Runtime Error):
import bisect

INF = 10**9 + 1

N, Q = [int(x) for x in input().split()]

data = []
for i in range(N):
    S, T, X = [int(x) for x in input().split()]
    data.append([X, S, T])
data = sorted(data, reverse=True)

D = []
for i in range(Q):
    D.append(int(input()))

dist = [INF]*Q
for i in range(N):
    print(dist)
    [X, S, T] = data[i]
    l = bisect.bisect_left(D, S - X - 0.5)
    r = bisect.bisect_right(D, T - X - 0.5)
    dist = dist[:l] + [X]*(r - l) + dist[r:]

for i in range(Q):
    if dist[i] == INF:
        print(-1)
    else:
        print(dist[i])
Problem p03045 (python)

Fixed submission:
class UnionFind():
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n

    def root(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.par[x] = y
            else:
                self.par[y] = x
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1

    def samegrp(self, x, y):
        return self.root(x) == self.root(y)

n, m = [int(x) for x in input().split()]
A = UnionFind(n)
ans = n
for i in range(m):
    x, y, _ = [int(z) - 1 for z in input().split()]
    if not A.samegrp(x, y):
        ans -=1
    A.union(x, y)

print(ans)

Buggy submission (verdict: Runtime Error):
class UnionFind():
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n

    def root(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.par[x] = y
            else:
                self.par[y] = x
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1

    def samegrp(self, x, y):
        return self.root(x) == self.root(y)

from mymodules.somedatastrs import UnionFind

n, m = [int(x) for x in input().split()]
A = UnionFind(n)
ans = n
for i in range(m):
    x, y, _ = [int(z) - 1 for z in input().split()]
    if not A.samegrp(x, y):
        ans -=1
    A.union(x, y)

print(ans)
Problem p02550 (python)

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

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

a_list = [x]
a = x
i = 1
while (i<n and i < m+1):
    a = (a*a) % m
    a_list.append(a)
    i += 1
    
#print(i)
#print(a_list)
    
if i == n:
  ans = sum(a_list)
else:
    b = a_list.index(a)
    sum1 = sum(a_list[:b+1])
    sum2 = sum(a_list[b+1:i])
    blen = i-b-1
    repeat = (n-b-1) // blen
    amari = (n-b-1) % blen
    sum3 = 0
    if amari != 0:
    	sum3 = sum(a_list[b+1:b+amari+1])
    ans = sum1 + sum2*repeat + sum3
    #print(blen)
    #print(amari)
    #print(sum1, sum2, repeat, sum3)

print(ans)

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

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

a_list = [x]
a = x
i = 1
while (i<n and i < m):
    a = (a*a) % m
    a_list.append(a)
    i += 1
    
#print(i)
#print(a_list)
    
if i == n:
  ans = sum(a_list)
else:
    b = a_list.index(a)
    sum1 = sum(a_list[:b+1])
    sum2 = sum(a_list[b+1:i])
    blen = i-b-1
    repeat = (n-b-1) // blen
    amari = (n-b-1) % blen
    sum3 = 0
    if amari != 0:
    	sum3 = sum(a_list[b+1:b+amari+1])
    ans = sum1 + sum2*repeat + sum3
    #print(blen)
    #print(amari)
    #print(sum1, sum2, repeat, sum3)

print(ans)
Problem p02572 (python)

Fixed submission:
MOD = 1000000007
n = int(input())
nums = list(map(int, input().split()))
x = sum(nums)
y = sum([(nums[i]**2) for i in range(n)])
print(((x**2 - y)//2)% MOD)

Buggy submission (verdict: Runtime Error):
MOD = 1000000007
n = int(input())
nums = list(map(int, input().split()))
x = sum(sums)
y = sum([(x[i]**2) for i in range(n)])
print(((x**2 - y)//2)% MOD)
Problem p02595 (python)

Fixed submission:
N, D = map(int, input().split())
count = 0
for i in range(N):
  a, b = map(int, input().split())
  r = (a **2 + b ** 2) ** 0.5
  if r <= D:
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
n = map(int, input().split())
count = 0
for i in range(n[0]):
  a, b = map(int, input().split())
  r = (a **2 + b ** 2) ** 0.5
  if r <= n[1]:
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
n = map(int, input())
count = 0
for i in range(n[0]):
  a, b = map(int, input())
  r = (a **2 + b ** 2) ** 0.5
  if r <= n[1]:
    count += 1
print(count)
Problem p02623 (python)

Fixed submission:
from itertools import accumulate
from bisect import bisect_right

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

a = [0] + list(accumulate(A))
b = [0] + list(accumulate(B))

result = 0
for i in range(N + 1):
    if a[i] > K:
        break
    j = bisect_right(b, K - a[i])
    result = max(result, i + j - 1)
print(result)

Buggy submission (verdict: Runtime Error):
def main():
    N,M,K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    
    indb = M-1
    now = sum(B)
    count = M
    while now > K:
        now -= B[indb]
        count -= 1
        indb -= 1
    
    ans = count
    
    for a in A:
        count += 1
        now += a
        
        while now >K and indb >= 0:
            now -= B[indb]
            count -= 1
            indb -= 1
        
        if now <= K:
            if ans < count:
                ans = count
    print(ans)
    

if __name __ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
N,M,K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
c = 0
while K >=0:
    c +=1
    if not A:
        K -= B.pop(0)
    elif not B:
        K -= A.pop(0)
    elif A[0] >=B[0]:
        K -= B.pop(0)
    else:
        K -= A.pop(0)
if K == 0:
    print(c)
else:
    print(c-1)
Problem p02659 (python)

Fixed submission:
a, b = map(str, open(0).read().split())
print(int(a)*int(b[:-3]+b[-2:]) // 100)

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

print(int(A)*round(float(b)*100)//100)

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

print(int(int(A)*round(float(b)*100)//100))

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

print(int(A)*round(float(b)*100)//100)

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

print(int(A)*round(float(b)*100)//100)
Problem p02785 (python)

Fixed submission:
N,K = map(int, input().split())
H = list(map(int, input().split()))

if N < K:
    print(0)
else:
    H.sort()
    for i in range(1,K+1):
        H[-i] = 0
    print(sum(H))

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

H.sort()
for i in range(1,K+1):
    H[-i] = 0
print(sum(H))
Problem p02859 (python)

Fixed submission:
r = int(input())
print(r**2)

Buggy submission (verdict: Runtime Error):
r = input()
ans = int(r)**2
return ans

Buggy submission (verdict: Runtime Error):
ans = r**2
return int(ans)

Buggy submission (verdict: Runtime Error):
return int(r**2)

Buggy submission (verdict: Runtime Error):

return int(radius**2)
Problem p02881 (python)

Fixed submission:

N = int(input())
b = N**0.5//1.0
while True:
    if N%b != 0:
        b -= 1
    else:
        break
print(int(b+N/b-2))

Buggy submission (verdict: Runtime Error):

N = int(input())
b = n**0.5//1.0
while True:
    if N%b != 0:
        b -= 1
    else:
        break
print(int(b+N/b-2))
Problem p02954 (python)

Fixed submission:
LOG = 18

def main():
    S = input()
    N = len(S)
    to = []
    for _ in range(LOG):
        l = [0]*N
        to.append(l)
        
    for i in range(N):
        to[0][i] = i + 1 if S[i] == "R" else i -1
    
    for i in range(1, LOG):
        for j in range(N):
            to[i][j] = to[i-1][to[i-1][j]]
            
    ans = [0]*N
    for j in range(N):
        ans[to[LOG-1][j]] += 1
        
    print(*ans)
    return

main()

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

S = input()
s = len(S)
shift = 10**100
K = shift.bit_length()

ini_ad = np.array([1 if i == "R" else -1 for i in S])

def db(A:list, k:int):
    dv = np.array([[0]*s for _ in range(k+1)])
    dv[0] = A
    for kk in range(1,k+1):
        for n in range(s):
            dv[kk][n] = dv[kk-1][dv[kk-1][n]]
    return dv[k]

a = list(range(s))+ini_ad
for i in range(1,K):
    if (shift >> i)&1:
        a = db(a, i)
ans = [0]*s
for j in a:
    ans[j]+=1
print(*ans)

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

S = input()
s = len(S)
shift = 10**100
K = shift.bit_length()

ini_ad = np.array([1 if i == "R" else -1 for i in S])

def db(A:list, k:int):
    dv = np.array([[0]*s for _ in range(k+1)])
    dv[0] = A
    for kk in range(1,k+1):
        for n in range(s):
            dv[kk][n] = dv[kk-1][dv[kk-1][n]]
    return dv[k]

a = list(range(s))+ini_ad
for i in range(1,K):
    if (shift >> i)&1:
        a = db(ans, i)
ans = [0]*s
for j in a:
    ans[j]+=1
print(*ans)

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

S = input()
s = len(S)
shift = 10**100
K = shift.bit_length()

ini_ad = np.array([1 if i == "R" else -1 for i in S])

def db(A:list, k:int):
    dv = np.array([[0]*s for _ in range(k+1)])
    dv[0] = A
    for kk in range(1,k+1):
        for n in range(s):
            dv[kk][n] = dv[kk-1][dv[kk-1][n]]
    return dv[k]

ans = list(range(s))+ini_ad
for i in range(1,K):
    if (shift >> i)&1:
        ans = db(ans, i)

for j in range(s):
    print(np.count_nonzero(ans ==j))
Problem p03207 (python)

Fixed submission:
N = int(input())
p = [int(input()) for i in range(N)]
p.sort()
print(int(sum(p[:-1]) + p[-1]/2))

Buggy submission (verdict: Runtime Error):
import sys

s = sys.stdin.readline()
N = s[0]
p = sorted(s[1:])
print(p[:-1].sum() + p[-1]/2)

Buggy submission (verdict: Runtime Error):
N, *p = map(int, open(0).read().split())
p.sort()
print(p[:-1].sum() + p[-1]/2)
Problem p03286 (python)

Fixed submission:
n=int(input())
x = ""
while n!=0:
    x = str(n%2) + x
    n = -(n//2)
if x == "":
    print(0)
else:
    print(x)

Buggy submission (verdict: Runtime Error):
n=int(input())
x = ""
while n!=0:
    x = str(n%2) + x
    n = -(n//2)
if x = "":
    print(0)
else:
    print(x)
Problem p02577 (python)

Fixed submission:
n=input()
lst=list(n)
#print(lst)
s=0
for i in lst:
    s+=int(i)
if s%9==0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n=input()
#lst=list(n)
#print(lst)
s=0
for i in lst:
    s+=int(i)
if s%9==0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n=input()
#lst=list(n)
print(lst)
s=0
for i in lst:
    s+=int(i)
if s%9==0:
    print('Yes')
else:
    print('No')
Problem p02546 (python)

Fixed submission:
import random


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


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

s=input()
if s[len(s)-1]!='s':
    s+='s'
else:
    s+='es'
print(s)

Buggy submission (verdict: Runtime Error):
import random


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


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

s=input()
if s[len(s)-1]!='s':
    s+='s'
else:
    s+='es'
print(s)
import random


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


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

s=input()
if s[len(s)-1]!='s':
    s+='s'
else:
    s+='es'
print(s)
Problem p02594 (python)

Fixed submission:
import random


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


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


n = int(input())
#a = list(map(int, input().split()))
#= map(int, input().split())
if n>=30:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import random


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


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


for _ in range(int(input())):
    n = int(input())
    #a = list(map(int, input().split()))
    #= map(int, input().split())
    if n>=30:
        print('Yes')
    else:
        print('No')
Problem p03774 (python)

Fixed submission:
N,M = [int(c) for c in input().split()]
ab = [list(map(int,input().split())) for c in range(N)]
cd = [list(map(int,input().split())) for c in range(M)]
for i in range(N):
    mi = 2*10**9
    for j in range(M):
        tmp = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
        if mi > tmp:
            mi = tmp
            ans = j+1
    print(ans)

Buggy submission (verdict: Runtime Error):
N,M = [int(c) for c in input().split()]
ab = [list(map(int,input().split())) for c in range(N)]
cd = [list(map(int,input().split())) for c in range(M)]
for i in range(N):
    mi = 2*10**8+1
    for j in range(M):
        tmp = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
        if mi > tmp:
            mi = tmp
            ans = j+1
    print(ans)

Buggy submission (verdict: Runtime Error):
N,M = [int(c) for c in input().split()]
ab = [list(map(int,input().split())) for c in range(N)]
cd = [list(map(int,input().split())) for c in range(M)]
for i in range(N):
    mi = 2*10**8
    for j in range(M):
        tmp = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
        if mi > tmp:
            mi = tmp
            ans = j+1
    print(ans)
Problem p02578 (python)

Fixed submission:
# 自分の改造
n = int(input())
A = list(map(int, input().split()))
s = 0 
M = 0
for i in range(n-1):
    if A[i] <= A[(i+1)] and M <= A[(i+1)]:
        M = 0
        continue
    else:
        if M == 0:
            s += A[i] - A[(i+1)]
            M = A[(i+1)] + (A[i] - A[(i+1)])
        else:
            s += M - A[(i+1)]
print(s)

Buggy submission (verdict: Runtime Error):
# C
n = int(input())
A = list(map(int, input().split()))
b = sum(A)
for i in range(n-1):
    if A[i] <= A[(i+1)]:
        continue
    else:
        s = A[i] - A[(i+1)]
        s = s + A[(i+1)]
        A.pop(A[(i+1)])
        A.insert((i+1),s)

print(sum(A) - b)
Problem p02729 (python)

Fixed submission:
# ABC159
# A The Number of Even Pairs
import math
n, m = map(int, input().split())
if n < 2:
    x = 0
else:
    x = math.factorial(n) // (math.factorial(n-2) * math.factorial(2))

if m < 2:
    y = 0
else:
    y = math.factorial(m) // (math.factorial(m-2) * math.factorial(2))

print(x+y)

Buggy submission (verdict: Runtime Error):
# ABC159
# A The Number of Even Pairs
import math
n, m = map(int, input().split())
if n < 2:
    x = 0
else:
    x = math.factorial(n) // (math.factorial(n-2) * math.factorial(2))

if m < 0:
    y = 0
else:
    y = math.factorial(m) // (math.factorial(m-2) * math.factorial(2))

print(x+y)
Problem p02777 (python)

Fixed submission:
# ABC154
#A Remaining balls
s, t = map(str,input().split())
a, b = map(int, input().split())
u = input()
if s == u:
    a = a - 1
else:
    b = b -1
print(a, b)

Buggy submission (verdict: Runtime Error):

# ABC154
#A Remaining balls
s, t = map(input().split())
a, b = map(int, input().split())
u = input()
if s == u:
    a = a - 1
else:
    b = b -1
print(a, b)
Problem p02859 (python)

Fixed submission:
r = int(input())
x = r ** 2
print(x)

Buggy submission (verdict: Runtime Error):
r = int(input)
x = r ** 2
print(x)
Problem p02571 (python)

Fixed submission:
S = input()
T = input()
n = len(S)
m = len(T)
x = int(1e9)
for i in range(n-m+1):
  cnt = 0
  for j in range(m):
    cnt += (S[i+j] != T[j])
  x = min(x, cnt)
print(x)

Buggy submission (verdict: Runtime Error):
s=str(input())
t=str(input())
ans=0
f=[]
g=len(s)
h=len(t)
n=g-h
for i in range(n):
    for j in range(h):
        if s[i+j]!=t[j]:
            ans+=1
    f.append(ans)
    ans=0
    f.sort()
print(f[0])

Buggy submission (verdict: Runtime Error):
s=str(input())
t=str(input())
ans=0
f=[]
g=len(s)
h=len(t)
for i in range(g-h):
    for j in range(h):
        if s[i+j]!=t[j]:
            ans+=1
    f.append(ans)
    ans=0
    f.sort()
print(f[0])

Buggy submission (verdict: Runtime Error):
s=str(input())
t=str(input())
ans=0
f=[]
g=len(s)
h=len(t)
for i in range(g-h):
    for j in range(h):
        if s[i+j]!=t[j]:
            ans+=1
    f.append(ans)
    ans=0
f.sort()
print(int(f[0]))

Buggy submission (verdict: Runtime Error):
s=str(input())
t=str(input())
ans=0
f=[]
r=0
g=len(s)
h=len(t)
for i in range(g-h):
    for j in range(h):
        if s[i+j]!=t[j]:
            ans+=1
        else:
            r=+1
    f.append(ans)
    ans=0
f.sort()
print(f[0])

Buggy submission (verdict: Runtime Error):
s=str(input())
t=str(input())
ans=0
f=[]
g=len(s)
h=len(t)
for i in range(g-h):
    for j in range(h):
        if s[i+j]!=t[j]:
            ans+=1
    f.append(ans)
    ans=0
f.sort()
print(f[0])

Buggy submission (verdict: Runtime Error):
s=str(input())
t=str(input())
ans=0
f=[]
g=len(s)
h=len(t)
for i in range(g-h):
    for j in range(h):
        if s[i+j]!=t[j]:
            ans+=1
    f.append(ans)
    ans=0
f.sort()
print(f[0])
Problem p02572 (python)

Fixed submission:
N=int(input())
A=list(map(int, input().split()))
MOD = 10 ** 9 + 7

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

ans = 0
for i in range(N):
    ans += (A[i] * (cumsum[-1] - cumsum[i])) % MOD
    ans %= MOD

print(ans)

Buggy submission (verdict: Runtime Error):
n=input()
m=0
from itertools import combinations
b=combinations
a=b(map(int,input().split()),2)
for i,j in a:
    k=i*j
    m+=k
if m<=MOD:
    print(m)
else:
	MOD=10**9+7
    v=m%MOD
    print(v)
Problem p02847 (python)

Fixed submission:
s=input()
s=s.lower()
week=['sun','mon','tue','wed','thu','fri','sat']
ans=week.index(s)
print(7-int(ans))

Buggy submission (verdict: Runtime Error):
s=input()
s.upper()
week=['sun','mon','tue','wed','thu','fri','sat']
ans=week.index(s)
print(7-ans)
Problem p03041 (python)

Fixed submission:
n,k=map(int,input().split())
s=list(input())
s[k-1]=str.lower(s[k-1])
print(''.join(s))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=input()
w=s[k+1]
w=w.lower()
ans=s[:k+1]+w+s[n:]
print(ans)
Problem p02693 (python)

Fixed submission:
import numpy as np
import math
k=int(input())
a,b=map(int,input().split())

#print((a%k*b%k))

if((b//k-a//k)>=1 or (b%k*a%k)==0):
  print("OK")
else:
  print("NG")

Buggy submission (verdict: Runtime Error):
import numpy as np
import math
k=int(input())
a,b=map(int,input().split())

#print((a%k*b%k))

if((b//k-a//k)>=1 or (b%k*a%k)==0):
  print("OK")
else:
  print("NG")
Problem p02735 (python)

Fixed submission:
H,W=map(int,input().split())

a=[[0]*W for i in range(H)]
b=[[0]*W for i in range(H)]

#print(b)

for i in range(H):
	a[i]=list(input())
#print(a)
    
for j in range(1,W):
	b[0][j]=b[0][j-1]+int(not(a[0][j]==a[0][j-1]))

for i in range(1,H):
	b[i][0]=b[i-1][0]+int(not(a[i-1][0]==a[i][0]))
	for j in range(1,W):
		b[i][j]=min(b[i-1][j]+int(not(a[i-1][j]==a[i][j])),b[i][j-1]+int(not(a[i][j-1]==a[i][j])))

if(a[0][0]=="." and a[H-1][W-1]=="."):
	print(int(b[H-1][W-1]/2))
elif(a[0][0]=="#" and a[H-1][W-1]=="#"):
  print(int(b[H-1][W-1]/2+1))
else:
  print(int((b[H-1][W-1]+1)/2))
#print(int(b[H-1][W-1]/2))

Buggy submission (verdict: Runtime Error):
H,W=map(int,input().split())

a=[[0]*W for i in range(H)]
b=[[0]*W for i in range(H)]


for i in range(H):
	a[i]=input().split(",")

for j in range(1,W):
	b[0][j]=b[0][j-1]+int(not(a[0][j]==a[0][j-1]))

for i in range(1,H):
	b[i][0]=b[i-1][0]+int(not(a[i-1][0]==a[i][0]))
	for j in range(1,W):
		b[i][j]=min(b[i-1][j]+int(not(a[i-1][j]==a[i][j])),b[i][j-1]+int(not(a[i][j-1]==a[i][j])))
	
print(b[H-1][W-1])
Problem p02753 (python)

Fixed submission:
S=list(input())

if(S[0]==S[1] and S[1]==S[2]):
  print("No")
  
else:
  print("Yes")

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

tmp1,tmp2=divmod(n,a+b)

blue=tmp1*a
if(tmp2>a):
  blue=blue+a
else:
  blue=blue+tmp2
  
print(blue)
Problem p02754 (python)

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

tmp1,tmp2=divmod(n,a+b)

blue=tmp1*a
if(tmp2>a):
  blue=blue+a
else:
  blue=blue+tmp2
  
print(blue)

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

tmp1,tmp2=divmod(N,a+b)

blue=tmp1*a
if(tmp2>a):
  blue=blue+a
eles:
  blue=blue+tmp2
  
print("blue")
Problem p02570 (python)

Fixed submission:
D,T,S = map(int,input().split())
duration = float(D)/float(S)
if duration > T:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
sumA = sum(A)%(1000000007)
sumA2 = (sumA * sumA)%(1000000007)
square = 0
for i in range(N):
    square +=  ( A[i]**2 ) % (1000000007)
    square = square % (1000000007)
buf = sumA2 - square
if buf < 0:
  buf = buf + (1000000007)
res = ( buf * ((1000000007+1)//2)) % 1000000007
print(round(res))
Problem p02699 (python)

Fixed submission:
e = list(map(int,input().split(sep=" ")))
if e[0]<=e[1]:
    print("unsafe")
else:
    print("safe")

Buggy submission (verdict: Runtime Error):
S=input()
mem_mod = [0 for i in range(0,2019,1)]
N = len(S)
counter = 0
S_num_tmp = list(S)
S_num = list(map(int, S_num_tmp))
tmp=10

for i in range(1,N,1):
    S_num[N-i-1] = S_num[N-i] + S_num[N-i-1]*pow(10,i,2019)

for i in range(0,N,1):
    X = S_num[N-i-1] % 2019
    if X==0:
        counter+=1
    counter += mem_mod[X]
    mem_mod[X] += 1
print(counter)

Buggy submission (verdict: Runtime Error):
S=input()
mem_mod = [0 for i in range(0,2019,1)]
N = len(S)
counter = 0
S_num_tmp = list(S)
S_num = list(map(int, S_num_tmp))
tmp=10

Buggy submission (verdict: Runtime Error):
S=input()
mem_mod = [0 for i in range(0,2019,1)]
N = len(S)
counter = 0
S_num_tmp = list(S)
S_num = list(map(int, S_num_tmp))
tmp=10