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

Fixed submission:
# -*- coding: utf-8 -*-


# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    a, b = input_to_int_map()
    import itertools
    _a = "".join(itertools.repeat(str(a), b))
    _b = "".join(itertools.repeat(str(b), a))
    ret = _b
    if _a < _b:
        ret = _a

    return ret


if __name__ == "__main__":
    print(main())

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


# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    a, b = input_to_int_map()
    import itertools
    _a = itertools.repeat(str(a), b)
    _b = itertools.repeat(str(b), a)
    ret = _b
    if _a < _b:
        ret = _a

    return ret


if __name__ == "__main__":
    print(main())
Problem p02725 (python)

Fixed submission:
import numpy as np

k, n = map(int,input().split())
a = np.array(list(map(int, input().split())))
diff = a[1:] - a[:-1]
diff = np.append(diff, k - a[-1] + a[0])
if np.argmax(diff) == len(a) - 1:
    print(a[-1] - a[0])
else:
    print(k - a[np.argmax(diff) + 1] + a[np.argmax(diff)])

Buggy submission (verdict: Runtime Error):
if a[0] == 0:
    print(a[len(a) - 1] - a[1])
else:
    print(a[len(a) - 1] - a[0])
Problem p02880 (python)

Fixed submission:
N=int(input())

for i in reversed(range(1,10)):
    if N%i==0:
        if N/i > 9:
            print('No')
            exit(0)
        else:
            print('Yes')
            exit(0)

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

for i in reversed(range(1,10)):
    print(i)
    if N%i==0:
        if N/i > 9:
            print('No')
            exit(1)
        else:
            print('Yes')
            exit(1)

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

for i in reversed(range(1,10)):
    if N%i==0:
        if N/i > 9:
            print('No')
            exit(0)
    print('Yes')
    exit(1)

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

for i in reversed(range(1,10)):
    if N%i==0:
        if N/i > 9:
            print('No')
            exit(1)
    print('Yes')
    exit(1)
Problem p02598 (python)

Fixed submission:
#!/usr/bin/env pypy3

import math

def num_cuts(A, ml):
	ret = 0
	for a in A:
		ret += (math.ceil(a / ml) - 1)
	return ret

def ok(A, ml):
	return num_cuts(A, ml) <= K

def ans(A, K):

	low = min(A) / (K+5)
	high = max(A)+1

	assert(not(ok(A, low)))
	assert(ok(A, high))

	while (high - low) > 0.1:
		mid = (low + high) / 2
		if ok(A, mid):
			high = mid
		else:
			low = mid

	low = max(1, math.floor(low) - 5)

	for i in range(100):
		p = low + i/2
		if ok(A, p):
			return math.ceil(p)

	assert(False)


N, K = input().split()
N = int(N)
K = int(K)

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

print(ans(A, K))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env pypy3

import math

def num_cuts(A, ml):
	if ml == 0:
		while True:
			continue
			
	ret = 0
	for a in A:
		ret += (math.ceil(a / ml) - 1)
	return ret

def ok(A, ml):
	return num_cuts(A, ml) <= K

def ans(A, K):

	low = 0.5
	high = max(A)+1

	assert(not(ok(A, low)))
	assert(ok(A, high))

	while (high - low) > 0.1:
		mid = (low + high) / 2
		if ok(A, mid):
			high = mid
		else:
			low = mid

	low = max(1, math.floor(low) - 5)

	for i in range(100):
		p = low + i/3
		q = low + (i+1) / 3

		if not(ok(A, p)) and ok(A, q):
			return math.ceil(q)


N, K = input().split()
N = int(N)
K = int(K)

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

print(ans(A, K))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env pypy3

import math

def num_cuts(A, ml):
	ret = 0
	for a in A:
		ret += (math.ceil(a / ml) - 1)
	return ret

def ok(A, ml):
	return num_cuts(A, ml) <= K

def ans(A, K):

	low = 0.5
	high = max(A)+1

	assert(not(ok(A, low)))
	assert(ok(A, high))

	while (high - low) > 0.1:
		mid = (low + high) / 2
		if ok(A, mid):
			high = mid
		else:
			low = mid

	low = max(1, math.floor(low) - 5)

	for i in range(100):
		p = low + i/3
		q = low + (i+1) / 3

		if not(ok(A, p)) and ok(A, q):
			return math.ceil(q)


N, K = input().split()
N = int(N)
K = int(K)

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

print(ans(A, K))
Problem p02754 (python)

Fixed submission:
#!/bin/bash
''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/g.inp"
exit $?
'''
import sys

def _ia(): return [ int(x) for x in sys.stdin.readline().strip().split() ]


def main():
    n, a, b = _ia()
    #
    ab = n//(a+b)
    cnt = a * ab
    print(cnt + min(n-(a+b)*ab, a))


if __name__=="__main__":
    main()

Buggy submission (verdict: Runtime Error):
#!/bin/bash
''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/g.inp"
exit $?
'''
import sys
import math

def _ia(): return [ int(x) for x in sys.stdin.readline().strip().split() ]


def main():
    n, a, b = _ia()
    count = math.ceil(n/(a+b))
    ball = []
    for _ in range(count):
        ball += ["b"] * a
        ball += ["r"] * b
    print(ball[:n].count("b"))



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

Fixed submission:
import sys


def _s(): return sys.stdin.readline().strip()


def _ia(): return map(int, sys.stdin.readline().strip().split())


n, p = _ia()
u = [1 if i == 0 else 0 for i in range(p)]
s = _s()
cnt = 0
if p == 2 or p == 5:
    for i, c in enumerate(s):
        if int(c) % p == 0:
            cnt += i + 1
else:
    b = 1
    m10 = 10 % p
    prev = 0
    for c in s[::-1]:
        ui = prev = (prev + int(c) * b) % p
        b = (b*m10) % p
        cnt += u[ui]
        u[ui] += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
import sys


def _i(): return int(sys.stdin.readline().strip())


def _ia(): return [int(x) for x in sys.stdin.readline().strip().split()]


def main():
    n, p = _ia()
    u = [1 if i == 0 else 0 for i in range(p)]
    s = _i()
    cnt = 0
    if p == 2 or p == 5:
        for i, c in enumerate(s):
            if int(c) % p == 0:
                cnt += i + 1
        return cnt

    m = 10
    for _ in range(n):
        ui = (s % m) % p
        cnt += u[ui]
        u[ui] += 1
        m *= 10

    return cnt


if __name__ == "__main__":
    print(main())
Problem p02863 (python)

Fixed submission:
#!/usr/bin/env python
import sys
from operator import itemgetter

def _ia(): return [ int(x) for x in sys.stdin.readline().strip().split() ]

n,t = _ia()
ab = []
for i in range(n): ab.append(_ia())
ab.sort(key=itemgetter(0))
#
bmax= ab[0][0]
dp = [ [0]*(t) for _ in range(n) ]
for i in range(n-1):
    a,b = ab[i]
    
    prev = dp[i]
    dnew = dp[i+1]
    for atot in range(t):
        if atot>=a: dnew[atot] = max(prev[atot],prev[atot-a]+b)
        else: dnew[atot] = prev[atot]
    #
    bmax = max(bmax,prev[-1]+b)
#
print(max(bmax,dp[-1][-1]+ab[-1][1]))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
import sys

def _ia(): return [ int(x) for x in sys.stdin.readline().strip().split() ]

n,t = _ia()
ab = []
imax = -1
amax = -1
bmax = -1
for i in range(n):
    _a,_b = _ia()
    ab.append((_a,_b))
    if bmax<0 or (_b>=bmax and _a>ab[imax][0]):
        imax = i
        amax = _a
        bmax = _b
#
dp = [ 0 ] * (t+1)
for i, _ab in enumerate(ab):
    if i==imax: continue
    a,b = _ab
    prev = dp.copy()
    for atot in range(t+1):
        if atot>=a:
            dp[atot] = max(prev[atot],prev[atot-a]+b)
        else:
            dp[atot] = prev[atot]
#
print(max(dp[t-1]+bmax,dp[t]))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
import sys

def _ia(): return [ int(x) for x in sys.stdin.readline().strip().split() ]

n,t = _ia()
ab = []
asum = 1
imax = -1
amax = -1
bmax = -1
for i in range(n):
    _a,_b = _ia()
    ab.append((_a,_b))
    asum += _a
    if bmax<0 or (_b>=bmax and _a>ab[imax][0]):
        imax = i
        amax = _a
        bmax = _b
#
dp = [ 0 ] * (asum)
for i, _ab in enumerate(ab):
    if i==imax: continue
    a,b = _ab
    prev = dp.copy()
    for atot in range(asum):
        if atot>=a:
            dp[atot] = max(prev[atot],prev[atot-a]+b)
        else:
            dp[atot] = prev[atot]
#
if t>asum:
    print(dp[-1]+bmax)
else:
    print(max(dp[t-1]+bmax,dp[t]))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
import sys

def _ia(): return [ int(x) for x in sys.stdin.readline().strip().split() ]

n,t = _ia()
ab = []
asum = 1
imax = -1
amax = -1
bmax = -1
for i in range(n):
    _a,_b = _ia()
    ab.append((_a,_b))
    asum += _a
    if bmax<0 or (_b>=bmax and _a>ab[i-1][0]):
        imax = i
        amax = _a
        bmax = _b
#
del(ab[imax])
asum -= amax
dp = [ 0 ] * (asum)
for a, b in ab:
    prev = dp.copy()
    for atot in range(asum):
        if atot>=a: dp[atot] = max(prev[atot],prev[atot-a]+b)
        else: dp[atot] = prev[atot]
#
if t>asum: print(dp[-1]+bmax)
else: print(max(dp[t-1]+bmax,dp[t]))
Problem p03018 (python)

Fixed submission:
#!/usr/bin/env python

import sys
import re

s= sys.stdin.readline().strip()
s= s.replace("BC","D")
s= re.sub("[BC]+"," ",s).split()

t= 0
for seg in s:
    a= 0
    for c in seg:
        if c=="A": a+=1
        elif c=="D": t+= a
#
print( t )

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python

import sys
import re

_,a,b,c,d = [ int(x)-1 for x in sys.stdin.readline().split() ]
m = sys.stdin.readline().strip()
#
loc= []
for match in re.finditer( "##",m ): loc.append( match.start() )
if c>d:
    if m[b-1:b+2]!="..." and m[b+1:d+1].find("..")<0:
        print( "No" )
        exit()
#
# check b->d
flag= False
ii= b+1
jj= d-2
if ii<=jj:
    for l in loc:
        if ii<=l<=jj:
            flag=True
            break
if flag:
    print( "No" )
    exit()
#
# check a->c
ii= a+1
jj= c-2
if ii<=jj:
    for l in loc:
        if ii<=l<=jj:
            flag=True
            break
#
if flag:
    print( "No" )
    exit()
#
print( "Yes" )
Problem p02578 (python)

Fixed submission:
n=int(input())

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


s=0
for i in range(1,n):
    if row[i-1]>row[i]:
        s+=row[i-1]-row[i]
        row[i]=row[i-1]
print(s)

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

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

for i in range(len(a)-1):
    if a[i]>a[+1]:
        s+=0
    else:
        s+=a[i+1]-a[i]

print(s)
Problem p02693 (python)

Fixed submission:
K=int(input())
A,B=map(int,input().split())
i=0
import sys

while K*i<=B:



    if A<=K*i and K*i<=B:

        print("OK")

        sys.exit()
    else:
        i+=1

print("NG")

Buggy submission (verdict: Runtime Error):
a,b,n=map(int,input().split())
m=0
if n<=(10**7):


    for x in range(n+1):
        l=int(a*x/b)-a*int(x/b)

        if l>=m:

            m=l

else:
    for x in range(10**6,n+1):


        l=int(a*x/b)-a*int(x/b)
        if l>m:

            m=l
print(m)
Problem p02699 (python)

Fixed submission:
n,m=map(int,input().split())

if m>=n:

    print('unsafe')

else:
    print('safe')

Buggy submission (verdict: Runtime Error):
n,m=map(int,input())

if m>=n:

    print('unsafe')

else:
    print('safe')

Buggy submission (verdict: Runtime Error):
n,m=map(int,input())

if m>=n:

    print('unsafe')

else:
    print('safe')
Problem p02771 (python)

Fixed submission:
a=[]
a=list(map(int,input().split()))
a=set(a)

if len(a)==2:

    print("Yes")

else:print("No")

Buggy submission (verdict: Runtime Error):

n=int(input())
a=[]
b=[]
c=[]
a=list(map(int,input().split()))


for i in range(n):

    if a[i]%2==0:
        b.append(a[i])

    else:pass


for k in range(len(b)):

    if b[k]%3==0 or b[k]%5==0:

        c.append(b[k])

if len(b)==len(c):

    print("APPROVED")

else:
    print("DENIED")
Problem p02729 (python)

Fixed submission:
N,M = map(int,input().split())

import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
if N < 2:
    base = 0
else:
    base = comb(N,2)
    
if M < 2:
    base2 = 0
else:
    
    base2 = comb(M,2)

print(base+base2)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())

from scipy.special import comb
base = comb(N, 2, exact=True)
base2 = comb(M, 2, exact=True)
print(base+base2)
Problem p02785 (python)

Fixed submission:
import sys
read = sys.stdin.buffer.read#全部読み込むやつ
readline = sys.stdin.buffer.readline#1行読み込むやつ
readlines = sys.stdin.buffer.readlines#リストで読み込むらしい

N,K,*H = map(int,read().split())
N -= K
if N <= 0:
    print(0)
    exit()
    
H.sort()
    
print(sum(H[: N]))

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read#全部読み込むやつ
readline = sys.stdin.buffer.readline#1行読み込むやつ
readlines = sys.stdin.buffer.readlines#リストで読み込むらしい

N,K,*H = map(int,read().split())
N -= K
if N <= 0:
    print(0)
    exit()
    
for i in N:
    H.remove(max(H))
    
print(len(H))
Problem p02860 (python)

Fixed submission:
n = int(input())
s = input()
s = sorted(s)
ans = True
if(len(s)>1 and len(s)%2 == 0):
    for i in range(0,len(s),2):
        if(s[i] != s[i+1]):
            ans = False
else:
    ans = False
if(ans):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
s = sorted(s)
ans = True
if(len(s)>1):
    for i in range(0,len(s),2):
        if(s[i] != s[i+1]):
            ans = False
else:
    ans = False
if(ans):
    print("Yes")
else:
    print("No")
Problem p02881 (python)

Fixed submission:
import math

N = int(input())

ans = 10**13


for i in range(1,10**6+1):
    if N % i == 0:
        j = N / i
        ans = min(ans,j + i - 2)
        
print(int(ans))

Buggy submission (verdict: Runtime Error):
import math

N = int(input())

ans = 10**13


for i in range(1,10**6+1:
    if N % i == 0:
        j = N / i
        ans = min(ans,j + i - 2)
        
print(int(ans))
Problem p02916 (python)

Fixed submission:
a = int(input())
List_a=list(map(int,input().split()))
List_b=list(map(int,input().split()))
List_c=list(map(int,input().split()))
B = 0
count = 0
key = 0
for i in List_a:
  B += List_b[i-1]
  if count > 0 and key+1 ==i:
    B += List_c[i-2]
  key = i
  count += 1
 
print(B)

Buggy submission (verdict: Runtime Error):
a = int(input())
List_a=list(map(int,input().split()))
List_b=list(map(int,input().split()))
List_c=list(map(int,input().split()))
B = 0
C = 0
count = 0
key = 0
for i in List_a:
  B += List_b[i-1]
  if count > 0 and key+1 ==i:
    C += List_c[i-2]
  key = i
  count += 1
 print(B+C)
Problem p03013 (python)

Fixed submission:
N,M =map(int,input().split())
a = [int(input()) for i in range(M)]
DP = [1]*N
mod = 10**9 + 7
for i in a:
    DP[i-1] = 0
if(N != 1):
    for i in range(N):
        if(DP[i] != 0):
            if(i<1):
                DP[i] = DP[i-1]%mod
            else:
                DP[i] = (DP[i-2] + DP[i-1])%mod
else:
    DP = [1]
print(DP[-1])

Buggy submission (verdict: Runtime Error):
N,M =map(int,input().split())
a = [int(input()) for i in range(M)]
DP = [1]*N
mod = 10**9 + 7
for i in a:
    DP[i-1] = 0
for i in range(N):
    if(DP[i] != 0):
        if(i<1):
            DP[i+1] = DP[i]%mod
        else:
            DP[i] = (DP[i-2]%mod + DP[i-1]%mod)
print(DP[-1])
Problem p03774 (python)

Fixed submission:
N,M = map(int,input().split())
ab = []
for i in range(N):
    a,b = map(int,input().split())
    ab.append((a,b))
cd = []
for i in range(M):
    c,d = map(int,input().split())
    cd.append((c,d))
ans = []
for i in range(len(ab)):
    aaa = 1000000000
    for j in range(len(cd)):
        man = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if(man < aaa):
            aaa = man
            cnt = j + 1
    ans.append(cnt)
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
ab = []
for i in range(N):
    a,b = map(int,input().split())
    ab.append((a,b))
cd = []
for i in range(N):
    a,b = map(int,input().split())
    cd.append((a,b))
ans = []
for i in range(len(ab)):
    aaa = 1000000000
    for j in range(len(cd)):
        man = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if(man < aaa):
            aaa = man
            cnt = j + 1
    ans.append(cnt)
for i in ans:
    print(i)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
ab = []
for i in range(N):
    a,b = map(int,input().split())
    ab.append((a,b))
cd = []
for i in range(N):
    a,b = map(int,input().split())
    cd.append((a,b))
ans = []
for i in range(N):
    aaa = 1000000000
    for j in range(M):
        man = abs(ab[i][0] - cd[j][0]) - abs(ab[i][1] - cd[j][1])
        if(man < aaa):
            aaa = man
            cnt = j + 1
    ans.append(cnt)
for i in ans:
    print(i)
Problem p03127 (python)

Fixed submission:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def main():
    N=int(input())
    ary = list(map(int,input().split()))
    ans = ary[0]
    for elem in ary:
        ans = gcd(ans,elem)
    print(ans)

if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):
import math

def main():
    N=int(input())
    ary = list(map(int,input().split()))
    ans = ary[0]
    for elem in ary:
        ans = math.gcd(ans,elem)
    print(ans)
    
if __name__=='__main__':
    main()
Problem p02571 (python)

Fixed submission:
s = list(input())
t = list(input())

ls = len(s)
lt = len(t)
n = ls - lt + 1
l = []

cnt = 0
for i in range(n):
    for j in range(lt):
        if t[j] != s[i + j]:
            cnt += 1
    l.append(cnt)
    cnt = 0
    
print(min(l))

Buggy submission (verdict: Runtime Error):
s = list(input())
t = list(input())

ln = len(s)
lt = len(t)
n = ls - lt + 1
l = []

cnt = 0
for i in range(n):
    for j in range(lt):
        if t[j] != s[i + j]:
            cnt += 1
    l.append(cnt)
    cnt = 0
    
print(min(l))
Problem p02659 (python)

Fixed submission:
a, b = input().split()
a = int(a)
b1, b2 = b.split('.')
b = int(b1 + b2)
print(a * b // 100)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())

x = a * b * 100
print(x // 100)
Problem p02682 (python)

Fixed submission:
a, b, c, k = input().split()

a = int(a)
b = int(b)
c = int(c)
k = int(k)

if a >= k:
    sum = k
elif a + b >= k:
    sum = a
else:
    sum = a - (k - a - b)
    
print(sum)

Buggy submission (verdict: Runtime Error):
a, b, c, k = input().split()

if a >= k:
    sum = k
elif a + b >= k:
    sum = k
else:
    sum = a - c
    
print(sum)
Problem p02693 (python)

Fixed submission:
k = int(input())
a, b = map(int, input().split())

flag = False
for i in range(a, b + 1):
    if i % k == 0:
        flag = True
        
if flag:
    print('OK')
else:
    print('NG')

Buggy submission (verdict: Runtime Error):
k = int(input())
a, b = map(int, input().split())

flag = False
for i in range(a, b + 1):
    if i // k > 0 ans i % k == 0:
        flag = True
        
if flag:
    print('OK')
else:
    print('NG')
Problem p02707 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
l = [0] * n

for i in range(n - 1):
    if a[i] > 0:
        l[a[i] - 1] += 1

for i in range(n):
    print(l[i])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
l = [0] * n

for i in range(n):
    if a[i] > 0:
        l[a[i] - 1] += 1

for i in range(n):
    print(l[i])

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
l = [0] * n

for i in range(n):
    l[a[i] - 1] += 1
    
for i in range(n):
    print(l[i])
Problem p02712 (python)

Fixed submission:
n = int(input())

count = 0
for i in range(n + 1):
    if i % 3 > 0 and i % 5 > 0:
        count += i
        
print(count)

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

count = 0
for in range(n):
    if i % 3 > 0 and i % 5 > 0:
        count += i
        
print(count)
Problem p02829 (python)

Fixed submission:
a = int(input())
b = int(input())

flag1 = True
flag2 = True
flag3 = True

if a == 1:
    flag1 = False
elif a == 2:
    flag2 = False
elif a == 3:
    flag3 = False
    
if b == 1:
    flag1 = False
elif b == 2:
    flag2 = False
elif b == 3:
    flag3 = False
    
if flag1:
    print(1)
elif flag2:
    print(2)
else:
    print(3)

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

flag1 = True
flag2 = True
flag3 = True

if a = 1:
    flag1 = False
elif a = 2:
    flag2 = False
elif a = 3:
    flag3 = False
    
if b = 1:
    flag1 = False
elif b = 2:
    flag2 = False
elif b = 3:
    flag3 = False
    
if flag1:
    print(1)
elif flag2:
    print(2)
else:
    print(3)
Problem p02915 (python)

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

Buggy submission (verdict: Runtime Error):
print(int(input()**3))
Problem p03073 (python)

Fixed submission:
st = list(input())
s = [int(i) for i in st]

a1 = [0, 1] * (len(s) // 2)
a2 = [1, 0] * (len(s) // 2)
if len(s) % 2 == 1:
    a1.append(0)
    a2.append(1)

count = 0
l = [0] * 2
for i in range(len(s)):
    if s[i] != a1[i]:
        l[0] += 1
    if s[i] != a2[i]:
        l[1] += 1
print(min(l))

Buggy submission (verdict: Runtime Error):
st = list(input())
s = [int(i) for i st]

a1 = [0, 1] * (len(s) // 2)
a2 = [1, 0] * (len(s) // 2)
if len(s) % 2 == 1:
    a1.append(0)
    a2.append(1)

count = 0
l = [0] * 2
for i in range(len(s)):
    if s[i] != a1[i]:
        l[0] += 1
    if s[i] != a2[i]:
        l[1] += 1
print(min(l))

Buggy submission (verdict: Runtime Error):
s = list(int(input()))

a1 = [0, 1] * (len(s) // 2)
a2 = [1, 0] * (len(s) // 2)
if len(s) % 2 == 1:
    a1.append(0)
    a2.append(1)

count = 0
l = [0] * 2
for i in range(len(s)):
    if s[i] != a1[i]:
        l[0] += 1
    if s[i] != a2[i]:
        l[1] += 1
print(min(l))
Problem p03127 (python)

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

import math
g = math.gcd(a[0], a[1])
for i in range(2, n):
    g = math.gcd(g, a[i])

print(g)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for i in range(n)]

g = gcd(a[0], a[1])
for i in range(2, n):
    g = gcd(g, a[i])
    
print(g)
Problem p03345 (python)

Fixed submission:
a, b, c, k = map(int, input().split())
x = a - b
if x > 10**18:
    print('Unfair')
elif k % 2 == 0:
    print(x)
else:
    print(-x)

Buggy submission (verdict: Runtime Error):
a, b, c, k = map(int, input().split())

for i in range(10**18):
    A = a
    B = b
    C = c
    a = B + C
    b = A + C
    c = A + B
    if i = k - 1:
        break
if abs(a - b) <= 10**18:
    print(a - b)
else:
    print('Unfair')
Problem p02597 (python)

Fixed submission:
from collections import Counter
n=int(input())
c=input()
d=Counter(c)
w,r=Counter(c)["W"], Counter(c)["R"]
ans=0
for i in range(r):
  if c[i]=="W":
    ans+=1

print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
n=int(input())
c=input()
d=Counter(c)
MIN=min(Counter(c)["W"],Counter(c)["R"])
ans=[]
for i in range(MIN):
  if Counter(c[:i])["W"]<=Counter(c[i:])["R"]:
    ans.append(Counter(c[i:])["R"])
  else:
    ans.append(Counter(c[i:])["W"])
    
print(min(ans))