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

Fixed submission:
#coding:utf-8
a = int(input())

if a == 25:
	print('Christmas')
if a == 24:
	print('Christmas Eve')
if a == 23:
	print('Christmas Eve Eve')
if a==22:
	print('Christmas Eve Eve Eve')

Buggy submission (verdict: Runtime Error):
#coding:utf-8
a = int(input('a = '))

if a == 25:
	print "Christmas"
if  a == 24:
	print "Christmas Eve"
if  a == 23:
	print "Christmas Eve Eve"
if a==22:
	print "Christmas Eve Eve Eve"

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

def count(a):
	if a == 25:
		print "Christmas"
	if  a == 24:
		print "Christmas Eve"
	if  a == 23:
		print "Christmas Eve Eve"
	if a==22:
		print "Christmas Eve Eve Eve"

if __name__ == "__main__":
    print('入力してください')
    b = input('a = ')
    count(b)

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

def count(a):
	if a == 25:
		print "Christmas"
	elif  a == 24:
		print "Christmas Eve"
	elif  a == 23:
		print "Christmas Eve Eve"
	elif a==22:
		print "Christmas Eve Eve Eve"

if __name__ == "__main__":
    print('入力してください')
    b = input('a = ')
    count(b)

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

def count(a):
	if 'a == 25':
		print "Christmas"
	elif  'a == 24':
		print "Christmas Eve"
	elif  'a == 23':
		print "Christmas Eve Eve"
	elif  'a == 22':
		print "Christmas Eve Eve Eve"

if __name__ == "__main__":
    print('入力してください')
    a = input('a = ')
    count(a)

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

def count():
	if 'a == 25':
		print "Christmas"
	elif  'a == 24':
		print "Christmas Eve"
	elif  'a == 23':
		print "Christmas Eve Eve"
	elif  'a == 22':
		print "Christmas Eve Eve Eve"

if __name__ == "__main__":
    print('入力してください')
    a = input('a = ')
    count(a)
Problem p02882 (python)

Fixed submission:
a,b,x = map(int,input().split())
h = x/(a*a)

import math

def f1(d,H,h):
    if h == H:
        return 90
    if h > H/2:
        return math.degrees(math.atan(d/(2*(H-h))))
    else:
        return math.degrees(math.atan((2*d*h)/(H*H)))

print(str.format('{0:.10f}', 90 - f1(a,b,h)))

Buggy submission (verdict: Runtime Error):
a,b,x = map(int,input().split())
h = x/(a*a)

import math

def f1(d,H,h):
    if h >= H/2:
        return math.degrees(math.atan(d/(2*(H-h))))
    else:
        return math.degrees(math.atan((2*d*h)/(H*H)))

print(str.format('{0:.10f}', 90 - f1(a,b,h)))

Buggy submission (verdict: Runtime Error):
a,b,x = map(int,input().split())
h = x/(a*a)

import math

def f1(d,H,h):
    if h > H/2:
        return math.degrees(math.atan(d/(2*(H-h))))
    else:
        return math.degrees(math.atan((2*d*h)/(H*H)))

print(str.format('{0:.10f}', 90 - f1(a,b,h)))
Problem p02923 (python)

Fixed submission:
n = int(input())
a = [ int(i) for i in input().split() ]
if n == 1:
    print(0)
    import sys
    sys.exit()
ans = []
for i in range(1,n):
    if a[i] > a[i-1]:
        ans.append(0)
    else:
        ans.append(1)


dp = [ 0 for i in range(n-1) ]
dp[0] = ans[0]
for i in range(1,n-1):
    if ans[i] == 0:
        dp[i] = 0
    else:
        dp[i] = 1 + dp[i-1]

print(max(dp))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [ int(i) for i in input().split() ]
ans = []
for i in range(1,n):
    if a[i] > a[i-1]:
        ans.append(0)
    else:
        ans.append(1)


dp = [ 0 for i in range(n-1) ]
dp[0] = ans[0]
for i in range(1,n-1):
    if ans[i] == 0:
        dp[i] = 0
    else:
        dp[i] = 1 + dp[i-1]

print(max(dp))
Problem p03000 (python)

Fixed submission:
n,x = map(int,input().split())
l = [ int(i) for i in input().split() ]
st = 0
cnt = 1
for i in range(0,n):
  st += l[i]
  if st > x:
    break
  cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
n,x = map(int,input().split())
l = [ int(i) for i in input().split() ]
st = 0
cnt = 1
for i range(0,n):
  st += l[i]
  if st > x:
    break
  cnt += 1
print(cnt)
Problem p03110 (python)

Fixed submission:
n = int(input())
ans = 0
for i in range(n):
  a,b =  input().split()
  a = float(a)
  if b == "BTC":
    a = 380000.0 * a 
  ans += a 
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = 0
for i in range(n):
  a,b =  input().split()
  a = double(a)
  if b == "BTC":
    a = 380000.0 * a 
  ans += a 
print(a)
Problem p03352 (python)

Fixed submission:
import bisect
a = []
for pw in range(2,1001):
    for x in range(1,1001):
        nw = x**pw
        if nw > 1000:
            break
        a.append(nw)
a = sorted(a)
x = int(input())
y = bisect.bisect_right(a,x)
print(a[y-1])

Buggy submission (verdict: Runtime Error):
from math import log
from math import floor
x = int(input())

y = []
for i in range(2,x):
    j = floor(log(x,i))
    if j>1 and i**j <= x:
        y.append(i**j)
print(max(y))
Problem p03761 (python)

Fixed submission:
n = int(input())
cnt = [ int(1e9) for i in range(26) ]
for i in range(n):
    s = input()
    nw = [ 0 for j in range(26) ]
    for j in s:
        nw[ord(j) - ord('a')]+=1
    for j in range(26):
        cnt[j] = min( cnt[j], nw[j] )
ans = ""
for i in range(26):
    if cnt[i] != int(1e9):
        ans += chr(i+97) * int(cnt[i])
print(ans)

Buggy submission (verdict: Runtime Error):
																																																																																																																																																																																																											n = int(input())
cnt = [ int(1e9) for i in range(26) ]
for i in range(n):
    s = input()
    nw = [ 0 for j in range(26) ]
    for j in s:
        nw[ord(j) - ord('a')]+=1
    for j in range(26):
        cnt[j] = min( cnt[j], nw[j] )
ans = ""
for i in range(26):
    if cnt[i] != int(1e9):
        ans += chr(i+97) * int(cnt[i])
print(ans)
Problem p02663 (python)

Fixed submission:
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(H: "List[int]", M: "List[int]", K: int):
    s = H[0] * 60 + M[0]
    t = H[1] * 60 + M[1]
    ret = t - s - K
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = [int()] * (2)  # type: "List[int]"
    M = [int()] * (2)  # type: "List[int]"
    for i in range(2):
        H[i] = int(next(tokens))
        M[i] = int(next(tokens))
    K = int(next(tokens))  # type: int
    solve(H, M, K)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(N: int, A: "List[int]"):
    cur = 1
    ret = 0
    t = []
    for i in range(N):
        v = A[i]
        if v >= cur:
            print(-1)
            return
        t.append(cur)
        ret += cur
        #print(i, cur, ret)
        cur = (cur - v) * 2
    if A[-1] > cur:
        print(-1)
        return
    ret += A[-1]
    #print(ret)

    mx = A[-1]
    for i in range(1, N)[::-1]:
        tmp = min(mx + A[i], 2 ** i)
        if t[i] > tmp:
            ret -= t[i] - tmp
        #ret += tmp
        mx = min(tmp, 2 ** (i - 1))
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N - 0 + 1)]  # type: "List[int]"
    solve(N, A)

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

Fixed submission:
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(X: int):
    a = 0
    b = 0
    while True:
        for x in [1, -1]:
            tmp = X + (x * b) ** 5
            if tmp < 0:
                continue
            t = int(tmp ** (1 / 5))
            if t ** 5 == tmp:
                print(t, x * b)
                return
        b += 1
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(X: int):
    a = 0
    b = 0
    while True:
        tmp = X + b ** 5
        t = int(tmp ** (1 / 5))
        if t ** 5 == tmp:
            a = t
            print(a, b)
            break
        tmp = X + (-b) ** 5
        t = int(tmp ** (1 / 5))
        if t ** 5 == tmp:
            a = t
            print(a, -b)
            break
        b += 1
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

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

Fixed submission:
#!/usr/bin/env python3
import sys


def solve(A: int, P: int):
    ret = (3 * A + P) // 2
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    P = int(next(tokens))  # type: int
    solve(A, P)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
 
 
def solve(N: int, Q: int, S: "List[int]", T: "List[int]", X: "List[int]", D: "List[int]"):
    def bsearch_l(val, D):
        l = -1
        r = Q - 1
        while r - l > 1:
            m = (l + r) // 2
            #print(val, l, r, m)
            if val > m:
                l = m
            else:
                r = m
        #print(val, l, r)
        return r
    def bsearch_r(val, D):
        l = 0
        r = Q
        while r - l > 1:
            m = (l + r) // 2
            #print(val, l, r, m)
            if val < D[m]:
                r = m
            else:
                l = m
        #print(val, l, r)
        return l
    a = []
    for i in range(N):
        a.append([X[i], max(0, -(X[i] - S[i]) - 1), max(0, -(X[i] - T[i]) - 1)])
    a.sort(key=lambda x: x[0])
    ret = [-1] * Q
    for tmp in a:
        l = bsearch_l(tmp[1], D)
        r = bsearch_r(tmp[2], D)
        #print(tmp)
        #print(l, r)
        for i in range(l, r + 1):
            if i >= 0 and i < Q and ret[i] < 0:
                ret[i] = tmp[0]
 
    for r in ret:
        print(r)
    return
 
 
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    S = [int()] * (N)  # type: "List[int]" 
    T = [int()] * (N)  # type: "List[int]" 
    X = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        S[i] = int(next(tokens))
        T[i] = int(next(tokens))
        X[i] = int(next(tokens))
    D = [ int(next(tokens)) for _ in range(Q) ]  # type: "List[int]"
    solve(N, Q, S, T, X, D)
 
if __name__ == '__main__':
    main()
Problem p03063 (python)

Fixed submission:
#!/usr/bin/env python3
import sys


def solve(N: int, S: str):
    white = []
    white.append(0)
    cur = 0
    for c in S:
        if c == '.':
            cur += 1
        white.append(cur)
    black = []
    black.append(0)
    cur = 0
    for c in S[::-1]:
        if c == '#':
            cur += 1
        black.append(cur)
    black.reverse()
    #print(white)
    #print(black)
    ret = float('inf')
    for i in range(N + 1):
        ret = min(ret, N - (white[i] + black[i]))
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
from pprint import pprint

MOD = 998244353  # type: int

def solve(N: int, a: "List[int]"):
    s = sum(a)
    dp = [[[0] * 2 for _ in range(s + 1)] for _ in range(N + 1)] # dp[idx][sum][]
    dp[0][0][0] = 1
    dp[0][0][1] = 1
    for i in range(N):
        for j in range(s + 1 - a[i]):
            dp[i + 1][j + a[i]][0] += dp[i][j][0]
            dp[i + 1][j + a[i]][1] += dp[i][j][1]
            dp[i + 1][j][0] += dp[i][j][0]
            dp[i + 1][j][1] += dp[i][j][1] * 2

    tmp = 0
    border = (s + 1) // 2
    uniq = 0
    #pprint(dp)
    for j in range(border, s + 1):
        tmp += dp[N][j][1]
        uniq += dp[N][j][0]
    #print(tmp, uniq)
    tmp -= uniq * 2
    tmp *= 3

    ret = (3 ** N) % MOD
    col_2 = (2 ** N) % MOD
    ret -= 3 + (col_2 - 2) * 3 + 3
    #print(ret)
    #for i in range(N):
    #    ret *= 3
    #    ret %= MOD
    #    col_2 *= 2
    #    col_2 %= MOD
    ret -= tmp
    print(ret % MOD)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, a)

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

Fixed submission:
#!/usr/bin/env python3
import sys


def solve(S: str):
    s = int(S[:4] + S[5:7] + S[8:10])
    if s <= 20190430:
        ret = 'Heisei'
    else:
        ret = 'TBD'
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
 
 
def solve(n: int, m: int, Q: int, s: "List[int]", t: "List[int]", x: "List[int]"):
 
    def check_pos(target, a, x):
        ret = {}
        a_x = a + x
        a_x.sort()
        idx = 0
        while idx < len(a_x) and a_x[idx] < target[0]:
            dis = target[0] - a_x[idx]
            ret[a_x[idx]] = [dis, [target[0], dis]] # [pos, dis]
            idx += 1
        for i in range(len(target) - 1):
            while idx < len(a_x) and target[i] <= a_x[idx] <= target[i + 1]:
                pos = a_x[idx]
                l = a_x[idx] - target[i]
                r = target[i + 1] - a_x[idx]
                ret[pos] = [
                    min(l, r),
                    [target[i],     l],
                    [target[i + 1], r]
                ]
                idx += 1
        while idx < len(a_x):
            dis = a_x[idx] - target[-1]
            ret[a_x[idx]] = [dis, [target[-1], dis]] # [pos, dis]
            idx += 1
        return ret
 
    nearest_s = check_pos(s, t, x)
    nearest_t = check_pos(t, s, x)
    print('hoge')
    return
 
    for q in x:
        ret = min(
                min([(pos_dis[1] + nearest_t[pos_dis[0]][0]) for pos_dis in nearest_s[q][1:]]),
                min([(pos_dis[1] + nearest_s[pos_dis[0]][0]) for pos_dis in nearest_t[q][1:]]))
        print(ret)
    return
 
 
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    s = [ int(next(tokens)) for _ in range(A) ]  # type: "List[int]"
    t = [ int(next(tokens)) for _ in range(B) ]  # type: "List[int]"
    x = [ int(next(tokens)) for _ in range(Q) ]  # type: "List[int]"
    solve(A, B, Q, s, t, x)
 
if __name__ == '__main__':
    main()
Problem p03142 (python)

Fixed submission:
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, A: "List[int]", B: "List[int]"):
    par = [[] for _ in range(N)]
    chi = [[] for _ in range(N)]
    root = None
    for i in range(N + M - 1):
        chi[A[i] - 1].append(B[i] - 1)
        par[B[i] - 1].append(A[i] - 1)

    #print(chi)
    #print(par)
    for i in range(N):
        if len(par[i]) < 1:
            root = i
            par[i].append(-1)
            break

    cur = {root}
    while len(cur) > 0:
        #print(cur)
        nex = set()
        for idx in cur:
            for c in chi[idx]:
                if len(par[c]) < 2:
                    nex.add(c)
                else:
                    par[c].remove(idx)
        cur = nex

    for i in range(N):
        ret = par[i][0]
        print(ret + 1)

    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int()] * (N-1+M)  # type: "List[int]" 
    B = [int()] * (N-1+M)  # type: "List[int]" 
    for i in range(N-1+M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, M, A, B)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, A: "List[int]", B: "List[int]"):
    par = [[] for _ in range(N)]
    chi = [[] for _ in range(N)]
    root = None
    for i in range(N + M - 1):
        chi[A[i] - 1].append(B[i] - 1)
        par[B[i] - 1].append(A[i] - 1)

    #print(chi)
    #print(par)
    for i in range(N):
        if len(par[i]) < 1:
            root = i
            par[i].append(-1)
            break

    depths = [0] * (N)
    def dfs(i, d):
        depths[i] = max(depths[i], d)
        for ch in chi[i]:
            dfs(ch, d + 1)
    dfs(root, 0)
    #print(depths)

    for i in range(N):
        if len(par[i]) > 1:
            for p in par[i]:
                if depths[p] == depths[i] - 1:
                    ret = p
        else:
            ret = par[i][0]
        print(ret + 1)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int()] * (N-1+M)  # type: "List[int]" 
    B = [int()] * (N-1+M)  # type: "List[int]" 
    for i in range(N-1+M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, M, A, B)

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

Fixed submission:
#!/usr/bin/env python3
import sys


def solve(N: int):
    ret = ''
    for i in range(N, 1000):
        s = str(i)
        if s[0] == s[1] and s[1] == s[2]:
            ret = s
            break
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def solve(N: int):
    for i in range(N, 999):
        s = str(i)
        if s[0] == s[1] == s[2]:
            ret = s
            break
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

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

Fixed submission:
#!/usr/bin/env python3
import sys


def solve(S: int, K: int):
    for i in range(K):
        c = S[i]
        if c != '1':
            print(c)
            return
    print(1)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = str(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(S, K)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def solve(S: int, K: int):
    HOGE = 5000000000000000
    for c in S:
        if K == 0:
            ret = 1
            break
        if c == '1':
            K -= 1
        else:
            ret = c
            break
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = str(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(S, K)

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

Fixed submission:
#!/usr/bin/env python3
import sys


def solve_(S: str, K: int, used):
    #print(S, K, used)
    mn = 'z'
    tmp = set()
    for i, c in enumerate(S):
        if c < mn and not c in used:
            tmp = set()
            for j in range(5):
                tmp.add(S[i:i + j + 1])
            mn = c
        elif c == mn:
            for j in range(5):
                tmp.add(S[i:i + j + 1])
    if len(tmp) < K:
        used.append(mn)
        return solve_(S, K - len(tmp), used)
    else:
        tmp = list(tmp)
        tmp.sort()
        return tmp[K - 1]

def solve(S, K):
    ret = solve_(S, K, [])
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    K = int(next(tokens))  # type: int
    solve(s, K)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def solve_(S: str, K: int):
    mn = 'z'
    tmp = set()
    for i, c in enumerate(S):
        if c < mn:
            tmp = set()
            for j in range(5):
                tmp.add(S[i:i + j + 1])
            mn = c
        elif c == mn:
            for j in range(5):
                tmp.add(S[i:i + j + 1])
    #print(tmp)
    if len(tmp) < K:
        s = ''
        for c in S:
            if c != mn:
                s += c
        return solve_(s, K - len(tmp))
    else:
        tmp = list(tmp)
        tmp.sort()
        return tmp[K - 1]

def solve(S, K):
    ret = solve_(S, K)
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    K = int(next(tokens))  # type: int
    solve(s, K)

if __name__ == '__main__':
    main()