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

Fixed submission:
strTest = input()
print(strTest.count("1"))

Buggy submission (verdict: Runtime Error):
a,b,c = int(input())
testList = [a,b,c]

def countOne(self,list):
  count =0
  for i in list:
    if i == 0:
      count +=1
  return count

print(countOne(testList))

Buggy submission (verdict: Runtime Error):
a,b,c = int(input())
testList = [a,b,c]

def countOne(self,list):
  count =0
  for i in list:
    if i == 0:
      count +=1
  return count

print(countOne(list))

Buggy submission (verdict: Runtime Error):
list = list(input().split(""))

def countOne(self,list):
  count =0
  for i in list:
    if i == 0:
      count +=1
  return count

print(countOne(list))
Problem p03006 (python)

Fixed submission:
N = int(input())
X,Y = [],[]
for _ in range(N):
    x,y = map(int,input().split())
    X.append(x)
    Y.append(y)
inf = 10**10

d = {}
for i in range(N):
    for j in range(i+1,N):
        if X[i] > X[j]:
            r,l = i,j
        elif X[i] == X[j]:
            if Y[i] > Y[j]:
                r,l = i,j
            else:
                r,l = j,i
        else:
            r,l = j,i
        k = (X[r]-X[l],Y[r]-Y[l])
        if k in d.keys():
            d[k] += 1
        else:
            d[k] = 1

if N == 1:
    print(1)
else:
    print(N-(max(d.values())))

Buggy submission (verdict: Runtime Error):
N = int(input())
X,Y = [],[]
for _ in range(N):
    x,y = map(int,input().split())
    X.append(x)
    Y.append(y)
inf = 10**10

d = {}
for i in range(N):
    for j in range(i+1,N):
        if X[i] >= X[j]:
            r,l = i,j
        else:
            r,l = j,i
        k = (X[r]-X[l],Y[r]-Y[l])
        if k in d.keys():
            d[k] += 1
        else:
            d[k] = 1

print(N-(max(d.values())))
Problem p03007 (python)

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

p,m = [],[]
p_total = 0
m_total = 0
p_max,p_min = 0,10**10
m_max,m_min = -10**10,0
p_count,p_min_idx,p_max_idx = 0,0,0
m_count,m_min_idx,m_max_idx = 0,0,0
for a in A:
    if a < 0:
        if m_min > a:
            m_min = a
            m_min_idx = m_count
        if m_max < a:
            m_max = a
            m_max_idx = m_count
        m_total += a
        m.append(a)
        m_count += 1
    else:
        if p_min > a:
            p_min = a
            p_min_idx = p_count
        if p_max < a:
            p_max = a
            p_max_idx = p_count
        p_total += a
        p.append(a)
        p_count += 1

if len(m) == 0:
    print(p_total-2*p_min)
    for i in range(len(p)-1):
        if i != p_min_idx:
            print(p[p_min_idx],p[i])
            p[p_min_idx] -= p[i]
    print(p[-1],p[p_min_idx])

elif len(p) == 0:
    print(2*m_max-m_total)
    for i in range(len(m)-1):
        if i != m_max_idx:
            print(m[m_max_idx],m[i])
            m[m_max_idx] -= m[i]
    print(m[m_max_idx],m[-1])

else:
    print(p_total-m_total)
    for i,v in enumerate(p):
        if i != p_max_idx:
            print(m[0], v)
            m[0] -= v
    for i in range(len(m)):
        print(p[p_max_idx],m[i])
        p[p_max_idx] -= m[i]

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

m,p = [],[]
m_total = 0
p_total = 0
p_max,p_min = 0,10**10
c,p_min_idx,p_max_idx = 0,0,0
for a in A:
    if a < 0:
        m_total += a
        m.append(a)
    else:
        if p_min > a:
            p_min = a
            p_min_idx = c
        if p_max < a:
            p_max = a
            p_max_idx = c
        p_total += a
        p.append(a)
        c += 1

if len(m) > 0:
    print(p_total-m_total)
    for i,v in enumerate(p):
        if i != p_max_idx:
            print(m[0], v)
            m[0] -= v
    for i in range(len(m)):
        print(p[p_max_idx],m[i])
        p[p_max_idx] -= m[i]
else:
    print(p_total-2*p_min)
    for i in range(len(p)-1):
        if i != p_min_idx:
            print(p[p_min_idx],p[i])
            p[p_min_idx] -= p[i]
    print(p[-1],p[p_min_idx])
Problem p03147 (python)

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

def dfs(L):
    for i,l in enumerate(L):
        if l != 0:
            break
    L = L[i:N]
    s = 0
    res = 0
    for i,l in enumerate(L):
        if l == 0:
            L_ = [l_-1 for l_ in L[s:i]]
            s = i+1
            if len(L_) != 0:
                res += 1
                res += dfs(L_)
        elif i == len(L)-1:
            L_ = [l_-1 for l_ in L[s:len(L)]]
            s = i+1
            if len(L_) != 0:
                res += 1
                res += dfs(L_)
    return res

if sum(h) == 0:
    print(0)
else:
    print(dfs(h))

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

def dfs(L):
    for i,l in enumerate(L):
        if l != 0:
            break
    L = L[i:N]
    s = 0
    res = 0
    for i,l in enumerate(L):
        if l == 0:
            L_ = [l_-1 for l_ in L[s:i]]
            if len(L_) != 0:
                res += 1
                s = i+1
                if sum(L_) != 0:
                    res += dfs(L_)
        elif i == len(L)-1:
            L_ = [l_-1 for l_ in L[s:len(L)]]
            if len(L_) != 0:
                res += 1
                s = i+1
                if sum(L_) != 0:
                    res += dfs(L_)
    return res

if sum(h) == 0:
    print(0)
else:
    print(dfs(h))
Problem p03238 (python)

Fixed submission:
# coding : utf-8

N = input()
if N == '1':
    print('Hello World')
elif N == '2':
    A = int(input())
    B = int(input())
    print(A+B)

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

import math

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

b = M//N

l = []
for i in range(1,int(math.sqrt(M)+1)):
    if M % i == 0:
        l.append(i)

ans = 1
for l_ in l:
    if l_ <= b:
        ans = max(ans,l_)

print(ans)
Problem p03262 (python)

Fixed submission:
import fractions
from functools import reduce

N, X = list(map(int, input().split()))
x = [i-X for i in list(map(int, input().split()))]

def func(nums):
    return reduce(fractions.gcd, nums)

print(abs(func(x)))

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

N, X = list(map(int, input().split()))
x = [i-X for i in list(map(int, input().split()))]

def func(nums):
    return reduce(math.gcd, nums)

print(func(x))
Problem p03290 (python)

Fixed submission:
D,G = list(map(int,input().split()))
P = []
C = []

for i in range(D):
    p,c = list(map(int,input().split()))
    P.append(p)
    C.append(c)

ans = 10000

for c in range(2**D):
    score = 0
    solved = 0
    remain = []
    for i,b in enumerate(format(c,'b').zfill(D)):
        if b == '1':
            score += P[i]*100*(i+1) + C[i]
            solved += P[i]
        else:
            remain.append(i)
    if score < G:
        R = G - score
        j = remain[-1]
        if (P[j]-1)*(j+1)*100 < R:
            continue
        solved += -(-R//(100*(j+1)))
    ans = min(solved, ans)

print(ans)

Buggy submission (verdict: Runtime Error):
D,G = list(map(int,input().split()))
P = []
C = []

for i in range(D):
    p,c = list(map(int,input().split()))
    P.append(p)
    C.append(c)

for c in range(2**D):
    score = 0
    solved = 0
    remain = []
    for i,b in enumerate(format(c,'b').zfill(D)):
        if b == '1':
            score += P[i]*100*(i+1) + C[i]
            solved += P[i]
        else:
            remain.append(i)
    if score < G:
        R = G - score
        j = remain[-1]
        if (P[j]-1)*(j+1)*100 < R:
            continue
        solved += (R//(100*(j+1)))
    ans = min(solved, ans)

print(ans)
Problem p03469 (python)

Fixed submission:
#coding : utf-8

s = input()
s = '2018' + s[4:]
print(s)

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

N,Y = [int(i) for i in input().split()]
flag = 0

for i in range(N+1):
    for j in range(N+1-i):
        if Y == 10000*i + 5000*j + 1000*(N-i-j) and flag == 0:
            print(i,j,N-i-j)
            flag = 1
            break
if flag == 0:
    print(-1,-1,-1)
Problem p03599 (python)

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

ans_con = -1
max_con = E/(100+E)*100

a = 0
while F >= 100*A*a:
    b = 0
    while F-100*A*a >= 100*B*b:
        water = 100*(A*a+B*b)
        c = 0
        while F-water >= C*c:
            d = 0
            while F-water-C*c >= D*d:
                sugar = C*c+D*d
                mass = water + sugar
                if 0 < mass <= F:
                    con = sugar/mass*100
                    if ans_con < con <= max_con:
                        ans_con = con
                        ans_mass = mass
                        ans_sugar = sugar
                d += 1
            c += 1
        b += 1
    a += 1

print(int(ans_mass), int(ans_sugar))

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

ans_con = 0
max_con = E/(100+E)*100

a = 0
while F > 100*A*a:
    b = 0
    while F-100*A*a > 100*B*b:
        c = 0
        while F-100*(A*a+B*b) > C*c and c:
            water = 100*(A*a+B*b)
            sugar = C*c+D*min((F-100*(A*a+B*b)-C*c)//D, (water/100*E-C*c)//D)
            mass = water + sugar
            if mass != 0:
                con = sugar/mass*100
                if ans_con < con <= max_con:
                    ans_con = con
                    ans_mass = mass
                    ans_sugar = sugar
            c += 1
        b += 1
    a += 1

print(int(ans_mass), int(ans_sugar))

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

ans_con = 0
max_con = E/(100+E)*100

a = 0
while F > 100*A*a:
    b = 0
    while F-100*A*a > 100*B*b:
        c = 0
        while F-100*(A*a+B*b) > C*c and c:
            water = 100*(A*a+B*b)
            sugar = C*c+D*min((F-100*(A*a+B*b)-C*c)//D, (water/100*E-C*c)//D)
            mass = water + sugar
            if mass == 0 or mass > F:
                break
            con = sugar/mass*100
            if ans_con < con <= max_con:
                ans_con = con
                ans_mass = mass
                ans_sugar = sugar
            c += 1
        b += 1
    a += 1

print(int(ans_mass), int(ans_sugar))
Problem p02646 (python)

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

dis = abs(B - A)
speed = V - W


if dis <= speed*T:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
N,S = map(int,input().split())
n,s = map(int,input().split())
T = int(input())

if (N - n)%(S-s)== 0 and N + S*T >= n + s*t:
  print("Yes")
else:
  print("No")
Problem p02658 (python)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
lim = 10**18

if 0 in A:
  print(0)
  exit()

  
ans = 1
A.sort(reverse = True)
for i in range(len(A)):
  ans = ans * A[i] 
  if ans > lim:
    print(-1)
    exit()

if ans > lim:
  print(-1)
else:
  print(ans)

Buggy submission (verdict: Runtime Error):
if 0 in A:
  print(0)
  exit()

  
ans = 1
A.sort(reverse = True)
for i in range(len(A)):
  ans = ans * A[i] 
  if ans > lim:
    print(-1)
    exit()

if ans > lim:
  print(-1)
else:
  print(ans)
Problem p02767 (python)

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

ans = 10000000

for i in range(100):
    result = 0
    for j in x:
        result += (j - i )**2
    ans = min(result, ans)
        
print(ans)

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

ans = 100000

for i in range(100):
    result = 0
    for j in x:
        result += (j - i )**2
    ans = min(result, ans)
        
print(ans)

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

ans = 100000

for i in 1,101:
    result = 0
    for j in x:
        result += (j - i )**2
    ans = min(result, ans)
        
print(ans)

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


for i in 100:
  result = 0
  for j in x:
    result += (i - j)**2
  print(min(result))
Problem p02780 (python)

Fixed submission:
import sys
#input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

#import numpy as np

def main():
	n,k=MI()
	p=LI()

	for i in range(n):
		p[i]=p[i]/2+0.5
	#print(p)

	ans=sum(p[:k])
	now=sum(p[:k])

	for i in range(n-k):
		now=now-p[i]+p[i+k]
		ans=max(ans,now)
	print(ans)















if __name__ == "__main__":
	main()

Buggy submission (verdict: Runtime Error):
import sys
#input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

#import numpy as np

def main():
	n,k=MI()
	p=LI()

	for i in range(N -K +1):
  	ans2 = sum(p[i:i+K])
  	if ans2 > ans1:
    	ans1 = ans2
    	ans_list = p[i:i+K]
    ans = sum(map(lambda i:i/2+0.5,ans_list))
	print(ans)


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

Fixed submission:
a, b = map(int, input().split())
 
k = 1
ans = 0
 
if b == 1:
  print(0)
else:
  while k<b:
    k += a-1
    ans += 1
  print(ans)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
 
if b == 0:
    return 1
else:
    inpu = 1
    while b > (a -1) * inpu + a:
        inpu +=1
    print(inpu + 1)

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

if b == 0:
	return 1
else:
	inpu = 1
    while b > (a -1) * inpu + a:
    	inpu +=1
    print(inpu + 1)

Buggy submission (verdict: Runtime Error):
k = 1
ans = 0
 
if b == 1:
  print(0)
else:
  while k<b:
    k += a-1
    ans += 1
  print(ans)
Problem p02924 (python)

Fixed submission:
N = int(input())

if (N -1) % 2 == 0:
  ans = N*(N-1)//2
else:
  ans = N*(N-2)//2 + N//2
  
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
my_list =list(range(1,N ))

print(sum(my_list))
Problem p03378 (python)

Fixed submission:
N, M, X = map(int,input().split())
A = list(map(int,input().split()))
a = len(A)

count_low = 0
count_high = 0
for i in range(a):
  if A[i] > X:
    count_high +=1
  elif A[i] < X:
    count_low += 1
    
if count_low >= count_high:
  print(count_high)
elif count_low < count_high:
  print(count_low)

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

count_low = 0
count_high = 0
for i in range(A):
  if A[i] > X:
    count_high +=1
  elif A[i] < X:
    count_low += 1
    
if count_low >= count_high:
  print(count_high)
elif count_low < count_high:
  print(count_low)

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

count_low = 0
count_high = 0
for i in range(A):
  if A[i] > X:
    count_high +=1
  else:
    count_low += 1
    
if count_low >= count_high:
  print(count_high)
else:
  print(count_low)
Problem p03486 (python)

Fixed submission:
S = list(input())
T = list(input())
s = []
t = []
for i in S:
  s.append(int(ord(i)))
for i in T:
  t.append(int(ord(i)))

s.sort()
t.sort()
for i in range(max(len(s),len(t))):
  if i >= min(len(s),len(t)):
    break
  elif max(t) > s[i]:
    print("Yes")
    exit(0)
  elif s[i] not in t:
    break
  else:
    t.remove(s[i])
    s.remove(s[i])
    
  
if len(t) > len(s):
  for i in s:
    if i not in t:
      print("No")
      exit(0)
    else:
      t.remove(i)
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
S = list(input())
T = list(input())
s = []
t = []
for i in S:
  s.append(int(ord(i)))
for i in T:
  t.append(int(ord(i)))

s.sort(reverse = True)
t.sort(reverse = True)
for i in range(max(len(s),len(t))):
  if t[i] > s[i]:
    print("Yes")
    exit(0)
  elif s[i] != t[i]:
    break
  
if len(t) > len(s):
  for i in s:
    if i == len(s):
      print("Yes")
    elif i not in t:
      print("No")
      exit(0)
    else:
      t.remove(i)
else:
  print("No")
  exit(0)
print("No")
Problem p03699 (python)

Fixed submission:
N = int(input()) 
S = [int(input()) for i in range(N)]
S.sort()
max_ans = sum(S)

if N == 1:
  if max_ans % 10 == 0:
    print(0)
    exit(0)
  else:
    print(max_ans)
    exit(0)
if max_ans % 10 == 0:
  i = 0
  while S[i] % 10 == 0:
    i += 1
    if i == N-1:
      print(0)
      exit(0)
  ans = max_ans - S[i]
  print(ans)
else:
  print(max_ans)

Buggy submission (verdict: Runtime Error):
N = int(input()) 
S = [int(input()) for i in range(N)]
S.sort()
max_ans = sum(S)

if N == 1:
  if max_ans % 10 == 0:
    print(0)
    exit(0)
  else:
    print(max_ans)
    exot(0)
if max_ans % 10 == 0:
  i = 0
  while S[i] % 10 == 0:
    i += 1
    if i == N-1:
      print(0)
      exit(0)
  ans = max_ans - S[i]
  print(ans)
else:
  print(max_ans)

Buggy submission (verdict: Runtime Error):
N = int(input()) 
S = [int(input()) for i in range(N)]
S.sort()
max_ans = sum(S)

if max_ans % 10 == 0:
  i = 0
  while S[i] % 10 == 0:
    i += 1
    if i == N-1:
      print(0)
      exit(0)
  ans = max_ans - S[i]
  print(ans)
else:
  print(max_ans)
Problem p03455 (python)

Fixed submission:
num_list = list(map(int,input().split()))
product = num_list[0] * num_list[1]
if product % 2 == 0:
  print("Even")
else:
  print("Odd")

Buggy submission (verdict: Runtime Error):
num_list = list(int(input().split()))
product = num_list[0] * num_list[1]
if product % 2 == 0:
  print("Even")
else:
  print("Odd")
Problem p03493 (python)

Fixed submission:
text = input()
ans = text.count('1')
print(ans)

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

count = 0
for i in num_list:
  if i % 2 == 0:
    count += 1
    # print(count)
  else:
    print(0)
    break

count_s = 0
if count == number:
  num_min = min(num_list)
  while num_min % 2 == 0:
    num_min = num_min / 2
    count_s += 1
  print(count_s)

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

count = 0
for i in num_list:
  if i % 2 == 0:
    count += 1
    # print(count)
  else:
    print(0)
    break

count_s = 0
if count == number:
  num_min = min(num_list)
  while True:
    num_min = num_min / 2
    count_s += 1
    if num_min == 1:
      print(count_s)
      break
Problem p02690 (python)

Fixed submission:
X = int(input())
flag = False
for a in range(-118, 120):
    for b in range(-119, 119):
        if a**5 - b**5 == X:
            print('{} {}'.format(a,b))
            flag = True
            break
    if flag:
        break

Buggy submission (verdict: Runtime Error):
X = int(input())
flag = False
for a in range(-118, 120):
    for b in range(-119, 119):
        if a**5 - b**5 == X:
            print('{} {}'.format(a,b))
            flag = True
            break
    if flag:
        breakX = int(input())
flag = False
for a in range(-118, 120):
    for b in range(-119, 119):
        if a**5 - b**5 == X:
            print('{} {}'.format(a,b))
            flag = True
            break
    if flag:
        break
Problem p02612 (python)

Fixed submission:
N = int(input())
for i in range(10):
    if (i + 1) * 1000 >= N:
        print((i + 1) * 1000 - N)
        break

Buggy submission (verdict: Runtime Error):
mod = 10 ** 9 + 7

N, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort(key=lambda x: abs(x), reverse=True)
ans = 1
if N == K:
    for i in range(K):
        ans *= A[i]
        if abs(ans) > mod:
            ans %= mod
elif len([v for v in A if v <= 0]) == N:
    for i in range(K):
        ans *= A[-(i + 1)]
        if abs(ans) > mod:
            ans %= mod
else:
    num_hu = len([v for v in A[:K] if v < 0])
    if num_hu % 2 == 0:
        for i in range(K):
            ans *= A[i]
            if abs(ans) > mod:
                ans %= mod
    else:
        if len([v for v in A[K:] if v >= 0]) == N - K:
            idx = K - 1
            while True:
                if A[idx] < 0:
                    break
                idx -= 1
            for i in range(idx):
                ans *= A[i]
                if abs(ans) > mod:
                    ans %= mod
            ans *= A[K]
            ans %= mod
            for i in range(idx + 1, K):
                ans *= A[i]
                if abs(ans) > mod:
                    ans %= mod
        elif len([v for v in A[K:] if v <= 0]) == N - K:
            idx = K - 1
            while True:
                if A[idx] > 0:
                    break
                idx -= 1
            for i in range(idx):
                ans *= A[i]
                if abs(ans) > mod:
                    ans %= mod
            ans *= A[K]
            ans %= mod
            for i in range(idx + 1, K):
                ans *= A[i]
                if abs(ans) > mod:
                    ans %= mod
        else:
            ans_1 = 1
            ans_2 = 1
            # ans_1
            min_hu_idx = K - 1
            while True:
                if A[min_hu_idx] < 0:
                    break
                min_hu_idx -= 1
            max_sei_idx = K
            while True:
                if A[max_sei_idx] > 0:
                    break
                max_sei_idx += 1
            for i in range(K):
                if i == min_hu_idx:
                    ans_1 *= A[max_sei_idx]
                else:
                    ans_1 *= A[i]
                if abs(ans_1) > mod:
                    ans_1 %= mod
            # ans_2
            min_sei_idx = K - 1
            while True:
                if A[min_sei_idx] > 0:
                    break
                min_sei_idx -= 1
            max_hu_idx = K
            while True:
                if A[max_hu_idx] < 0:
                    break
                max_hu_idx += 1
            for i in range(K):
                if i == min_sei_idx:
                    ans_2 *= A[max_hu_idx]
                else:
                    ans_2 *= A[i]
                if abs(ans_2) > mod:
                    ans_2 %= mod
            ans = max(ans_1, ans_2)
print(ans % mod)