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

Fixed submission:
H, W = map(int, input().split())
S = [list(input()) for i in range(H)]

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

if S[0][0] == '#':
    board[0][0] = 1

for i in range(1, W):
    if S[0][i - 1] == '.' and S[0][i] == '#':
        board[0][i] = board[0][i - 1] + 1
    else:
        board[0][i] = board[0][i - 1]

for i in range(1, H):
    if S[i - 1][0] == '.' and S[i][0] == '#':
        board[i][0] = board[i - 1][0] + 1
    else:
        board[i][0] = board[i - 1][0]

for i in range(1, H):
    for j in range(1, W):
        if S[i][j] == '.':
            board[i][j] = min(board[i - 1][j], board[i][j - 1])
        else:
            if S[i - 1][j] == '.':
                up = 1
            else:
                up = 0
            if S[i][j - 1] == '.':
                left = 1
            else:
                left = 0
            board[i][j] = min(board[i - 1][j] + up, board[i][j - 1] + left)

print(board[H - 1][W - 1])

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

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

if S[0][0] == '#':
    board[0][0] = 1

if W > 1:
    for i in range(1, W):
        if S[0][i - 1] == '.' and S[0][i] == '#':
            board[0][i] = board[0][i - 1] + 1
        else:
            board[0][i] = board[0][i - 1]
if H > 1:
    for i in range(1, H):
        if S[i - 1][0] == '.' and S[i][0] == '#':
            board[i][0] = board[i - 1][0] + 1
        else:
            board[i][0] = board[i - 1][0]

if H > 1 and W > 1:
    for i in range(1, W):
        for j in range(1, H):
            if S[i][j] == '.':
                board[i][j] = min(board[i - 1][j], board[i][j - 1])
            else:
                if S[i - 1][j] == '.':
                    left = 1
                else:
                    left = 0
                if S[i][j - 1] == '.':
                    up = 1
                else:
                    up = 0
                board[i][j] = min(board[i - 1][j] + left, board[i][j - 1] + up)

print(board[H - 1][W - 1])

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

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

if S[0][0] == '#':
    board[0][0] = 1

for i in range(1, W):
    if S[0][i - 1] == '.' and S[0][i] == '#':
        board[0][i] = board[0][i - 1] + 1
    else:
        board[0][i] = board[0][i - 1]

for i in range(1, H):
    if S[i - 1][0] == '.' and S[i][0] == '#':
        board[i][0] = board[i - 1][0] + 1
    else:
        board[i][0] = board[i - 1][0]

for i in range(1, W):
    for j in range(1, H):
        if S[i][j] == '.':
            board[i][j] = min(board[i - 1][j], board[i][j - 1])
        else:
            if S[i - 1][j] == '.':
                left = 1
            else:
                left = 0
            if S[i][j - 1] == '.':
                up = 1
            else:
                up = 0
            board[i][j] = min(board[i - 1][j] + left, board[i][j - 1] + up)

print(board[H - 1][W - 1])
Problem p02753 (python)

Fixed submission:
s = input()
if s[0] == s[1] and s[1] == s[2]:
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
    s = input()
    if s[0] == s[1] and s[1] == s[2]:
        print("No")
    else:
        print("Yes")
Problem p02779 (python)

Fixed submission:
N = int(input()) # 数字を変数に格納
List = list(map(int,input().split())) # 複数の数字をリストに格納

List.sort()
result = 'YES'

for i in range(N-1):
    if List[i] == List[i+1]:
        result = 'NO'
        break
        
print(result)

Buggy submission (verdict: Runtime Error):
N = int(input()) # 数字を変数に格納
List = list(map(int,input().split())) # 複数の数字をリストに格納

List.sort()

for i in range(N-1):
    if List[i] == List[i+1]:
        result = 'NO'
        break
        
print(result)
Problem p03017 (python)

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

flag = 0

if D > C:
    for i in range(D-B-2):
        if S[B+i] == '#' and S[B+i+1] == '#':
            print('No')
            flag = 1
            break
    if flag == 0:
        for j in range(C-A-2):
            if S[A+j] == '#' and S[A+j+1] == '#':
                print('No')
                flag = 1
                break        
        if flag == 0:
            print('Yes')
else:
    count = 0
    for i in range(D-B+3):
        if S[B-2+i] == '.':
            count += 1
        else:
            count = 0
        if count == 3:
            flag = 1
            break
    if flag == 0:
        print('No')
    else:
        for j in range(C-A-2):
            if S[A+j] == '#' and S[A+j+1] == '#':
                print('No')
                flag = 0
                break        
        if flag == 1:
            print('Yes')

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

flag = 0

if D > C:
    for i in range(D-B-2):
        if S[B+i] == '#' and S[B+i+1] == '#':
            print('No')
            flag = 1
            break
    if flag == 0:
        for j in range(C-A-2):
            if S[A+j] == '#' and S[A+j+1] == '#':
                print('No')
                flag = 1
                break        
        if flag == 0:
            print('Yes')
else:
    count = 0
    for i in range(D-B+3):
        if S[B-2+j] == '.':
            count += 1
        else:
            count = 0
        if count == 3:
            flag = 1
            break
    if flag == 0:
        print('No')
    else:
        for j in range(C-A-2):
            if S[A+j] == '#' and S[A+j+1] == '#':
                print('No')
                flag = 0
                break        
        if flag == 1:
            print('Yes')
Problem p03018 (python)

Fixed submission:
s = input()

N = len(s)

i = 0
result = 0
count_a = 0
count_bc = 0

while i < N-2:
    if s[i] == 'A':
        while s[i] == 'A' and i < N-2:
            count_a += 1
            i += 1
        
        if i >= N-1:
            break
                        
        while s[i] == 'B' and s[i+1] == 'C':
            count_bc += 1
            i += 2
            if i >= N-1:
                break
        
        result += count_a * count_bc

        if i >= N-1:
            break
        
        if count_bc > 0 and s[i] == 'A':
            count_a = count_a
        else:
            count_a = 0
        
        count_bc = 0
                    
    else:
        i += 1
        
print(result)

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

N = len(s)

i = 0
result = 0
count_a = 0
count_bc = 0

while i < N-2:
    if s[i] == 'A':
        while s[i] == 'A':
            count_a += 1
            i += 1
        
        if i >= N-1:
            break
        
#        if s[i] == 'B' and s[i+1] == 'C':
#            result += count_a - 1
                
        while s[i] == 'B' and s[i+1] == 'C':
            count_bc += 1
            i += 2
            if i >= N-1:
                break
        
        result += count_a * count_bc

        if i >= N-1:
            break
        
        if count_bc > 0 and s[i] == 'A':
            count_a = count_a
        else:
            count_a = 0
        
        count_bc = 0
                    
    else:
        i += 1
        
print(result)

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

N = len(s)

i = 0
result = 0
count_a = 0
count_bc = 0

while i < N-2:
    if s[i] == 'A':
        while s[i] == 'A':
            count_a += 1
            i += 1
        
        if i >= N-1:
            break
        
        if s[i] == 'B' and s[i+1] == 'C':
            result += count_a - 1
        
        count_a = 0
        
        while s[i] == 'B' and s[i+1] == 'C':
            count_bc += 1
            i += 2
            if i >= N-1:
                break
            if s[i] == 'A':
                count_a = 1
        
        result += count_bc
        count_bc = 0
                    
    else:
        i += 1
        
print(result)

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

N = len(s)

i = 0
result = 0
count_a = 0
count_bc = 0

while i < N-2:
    if s[i] == 'A':
        while s[i] == 'A':
            count_a += 1
            i += 1
        
        if i >= N-1:
            break
        
        if s[i] == 'B' and s[i+1] == 'C':
            result += count_a - 1
        
        count_a = 0
        
        while s[i] == 'B' and s[i+1] == 'C':
            count_bc += 1
            i += 2
            if i >= N-1:
                break
            if s[i] == 'A':
                count_a = 1
        
        result += count_bc
        count_bc = 0
            
        if i >= N -1:
            break
        
    else:
        i += 1
        
print(result)
Problem p03038 (python)

Fixed submission:
N, M = map(int,input().split())
List_A = list(map(int,input().split()))
List_BC = [list(map(int,input().split())) for i in range(M)]

List_A.sort()
List_BC.sort(key=lambda x:x[1], reverse=True)
flag = 0
k = 0

for i in range(M):
    for j in range(List_BC[i][0]):
        if k >= N:
            flag = 1
            break
        elif List_BC[i][1] > List_A[k]:
            List_A[k] = List_BC[i][1]
            k += 1
        else:
            flag = 1
            break
    if flag == 1:
        break

tmp = 0
for i in range(N):
    tmp += List_A[i]
    
print("{}".format(tmp))

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
List_A = list(map(int,input().split()))
List_BC = [list(map(int,input().split())) for i in range(M)]

List_A.sort()
List_BC.sort(key=lambda x:x[1], reverse=True)
flag = 0
k = 0

for i in range(M):
    for j in range(List_BC[i][0]):
        if List_BC[i][1] >= List_A[k] and k < N:
            List_A[k] = List_BC[i][1]
            k += 1
        else:
            flag = 1
            break
    if flag == 1:
        break

tmp = 0
for i in range(N):
    tmp += List_A[i]
    
print("{}".format(tmp))

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
List_A = list(map(int,input().split()))
List_BC = [list(map(int,input().split())) for i in range(M)]

List_A.sort()
List_BC.sort(key=lambda x:x[1], reverse=True)
flag = 0
k = 0

for i in range(M):
    for j in range(List_BC[i][0]):
        if List_BC[i][1] > List_A[k] and k < N:
            List_A[k] = List_BC[i][1]
            k += 1
        else:
            flag = 1
            break
    if flag == 1:
        break

tmp = 0
for i in range(N):
    tmp += List_A[i]
    
print("{}".format(tmp))

Buggy submission (verdict: Runtime Error):
N, M = map(int,input().split())
List_A = list(map(int,input().split()))
List_BC = [list(map(int,input().split())) for i in range(M)]

List_A.sort()
List_BC.sort(key=lambda x:x[1], reverse=True)
flag = 0
k = 0

for i in range(M):
    for j in range(List_BC[i][0]):
        if List_BC[i][1] > List_A[k]:
            List_A[k] = List_BC[i][1]
            k += 1
        else:
            flag = 1
            break
    if flag == 1:
        break

tmp = 0
for i in range(N):
    tmp += List_A[i]
    
print("{}".format(tmp))
Problem p02933 (python)

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

Buggy submission (verdict: Runtime Error):
a = input()
s = input()
if a > 3200:
  print(s)
else:
  print('red')
Problem p02578 (python)

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

s = 0

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

print(s)

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

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

s = 0

def step(a, s):
    am = np.argmax(a)
    s = s + np.max(a)*a[am+1:].shape[0] - np.sum(a[am+1:])

    if am == 0:
        return s
    else:
        return step(a[:am], s)

print(step(A, s))

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

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

s = 0

def step(a, s):
    am = np.argmax(a)
    s = s + np.max(a)*a[am+1:].shape[0] - np.sum(a[am+1:])

    if am == 0:
        return s
    else:
        return step(a[:am], s)

print(step(A, s))

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

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

s = 0

def step(a, s):
    am = np.argmax(a)
    s = s + np.max(a)*a[am+1:].shape[0] - np.sum(a[am+1:])
    
    if am == 0:
        return s
    return step(a[:am], s)

print(step(A, s))

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

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

s = 0

def step(a, s):
    am = np.argmax(a)
    s = s + np.max(a)*a[am+1:].shape[0] - np.sum(a[am+1:])
    
    if am == 0:
        return s
    return step(a[:am], s)

print(step(A, s))

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

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

s = 0

def step(a, s):
    am = np.argmax(a)
    s = s + np.max(a)*a[am+1:].shape[0] - np.sum(a[am+1:])
    
    if am == 0:
        return s
    return step(a[:am], s)

print(step(A, s))
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):
N=input()
A=map(int,input().split(' '))
summed=0
for i in range(0,N):
	for j in range(i+1,N):
		sumed+=A[i]*A[j]
MOD=10**9+7
print(sumed%MOD)
Problem p02571 (python)

Fixed submission:
S=input()
T=input()
result=len(T)
for s in range(0,len(S)-len(T)+1):
	diff=0
	for i in range(0,len(T)):
		if T[i]!=S[s+i]:
			diff+=1
	result=min(result,diff)

print(result)

Buggy submission (verdict: Runtime Error):
S=input()
T=input()
result=len(T)
for s in range(0,len(S)-len(T)+1):
	diff=0
	for i in range(0,len(T)):
		if T[i]!=S[s+i]:
			diff+=1
	result=min(ans,diff)

print(result)

Buggy submission (verdict: Runtime Error):
S=input()
T=input()
length=len(T)
for s in range(0,len(S)-len(T)+1):
	diff=0
	for i in range(0,len(T)):
		if T[i]!=S[s+i]:
			diff+=1
	result=min(ans,diff)

print(result)

Buggy submission (verdict: Runtime Error):
S=input()
T=input()
length=len(T)
for i in range(0,len(S)-len(T)+1):
	diff=0
	for i in range(0,len(T)):
		if T[i]!=S[s+i]:
			diff+=1
	result=min(ans,diff)

print(result)

Buggy submission (verdict: Runtime Error):
S=input()
T=input()
length=len(T)
for i in range(0,len(S)-len(T)+1):
	if S[i,i+length]==T:
		print(0)
Problem p02570 (python)

Fixed submission:
requestMap = list(map(float, input().split()))

D = requestMap[0]
T = requestMap[1]
S = requestMap[2]

dist = S * T

if dist >= D:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
def SumOfProduct(n, arrayA):
  ans = 0

  for i in range(0, len(arrayA)):
    for j in range(i + 1, len(arrayA)):
      ans += arrayA[i] * arrayA[j]

  print(ans)

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

SumOfProduct(n, arrayA)
Problem p02777 (python)

Fixed submission:
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(l):
	n = len(l)
	

s,t = map(str, stdin.readline().rstrip().split())
a,b = map(int, stdin.readline().rstrip().split())
u = input()
if(u == s):
	a -= 1
else:
	b -= 1
print(a,b)

Buggy submission (verdict: Runtime Error):
,
Problem p02831 (python)

Fixed submission:
# ANSHUL GAUTAM
# IIIT-D

from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)


'''

'''

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

def solve(a,b):
	g = gcd(a,b)
	return a*b//g

a,b = list(map(int, stdin.readline().rstrip().split()))
ans = solve(a,b)
print(ans)

Buggy submission (verdict: Runtime Error):
# ANSHUL GAUTAM
# IIIT-D

from math import *

a,b = list(map(int, stdin.readline().rstrip().split()))
print(0)

Buggy submission (verdict: Runtime Error):
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(a,b):
	g = gcd(a,b)
	return a*b//g

a,b = list(map(int, stdin.readline().rstrip().split()))
ans = solve(a,b)
print(ans)

Buggy submission (verdict: Runtime Error):
# ANSHUL GAUTAM
# IIIT-D

from math import *

'''

'''

def solve(a,b):
	g = gcd(a,b)
	return a*b//g

a,b = map(int, input().split())
ans = solve(a,b)
print(ans)

Buggy submission (verdict: Runtime Error):
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(a,b):
	g = gcd(a,b)
	return a*b//g

a,b = map(int, stdin.readline().rstrip().split())
ans = solve(a,b)
print(ans)

Buggy submission (verdict: Runtime Error):
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''

'''

def solve(a,b):
	g = gcd(a,b)
	return a*b//g

a,b = map(int, stdin.readline().rstrip().split())
ans = solve(a,b)
print(ans)
Problem p02948 (python)

Fixed submission:
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from heapq import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''
3 4
4 3
4 1
2 2
'''

def solve(l,m):
	n = len(l)
	L = [[] for i in range(10**5+1)]
	for i in l:
		d,r = i
		L[d].append(r)
	ans = 0
	hp = []
	for i in range(1,m+1):
		for j in L[i]:
			heappush(hp,-j)
		if(hp):
			ans -= heappop(hp)
	return ans

N,M = list(map(int, stdin.readline().rstrip().split()))
l = []
for _ in range(N):
	a,b = list(map(int, stdin.readline().rstrip().split()))
	l.append([a,b])
ans = solve(l,M)
print(ans)

Buggy submission (verdict: Runtime Error):
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from heapq import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''
3 4
4 3
4 1
2 2
'''

def solve(l,m):
	n = len(l)
	L = [[] for i in range(5)]
	for i in l:
		d,r = i
		L[d].append(r)
	ans = 0
	hp = []
	for i in range(1,m+1):
		for j in L[i]:
			heappush(hp,-j)
		if(hp):
			ans -= heappop(hp)
	return ans

N,M = list(map(int, stdin.readline().rstrip().split()))
l = []
for _ in range(N):
	a,b = list(map(int, stdin.readline().rstrip().split()))
	l.append([a,b])
ans = solve(l,M)
print(ans)
Problem p02547 (python)

Fixed submission:
N = int(input())

result = False
count = 0

for i in range(N):
    D1,D2 = map(int,input().split())
    if D1 == D2:
        count += 1
    else:
        count = 0

    if count > 2:
        result = True
        break

if result:
    print('Yes')
else:
    print('No')

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

result = False
count = 0

for range(N):
    D1,D2 = map(int,input().split())
    if D1 == D2:
        count += 1
    else:
        count = 0

    if count > 2:
        result = True
        break

if result:
    print('Yes')
else:
    print('No')
Problem p02572 (python)

Fixed submission:

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

result = 0

s = sum(n_list)
m = 10**9+7

for num in n_list:
    s -= num
    result += num * s % m
    result %= m

print(result)

Buggy submission (verdict: Runtime Error):
MOD = 1000000007

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

print(n_list)

result = 0

for i in range(n):
    for j in range(n-i-1)
        result += n_list[i] * n_list[j+1] % MOD
        result = result % MOD

print(result)
Problem p02627 (python)

Fixed submission:
a = str(input())


if 'A'<=a and a<='Z':
    print('A')
else:
    print('a')

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

cnt_dict = {}


s = sum(A)

ans = 0

for item in A:
    if item not in cnt_dict:
        cnt_dict[item] = 0
    cnt_dict[item] += 1

for _ in range(Q):
    X,Y = map(int,input().split())

    if X not in cnt_dict:
        cnt_dict[X] = 0
    if Y not in cnt_dict:
        cnt_dict[Y] = 0

    s -= cnt_dict[X] * X
    s += cnt_dict[X] * Y

    cnt_dict[Y] += cnt_dict[X]
    cnt_dict[X] = 0


    print(s)





'''
#初期案　遅すぎ

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



for i in range(Q):
    X,Y = map(int,input().split())

    ans = 0

    for j in range(N):
        if A[j] == X:
            ans += Y
            A[j] = Y
        else:
            ans += A[j]

    print(ans)

    '''