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

Fixed submission:
import sys
S = input()
T = "AKIHABARA"
posS = 0
posT = 0
while True:
    if posS == len(S):
        if posT >= len(T)-1:
            print("YES")
        else:
            print("NO")
        sys.exit()
    if posT >= len(T):
        print("NO")
        sys.exit()
    if S[posS] == T[posT]:
        posS += 1
        posT += 1
    elif T[posT] == 'A':
        posT += 1
    else:
        print("NO")
        sys.exit()

Buggy submission (verdict: Runtime Error):
import sys
S = input()
T = "AKIHABARA"
posS = 0
posT = 0
while True:
    if posS == len(S) and posT >= len(T)-1:
        print("YES")
        sys.exit()
    if posT >= len(T):
        print("NO")
        sys.exit()
    if S[posS] == T[posT]:
        posS += 1
        posT += 1
    elif T[posT] == 'A':
        posT += 1
    else:
        print("NO")
        sys.exit()

Buggy submission (verdict: Runtime Error):
import sys
S = input()
T = "AKIHABARA"
pos = 0
for x in S:
    if pos >= len(T):
        print("NO")
        sys.exit()
    if x == T[pos]:
        pos += 1
    elif T[pos] == 'A':
        pos += 1
        if x == T[pos]:
            pos += 1
        else:
            print("NO")
            sys.exit()
    else:
        print("NO")
        sys.exit()
print("YES")
Problem p03624 (python)

Fixed submission:
S = input()
flag = False
for i in range(26):
    c = chr(ord('a')+i)
    if c not in S:
        print(c)
        flag = True
        break
if flag == False:
    print('None')

Buggy submission (verdict: Runtime Error):
S = input()
flag = False
for i in range(26):
    c = chr(ord('a')+i)
    if c not in S:
        print(c)
        flag = True
        break
if !flag:
    print('None')
Problem p03777 (python)

Fixed submission:
a, b = list(map(str, input().split()))
if (a == 'H' and b == 'H') or (a == 'D' and b == 'D'):
    print('H')
else:
    print('D')

Buggy submission (verdict: Runtime Error):
a, b = list(map(int, input().split()))
if (a == 'H' and b == 'H') or (a == 'D' and b == 'D'):
    print('H')
else:
    print('D')
Problem p03970 (python)

Fixed submission:
str = "CODEFESTIVAL2016"
s =input()
cnt = 0
for i in range(16):
  if s[i]!=str[i]:
    cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
str = "CODEFESTIVAL2016"
s =input()
cnt = 0
for i in range(16):
  if s[i]!=str[i]:
    cnt++
print(cnt)
Problem p02696 (python)

Fixed submission:
a, b, n = map(int, input().split())
x = min(b-1, n)
ans = int((a*x)/b) - a*int(x/b)
print(ans)

Buggy submission (verdict: Runtime Error):
a, b, n = map(int, input().split())
x = min(b-1, n)
ans = max(int((a*x)/b) - a*int(x/b))
print(ans)

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

a, b, n = map(int, input().split())
array = np.arange(1, n+1, math.ceil(1/10**5))
ans = -sys.maxsize-1

for x in array:
    val = int((a*x)/b) - a*int(x/b)
    if val > ans:
        ans = val

print(ans)
Problem p03061 (python)

Fixed submission:
from fractions import gcd

N = int(input())
nums = [int(i) for i in input().split()]

fort = [nums[0], gcd(nums[0], nums[1])]
back = [nums[N-1], gcd(nums[N-1], nums[N-2])]
ans = []

for i in range(N-2):
    fort.append(gcd(fort[i+1], nums[i+2]))
                
for i in range(N-2):
    back.append(gcd(back[i+1], nums[N-(i+3)]))
    
for i in range(1, N-1):
    ans.append(gcd(fort[i-1], back[N-2-i]))

ans.append(fort[N-2])
ans.append(back[N-2])

print(max(ans))

Buggy submission (verdict: Runtime Error):
import math
import copy
from functools import reduce
from fractions import gcd

N = int(input())
nums = [int(i) for i in input().split()]
nums2 = copy.copy(nums)
ans = []

def gcds(numlist):
    return reduce(math.gcd, numlist)


for i in range(N):
   nums.pop(i)
   ans.append(gcds(nums))
   nums = copy.copy(nums2)

print(max(ans))

Buggy submission (verdict: Runtime Error):
import math
import copy
from functools import reduce

N = int(input())
nums = [int(i) for i in input().split()]
nums2 = copy.copy(nums)
ans = []

def gcds(numlist):
    return reduce(math.gcd, numlist)


for i in range(N):
   nums.pop(i)
   ans.append(gcds(nums))
   nums = copy.copy(nums2)

print(max(ans))
Problem p02621 (python)

Fixed submission:
a = int(input())
print(a + a**2 + a**3)

Buggy submission (verdict: Runtime Error):
n = map(x**3 + x**2 + x,int(input()))
print(n)
Problem p02639 (python)

Fixed submission:
s = input()
list = s.split(" ")
for i in range(5):
  if int(list[i]) == 0:
    print(i+1)

Buggy submission (verdict: Runtime Error):
a,b = map(int, input().split())
list = []
for y in range(a+1):
  list += [y*4 + (a-y)*2]
  
if b in list:
  print("Yes")
else:
  print("No")
Problem p02614 (python)

Fixed submission:
import itertools
from typing import List


def main():
    h, w, k = map(int, input().split())
    c = []
    for _ in range(h):
        c.append(list(input()))

    print(hv(c, h, w, k))


def hv(c: List[List[str]], h: int, w: int, k: int) -> int:
    ret = 0
    for comb_h in itertools.product((False, True), repeat=h):
        for comb_w in itertools.product((False, True), repeat=w):
            cnt = 0
            for i in range(h):
                for j in range(w):
                    if comb_h[i] and comb_w[j] and c[i][j] == '#':
                        cnt += 1
            if cnt == k:
                ret += 1
    return ret


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import itertools
from typing import List


def main():
    h, w, k = map(int, input().split())
    c = []
    for _ in range(h):
        c.append(input().split())

    print(hv(c, h, w, k))


def hv(c: List[List[str]], h: int, w: int, k: int) -> int:
    ret = 0
    for comb_h in itertools.product((False, True), repeat=h):
        for comb_w in itertools.product((False, True), repeat=w):
            cnt = 0
            for i in range(h):
                for j in range(w):
                    if comb_h[i] and comb_w[j] and c[i][j] == '#':
                        cnt += 1
            if cnt == k:
                ret += 1
    return ret


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

Fixed submission:
from typing import List


def main():
    nums = [int(n) for n in input().split(' ')]

    if si(nums):
        print('Yes')
    else:
        print('No')


def si(nums: List[int]) -> bool:
    result = False
    a, b, c = nums

    if 4 * a * b < (c - a - b) ** 2 and (c - a - b) > 0:
        result = True

    return result


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math

from typing import List


def main():
    a, b, c = input().split(' ')

    if si([a, b, c]):
        print('YES')
    else:
        print('NO')


def si(nums: List[str]) -> bool:
    a, b, c = nums
    a *= 10 ** 8
    b *= 10 ** 8
    c *= 10 ** 8

    if int(math.sqrt(a)) + int(math.sqrt(b)) < int(math.sqrt(c)):
        return True
    else:
        return False


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

Fixed submission:
c = input()
print(chr(ord(c) + 1))

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


def main():
    h, w = map(int, input().split())
    g = [input() for _ in range(h)]
    print(mm(h, w, g))


def mm(h: int, w: int, g: List[List[str]]) -> int:
    ret = 0
    for i in range(h):
        for j in range(w):
            if (g[i][j] == '#'):
                continue
            cnt = 0
            q = deque([(i, j, cnt)])
            v = set()
            while q:
                ii, jj, cnt = q.popleft()
                v.add((ii, jj))
                ret = max(ret, cnt)
                # ↓
                if ii < h - 1 and g[ii + 1][jj] == '.' and (ii + 1, jj) not in v:
                    q.append((ii + 1, jj, cnt + 1))
                # →
                if jj < w - 1 and g[ii][jj + 1] == '.' and (ii, jj + 1) not in v:
                    q.append((ii, jj + 1, cnt + 1))
                # ↑
                if ii > 0 and g[ii - 1][jj] == '.' and (ii - 1, jj) not in v:
                    q.append((ii - 1, jj, cnt + 1))
                # ←
                if jj > 0 and g[ii][jj - 1] == '.' and (ii, jj - 1) not in v:
                    q.append((ii, jj - 1, cnt + 1))
    return ret


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

Fixed submission:
from collections import deque
from typing import List


def main():
    h, w = map(int, input().split())
    g = []
    for _ in range(h):
        r = list(input())
        g.append(r)
    print(mm(h, w, g))


def mm(h: int, w: int, g: List[List[str]]) -> int:
    ret = 0
    for i in range(h):
        for j in range(w):
            if (g[i][j] == '#'):
                continue
            v = set()
            q = deque([(i, j, 0)])
            v.add((i, j))
            while q:
                ii, jj, cnt = q.popleft()
                ret = max(ret, cnt)
                # ↓
                if ii < h - 1 and g[ii + 1][jj] == '.' and (ii + 1, jj) not in v:
                    q.append((ii + 1, jj, cnt + 1))
                    v.add((ii + 1, jj))
                # →
                if jj < w - 1 and g[ii][jj + 1] == '.' and (ii, jj + 1) not in v:
                    q.append((ii, jj + 1, cnt + 1))
                    v.add((ii, jj + 1))
                # ↑
                if ii > 0 and g[ii - 1][jj] == '.' and (ii - 1, jj) not in v:
                    q.append((ii - 1, jj, cnt + 1))
                    v.add((ii - 1, jj))
                # ←
                if jj > 0 and g[ii][jj - 1] == '.' and (ii, jj - 1) not in v:
                    q.append((ii, jj - 1, cnt + 1))
                    v.add((ii, jj - 1))
    return ret


if __name__ == '__main__':
    main()

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


def main():
    h, w = map(int, input().split())
    g = []
    for _ in range(h):
        r = input().split()
        g.append(r)
    print(mm(h, w, g))


def mm(h: int, w: int, g: List[List[str]]) -> int:
    ret = 0
    for i in range(h):
        for j in range(w):
            if (g[i][j] == '#'):
                continue
            cnt = 0
            q = deque([(i, j, cnt)])
            v = set()
            while q:
                ii, jj, cnt = q.popleft()
                v.add((ii, jj))
                ret = max(ret, cnt)
                # ↓
                if ii < h - 1 and g[ii + 1][jj] == '.' and (ii + 1, jj) not in v:
                    q.append((ii + 1, jj, cnt + 1))
                # →
                if jj < w - 1 and g[ii][jj + 1] == '.' and (ii, jj + 1) not in v:
                    q.append((ii, jj + 1, cnt + 1))
                # ↑
                if ii > 0 and g[ii - 1][jj] == '.' and (ii - 1, jj) not in v:
                    q.append((ii - 1, jj, cnt + 1))
                # ←
                if jj > 0 and g[ii][jj - 1] == '.' and (ii, jj - 1) not in v:
                    q.append((ii, jj - 1, cnt + 1))
    return ret


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

Fixed submission:
n = int(input())
s = list(input())

result = 0
for i in range(len(s)):
    if (i > n - 3):
        break
    if (s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C'):
        result = result + 1

print(result)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = int(input())
s = list(input())
 
result = 0
for range(len(s)):
  if s > n - 3:
    break
  if (s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C'):
    result = result + 1
    
print(result)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = int(input())
s = list(input())

result = 0
for(int i = 0; i < n - 3; i++):
  if (s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C'):
    result = result + 1
    
print(result)
Problem p03290 (python)

Fixed submission:
import copy
import heapq

from typing import List, Tuple


def main():
    d, g = map(int, input().split())
    v = []
    for _ in range(d):
        p, c = map(int, input().split())
        v.append((p, c))

    print(ag(v, g))


def ag(v: List[Tuple[int, int]], g: int) -> int:
    rs = []
    # ex. [(3, 500), (5, 800)] -> [(1, 3, 500), (2, 5, 800)]
    v = [(i, p, c) for i, (p, c) in enumerate(v, 1)]

    for j in range(2 ** len(v)):
        cb = []
        for k in range(len(v)):
            if ((j >> k) & 1):
                cb.append(v[k])

        sc = 0
        cnt = 0
        # calc bonus score
        for (i, p, c) in cb:
            sc += i * 100 * p + c
            cnt += p

        vv = [x for x in copy.copy(v) if not x in cb]
        while sc < g:
            if not vv:
                break
            i, p, _ = vv.pop()
            for _ in range(p - 1):
                if sc >= g:
                    break
                sc += i * 100
                cnt += 1

        if sc >= g:
            heapq.heappush(rs, cnt)
    return heapq.heappop(rs)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import copy
import heapq

from typing import List, Tuple


def main():
    d, g = map(int, input().split())
    v = []
    for _ in range(d):
        p, c = map(int, input().split())
        v.append((p, c))

    print(ag(v, g))


def ag(v: List[Tuple[int, int]], g: int) -> int:
    rs = []
    # ex. [(3, 500), (5, 800)] -> [(1, 3, 500), (2, 5, 800)]
    v = [(i, p, c) for i, (p, c) in enumerate(v, 1)]

    for j in range(len(v) ** 2):
        cb = []
        for k in range(len(v)):
            if ((j >> k) & 1):
                cb.append(v[k])

        sc = 0
        cnt = 0
        # calc bonus score
        for (i, p, c) in cb:
            sc += i * 100 * p + c
            cnt += p

        vv = [x for x in copy.copy(v) if not x in cb]
        while sc < g:
            if not vv:
                break
            i, p, _ = vv.pop()
            for _ in range(p - 1):
                if sc >= g:
                    break
                sc += i * 100
                cnt += 1

        if sc >= g:
            heapq.heappush(rs, cnt)

    return heapq.heappop(rs)


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

Fixed submission:
from typing import List, Tuple


def main():
    n, m = map(int, input().split())
    g = []
    for _ in range(m):
        a, b = map(int, input().split())
        g.append((a, b))
    print(bb(n, m, g))


def bb(n: int, m: int, g: List[Tuple[int, int]]):
    ret = 0
    for i in range(m):
        v = set()
        w = [1]
        while w:
            now = w.pop()
            v.add(now)
            for j, node in enumerate(g):
                if j == i:
                    continue
                if node[0] == now and node[1] not in v:
                    w.append(node[1])
                elif node[1] == now and node[0] not in v:
                    w.append(node[0])
        if len(v) != n:
            ret += 1
    return ret


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from typing import List, Tuple


def main():
    n, m = map(int, input().split())
    g = []
    for _ in range(m):
        a, b = map(int, input().split())
        g.append((a, b))
    print(b(n, m, g))


def b(n: int, m: int, g: List[Tuple[int, int]]):
    ret = 0
    for i in range(m):
        v = set()
        w = [1]
        while w:
            now = w.pop()
            v.add(now)
            for j, node in enumerate(g):
                if j == i:
                    continue
                if node[0] == now and node[1] not in v:
                    w.append(node[1])
                elif node[1] == now and node[0] not in v:
                    w.append(node[0])
        if len(v) != n:
            ret += 1
    return ret


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from typing import List, Tuple


def main():
    n, m = map(int, input().split())
    g = []
    for _ in range(m):
        a, b = map(int, input().split())
        g.append((a, b))
    print(b(n, m, g))


def b(n: int, m: int, g: List[Tuple[int, int]]):
    ret = 0
    for i in range(m):
        v = set()
        w = []
        w.append(1)
        while w:
            now = w.pop()
            v.add(now)
            for j, node in enumerate(g):
                if j == i:
                    continue
                if node[0] == now and node[1] not in v:
                    w.append(node[1])
                elif node[1] == now and node[0] not in v:
                    w.append(node[0])
        if len(v) != n:
            ret += 1
    return ret


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

Fixed submission:
s_list = list(input())

result = None

for s_uni in range(ord('a'), ord('z') + 1):
    if not chr(s_uni) in s_list:
        result = chr(s_uni)
        break

if result:
    print(result)
else:
    print('None')

Buggy submission (verdict: Runtime Error):
s_list = list(input())
 
result = None
 
for s_uni in range(ord('a'), ord('z') + 1):
    if not chr(s_uni) in s_list:
        result = chr(s_uni)
        break
 
if result:
  print(result)
else
  print('None')

Buggy submission (verdict: Runtime Error):
s_list = list(input())

small = None

for s_uni in range(ord('a'), ord('z') + 1):
    if not chr(s_uni) in s_list:
        small = chr(s_uni)
        break

if small:
  print(smal)
else
  print('None')
Problem p03673 (python)

Fixed submission:
from collections import deque
from typing import List


def main():
    n = int(input())
    v = input().split(" ")
    print(*pp(n, v))


def pp(n: int, v: List[str]) -> List[str]:
    x = []
    y = deque([])

    if n % 2 == 0:
        for i in range(n):
            if i % 2 == 0:
                y.append(v[i])
            else:
                x.append(v[i])
    else:
        for i in range(n):
            if i % 2 == 0:
                x.append(v[i])
            else:
                y.append(v[i])

    ret = []
    for i in range(len(x)):
        ret.append(x.pop())

    for i in range(len(y)):
        ret.append(y.popleft())

    return ret


if __name__ == "__main__":
    main()

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


def main():
    n = int(input())
    v = input().split("")
    print(pp(n, v))


def pp(n: int, v: List[str]) -> List[str]:
    x = []
    y = deque([])

    if n % 2 == 0:
        for i in range(n):
            if i % 2 == 0:
                y.append(v[i])
            else:
                x.append(v[i])
    else:
        for i in range(n):
            if i % 2 == 0:
                x.append(v[i])
            else:
                y.append(v[i])

    ret = []
    for i in range(len(x)):
        ret.append(x.pop())

    for i in range(len(y)):
        ret.append(y.popleft())

    return ret


if __name__ == "__main__":
    main()

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


def main():
    n = int(input())
    v = [input().split("")]
    print(pp(n, v))


def pp(n: int, v: List[str]) -> List[str]:
    x = []
    y = deque([])

    if n % 2 == 0:
        for i in range(n):
            if i % 2 == 0:
                y.append(v[i])
            else:
                x.append(v[i])
    else:
        for i in range(n):
            if i % 2 == 0:
                x.append(v[i])
            else:
                y.append(v[i])

    ret = []
    for i in range(len(x)):
        ret.append(x.pop())

    for i in range(len(y)):
        ret.append(y.popleft())

    return ret


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

Fixed submission:
# coding : utf-8

import numpy as np

A = [int(i) for i in input().split()]

if A[0] <= A[2] and A[0] + A[1] >= A[2]:
	print("YES")
else:
	print("NO")

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

import numpy as np

A = [int(i) for i in input().split()]

if A[0] <= A[2] and A[0] + A[1] => A[2]:
	print("YES")
else:
	print("NO")
Problem p03380 (python)

Fixed submission:
# coding : utf-8

import numpy as np

N = int(input())
X = np.array([int(i) for i in input().split()])

X = np.sort(X)
maxl = np.max(X)
Xed = (X - maxl/2)**2
com = X[np.where(Xed == np.min(Xed))]

print(maxl,com[0])

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

import numpy as np

N = int(input())
X = np.array([int(i) for i in input().split()])

X = np.sort(X)
maxl = np.max(X)
Xed = (X - maxl/2)**2
com = Xed[np.where(np.min(Xed))]
print(X)
print(Xed)
print(com)
print(maxl,Xed[com[0]])

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

import numpy as np

N = int(input())
X = np.array([int(i) for i in input().split()])

X = np.sort(X)
maxl = np.max(X)
Xed = (X - maxl/2)**2
com = X[np.where(np.min(Xed))]
print(X)
print(Xed)
print(com)
print(maxl,X[com[0]])

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

import numpy as np

N = int(input())
X = np.array([int(i) for i in input().split()])

X = np.sort(X)
maxl = np.max(X)
Xed = (X - int(maxl/2))**2
com = X[np.where(np.min(Xed))]
print(maxl,X[com[0]])

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

import numpy as np

N = int(input())
X = np.array([int(i) for i in input().split()])

X = sorted(X)
maxl = np.max(X)
com = X[np.where(np.min(X-int(maxl/2)))]
 
print(maxl,com[0])
Problem p03385 (python)

Fixed submission:
# coding : utf-8

import numpy as np

A = input()

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

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

import numpy as np

A = input()

if(A[0]!=A[1] and A[0]!=A[2] and A[1]!=A[2])
	print("Yes")
else:
	print("No")
Problem p03417 (python)

Fixed submission:
# coding:utf-8

in1 = input().split()

in1 = [int(i) for i in in1]

if(in1[0]==1 and in1[1]==1):
    print("1")
elif(in1[0]==1 or in1[1]==1):
    print((in1[0]-2)*(in1[1]-2)*(-1))
else:
    print((in1[0]-2)*(in1[1]-2))

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

in1 = input().split()

in1 = [int(i) for i in in1]

if(in1[0]==1 fand in1[1]==1):
    print("1")
elif(in1[0]==1 or in1[1]==1):
    print((in1[0]-2)*(in1[1]-2)*(-1))
else:
    print((in1[0]-2)*(in1[1]-2))
Problem p02658 (python)

Fixed submission:
from sys import stdin
input = stdin.readline

n = int(input())
aa = list(map(int, input().split()))
if 0 in aa:
  print(0)
  exit()
ans = 1
for a in aa:
  ans *= a
  if ans > 10**18:
    print(-1)
    exit()
print(ans)

Buggy submission (verdict: Runtime Error):
from sys import stdin
input = stdin

n = int(input())
aa = list(map(int, input().split()))
if 0 in aa:
  print(0)
  exit()
ans = 1
for a in aa:
  ans *= a
  if ans > 10**18:
    print(-1)
    exit()
print(ans)

Buggy submission (verdict: Runtime Error):
from sys import stdin
input = sys.stdin

n = int(input())
aa = list(map(int, input().split()))
if 0 in aa:
  print(0)
  exit()
ans = 1
for a in aa:
  ans *= a
  if ans > 10**18:
    print(-1)
    exit()
print(ans)