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

Fixed submission:
from operator import itemgetter

def input_list(num,args):
    for i in range(num):
        S,P = input().split()
        P=int(P)
        if 1<=len(S)<=10 and S.islower()==1 and S.isalpha()==1 \
           and 0<=P<=100 and isinstance(P,int)==1:
            args.append([S,P])
        else :
            print("ERROR")
            exit()



def sort_list(*args):
    tmp=sorted(args,key=itemgetter(1),reverse=1)
    dict_sorted=sorted(tmp,key=itemgetter(0))

    return dict_sorted


def check_list(seq):
    seen = []
    unique_list = [x for x in seq if x not in seen and not seen.append(x)]
    if len(seq) != len(unique_list):
        print("ERORR")
        exit()
    # else :                                                                                         
    #     print("restaurant is ok.")           



def main():
    # restaurant=[['N1',88],['N2',85],['N3',92],['N7',21],['N4',34],['N8',45],['N2',24],['N2',35]]   
    # num=8                                                                                          

    num=int(input())
    if 1<=num<=100:
        # [[] for i in range(5)]                                                                     
        restaurant=[]
        input_list(num,restaurant)

        check_list(restaurant)

        # print(restaurant)                                                                          
        restaurant_sorted=sort_list(*restaurant)

        for i in range(num):
            for j in range(num):
                if restaurant_sorted[i][1]==restaurant[j][1]:
                    print(j+1)
    else :
        print("ERORR")
        exit()

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from operator import itemgetter

def input_list(num,args):
    for i in range(num):
        S,P = input().split()
        if 1<=len(S)<=10 and S.islower==1 and 0<=P<=100 and type(P) is int :
            args.append([S,P])
        else :
            print("ERROR")
            exit()

            
def sort_list(*args):
    tmp=sorted(args,key=itemgetter(1),reverse=1)
    dict_sorted=sorted(tmp,key=itemgetter(0))

    return dict_sorted


def check_list(seq):
    seen = []
    uniequ_list = [x for x in seq if x not in seen and not seen.append(x)]
    if len(seq) != len(unique_list):
	print("ERORR")
	exit()
    # else :                                                                                         
    #     print("restaurant is ok.")                                                                 


def main():
    num=int(input())
    if 1<=num<=100:
        restaurant=[]
        input_list(num,restaurant)

        check_list(restaurant)

        restaurant_sorted=sort_list(*restaurant)

        for i in range(num):
            for j in range(num):
                if restaurant_sorted[i][1]==restaurant[j][1]:
                    print(j+1)
    else :
        print("ERORR")
        exit()

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

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

if 0 <=A<=100 and 2<=B<=1000:
    if B%2 == 1:
        print("ERROR")
        exit()
    else :
        if A <=5 :
            fare=0
        elif 6<=A<=12 :
            fare=B//2
        else:
            fare=B
else:
    print("ERROR")
    exit()

print(fare)

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

if 0 <=A<=100 and 2<=B<=1000:
    if B%2 == 1:
        print("ERROR")
        exit()
    else :
        if A <=5 :
            fare=0
        elif 6<=A<=12 :
            fare=B//2
        else:
            fare=B
else:
    print("ERROR")
    exit()

print(fare)

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

args=sys.argv
A=int(args[1])
B=int(args[2])


if 0 <=A<=100 and 2<=B<=1000:
    if B%2 == 1:
        print("ERROR")
        exit()
    else :
        if A <=5 :
            fare=0
        elif 6<=A<=12 :
            fare=int(B/2)
        else:
            fare=B
else:
    print("ERROR")
    exit()

print(fare)
Problem p03060 (python)

Fixed submission:
import sys

N=input()
if N.isdecimal() == 0 or int(N)<1 or int(N)>20 :
    print("error")
    sys.exit()

N=int(N)

V=list(map(int,input().strip().split()))
C=list(map(int,input().strip().split()))
# print(V[0],V[1],V[2])                                                                              

for i in range(N):
    if C[i]<1 or C[i]>50 or V[i]<1 or V[i]>50:
        print("error")
        sys.exit()

diff=0
max_profit=0



for i in range(N):
    # print(V[i],type(V[i]),C[i],type(C[i]))                                                         
    diff=V[i]-C[i]
    if diff >=0 :
        max_profit=max_profit+diff

print(max_profit)

Buggy submission (verdict: Runtime Error):
import sys

N=int(input())
if N<1 or N>20 :
    print("error")
    sys.exit()

V=list(map(int,input().strip().split()))
C=list(map(int,input().strip().split()))
# print(V[0],V[1],V[2])                                                                              

for i in range(N):
    if C[i]<1 or C[i]>20 or V[i]<1 or v[i]>20:
        print("error")
        sys.exit()

    # try:                                                                                           
    #     inp=dic[input('[Y]es/[N]o? >> ').lower()]                                                  
    #     break                                                                                      
    # except:                                                                                        
    #     pass                                                                                       

diff=0
max_profit=0



for i in range(N):
    # print(V[i],type(V[i]),C[i],type(C[i]))                                                         
    diff=V[i]-C[i]
    if diff >=0 :
        max_profit=max_profit+diff

print(max_profit)
Problem p03085 (python)

Fixed submission:
import sys

b=input()
if b=='A':
    print('T')
elif b=='T':
    print('A')
elif b=='C':
    print('G')
elif b=='G':
    print('C')
else :
    sys.exit()

Buggy submission (verdict: Runtime Error):
File Edit Options Buffers Tools Python Help                                                                                                                                              
# -*- coding: utf-8 -*-                                                                                                                                                                  

import sys

b=input()
if b=='A':
    print('T')
elif b=='T':
    print('A')
elif b=='C':
    print('G')
elif b=='G':
    print('C')
else :
    sys.exit()
Problem p03109 (python)

Fixed submission:
S = input()
year = int(S[:4])
month = int(S[5:7])
if year < 2019:
    print('Heisei')
elif month < 5:
    print('Heisei')
else:
    print('TBD')

Buggy submission (verdict: Runtime Error):
S = input()
year = int(S[:4])
month = int(S[5:7])
if year < 2019:
    print('Heisei')
elif year == 2019:
    if month > 4:
        print('TBD')
    else:
        print('Heisei')
else:
    print('TBD'

Buggy submission (verdict: Runtime Error):
S = input()
year = int(S[:4])
month = int(S[5:7])
if year < 2019:
    print('Heisei')
elif year == 2019:
    if month > 4:
        print('TBD')
    else:
        print('Heisei')
else:
    print('TBD'
Problem p03029 (python)

Fixed submission:
a, p = (int(i) for i in input().split())  
print((a*3+p) // 2)

Buggy submission (verdict: Runtime Error):
a, p = (int(i) for i in input().split())
print(a*3 // p)
Problem p03029 (python)

Fixed submission:
a, p = map(int, input().split())
print((a * 3 + p) // 2)

Buggy submission (verdict: Runtime Error):
a, p = map(int, input().split())
print((a * 3 + p) // 2)

Buggy submission (verdict: Runtime Error):
a, p = map(int, input().split())
print((a * 3 + p) / 2)
Problem p03089 (python)

Fixed submission:
size = int(input())
sequence = list(map(int, input().split()))

answer = []
while len(sequence):
  if not any(sequence[i] == i + 1 for i in range(len(sequence))):
    print(-1)
    exit()
  for i in reversed(range(len(sequence))):
    if sequence[i] == i + 1:
      answer.append(sequence[i])
      sequence.pop(i)
      break

for ans in reversed(answer):
  print(ans)

Buggy submission (verdict: Runtime Error):
sequence_size = int(input())
sequence = list(map(int, input().split()))
error = False
error_msg = -1
sequence.sort()
if max(sequence) > sequence_size:
    print(error_msg)
else:
    for index in range(0,sequence_size - 1):
        if sequence[index] <= index + 1:
            error is False
        else:
            error is True
            break
if error is False:
    for num in sequence:
        print(sequence[num])
else:
    print(error_msg)
Problem p03665 (python)

Fixed submission:
num_bags, congr_factor = list(map(int, input().split()))
bags = list(map(int, input().split()))
odd_bags = len([bag for bag in bags if (bag % 2 == 1)])

if congr_factor == 0 and odd_bags == 0:
  print(2 ** num_bags)
elif congr_factor == 1 and odd_bags == 0:
  print(0)
else:
  print(2 ** (num_bags-1))

Buggy submission (verdict: Runtime Error):
num_bags, congr_factor = list(map(int, input().split()))
bags = list(map(int, input().split()))
odd = len([a for a in bags if (a % 2 == 1]))

if congr_factor == 0 and odd == 0:
  print(2 ** num_bags)
elif congr_factor == 1 and odd == 0:
  print(0)
else:
  print(2 ** (num_bags-1))

Buggy submission (verdict: Runtime Error):
num_bags, congr_factor = list(map(int, input().split()))
bags = list(map(int, input().split()))
odd_bags = len([bag for bag in bags if (bag % 2 == 1]))

if congr_factor == 0 and odd == 0:
  print(2 ** num_bags)
elif congr_factor == 1 and odd == 0:
  print(0)
else:
  print(2 ** (num_bags-1))
Problem p03807 (python)

Fixed submission:
num_ints = int(input())
sum_ints = sum([int(i) for i in input().split()])

if sum_ints % 2 == 0:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
num_ints = int(input())
sum_ints = sum([int(i) for i in input().split()])

if sum % 2 == 0:
    print("YES")
else:
    print("NO")
Problem p03030 (python)

Fixed submission:
import numpy as np
N = int(input())
a = []
for i in range(N):
  S, P = input().split()
  a.append((S, 100-int(P), i+1))
a.sort()
for i in a:
  print(i[2])

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
a = []
for i in range(N):
  S, P = input().split()
  a.append((S, 100-P, i+1))
a.sort()
for i in a:
  print(i[2])
Problem p03049 (python)

Fixed submission:
n = int(input())
ss = [input() for _ in range(n)]
ans = 0
count_ab = 0 # if ab exists
count_a = 0 # if end in a
count_b = 0 # if start in b
count_ba = 0 # if start in b and end in a
for s in ss:
  slen = len(s)
  if s[0] == 'B' and  s[-1] == 'A':
    count_ba +=1
  else:
      if s[0] == 'B':
        count_b +=1
      if s[-1] == 'A':
        count_a +=1
  count_ab += s.count("AB")
 
if count_ba == 0:
    print(count_ab + min(count_a, count_b))
elif count_a == 0 and count_b == 0:
    print(count_ab + count_ba - 1)
elif count_a > 0 and count_b > 0:
    print(count_ab +  min(count_a, count_b) + count_ba)
else:
    print(count_ab + count_ba)

Buggy submission (verdict: Runtime Error):
n = int(input())
ss = [input() for _ in range(n)]
ans = 0
count_ab = 0 # if ab exists
count_a = 0 # if end in a
count_b = 0 # if start in b
count_ba = 0 # if start in b and end in a
for s in ss:
  slen = len(s)
  if s[0] == 'B' and  s[-1] == 'A':
    count_ba +=1
  else:
      if s[0] == 'B':
        count_b +=1
      if s[-1] == 'A':
        count_a +=1
  count_ab += s.count("AB")

if count_ba == 0:
    print(count_ab + min(count_a, count_b))
elif count_a == 0 and count_b == 0:
    print(count_ab + count+ba -1)
elif count_a > 0 and count_b > 0:
    print(count_ab +  min(count_a, count_b) + count_ba)
else:
    print(count_ab + count_ba)
Problem p03210 (python)

Fixed submission:
#-*- coding : utf-8 -*-
X = int(input())
if X == 3 or X == 5 or X == 7:
 	print("YES")
else:
 	print("NO")

Buggy submission (verdict: Runtime Error):
X = int(input())
if X == 3 or X == 5 or X == 7:
 	print("Yes")
else
 	print("No")

Buggy submission (verdict: Runtime Error):
X = int(input())
if X == 3 or X == 5 or X == 7:
  print("Yes")
else
  print("No")
Problem p03323 (python)

Fixed submission:
# -*- coding: utf-8 -*-
A, B = map(int, input().split())

if (A > 8) or (B > 8):
    print (":(")
else:
    print ("Yay!")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
A = int(input())
B = int(input())

if (A > 8) or (B > 8):
    print (":(")
else:
     print ("Yay!")
Problem p03495 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 20 12:35:48 2017

"""
 
from collections import Counter

NKList = list(map(int,input().split()))
N = NKList[0]
K = NKList[1]

AList = list(map(int,input().split()))

countDict = Counter(AList)
soretedList = sorted(countDict.values())

l = len(soretedList)

if len(soretedList) <= K :
    print(0)
else:
    print(N - sum(soretedList[l-K:] ))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 20 12:35:48 2017

"""
 
from collections import Counter

NKList = list(map(int,input().split()))
N = NKList[0]
K = NKList[1]

AList = list(map(int,input().split()))

countDict = Counter(AList)
soretedList = sorted(countDict.values())

rewrite = 0
l = len(soretedList)

while l > K:
    head = soretedList.pop(0)
    rewrite += head
    
print(rewrite)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 20 12:35:48 2017

"""
 
from collections import Counter

NKList = list(map(int,input().split()))
N = NKList[0]
K = NKList[1]

AList = list(map(int,input().split()))

countDict = Counter(AList)
soretedList = sorted(countDict.values())

rewrite = 0
l = len(soretedList)

while l > K:
    head = soretedList.pop(0)
    rewrite += head
    
print(rewrite)
Problem p03605 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Tue Dec 19 09:31:04 2017

@author: kotania
"""

N = input()

if int(N) > 89 :
    print("Yes")
elif N[1] == "9":
    print("Yes")
else :
    print("No")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Tue Dec 19 09:36:44 2017

@author: kotania
"""

N = int(input())
lrList = [""]*N
for n in range(0,N):
    lrList[n] = input()

sum = 0
for lr in lrList:
    sum += (int(lr.split()[1]) - int(lr.split()[0]) + 1)
    
print(sum)
Problem p03029 (python)

Fixed submission:
A ,P = map(int,input().split())
print(int((3*A + P) /2))

Buggy submission (verdict: Runtime Error):
import itertools

def is_lit(i, bit):
    l = [bit[j-1] for j in sockets[i]]
    return p[i] == l.count(True) % 2

count = 0
N, M = map(int, input().split())
bit_list = list(itertools.product([True, False], repeat = N))

sockets = []
for i in range(M):
    args = input().split(' ')
    k = int(args[0])
    sockets.append([int(args[i+1]) for i in range(k)])

p = [int(x) for x in input().split(' ')]

for bit in bit_list:
    o = [is_lit(i, bit) for i in range(M)]
    if o.count(True) == len(o):
        count += 1

print(count)
Problem p03037 (python)

Fixed submission:
N, M = input().split(" ")
#S = []
if M == 1:
    a, b = input().split(" ")
    print(int(b)-int(a)+1)
else:    
    a, b = input().split(" ")
    aM, bm = int(a),int(b)
    #sets = set([i for i in range(int(a),int(b)+1)])
    for m in range(int(M)-1):
        a, b = input().split(" ")
        aM = max(aM,int(a))
        bm = min(bm,int(b))
        #sets = sets & set([i for i in range(int(a),int(b)+1)])
    if(bm<aM):
        print(0)
    else:
        print(int(bm)-int(aM)+1)

Buggy submission (verdict: Runtime Error):
S = []
N, M = input().split(" ")
for m in range(len(int(M))):
  S.append(set([i for i in range(int(a),int(b)+1)]))
if M == 1:
  print(len(S[0]))
else:
  sets = S[0]
  for i in range(1,M):
    sets = sets & S[i]
  print(len(sets))
Problem p03043 (python)

Fixed submission:
import math
N, K = input().split(" ")
N, K = int(N), int(K)
P = 0
if (N < K):
  for n in range(1,N+1):
    P += 1/(N*pow(2,math.ceil(math.log2(K)-math.log2(n))))
else:
  for n in range(1, K+1):
    P += 1/(N*pow(2,math.ceil(math.log2(K)-math.log2(n))))
  P += (N-K)/N
print(P)

Buggy submission (verdict: Runtime Error):
import math
N, K = input().split(" ")
N, K = int(N), int(K)
P = 0
if (N < K):
  for n in N:
    P += 1/(N*math.ceil(math.log2(K)-math.log2(n)))
else:
  for n in K:
    P += 1/(N*math.ceil(math.log2(K)-math.log2(n)))
  P += (K-N)/N
print(P)

Buggy submission (verdict: Runtime Error):
import math
N, K = input().split(" ")
N, K = int(N), int(K)
P = 0
if (N < K):
  for n in N:
    P += 1/(N*math.ceil(math.log2(K)-math.log2(n)))
else:
  for n in K:
    P += 1/(N*math.ceil(math.log2(K)-math.log2(n)))
  P += (K-N)/N
print(K)
Problem p03050 (python)

Fixed submission:
import math
ans=0
m=[]
N=int(input())
rN=math.floor(math.sqrt(N))
for i in range(1,rN+1):
    if N%i==0:
        m.append(i)
        m.append(int(N/i))
    else:
        pass
m.sort()
m2=list(map(lambda x: x-1,m))
for i in m2:
    if i==0:
        pass
    else:
        a,b=divmod(N,i)
        if a==b:
            ans+=i
        else:
            pass
print(ans)

Buggy submission (verdict: Runtime Error):
import math
ans=0
m=[]
N=int(input())
rN=math.floor(math.sqrt(N))
for i in range(1,rN+1):
    if N%i==0:
        m.append(i)
        m.append(int(N/i))
    else:
        pass
m.sort()
m2=list(map(lambda x: x-1,m))
m2.pop(0)
for i in m2:
    a,b=divmod(N,i)
    if a==b:
        ans+=i
    else:
        pass
print(ans)
Problem p03433 (python)

Fixed submission:
N=int(input())
A=int(input())
if N%500<=A:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
N=int(input())
A=int(input())
if N%500<=A：
    print("Yes")
else:
    print("No")
Problem p03447 (python)

Fixed submission:
import math
X=int(input())
A=int(input())
B=int(input())
num=math.floor((X-A)/B)
print(X-A-B*num)

Buggy submission (verdict: Runtime Error):
import math
A=int(input())
B=int(input())
C=int(input())
X=int(input())

ans=0
a=math.floor(X/500)
for i in range(min(A,a)+1):
    X2=X-500*i
    b=math.floor(X2/100)
    for j in range(min(B,b)+1):
        X3=X2-100*j
        if X3%50==0:
            c=X3/50
            if c<=C:
                ans+=1
            else:
                continue
        else:
            continue
print(ans)
Problem p03471 (python)

Fixed submission:
N,Y=map(int,input().split())
flag=False
for i in range(N+1):
    if flag==True:
        break
    else:
        pass
    for j in range(N+1-i):
        k=N-i-j
        if 10000*i+5000*j+1000*k==Y:
            print(i, j, k)
            flag=True
            break
        else:
            continue
if flag==False:
    print("-1 -1 -1")
else:
    pass

Buggy submission (verdict: Runtime Error):
import math
N,Y=map(int,input().split())
YY=min(N,math.floor(Y/10000))
flag=False
for i in reversed(range(YY+1)):
    Y2=Y-i*10000
    N2=N-i
    YYY=min(N2,math.floor(YY2/5000))
    for j in reversed(range(YYY+1)):
        YY3=int((Y2-j*5000)/1000)
        if YY3==N2-j:
            print(i, j, YY3)
            flag=True
            break
        else:
            continue
if flag==False:
    print("-1 -1 -1")
else:
    exit()

Buggy submission (verdict: Runtime Error):
import math
N,Y=map(int,input().split())
YY=min(N,math.floor(Y/10000))
flag=False
for i in reversed(range(YY+1)):
    Y2=Y-i*10000
    N2=N-i
    YYY=min(N2,math.floor(YY2/5000))
    for j in reversed(range(YYY+1)):
        YY3=int((Y2-j*5000)/1000)
        if YY3==N2-j:
            print(i, j, YY3)
            flag=True
            break
        else:
            continue
if flag==False:
    print("-1 -1 -1")
else:
    exit

Buggy submission (verdict: Runtime Error):
import math
N,Y=map(int,input().split())
YY=min(N,math.floor(Y/10000))
flag=False
for i in reversed(range(YY+1)):
    Y2=Y-i*10000
    N2=N-i
    YYY=min(N2,math.floor(YY2/5000))
    for j in reversed(range(YYY+1)):
        YY3=int((Y2-j*5000)/1000)
        if YY3==N2-j:
            print(str(i),"",str(j),"",str(YY3))
            flag=True
            break
        else:
            continue
if flag==False:
    print(str(-1),"",str(-1),"",str(-1) )
else:
    exit

Buggy submission (verdict: Runtime Error):
import math
N,Y=map(int,input().split())
YY=min(N,math.floor(Y/10000))
flag=False
for i in reversed(range(YY+1)):
    Y2=Y-i*10000
    N2=N-i
    YYY=min(N2,math.floor(YY2/5000))
    for j in reversed(range(YYY+1)):
        YY3=int((Y2-j*5000)/1000)
        if YY3==N2-j:
            print(str(i),str(j),str(YY3))
            flag=True
            break
        else:
            continue
if flag==False:
    print(str(-1),str(-1),str(-1) )
else:
    exit
Problem p03493 (python)

Fixed submission:
sss=list(input())
print(sss.count('1'))

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
ans=0
for i,j in enumerate(A):
    if j%2!=0:
        print(ans)
        exit()
    else:
        A[i]=j/2
    count+=1

Buggy submission (verdict: Runtime Error):
N=int(input)
A=list(int(input().split()))
ans=0
flag=True
if flag==True:
    for i in range(N)
        if A[i]%2==0:
            A[i]=A[i]/2
        else:
            flag=False
            break
    ans+=1
else:
    break
        
print(ans)
Problem p03494 (python)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
flag=False
ans=0
while True:
    for i,j in enumerate(A):
        if j%2!=0:
            print(ans)
            flag=True
            break
        else:
            A[i]=j/2
    ans+=1 
    if flag:
        break

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
ans=0
for i,j in enumerate(A):
    if j%2!=0:
        print(ans)
        exit()
    else:
        A[i]=j/2
    count+=1
Problem p03495 (python)

Fixed submission:
N,K=map(int,input().split())
A=list(map(int,input().split()))
sa=len(set(A))-K
if sa>0:
    As={}
    for i in range(N):
        if A[i] in As:
            As[A[i]]+=1
        else:
            As[A[i]]=1
    Ass=sorted(As.values())
    print(sum(Ass[:sa]))
else:
    print(0)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
A=list(map(int,input().split()))
As=list(set(A))
sa=max(0,len(As)-K)
if sa==0:
    print(0)
    exit
else:
    count=[0]*len(As)
    for i in As:
        count[i]=A.count(i)
    num=sorted(count)
    ans=0
    for i in range(sa):
        ans+=num[i]
    print(ans)

Buggy submission (verdict: Runtime Error):
N,K=map(int,input().split())
A=list(map(int,input().split()))
As=list(set(A))
sa=max(0,len(As)-K)
if sa==0:
    print(0)
    break
else:
    count=[]
    for i in As:
        count.append(A.count(i))
    num=sorted(count)
    ans=0
    for i in range(sa):
        ans+=num[i]
    print(ans)