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

Fixed submission:
yen = int(input())
'''
happy= 0
while yen > 499:
  yen -= 500
  happy += 1000

while yen > 4:
  yen -=5
  happy += 5
'''
happy = 1000 * int(yen//500) + 5 * int((yen - (500 * int(yen//500)))//5)

print(happy)

Buggy submission (verdict: Runtime Error):
yen = int(input())
'''
happy= 0
while yen > 499:
  yen -= 500
  happy += 1000

while yen > 4:
  yen -=5
  happy += 5
'''
happy = 1000 * int(yen//500) + 5 * int((yen - (500 * int(yen//500)))//5)

print(hap)py)
Problem p02730 (python)

Fixed submission:
string = input()

def palindrome(inp):
  if inp == inp[::-1]: return True
  else: return False

if palindrome(string) and palindrome(string[:int((len(string) -1)/2)]) and palindrome(string[int((len(string) +1)/2):]): print("Yes")
else: print("No")

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

def palindrome(inp):
  if inp == inp[::-1]: return True
  else: return False
  
if palindrome(string) and palindrome(string[:int((len(string) + 1)/2)] and palindrome(string[int((len(string) +3)/2):]: print("Yes")
else: print("No")
Problem p02848 (python)

Fixed submission:
n = int(input())

def push(chara, dig):
  if ord(chara) + dig > 90: return chr(64 + dig + ord(chara) -90)
  else: return chr(dig + ord(chara))
  
string = input()
e = ""
for i in range(0, len(string)):
  e = e + push(string[i], n)
  
print(e)

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

def push(chara, dig):
  if ord(chara) + dig > 90: return chr(64 + dig + ord(chara) -90)
  else: return chr(dig + ord(chara))
  
string = input()

for i in range(0, len(string)):
  string[i] = push(string[i], n)
  
print(string)
Problem p02952 (python)

Fixed submission:
a = int(input())
ans = 0
for i in range(1, a + 1):
  if len(str(i)) % 2 ==1: ans+=1   
print(ans)

Buggy submission (verdict: Runtime Error):
a = int(input())
for i in range(1, a + 1):
  if len(str(i)) % 2 ==1: ans+=1   
print(ans)
Problem p02993 (python)

Fixed submission:
passw = input()
if passw[0] == passw[1] or passw[1] == passw[2] or passw[2] == passw[3]: print("Bad")
else: print("Good")

Buggy submission (verdict: Runtime Error):
pass = input()
if pass[0] == pass[1] or pass[1] == pass[2] or pass[2] == pass[3]: print("Bad")
else: print("Good")
Problem p04019 (python)

Fixed submission:
string = input()

c1 = True
c2 = True
c3 = True

if ("W" in string and not("E" in string)) or "E" in string and not("W" in string): c1 = False
    
if ("N" in string and not("S" in string)) or "S" in string and not("N" in string): c2 = False

if "N" in string and "S" in string and "E" in string and "W" in string:
    N = string.count("N")
    S = string.count("S")
    W = string.count("W")
    E = string.count("E")
    if not(N/S == W/E or N/S == E/W): c3 = False
    
if c1 and c2 and c3: print("Yes")
else: print("No")

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

c1 = True
c2 = True
c3 = True

if ("W" in string and not("E" in string) or "E" in string and not("W" in string): c1 = False
    
if ("N" in string and not("S" in string) or "S" in string and not("N" in string): c2 = False

if "N" in string and "S" in string and "E" in string and "W" in string:
    N = string.count("N")
    S = string.count("S")
    W = string.count("W")
    E = string.count("E")
    if not(N/S == W/E or N/S == E/W): c3 = False
    
if c1 and c2 and c3: print("Yes")
else: print("No")
Problem p02602 (python)

Fixed submission:
from copy import deepcopy
import numpy as np


nk = input().split()
n = int(nk[0])
k = int(nk[1])
ajs = input().split()
ajs = np.log([int(aj) for aj in ajs])
ajs = ajs / ajs.max()

ak_current = ajs[:k].cumsum()[-1]

for i in range(k, n):
  ak_tmp = deepcopy(ak_current)

  ak_tmp =  ak_tmp - (ajs[i-k]) + (ajs[i])
  
  if ak_tmp > ak_current:
    print('Yes')
  else:
    print('No')
    
  ak_current = ak_tmp

Buggy submission (verdict: Runtime Error):
from copy import deepcopy

nk = input().split()
n = int(nk[0])
k = int(nk[1])
ajs = input().split()
ajs = np.array([int(aj) for aj in ajs])

ak_current = ajs[:k].cumprod()[-1]

for i in range(k, n):
  ak_tmp = deepcopy(ak_current)
  ak_tmp = ak_tmp * ajs[i] / ajs[i-k]
  
  if ak_tmp > ak_current:
    print('Yes')
  else:
    print('No')
    
  ak_current = ak_tmp
Problem p02609 (python)

Fixed submission:
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())
    X_bin = readline().strip()
    n = X_bin.count("1")
    X = int(X_bin, 2)

    X_pop_p = X % (n + 1)
    if n != 1:
        X_pop_m = X % (n - 1)

    
    def count(x):
        cnt = 1
        while x:
            x %= bin(x).count("1")
            cnt += 1
        return cnt
        
    ans = []
    for i in range(N):
        X_i = X ^ (1 << i)
        if X_i == 0:
            ans.append(0)
        else:
            if X_bin[-(i+1)] == "1":
                mod = (X_pop_m - pow(2, i, n - 1)) % (n - 1)
                ans.append(count(mod))
            else:
                mod = (X_pop_p + pow(2, i, n + 1)) % (n + 1)
                ans.append(count(mod))

    print("\n".join(map(str, ans[::-1])))


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())
    X_bin = readline().strip()
    n = X_bin.count("1")
    X = int(X_bin, 2)

    X_pop_p = X % (n + 1)
    X_pop_m = X % (n - 1)
    
    def count(x):
        cnt = 1
        while x:
            x %= bin(x).count("1")
            cnt += 1
        return cnt
        
    ans = []
    for i in range(N):
        X_i = X ^ (1 << i)
        if X_i == 0:
            ans.append(0)
        else:
            if X_bin[-(i+1)] == "1":
                mod = (X_pop_m - pow(2, i, n - 1)) % (n - 1)
                ans.append(count(mod))
            else:
                mod = (X_pop_p + pow(2, i, n + 1)) % (n + 1)
                ans.append(count(mod))

    print("\n".join(map(str, ans[::-1])))


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

Fixed submission:
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

MOD = 10**9+7

fac = [1, 1]     # 元テーブル
f_inv = [1, 1]   # 逆元テーブル
inv = [0, 1]     # 逆元テーブル計算用テーブル

def prepare(n, mod):
    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inv.append((-inv[mod % i] * (mod//i)) % mod)
        f_inv.append((f_inv[-1] * inv[-1]) % mod)

def modcmb(n, r, mod):
    if n < 0 or r < 0:
        return 0
    if r > n:
        return 0

    return fac[n] * f_inv[r] * f_inv[n-r] % mod


def main():
    K = int(readline())
    S = readline().strip()
    N = len(S)

    prepare(N + K + 10, MOD)

    ans = 0
    for i in range(K+1):
        ans += modcmb(N-1+i, i, MOD) * pow(25, i, MOD) * pow(26, K-i, MOD) % MOD
        ans %= MOD

    print(ans)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

MOD = 10**9+7

fac = [1] * (2 * 10**6 + 10)
f_inv = [1] * (2 * 10**6 + 10)

def prepare(n, mod):
    for i in range(1, n+1):
        fac[i] = (fac[i-1] * i) % mod
    
    f_inv[n] = pow(fac[n], -1, MOD)
    for i in range(n-1, 0, -1):
        f_inv[i] = (f_inv[i+1] * (i+1)) % MOD

def modcmb(n, r, mod):
    if n < 0 or r < 0:
        return 0
    if r > n:
        return 0

    return fac[n] * f_inv[r] * f_inv[n-r] % mod


def main():
    K = int(readline())
    S = readline().strip()
    N = len(S)

    prepare(N + K + 10, MOD)

    inv26 = pow(26, -1, MOD)
    pow26 = pow(26, K, MOD)
    pow25 = 1
    ans = 0
    for i in range(K+1):
        ans += (modcmb(N-1+i, i, MOD) * pow25 * pow26) % MOD
        ans %= MOD

        pow25 *= 25
        pow25 %= MOD
        pow26 *= inv26
        pow26 %= MOD

    print(ans)


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

Fixed submission:
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    s = readline().strip()
    t = readline().strip()

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


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import time

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

if (N != M) and (M == 1) and (K == 1):
  time.sleep(0.2)
Problem p02692 (python)

Fixed submission:
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    n,A,B,C = map(int, readline().split())
    N = A + B + C
    S = [readline().strip() for _ in range(n)]

    ans = []
    possible = True
    for i, s in enumerate(S):
        if s == "AB":
            if A + B == 0:
                print("No")
                possible = False
                break
            
            if i < n - 1 and N == 2 and A == B == 1:
                if S[i+1] == "AC":
                    A += 1
                    B -= 1
                    ans.append("A")
                elif S[i+1] == "BC":
                    A -= 1
                    B += 1
                    ans.append("B")
                else:
                    A += 1
                    B -= 1
                    ans.append("A")
            else:
                if A < B:
                    A += 1
                    B -= 1
                    ans.append("A")
                else:
                    A -= 1
                    B += 1
                    ans.append("B")

        elif s == "AC":
            if A + C == 0:
                print("No")
                possible = False
                break
            
            if i < n - 1 and N == 2 and A == C == 1:
                if S[i+1] == "AB":
                    A += 1
                    C -= 1
                    ans.append("A")
                elif S[i+1] == "BC":
                    A -= 1
                    C += 1
                    ans.append("C")
                else:
                    A += 1
                    C -= 1
                    ans.append("A")
            else:
                if A < C:
                    A += 1
                    C -= 1
                    ans.append("A")
                else:
                    A -= 1
                    C += 1
                    ans.append("C")

        else:
            if B + C == 0:
                print("No")
                possible = False
                break
            
            if i < n - 1 and N == 2 and B == C == 1:
                if S[i+1] == "AB":
                    B += 1
                    C -= 1
                    ans.append("B")
                elif S[i+1] == "AC":
                    B -= 1
                    C += 1
                    ans.append("C")
                else:
                    B += 1
                    C -= 1
                    ans.append("B")
            else:
                if B < C:
                    B += 1
                    C -= 1
                    ans.append("B")
                else:
                    B -= 1
                    C += 1
                    ans.append("C")

    if possible:
        print("Yes")
        print("\n".join(ans))


if __name__ == "__main__":
    main()

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

if n == 2:
  print("No)
Problem p02742 (python)

Fixed submission:
from math import ceil
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    h,w = map(int, readline().split())

    if h == 1 or w == 1:
        print(1)
        exit()

    print(ceil(h/2)*ceil(w/2) + (h//2) * (w //2) )



if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    K = int(readline())

    print(A[K-1])



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

Fixed submission:
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,M = map(int, readline().split())

    if N == 1 and M == 0:
        print(0)
        exit()

    ans = [None]*N
    for i in range(M):
        s, c = map(int, readline().split())
        if ans[s-1] is None:
            ans[s-1] = c
        elif c == ans[s-1]:
            continue        
        else:
            print(-1)
            exit()
    
    if ans[0] is None:
        ans[0] = 1
    
    for i in range(1,N):
        if ans[i] is None:
            ans[i] = 0

    if N >= 2 and ans[0] == 0:
        print(-1)
        exit()

    print("".join(map(str,ans)))

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,M = map(int, readline().split())

    ans = [None]*N
    for i in range(M):
        s, c = map(int, readline().split())
        if ans[s-1] is None:
            ans[s-1] = c
        elif c == ans[s-1]:
            continue        
        else:
            print(-1)
            exit()
    
    if ans[0] is None:
        ans[0] = 1
    if ans[1] is None:
        ans[1] = 0
    if ans[2] is None:
        ans[2] = 0

    if N >= 2 and ans[0] == 0:
        print(-1)
        exit()

    print("".join(map(str,ans)))

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

Fixed submission:
import numpy as np
import sys
input = sys.stdin.readline


def main():
    N,K = map(int, input().split())
    A = np.array(sorted([int(i) for i in input().split()]))

    negative = A[A < 0]
    positive = A[A > 0]
    ln = len(negative)
    lp = len(positive)
    zero = np.count_nonzero(A == 0)

    def count(x):
        count = 0
        if x >= 0:
            count += N * zero
        count += np.searchsorted(A, x // positive, side='right').sum()
        count += N * ln - np.searchsorted(A, -(-x // negative), side='left').sum()
        count -= np.count_nonzero(A * A <= x)
        count //= 2

        return count


    left = -(10**18)
    right = 10**18
    while right - left > 1:
        x = (left + right) // 2
        if count(x) < K:
            left = x
        else:
            right = x

    print(right)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import numpy as np
import sys
input = sys.stdin.readline


def main():
    N,K = map(int, input().split())
    A = np.array(sorted([int(i) for i in input().split()]))

    zero_left = np.searchsorted(A, 0, side='left')
    zero_right = np.searchsorted(A, 0, side='right')

    negative = zero_left
    positive = N - zero_right
    zero = zero_right - zero_left
    non_posi = negative * positive + zero * (N - zero) + zero * (zero - 1) // 2

    if K <= negative * positive:
        Nega = A[:zero_left]
        Posi = A[zero_right:]

        left = -(A[0]**2)
        right = 0
        while right - left > 1:
            x = (left + right) // 2
            count = np.searchsorted(Nega, x // Posi, side='right').sum()

            if count < K:
                left = x
            else:
                right = x

        print(right)

    elif K <= non_posi:
        print(0)

    else:
        Nega = np.sort(np.abs(A[:zero_left]))
        Posi = A[zero_right:]

        left = 0
        right = Posi[-1]**2
        while right - left > 1:
            x = (left + right) // 2
            A = np.searchsorted(Nega, x // Nega, side='right')
            B = np.searchsorted(Posi, x // Posi, side='right')
            count = 0
            count += A.sum()
            count += B.sum()
            count -= np.int_(np.where(A >= np.arange(1,negative+1), True, False)).sum()
            count -= np.int_(np.where(B >= np.arange(1,positive+1), True, False)).sum()
            count //= 2

            if count + non_posi < K:
                left = x
            else:
                right = x

        print(right)


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

Fixed submission:
from collections import deque
def main():
    N = int(input())
    # 辺の集合を隣接リストとして入力
    E = [[] for i in range(N+1)]
    edge_order = []
    for i in range(N-1):
        a,b = map(int, input().split())
        E[a].append(b)
        edge_order.append(b)
    
    # 頂点1から幅優先探索
    queue = deque([1])
    color = [0] * (N+1) 
    while queue:
        V = queue.popleft()
        c = 1
        for i in E[V]:
            if i < V:
                continue
            if c == color[V]:
                c += 1
            color[i] = c
            c += 1
            queue.append(i)

    print(max(color))
    for i in edge_order:
        print(color[i])


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque
read = sys.stdin.read

def main():
    N, *ab = map(int, read().split())
    E = [[] for _ in range(N + 1)]
    
    for a, b in zip(*[iter(ab)] * 2):
        E[a].append(b)
        edge_order.append(b)
    
    # 頂点1から幅優先探索
    queue = deque([1])
    color = [0] * (N+1) 
    while queue:
        V = queue.popleft()
        c = 1
        for i in E[V]:
            if c == color[V]:
                c += 1
            color[i] = c
            c += 1
            queue.append(i)

    print(max(color))
    for i in edge_order:
        print(color[i])


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

Fixed submission:
from math import atan, degrees

def main():
    a,b,x = map(int, input().split())
    if x == a**2 * b:
        print(0.0)
        exit()

    t = atan(a**3 / (2 * a**2 * b - 2 * x))
    s = atan(2 * x / (a * b**2))

    if x >= a**2 * b / 2:
        print(90.0 - degrees(t))
    else:
        print(90.0 - degrees(s))


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from math import atan, degrees

def main():
    a,b,x = map(int, input().split())

    t = atan(a**3 / (2 * a**2 * b - 2 * x))
    s = atan(2 * x / (a * b**2))

    if x >= a**2 * b / 2:
        print(90.0 - degrees(t))
    else:
        print(90.0 - degrees(s))


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

Fixed submission:
import math
from fractions import gcd

def era(ps, n):
    if len(ps) == 1:
        return 1
    search_list = ps[1:]
    for i in range(1, n+1):
        search_list = [num for num in search_list if num % i != 0 or num == i ]

    return len(search_list)+1

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

def make_divisors(n):
    divisors = []
    for i in range(1, int(math.sqrt(n))+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def main():
    a,b = map(int, input().split())

    g = gcd(a, b)
    div = make_divisors(g)
    #print(div)

    ans = 1
    for n in div:
        if is_prime(n):
            ans += 1

    print(ans)



if __name__ == "__main__":
    main()

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

def era(n):
    if n == 1:
        return []
    prime_list = []
    # 2からnumberまでの数字をsearch_listに入れる
    search_list = list(range(2,n+1))
    while True:
      # search_listの先頭の値が√nの値を超えたら処理終了
        if search_list[0] > math.sqrt(n):
            # prime_listにsearch_listを結合
            prime_list.extend(search_list)
            break
        else:
            # search_listの先頭をprime_listに入れる
            head_num = search_list[0]
            prime_list.append(head_num)
            # search_listの先頭をpopする
            search_list.pop(0)
            # head_numの倍数を取り除く
            search_list = [num for num in search_list if num % head_num != 0]

    return prime_list

def main():
    a,b = map(int, input().split())

    g = gcd(a, b)
    p_nums = era(g)

    ans = 1
    if len(p_nums) >= 1:
        for p in p_nums:
            if g % p == 0:
                ans += 1

    print(ans)


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

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

ans = 0

for i in range(3):
    if s[i] == t[i]:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
n = 45

x = [None] * N
y = [None] * N
for i in range(N):
    x[i], y[i] = map(int, input().split())

ans = 0
for i in range(n):
    theta = (2 * math.pi / n) * i
    c = math.cos(theta)
    s = math.sin(theta)
    tmp_x = 0
    tmp_y = 0
    for j in range(N):
        if x[j] * c + y[j] * s > 0:
            tmp_x += x[j]
            tmp_y += y[j]
    if tmp_x**2 + tmp_y**2 > ans**2:
        ans = math.sqrt(tmp_x**2 + tmp_y**2)

print(ans)
Problem p02952 (python)

Fixed submission:
N = int(input())

n = len(str(N))
if n == 1:
    print(N)
else:
    if n % 2 == 0:
        s = "90" * (n//2)
        print(s[:-1])
        
    else:
        s = "90" * ((n-1) // 2)
        ans = int(s[:-1]) + N - 10**(n-1) + 1
        print(ans)

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

n = len(str(N))
if n % 2 == 0:
    s = "90" * (n//2)
    print(s[:-1])
    
else:
    s = "90" * ((n-1) // 2)
    ans = int(s[:-1]) + N - 10**(n-1) + 1
    print(ans)
Problem p02975 (python)

Fixed submission:
from collections import Counter
N = int(input())
a = [int(i) for i in input().split()]

c = Counter(a)

if c[0] == N:
    print("Yes")
    exit()

if N % 3 == 0 and c[0] == N // 3 and len(c.values()) == 2:
    print("Yes")
    exit()

n =  N // 3
k = list(c.keys())
v = list(c.values())

if N % 3 == 0 and v == [n, n, n] and k[0]^k[1]^k[2] == 0:
    print("Yes")
    exit()

print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [int(i) for i in input().split()]

a.sort()
for i in range(N-1):
    if a[i-1] ^ a[i+1] == a[i]:
        continue
    else:
        print("No")
        exit()

if a[N-2] ^ a[0] != a[N-1]:
    print("No")
    exit()

print("Yes" if flag else "No")

Buggy submission (verdict: Runtime Error):
N = int(input())
a = [int(i) for i in input().split()]

a.sort()
for i in range(N-1):
    if a[i-1] ^ a[i+1] == a[i]:
        continue
    else:
        print("No")
        exit()

if a[N-2] ^ a[0] != a[N-1]:
    print("No")
        exit()

print("Yes" if flag else "No")
Problem p03037 (python)

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

L=[]
R=[]

for i in range(M):
    a,b=map(int, input().split())
    L.append(a)
    R.append(b)

ans=min(R)-max(L)+1
print("0" if ans<0 else ans)

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

L=[]
R=[]

for i in range(M):
    a,b=map(int, input().split())
    L.append(a)
    R.append(b)


ans=max(R)-max(L)+1
if ans<0:
  print(0)
else:
  prnit(ans)

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

s=[[] for i in range(M)]

for i in range(M):
    L,R=map(int, input().split())
    for j in range(L,R+1):
        s[i].append(j)

for i in range(M-1):
    s=set(s[i]) & set(s[i+1])

print(len(s))