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

Fixed submission:
s=input()
k=int(input())
p=s[0]
cnt=1
q=[]
for i in range(len(s)-1):
	if s[i+1]==p:
		cnt+=1
	else:
		q.append(cnt)
		cnt=1
		p=s[i+1]
q.append(cnt)
if q[-1]%2==0:
	cnt=True
else:
	cnt=False
ans=0
if cnt==True:
	for i in range(len(q)):
		ans+=q[i]//2
	print(ans*k)
	exit()
if len(q)==1:
	print(len(s)*k//2)
	exit()
for i in range(len(q)-2):
	ans+=q[i+1]//2
ans*=k
ans+=q[0]//2
if s[0]==s[-1]:#miss
	ans+=(q[0]+q[-1])//2*(k-1)
	ans+=q[-1]//2
	print(ans)
	exit()
else:
	ans=0
	for i in range(len(q)):
		ans+=q[i]//2
	print(ans*k)

Buggy submission (verdict: Runtime Error):
s=input()
k=int(input())
p=s[0]
cnt=1
q=[]
for i in range(len(s)-1):
	if s[i+1]==p:
		cnt+=1
	else:
		q.append(cnt)
		cnt=1
		p=s[i+1]
q.append(cnt)
if q[-1]%2==0:
	cnt=True
else:
	cnt=False
ans=0
if cnt==True:
	for i in range(len(q)):
		ans+=q[i]//2
	print(ans*k)
	exit()
if len(q)==1:
	print(len(s)*k//2)
	exit()
for i in range(len(q)-1):
	ans+=q[i+1]//2
ans*=k
ans+=q[0]//2
if s[0]==s[-1]:
	ans+=(q[0]+q[-1])//2*(k-1)
	ans+=q[-1]//2
	print(ans)
	print(2/0)
else:
	ans=0
	for i in range(len(q)):
		ans+=q[i]//2
	print(ans*k)

Buggy submission (verdict: Runtime Error):
s=input()
k=int(input())
p=s[0]
cnt=1
q=[]
for i in range(len(s)-1):
	if s[i+1]==p:
		cnt+=1
	else:
		q.append(cnt)
		cnt=1
		p=s[i+1]
q.append(cnt)
if q[-1]%2==0:
	cnt=True
else:
	cnt=False
ans=0
if cnt==True:
	for i in range(len(q)):
		ans+=q[i]//2
	print(ans*k)
	exit()
if len(q)==1:
	print(len(s)*k//2)
	exit()
for i in range(k-2):
	ans+=q[i+1]//2
ans*=k
ans+=q[0]//2
ans+=(q[0]+q[1])//2*(k-1)
ans+=q[-1]//2
print(ans)
Problem p02925 (python)

Fixed submission:
def main():
	from collections import deque
	n=int(input())
	battle=n*(n-1)//2
	lis=[[] for i in range(battle)]
	num=[-1]*(n**2)
	cnt=-1
	for x in range(n**2):
		if x//n<x%n:
			cnt+=1
			num[x]=cnt
	for i in range(n):
		a=list(map(int,input().split()))
		for j in range(n-2):
			x=a[j]-1
			y=a[j+1]-1
			px=num[min(i*n+x,x*n+i)]
			py=num[min(i*n+y,y*n+i)]
			lis[px].append(py)
	node_in=[0]*(battle)
	for i in range(battle):
		for x in lis[i]:
			node_in[x]+=1
	zero=deque([])
	days=[10**9]*(battle)
	for i in range(battle):
		if node_in[i]==0:
			zero.append(i)
			days[i]=1
	while zero:
		r=zero.popleft()
		for x in lis[r]:
			node_in[x]-=1
			if node_in[x]==0:
				zero.append(x)
				days[x]=days[r]+1
	if 10**9 in days:
		print(-1)
	else:
		print(max(days))
if __name__ == '__main__':
	main()

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]
for i in range(n):
	a.append(list(map(int,input().split())))
d=[[]for _ in range(n**2//2+2)]
start=[0]*(n**2)
for i in range(n):
	for j in range(n-2):
		p=[i,a[i][j]-1];q=[i,a[i][j+1]-1]
		if i>a[i][j]-1:
			p=[a[i][j]-1,i]
		if i>a[i][j+1]-1:
			q=[a[i][j+1]-1,i]
		start[p[0]*n+p[1]]+=1
		start[q[0]*n+q[1]]=-10**7
		d[p[0]*n+p[1]].append(q[0]*n+q[1])
st=-1
for i in range(n**2):
	if start[i]>0:
		st=i
		break
if st==-1:
	print(-1)
	exit()
stack=[st]
deep=[1]*(n**2//2+2)
while stack:
	p=stack.pop()
	for x in d[p]:
		stack.append(x)
		deep[x]=deep[p]+1
print(max(deep))
Problem p02987 (python)

Fixed submission:
s=input()
if s[0]==s[1] and s[2]==s[3] and s[1]==s[2]:
 print("No")
elif s[0]==s[1] and s[2]==s[3]:
 print("Yes")
elif s[0]==s[2] and s[1]==s[3]:
 print("Yes")
elif s[0]==s[3] and s[1]==s[2]:
 print("Yes")
else:
 print("No")

Buggy submission (verdict: Runtime Error):
from math import ceil
mod=10**9+7
def comb(a,b):
	if a<b:
		return 0
	fac=[1]
	for i in range(a):
		fac.append(fac[i]*(i+1))
	r=pow(fac[b]*fac[a-b]%mod,mod-2,mod)
	return fac[a]*r%mod
n,k=map(int,input().split())
for i in range(1,k+1):
	q=comb(n-k+1,i)
	qq=comb(k-i+i-1,i-1)
	print(q*qq%mod)
Problem p03017 (python)

Fixed submission:
n,a,b,c,d=map(int,input().split())
s=input()
for i in range(a,d-1):
	if s[i]==s[i+1]=="#":
		print("No")
		exit()
three=0
s="#"+s+"#"
for i in range(b,d+1):
	if s[i]==s[i+1]==s[i-1]==".":
		three=True
if c<d:
	print("Yes")
elif three==True:
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
n,a,b,c,d=map(int,input().split())
s=input()
for i in range(n-1):
	if s[i]==s[i+1]=="#":
		print("No")
		exit()
three=0
s="#"+s
for i in range(b,d+1):
	if s[i]==s[i+1]==s[i-1]==".":
		three=True
if c<d:
	print("Yes")
elif three==True:
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
n,a,b,c,d=map(int,input().split())
s=input()
for i in range(n-1):
	if s[i]==s[i+1]=="#":
		print("No")
		exit()
three=0
s="#"+s
for i in range(b,d+1)
	if s[i]==s[i+1]==s[i-1]==".":
		three=True
if c<d:
	print("Yes")
elif three==True:
	print("Yes")
else:
	print("No")

Buggy submission (verdict: Runtime Error):
print("Yes)
Problem p03041 (python)

Fixed submission:
n,k=map(int,input().split())
s=input()
if s[k-1]=="A":
 d="a"
elif s[k-1]=="B":
 d="b"
else:
 d="c"
print(s[:k-1]+d+s[k:])

Buggy submission (verdict: Runtime Error):
n=int(input())
dis=[10**15]*n
dis[0]=0
pair=[[]for _ in range(n)]
for i in range(n-1):
	a,b,c=map(int,input().split())
	pair[a-1].append([b-1,c])
	pair[b-1].append([a-1,c])
now=0
stack=set()
cnt=n-1
while cnt!=0:
	for i in range(len(pair[now])):
		if dis[pair[now][i][0]]==10**15:
			dis[pair[now][i][0]]=dis[now]+pair[now][i][1]
			stack.add(pair[now][i][0])
	now=list(stack)[0]
	stack=set(stack)
	stack.remove(now)
	cnt-=1
for i in range(n):
	if dis[i]%2==0:
		print(0)
	else:
		print(1)
Problem p03253 (python)

Fixed submission:
mod=10**9+7
dic={}
def ADD(x):
	if x in dic:
		dic[x]+=1
	else:
		dic[x]=1
n,m=map(int,input().split())
for i in range(2,int(m**0.5+2)):
	while m%i==0:
		ADD(i)
		m//=i
if m>1:
	ADD(m)
dic=tuple(dic.values())
ans=1
fac=[1]
for i in range(10**6):
	fac.append(fac[-1]*(i+1)%mod)
def c(a,b):
	r=pow(fac[b]*fac[a-b]%mod,mod-2,mod)
	return fac[a]*r%mod
for x in dic:
	ans*=c(x+n-1,x)
	ans%=mod
print(ans)

Buggy submission (verdict: Runtime Error):
mod=10**9+7
dic={}
def ADD(x):
	if x in dic:
		dic[x]+=1
	else:
		dic[x]=1
n,m=map(int,input().split())
for i in range(2,int(m**0.5+2)):
	while m%i==0:
		ADD(i)
		m//=i
if m>1:
	ADD(m)
dic=tuple(dic.values())
ans=1
fac=[1]
for i in range(n+max(dic)+2):
	fac.append(fac[-1]*(i+1)%mod)
def c(a,b):
	r=pow(fac[b]*fac[a-b]%mod,mod-2,mod)
	return fac[a]*r%mod
for x in dic:
	ans*=c(x+n-1,x)
	ans%=mod
print(ans)

Buggy submission (verdict: Runtime Error):
mod=10**9+7
dic={}
def ADD(x):
	if x in dic:
		dic[x]+=1
	else:
		dic[x]=1
n,m=map(int,input().split())
for i in range(2,int(m**0.5+2)):
	while m%i==0:
		ADD(i)
		m//=i
if m>1:
	ADD(m)
dic=tuple(dic.values())
ans=1
fac=[1]
for i in range(2*n+2):
	fac.append(fac[-1]*(i+1)%mod)
def c(a,b):
	r=pow(fac[b]*fac[a-b]%mod,mod-2,mod)
	return fac[a]*r%mod
for x in dic:
	ans*=c(x+n-1,x)
	ans%=mod
print(ans)
Problem p03327 (python)

Fixed submission:
a=int(input())

if a>= 1000:
 print("ABD")
else:
 print("ABC")

Buggy submission (verdict: Runtime Error):
a=int(input())

if a>= 1000:
 print("ABD"):
else:
 print("ABC")
Problem p03315 (python)

Fixed submission:
s=input()
print(s.count('+')-s.count('-'))

Buggy submission (verdict: Runtime Error):
s=input()
print(s.count('+')-s.sount('-'))
Problem p02598 (python)

Fixed submission:
from collections import defaultdict
from collections import deque
from collections import Counter
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n,k = readInts()
a = readInts()

a.sort(reverse=True)

if n==1:
	print(math.ceil(a[0]/(k+1)))
	exit()

def get(left, right):
	l = (right-left)//2+left
	ans = 0
	for i in a:
		ans+=math.ceil(i/l)-1
	#print(l, ans, left, right)
	return ans,l

def nibu(left,right):
	ans,l = get(left, right)

	if left<right:
		if ans<=k:
			return nibu(left,l)
		else:
			return nibu(l+1, right)
	else:
		return right


print(nibu(1,a[0]))

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
from collections import deque
from collections import Counter
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n,k = readInts()
a = readInts()

a.sort(reverse=True)

def nibu(left,right):
	l = (right-left)//2+left
	ans = 0
	for i in a:
		ans+=math.floor(i/l)
	#print(l, ans, left, right)

	if left<right-1:
		if ans<=k:
			return nibu(left,right-(right-l))
		else:
			return nibu(left+(l-left), right)
	else:
		return left


print(nibu(0,a[0])+1)
Problem p03017 (python)

Fixed submission:
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

n,a,b,c,d = readInts()
a-=1
b-=1
c-=1
d-=1
s = readChar()
if (a-b)*(c-d)<0:
  if "..." in s[b-1:d+2] and "##" not in s[a:c]:
    print("Yes")
  else:
    print("No")
else:
  if "##" not in s[a:d+1]:
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n,a,b,c,d = readInts()
s = readChar()
if (a-b)*(c-d)<0:
	if "..." in s[max(a,b)-1:] and "##" not in s[min(a,b)]:
		print("Yes")
	else:
		print("No")
elif c<b:
	if "##" not in s[a:c] and "##" not in s[b:d]:
		print("Yes")
	else:
		print("No")
else:
	if "##" not in s[min(a,b):]:
		print("Yes")
	else:
		print("No")
	raise Exception
Problem p03208 (python)

Fixed submission:
n,k=map(int,input().split())
h=[int(input()) for i in range(n)]
h.sort()
ans=float("inf")
for i in range(len(h)-k+1):
	ma = h[i+k-1]
	mi = h[i]
	ans = min(ans,ma-mi)

print(ans)

Buggy submission (verdict: Runtime Error):
N, K, *h = map(int, open(0).read().split())
h = sorted(h)
ans=float("inf")
for i in range(len(h)-k+1):
	ma = h[i+k-1]
	mi = h[i]
	ans = min(ans,ma-mi)

print(ans)

Buggy submission (verdict: Runtime Error):
N, K, *h = map(int, open(0).read().split())
h.sort()
ans=float("inf")
for i in range(len(h)-k+1):
	ma = h[i+k-1]
	mi = h[i]
	ans = min(ans,ma-mi)

print(ans)
Problem p02862 (python)

Fixed submission:
MOD = 10**9 + 7
def comb(n, k, MOD):
    if n < k or n < 0 or k < 0:
        return 0
    k = min(k, n - k)
    if k == 0:
        return 1
    iinv = [1] * (k + 1)
    ans = n
    for i in range(2, k + 1):
        iinv[i] = MOD - iinv[MOD % i] * (MOD // i) % MOD
        ans *= (n + 1 - i) * iinv[i] % MOD
        ans %= MOD
    return ans
X, Y = map(int,input().split())
if (X+Y) % 3 != 0:
    print(0)
    exit()
n = (2*Y-X)//3
m = (2*X-Y)//3
print(comb(n+m,m,MOD))

Buggy submission (verdict: Runtime Error):
import math
mod = 10**9 + 7
def P(n, r):
    return math.factorial(n)//math.factorial(n-r)
def C(n, r):
    return P(n, r)//math.factorial(r)
X, Y = map(int,input().split())
if (X+Y) % 3 != 0:
    print(0)
    exit()
n = (2*Y-X)//3
m = (2*X-Y)//3
print(C(n+m,m) % mod)
Problem p02891 (python)

Fixed submission:
def f(s,n):
    res = 0
    flg = False
    for i in range(1,n):
        if flg:
            flg = False
            continue
        if S[i] == S[i-1]:
            flg = True
            res += 1
    return res
S = input()
K = int(input())
if len(set(list(S))) == 1:
    print(len(S)*K//2)
    exit()
ans = f(S,len(S))
S = S * 2
print(ans + (f(S,len(S)) - ans) * (K-1))

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
N = len(S)
cnt = 0
flg1 = False
flg2 = False
flg3 = False
flg4 = False
if N == 2:
    a = S[10000]
for i in range(N-1):
    if S[i] != S[i+1]:
        flg3 = True
        break
if (flg3 == False) and N % 2 == 1:
    print((N*K)//2)
    exit()
if (S[0] == S[N-1]) and K != 1:
    if S[0] != S[1]:
        cnt += 1
        flg1 = True
if (S[N-2] == S[N-1]):
    flg4 = True
for i in range(N-1):
    if flg2:
        flg2 = False
        continue
    if (i == N - 2) and flg1:
        break
    if S[i] == S[i+1]:
        cnt += 1
        flg2 = True
if flg1 and flg4 == False:
    print(cnt*K-1)
else:
    print(cnt*K)

Buggy submission (verdict: Runtime Error):
S = input()
K = int(input())
N = len(S)
cnt = 0
flg1 = False
flg2 = False
flg3 = False
flg4 = False
flg5 = False
for i in range(N-1):
    if S[i] != S[i+1]:
        flg3 = True
        break
if (flg3 == False) and N % 2 == 1:
    print((N*K)//2)
    exit()


if (S[0] == S[N-1]) and K != 1:
    if S[0] != S[1]:
        cnt += 1
        flg1 = True
        flg5 = True
    if (S[1] == S[2]) and (2 < N) and (flg5 == False):
        cnt += 1
        flg1 = True
if (S[N-2] == S[N-1]):
    flg4 = True

for i in range(N-1):
    if flg2:
        flg2 = False
        continue
    if (i == N - 2) and flg1:
        break
    if S[i] == S[i+1]:
        cnt += 1
        flg2 = True
if flg1 and flg4 == False:
    print(cnt*K-1)
else:
    print(cnt*K)
Problem p03017 (python)

Fixed submission:
N, A, B, C, D = map(int, input().split())
S = input()
for i in range(A-1,max(C,D)-1):
    if S[i] == '#' and S[i+1] == '#':
        print('No')
        exit()
if D < C:
    for i in range(B-2,N-2):
        if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.':
            print('Yes')
            exit()
        if i+1 == D-1:
            break
    print('No')
    exit()
else:
    print('Yes')
    exit()

Buggy submission (verdict: Runtime Error):
N, A, B, C, D = map(int, input().split())
S = input()
if '##' in S:
    print('No')
    exit()
if D < C:
    for i in range(B-1,D):
        if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.':
            print('Yes')
            exit()
    print('No')
    exit()
else:
    print('Yes')
    exit()
Problem p03107 (python)

Fixed submission:
S = input()
array = []
for i in range(len(S)):
    array.append(S[i])
print(len(S)-abs(array.count('0')-array.count('1')))

Buggy submission (verdict: Runtime Error):
S = input()
ans = len(S)
def check(S):
	first = S[0]
	for i in range(1,len(S)):
		if first != S[i]:
			S = S[0:i-1] + S[i+1:]
			return S
		else:
			first = S[i]
while 1:
	S = check(S)
	if ('1' in S) and ('0' in S):
		continue
	else:
		print(ans-len(S))
		break
Problem p03127 (python)

Fixed submission:
N = int(input())
array = list(map(int, input().split()))
array.sort()
min = array[0]
while True:
	tmp2 = min
	for item in array:
		tmp = item % min
		if tmp != 0 and tmp < min:
			min = tmp
	if min == tmp2:
		break
print(min)

Buggy submission (verdict: Runtime Error):
import fractions
N = int(input())
array = list(map(int, input().split()))
array.sort()
ans = array[0]
for i in range(1,ans):
	ans = fractions.gcd(ans,array[i])
print(ans)
Problem p03221 (python)

Fixed submission:
import sys
input = sys.stdin.readline
N, Q = map(int, input().split())
town = [[] for _ in range(N)]
for i in range(Q):
    place, year = map(int, input().split())
    town[place-1].append([year,i])

# print(town)

ans = []
k = 0
for item in town:
    index = k
    # index = town.index(item)
    # print(item)
    item.sort()
    index = str(index+1)
    while len(index) < 6:
        index = '0' + index
    for i in range(len(item)):
        num = str(i+1)
        while len(num) < 6:
            num = '0' + num
        xxx = index + num
        ans.append([item[i][1],xxx])
    k += 1

ans.sort()
for item in ans:
    print(item[1])

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N, Q = map(int, input().split())
town = [[] for _ in range(N)]
for i in range(Q):
    place, year = map(int, input().split())
    town[place-1].append([year,i])

# print(town)

ans = []
index = 0
for item in town:
    # print(item)
    item.sort()
    index += 1
    index = str(index)
    while len(index) < 6:
        index = '0' + index
    for i in range(len(item)):
        num = i + 1
        num = str(num)
        while len(num) < 6:
            num = '0' + num
        xxx = index + num
        tmp = []
        tmp.append(item[i][1])
        tmp.append(xxx)
        ans.append(tmp)
    index += 1

ans.sort()
for item in ans:
    print(item[1])
Problem p03329 (python)

Fixed submission:
N = int(input())
dp = [N] * 110000
dp[0] = 0
for i in range(0,N+1):
    m = 1
    while m <= N:
        dp[i] = min(dp[i],dp[i-m]+1)
        m *= 6
    m = 1
    while m <= N:
        dp[i] = min(dp[i],dp[i-m]+1)
        m *= 9
print(dp[N])

Buggy submission (verdict: Runtime Error):
N = int(input())
dp = [N] * 200
dp[0] = 0
for i in range(0,N+1):
    m = 1
    while m <= N:
        dp[i] = min(dp[i],dp[i-m]+1)
        m *= 6
    m = 1
    while m <= N:
        dp[i] = min(dp[i],dp[i-m]+1)
        m *= 9
print(dp[N])
Problem p03805 (python)

Fixed submission:
N, M = map(int, input().split())
G = [list(map(int, input().split())) for _ in range(M)]
edges = [[] for _ in range(N)]
for a, b in G:
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)

def dfs(start, edges, path):
    path.append(start)
    if len(path) == N:
        path.pop()
        return 1
    ans = 0
    for u in edges[start]:
        if u in path:
            continue
        ans += dfs(u, edges, path)
    path.pop()
    return ans

print(dfs(0, edges, []))

Buggy submission (verdict: Runtime Error):
import copy
import sys
sys.setrecursionlimit(10**7)
N, M = map(int, input().split())
edges = [[] for _ in range(M)]
for _ in range(M):
    a, b = map(int, input().split())
    edges[a - 1].append(b - 1)
    edges[b - 1].append(a - 1)
ans = 0
def dfs(start,path):
    next_path = copy.copy(path)
    global ans
    next_path.append(start)
    if len(next_path) == N:
        ans += 1
        return
    for i in edges[start]:
        if i not in next_path:
            dfs(i,next_path)
dfs(0,[])
print(ans)
Problem p02623 (python)

Fixed submission:
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ea=[0]
for i in range(n):
    ea.append(ea[i]+a[i])
eb=[0]
for i in range(m):
    eb.append(eb[i]+b[i])
tb=m
p=0
for i in range(n+1):
    while ea[i]+eb[tb]>k:
        if tb==0:
            break
        tb-=1
    if ea[i]+eb[tb]<=k:
        p=max(i+tb,p)
print(p)

Buggy submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ea=[0]
for i in range(n):
    ea.append(ea[i]+a[i])
eb=[0]
for i in range(m):
    eb.append(eb[i]+b[i])
tb=m
p=0
if n<m:
    ea,eb=eb,ea
    n,m=m,n
for i in range(n+1):
    while ea[i]+eb[tb]>k:
        if tb==0:
            break
        tb-=1
    if ea[i]+eb[tb]<=k:
        p=max(i+tb,p)
print(p)

Buggy submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
at,bt=0,0
p=0
while p<=k:
    if (n!=at and a[at]<b[bt]) or m==bt:
        p+=a[at]
        at+=1
    else:
        p+=b[bt]
        bt+=1
    if n==at and m==bt:
        print(at+bt)
        break
    #print(p)
else:
    print(at+bt-1)

Buggy submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
at,bt=0,0
p=0
while p<k:
    if (n!=at and a[at]<b[bt]) or m==bt:
        p+=a[at]
        at+=1
    else:
        p+=b[bt]
        bt+=1
    if n==at and m==bt:
        print(at+bt)
        break
    #print(p)
else:
    print(at+bt-1)

Buggy submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
at,bt=0,0
p=0
while p<k:
    if n!=at and a[at]<b[bt]:
        p+=a[at]
        at+=1
    else:
        p+=b[bt]
        bt+=1
    if n==at and m==bt:
        print(at+bt)
        break
    #print(p)
else:
    print(at+bt-1)
Problem p02661 (python)

Fixed submission:
n=int(input())
al=list()
bl=list()
for i in range(n):
    a,b=map(int,input().split())
    al.append(a)
    bl.append(b)
al.sort()
bl.sort()
l=n//2
if n%2==0:
    print(bl[l-1]+bl[l]-al[l-1]-al[l]+1)
else:
    print(bl[l]-al[l]+1)

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

Fixed submission:
a = input()
if a=='AAA' or a=='BBB':
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
a = input()
if a='AAA' or a='BBB':
  print('No')
else:
  print('Yes')
Problem p02773 (python)

Fixed submission:
d=dict()
for i in range(int(input())):
    s=input()
    if s not in d:
        d[s]=1
    else:
        d[s]+=1
max_v = max(d.values())
print(*sorted([kv[0] for kv in d.items() if kv[1] == max_v]))

Buggy submission (verdict: Runtime Error):
n=int(input())
a = []
for i in range(n):
    a.append(input())
a_count = [a.count(i) for i in a]
print('\n'.join(sorted(set([a[i] for i in range(len(a_count)) if a_count[i] == max(a_count)])))
Problem p02879 (python)

Fixed submission:
a,b=map(int, input().split())
if a<10 and b<10:
    print(a*b)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
a,b=map(int input().split())
if a<10 and b<10:
    print(a*b)
else:
    print(-1)
Problem p03013 (python)

Fixed submission:
n,m,*a=map(int,open(0).read().split())
mod=10**9+7
p=[1]
a=iter(a)
b=next(a,-1)
if 1==b:
    p.append(0)
    b=next(a,-1)
else:
    p.append(1)
for i in range(2,n+1):
    if i==b:
        p.append(0)
        b=next(a,-1)
    else:
        p.append((p[i-1]+p[i-2])%mod)
print(p[-1])

Buggy submission (verdict: Runtime Error):
n,m,*a=map(int,open(0).read().split())
mod=10**9+7
p=[1]
a=iter(a)
b=a.__next__()
if 1==b:
    p.append(0)
    b=next(a,-1)
else:
    p.append(1)
for i in range(2,n+1):
    if i==b:
        p.append(0)
        b=next(a,-1)
        print(i)
    else:
        p.append((p[i-1]+p[i-2])%mod)
print(p[-1])
Problem p03038 (python)

Fixed submission:
n,m=map(int,input().split())
a=sorted(map(int,input().split()))
l=list()
for i in range(m):
    l.append(list(map(int,input().split())))
l.sort(key=lambda x:-x[1])
i=0
for b,c in l:
    for j in range(b):
        if i+j<n and a[i+j]<c:
            a[i+j]=c
        else:
            print(sum(a))
            exit()
    i+=b
print(sum(a))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=sorted(map(int,input().split()))
l=list()
for i in range(m):
    l.append(list(map(int,input().split())))
l.sort(key=lambda x:-x[1])
i=0
for b,c in l:
    for j in range(b):
        if a[i+j]<c:
            a[i+j]=c
        else:
            print(sum(a))
            exit()
    i+=b
print(sum(a))
Problem p03127 (python)

Fixed submission:
def f(a,b):
    if b:
        return f(b,a%b)
    return a
n=int(input())
a=list(map(int,input().split()))
p=f(a[0],a[1])
for i in a:
    p=f(p,i)
print(p)

Buggy submission (verdict: Runtime Error):
def f(a,*b):
    if len(b)>1:
        return f(a,f(*b))
    b=b[0]
    if b:
        return f(b,a%b)
    return a
n=int(input())
a=list(map(int,input().split()))
print(f(*a))
Problem p03250 (python)

Fixed submission:
l = list(map(int, input().split()))
print(sum(l)+max(l)*9)

Buggy submission (verdict: Runtime Error):
l = list(map(int, input.split()))
print(sum(l)+max(l)*9)
Problem p02598 (python)

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
for i in range(1,31):
    if 2**i>=a[-1]+1:
        num=i
        break
ans=2**(num-1)
num1=2**(num-1)
l1=[]
for i in range(num+1):
    cnt=0
    for j in range(n):
        cnt+=-(a[j]//-ans)-1
    num1=num1//2
    if cnt>k:
        ans=min(a[-1],ans+num1)
    else:
        l1.append(ans)
        ans=max(1,ans-num1)
print(min(l1))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
for i in range(n):
    a[i]=[a[i],i]
for i in range(1,23):
    if 2**i>=n:
        num=i
        break
num2=2**(num-1)
ans=num2
ans2=0
for i in range(num):
    num3=0
    num4=a[ans-1][0]
    for j in range(ans,n):
        num3+=-(a[j][0]//-num4)-1
    num2=num2//2
    if num4>=k:
        ans=max(ans-num2,1)
        ans2=num3
    else:
        ans=min(ans+num2,n-1)
k-=ans2
num5=a[ans-1][0]
ans3=[0]*n
for i in range(ans,n):
    num6=-(a[i][0]//-num5)
    a[i][0]=a[i][0]/num6
    ans3[i]=num6
a.sort()
for i in range(k):
    ans3[a[-1][1]]+=1
    a[-1]/=ans3[a[-1][1]]
    a.sort()
print(-(a[-1][0])//-1)