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

Fixed submission:
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

x,y,a,b,c=MI()
ps=sorted(LI(),reverse=True)
qs=sorted(LI(),reverse=True)
rs=sorted(LI(),reverse=True)
ps=ps[0:x]
qs=qs[0:y]
u=rs+ps+qs
u.sort(reverse=True)
print(sum(u[0:x+y]))

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

x,y,a,b,c=MI()
rs=sorted(LI(),reverse=True)
gs=sorted(LI(),reverse=True)
ns=sorted(LI(),reverse=True)
rs=rs[0:x]
gs=gs[0:y]
#print(gs)
R=deque(rs)
G=deque(gs)
N=deque(ns)


u=R.popleft()
v=G.popleft()
w=N.popleft()
if x==1:
    s=u
else:
    s=R.pop()
if y==1:
    t=v
else:
    t=G.pop()
ans=0
while x>0 or y>0:
    if x==0:
        u=0
        s=inf
    if y==0:
        v=0
        t=inf
    if u>v and u>=w:
        #print(u)
        ans+=u
        x-=1
        if x==1:
            u=s
        elif x!=0:
            u=R.popleft()
        
    elif v>u and v>=w:
        #print(v)
        ans+=v
        y-=1
        if y==1:
            v=t
        elif y!=0:
            v=G.popleft()
        
    elif w>u and w>v:
        #print(w)
        ans+=w
        if s<=t:
            if x==1:
                s=u
                x-=1
            elif x!=0:
                s=R.pop()
                x-=1
        else:
            if y==1:
                t=v
                y-=1
            elif y!=0:
                t=G.pop()
                y-=1
print(ans)
Problem p02744 (python)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n=I()
lis=[[]for i in range(n)]
lis[0].append([1])
for i in range(n-1):
    for j in lis[i]:
        for m in range(max(j)+1):
            lis[i+1].append(j+[m+1])
        #print(max(j))
#print(lis[n-1])
alpha=["a","b","c","d","e","f","g","h","i","j"]
for u in lis[n-1]:
    ans=""
    for j in u:
        ans+=alpha[j-1]
    print(ans)

Buggy submission (verdict: Runtime Error):
'''alpha10=["a","b","c","d","e","f","g","h","i","j"]
N=int(input())
answers=[[] for i in range(10)]
answers[0].append("0")
print(answers)
for i in range(9):
    for befans in answers[i]:
        answers[i+1].append("0"+befans)'''
'''import sys
n=int(input())
points=[["0","0","0"]]
for i in range(n):
    points.append(input().rstrip().split(" "))
print(points)
for i in range(n):
    delx=int(points[i+1][1])-int(points[i][1])
    dely=int(points[i+1][2])-int(points[i][2])
    delt=int(points[i+1][0])-int(points[i][0])
    if delx+dely>delt or (delt-delx-dely)%2==1:
	    print("No")
    	sys.exit()
print("Yes")'''
import sys
n=int(input())
points=[["0","0","0"]]
for i in range(n):
    points.append(input().rstrip().split(" "))
#print(points)
for i in range(n):
    delx=int(points[i+1][1])-int(points[i][1])
    dely=int(points[i+1][2])-int(points[i][2])
    delt=int(points[i+1][0])-int(points[i][0])
    if abs(delx)+abs(dely)>delt or (delt-delx-dely)%2==1:
        print("No")
        sys.exit()
print("Yes")
Problem p02761 (python)

Fixed submission:
import sys
nm =input().rstrip().split(" ")
n =int(nm[0])
m =int(nm[1])
direcs=[]
for i in range(m):
    direcs.append(input().rstrip().split(" "))
#print(direcs)
trdirecs=list(map(list, set(map(tuple, direcs))))
#print(trdirecs)
first=[]
second=[]
third=[]
for j in trdirecs:
    if int(j[0])==1:
        first.append(int(j[1]))
    if int(j[0])==2:
        second.append(int(j[1]))
    if int(j[0])==3:
        third.append(int(j[1]))
if len(first)!=0 and first[0]==0 and (n==2 or n==3):
    answer=-1
    print(answer)
    sys.exit()
    
'''print(first)
print(second)
print(third)'''
'''if len(first)>1 or len(second)>1 or len(third)>1:
    print(-1)'''
if len(first)==0:
    first.append(0)
if len(second)==0:
    second.append(0)
if len(third)==0:
    third.append(0)
#数字が条件を満たしているかどうか判定する
if n==1:
    for i in range(0,10):
        if i==first[0]:
            answer=i
elif n==2:
    for i in range(0,100):
        d1=int((i-i%10)/10)
        d2=i%10
        if d1==first[0] and d2 ==second[0]:
            answer=i
            if answer<=9:
                answer=10+i
elif n==3:
    for i in range(0,1000):
        d3=i%10
        a=int((i-d3)/10)
        d2=a%10
        d1=int((a-a%10)/10)
        #print(d1,d2,d3)
        if d1==first[0] and d2==second[0] and d3==third[0]:
            answer=i
            if answer<100:
                answer=100+i
if len(first)>1 or len(second)>1 or len(third)>1:
    answer=-1
print(answer)

Buggy submission (verdict: Runtime Error):
import sys
nm =input().rstrip().split(" ")
n =int(nm[0])
m =int(nm[1])
direcs=[]
for i in range(m):
    direcs.append(input().rstrip().split(" "))
#print(direcs)
trdirecs=list(map(list, set(map(tuple, direcs))))
#print(trdirecs)
first=[]
second=[]
third=[]
for j in trdirecs:
    if int(j[0])==1:
        first.append(int(j[1]))
    if int(j[0])==2:
        second.append(int(j[1]))
    if int(j[0])==3:
        third.append(int(j[1]))
if first[0]==0 and (n==2 or n==3):
    answer=-1
    print(answer)
    sys.exit()
    
'''print(first)
print(second)
print(third)'''
'''if len(first)>1 or len(second)>1 or len(third)>1:
    print(-1)'''
if len(first)==0:
    first.append(0)
if len(second)==0:
    second.append(0)
if len(third)==0:
    third.append(0)
#数字が条件を満たしているかどうか判定する
if n==1:
    for i in range(0,10):
        if i==first[0]:
            answer=i
elif n==2:
    for i in range(0,100):
        d1=int((i-i%10)/10)
        d2=i%10
        if d1==first[0] and d2 ==second[0]:
            answer=i
            if answer<=9:
                answer=10+i
elif n==3:
    for i in range(0,1000):
        d3=i%10
        a=int((i-d3)/10)
        d2=a%10
        d1=int((a-a%10)/10)
        #print(d1,d2,d3)
        if d1==first[0] and d2==second[0] and d3==third[0]:
            answer=i
            if answer<100:
                answer=100+i
if len(first)>1 or len(second)>1 or len(third)>1:
    answer=-1
print(answer)
Problem p02780 (python)

Fixed submission:
nk=input().rstrip().split(" ")
n=int(nk[0])
k=int(nk[1])
numbers=input().rstrip().split(" ")
sigmas=[0]
sigma=0
for i in range(n):
    sigma=sigma+(int(numbers[i])+1)/2
    sigmas.append(sigma)
#print(sigmas)
deltas=[]
for i in range(n-k+1):
    delta=sigmas[k+i]-sigmas[i]
    deltas.append(delta)
#print(deltas)
answer=0
for delt in deltas:
    if delt>=answer:
        answer=delt
print(answer)

Buggy submission (verdict: Runtime Error):
straights=[]
nk =input().rstrip().split(" ")
n =int(nk[0])
k =int(nk[1])
numbers =input().rstrip().split(" ")
rank=sorted(numbers)
for i in range(k):
  answer=answer+rank[i]
trans=(answer+k)/2
Problem p02802 (python)

Fixed submission:
import sys
nm=input().rstrip().split(" ")
n=int(nm[0])
m=int(nm[1])
answers=[[] for i in range(n)]
for i in range(m):
    line=input().rstrip().split(" ")
    if line[1]=="AC":
        answers[int(line[0])-1].append(1)
    if line[1]=="WA":
        answers[int(line[0])-1].append(0)
#print(answers)
ac=0
i=0
was=[]
while i<n:
    sums=0
    j=0
    while j<len(answers[i]):
        sums=sums+answers[i][j]
        if sums>0:
            ac+=1
            was.append(j)
            break
        j=j+1
    i=i+1
print(ac,end=" ")
#print(was)
wacount=0
for j in was:
    wacount=wacount+j
print(wacount)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split()) 
L=[list(input().split()) for i in range(M)]
W=[0]*N
A=[0]*N
a=0
w=0
for i in range(M):
  if L[i][1]=="AC":
    A[int(L[i][0])-1]=1
    
  elif L[i][1]=="WA" and A[int(L[i][0])-1]==0:
    W[int(L[i][0])-1]+=1
#for i in A:
  #a+=i
#for i in W:
  #w+=i
for i in range(n):
  if A[i]>0:
    a+=1
    w+=W[i]
print(a,w)
Problem p02969 (python)

Fixed submission:
import sys
input = sys.stdin.readline
import math
import collections
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

r=I()
print(3*r*r)

Buggy submission (verdict: Runtime Error):
r=I()
print(3*r*r)
Problem p03067 (python)

Fixed submission:
a,b,c=map(int,input().rstrip().split(' '))
if (a<c<b) or (b<c<a):
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input.rstrip().split(' '))
if (a<c<b) or (b<c<a):
  print('Yes')
else:
  print('No')
Problem p03147 (python)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n=I()
lis=LI()
count=0
while sum(lis)>0:
    i=0
    state=""
    while i<n:
        if lis[i]>0:
            lis[i]-=1
            state="water"
            #print(1)
        elif lis[i]==0 and state=="water":
            count+=1
            state=""
            #print(2)
        if i==n-1 and state=="water":
            count+=1
            state=""
            #print(3)
        i+=1
print(count)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n=I()
lis=LI()
count=0
while sum(lis)>0:
    i=0
    while i<n:
        if lis[i]>0:
            lis[i]-=1
            state="water"
            #print(1)
        elif lis[i]==0 and state=="water":
            count+=1
            state=""
            #print(2)
        if i==n-1 and state=="water":
            count+=1
            state=""
            #print(3)
        i+=1
print(count)
Problem p03197 (python)

Fixed submission:
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=[I() for i in range(n)]
for i in range(n):
    if lis[i]%2==1:
        print("first")
        exit()
print("second")

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=LI()
for i in range(n):
    if lis[i]%2==1:
        print("first")
        exit()
print("second")
Problem p03212 (python)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

N = int(input())
def dfs(s): # 文字列 s で始まる七五三数の個数
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0 
    # s 自体が七五三数なら +1 
    for c in '753':
        ret += dfs(s + c)
    return ret
print(dfs('0')) # 本当は dfs('') と書きたいが 4 行目でのエラーを防ぐため仕方なく

#文字列をどんどん分岐しながら延ばすときにもdfsは使える
#準七五三数を全列挙し、それぞれについて判定

Buggy submission (verdict: Runtime Error):
N = int(input())
def dfs(s): # 文字列 s で始まる七五三数の個数
    if int(s) > N:
        return 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0 # s 自体が七五三数なら +1 for c in '753':
            ret += dfs(s + c)
    return ret
print(dfs('0')) # 本当は dfs('') と書きたいが 4 行目でのエラーを防ぐため仕方なく

#文字列をどんどん分岐しながら延ばすときにもdfsは使える
#準七五三数を全列挙し、それぞれについて判定
Problem p03283 (python)

Fixed submission:
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,m,que=MI()
lis=[[0]*n for i in range(n)]
for i in range(m):
    l,r=MI()
    lis[l-1][r-1]+=1
for i in range(n):
    lis[i]=list(accumulate(lis[i]))
#print(lis)
for i in range(que):
    p,q=MI()
    ans=0
    for i in range(p,q+1):
        if i==1:
            ans+=lis[i-1][q-1]
        else:
            ans+=lis[i-1][q-1]-lis[i-1][i-2]
    print(ans)

Buggy submission (verdict: Runtime Error):
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

u=input().rstrip()
n=int(u)
u=list(u)
s=int(u[-1])
sm=0
for i in u:
    sm+=int(i)

import math
def judprime(x):
    y=math.sqrt(x)
    count=0
    for j in range(2,int(y)+1):
        if x%j==0:
            count+=1
    if count==0:
        return 1
    else:
        return 0
#print(judprime(7))
#print(judprime(42))
pri =[1,3,7,9]
if judprime(n)==1:
    print("Prime")
else:
    if s in pri and sm%3!=0:
        print("Prime")
        
    else:
        print("Not Prime")
Problem p03353 (python)

Fixed submission:
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

s=SI()
k=I()
n=len(s)
strs=[]
for i in range(n):
    for j in range(1,k+1):
        strs.append(s[i:i+j])
print(sorted(list(set(strs)))[k-1])

Buggy submission (verdict: Runtime Error):
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

s=SI()
k=I()
n=len(s)
u=sorted(list(s))[0]
#print(s)
strs=[]
if n>=5:
    for i in range(n):
        if s[i]==u:
            for j in range(1,6):
                strs.append(s[i:i+j])
    #print(strs)
    #print(sorted(set(strs))[k-1])
else:
    for i in range(n):
        for j in range(i+1,n+1):
            #print(i,j)
            #print(s[i:j])
            strs.append(s[i:j])
#print(strs)
print(sorted(set(strs))[k-1])
Problem p03447 (python)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
#from operator import itemgetter
from copy import deepcopy
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [LI()for i in range(n)]
inf = 10**17
mod = 10**9 + 7

x=I()
a=I()
b=I()
ans=(x-a)%b
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
edge=[[]for _ in range(n)]
for _ in range(m):
  l,r,d=map(int,input().split())
  l-=1
  r-=1
  edge[l].append((r,d))
  edge[r].append((l,-d))
ans=[10**20]*n
inf=10**20
for i in range(n):
  if ans[i]!=inf:continue
  stack=[i]
  visited={i}
  ans[i]=0
  for node in stack:
    for mode,d in edge[node]:
      if ans[node]+d!=ans[mode]!=inf:exit(print("No")) #ans[node]+d!=ans[mode] and ans[mode]!=inf
      if mode in visited:continue
      visited.add(mode)
      stack.append(mode)
      if ans[mode]==inf:
        ans[mode]=ans[node]+d
        #if ans[node]+d!=ans[mode]:exit(print("No"))
print("Yes")