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

Fixed submission:
A = list(map(int,input().split()))
B = (A[0]+A[1])/2
if B > int(B):
  print(int(B)+1)
else:
  print(int(B))

Buggy submission (verdict: Runtime Error):
A = list(map(int,input().split))
B = (A[0]+A[1])/2
if B >= int(B):
  print(int(B)+1)
else:
  print(int(B))

Buggy submission (verdict: Runtime Error):
A = list(map(int,input().split))
B = (A[0]+A[1])/2
if B >= int(B):
  print(int(B)+1)
else:
  print(B)

Buggy submission (verdict: Runtime Error):
A = list(map(int,input().split))
B = (A[0]+A[1])/2
if B <= int(B):
  print(int(B)+1)
else:
  print(B)
Problem p03493 (python)

Fixed submission:
A = input()
s = 0
for i in range(len(A)):
  if A[i]=="1":
    s = s + 1
print(s)

Buggy submission (verdict: Runtime Error):
A = input()
s = 0
for i in range(1,3):
  if A[i]="1":
    s = s + 1
print(s)

Buggy submission (verdict: Runtime Error):
A = input()
s = 0
for i in range(0,3):
  if A[i]="1":
    s = s + 1
print(s)

Buggy submission (verdict: Runtime Error):
A = input()
s = 0
for i in range(0,2):
  if A[i]="1":
    s = s + 1
print(s)

Buggy submission (verdict: Runtime Error):
A = int(input())
s = 0
for i in range(0,2):
  if A[i]==1:
    s = s +1
print(s)

Buggy submission (verdict: Runtime Error):
N = input()
s = 0
for i in range(0,2):
  if N[i] = 1:
    s = s + 1
print(s)

Buggy submission (verdict: Runtime Error):
N = int(input())
s = 0
for i in range(0,2):
if N[i] = 1:
    s = s + 1
print(s)

Buggy submission (verdict: Runtime Error):
N = int(input())
s = 0
for i in range(0,2):
  if N[i] = 1:
    s = s + 1
print(s)

Buggy submission (verdict: Runtime Error):
N = str(input())
s = 0
for i in range(0,2):
  if N[i] = 1:
    s = s + 1
print(s)
Problem p03606 (python)

Fixed submission:
N = int(input())
M = [list(map(int,input().split()))for _ in range(N)]
sum = 0
for i in range(N):
  sum = sum + M[i][1]-M[i][0]+1
print(sum)

Buggy submission (verdict: Runtime Error):
N = int(input())
M = list(map(int,input().split()))for _ in range(N)
sum = o
for i in range(N):
  sum = sum + M[i][1]-M[i][0]+1
print(sum)
Problem p03636 (python)

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

Buggy submission (verdict: Runtime Error):
S = input()
print(S[0]+ len(S) + S[-1])

Buggy submission (verdict: Runtime Error):
S = int()
print(S[0]+ len(S) + S[-1])

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

Fixed submission:
a,b,c = map(str,input().split())
print(a[0]+b[0]+c[0])

Buggy submission (verdict: Runtime Error):
S=input()
print("A"+s[0]+"C")
Problem p02732 (python)

Fixed submission:
import collections
N = int(input())
A_list = list(map(int, input().split()))
A_collection=collections.Counter(A_list)
total=0
for i in A_collection.values():
    total+=i*(i-1)//2
for k in A_list:
    print(total-(A_collection[k]-1))

Buggy submission (verdict: Runtime Error):
# %%time
import numpy as np
# N = 200000
# A_npa = np.arange(N, dtype=np.int32)
N = int(input())
A_npa = np.array(list(map(int, input().split())))
total = 0
A_unique, inverse, counts = np.unique(
    A_npa, return_inverse=True, return_counts=True)
counts = np.sum(counts*(counts-1)//2)-(counts-1)
for i in inverse:
    print(counts[i])
Problem p02995 (python)

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


def func(x,y):
    if(x<0):
        assert()
    if(y<=0):
        assert()
    # print(x,y,int(x/y))
    # return int((x/y))
    # print(x,y,x//y)
    return int((x//y))

# print(func(100,10))


lcm = int((C * D) / int(fractions.gcd(C, D)))
print(int( B - func(B, C) - func(B, D) + func(B, lcm) - A + 1 + func(A-1, C) + func(A-1, D) - func(A-1, lcm)))

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


#     {x | A <= x <= B and x % C != 0 and x % D != 0}
# =             {x | 1 <= x <= B and x % C != 0 and x % D != 0}
#           -   {x | 1 <= x <= A-1 and x % C != 0 and x % D != 0}
# =   {x | 1 <= x <= B} - {x | 1 <= x <= B and x % C = 0} - {x | 1 <= x <= B and x % D = 0} + - {x | 1 <= x <= B and x % C = 0 and x % D = 0}
#     (略)

def func(x,y):
    # print(x,y,math.floor((x/y)))
    return math.floor((x/y))

# print(func(100,10))

lcm = C * D /math.gcd(C, D)
print( (B - (func(B, C) + func(B, D) - func(B, lcm))) -
       (A-1 - (func(A-1, C) + func(A-1, D) - func(A-1, lcm))) )
Problem p03854 (python)

Fixed submission:
S = input()
S = S[::-1]
# print(S)
# print(len(S))


# t_sub = ["dreamer", "dream", "eraser", "erase"]
t_sub = ["remaerd", "maerd", "resare", "esare"]

def func():
    i = 0
    while True:
        flag = False
        for t in t_sub:
            ret = (S.find(t, i) == i)
            # print(S,".find(",t,", ",i,") == ",i, "ret=", ret)
            if ret ==True:
                if (i+len(t) == len(S)):
                    return "YES"
                else:
                    i += len(t)
                    flag = True
                    break
        if flag != True:
            return "NO"

print(func())

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

# print(S)
# print(len(S))


t_sub = ["dreamer", "dream", "eraser", "erase"]
i = 0


def check_1(S, i, t_sub):
    # print("check_1(",S,", ",i,")")
    for t in t_sub:
        # print("check ",t)
        if (S.find(t, i) == i):
            # print("hit " ,t,"at ",i)
            if (i+len(t) == len(S)):
                return "YES"
            else:
                if(check_1(S, i + len(t), t_sub) == "YES"):
                    return "YES"

    # print("cant find ",i )                
    return "NO"


print(check_1(S, i, t_sub))
Problem p02683 (python)

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

def main():
    N, M, X = map(int, input().split())
    mat = [list(map(int, input().split())) for _ in range(N)]

    flag = False
    ans = 10 ** 18

    for i in range(1<<N):
        tmp = [0] * (M+1)
        mflag = True
        for j in range(N):
            if (i>>j)&1:
                tmp = [x+y for x, y in zip(tmp, mat[j])]
        for k in range(M):
            if tmp[1+k] < X:
                mflag = False
                break
        if mflag and tmp[0] < ans:
            ans = tmp[0]
            flag = True
    print(ans) if flag else print('-1')

if __name__ == '__main__':
    main()

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

def main():
    N, M, X = map(int, input().split())
    mat = [list(map(int, input().split())) for _ in range(N)]

    ans = 12 * (10 ** 5) +1
    for i in range(1<<N):
        tmp = [0] * (M+1)
        for j in range(N):
            if (i>>j)&1:
                tmp = [x+y for x, y in zip(tmp, mat[j])]
        if all(tmp[i] >= X for i in range(1, M):
                ans = min(ans, tmp[0])

    print('-1') if ans == 12 * (10 ** 5) +1 else print(ans)
            
if __name__ == '__main__':
    main()
Problem p02717 (python)

Fixed submission:
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
#from fractions import gcd
from math import ceil, floor
import bisect
sys.setrecursionlimit(10 ** 6)
inf = float("inf")

def input():
    return sys.stdin.readline()[:-1]

def main():
    x, y, z = map(int, input().split())
    print(z, x, y) 


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
#from fractions import gcd
from math import gcd
from math import ceil, floor
import bisect
sys.setrecursionlimit(10 ** 6)
inf = float("inf")

def input():
    return sys.stdin.readline()[:-1]

def main():
    x, y, z = map(int, input().split())
    print(z, x, y) 


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

Fixed submission:
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
#from fractions import gcd
from math import ceil, floor
import bisect
sys.setrecursionlimit(10 ** 6)
inf = float("inf")

def input():
    return sys.stdin.readline()[:-1]

def main():
    n, m = map(int, input().split())
    A = tuple(map(int, input().split()))
    ans = 0
    total = sum(A)
    for a in A:
        if a >= total/(4*m):
            ans += 1
    print("Yes") if ans >= m else print("No")

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
#from fractions import gcd
from math import gcd
from math import ceil, floor
import bisect
sys.setrecursionlimit(10 ** 6)
inf = float("inf")

def input():
    return sys.stdin.readline()[:-1]

def main():
    n, m = map(int, input().split())
    A = tuple(map(int, input().split()))
    ans = 0
    total = sum(A)
    for a in A:
        if a >= total/(4*m):
            ans += 1
    print("Yes") if ans >= m else print("No")

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

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

def main():
    N, M = map(int, input().split())
    # [AC, WA]
    cnt = [[0, 0] for _ in range(N)]
    for _ in range(M):
        num, status = input().split()
        num = int(num) -1
        if status == "AC":
            if cnt[num][0] == 0:
                cnt[num][0] += 1
        if status == "WA":
            if cnt[num][0] == 0:
                cnt[num][1] += 1

    ac_cnt, wa_cnt = 0, 0
    for i in range(N):
        if cnt[i][0] == 1:
            ac_cnt += cnt[i][0]
            wa_cnt += cnt[i][1]

    print(ac_cnt, wa_cnt, sep=" ")

if __name__ == '__main__':
    main()

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

def main():
    N, M = map(int, input().split())
    # [AC, WA]
    cnt = [[0, 0] for _ in range(2)]
    for _ in range(M):
        num, status = input().split()
        num = int(num) -1
        if status == "AC":
            if cnt[num][0] == 0:
                cnt[num][0] += 1
        if status == "WA":
            if cnt[num][0] == 0:
                cnt[num][1] += 1

    ac_cnt, wa_cnt = 0, 0
    for i in range(N):
        ac_cnt += cnt[i][0]
        wa_cnt += cnt[i][1]

    print(ac_cnt, wa_cnt, sep=" ")

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

Fixed submission:
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10 ** 6)

def input():
    return sys.stdin.readline()[:-1]

def main():
    n = int(input())
    p = tuple(map(int, input().split()))
    q = tuple(map(int, input().split()))
    l = permutations(list(range(1, n+1)))
    if p == q:
        print(0)
    else:
        for idx, item in enumerate(l):
            if item == p:
                idp = idx
            elif item == q:
                idq = idx
        print(abs(idp - idq))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
from math import ceil, floor, gcd
sys.setrecursionlimit(10 ** 6)

def input():
    return sys.stdin.readline()[:-1]

def main():
    n = int(input())
    p = tuple(map(int, input().split()))
    q = tuple(map(int, input().split()))
    l = permutations(list(range(1, n+1)))
    if p == q:
        print(0)
    else:
        for idx, item in enumerate(l):
            if item == p:
                idp = idx
            elif item == q:
                idq = idx
        print(abs(idp - idq))

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
from math import ceil, floor, gcd
sys.setrecursionlimit(10 ** 6)

def input():
    return sys.stdin.readline()[:-1]

def main():
    n = int(input())
    p = tuple(map(int, input().split()))
    q = tuple(map(int, input().split()))
    l = permutations(list(range(1, n+1)))
    if p == q:
        print(0)
        exit()
    for idx, item in enumerate(l):
        if item == p:
            idp = idx
        elif item == q:
            idq = idx
    print(abs(idp - idq))

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

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

def main(N, H):
    ans = 'Yes'

    min_val = H[0] -1
    for i in range(1, N):
        if min_val <= H[i] -1:
            min_val = H[i] -1
        elif min_val <= H[i]:
            min_val = H[i]
        else:
            ans = 'No'
            break
    return ans

if __name__ == '__main__':
    N = int(input())
    H = list(map(int, input().split()))
    print(main(N, H))

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

def main(N, H):
    ans = 'Yes'

    min_val = H[0] -1
    for i in range(1, N):
        if min_val <= H[i] -1:
            min_val = H[i] -1
        elif min_val <= H[i]:
            min_val = h[i]
        else:
            ans = 'No'
            break
    return ans

if __name__ == '__main__':
    N = int(input())
    H = list(map(int, input().split()))
    print(main(N, H))
Problem p02957 (python)

Fixed submission:
#!/usr/bin/env python
def main():
    A, B = list(map(int, input().split()))
    tmp = B
    if A > B:
        B = A
        A = tmp
    
    tmp = (B - A) / 2 + A
    if round(tmp) == tmp:
        return int(tmp)
    else:
        return 'IMPOSSIBLE'

if __name__ == '__main__':
    print(main())

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
import numpy as np

def main():
    S = input()
    
    lenS = len(S)
    N = 13
    DP = np.zeros(N, dtype=np.int64)
    DP[0] = 1
    
    mod = 10 ** 9 + 7
    mul = 1
    for i in reversed(range(lenS)):
        nextDP = np.zeros(N, dtype=np.int64)
        c = S[i]
        if c == '?':
            for k in range(10):
                for j in range(N):
                    nextDP[(k * mul + j) %N] += DP[j]
                    nextDP[(k * mul + j) %N] %= mod

        else:
            k = int(S[i])
            for j in range(N):
                nextDP[(k * mul + j) %N] += DP[j]
                nextDP[(k * mul + j) %N] %= mod

        mul *= 10
        mul %= N
        DP = nextDP

    return DP[5]

if __name__ == '__main__':
    print(main())
Problem p02958 (python)

Fixed submission:
#!/usr/bin/env python
import itertools

def main():
    N = int(input())
    p = list(map(int, input().split()))

    compArr = list(range(1, N+1))
    arr = list(range(N))
    combs = list(itertools.combinations(arr, 2))

    ans = 'NO' 
    if p == compArr:
        ans = 'YES'
    for c in combs:
        tmpArr = compArr.copy()
        tmpArr[c[0]], tmpArr[c[1]] = tmpArr[c[1]], tmpArr[c[0]]
        if p == tmpArr:
            ans = 'YES'

    return ans

if __name__ == '__main__':
    print(main())

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
import itertools

def main():
    N = int(input())
    p = list(map(int, input().split()))

    compArr = list(range(1, N+1))
    arr = list(range(N))
    combs = list(itertools.combinations(arr, 2))

    ans = 'NO' 
    if p == compArr:
        ans = 'YES'
    for c in combs:
        tmpArr = compArr.copy()
        tmpArr[c[0]], tmpArr[c[1]] = tmpArr[c[1]], tmpArr[c[0]]
        if p == tmpArr:
            ans = 'YES'

    return ans

if __name__ == '__main__':
    print(main())
Problem p02969 (python)

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

def main():
    r = int(input().strip())
    return(3 * r * r)

if __name__ == '__main__':
    print(main())

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

def main():
    r = int(input().strip())
    return(3 * r * r)

if __name__ == '__main__':
    print(main()
Problem p02971 (python)

Fixed submission:
#!/usr/bin/env python
import numpy as np

def main():
    N = int(input().strip())
    arr = np.zeros(N, np.int32)
    for i in range(N):
        arr[i] = int(input().strip())
    arr2 = np.sort(arr)[::-1]
    max1, max2 = arr2[0], arr2[1]

    for i in range(N):
        print(max1) if arr[i] != max1 else print(max2)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
import numpy as np

def main():
    N = int(input().strip())
    arr = np.zeros(N, np.int32)
    for i in range(N):
        arr[i] = int(input().strip())
    for i in range(N):
        arr2 = np.copy(arr)
        arr2[i] = 0
        print(arr2.max())


main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
import numpy as np

def main():
    N = int(input().strip())
    arr = np.zeros(N, np.int32)
    for i in range(N):
        arr[i] = int(input().strip())
    for i in range(N):
        arr2 = np.copy(arr)
        arr2[i] = 0
        print(arr2.max())

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

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

A, B, C = list(map(int, input().split()))

if A * B < C:
    print(A * B)
else:
    print(C)

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

def main():
    N, A, B = list(map(int, input().strip().split()))
    if N * A < B:
        return N * A
    else:
        return B

 print(main())
Problem p02983 (python)

Fixed submission:
def main():
  p = 2019
  L, R = list(map(int, input().split()))
  
  if (R - L) >= p:
    ans = 0
    print(ans)
    
  else:
    L, R = L % p, R % p
    ans = 2019 ** 2
    for i in range(L, R + 1):
      for j in range(i+1, R+1):
        tmp = (i * j) % p
        if tmp < ans:
          ans = tmp
    print(ans)
    
main()

Buggy submission (verdict: Runtime Error):
def main():

p = 2019
L, R = list(map(int, input().split()))
if (R - L) >= (p -1):
  ans = 0
  print(ans)
else:
  L, R = 
  if L < R:
    ans = L * (L+1)
  else:
    ans = 0
  print(ans)
  
main()

Buggy submission (verdict: Runtime Error):
def main():

p = 2019
L, R = list(map(int, input().split()))
if (R - L) >= (p -1):
  ans = 0
  print(ans)
else:
  L, R = [x % p for x in [L, R]]
  if L < R:
    ans = L * (L+1)
  else:
    ans = 0
  print(ans)
  
main()
Problem p02995 (python)

Fixed submission:
#!/usr/bin/env python
import fractions

def count_antidivision(n, x, y):
    """
    returns count of numbers from 1 to n which are not dividable by x nor y.
    """
    return n - n // x - n // y + n // (x * y // fractions.gcd(x, y))    

def main(A, B, C, D):
    return count_antidivision(B, C, D) - count_antidivision(A-1, C, D)

if __name__ == '__main__':
    A, B, C, D = list(map(int, input().split()))
    print(main(A, B, C, D))

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

def count_antidivision(n, x, y):
    """
    returns count of numbers from 1 to n which are not dividable by x nor y.
    """
    return n - n // x - n // y + n // (x * y // math.gcd(x, y))    

def main(A, B, C, D):
    return count_antidivision(B, C, D) - count_antidivision(A-1, C, D)

if __name__ == '__main__':
    A, B, C, D = list(map(int, input().split()))
    print(main(A, B, C, D))

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

def count_antidivision(n, x, y):
    """
    returns count of numbers from 1 to n which are not dividable by x nor y.
    """
    return n - n // x - n // y + n // (x * y // math.gcd(x, y))    

def main(A, B, C, D):
    return count_antidivision(B, C, D) - count_antidivision(A-1, C, D)

if __name__ == '__main__':
    A, B, C, D = list(map(int, input().split()))
    print(main(A, B, C, D))

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

def count_antidivision(n, x, y):
    """
    returns count of numbers from 1 to n which are not dividable by x nor y.
    """
    return n - n // x - n // y + n // (x * y // math.gcd(x, y))    

def main(A, B, C, D):
    return count_antidivision(B, C, D) - count_antidivision(A-1, C, D)

if __name__ == '__main__':
    A, B, C, D = list(map(int, input().split()))
    print(main(A, B, C, D))
Problem p03031 (python)

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

def main():
    N, M = map(int, input().split())
    S = [list(map(int, input().split())) for _ in range(M)]
    P = list(map(int, input().split()))
    ans = 0

    # all possible switch patterns
    for i in range(2 ** N):
        light_on = 0
        # all switch conditions
        for j in range(M):
            switch_on = 0
            # all connected switch
            for k in S[j][1:]:
                # convert integer to binary
                if (i >> k-1) & 1:
                    switch_on += 1
            if switch_on %2 == P[j]:
                light_on += 1
        if light_on == M:
            ans += 1

    return ans

if __name__ == '__main__':
    print(main())

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

def main():
    N, M = map(int, input().split())
    S = [list(map(int, input().split() for _ in range(M)))]
    P = list(map(int, input().split()))
    ans = 0

    # all possible switch patterns
    for i in range(2 ** N):
        light_on = 0
        # all switch conditions
        for j in range(M):
            switch_on = 0
            # all connected switch
            for k in S[j][1:]:
                # convert integer to binary
                if (i >> k-1) & 1:
                    switch_on += 1
            if switch_on %2 == P[j]:
                light_on += 1
        if light_on == M:
            ans += 1

    return ans

if __name__ == '__main__':
    print(main())
Problem p03035 (python)

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

def main():
    A, B = map(int, input().split())
    if A < 6:
        return 0
    elif A < 13:
        return B / 2
    else:
        return B

if __name__ == '__main__':
    print(int(main()))

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

def main():
    N, M = map(int, input().split())
    INF = float('inf')

    LR = [-INF, INF]
    for _ in range(M):
        L, R = map(int, input().split())
        if LR[0] < L:
            LR[0] = L
        if LR[1] > R:
            LR[1] = R
    if LR[1] > LR[0]:
        return int(LR[1] - LR[0] + 1)
    else:
        return 0

if __name__ == '__main__':
    print(main())
Problem p03043 (python)

Fixed submission:
#!/usr/bin/env python
from math import log2, ceil

def main():
    N, K = map(int, input().split())

    ans = 0
    for i in range(1, N+1):
        n = ceil(log2(K) - log2(i))
        if n > 0:
            ans += 0.5 ** n
        else:
            ans += 1

    return ans / N

if __name__ == '__main__':
    print(main())

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
from math import log2, ceil

def main():
    N, K = map(int, input().split())

    ans = 0
    for i in range(1, N+1):
        n = ceil(log2(K) - log2(i))
        if n > 0:
            ans += 0.5 ** n
        else:
            ans += 1

    return ans / N

if __name__ == '__main__':
    print(main())