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

Fixed submission:
n = int(input())
a = sorted([int(input()) for i in range(n)])

if n % 2 == 0:
    small = a[:(n//2)]
    big = a[(n//2):]
    ans = sum(big) * 2 - sum(small) * 2  - big[0] + small[-1]
    print(ans)

else:
    small = a[:(n//2)]
    big = a[(n//2):]
    ans = sum(big) * 2 - sum(small) * 2  - big[0] -big[1]

    small = a[:(n//2)+1]
    big = a[(n//2)+1:]
    ans = max(ans, sum(big) * 2 - sum(small) * 2 + small[-1] + small[-2])
    print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = sorted([int(input()) for i in range(n)])
l = n//2

if n % 2 == 0:
    small = a[:l]
    big = a[l:]
    ans = sum(big) * 2 - sum(small) * 2  - big[0] + small[-1]
    print(ans)

else:
    small = a[:l]
    big = a[l+1:]
    ans = sum(big) * 2 - sum(small) * 2 - min(n[l] - small[-1], big[0] - n[l])
    print(ans)
Problem p03241 (python)

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

count = 1
for i in range((m//n), 0, -1):
    if m % i == 0:
        count = i
        break

print(count)

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

count = 1
for i in range((m//n)+1, 1, -1):
    if m % i == 0:
        count = i
        break()

print(count)
Problem p03244 (python)

Fixed submission:
from collections import Counter

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

v1 = v[::2]
v2 = v[1::2]

cv1 = Counter(v1).most_common(2)
cv2 = Counter(v2).most_common(2)

if cv1[0][0] != cv2[0][0]:
    print(n - cv1[0][1] - cv2[0][1])
else:
    p1 = cv1[0][1] + cv2[1][1] if len(cv2) >= 2 else n - cv1[0][1]
    p2 = cv2[0][1] + cv1[1][1] if len(cv1) >= 2 else n - cv2[0][1]
    print(n - max(p1, p2))

Buggy submission (verdict: Runtime Error):
from collections import Counter

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

counted_v1 = Counter(v[::2])
counted_v2 = Counter(v[1::2])

most_v1 = counted_v1.most_common()[0]
most_v2 = counted_v2.most_common()[0]

if  most_v1[0] != most_v2[0]:
    print(n - most_v1[1] - most_v2[1])


elif len(counted_v1) == 1 and len(counted_v2) == 1:
    print(n // 2)

elif most_v1[1] > most_v2[1]:
    second_v2 = counted_v2.most_common()[1] if len(counter_v2) >= 2 else most_v2[1]
    print(n - most_v1[1] - second_v2[1])

else:
    second_v1 = counted_v1.most_common()[1] if len(counter_v1) >= 2 else most_v1[1]
    print(n - second_v1[1] - most_v2[1])
Problem p03294 (python)

Fixed submission:
from fractions import gcd

def lcm (x, y):
    return (x * y) // gcd(x, y)

N = int(input())
a = list(map(int, (input().split())))
l = (a[0] * a[1]) // gcd(a[0], a[1])

for i in a[2:]:
    l = lcm(l, i)

l -= 1

ans = sum(map(lambda x: l%x , a))
print(ans)

Buggy submission (verdict: Runtime Error):
def lcm (x, y):
    return (x * y) // gcd(x, y)

N = int(input())
a = list(map(int, (input().split())))
l = (a[0] * a[1]) // gcd(a[0], a[1])

for i in a[2:]:
    l = lcm(l, i)

l -= 1

ans = sum(map(lambda x: l%x , a))
print(ans)
Problem p03316 (python)

Fixed submission:
N = input()
digitsum_N = 0

for i in N:
  digitsum_N += int(i)
  
print("Yes" if int(N) % digitsum_N == 0 else "No")

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

for i in N:
  digitsum_N += int(i)
  
print("Yes" if N % digitsum_N == 0 else "No")
Problem p03379 (python)

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

sorted_X = sorted(X)
left = sorted_X[N // 2 - 1]
right = sorted_X[N // 2]

for x in X:
    if x <= left:
        print(right)
    else:
        print(left)

Buggy submission (verdict: Runtime Error):
sorted_X = sorted(X)
left, right = sorted_X[N // 2 - 1], sorted_X[N // 2]

for x in X:
    print(right if x <= left else left)
Problem p03425 (python)

Fixed submission:
N = int(input())
S = [input() for i in range(N)]
march = {"M":0, "A":0, "R":0, "C":0, "H":0}

for i in S:
    if i[0] in march:
        march[i[0]] += 1

ans = 0
for key1, value1 in march.items():
    for key2, value2 in march.items():
        for key3, value3 in march.items():
            if key1 < key2 < key3:
                ans += value1 * value2 * value3

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = [input() for i in range(N)]
march = {"M":0, "A":0, "R":0, "C":0, "H":0}

for i in S:
    if i[0] in march:
        march[i[0]] += 1

ans = 0
for first, second, third in combinations(march.values(), 3):
    ans += first * second * third

print(ans)
Problem p03435 (python)

Fixed submission:
c = [list(map(int, input().split())) for i in range(3)]

f = c[0][0]
s = c[0][1] - f
t = c[0][2] - f

for i in c:
    i_f = i[0]

    if i[1] != i_f + s or i[2] != i_f + t:
        print("No")
        exit()

print("Yes")

Buggy submission (verdict: Runtime Error):
x1, y1, x2, y2 = map(int, input().split())

def vector(x1, y1, x2, y2):
    return x2 - (y2 - y1), y2 + (x2 - x1)

x3, y3 = vector(x1, y1, x2, y2)
x4, y4 = vector(x2, y2, x3, y3)

print(x3, y3, x4, y4)
Problem p03447 (python)

Fixed submission:
x, a, b = [int(input()) for i in range(3)]

print((x - a) % b)

Buggy submission (verdict: Runtime Error):
a, b, c, x = [int(input()) for i in range(4)]
counter = 0

for rep1 in range(a + 1):
    for rep2 in range(b + 1):
        for rep3 in range(c + 1):
            if rep1 * 500 + rep2 * 100 + rep3 * 50 == x:
                counter += 1

print(counter)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0

for re1 in range(a +1):
    for re2 in range(b + 1):
        for re3 in range(c + 1):
            if re1*500 + re2*100 + re3*50 == x:
                ans += 1
Problem p03455 (python)

Fixed submission:
a, b = map(int, input().split())
print("Odd") if (a * b) % 2 == 1 else print("Even")

Buggy submission (verdict: Runtime Error):
n = int(input())
for i in range(n):
    t, x, y = map(int, input().split())

    if (t + x + y) % 2 == 1 or (x + y) > t:
        print("No")
        exit()

print("Yes")
Problem p03469 (python)

Fixed submission:
print(input().replace("2017", "2018"))

Buggy submission (verdict: Runtime Error):
n, y = map(int, input().split())
y = y/1000
answer= ""

for rep1 in range(n + 1):
    for rep2 in range(n + 1):
        for rep3 in range(n + 1):
            if rep1 + rep2 + rep3 == n and rep1 * 10 + rep2 * 5 + rep3 == y:
                answer = ("rep1 rep2 rep3")
                break

print(answer) if answer != "" else print("-1 -1 -1")

Buggy submission (verdict: Runtime Error):
n, y = map(int, input().split())
y = y/1000
counter = []

for rep1 in range(n + 1):
    for rep2 in range(n + 1):
        for rep3 in range(n + 1):
            if rep1 + rep2 + rep3 == n and rep1 * 10 + rep2 * 5 + rep3 == y:
                counter = ([rep1, rep2, rep3])
                break

print(counter) if counter != [] else print("-1 -1 -1")
Problem p03471 (python)

Fixed submission:
n, y = map(int, input().split())
y = y/1000
answer= []

for ten in range(n + 1):
    for five in range(n + 1 - ten):
        one = n - ten - five
        if ten * 10 + five * 5 + one == y:
            answer = [ten, five, one]
            break

print(answer[0], answer[1], answer[2]) if answer != [] else print("-1 -1 -1")

Buggy submission (verdict: Runtime Error):
n, y = map(int, input().split())
y = y/1000
answer= []

for rep1 in range(n + 1):
    for rep2 in range(n + 1):
        for rep3 in range(n + 1):
            if rep1 + rep2 + rep3 == n and rep1 * 10 + rep2 * 5 + rep3 == y:
                answer = ([rep1, rep2, rep3])
                break

print(counter) if counter != [] else print("-1 -1 -1")
Problem p03477 (python)

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

print("Left" if a+b > c+d else "Balanced" if a+b == c+d else "Right")

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

for i in range(1, n):
    str_i = str(i)
    sum_i = sum(map(int, str_i))
    if a <= sum_i <= b:
        counter += i

print(counter)

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

for i in range(1, n):
    str_i = str(i)
    sum_i = sum(map(int, str_i))
    if a <= sum_i <= b:
        counter += i

print(counter)
Problem p03493 (python)

Fixed submission:
print(str(input()).count("1"))

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

for i in range(n):

	a_joined = a_joined | a[i]

a_joined = a_joined & -(a_joined)
print(len(bin(a_joined)) - 3)

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

for i in range(n):

	a_joined = a_joined | a[i]

print(len(bin(a_joined)) - 3)

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

for i in range(n):

	a_joined = a_joined | a[i]

print(len(bin(a_joined)) - 3)
Problem p03568 (python)

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

odds = 1
for i in A:
    odds *= 1 if i % 2 == 1 else 2

print(3 ** N - odds)

Buggy submission (verdict: Runtime Error):
print(3 ** int(input()) - reduce(lambda x,y: x*y, (1 if i % 2 == 1 else 2 for i in map(int, input().split()

Buggy submission (verdict: Runtime Error):
print(3 ** int(input()) - reduce(mul, (1 if i % 2 == 1 else 2 for i in map(int, input().split()))))
Problem p03583 (python)

Fixed submission:
from itertools import product
N = int(input())

for h in range(1, 3501):
    for n in range(1, 3501):
        a = (4 * h * n - N * n - N * h)
        if a > 0 and (N * h * n) % a == 0:
            w = (N * h * n) / a
            int_w = int(w)
            if w == int_w:
                print(n,h,int_w)
                exit()

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

for x,y in product(range(1,3501), range(1,3501)):
    temp = (4/N) - (1/x) - (1/y)
    if temp > 0:
        z = 1/temp
        int_z = int(z)
        if int_z == z:
            print(x, y, int_z)
            exit()

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

for h, n in product(range(1, 3501), range(1, 3501)):
    a = (4 * h * n - N * n - N * h)
    if a != 0:
        w = (N * h * n) / a
        if w == int(w) and w > 1:
            print(n,h,int(w))
            exit()

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

for h, n in product(range(1, 3501), range(1, 3501)):
    a = (4 * h * n - N * n - N * h)
    if a != 0:
        w = (N * h * n) / a
        if w == w//1 and w > 1:
            print(n,h,w)
            exit()
Problem p03606 (python)

Fixed submission:
n = int(input())
ans = 0
for i in range(n):
    l, r = map(int, input().split())
    ans += r - l + 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = input()
ans = 0
for i in range(n):
    l, r = map(int, (input().split()))
    ans += r - l + 1
print(ans)
Problem p03625 (python)

Fixed submission:
from collections import *

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

filtered_a = sorted([i for i in Counter(a).most_common() if i[1] >= 2], reverse=True)

print(  0 if len(filtered_a) < 2
        else filtered_a[0][0] ** 2 if filtered_a[0][1] >= 4
        else filtered_a[0][0] * filtered_a[1][0])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
sorted_a = sorted([i[0]for i in Counter(a).most_common() if i[1] >= 2], reverse=True)
print(sorted_c_a[0] * sorted_c_a[1] if len(sorted_c_a) >= 2 else 0)
Problem p03636 (python)

Fixed submission:
s = input()
print(s[0] + str(len(s) - 2) + s[-1])

Buggy submission (verdict: Runtime Error):
s = input()
print(s[0] + str(len(s) - 2) + s[-1]))
Problem p03640 (python)

Fixed submission:
from functools import *

H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))

ans_list = ([[i+1] * a[i] for i in range(N)])
ans_list = reduce(lambda a, b: a + b, ans_list)

for i in range(H):
    ans = ans_list[i*W:i*W+W] if i%2 == 0 else ans_list[i*W+W-1:i*W-1:-1]
    print(*ans)

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

ans_list = ([[i+1] * a[i] for i in range(N)])
ans_list = reduce(lambda a, b: a + b, ans_list)

for i in range(H):
    print(ans_list[i*W:i*W+W] if i%2 == 0 else ans_list[i*W+W-1:i*W-1:-1])
Problem p03645 (python)

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

graph = [list() for i in range(n+1)]

for i in range(m):
    a, b = map(int, (input().split()))
    graph[a] += [b]
    graph[b] += [a]

for i in graph[1]:
    if n in graph[i]:
        print("POSSIBLE")
        exit()
        
print("IMPOSSIBLE")

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

graph = [list() for i in range(n+1)]

for i in range(m):
    a, b = map(int, (input().split()))
    graph[a] += [b]
    graph[b] += [a]

for i in graph[1]:
    if n in graph[i]:
        print("POSSIBLE")
        exit()
        
print(IMPOSSIBLE)
Problem p03651 (python)

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

from functools import reduce
from fractions import gcd

g = reduce(gcd, a)

print('POSSIBLE' if (k % g == 0) and (k <= max(a)) else 'IMPOSSIBLE')

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

from functools import reduce
from math import gcd

g = reduce(gcd, a)

print('POSSIBLE' if (k % g == 0) and (k <= sum(a)) else 'IMPOSSIBLE')
Problem p03695 (python)

Fixed submission:
n = int(input())

colors = [0] * 13
for i in list(map(int, input().split())):
    colors[i//400] += 1

ans = 8 - colors[:8].count(0)
free = sum(colors[8:])

print(max(1, ans), max(1, ans + free))

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

colors = [0] * 12
for i in list(map(int, input().split())):
    colors[i//400] += 1

ans = 8 - colors[:8].count(0)
free = sum(colors[8:])

print(max(1, ans), max(1, ans + free))
Problem p03761 (python)

Fixed submission:
from collections import *

n = int(input())
s_counted = Counter(input())

for i in range(n - 1):
    si_counted = Counter(input())
    for j in s_counted:
        if j in si_counted:
            s_counted[j] = min(s_counted[j], si_counted[j])

        else:
            s_counted[j] = 0

ans = ""
for i in sorted(s_counted.most_common()):
    ans += i[1] * i[0]

print(ans)

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

for i in range(n - 1):
    si_counted = Counter(input())
    for j in s_counted:
        if j in si_counted:
            s_counted[j] = min(s_counted[j], si_counted[j])

        else:
            s_counted[j] = 0

ans = ""
for i in sorted(s_counted.most_common()):
    ans += i[1] * i[0]

print(ans)
Problem p03994 (python)

Fixed submission:
s = [ord(i) - 97 for i in input()]
k = int(input())

for i in range(len(s)):
    diff = 26 - s[i]
    if (s[i] != 0) and (diff <= k):
        k -= diff
        s[i] = 0

s[-1] = (s[-1] + k) % 26

ans = "".join(chr(i+97) for i in s)
print(ans)

Buggy submission (verdict: Runtime Error):
s = [ord(i) - 97 for i in input()]
k = int(input())

for i in range(len(s)):
    if 26 - s[i] <= k:
        k -= 26 - s[i]
        s[i] = 0

s[-1] += k

ans = "".join(chr(i+97) for i in s)
print(ans)
Problem p04012 (python)

Fixed submission:
from collections import Counter

print("Yes" if all(i % 2 == 0 for i in Counter(input()).values()) else "No")

Buggy submission (verdict: Runtime Error):
print("Yes" if all(i % 2 == 0 for i in Counter(input()).values()) else "No")
Problem p02761 (python)

Fixed submission:

N, M = map(int, input().split())
S, C = [], []
for i in range(M):
    s, c = map(int, input().split())
    S.append(s)
    C.append(c)
F = False
for i in range(10**(N)):
    t = str(i)
    flag = True
    if len(t) != N:
        continue
    for j in range(M):
        if t[S[j]-1] != str(C[j]):
            flag = False
    if flag:
        print(i)
        F = True
        break
if not F:
    print(-1)

Buggy submission (verdict: Runtime Error):

N, M = map(int, input().split())
S, C = [], []
for i in range(M):
    s, c = map(int, input().split())
    S.append(s)
    C.append(c)

for i in range(10**(N-1), 10**(N)):
    t = str(i)
    flag = True
    for j in range(M):
        if t[S[j]-1] != str(C[j]):
            flag = False
    if flag:
        print(i)
        F = True
        break
if not F:
    print(-1)
Problem p02882 (python)

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


def solve(a: int, b: int, x: int):
    r = 1/2 * a**2 * b
    if x >= r:
        if a**2*b-x != 0:
            tan = a**3/(2*(a**2*b-x))
        else:
            print(0)
            return
    else:
        tan = (2*x)/(a*b**2)
    print(90-math.degrees(math.atan(tan)))
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    x = int(next(tokens))  # type: int
    solve(a, b, x)

if __name__ == '__main__':
    main()

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


def solve(a: int, b: int, x: int):
    r = 1/2 * a**2 * b
    if x >= r:
        tan = a**3/(2*(a**2*b-x))
    else:
        tan = (2*x)/(a*b**2)
    print(90-math.degrees(math.atan(tan)))
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    x = int(next(tokens))  # type: int
    solve(a, b, x)

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

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

print(max(0, A-2*B))

Buggy submission (verdict: Runtime Error):
A, B = map(int, input())

print(max(0, A-2*B))
Problem p02960 (python)

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

MOD = 1000000007  # type: int

def solve(S: str):
    N = len(S)
    dp = [[0 for _ in range(13)] for _ in range(len(S))]
    if S[N-1] != '?':
        dp[0][int(S[N-1])] = 1
    else:
        dp[0] = [1,1,1,1,1,1,1,1,1,1,0,0,0]
    ten = [1]
    for i in range(1, len(S)):
        ten.append(ten[-1] * 10 % 13)
        ii = len(S) - i - 1
        for j in range(13):
            if S[ii] == '?':
                for ll in range(10):
                    kk = ll * ten[i] % 13
                    dp[i][j] += dp[i-1][(13 + j - kk)%13]
                    dp[i][j] %= MOD
            else:
                x = int(S[ii])
                m = x * ten[i] % 13
                dp[i][j] = dp[i-1][(13+j-m)%13]
                dp[i][j] %= MOD
    print(dp[len(S)-1][5])
    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):
import sys

MOD = 1000000007  # type: int

def solve(S: str):
    N = len(S)
    dp = [[0 for _ in range(13)] for _ in range(len(S))]
    if S[N-1] != '?':
        dp[0][int(S[N-1])] = 1
    else:
        dp[0] = [1,1,1,1,1,1,1,1,1,1,0,0,0]
    for i in range(1, len(S)):
        ii = len(S) - i - 1
        for j in range(13):
            if S[ii] == '?':
                for ll in range(10):
                    kk = (ll * 10 ** i) % 13
                    dp[i][j] += dp[i-1][(13 + j - kk)%13]
                    dp[i][j] %= MOD
            else:
                x = int(S[ii])
                m = x * 10 ** i % 13
                dp[i][j] = dp[i-1][(13+k-m)%13]
                dp[i][j] %= MOD
    print(dp[len(S)-1][5])
    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
import numpy as np

MOD = 1000000007  # type: int

def solve(S: str):
    N = len(S)
    dp = np.zeros((N, 13))
    if S[N-1] != '?':
        dp[0, int(S[N-1])] = 1
    else:
        dp[0] = np.array([1,1,1,1,1,1,1,1,1,1,0,0,0])
    for i in range(1, len(S)):
        ii = N - i - 1
        for j in range(13):
            if S[ii] == '?':
                for ll in range(10):
                    kk = (ll * 10 ** i) % 13
                    dp[i, j] += dp[i-1, (13 + j - kk) % 13]
                    dp[i, j] %= MOD
            else:
                x = int(S[ii])
                m = x * 10 ** i % 13
                dp[i, j] = dp[i-1, (13+j-m)%13]
                dp[i, j] %= MOD
    print(int(dp[N-1, 5]))
    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()
Problem p03005 (python)

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

if (K == 1):
    print("0")
else:
    print(N-K)

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

if (K == 1):
    print("0")
else:
    print(N-K)