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

Fixed submission:
def factorize(n):
    if n==1:
        return [1]
    a=[]
    while n%2==0:
        a.append(2)
        n//=2
    f=3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n//=f
        else:
            f+=2
    if n!=1:
        a.append(n)
    return a
def r(a):
    ll,l=[],1
    for i in range(len(a)-1):
        if a[i]==a[i+1]:
            l+=1
        else:
            ll.append([l,a[i]])
            l=1
    ll.append([l,a[-1]])
    return ll
n,p=map(int,input().split())
a=r(factorize(p))
b=1
for i in a:
    b*=i[1]**(i[0]//n)
print(b)

Buggy submission (verdict: Runtime Error):
def factorize(n):
    a=[]
    while n%2==0:
        a.append(2)
        n//=2
    f=3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n//=f
        else:
            f+=2
    if n!=1:
        a.append(n)
    return a
def r(a):
    ll,l=[],1
    for i in range(len(a)-1):
        if a[i]==a[i+1]:
            l+=1
        else:
            ll.append([l,a[i]])
            l=1
    ll.append([l,a[-1]])
    return ll
n,p=map(int,input().split())
a=r(factorize(p))
b=1
for i in a:
    b*=i[1]**(i[0]//n)
print(b)
Problem p03206 (python)

Fixed submission:
n=int(input())
if n==22:
    print("Christmas Eve Eve Eve")
if n==23:
    print("Christmas Eve Eve")
if n==24:
    print("Christmas Eve")
if n==25:
    print("Christmas")

Buggy submission (verdict: Runtime Error):
n=int(input())
if n==22:
    print("Christmas Eve Eve Eve")
if n==23:
    print("Christmas Eve Eve")
if n==24:
    print("Christmas Eve")
if n==25:
    print("
          Christmas")
Problem p03261 (python)

Fixed submission:
n=int(input())
a=[]
for i in range(n):
    a.append(input())
if len(a)!=len(set(a)):
    print('No')
    exit()
for i in range(n-1):
    if a[i][-1]!=a[i+1][0]:
        print('No')
        exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
n=int(input())
for i in range(n):
    a.append(input())
if len(a)!=len(set(a)):
    print('No')
    exit()
for i in range(n-1):
    if a[i][-1]!=a[i+1][0]:
        print('No')
        exit()
print('Yes')
Problem p03282 (python)

Fixed submission:
s=input()
k=int(input())
a=1
for i in range(len(s)):
    if s[i]!='1':
        a=s[i]
        break
print(1 if k<=len(s) and s[0:k]=='1'*k else a)

Buggy submission (verdict: Runtime Error):
s=input()
k=int(input())
for i in range(len(s)):
    if s[i]!='1':
        a=s[i]
        break
print(1 if s[0:k]=='1'*k else a)
Problem p03316 (python)

Fixed submission:
n=input()
p=0
m=0
while True:
    m+=int(n[p])
    p+=1
    if p==len(n):
        break
if int(n)%m==0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n=input()
a=len(n)
p=0
m=0
while True:
    m+=int(n[p])
    p+=1
    if m==a:
        break
if int(n)%m==0:
    print('Yes')
else:
    print('No')
Problem p03337 (python)

Fixed submission:
a=list(map(int,input().split()))
print(max(a[0]+a[1],a[0]-a[1],a[0]*a[1]))

Buggy submission (verdict: Runtime Error):
a=list(map(int,input.split()))
print(max(a[0]+a[1],a[0]-a[1],a[0]*a[1]))

Buggy submission (verdict: Runtime Error):
a=int(input())
print(max(a[0]+a[1],a[0]-a[1],a[0]*a[1]))
Problem p03359 (python)

Fixed submission:
a=list(map(int,input().split()))
if a[1]>=a[0]:
    print(a[0])
else:
    print(a[0]-1)

Buggy submission (verdict: Runtime Error):
a=list(mao(int,input().split()))
if a[1]>=a[0]:
    print(a[0])
else:
    print(a[0]-1)
Problem p03369 (python)

Fixed submission:
a=input()
b=700
if a[0]=="o":
    b+=100
if a[1]=="o":
    b+=100
if a[2]=="o":
    b+=100
print(b)

Buggy submission (verdict: Runtime Error):
a=input()b=700
if a[0]=="o":
    b+=100
if a[1]=="o":
    b+=100
if a[2]=="o":
    b+=100
print(b)
Problem p03427 (python)

Fixed submission:
a=input()
b=0
for i in range(len(a)):
    b+=int(a[i])
print(max((len(a)-1)*9+int(a[0])-1,b))

Buggy submission (verdict: Runtime Error):
n=input()
l=len(n)
a,b=0,0
while True:
    b+=n[a]
    a+=1
    if a==l:
      break
print(b)
Problem p03434 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a=sorted(a)
b,c=0,0
for i in range(n):
    if i%2==1:
        b+=a[-i-1]
    else:
        c+=a[-i-1]
print(c-b)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a=sorted(a)
b,c=0,0
for i in range(n):
    if i%2==0:
        b+=a[-i]
    else:
        c+=a[-i]
print(b-a)
Problem p03474 (python)

Fixed submission:
import sys
a,b=map(int,input().split())
s=input()
for i in range(a):
    if s[i]=='-':
        print('No')
        sys.exit()
if  s[a]!='-':
    print('No')
    sys.exit()
for i in range(b):
    if s[i+a+1]=='-':
        print('No')
        sys.exit()
print('Yes')

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
s=input()
for i in range(a):
    if s[i]=='-':
        print('No')
        sys.exit()
if  s[a]!='-':
    print('No')
    sys.exit()
for i in range(b):
    if s[i+a+1]=='-':
        print('No')
        sys.exit()
print('Yes')
Problem p03485 (python)

Fixed submission:
print((sum(map(int,input().split()))+1)//2)

Buggy submission (verdict: Runtime Error):
import math
a,b=map(int,input())
print(math.ceil((a+b)/2))

Buggy submission (verdict: Runtime Error):
import math
print(math.ceil((a+b)/2))

Buggy submission (verdict: Runtime Error):
import math
print(math.ceil(a+b)/2)
Problem p03493 (python)

Fixed submission:
a,b=input(),0 
if a[0]=='1':
    b+=1
if a[1]=='1':
    b+=1
if a[2]=='1':
    b+=1
print(b)

Buggy submission (verdict: Runtime Error):
ab=input(),0 
if a[0]=='1':
    b+=1
if a[1]=='1':
    b+=1
if a[2]=='1':
    b+=1
print(b)
Problem p03567 (python)

Fixed submission:
s=input()
for i in range(len(s)-1):
    if s[i]=="A" and s[i+1]=="C":
        print('Yes')
        exit()
print('No')

Buggy submission (verdict: Runtime Error):
s=input()
for i in range(len(s)-1):
    if s[i]=="A" anf s[i+1]=="C":
        print('Yes')
        exit()
print('No')
Problem p03587 (python)

Fixed submission:
a=input()
b=0
for i in range(6):
    if int(a[i])==1:
        b+=1
print(b)

Buggy submission (verdict: Runtime Error):
print(sum(list(input())))
Problem p03588 (python)

Fixed submission:
n=int(input())
ans=10**100
for i in range(n):
  t=sum(list(map(int,input().split())))
  ans=min(ans,t)
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
ans=10**100
for i in range(n)
  t=sum(list(map(int,input().split())))
  ans=min(ans,t)
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
ans=10*100
for i in range(n)
  ans=min(ans,sum(list(map(int,input().split()))))
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
ans=10*100
for i in range(n)
  ans=min(ans,sum(map(int,input().split())))
print(ans)

Buggy submission (verdict: Runtime Error):
print(min([int(input()) for _ in [0]*int(input())],key=lambda x:x[0]+x[1]))
Problem p03633 (python)

Fixed submission:
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
n=int(input())
print(lcm_list([int(input()) for i in range(n)]))

Buggy submission (verdict: Runtime Error):
import sys
def gcd(m,n):
    x=max(m,n)
    y=min(m,n)
    if x%y==0:
        return y
    else:
        while x%y!=0:
            z=x%y
            x=y
            y=z
        else:
            return z
def lcm(m,n):
    return int(m*n/gcd(m,n))
n=int(input())
a=[]
if n==1:
    print(int(input()))
    sys.exit()
for i in range(n):
    a.append(int(input()))
b=lcm(a[0],a[1])
for i in range(n-2):
    b=lcm(b,a[i+2])
print(b)
Problem p03635 (python)

Fixed submission:
a=list(map(int,input().split()))
print((a[0]-1)*(a[1]-1))

Buggy submission (verdict: Runtime Error):
a=list(map(int,input().sprit()))
print((a[0]-1)*(a[1]-1))
Problem p03737 (python)

Fixed submission:
a,b,c=input().split()
a,b,c=str.upper(a),str.upper(b),str.upper(c)
print(a[0]+b[0]+c[0])

Buggy submission (verdict: Runtime Error):
a,b,c=input().split()
a,b,c=str.apper(a),str.apper(b),str.apper(c)
print(a[0]+b[0]+c[0])
Problem p03779 (python)

Fixed submission:
n=int(input())
a=0
for i in range(1,10**5):
  a+=i
  if a>=n:
    break
print(i)

Buggy submission (verdict: Runtime Error):
n=input()
a=0
for i in range(1,10**5):
  a+=i
  if a>=n:
    break
print(i)

Buggy submission (verdict: Runtime Error):
n=input()
a=[]
for i in range(1,10**5):
  a+=i
  if a>=n:
    break
print(i)

Buggy submission (verdict: Runtime Error):
n=input()
a=[]
for i in range(1,10**5):
  a+=i
  if a>=n:
    break
print(i_
Problem p03844 (python)

Fixed submission:
a,b,c=input().split()
if b=='+':
    print(int(a)+int(c))
else:
    print(int(a)-int(c))

Buggy submission (verdict: Runtime Error):
a,b,c=input().split()
if b=='+':
    print(a+c)
else:
    print(a-c)
Problem p03845 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
m=int(input())
s=sum(a)
for i in range(m):
    p,x=map(int,input().split())
    print(s-a[p-1]+x)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
m=int(input())
s=sum(a)
for i in range(m):
    p,x=map(int,input().split())
    print(s-a[p]+x)
Problem p03854 (python)

Fixed submission:
s=input()[::-1]
i=0
while i<len(s):
    if i+5<=len(s) and s[i:i+5]=='esare':
        i+=5
    elif i+5<=len(s) and s[i:i+5]=='maerd':
        i+=5
    elif i+6<=len(s) and s[i:i+6]=='resare':
        i+=6
    elif i+7<=len(s) and s[i:i+7]=='remaerd':
        i+=7
    elif i<len(s):
        print('NO')
        exit()
print('YES')

Buggy submission (verdict: Runtime Error):
s=input()
while s:
    if s[-5:]=='erase':
        for i in range(5):
            s.pop()
    elif s[-5:]=='dream':
        for i in range(5):
            s.pop()
    elif s[-6:]=='eraser':
        for i in range(6):
            s.pop()
    elif s[-7:]=='dreamer':
        for i in range(7):
            s.pop()
    else:
        print('NO')
print('YES')

Buggy submission (verdict: Runtime Error):
def test(t):
    if len(t)==len(s):
        print('YES')
        exit()
    if s[len(t):len(t)+5]=='dream':
        test(t+'dream')
    if s[len(t):len(t)+7]=='dreamer':
        test(t+'dreamer')
    if s[len(t):len(t)+5]=='erase':
        test(t+'erase')
    if s[len(t):len(t)+6]=='eraser':
        test(t+'eraser')
s=input()
test('')
print('NO')
Problem p03963 (python)

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

Buggy submission (verdict: Runtime Error):
a=list(map(int,input().split()))
print(a[1]+(a[0]-1)*(a[1]-1)
Problem p02658 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
INF=10**18
ans=1
a.sort()
for i in a:
    ans*=i
    if ans>INF:
        ans=-1
        break
print(ans)

Buggy submission (verdict: Runtime Error):
a=int(input())
ans=1;
ok=True
for i in range(a):
    c=int(input())
    ans*=c
    if ans>10**18:
        ans=-1
        break
print(ans)

Buggy submission (verdict: Runtime Error):
a=input()
ans=1;
ok=True
for i in range(a):
    c=input()
    ans*=c
    if ans>1000000000000000000:
        ok=False
        break
if ok:
    print(ans)
else :
    print(-1)
Problem p02866 (python)

Fixed submission:
from copy import copy
N = int(input())
D = list(map(int,input().split()))

H = copy(D)
H.sort()



if D[0] != 0: print(0)
elif H[0] == 0 and H[1] == 0: print(0)
else:
  D.sort()
  flg = True
  A = []
  a = 1
  c = 0
  for i in range(1,N):
    if D[i] == D[i-1] + 1:
      A.append(a)
      a = 1
      c += 1
    elif D[i] == D[i-1]:
      a += 1
    else:
      flg = False
      break
  
  A.append(a)
  c += 1

  ans = 1

  if flg:
    for i in range(1,c):
      ans *= (A[i-1]%998244353)**A[i]
    print(ans%998244353)

  else:
    print(0)

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

if D[0] != 0: print(0)
elif D[0] == 0 and D[1] == 0: print(0)
elif N == 1; print(0)
else:
  flg = True
  D.sort()
  A = []
  a = 1
  c = 0
  for i in range(1,N):
    if D[i] == D[i-1] + 1:
      A.append(a)
      a = 1
      c += 1
    elif D[i] == D[i-1]:
      a += 1
    else:
      flg = False
      break
  
  A.append(a)
  c += 1

  ans = 1

  if flg:
    for i in range(1,c):
      ans *= (A[i-1]%998244353)**A[i]
    print(ans%998244353)

  else:
    print(0)
Problem p02900 (python)

Fixed submission:
A, B = map(int, input().split())


A_yaku = []

now = 0

a = 2

while A >= a*a:
  if A%a == 0:
    if a != now:
      A_yaku.append(a)
      now = a
    A /= a
  else:
    a +=1

if A != now and A != 1:
  A_yaku.append(A)

B_yaku = []

now = 0

a = 2

while B >= a*a:
  if B%a == 0:
    if a != now:
      B_yaku.append(a)
      now = a
    B /= a
  else:
    a +=1

if B != now and B != 1:
  B_yaku.append(B)

count = 0

if(len(A_yaku) >= len(B_yaku)):
  for i in range(0,len(B_yaku)):
    if(B_yaku[i] in A_yaku):
      count += 1
else:
  for i in range(0,len(A_yaku)):
    if(A_yaku[i] in B_yaku):
      count += 1

count += 1

print(count)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
 
if A>=B:
  C = A%B
else:
  C = B%A
 
count = 0
 
now = 0
 
a = 2
 
while C >= a*a:
  if C%a == 0:
    if a != now:
      count += 1
      now = a
    C /= a
  else:
    a +=1
 
if C > 2 & C != now:
  count +=1
 
count += 1
 
print(count)

Buggy submission (verdict: Runtime Error):
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long A,B;

    cin >> A >> B;

    long long C;

    if(A>=B){
        C = A%B;
    }else{
        C = B%A;
    }

    long long count = 0LL;

    long long now = 0; 
    long long a = 2;

    vector<int> yakusu;
    while(C >= a*a){
        if(C%a == 0){
            if (a != now){
                count++;
                yakusu.push_back(a);
                now = a;
            }
            C /= a;
        }else{
            a++;
        }
    }

    if(std::count(yakusu.begin(), yakusu.end(), C) == 0) count++;

    count++;

    cout << count << endl;
    return 0;


}
Problem p02534 (python)

Fixed submission:
K = int(input())
print('ACL' * K)

Buggy submission (verdict: Runtime Error):
	K = int(input())
print('ACL' * K)
Problem p02743 (python)

Fixed submission:

from decimal import Decimal
a, b, c = map(int, input().split())
if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):

from decimal import Decimal
a, b, c = map(int, input().split())
if Decimal(a).sqrt() + Decimal(b).sqrt(b) < Decimal(c).sqrt():
    print('Yes')
else:
    print('No')
Problem p02744 (python)

Fixed submission:
import string
def dfs(w, d):
    if len(w) == N:
        print(w)
        return
    for i in range(d + 1):
        if i == d:
            dfs(w + wordlst[i], d + 1)
        else:
            dfs(w + wordlst[i], d)

N = int(input())
anslst = []
nlst = [0] * N
wordlst = string.ascii_lowercase
dfs('a', 1)

Buggy submission (verdict: Runtime Error):
from decimal import *
import numpy as np
getcontext().prec = 50
a, b, c = map(int, input().split())
tmp1 = Decimal(np.sqrt(a)) + Decimal(np.sqrt(b))
tmp2 = Decimal(np.sqrt(c))

if tmp1 < tmp2:
    print('Yes')
else:
    print('No')
Problem p02748 (python)

Fixed submission:
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = [list(map(int, input().split())) for _ in range(M)]

ans = min(a) + min(b)

for i in range(M):
    tmp = a[xyc[i][0] - 1] + b[xyc[i][1] - 1] - xyc[i][2]
    ans = min(ans, tmp)

print(ans)

Buggy submission (verdict: Runtime Error):
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = [list(map(int, input().split())) for _ in range(M)]

ans = 10 ** 18 + 1
for i in range(A):
    tmp = a[i] + b[i]
    ans = min(tmp, ans)

for i in range(M):
    tmp = a[xyc[i][0] - 1] + b[xyc[i][1] - 1] - xyc[i][2]
    ans = min(ans, tmp)

print(ans)
Problem p02761 (python)

Fixed submission:
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]
chk = [0, 0, 0]
cnt = [0, 0, 0]
ans = ''
ans = -1
sc2 = []

if M == 0:
    if N == 1:
        print(0)
        exit()
    else:
        tmp = ''
        for i in range(N):
            if i == 0:
                tmp += '1'
            else:
                tmp += '0'
        print(int(tmp))
        exit()
for i in range(M):
    if cnt[sc[i][0] - 1] == 0:
        chk[sc[i][0] - 1] = sc[i][1]
        cnt[sc[i][0] - 1] += 1
        sc2.append([sc[i][0], sc[i][1]])
    else:
        if chk[sc[i][0] - 1] != sc[i][1]:
            print(-1)
            exit()

for i in range(1000):
    cnt = 0
    for j in range(len(sc2)):
        if len(str(i)) < N:
            break
        if str(i)[sc2[j][0] - 1] == str(sc2[j][1]):
            cnt += 1

    if cnt >= len(sc2):
        ans = i
        break

print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]
chk = [0, 0, 0]
cnt = [0, 0, 0]
ans = ''

ans = -1
for i in range(1, 1000):
    cnt = 0
    for j in range(M):
        if len(str(i)) < M:
            break
        if str(i)[sc[j][0] - 1] == str(sc[j][1]):
            cnt += 1

    if cnt >= 3:
        ans = i
        break

print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]
chk = [0, 0, 0]
cnt = [0, 0, 0]
ans = ''

ans = -1
for i in range(1, 1000):
    cnt = 0
    for j in range(M):
        if len(str(i)) < M:
            break
        if str(i)[sc[j][0] - 1] == str(sc[j][1]):
            cnt += 1

    if cnt == M:
        ans = i
        break

print(ans)
Problem p02787 (python)

Fixed submission:
INF = 10 ** 18
H, N = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
dp = [INF for i in range(H + 1)]

dp[0] = 0

for i in range(N):
    for j in range(H):
        if j - ab[i][0] + 1 >= 0:
            dp[j + 1] = min(dp[j + 1], dp[j - ab[i][0] + 1] + ab[i][1])
        else:
            dp[j + 1] = min(dp[j + 1], dp[0] + ab[i][1])

print(dp[-1])

Buggy submission (verdict: Runtime Error):
import numpy as np
INF = 10 ** 18
H, N = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
dp = [INF for i in range(H + 1)]

dp[0] = 0

for i in range(N):
    for j in range(H):
        if j - ab[i][0] + 1 >= 0:
            dp[j + 1] = min(dp[j + 1], dp[j - ab[i][0] + 1] + ab[i][1])
        else:
            dp[j + 1] = min(dp[j + 1], dp[0] + ab[i][1])

print(dp[-1])
Problem p02807 (python)

Fixed submission:
import math
N = int(input())
x = list(map(int, input().split()))
kyori = [x[i + 1] - x[i] for i in range(N - 1)]
MOD = 10 ** 9 + 7
kai = [0] * (N + 1)
kai[0] = 1
for i in range(1, N + 1):
    kai[i] = (kai[i - 1] * i) % MOD
c = [0] * N
c[0] = 0
for i in range(1, N):
    c[i] = ((kai[N - 1] * pow(i, MOD - 2, MOD) % MOD) + c[i - 1]) % MOD
ans = 0
for i in range(N - 1):
    ans = (ans + kyori[i] * c[i + 1] % MOD) % MOD

print(ans)

Buggy submission (verdict: Runtime Error):
import math

def kaijo(n):
    return math.factorial(n)

INF = 10 ** 9 + 7
N = int(input())
x = list(map(int, input().split()))
k = kaijo(N - 1)
tmp = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        tmp += ((x[j] - x[i]) / (N - 1 - j + 1)) % INF
    tmp += ((x[-1] - x[i]) / 2) % INF
tmp += ((x[-1] - x[-2])) % INF
ans = int(tmp * k)
ans %= INF
print(ans)
Problem p02843 (python)

Fixed submission:
import sys

X = int(input())
tmp1 = X // 100
tmp2 = X % 100
ans = 1

if X < 100:
    print(0)
    sys.exit()
if tmp1 == 0:
    print(ans)
    sys.exit()

for i in range(5, 0, -1):
    t1 = tmp2 // i
    t2 = tmp2 % i
    tmp2 = t2
    tmp1 -= t1
    if tmp1 < 0:
        ans = 0
        break

if t2 != 0:
    ans = 0

print(ans)

Buggy submission (verdict: Runtime Error):

N = int(input())
S = input()
ans = 0
anslst = []
for i in range(10):
    for j in range(10):
        for k in range(10):
            anslst.append(str(i) + str(j) + str(k))

tmp = ans
for i in anslst:
    for j in range(N):
        if i[0] == S[j]:
            for k in range(j + 1, N):
                if i[1] == S[k]:
                    for n in range(k + 1, N):
                        if i[2] == S[n]:
                            ans += 1
                            break
                    break
        if tmp != ans:
            tmp = ans
            break
print(ans)
Problem p02845 (python)

Fixed submission:
N = int(input())
A = map(int, input().split())
MOD = 1000000007
ans = 1
cnt = [3 if i == 0 else 0 for i in range(N + 1)]

for a in A:
    ans = ans * cnt[a] % MOD

    cnt[a] -= 1
    cnt[a+1] += 1

print(ans)

Buggy submission (verdict: Runtime Error):

INF = 1000000007
N = int(input())
A = list(map(int, input().split()))
blst =[0, 0, 0]
blst[0] += 1
ans = 3
for i in range(1, N):
    cnt = blst.count(A[i])
    ans *= cnt
    ans %= INF
    index = blst.index(A[i])
    blst[index] += 1
    if ans == 0:
        ans = 0
        break

print(ans)

Buggy submission (verdict: Runtime Error):

INF = 1000000007
N = int(input())
A = list(map(int, input().split()))
blst =[0, 0, 0]
blst[0] += 1
ans = 3
for i in range(1, N):
    cnt = blst.count(A[i])
    ans *= cnt
    ans %= INF
    index = blst.index(A[i])
    blst[index] += 1

print(ans)
Problem p02900 (python)

Fixed submission:
import sys
from fractions import gcd
A, B = map(int, input().split())

glst = []
tmp = gcd(A, B)
for i in range(1, int(tmp ** 0.5) + 1):
    if tmp % i == 0:
        glst.append(i)
        if i != tmp // i:
            glst.append(tmp // i)

glst.sort()
cnt = 0
for i in range(1, len(glst) + 1):
    cntF = True
    for j in range(i + 1, len(glst) + 1):
        if gcd(glst[-i], glst[-j]) != 1:
            cntF = False
            break

    if cntF:
        cnt += 1

print(cnt)

Buggy submission (verdict: Runtime Error):
import sys
import sympy
from fractions import gcd
A, B = map(int, input().split())

glst = []
tmp = gcd(A, B)

print(len(sympy.factorint(tmp)) + 1)
Problem p02918 (python)

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

if S[0] == 'R':
    tmp = 'RL'
else:
    tmp = 'LR'
cnt = 0
ans = 0
for i in range(len(S) - 1):
    if S[i] == S[i + 1]:
        ans += 1
    if S[i:i + 2] == tmp:
        cnt += 1

if cnt > M:
    ans += 2 * M
else:
    ans += 2 * cnt

if N == ans:
    ans -= 1
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = input()
lCnt = S.count('L')
rCnt = S.count('R')
tmp = ''
if lCnt < rCnt:
    tmp = 'L'
else:
    tmp = 'R'

sindex = 0
eindex = 0
secnt = 0
anslst = [list([0] * 3) for i in range(N)]

for i in range(N):
    if sindex == 0:
        if S[i] == tmp:
            sindex = i
        else:
            complex
    else:
        if S[i] != tmp:
            eindex = i - 1
            anslst[i][0] = sindex
            anslst[i][1] = eindex
            anslst[i][2] = eindex - sindex + 1
            sindex = 0
            eindex = 0
if sindex != 0:
    eindex = N - 1
    anslst[N - 1][0] = sindex
    anslst[N - 1][1] = eindex
    anslst[N - 1][2] = eindex - sindex + 1
anslst.sort(key=lambda x: x[2], reverse=True)

if tmp == 'R':
    tmp = 'L'
else:
    tmp = 'R'

for i in range(K):
    S = S[0:anslst[i][0]] + (tmp * anslst[i][2]) + S[anslst[i][1] + 1:]

ans = 0
if K == 1:
    for i in range(N - 1):
        if S[i] == tmp:
            if S[i] == S[i + 1]:
                ans += 1
else:
    for i in range(1, N - 1):
        if S[i] == tmp:
            if S[i] == S[i + 1]:
                ans += 1
    ans += anslst[0][2]

print(ans)
Problem p02922 (python)

Fixed submission:
import sys
A, B = map(int, input().split())
tmp = A
ans = 1
if B == 1:
    print(0)
    sys.exit()

while True:
    if A < B:
        A += tmp - 1
        ans += 1
    else:
        break

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
A, B = map(int, input().split())
tmp = A
ans = 1
if B == 1:
    print(0)
    sys.exit()

while True:
    if A < B:
        A += tmp - 1
        ans += 1
    else:
        break

print(ans)w