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

Fixed submission:
i=int(input())
j=int(input())
a=6-(i+j)
print(str(a))

Buggy submission (verdict: Runtime Error):
s=input().split()
i=int(s[0])
j=int(s[1])
amari=[]
a=""
if i<j:
  p_1=j
  p_2=i
elif i==j:
  a=str(i)
elif i>j:
  p_1=i
  p_2=j
while a=="":
  am=p_1%p_2
  if am==0:
    break
  amari.append(am)
  p_1=p_2
  p_2=am
a=str(amari[-1])
print(a)

Buggy submission (verdict: Runtime Error):
i=int(input())
j=int(input())
print(str(6-(i+j))

Buggy submission (verdict: Runtime Error):
i=int(input())
j=int(input())
l=list(range(1,3,1))
l.remove(i)
l.remove(j)
a=l.pop(0)
print(a)

Buggy submission (verdict: Runtime Error):
i=int(input())
j=int(input())
ls=list(range(1,3))
ls.remove(i)
ls.remove(j)
a=ls.pop(0)
print(a)

Buggy submission (verdict: Runtime Error):
i=input()
i.splitlines()
ls=list(range(1,3))
ls.remove(i[0])
ls.remove(i[1])
a=ls.pop()
print(a)

Buggy submission (verdict: Runtime Error):
i=input()
i.splitlines()
ls=list(range(1,3))
ls.remove(int(i[0]))
ls.remove(int(i[1]))
print(ls.pop())

Buggy submission (verdict: Runtime Error):
i=input()
i.splitlines()
ls=list(range(1,3))
ls.remove(i[0])
ls.remove(i[1])
print(ls.pop())

Buggy submission (verdict: Runtime Error):
i=int(input())
j=int(input())
ls=range(1,3)
ls.remove(i)
ls.remove(j)
print(ls.pop())
Problem p02623 (python)

Fixed submission:
import math
import sys
import itertools
from math import gcd
from math import sqrt
from sys import stdin
def input() : return stdin.readline().rstrip()
def mips():
    return map(int,input().split())
def ii():
    return int(input())
sys.setrecursionlimit(10**9)

N,M,K = mips()
A = [i for i in mips()]
B = [i for i in mips()]
# N,M <= 200000
ans = 0
clock = K
A2 = [0]
B2 = [0]
for i in range(1,N+1):
    ai = A2[i-1] + A[i-1]
    A2.append(ai)
for i in range(1,M+1):
    bi = B2[i-1] + B[i-1]
    B2.append(bi)
j = M
for i in range(N+1):
    if A2[i] > K:
        break
    while (B2[j] + A2[i] > K):
        j -= 1
    ans = max(ans,i+j)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
import sys
import itertools
from math import gcd
from math import sqrt
from sys import stdin
def input() : return stdin.readline().rstrip()
def mips():
    return map(int,input().split())
def ii():
    return int(input())
sys.setrecursionlimit(10**9)

N,M,K = mips()
A = [i for i in mips()]
B = [i for i in mips()]
# N,M <= 200000
ans = 0
clock = K
A2 = [0]
B2 = [0]
for i in range(1,N+1):
    ai = A2[i-1] + A[i-1]
    A2.append(ai)
for i in range(1,M+1):
    bi = B2[i-1] + B[i-1]
    B2.append(bi)
for i in range(N+1):
    j = M
    if A2[i] > K:
        break
    while (B2[j] + A[i] > K):
        j -= 1
    ans = max(ans,i+j)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
import sys
import itertools
from math import gcd
from math import sqrt
from sys import stdin
def input() : return stdin.readline().rstrip()
def mips():
    return map(int,input().split())
def ii():
    return int(input())
sys.setrecursionlimit(10**9)

N,M,K = mips()
A = [i for i in mips()]
B = [i for i in mips()]
# N,M <= 200000
ans = 0
clock = K
A2 = [0]
B2 = [0]
for i in range(1,N+1):
    ai = A2[i-1] + A[i-1]
    A2.append(ai)
for i in range(1,M+1):
    bi = B2[i-1] + B[i-1]
    B2.append(bi)
for i in range(N+1):
    j = M
    if A[i] > K:
        break
    while (j >= 0):
        if A2[i] + B2[j] <= K:
            ans = max(ans,i+j)
        j -= 1
print(ans)
Problem p02659 (python)

Fixed submission:
from decimal import Decimal
A, B = map(Decimal, input().split())
print(int(A * B))

Buggy submission (verdict: Runtime Error):
><

Buggy submission (verdict: Runtime Error):
import math
A,B = map(float,input().split())
A = int(A)
if A == 0 or B == 0 :
    print(0)
else:
    ans = A*B
    i = math.floor(ans)-1
    while True : 
        if i <= ans and i+1 > ans:
            print(i)
            sys.exit(0)
        i += 1
Problem p02754 (python)

Fixed submission:
N,A,B = map(int,input().split())
R = N%(A+B)
res = (N//(A+B))*A
if R == 0:
  print(res)
else:
  if R<A:
    print(res+R)
  else:
    print(res+A)

Buggy submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
goal = ''
if A == 0:
  print(0)
if B == 0 and A != 0:
  print(N)
if A != 0:
  howmany = (N//min(A,B)) + 1
  for i in range(howmany):
    goal += A*"b"
    goal += B*"r"
  print(goal[0:N].count("b"))

Buggy submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
file = ''
while len(file) <= N+1:
  file += A*"b"
  file += B*"r"
res = file[0:N]
blue = res.count("b")
print(blue)
Problem p02831 (python)

Fixed submission:
def PGCD(a,b):
    while b!=0:
        a,b=b,a%b
    return a
def ppcm(a,b):
    return a*b//PGCD(a,b)
A,B = map(int,input().split())
print(ppcm(A,B))

Buggy submission (verdict: Runtime Error):
import math
def ppcm(x,y):
    return (x*y) // math.gcd(x,y)
A,B = map(int,input().split())
print(ppcm(A,B))
Problem p02832 (python)

Fixed submission:
N = int(input())
k = 0
for x in map(int,input().split()):
    if x == k + 1:
        k += 1
print(N-k if k else -1)

Buggy submission (verdict: Runtime Error):
N = int(input())
List_Bricks = [int(i) for i in input().split()]
#print(List_Bricks)
Search = 1
Kudaku = 0
i = 0
Boole = False
Count = 0
L = len(List_Bricks)-1
while len(List_Bricks) != 1:
    try:
        del List_Bricks[0:List_Bricks.index(Search)]
    except ValueError:
        pass
    Kudaku += List_Bricks.index(Search)
    Search += 1
Problem p02836 (python)

Fixed submission:
S = input()
a = len(S)
k1 = ''
k2 = ''
res = 0
if a % 2 == 0:
    for i in range(0,a//2):
        k1 += S[i]
    for i in range(a//2,a):
        k2 += S[i]
else:
    for i in range(0,(a-1)//2):
        k1 += S[i]
    for i in range((a-1)//2 + 1,a):
        k2 += S[i]
for i in range(len(k1)):
    if k1[i] != k2[(len(k1)-i-1)]:
        res += 1 
print(res)

Buggy submission (verdict: Runtime Error):
#include <stdio.h>
#include <string.h>
char s[101];
int main(void)
{
    scanf("%s",s);
    int res = 0;
    int i;
    int n = strlen(s);
    for (i=0;i<n;i++)
    {
        if (s[i] != s[n-i-1]) res++;
    }
    printf("%d\n",res/2);
}
Problem p02951 (python)

Fixed submission:
A,B,C = map(int,input().split())
if (A-B) >= C:
	print(0)
else:
 	print(C-(A-B))

Buggy submission (verdict: Runtime Error):
A,B,C = map(int,input().split())
if (A-B) >= C:
	print(0)
else:
  prnt(C-(A-B))
Problem p03013 (python)

Fixed submission:
import sys
N,M = map(int,input().split())
intact = [True for _ in range(N)]
dp = [0 for _ in range(N+1)]
MOD = 1000000007
for i in range(M):
  a = int(input())
  intact[a] = False
if N == 1:
  print(1)
  sys.exit(0)
dp[0] = 1
if (intact[1]):
  dp[1] = 1
for i in range(2,N+1):
  if intact[i-2]:
    dp[i] += dp[i-2]
  if intact[i-1]:
    dp[i] += dp[i-1]
  dp[i] %= MOD
print(dp[N])

Buggy submission (verdict: Runtime Error):
import sys
N,M = map(int,input().split())
intact = [True for _ in range(N)]
dp = [0 for _ in range(N+1)]
MOD = 1000000007
for i in range(M):
  a = int(input())
  if N == 1:
    print(1)
    sys.exit(0)
  intact[a] = False
dp[0] = 1
if (intact[1]):
  dp[1] = 1
for i in range(2,N+1):
  if intact[i-2]:
    dp[i] += dp[i-2]
  if intact[i-1]:
    dp[i] += dp[i-1]
  dp[i] %= MOD
print(dp[N])

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
intact = [True for _ in range(N)]
dp = [0 for _ in range(N+1)]
MOD = 1000000007
for i in range(M):
  a = int(input())
  intact[a] = False
dp[0] = 1
if (intact[1]):
  dp[1] = 1
for i in range(2,N+1):
  if intact[i-2]:
    dp[i] += dp[i-2]
  if intact[i-1]:
    dp[i] += dp[i-1]
  dp[i] %= MOD
print(dp[N])
Problem p03041 (python)

Fixed submission:
N,K = map(int,input().split())
a = input()
res = ''
S = [el for el in a]
if S[K-1] == 'A':
  S[K-1] = 'a'
elif S[K-1] == 'B':
  S[K-1] = 'b'
elif S[K-1] == 'C':
  S[K-1] = 'c'
for el in S:
  res += el
print(res)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
S = input()
if S[K-1] == 'A':
  S[K-1] = 'a'
elif S[K-1] == 'B':
  S[K-1] = 'b'
elif S[K-1] == 'C':
  S[K-1] = 'c'
print(S)
Problem p03127 (python)

Fixed submission:
from functools import reduce
import fractions 
N = int(input())
L = [i for i in map(int,input().split())]
def gcd_list(numbers):
  return reduce(fractions.gcd,numbers)
print(gcd_list(L))

Buggy submission (verdict: Runtime Error):
from functools import reduce
import fractions 
N = int(input())
L = [i for i in map(int,input().split())]
def gcd_list(numbers):
  return reduce(fractions.gcd(),numbers)
prind(gcd_list(L))
Problem p03242 (python)

Fixed submission:
n = input()
s = ''
for c in n:
  if c == '1':
    s += '9'
  else:
    if c == '9':
        s += '1'
    else:
        s += c
print(s)

Buggy submission (verdict: Runtime Error):
n = input()
s = ''
for c in n:
  if c == '1':
    s += '9'
  else:
  	if c == '9':
    	s += '1'
    else:
      s += c
print(s)
Problem p03835 (python)

Fixed submission:
K,S = map(int,input().split())
print(sum([0<=S-X-Y<=K for X in range(0,K+1) for Y in range(0,K+1)]))

Buggy submission (verdict: Runtime Error):
K,S = map(int,input().split())
res = 0
for X in range(0,K+1):
    if X > S:
        break
    for Y in range(0,K+1):
        if X + Y > S:
            break
        elif 0<=(S-X-Y) and (S-X-Y)) <= K:
            res += 1
print(res)
Problem p02623 (python)

Fixed submission:
import itertools
def main():
    n,m,k=map(int, input().split())
    a=[int(i) for i in input().split()]
    b=[int(i) for i in input().split()]
    a = [0]+list(itertools.accumulate(a))
    b = [0]+list(itertools.accumulate(b))
    res = 0
    j = m
    best=0
    for i in range(n+1):
        if(a[i]>k):
            break
        while(b[j] > k-a[i]):
            j-=1
        res = max(res,i+j)
    print(res)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import itertools
def main():
    n,m,k=map(int, input().split())
    a=[int(i) for i in input().split()]
    b=[int(i) for i in input().split()]

    ia = n-1
    res = n
    ib = 0
    time = sum(a)

    while(ia>=0 and ib<m):

      if(time > k):
            time -= (a[ia])
            res-=1
            ia-=1
        elif(time+b[ib]<=k):
            time += (b[ib])
            res+=1
            ib+=1
        else:
            break

    print(res)

if __name__ == '__main__':
    main()
Problem p02835 (python)

Fixed submission:

def main1():
    n,m,c=map(int, input().split())
    if(n+m+c>21):print("bust")
    else:print("win")


if __name__ == '__main__':
    main1()

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
def main2():
    ketaone = [0]*61
    MOD = 10**9 + 7
    n = int(input())
    A=[int(i) for i in input().split()]

    for i in A:
        for j in range(61):
            if i&(1<<j):
                ketaone[j]+=1
    res = 0

    for i in range(61):
        res = res + (ketaone[i]*(n-ketaone[i])*(2**i))%MOD
        res%=MOD
    print(res)


def main1():
    n = int(input())
    lis = [[] for _ in range(n)]
    for i in range(n):
        a = int(input())
        for j in range(a):
            lis[i].append(list(map(int, input().split())))
    res = 0

    for i in range(1<<n):
        f = True
        uso=set()
        syo=set()
        tmp=0
        for j in range(n):
            if(i&(1<<j)):
                tmp+=1
                for k in lis[j]:
                    if (i&(1<<(k[0]-1))) and k[1]==0:
                        f=False
                    if k[1]==1 and not (i&(1<<k[0]-1)):
                        f=False
        if f:
            res = max(res,tmp)
    print(res)


if __name__ == '__main__':
    main2()
Problem p02862 (python)

Fixed submission:
X,Y=map(int, input().split())

MOD = 10**9 + 7
def prepare(n, MOD):

    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return factorials, invs
if (X+Y)%3!=0:
    print(0)
else:
    #最初に行き方を決めて、使う移動方法の個数を求めて、重複組み合わせ
    #決め打ちしてから n:2x+yの移動　m:x+2yの移動
    n = (2*X-Y)//3
    m = (2*Y-X)//3

    if n<0 or m<0:
        print(0)
        exit()


    fac, invs = prepare((n+m), MOD)


    print(fac[n+m]*invs[n]*invs[m]%MOD)

Buggy submission (verdict: Runtime Error):
X,Y=map(int, input().split())

MOD = 10**9 + 7
def prepare(n, MOD):

    # 1! - n! の計算
    f = 1
    factorials = [1]  # 0!の分
    for m in range(1, n + 1):
        f *= m
        f %= MOD
        factorials.append(f)
    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return factorials, invs
if (X+Y)%3!=0:
    print(0)
else:
    #最初に行き方を決めて、使う移動方法の個数を求めて、重複組み合わせ
    #決め打ちしてから n:2x+yの移動　m:x+2yの移動
    n = (2*X-Y)//3
    m = (2*Y-X)//3


    fac, invs = prepare((n+m), MOD)


    print(fac[n+m]*invs[n]*invs[m]%MOD)
Problem p03038 (python)

Fixed submission:
n,m=map(int, input().split())
A=[int(i) for i in input().split()]
tmp = min(A)
A.sort()
ab=[]
for i in range(m):
    b,c=map(int, input().split())
    if not c<tmp:
        ab.append([b, c])
ab.sort(key=lambda x:x[1], reverse = True)
f=False
a = 0
for i in range(len(ab)):
    for j in range(min(ab[i][0], n)):
        if A[a]>ab[i][1]:
            f=True
            break
        A[a]=ab[i][1]
        a+=1
        if a==n:
            f=True
            break
    if f==True:break
print(sum(A))

Buggy submission (verdict: Runtime Error):
n,m=map(int, input().split())
A=[int(i) for i in input().split()]
A.sort()
bc=[]
for i in range(m):
    b,c=map(int, input().split())
    bc.append([b,c])
bc.sort(key = lambda x:x[1], reverse=True)
count=0
for i in bc:
    for j in range(i[0]):
        if A[count]<i[1]:
            A[count]=i[1]
            count+=1
        else:
            break
        if count==n:
            break
print(sum(A))

Buggy submission (verdict: Runtime Error):
n,m=map(int, input().split())
A=[int(i) for i in input().split()]
A.sort()
bc=[]
for i in range(m):
    b,c=map(int, input().split())
    bc.append([b,c])
bc.sort(key = lambda x:x[1], reverse=True)
count=0
for i in bc:
    for j in range(i[0]):
        if A[count]<i[1]:
            A[count]=i[1]
            count+=1
        else:
            break
print(sum(A))
Problem p03042 (python)

Fixed submission:
def main():
    s  = int(input())
    k = s//100
    t = s%100

    if(k>0 and k<13) and (t>0 and t<13):
        res = "AMBIGUOUS"
    elif(k>0 and k<13):
        res = "MMYY"
    elif(t>0 and t<13):
        res = "YYMM"
    else:
        res = "NA"
    print(res)






if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    s  = int(input())
    k = s//100
    t = s%100

    if(k>0 and k<13) and (t>0 and t<13):
        res = "AMBIGUOUS"
    elif(k>0 and k<13) and
        res = "MMYY"
    elif(t>0 and t<13):
        res = "YYMM"
    else:
        res = "NA"
    print(res)






if __name__ == '__main__':
    main()
Problem p03104 (python)

Fixed submission:
def main():
    a,b = map(int, input().split())
    n = (b-a+1)#要素数
    k = n//2

    if n%2==0:
        if a%2==0:
            if k%2==0:
                res = 0
            else:
                res =1
        else:
            k = (n-2)//2
            if k%2 == 1:
                res=(a^b^1)
            else:
                res = a^b
    else:
        if a%2 == 0:
            if k%2 == 0:
                res = (b)
            else:
                res = b^1
        else:
            if k%2==1:
                res = a^1
            else:
                res = a
    print(res)





if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
a,b=map(int, input().split())
ans=a
if(b-a==0):
    print(b)
    exit()
#[2, 3, 4]a=2, b=4
#[1, 2, 3]
if(b-a+1)%2==1:#中が奇数こ
    if a%2==0:
        print(b^((b-a)//2)%2)
    else:
        print(a^((b-a)//2)%2)

#[2, 3, 4, 5]
#[1, 2, 3, 4]
else:
    if a%2==1:
        print(a^b^((b-a-1)/2)%2)
    else:
        print(0)
Problem p03137 (python)

Fixed submission:
import itertools
n,m=map(int, input().split())
x=[int(i) for i in input().split()]
x.sort()
if(n>=m):
    print(0)
    exit()
dist = abs(x[-1]-x[0])

diff = []

for i in range(m-1):
    diff.append([abs(x[i]-x[i+1]),i])

diff.sort(key = lambda x:x[0],reverse = True)
for i in range(n-1):
    dist-=diff[i][0]
print(dist)

Buggy submission (verdict: Runtime Error):
n,m=map(int, input().split())
x=[int(i) for i in input().split()]
x.sort()
dist = abs(x[-1]-x[0])
diff = []

for i in range(m-1):
    diff.append([abs(x[i]-x[i+1]),i])

diff.sort(key = lambda x:x[0],reverse = True)
for i in range(n-1):
    dist-=diff[i][0]
print(dist)
Problem p03634 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
n = int(input())
visited = [0]*n
def dfs(edge, dist, k):
    visited[k]=1
    for i in edge[k]:
        if visited[i[0]]==0:
            dist[i[0]]=i[1]+dist[k]
            dfs(edge, dist, i[0])


    return dist
def main():
    edge = [[] for _ in range(n)]
    for i in range(n-1):
        a,b,c=map(int, input().split())
        edge[a-1].append([b-1,c])
        edge[b-1].append([a-1,c])

    q,k=map(int, input().split())
    #頂点kから各頂点への距離を最初に求めておくdist[i]:頂点kから頂点iまでの距離　 dist[k]=0
    dist = [0]*n
    visited[k-1]=1
    dist = dfs(edge, dist, k-1)

    res = [0]*q
    for i in range(q):
        x,y=map(int, input().split())
        res[i]=dist[x-1]+dist[y-1]


    for i in range(q):
        print(res[i])
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
n = int(input())
visited = [0]*n
def dfs(edge, dist, k):
    visited[k]=1
    for i in edge[k]:
        if visited[i[0]]==0:
            dist[i[0]]=i[1]+dist[k]
            dfs(edge, dist, i[0])


    return dist
def main():
    edge = [[] for _ in range(n)]
    for i in range(n-1):
        a,b,c=map(int, input().split())
        edge[a-1].append([b-1,c])
        edge[b-1].append([a-1,c])

    q,k=map(int, input().split())
    #頂点kから各頂点への距離を最初に求めておくdist[i]:頂点kから頂点iまでの距離　 dist[k]=0
    dist = [0]*n
    visited[k-1]=1
    dist = dfs(edge, dist, k-1)

    res = [0]*q
    for i in range(q):
        x,y=map(int, input().split())
        res[i]=dist[x-1]+dist[y-1]


    for i in range(q):
        print(res[i])
if __name__ == '__main__':
    main()
Problem p03705 (python)

Fixed submission:
n,a,b=map(int, input().split())
pot = b-a+1
if(b<a):
    print(0)
    exit()
if n==0:
    print(0)
elif n==1:
    if a==b:
        print(1)
    else:print(0)
elif n==2:
    if a==b:print(1)
    print(1)
else:
    k = n-1
    m = k*b
    high = m+a
    low = a*k + b
    print(high-low+1)

Buggy submission (verdict: Runtime Error):
n,a,b=map(int, input().split())
pot = b-a+1
if(b<a):
    print(0)
    exit()
if n==0:
    print(0)
elif n==1:
    if a==b:
        print(1)
    else:print(0)
elif n==2:
    if a==b:print(1)
    print(1)
else:
    k = n-2
    ans=0

    for i in range(k):
        ans+=pot
        pot-=1
    print(ans)
Problem p02598 (python)

Fixed submission:
import sys
readline = sys.stdin.readline
 
N, K = map(int, readline().split())
A = list(map(int, readline().split()))
 
l = 0
r = 10**10
 
def test(m):
  return sum((a + m - 1) // m for a in A) - N <= K

while l + 1 < r:
  m = (l + r) // 2
  if test(m):
  	r = m
  else:
    l = m
print(r)

Buggy submission (verdict: Runtime Error):
import sys
readline = sys.stdin.readline
 
N, K = map(int, readline.split())
A = list(map(int, readline().split()))
 
l = 0, r = 10**10
 
def test(m):
  return sum((a + m - 1) // m for a in A) <= K

while l + 1 < r:
  m = (l + r) // 2
  if test(m):
  	r = m
  else:
    l = m
print(r)

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

N, K = map(int, readline.split())
A = list(map(int, readline().split()))

l = 0, r = 10**10

def test(m):
	return sum((a + m - 1) // m for a in A) <= K

while l + 1 < r:
	m = (l + r) // 2
   	if test(m):
      	r = m
    else:
      	l = m

print(r)
Problem p02754 (python)

Fixed submission:
n, a, b = map(int, input().split())
if a == 0 and b == 0:
    print(0)
    exit()
if n % (a + b) < a:
    bcnt = n % (a+b)
else:
    bcnt = a
print(n // (a + b) * a + bcnt)

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
s = "b" * a + "r" * b
if a == 0 and b == 0:
    print(0)
if s[n % (a + b)] == "b":
    bcnt = n % (a+b)
else:
    bcnt = a
print(n // (a + b) * a + bcnt)
Problem p02833 (python)

Fixed submission:
n = int(input())
if n % 2 == 1:
    print(0)
else:
    cnt = 0
    a = n // 2 // 5
    b = 0
    while a >= 5 ** b:
        cnt += a // 5**b
        b += 1
    print(cnt)

Buggy submission (verdict: Runtime Error):
if n % 2 == 1:
    print(0)
else:
    cnt = 0
    a = n // 2 // 5
    b = 0
    while a >= 5 ** b:
        cnt += a // 5**b
        b += 1
    print(cnt)
Problem p03617 (python)

Fixed submission:
q, h, s, d = map(int, input().split())
n = int(input())
h = min(q*2, h)
s = min(h*2, s)
d = min(s*2, d)
if n % 2 == 0:
  print(min(s*n, d*(n//2)))
else:
  print(min(s*n, d*(n//2)+s))

Buggy submission (verdict: Runtime Error):
q, h, s, d = map(int, input().split())
n = int(input())
n4 = n * 4
# jリットルになるようにしたi番目までの総和最小値
# dp[i][j] = 
w = [1, 2, 4, 8]
v = [q, h, s, d]
dp = [[10**8+1]*(n4+1) for i in range(4)]
for i in range(4):
  dp[i][0] = 0
for i in range(4):
  for j in range(n4+1):
    if j >= w[i] and i >= 1:
      dp[i][j] = min(dp[i-1][j], dp[i][j-w[i]] + v[i])
    else:
      dp[i][j] = dp[i-1][j]
print(dp[3][n4])

Buggy submission (verdict: Runtime Error):
q, h, s, d = map(int, input().split())
n = int(input())
n4 = n * 4
# jリットルになるようにしたi番目までの総和最小値
# dp[i][j] = 
w = [1, 2, 4, 8]
v = [q, h, s, d]
dp = [[10**9]*(n4+1) for i in range(4)]
for i in range(4):
  dp[i][0] = 0
for i in range(4):
  for j in range(n4+1):
    if j >= w[i]:
      dp[i][j] = min(dp[i-1][j], dp[i][j-w[i]] + v[i])
    else:
      dp[i][j] = dp[i-1][j]
print(dp[3][n4])
Problem p02580 (python)

Fixed submission:
#!/usr/bin/env python3
h, w, m = map(int, input().split())
r = [0] * (h + 1)
c = [0] * (w + 1)
s = []
for _ in range(m):
    x, y = map(int, input().split())
    r[x] += 1
    c[y] += 1
    s.append([x, y])
R = max(r)
nr = {i for i, x in enumerate(r) if x == R}
C = max(c)
nc = {i for i, x in enumerate(c) if x == C}
count = 0
for x, y in s:
    count += x in nr and y in nc
print(R + C - (len(nr) * len(nc) == count))

Buggy submission (verdict: Runtime Error):
(h,w,m),*s=[[*map(int,i.split())]for i in open(0)]
r,c=[0]*-~h,[0]*-~w
for x,y in s:
    r[x]+=1
    c[y]+=1
print((R:=max(r))+(C:=max(c))-(r.count(R)*c.count(C)==sum(r[x]+c[y]==R+C for x,y in s)))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import numpy as np

h, w, m = map(int, input().split())
a = np.zeros((h, w), dtype=np.int64)
b = [[*map(lambda x: int(x) - 1, input().split())] for _ in range(m)]
for x, y in b:
    a[x, :] += 1
    a[:, y] += 1
    a[x][y] -= 1
print(np.max(a))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import numpy as np

h, w, m = map(int, input().split())
a = np.zeros((h, w), dtype=np.int64)
b = [[*map(lambda x: int(x) - 1, input().split())] for _ in range(m)]
for x, y in b:
    c = np.zeros((h, w), dtype=np.int64)
    c[x, :] = 1
    c[:, y] = 1
    a = a + c
print(np.max(a))
Problem p02623 (python)

Fixed submission:
#!/usr/bin/env python3
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
A = [0]
B = [0]
for i in range(n):
    A.append(A[i] + a[i])
for i in range(m):
    B.append(B[i] + b[i])
ans = 0
j = m
for i in range(n + 1):
    if A[i] > k:
        break
    while j > 0 and k - A[i] < B[j]:
        j -= 1
    ans = max(ans, i + j)

print(ans)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
n, m, k = map(int, input().split())
a = [0] + list(map(int, input().split()))
b = [0] + list(map(int, input().split()))
for i in range(1, n + 1):
    a[i] = a[i - 1] + a[i]

for i in range(1, m + 1):
    b[i] = b[i - 1] + b[i]
ans = 0
t = 0
j = 0
for i in range(n + 1):
    while j < m + 1 and k - a[i] >= b[j]:
        j += 1
    j -= 1
    ans = max(ans, i + j)

print(ans)