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

Fixed submission:
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
if sum(a)+sum(b)<k:
    ans=m+n
else:
    numa=[0]
    numb=[0]
    for i in range(n):
        numa.append(numa[-1]+a[i])
    for j in range(m):
        numb.append(numb[-1]+b[j])
    ans=0
    for i in range(n+1):
        if numa[i]>k:
            break
        while numb[m]>k-numa[i]:
            m-=1
        ans=max(ans,i+m)
print(ans)

Buggy submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
if sum(a)+sum(b)<k:
    ans=m+n
else:
    numa=[0]
    numb=[0]
    for i in range(n):
        numa.append(numa[-1]+a[i])
    for j in range(m):
        numb.append(numb[-1]+b[i])
    ans=0
    for i in range(n+1):
        if numa[i]>k:
            break
        while numb[m]>k-numa[i]:
            m-=1
        ans=max(ans,i+m)
print(ans)

Buggy submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
if sum(a)+sum(b)<k:
    ans=m+n
else:
    numa=[0]
    numb=[0]
    for i in range(n):
        if numa[-1]+a[i]>k:
            break
        numa.append(numa[-1]+a[i])
    for j in range(m):
        if numb[-1]+b[i]>k:
            break
        numb.append(numb[-1]+b[i])
    n=len(numa)
    m=len(numb)-1
    ans=0
    for i in range(n):
        num1=k-numa[i]
        for j in range(m):
            if numb[m]<=num1:
                break
            m-=1
        ans=max(ans,i+m)
print(ans)

Buggy submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
if sum(a)+sum(b)<k:
    ans=m+n
else:
    numa=[0]
    numb=[0]
    for i in range(n):
        if numa[-1]+a[i]>k:
            break
        numa.append(numa[-1]+a[i])
    for j in range(m):
        if numb[-1]+b[i]>k:
            break
        numb.append(numb[-1]+b[i])
    n=len(numa)
    m=len(numb)-1
    ans=0
    for i in range(n):
        num1=k-numa[i]
        for j in range(m+1):
            if numb[m]<=num1:
                break
            m-=1
        ans=max(ans,i+m)
print(ans)

Buggy submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
numa=[0]
numb=[0]
for i in range(n):
    if numa[-1]+a[i]>k:
        break
    numa.append(numa[-1]+a[i])
for j in range(m):
    if numb[-1]+b[i]>k:
        break
    numb.append(numb[-1]+b[i])
n=len(numa)
m=len(numb)
ans=0
for i in range(n):
    num1=k-numa[i]
    for j in range(m):
        if numb[m-j-1]<=num1:
            break
        m-=1
    ans=max(ans,i+m-1)
print(ans)
Problem p02693 (python)

Fixed submission:
k=int(input())
a,b=map(int,input().split())
c=a//k
d=b//k
if d-c==0 and c*k!=a and d*k!=b:
    print("NG")
else:
    print("OK")

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
for i in range(m):
    print(m-i+1,m+2+i)
Problem p02773 (python)

Fixed submission:
from collections import Counter
n=int(input())
list=[input() for _ in range(n)]
list.sort()
c=Counter(list).most_common()
most=c[0][1]
c.sort()
for i in range(len(c)):
    if c[i][1]==most:
        print(c[i][0])

Buggy submission (verdict: Runtime Error):
n=int(input())
count=0
scount=0
listcount=0
anslist=[]
s=[]
for i in range(n):
    a=input()
    s.append(a)
s_count=s.count
s.sort()
for i in range(n):
    if listcount==n:
        break
    scount=s_count(s[listcount])
    if scount>count:
        count=scount
        anslist.clear()
        anslist.append(s[listcount])
    elif scount==count:
        anslist.append(s[listcount])
    listcount+=scount
anslist.sort()
for i in range(len(anslist)):
    print(anslist[i])
Problem p02777 (python)

Fixed submission:
s,t=input().split()
a,b=map(int,input().split())
u=input()
if s==u:
    a-=1
else:
    b-=1
print(a,b)

Buggy submission (verdict: Runtime Error):
s,t=map(input().split())
a,b=map(input().split())
u=input()
if s==u:
    a-=1
else:
    b-=1
print(a+b)
Problem p02831 (python)

Fixed submission:
import fractions
a,b=map(int,input().split())
c=fractions.gcd(a,b)
print((a*b)//c)

Buggy submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
c=math.gcd(a,b)
print((a*b)//c)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
import math
c=math.gcd(a,b)
print((a*b)//c)
Problem p03186 (python)

Fixed submission:
inp=raw_input().split()
a=int(inp[0])
b=int(inp[1])
c=int(inp[2])
if(c<=(a+b)):
	print(b+c)
else:
	print(a+b+b+1)

Buggy submission (verdict: Runtime Error):
inp=raw_input().split()
a=int(inp[0])
b=int(inp[1])
c=int(inp[2])
if(c<=(a+b)):
	print(b+c)
else:
	print(a+b+b+1)
Problem p02622 (python)

Fixed submission:
a=input()
b=input()
ans=0
for i,j in zip(a,b):
  if i != j:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
a=input()
b=input()
ans=0
for i,j in a,b:
  if i != j:
    ans+=1
print(ans)
Problem p02659 (python)

Fixed submission:
from decimal import Decimal as D
a,b=map(str,input().split())
print(int(D(a)*D(b)))

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(b*100*a//100)
Problem p02725 (python)

Fixed submission:
k,n=map(int,input().split())
A=list(map(int,input().split()))
ans=-1
for i in range(n-1):
  ans=max(ans,A[i+1]-A[i])
print(k- max(ans,k-(A[n-1]-A[0])))

Buggy submission (verdict: Runtime Error):
k,n=map(int,input().split())
A-list(map(int,input().split()))
ans=-1
for i in range(n-1):
  ans=max(ans,A[i+1]-A[i])
print(sum(A)- max(ans,k-(A[n-1]-A[0])))
Problem p02736 (python)

Fixed submission:
import sys
import math
import heapq
mod=10**9+7
inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict, OrderedDict
#すべてのkeyが用意されてる defaultdict(int)で初期化
#順序を保ったdict
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal  #変換後の末尾桁を0や0.01で指定
  #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
from functools import lru_cache
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########
n=int(input())
s=input()
A=[int(i)-1 for i in s]

RUI2=[pow(2,i) for i in range(21)]
import bisect as bi
@lru_cache(maxsize=10**10)
def tan(n):
    if n==0:return [1]
    if n==1:return [1,1]
    if n==2:return [1,0,1]
    i= bi.bisect_right(RUI2,n)-1
    return tan(n-pow(2,i)) + [0]*(pow(2,i+1)-n-1) + tan(n-pow(2,i))


# for i in range(n-1):
#     if A[i]==A[i+1]: A[i]=0
#     elif (A[i]^A[i+1])&1 : A[i]=1
#     else:A[i]=2
# for i in range(n-2):
#     if (A[i]^A[i+1])&1 : A[i]=1
#     else:A[i]=0

# print(A[:-2],tan(n-3))
if A.count(1)!=0:
    A=[i%2!=1 for i in A]
    a=[i&j for i,j in zip(A,tan(n-1))]
    # print(a)
    print(1 if sum(a)%2==1 else 0)
else:
    a=[(i//2)&j for i,j in zip(A,tan(n-1))]
    #print(a,tan(4))
    print(2 if sum(a)%2==1 else 0)

Buggy submission (verdict: Runtime Error):
import sys
import math
import heapq
mod=10**9+7
inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict, OrderedDict
#すべてのkeyが用意されてる defaultdict(int)で初期化
#順序を保ったdict
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal  #変換後の末尾桁を0や0.01で指定
  #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
from functools import lru_cache
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########
n=int(input())
s=input()
A=[int(i)-1 for i in s]

RUI2=[pow(2,i) for i in range(21)]
import bisect as bi
@lru_cache(maxsize=10**10)
def tan(n):
    if n==0:return [1]
    if n==1:return [1,1]
    if n==2:return [1,0,1]
    i= bi.bisect_right(RUI2,n)-1
    return tan(n-pow(2,i)) + [0]*(pow(2,i+1)-n-1) + tan(n-pow(2,i))


for i in range(n-1):
    if A[i]==A[i+1]: A[i]=0
    elif (A[i]^A[i+1])&1 : A[i]=1
    else:A[i]=2
for i in range(n-2):
    if (A[i]^A[i+1])&1 : A[i]=1
    else:A[i]=0

# print(A[:-2],tan(n-3))
a=[i&j for i,j in zip(A[:-2],tan(n-3))]
# print(a)
print(1 if sum(a)%2==1 else 0)
Problem p02753 (python)

Fixed submission:
s=input()
if s=="AAA" or s=="BBB":
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
a=int(input())
if a in ["AAA","BBB"]:
  print("No")
else:
  print("Yes")
Problem p02757 (python)

Fixed submission:
from collections import Counter
n,p=map(int,input().split())
A=list(map(int,input()))
def U(x):
    return int(A[x:])
if p in [2,5]:
    keta=0
    ans=0
    for i in range(n):
        keta+=1
        if int(A[i])%p==0:
            ans+=keta
    print(ans)
    exit()
    
acc = [0 for i in range(n)] 
cur = A[-1] % p
acc[-1] = cur
k = 1
for i in range(n-2, -1, -1):
    cur += pow(10, k, p) * A[i]
    cur %= p
    acc[i] = cur
    k += 1
acc = acc + [0]
 
C = Counter(acc)
ans = 0
for v in C.values():
    ans += v * (v-1) // 2
print(ans)

Buggy submission (verdict: Runtime Error):
n,p=map(int,input().split())
s=input()
def U(x):
    return int(s[x:])
if p in [2,5]:
    keta=0
    ans=0
    for i in range(n):
        keta+=1
        if int(s[i])%p==0:
            ans+=keta
    print(ans)
    exit()


ikeru=[0 for i in range(p)
for i in range(n):
    a=U(i) % p
    ikeru[a]+=1
ans=0
for t in ikeru:
    if t in [0,1]:continue
    ans+= t*(t-1)//2
print(ans)

Buggy submission (verdict: Runtime Error):
n,p=map(int,input().split())
s=input()
def U(x):
    return int(s[x:])
if p in [2,5]:
    keta=0
    ans=0
    for i in range(n):
        keta+=1
        if int(s[i])%p==0:
            ans+=keta
    print(ans)
    exit()

ans=0
ikeru=[0 for i in range(n)]
for i in range(n):
    a=U(i) % p
    if a==0:ans+=1
    ikeru[a]+=1

for t in ikeru:
    if t in [0,1]:continue
    ans+= t*(t-1)//2
print(ans)
Problem p02777 (python)

Fixed submission:
s,t=map(str,input().split())
a,b=map(int,input().split())
q=input()
print("{} {}".format(a-1,b) if q==s else "{} {}".format(a,b-1))

Buggy submission (verdict: Runtime Error):
s,t=map(str,input().split())
a,b=map(int,input().split())
q=input()
print("{x} {y}".format(a-1,b) if q==s else "{x} {y}".format(a,b-1))
Problem p02779 (python)

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
print("YES" if len(set(A))==len(A) else "NO")

Buggy submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input(),split()))
print("YES" if len(list(set(A)))==len(A) else "NO")

Buggy submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input(),split()))
print("YES" if len(set(A))==len(A) else "NO")

Buggy submission (verdict: Runtime Error):
n=int(input())
A=list(int,input(),split())
print("YES" if len(list(set(A)))==len(A) else "NO")

Buggy submission (verdict: Runtime Error):
n=int(input())
A=list(int,input(),split())
print("YES" if len(set(A))==len(A) else "NO")
Problem p02833 (python)

Fixed submission:
n=int(input())
if n%2==1:print(0)

else:
  ans=0
  for i in range(100):
    ans+= n//(10*5**i)
  print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
if n%2==1:print(0)
ans=0
else:
  for i in range(1,26):
    ans+= n//(5**i)
print(ans)
Problem p02915 (python)

Fixed submission:
print(int(input())**3)

Buggy submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
ans=B[A[0]-1]
for i in range(1,n):
  ans+=B[A[i]-1]
  if A[i-1]+1==A[i]:
    ans+=C[i-1]
print(ans)
Problem p02916 (python)

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
ans=B[A[0]-1]
for i in range(1,n):
  ans+=B[A[i]-1]
  if A[i-1]+1==A[i]:
    ans+=C[A[i-1]-1]
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
ans=A[0]
for i in range(n-1):
  ans+=B[A[i-1]]
  if A[i]+1==A[i+1]:
    ans+=C[i]
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
ans=A[0]
for i in range(n-1):
  ans+=A[i]
  if A[i]=A[i+1]:
    ans+=C[i]
print(ans)
Problem p02951 (python)

Fixed submission:
a,b,c=map(int,input().split())
print(max(0,c+b-a))

Buggy submission (verdict: Runtime Error):
print(max(0,c-b+a))
Problem p02955 (python)

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

s=sum(A)
import math
def yakusu(n):
  ans_local=set()
  for i in range(1,int(math.sqrt(n))+1):
    if n%i==0:
      ans_local = ans_local | set([i,n//i]) #setなので平方数でもOK
  return list(ans_local)  #必要に応じてsort

yaku=sorted(yakusu(s), reverse=1)
#print(yaku)
for mod in yaku:
    B=[i%mod for i in A if i%mod!=0]
    if B==[] : print(mod);exit()
    if len(B)==1:
        q=B[0]
        if 0<=q<=k or mod-k<=q: print(mod);exit()
        else:continue
    B.sort()
    r=[B[0]]*len(B)
    for i in range(len(B)-1):
        r[i+1]= r[i]+B[i+1]
    now=float("INF")
    for i in range(1,len(B)): #切り方
        if r[i-1] ==  mod*(len(B)-i)-(r[-1]-r[i-1]) and r[i-1]<=k:
            print(mod);exit()

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

s=sum(A)
import math
def yakusu(n):
  ans_local=set()
  for i in range(1,int(math.sqrt(n))+1):
    if n%i==0:
      ans_local = ans_local | set([i,n//i]) #setなので平方数でもOK
  return list(ans_local)  #必要に応じてsort

yaku=sorted(yakusu(s), reverse=1)
#print(yaku)
for mod in yaku:
    B=[i%mod for i in A if i%mod!=0]
    B.sort()
    r=[B[0]]*len(B)
    for i in range(len(B)-1):
        r[i+1]= r[i]+B[i+1]
    now=float("INF")
    for i in range(1,len(B)): #切り方
        if r[i-1] ==  mod*(len(B)-i)-(r[-1]-r[i-1]) and r[i-1]<=k:
            print(mod);exit()

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

s=sum(A)
import math
def yakusu(n):
  ans_local=set()
  for i in range(1,int(math.sqrt(n))+1):
    if n%i==0:
      ans_local = ans_local | set([i,n//i]) #setなので平方数でもOK
  return list(ans_local)  #必要に応じてsort

yaku=sorted(yakusu(s), reverse=1)
#print(yaku)
for mod in yaku:
    B=[i%mod for i in A if i%mod!=0]
    B.sort()
    r=[B[0]]*len(B)
    for i in range(len(B)-1):
        r[i+1]= r[i]+B[i+1]
    now=float("INF")
    for i in range(1,len(B)):
        now= min(max(r[i-1], mod*(len(B)-i)-(r[-1]-r[i-1])),now)
    if now<=k:
        print(mod);exit()
Problem p02970 (python)

Fixed submission:
a,b=map(int,input().split())
print(int((a-0.01)//(2*b+1)+1))

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
prnit((a-0.01)//(2*b+1)+1)
Problem p02984 (python)

Fixed submission:
n=int(input())
A=list(map(int,input().split()))
M=[0]*n
K=[k for k in range(n)][1::2]+[k for k in range(n)][::2]
for i in K:
  M[(i+1)%n]=M[i-1]+2*(A[i%n]-A[i-1])
  
d=(sum(A)-sum(M))//n
for i in range(n):
  print(M[i]+d)

Buggy submission (verdict: Runtime Error):
n=int(input())
A=list(map(int,input().split()))
M=[0]*n
K=[k for k in range(n)][1::2]+[k for k in range(n)][::2]
for i in K:
  M[i+1]=M[i-1]+2*(M[i]-M[i-1])
  
d=(sum(A)-sum(M))//n
for i in range(n):
  print(M[i]+d)
Problem p02990 (python)

Fixed submission:
import math
n,b=map(int,input().split())
def kaijo(x):
  return math.factorial(x)

def C(x,y):
  if x>=y:
    return(kaijo(x)//(kaijo(y)*kaijo(x-y)))

r=n-b

for i in range(1,b+1):
  if r+1<i:
    print(0)
    continue
  print((C(b-1,i-1)*C(r+1,i))%(10**9+7))

Buggy submission (verdict: Runtime Error):
import math
n,b=map(int,input().split())
def kaijo(x):
  return math.factorial(x)

def C(x,y):
  return(kaijo(x)//(kaijo(y)*kaijo(x-y)))

r=n-b
if n==b:
  for i in range(b):
    print(1)
    exit()
for i in range(1,b+1):
  print((C(b-1,i-1)*C(r+1,i))%(10**9+7))
Problem p03013 (python)

Fixed submission:
import sys
mod=10**9+7 ; inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict #すべてのkeyが用意されてる defaultdict(int)で初期化
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal  #変換後の末尾桁を0や0.01で指定
  #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
from functools import lru_cache
from bisect import bisect_left as bileft, bisect_right as biright
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########
n,m=map(int,input().split())
A=[int(input()) for i in range(m)]
NG=[0]*(10**5+10)
for i in A:
    NG[i]=1


@lru_cache(maxsize=10**10)
def qwe(x):
    if x==n:return 1
    if x>n:return 0
    if NG[x+1] and NG[x+2]: print(0);exit()
    if NG[x+1]:return qwe(x+2)%mod
    if NG[x+2]:return qwe(x+1)%mod
    return (qwe(x+2)+qwe(x+1))%mod
print(qwe(0))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
A=[int(input()) for i in range(m)]
NG=[0]*10**5
for i in range(m):
    NG[A[i]]=1
import sys
mod=10**9+7 ; inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict #すべてのkeyが用意されてる defaultdict(int)で初期化
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal  #変換後の末尾桁を0や0.01で指定
  #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
from functools import lru_cache
from bisect import bisect_left as bileft, bisect_right as biright
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########

@lru_cache(maxsize=10**10)
def qwe(x):
    if x==n:return 1
    if x>n:return 0
    if NG[x+1] and NG[x+2]: print(0);exit()
    if NG[x+1]:return qwe(x+2)%mod
    if NG[x+2]:return qwe(x+1)%mod
    return (qwe(x+2)+qwe(x+1))%mod
print(qwe(0))
Problem p03015 (python)

Fixed submission:
L=input()
mod=10**9+7



N=[int(i) for i in L]
keta=len(N)
dp=[[0 for i in range(2)] for j in range(keta+1)]
dp[0][0] = 1
#dp[0][0][1] =0
#dp[0][1][0] =0
#dp[0][1][1] =0

for i in range(keta):
    for smaller in [0,1]:
        if 1:
            for x in range(2 if smaller else (N[i]+1)):
                dp[i + 1][smaller | ((x == 0)&(N[i]==1))]+= dp[i][smaller]*(2 if x==1 else 1)
                dp[i + 1][smaller | ((x == 0)&(N[i]==1))] %=mod
print((dp[keta][0]+ dp[keta][1])%mod)

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



N=[int(i) for i in L]
keta=len(N)
dp=[[0 for i in range(2)] for j in range(101)]
dp[0][0] = 1
#dp[0][0][1] =0
#dp[0][1][0] =0
#dp[0][1][1] =0

for i in range(keta):
    for smaller in [0,1]:
        if 1:
            for x in range(2 if smaller else (N[i]+1)):
                dp[i + 1][smaller | ((x == 0)&(N[i]==1))]+= dp[i][smaller]*(2 if x==1 else 1)
                dp[i + 1][smaller | ((x == 0)&(N[i]==1))] %=mod
print((dp[keta][0]+ dp[keta][1])%mod)
Problem p03038 (python)

Fixed submission:
n,m=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
Q=[]
for i in range(m):
    b,c=map(int,input().split())
    Q.append([b,c])

Q=sorted(Q, key=lambda x:x[1], reverse=1)
kae=0

d=[-1]*(n)
now=0
for l in Q:
    b,c=l
    if n-now<b:
        d[now:]=[c]*(n-now)
        break
    d[now:now+b]=[c]*b
    now+=b

#print(d)
ans=sum(A)
now=ans
for kae in range(1,n+1):
    now+=d[kae-1]
    now-=A[kae-1]
    ans=max(ans,now)
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
A=list(map(int,input().split()))
B=[];C=[];Q=[]
A.sort()
for i in range(m):
    b,c=map(int,input().split())
    Q.append([b,c])

import bisect as bi

#Qの統合
s=set([l[1] for l in Q])
dicts={}
for i in s:
    dicts[s]=0
for l in Q:
    dicts[l[1]]+=l[0]
Q=[[j,i] for i,j in dicts.items()]
Q=sorted(Q, key=lambda x:x[1], reverse=1)
######
print(Q)

for l in Q:
    b,c=l
    a=bi.bisect_left(A,c)
    if A[0]>=c:
        break
    if a< b:
        A=[c]*a + A[a:]
        break
    
    A= A[b:a]+ [c]*b + A[a:]
    print(A)
print(sum(A))
Problem p03041 (python)

Fixed submission:
a,s=map(int,input().split())
k=input()
lk=list(k)
l=lk[s-1]
lk[s-1]=l.lower()
print("".join(lk))

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
s=input()
print(s.replace(s[b-1],lower(s[b-1])))
Problem p03053 (python)

Fixed submission:
h,w=map(int,input().split())
A=[list(input()) for i in range(h)]
import sys
mod=10**9+7 ; inf=float("inf")
from math import sqrt, ceil
from collections import deque, Counter, defaultdict #すべてのkeyが用意されてる defaultdict(int)で初期化
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP,Decimal as D  #変換後の末尾桁を0や0.01で指定
  #Decimal((str(0.5)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
from functools import lru_cache
from bisect import bisect_left as bileft, bisect_right as biright
from fractions import Fraction as F  #F(a,b)で正確なa/b
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#ソート、"a"+"b"、再帰ならPython3の方がいい
#######ここから天ぷら########

queue=deque([])
seen=[[0]*w for i in range(h)]
for i in range(h):
    for j in range(w):
        if A[i][j]=="#":
            queue.append([i,j,0])
            seen[i][j]=1

dx=[1,0,-1,0];dy=[0,1,0,-1]
while queue:
    x,y,t=queue.pop()
    for i,j in zip(dx,dy):
        if 0<=x+i<h and 0<=y+j<w and seen[x+i][y+j]==0:
            queue.appendleft([x+i,y+j,t+1])
            seen[x+i][y+j]=1
print(t)

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
A=[[["."] *w for j in range(h)] for i in range(10)]
A[0]=[list(input()) for _ in range(h)]


i=0
ans=0
while A[i]!=[["#"] *w for j in range(h)]:
  for takasa in range(h):
    for nanmojime in range(w):
      if A[i][takasa][nanmojime]=="#":
        if nanmojime==0 and takasa==0:
          A[i+1][0][1]="#"
          A[i+1][1][0]="#"
          A[i+1][0][0]="#"
        elif nanmojime==0 and takasa==h-1:
          A[i+1][h-2][0]="#"
          A[i+1][h-1][1]="#"
          A[i+1][h-1][0]="#"
        elif nanmojime==w-1 and takasa==0:
          A[i+1][0][w-2]="#"
          A[i+1][1][w-1]="#"
          A[i+1][0][w-1]="#"
        elif nanmojime==w-1 and takasa==h-1:
          A[i+1][h-1][w-2]="#"
          A[i+1][h-2][w-1]="#"
          A[i+1][h-1][w-1]="#"
        elif takasa==0:
          A[i+1][0][nanmojime-1]="#"
          A[i+1][0][nanmojime+1]="#"
          A[i+1][1][nanmojime]="#"
          A[i+1][0][nanmojime]="#"
        elif takasa==h-1:
          A[i+1][h-1][nanmojime-1]="#"
          A[i+1][h-1][nanmojime+1]="#"
          A[i+1][h-2][nanmojime]="#"
          A[i+1][h-1][nanmojime]="#"
        elif nanmojime==0:
          A[i+1][takasa-1][0]="#"
          A[i+1][takasa+1][0]="#"
          A[i+1][takasa][1]="#"
          A[i+1][takasa][nanmojime]="#"
        elif nanmojime==w-1:
          A[i+1][takasa-1][w-1]="#"
          A[i+1][takasa+1][w-1]="#"
          A[i+1][takasa][w-2]="#"
          A[i+1][takasa][nanmojime]="#"
        else:
          A[i+1][takasa-1][nanmojime]="#"
          A[i+1][takasa+1][nanmojime]="#"
          A[i+1][takasa][nanmojime-1]="#"
          A[i+1][takasa][nanmojime+1]="#"
          A[i+1][takasa][nanmojime]="#"

  i+=1
print(i)
print(A)
Problem p03075 (python)

Fixed submission:
A=[int(input()) for _ in range(5)]
k=int(input())

for i in range(5):
  for j in range(i):
    if A[i]-A[j]>k:
      print(":(")
      exit()
print("Yay!")

Buggy submission (verdict: Runtime Error):
A=[int(input()) for i in range(5)]
k=int(input())

for i in range(4):
	for i in range(i):
		if A[i]-A[j]>k:
			print(""":(""")
			exit()
print("Yay!")
Problem p03207 (python)

Fixed submission:
n=int(input())
A=[]
for i in range(n):
  A.append(int(input()))
A.sort()
print(int(sum(A)-A[-1]/2))

Buggy submission (verdict: Runtime Error):
n=int(input())
A=[]
for i in range(n):
  A.append(int(input())
A.sort()
print(sum(A)-A[-1]/2)