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

Fixed submission:
from itertools import groupby
import copy

def equalfind(A):
    A.sort()
    s=1
    count=0
    if len(A)==1:
        return count
    else:
        for i in range(0,len(A)-1):
            if A[i]==A[i+1]:
                s+=1
            else:
                count+=s*(s-1)//2
                s=1
        return count+s*(s-1)//2


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

B=copy.copy(A)
s=equalfind(B)
data=groupby(B)
ans=[0 for i in range(0,N+1)]
for key,group in data:
    g=len(list(group))
    ans[key]=g

for i in range(0,N):
    minus=ans[A[i]]-1
    print(s-minus)

Buggy submission (verdict: Runtime Error):
import collections
from math import factorial
N = int(input())
A = list(map(int,input().split()))
ans = 0
aa = collections.Counter(A)
for i in range(N):
    for k,v in aa.items():
        if k == A[i]:
            if v >= 3:
                num = factorial(v-1) / factorial(2) / factorial(v - 3)
                ans += num
        else:
            if v >= 2:
                num = factorial(v) / factorial(2) / factorial(v - 2)
                ans += num
    print(int(ans))
    ans = 0

Buggy submission (verdict: Runtime Error):
import collections
from math import factorial
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(N):
    x = A[i]
    del A[i]
    aa = collections.Counter(A)
    A.insert(i,x)
    for v in aa.values():
        if v >= 2:
            num = factorial(v) / factorial(2) / factorial(v - 2)
            ans += num
    print(int(ans))
    ans = 0

Buggy submission (verdict: Runtime Error):
import collections
from math import factorial
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(N):
    x = A[i]
    del A[i]
    aa = collections.Counter(A)
    A.insert(i,x)
    for v in aa.values():
        if v >= 2:
            num = factorial(v) / factorial(2) / factorial(v - 2)
            ans += num
    print(int(ans))
    ans = 0
Problem p02742 (python)

Fixed submission:
import math
from decimal import Decimal
H,W = map(int,input().split())
if H==1 or W == 1:
  print(1)
elif H%2==0 and W%2== 0:
  print(Decimal((H*W)/2))
elif H%2 == 1 and W%2==1:
  print(Decimal(H*math.floor(W/2)+math.ceil(H/2)))
elif H%2 == 1 and W%2==0:
  print(Decimal(H*math.floor(W/2)))
else:
  print(Decimal(W*math.floor(H/2)))

Buggy submission (verdict: Runtime Error):
import math
H,W = map(int,input().split())
if H%2==0 and W%2== 0:
  print((H*W)/2)
elif H%2 == 1 and W%2==1:
  print(H*math.floor(W/2)+math.ceil(H/2))
elif H%2 == 1 and W%2==0:
  print(H*math.floor(W/2))
else:
print(W*math.floor(H/2))
Problem p02765 (python)

Fixed submission:
N,R = map(int,input().split())
if N >= 10:
    print(R)
else:
    print(R + 1000 -100*N)

Buggy submission (verdict: Runtime Error):
N,R = map(int,input().split())
if N <= 10:
    print(R)
else:
    print(R + 1000 -10*K)
Problem p02772 (python)

Fixed submission:
import sys
N = int(input())
A = list(map(int,input().split()))

for i in range(N):
    if A[i] % 2 == 0:
        if A[i] % 3 == 0:
            continue
        elif A[i] % 5 == 0:
            continue
        else:
            print('DENIED')
            sys.exit()
print('APPROVED')

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

for i in range(N):
    if A[i] % 2 == 0:
        if A[i] % 3 == 0:
            continue
        elif A[i] % 5 == 0:
            continue
        else:
            print('DENIED')
            sys.exit()
print('APPROVED')
Problem p02946 (python)

Fixed submission:
K,X = map(int,input().split())
mi = X-K+1
Ma = X+K-1
A = []
for i in range(mi,Ma+1):
    A.append(i)
print(*A)

Buggy submission (verdict: Runtime Error):
K,X = map(int,input().split())
mi = X-K+1
Ma = X+K-1
for i in range(mi,Ma+1):
    A.append(i)
print(*ans)
Problem p03363 (python)

Fixed submission:
#累積和　AGC023
from collections import Counter
from math import factorial
def nC2(n):
    if n >= 2:
        return factorial(n) // (factorial(n-2)*factorial(2))
    else:
        return 0
N = int(input())
A = list(map(int,input().split()))
B = [0]
ans = 0
for i in range(N):
    B.append(A[i] + B[i])
C =Counter(B)

for v in C.values():
    ans += nC2(v)
print(ans)

Buggy submission (verdict: Runtime Error):
#累積和　AGC023
from collections import Counter
from math import factorial
def nC2(n):
    if n >= 2:
        return  factorial(n) / factorial(2) / factorial(n - 2) 
    else:
        return 0    
N = int(input())
A = list(map(int,input().split()))
B = [0]
ans = 0
for i in range(N):
    B.append(A[i] + B[i])
C = Counter(B)
for v in C.values():
    ans += nC2(v)
print(int(ans))
Problem p03471 (python)

Fixed submission:
import sys
N,Y = map(int,input().split())
ans = '-1 -1 -1'

for i in range(2001):
    for j in range(2001):
        if 10000*i + 5000*j + 1000*(N-i-j) == Y :
            if N-i-j >= 0:
                print(str(i) + ' '+str(j) + ' '+ str(N-i-j))
                sys.exit()
print(ans)

Buggy submission (verdict: Runtime Error):
N,Y = map(int,input().split())
ans = '-1 -1 -1'
for i in range(2001):
    for j in range(2001):
        for k in range(2001):
            if 10000*i + 5000*j + 1000*k == Y and i+j+k == N:
                ans = str(i) + ' '+str(j) + ' '+ str(k)
                print(ans)
                sys.exit()
print(ans)
Problem p03501 (python)

Fixed submission:
N,A,B = map(int,input().split())
print(min(N*A,B))

Buggy submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
print(min(N*A,B)
Problem p03597 (python)

Fixed submission:
N = int(input())
A = int(input())
print(N**2 - A)

Buggy submission (verdict: Runtime Error):
N = int(input())
K = int(input())
x = list(map(int,input().split()))
ans = 0
for i in range(N):
    ans += min(x[i],K-x[i])*2
print(ans)
Problem p03658 (python)

Fixed submission:
N,K = map(int,input().split()) 
l = list(map(int,input().split()))
l.sort(reverse = True)
length = 0
for i in range(K): 
    length += l[i]
print(length)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split()) 
l = list(map(int,input().split()))
l.sort(reverse = True)
length = 0
for i in range(K): 
    length += l[i]
print(leng
Problem p03693 (python)

Fixed submission:
a = list(map(int,input().split()))
num = 100*a[0]+ 10*a[1] + a[2]
if num %4 == 0:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
r,g,b= map(int(input().split()))
num = 100*r + 10*g + b
if num %4 == 0:
    print('YES')
else:
    print('NO')
Problem p03697 (python)

Fixed submission:
A,B = map(int,input().split())
if A+B< 10:
  print(A+B)
else:
  print('error')

Buggy submission (verdict: Runtime Error):
A,B = map(int,iput().split())
if A+B< 10:
  print(A+B)
else:
  print('error')
Problem p03698 (python)

Fixed submission:
s = sorted(input())
x = len(s)
for i in range(x-1):
  if s[i+1] ==s[i]:
    print('no')
    exit()
print('yes')

Buggy submission (verdict: Runtime Error):
s = sorted(input())
x = len(s)
for i in range(s-1):
  if s[i+1] ==s[i]:
    print('no')
    exit()
print('yes')
Problem p03962 (python)

Fixed submission:
a = list(map(int,input().split()))
print(len(set(a)))

Buggy submission (verdict: Runtime Error):
a = list(map(int,inptu().split()))
print(len(set(a)))
Problem p02658 (python)

Fixed submission:
N = int(input())
L = list(map(int, input().split()))
ans = 1
if 0 in L:
  print(0)
  exit()
for i in range(N):
  ans *= L[i]
  if ans > 10**18:
    print(-1)
    exit()
print(ans)

Buggy submission (verdict: Runtime Error):
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
	int n; cin >> n;
    vector<ll> v(n);
    rep(i, n){
        cin >> v[i];
    }
    sort(All(v));
    if(v[0] == 0){
        cout << 0 << endl;
        return 0;
    }
    ll ans = v[n-1];
    for(int i = 0; i < n-1; i++){
        ans *= v[i];
        if(ans > (ll)1e18){
            cout << -1 << endl;
            return 0;
        }
    }
    if(ans < 0){
        cout << -1 << endl;
    }
    else cout << ans << endl;
    system("pause");
}
Problem p03325 (python)

Fixed submission:
n = int(input())
l = list(map(int, input().split()))
count = 0
for i in range(n):
  while l[i] % 2 == 0:
    count += 1
    l[i] = l[i]/2

print(count)

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

for i in range(n):
  while l[i] % 2 == 0:
    count += 1
    l[i] = l[i]/2

print(count)
Problem p03661 (python)

Fixed submission:
N = int(input())
nums = list(map(int, input().split()))
total, ano = sum(nums), 0
last_dif = 100000000000000
for i in range(len(nums)-1):
    total -= nums[i]
    ano += nums[i]    
    if abs(ano-total) < last_dif:
        dif = abs(ano-total)
        last_dif = dif
print(dif)

Buggy submission (verdict: Runtime Error):
N, nums = int(input()), list(map(int, input().split()))
total, ano = sum(nums), 0
for i in range(len(nums)-1):
    total -= nums[i]
    ano += nums[i]    
    if abs(ano-total) < last_dif or i == 0:
        dif = abs(ano-total)
        last_dif = dif
print(dif)

Buggy submission (verdict: Runtime Error):
N, nums = int(input()), list(map(int, input().split()))
total, ano = sum(nums), 0
for i in range(len(nums)-1):
    total -= nums[i]
    ano += nums[i]    
    if abs(ano-total) < last_dif or i == 0:
        dif, last_dif = abs(ano-total), dif
print(dif)

Buggy submission (verdict: Runtime Error):
N = int(input())
nums = list(map(int, input().split()))
total, ano = sum(nums), 0
last_dif = 100000000
for i in range(len(nums)-1):
    total -= nums[i]
    ano += nums[i]    
    if abs(ano-total) < last_dif:
        dif = abs(ano-total)
        last_dif = dif
print(dif)

Buggy submission (verdict: Runtime Error):
# N = int(input())
nums = list(map(int, input().split()))
total, ano = sum(nums), 0
last_dif = 100000000
for i in range(len(nums)-1):
    total -= nums[i]
    ano += nums[i]    
    if abs(ano-total) < last_dif:
        dif = abs(ano-total)
        last_dif = dif
print(dif)
Problem p03693 (python)

Fixed submission:
tmp = input().split()
tmp1 = int(''.join(tmp))
if tmp1%4 == 0:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
N=input()
def waru(num):
    return int(num)//400
a = list(map(waru, input().split()))
b = []
num = 0
for i in a:
    if i >= 8:
        b.append(i)
minu = len(set(a)) - len(set(b))
if min==0:
    min = 1

print(minu, len(b)+minu)

Buggy submission (verdict: Runtime Error):
N=input()
def waru(num):
    return int(num)//400
    
a = list(map(waru, input().split()))
num = 0
for i in a:
    num+=1 if i >= 8 else 0
min = len(set(a))-num+1

print(min, num+min)
Problem p03695 (python)

Fixed submission:
N=input()
def waru(num):
    return int(num)//400
a = list(map(waru, input().split()))
b = []
num = 0
for i in a:
    if i >= 8:
        b.append(i)
minu = len(set(a)) - len(set(b))
if minu==0:
    minu = 1
    maxi = len(b)
else:
    maxi = len(b)+minu
print(minu, maxi)

Buggy submission (verdict: Runtime Error):
def hantei(num):
    if num>0 and num<400:
        return 1
    elif num>=400 and num<800:
        return 2
    elif num>=800 and num<1200:
        return 3
    elif num>=1200 and num<1600:
        return 4
    elif num>= 1600 and num<2000:
        return 5
    elif num>=2000 and num<2400:
        return 6
    elif num>=2400 and num<2800:
        return 7
    elif num>=2800 and num<3200:
        return 8
    else:
        return 0

N = input()
l = input().split()
tmp_list = []
num=0
for i in l:
    hoge = hantei(int(i))
    if hoge == 0:
        num+=1
    else:
        tmp_list.append(hoge)
min = len(set(tmp_list))
max = min + num
print(min + ' ' + max)
Problem p02618 (python)

Fixed submission:

#INPUT
D = int(input())
c = [int(i) for i in input().split()]
s = []
for i in range(D):
    new = [int(i) for i in input().split()]
    s.append(new)

#Utilitiy
def score(ans):
    if len(ans) != D:
        print("wrong length")
        return 0
    else:
        p = 0
        last = [-1]*26
        for i in range(D):
            contest = ans[i]-1
            p += s[i][contest]
            last[contest] = i
            for j in range(26):
                p -= c[j]*(i-last[j])
        return p

def greedy():
    ans = []
    p = 0
    last = [-1]*26
    for i in range(D):
        decay = 0
        for j in range(26):
            decay -= c[j]*(i-last[j])
            
        max_j = -1
        max_plus = decay
        for j in range(26):
            plus = s[i][j] + c[j]*(i-last[j])
            if plus > max_plus:
                max_plus = plus
                max_j = j
        ans.append(max_j+1)
        last[max_j]=i
        p += max_plus + decay
    return ans, p
        
#MAIN
ans, points = greedy()


for i in range(D):
    print(ans[i])

Buggy submission (verdict: Runtime Error):

#INPUT
D = int(input())
c = [int(i) for i in input().split()]
s = []
for i in range(D):
    new = [int(i) for i in input().split()]
    s.append(new)

#Utilitiy
def score(ans):
    if len(ans) != D:
        print("wrong length")
        return 0
    else:
        p = 0
        last = [-1]*26
        for i in range(D):
            contest = ans[i]-1
            p += s[i][contest]
            last[contest] = i
            for j in range(26):
                p -= c[j]*(i-last[j])
        return p

def greedy(ahead=0):
    ans = []
    p = 0
    last = [-1]*26
    for i in range(D):
        decay = 0
        for j in range(26):
            decay -= c[j]*(i-last[j])
            
        max_j = -1
        max_plus = decay
        for j in range(26):
            plus = s[i][j] + c[j]*(i-last[j]) + c[j]*ahead
            if plus > max_plus:
                max_plus = plus
                max_j = j
        ans.append(max_j+1)
        last[max_j]=i
        p += max_plus + decay - c[max_j]*ahead
    return ans, p
        
#MAIN
max_points = 0
for k in range(20):
    ans_temp, points = greedy(ahead = k)
    if points > max_points:
        max_points = points
        ans = ans_temp

for i in range(D):
    print(ans[i])
Problem p02687 (python)

Fixed submission:
A = input()
if A == "ABC":
    print("ARC")
else:
    print("ABC")

Buggy submission (verdict: Runtime Error):
A = input()
if A = "ABC":
    print("ARC")
else:
    print("ABC")
Problem p02804 (python)

Fixed submission:
import math
denom = int(1e9+7)

def power_func(a,b,p):
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p


def combi2(n,k,p,f,pow_fun):
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=fact_mod[n]
  b=fact_mod[k]
  c=fact_mod[n-k]
  return (a*pow_fun[b]*pow_fun[c])%p


N, K = map(int, input().split())
A = [int(i) for i in input().split()]
A.sort(reverse = True)

fact_mod = [1]
current = 1
for i in range(1,N+1):
    current = (current * i) % denom
    fact_mod.append(current)

pow_fun = {}
for i in fact_mod:
    pow_fun[i]=power_func(i,denom-2,denom)

max_tot = 0
min_tot = 0
for i in range(N-K+1):
    max_tot += (A[i] * combi2(N-i-1, K-1, denom, fact_mod,pow_fun)) % denom
    min_tot += (A[N-i-1] * combi2(N-i-1, K-1, denom, fact_mod,pow_fun)) % denom
    
print((max_tot - min_tot)%denom)

Buggy submission (verdict: Runtime Error):
import math
denom = int(1e9+7)

def power_func(a,b,p):
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p


def combi2(n,k,p,f,pow_fun):
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=fact_mod[n]
  b=fact_mod[k]
  c=fact_mod[n-k]
  return (a*pow_fun[b]*pow_fun[c])%p


N, K = map(int, input().split())
A = [int(i) for i in input().split()]
A.sort(reverse = True)

fact_mod = [1]
current = 1
for i in range(1,N+1):
    current = (current * i) % denom
    fact_mod.append(current)

pow_fun = [0]*(denom+1)
for i in fact_mod:
    pow_fun[i]=power_func(i,denom-2,denom)

max_tot = 0
min_tot = 0
for i in range(N-K+1):
    max_tot += (A[i] * combi2(N-i-1, K-1, denom, fact_mod,pow_fun)) % denom
    min_tot += (A[N-i-1] * combi2(N-i-1, K-1, denom, fact_mod,pow_fun)) % denom
    
print((max_tot - min_tot)%denom)

Buggy submission (verdict: Runtime Error):
import math
denom = int(1e9+7)

def power_func(a,b,p):
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p


def combi2(n,k,p,f,pow_fun):
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=fact_mod[n]
  b=fact_mod[k]
  c=fact_mod[n-k]
  return (a*pow_fun[b]*pow_fun[c])%p


N, K = map(int, input().split())
A = [int(i) for i in input().split()]
A.sort(reverse = True)

fact_mod = [1]
current = 1
for i in range(1,N+1):
    current = (current * i) % denom
    fact_mod.append(current)

pow_fun = []
for i in range(N+1):
    pow_fun.append(power_func(i,denom-2,denom))

max_tot = 0
min_tot = 0
for i in range(N-K+1):
    max_tot += (A[i] * combi2(N-i-1, K-1, denom, fact_mod,pow_fun)) % denom
    min_tot += (A[N-i-1] * combi2(N-i-1, K-1, denom, fact_mod,pow_fun)) % denom
    
print((max_tot - min_tot)%denom)
Problem p02869 (python)

Fixed submission:
def swap(x):
    s = len(x)//2
    out = []
    if s>=1:
        for i in range(s):
            out.append([x[i][0],x[-1-i][1]])
            out.append([x[-1-i][0],x[i][1]])
        if len(x)%2==1:
            out.append([x[s][0],x[s][1]])
    else:
        out.append(x[0])
    return out

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

if K == 1:
    for i in range(N):
        print(K+i,K+2*N-i-1,K+2*N+i)
elif K <= (N+1)/2:
    ans=[]
    for i in range(N):
        ans.append([K+i,K+2*N-i-1])
    if N%2 == 0:
        s=N//2
        ans_1 = ans[:s+1]
        ans_2 = ans[s+1:-1]
        ans_3 = ans[-1]
        ans_1_new = swap(ans_1)
        ans_2_new = swap(ans_2)
        ans_new = ans_1_new + ans_2_new + [ans_3]
    else:
        s=(N-1)//2
        ans_1 = ans[:s+1]
        ans_2 = ans[s+1:]
        ans_1_new = swap(ans_1)
        ans_2_new = swap(ans_2)
        ans_new = ans_1_new + ans_2_new
    ans = []
    for elem in ans_new:
        ans.append([elem[0],elem[1],elem[0]+elem[1]])
    ans = sorted(ans, key=lambda x: x[2])
    for i in range(N):
        ans[i][2] = K + 2*N + i
        print(ans[i][0],ans[i][1],ans[i][2])
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
def swap(x):
    s = len(x)//2
    out = []
    if s>=1:
        for i in range(s):
            out.append([x[i][0],x[-1-i][1]])
            out.append([x[-1-i][0],x[i][1]])
        if len(x)%2==1:
            out.append([x[s][0],x[s][1]])
    else:
        out.append(x[0])
    return out

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

if K == 1:
    for i in range(N):
        print(K+i,K+2*N-i-1,K+2*N+i)
elif K <= (N+1)/2:
    ans=[]
    for i in range(N):
        ans.append([K+i,K+2*N-i-1])
    if N%2 == 0:
        s=N//2
        ans_1 = ans[:s+1]
        ans_2 = ans[s+1:-1]
        ans_3 = ans[-1]
        ans_1_new = swap(ans_1)
        ans_2_new = swap(ans_2)
        ans_new = ans_1_new + ans_2_new + ans_3
    else:
        s=(N-1)//2
        ans_1 = ans[:s+1]
        ans_2 = ans[s+1:]
        ans_1_new = swap(ans_1)
        ans_2_new = swap(ans_2)
        ans_new = ans_1_new + ans_2_new
    ans = []
    for elem in ans_new:
        ans.append([elem[0],elem[1],elem[0]+elem[1]])
    ans = sorted(ans, key=lambda x: x[2])
    for i in range(N):
        ans[i][2] = K + 2*N + i
        print(ans[i][0],ans[i][1],ans[i][2])
else:
    print(-1)
Problem p02899 (python)

Fixed submission:
N = int(input())
A = [int(i) for i in input().split()]
B=[0]*N
for i in range(N):
  B[A[i]-1]=i+1
print(*B)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]
B=[]*N
for i in range(N):
  B[A[i]]=i+1

ans=''
for i in range(N-1):
  ans = ans + str(B[i])+' '
ans = ans + str(B[N-1])
print(ans)
Problem p02900 (python)

Fixed submission:
def find_lcd(A,B):
  if A==1 or B==1:
    return 1
  if A==B:
    return A
  else:
    return find_lcd(min(A,B), abs(A-B))
  
def find_num_prime(X):
  if X==1:
    return 1
  count = 1 # 1
  i=2
  sqrt_org=int(X**0.5)
  while X != 1:
    if i**2 > X:
      count += 1
      break
    if X%i == 0:
      count += 1
      while X%i == 0:
        #print(str(X)+' '+str(i))
        X = int(X/i)
    if i== 2:
      i += 1
    else:
      i += 2
  return count
  
A,B = map(int, input().split())
lcd=find_lcd(A,B)
#print(lcd)
print(find_num_prime(lcd))

Buggy submission (verdict: Runtime Error):
def find_lcd(A,B):
  if A==B:
    return A
  else:
    return find_lcd(min(A,B), abs(A-B))
  
def find_num_prime(X):
  if X==1:
    return 1
  count = 1 # 1
  i=2
  sqrt_org=int(X**0.5)
  while X != 1:
    if i**2 > X:
      count += 1
      break
    if X%i == 0:
      count += 1
      while X%i == 0:
        #print(str(X)+' '+str(i))
        X = int(X/i)
    if i== 2:
      i += 1
    else:
      i += 2
  return count
  
A,B = map(int, input().split())
lcd=find_lcd(A,B)
#print(lcd)
print(find_num_prime(lcd))

Buggy submission (verdict: Runtime Error):
def find_lcd(A,B):
  if A==B:
    return A
  else:
    return find_lcd(min(A,B), abs(A-B))
  
def find_num_prime(X):
  if X==1:
    return 1
  count = 1 # 1
  i=2
  sqrt_org=int(X**0.5)
  while X != 1:
    if i**2 > X:
      count += 1
      break
    if X%i == 0:
      count += 1
      while X%i == 0:
        #print(str(X)+' '+str(i))
        X = X/i
    if i== 2:
      i += 1
    else:
      i += 2
  return count
  
A,B = map(int, input().split())
lcd=find_lcd(A,B)
#print(lcd)
print(find_num_prime(lcd))

Buggy submission (verdict: Runtime Error):
def find_lcd(A,B):
  if A==B:
    return A
  else:
    return find_lcd(min(A,B), abs(A-B))
  
def find_num_prime(X):
  if X==1:
    return 1
  count = 1 # 1
  i=2
  sqrt_org=int(X**0.5)
  while X != 1 and i<=sqrt_org:
    if X%i == 0:
      count += 1
      while X%i == 0:
        #print(str(X)+' '+str(i))
        X = X/i
    if i== 2:
      i += 1
    else:
      i += 2
  return count
  
A,B = map(int, input().split())
lcd=find_lcd(A,B)
#print(lcd)
print(find_num_prime(lcd))

Buggy submission (verdict: Runtime Error):
def find_lcd(A,B):
  if A==B:
    return A
  else:
    return find_lcd(min(A,B), abs(A-B))
  
def find_num_prime(X):
  if X==1:
    return 1
  count = 1 # 1
  i=2
  while X != 1:
    if X%i == 0:
      count += 1
      while X%i == 0:
        #print(str(X)+' '+str(i))
        X = X/i
    if i== 2:
      i += 1
    else:
      i += 2
  return count
  
A,B = map(int, input().split())
lcd=find_lcd(A,B)
#print(lcd)
print(find_num_prime(lcd))

Buggy submission (verdict: Runtime Error):
def find_lcd(A,B):
  if A==B:
    return A
  else:
    return find_lcd(min(A,B), abs(A-B))
  
def find_num_prime(X):
  if X==1:
    return 1
  count = 1 # 1
  i=2
  while X != 1:
    if X%i == 0:
      count += 1
      while X%i == 0:
        #print(str(X)+' '+str(i))
        X = X/i
    i += 1
  return count
  
A,B = map(int, input().split())
lcd=find_lcd(A,B)
#print(lcd)
print(find_num_prime(lcd))
Problem p02918 (python)

Fixed submission:
N, K = map(int,input().split())
L = input()
count=0
for i in range(N-1):
  if L[i]==L[i+1]:
    count += 1

print(min(count+2*K, N-1))

Buggy submission (verdict: Runtime Error):
N, K = map(int,input().split())
L = input()
count=0
for i in range(N-1):
  if L[i]==L[i+1]:
    count += 1

print(min(count+2*L, N-1))
Problem p03131 (python)

Fixed submission:
K , A , B = map(int, input().split())
ma = 0
if A >= B:
    ma = K + 1
elif A < B:
    if (K-A+1)%2 == 0:
        ma = max(((K-A+1)//2-1)*(B-A)+B,K+1)
    elif (K-A+1)%2 == 1:
        ma = max(((K-A+1)//2-1)*(B-A)+B+1,K+1)
print(ma)

Buggy submission (verdict: Runtime Error):
K , A , B = map(int, input().split())
if A >= B:
    print(K+1)
elif A < B:
    if (K-A+1)%2 == 0:
        ma = max(((K-A+1)//2-1)*(B-A)+B,K+1)
    elif (K-A+1)%2 == 1:
        ma =max(((K-A+1)//2-1)*(B-A)+B + 1,K+1)
print(ma)

Buggy submission (verdict: Runtime Error):
K , A , B = map(int, input().split())
if A >= B:
    print(K+1)
elif A < B:
    if (K-A+1)%2 == 0:
        ma = ((K-A+1)//2-1)*(B-A)+B
    elif (K-A+1)%2 == 1:
        ma = ((K-A+1)//2-1)*(B-A)+B + 1
print(ma)