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

Fixed submission:
a,b = map(int,input().split())
if a==b:
  print(a)
else:
  ans = a
  if b-a<10**7:
    for i in range(a+1,b+1):
      ans = ans^i
    print(ans)
  else:
    if a%2==0:
      if (b-a)%4==1:
        print(1)
      elif (b-a)%4==2:
        print(b+1)
      elif (b-a)%4==3:
        print(0)
      else:
        print(b)
    else:
      if (b-a)%4==1:
        print(a^b)
      elif (b-a)%4==2:
        print(a-1)
      elif (b-a)%4==3:
        print((a-1)^b)
      else:
        print(a)

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
if a==b:
  print(a)
else:
  ans = a
  if b-a<10**7:
    for i in range(a+1,b+1):
      ans = ans^i
    print(ans)
  else:
    if a%2==0:
      if (b-a)%4==1:
        print(1)
      elif (b-a)%4==2:
        print(b+1)
      elif (b-a)%4==3:
        print(0)
      else:
        print(b)
    else:
      elif (b-a)%4==1:
        print(a^b)
      elif (b-a)%4==2:
        print(a-1)
      elif (b-a)%4==3:
        print((a-1)^b)
      else:
        print(a)
Problem p03209 (python)

Fixed submission:
import sys
def qwe(n,x,ans):
    n1 = "BPPPB"
    n2 = "BBPPPBPBPPPBB"
    if n==1:
        for s in n1:
            if s=="P": ans+=1
            x-=1
            if x==0:
                print(ans)
                sys.exit()
    else:
        for s in n2:
            if s=="P": ans+=1
            x-=1
            if x==0:
                print(ans)
                sys.exit()

def main():
    n,x = map(int, input().split())
    if n<=2:
        qwe(n,x,0)
    a = [1]
    b = [1]
    for i in range(n-1):
        a.append(2*a[-1]+3)
        b.append(2*b[-1]+1)
    ans = 0
    if x== 2*a[n-1]+3:
        print(2*b[n-1]+1)
        sys.exit()
    elif x==2*a[n-1]+2:
        print(2*b[n-1]+1)
        sys.exit()
    elif x == a[n-1]+2:
        print(b[n-1]+1)
        sys.exit()
    elif x== a[n-1]+1:
        print(b[n-1])
        sys.exit()
    elif x > a[n-1]+2:
        ans += b[n-1]+1
        x -= a[n-1]+2
        n = n-1
    else:
        x -=1
        n = n-1
    while n>2 or x > 0:
        if x== 2*a[n-1]+3:
            ans += 2*b[n-1]+1
            print(ans)
            sys.exit()
        elif x==2*a[n-1]+2:
            ans += 2*b[n-1]+1
            print(ans)
            sys.exit()
        if x == a[n-1]+2:
            ans += b[n-1]+1
            print(ans)
            sys.exit()
        elif x== a[n-1]+1:
            ans+=b[n-1]
            print(ans)
            sys.exit()
        elif x > a[n-1]+2:
            ans += b[n-1]+1
            x -= a[n-1]+2
            n = n-1
        else:
            x -=1
            n = n-1
    if x==0:
        print(ans)
        sys.exit()
    qwe(n,x,ans)
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n,x = map(int, input().split())
    a = "P"
    for i in range(n):
        a = "B" + a + "P" + a + "B"
    c = 0
    for s in a[:x]:
        if s == "P":
            c+=1
    print(c)

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

Fixed submission:
# coding: utf-8

week = {"SUN":7,"MON":6,"TUE":5,"WED":4,"THU":3,"FRI":2,"SAT":1}

str = input()

print(week[str])

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

alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

num = int(input())
str = input()
result = ""

for s in str:
  pos = alpha.find(s)
  result += alpha[pos+num]

print(result)
Problem p02933 (python)

Fixed submission:
a=int(input())
s=input()
if a>=3200:
  print(s)
else:
  print('red')

Buggy submission (verdict: Runtime Error):
import py

a = input()
a=int(a)
s=input()
if a >= 3200:
  print(s)
else:
    print('red')

Buggy submission (verdict: Runtime Error):
a=input()
a=int(x)
s=input()
if y>=3200:
  print(s)
else:
  print("red")

Buggy submission (verdict: Runtime Error):
a = input()
s=input()
if a >= 3200:
  print(s)
else:
    print('red')
Problem p02847 (python)

Fixed submission:
S = input()

if S == "SUN":
    print(7)
elif S == "MON":
    print(6)
elif S == "TUE":
    print(5)
elif S == "WED":
    print(4)
elif S == "THU":
    print(3)
elif S == "FRI":
    print(2)
else:
    print(1)

Buggy submission (verdict: Runtime Error):
S = input()

if S == "SAT":
    print(1)
elif S ==  "FRI":
    print(2)
elif S == "THU":
    print(3)
elif S == "WED":
    print(4)
elif S == "TUE":
    print(5)
elif S == "MON":
    print(6)
else S == "SUN":
    print(7)

Buggy submission (verdict: Runtime Error):
S = input()

if S == "SAT":
    print(1)
elif S=="FRI":
    print(2)
elif S=="THU":
    print(3)
elif S=="WED":
    print(4)
elif S=="TUE":
    print(5)
elif S=="MON":
    print(6)
else S=="SUN":
    print(7)

Buggy submission (verdict: Runtime Error):
S = input()

if S == "SAT":
    print(1)
elif S=='FRI':
    print(2)
elif S=='THU':
    print(3)
elif S=='WED':
    print(4)
elif S=='TUE':
    print(5)
elif S=='MON':
    print(6)
else S=='SUN':
    print(7)

Buggy submission (verdict: Runtime Error):
S = input()

if S == "SAT":
  print(1)
elif S=='FRI':
  print(2)
elif S=='THU':
  print(3)
elif S=='WED':
  print(4)
elif S=='TUE':
  print(5)
elif S=='MON':
  print(6)
else S=='SUN':
  print(7)

Buggy submission (verdict: Runtime Error):
S = input()

if S == 'SAT':
  print(1)
elif S=='FRI':
  print(2)
elif S=='THU':
  print(3)
elif S=='WED':
  print(4)
elif S=='TUE':
  print(5)
elif S=='MON':
  print(6)
else S=='SUN':
  print(7)

Buggy submission (verdict: Runtime Error):
S=input()

if S=='SAT':
  print(1)
elif S=='FRI':
  print(2)
elif S=='THU':
  print(3)
elif S=='WED':
  print(4)
elif S=='TUE':
  print(5)
elif S=='MON':
  print(6)
else S=='SUN':
  print(7)

Buggy submission (verdict: Runtime Error):
if S=='SAT':
    print(1)
elif S=='FRI':
    print(2)
elif S=='THU':
    print(3)
elif S=='WED':
    print(4)
elif S=='TUE':
    print(5)
elif S=='MON':
    print(6)
else S=='SUN':
    print(7)

Buggy submission (verdict: Runtime Error):
if S=='SAT':
  print(1)
elif S=='FRI':
  print(2)
elif S=='THU':
  print(3)
elif S=='WED':
  print(4)
elif S=='TUE':
  print(5)
elif S=='MON':
  print(6)
else S=='SUN':
  print(7)
Problem p03127 (python)

Fixed submission:
from functools import reduce

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


if __name__ == '__main__':
    n = int(input())
    a = [int(s) for s in input().split()]
    print(reduce(gcd, a))

Buggy submission (verdict: Runtime Error):
from functools import reduce
from math import gcd

if __name__ == '__main__':
    n = int(input())
    a = [int(s) for s in input().split()]
    print(reduce(gcd, a))
Problem p03317 (python)

Fixed submission:
def solve(n, k):
    div, mod = divmod(n - 1, k - 1)
    return div + (0 if mod == 0 else 1)

if __name__ == "__main__":
    n, k = map(int, input().split())
    array = [int(s) for s in input().split()]
    print(solve(n, k))

Buggy submission (verdict: Runtime Error):
def solve(array, k):
    if len(array) <= 1:
        return 0
    if array[0] == array[1]:
        return solve(array[1:], k)
    if len(array) <= k:
        return 1
    return 1 + solve([min(array[:k])] + array[k:], k)

if __name__ == "__main__":
    n, k = map(int, input().split())
    array = [int(s) for s in input().split()]
    print(solve(array, k))
Problem p03723 (python)

Fixed submission:
def solve(a, b, c, ans):
    if (a, b, c) in s:
        return -1
    if (a % 2) or (b % 2) or (c % 2):
        return ans
    s.add((a, b, c))
    a >>= 1
    b >>= 1
    c >>= 1
    return solve(b + c , c + a, a + b, ans + 1)

if __name__ == '__main__':
    a, b, c = map(int, input().split())
    s = set()
    print(solve(a, b, c, 0))

Buggy submission (verdict: Runtime Error):
def solve(a, b, c):
    if (a, b, c) in s:
        return -1
    if (a % 2) or (b % 2) or (c % 2):
        return 0
    a >>= 1
    b >>= 1
    c >>= 1
    return 1 + solve(b + c , c + a, a + b)

if __name__ == '__main__':
    a, b, c = map(int, input().split())
    s = set()
    print(solve(a, b, c))
Problem p02860 (python)

Fixed submission:
n=int(input())
s=input()
if len(s)%2==1:
  print('No')
else:
  i=len(s)//2
  if s[:i]+s[:i]==s:
    print('Yes')
  else :
    print('No')

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
if len(s)%2==1:
  print('No')
else:
  i=len(s)/2
  j=i//1
  if s[:j]+s[:j]==s:
    print('Yes')

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
if len(s)%2==1:
  print('No')
else:
  i=len(s)/2
  j=i//1
  if s[:j]+s[:j]==s:
    print(Yes)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
if len(s)%2==1:
  print('No')
else:
  i=len(s)/2//1
  if s[:i]*2==s:
    print(Yes)
Problem p02916 (python)

Fixed submission:
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
sat=sum(b)
for i in range(n-1):
  if a[i+1]==a[i]+1:
    sat+=c[a[i]-1]
print(sat)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
sat=sum(b)
for i in range(n-1):
  if a[i+1]==a[i]+1:
    sat+=c[a[i]]
print(sat)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
sat=sum(b)
for i in range(n-1):
  if a[i+1]=a[i]+1:
    sat+=c[i]
print(sat)
Problem p02935 (python)

Fixed submission:
n=int(input())
v=[int(i) for i in input().split()]
v.sort()
mid=(v[0]+v[1])/2
for i in range(2,n):
  mid=(mid+v[i])/2
print(mid)

Buggy submission (verdict: Runtime Error):
n=int(input())
v=[int(i) for i in input().split()]
v.sort()
mid=(v[0]+v[1])/2
for i in v[2,n]:
  mid=(mid+i)/2
print(mid)

Buggy submission (verdict: Runtime Error):
n=int(input())
v=[int(i) for i in input().split()]
v.sort()
mid=(v[0]+v[1])/2
for i in v[2,n]:
  mid=(mid+v[i])/2
print(mid)
Problem p02989 (python)

Fixed submission:
n=int(input())
d=[int(i) for i in input().split()]
d.sort()
print(d[n//2]-d[n//2-1])

Buggy submission (verdict: Runtime Error):
n=int(input())
d=[int(i) for i in input().split()]
d.sort()
print(d[n//2+1]-d[n//2])

Buggy submission (verdict: Runtime Error):
n=int(input())
d=[int,input().split()]
d.sort()
print(d[n//2]-d[n//2+1])
Problem p02990 (python)

Fixed submission:
import math

n,k=map(int,input().split())
for i in range(1,k+1):
  if n-k<i-1:
      print(0)
  else :
    a=math.factorial(k-1)
    b=math.factorial(i-1)
    c=math.factorial(k-i)
    d=math.factorial(n-k+1)
    e=math.factorial(i)
    f=math.factorial(n-k-i+1)
    g=a//b//c
    h=d//e//f
    print(g*h%1000000007)

Buggy submission (verdict: Runtime Error):
import math

n,k=map(int,input().split())
for i in range(1,k+1):
  if n-k<i-1:
      print(0)
  else :
    a=math.factorial(k-1)
    b=math.factorial(i-1)
    c=math.factorial(k-i)
    d=math.factorial(n-k+1)
    e=math.factorial(i)
    f=math.factorial(n-k-i+1)
    g=a/b/c
    h=d/e/f
    print(g*h%1000000007)
Problem p03137 (python)

Fixed submission:
n,m=map(int,input().split())
x=[int(i) for i in input().split()]

x.sort()
y=[]
if n-m>=0:
  print(0)
  exit(0)
else:
  for i in range(m-1):
    y.append(x[i+1]-x[i])
y.sort()
print(sum(y[:m-n]))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
x=[input(i) for i in input().split()]

x.sort()
y=[]
if n-m>=0:
  print(0)
  exit(0)
else:
  for i in range(m-1):
    y.append(x[i+1]-x[i])
y.sort()
print(sum(y[:n-m+2]))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
x=[int(i) for i in input().split()]
x.sort()
y=[]
if n-m>=0:
  print(0)
  exit(0)
else:
  for i in range(n-1):
    y.append(x[i+1]-x[i])
y.sort()
print(sum(y[:n-m])
Problem p02951 (python)

Fixed submission:
A, B, C = map(int, input().split())
print(max(C - A + B, 0))

Buggy submission (verdict: Runtime Error):
a=input("A")
b=input("B")
c=input("C")
i=int(a)-int(b)
j=int(c)-int(i)
if j > 0:
    print(j)
else:
    print('0')

Buggy submission (verdict: Runtime Error):
a=input("a")
b=input("b")
i=int(a)-int(b)
c=input("c")
j=int(c)-int(i)
if j > 0:
    print(j)
else:
    print('0')
Problem p03072 (python)

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

ans = 0
max_H = 0
for h in H:
  if h >= max_H:
    max_H = h
    ans += 1

print(ans)

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

ans = 0
max_H = 0
for h in H:
  if h >= max_H:
    h = max_H
    ans += 1

print(ans)
Problem p02880 (python)

Fixed submission:
N = int(input())

def prime_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)
    a.sort(reverse = True)
    return a

a = prime_factorize(n = N)
ans = 'Yes'


if len(a) == 0:
    if N > 9:
        ans = 'No'
elif len(a) > 4:
    if N / 8 > 9:
        ans = 'No'
elif len(a) == 3:
    if a[1] * a[2] > 9:
        ans = 'No'
else:
    n = N
    b = []
    for i in a:
        n = n / i
        b.append(n)

    if a[0] > 9:
        ans = 'No'
    if N > 81:
        ans = 'No'
    
print(ans)

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

def prime_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

a = prime_factorize(n = N)

if len(a) > 2:
    b = a[0] * a[1]
    if b > 9:
        print('No')
    else:
        print('Yes')
else:
    if (a[0] > 9):
        print('No')
    else:
        print('Yes')
Problem p02987 (python)

Fixed submission:
S = str(input())
s = list(S)

s0 = s[0]
s1 = s[1]
s2 = s[2]
s3 = s[3]

c0 = S.count(s0)
c1 = S.count(s1)
c2 = S.count(s2)
c3 = S.count(s3)
ct = c0 + c1 + c2 + c3
ct

if ct == 8:
    print('Yes')
else:
    print('No')

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

import statistics
t = len(d) / 2
k_low = statistics.median_low(d)
k_high = statistics.median_high(d)

c = 0
C = 0
for i in d:
    if i < k_low:
        c +=1
    else:
        c+=0
        
if c == t:
    C += 1
else:
    C += 0

c = 0
for i in d:
    if i >= k_high:
        c +=1
    else:
        c+=0
        
if c == t:
    C += 1
else:
    C += 0
    
print(C)
Problem p02860 (python)

Fixed submission:
n = input()
s = input()
n = int(n)
if n % 2 == 1:
    print("No")
else: 
    t = s[0 : n//2]
    if s[n//2: n] == t:
        print('Yes')
    else:
         print('No')

Buggy submission (verdict: Runtime Error):
n,s = (input().split())
n = int(n)
if n % 2 == 1:
    print("No")
else: 
    t = s[0 : n//2]
    if s[n//2: n] == t:
        print('Yes')
    else:
         print('No')

Buggy submission (verdict: Runtime Error):
n,s = (input().split())
n = int(n)
if n % 2 == 1:
    print("No")
else: 
    t = s[0 : n//2]
    if s[n//2: n] == t:
        print("Yes")
    else:
         print("No")

Buggy submission (verdict: Runtime Error):
n,s = (input().split())
n = int(n)
if n == 1:
    print("No")
else: 
    t = s[0 : n//2]
    if s[n//2: n] == t:
        print("Yes")
    else:
         print("No")
Problem p02879 (python)

Fixed submission:

a,b = list(map(int, input().split()))
  
if(1<=a<=9 and 1<=b<=9):
    print(a*b)

else:
    print(-1)

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

if(1<=a<=9 & 1<=b<=9):
   print a*b
else:
   pring -1

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

b=int(input())

if(0<=a<=9 & 0<=b<=9):
    print(a*b)

else:
    print(-1)

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
if(0<=a<=9 and 0<=b<=9):
  print(a*b)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
a=input()
b=input()
if(0<=a<=9 and 0<=b<=9):
  print(a*b)
else:
  print(-1)
Problem p02859 (python)

Fixed submission:
r = int(input())
print("{}".format(int(r**2)))

Buggy submission (verdict: Runtime Error):
r = int(input)
print("{}".format(r**2))

Buggy submission (verdict: Runtime Error):
r = int(input)
print(r**2)

Buggy submission (verdict: Runtime Error):
r = input()
 print(r**2)
Problem p02860 (python)

Fixed submission:
n = int(input())
string = str(input())

s1 = ""
s2 = ""

if(n % 2 == 0):
    for i, st in enumerate(string):
        if i < n/2:
            s1 = s1 + st
        else:
            s2 = s2 + st

    if s1 == s2:
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

s1 = ""
s2 = ""

if(n % 2 == 0):
    for i, st in enumerate(string):
        if i < n/2:
            s1 = s1 + st
        else:
            s2 = s2 + st

    if s1 == s2:
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

s1 = ""
s2 = ""

if(n % 2 == 0):
    for i st in enumerate(string):
        if i < n/2:
            s1 = s1 + st
        else:
            s2 = s2 + st

    if s1 == s2:
        print("Yes")
    else:
        print("No")
else:
    print("No")
Problem p02860 (python)

Fixed submission:
str_num = input()
input_str = input()
input_array = list(input_str)

n = 0
int_str_num =int(str_num)

if int_str_num % 2 == 0:
    half_str_num = int_str_num/2
    int_half_str_num = int(half_str_num)
    for i in range(int_half_str_num):
        if input_array[i] == input_array[i+int_half_str_num]:
            n = n + 1
    if n == half_str_num:
        print('Yes')
    else:
        print('No')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
str_num = input()
input_str = input()
input_array = list(input_str)

match_num = 0
int_str_num =int(str_num)

if int_str_num % 2 == 0:
  half_str_num = int_str_num/2
  int_half_str_num = int(half_str_num)
  for i in range(int_half_str_num):
    if input_array[i] == input_array[i+int_half_str_num]:
      match_num = match_num + 1
    
  if n == half_str_num:
    print('Yes')
  else:
    print('No')
else:
  print('No')
Problem p02897 (python)

Fixed submission:
import math
a=int(input())
if(a%2==0):
  print(0.5000)
else:
  print(math.floor(a/2+1)/a)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
listA=[] #appendのために宣言が必要
i=0
a=[]
b=[]
c=[]
while True:
    try:
        if(i%2==0):
          i=i+1
          a1,b1=(list(map(int,input().split())))
          a.append(a1)
          b.append(b1)
          #listA.append(list(map(int,input().split())))
        else:
          i=i+1
          c.append(list(map(int,input().split())))	
    except:
        break;
        #または、quit(),os.exit()をして止める。

#print(listA)
#print(a)
#print(b)
#print(*c)
#偶数はa,b
get_=[]
money=[]
kei=0
for i in range(m):
  get_.extend(c[i])
  kei=kei+a[i]
  if(len(list(set(get_)))==n):
    money.append(kei)
  
print(min(money))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
listA=[] #appendのために宣言が必要
i=0
a=[]
b=[]
c=[]
while True:
    try:
        if(i%2==0):
          i=i+1
          a1,b1=(list(map(int,input().split())))
          a.append(a1)
          b.append(b1)
          #listA.append(list(map(int,input().split())))
        else:
          i=i+1
          c.append(list(map(int,input().split())))	
    except:
        break;
        #または、quit(),os.exit()をして止める。

#print(listA)
print(a)
print(b)
print(*c)
#偶数はa,b
get_=[]
money=[]
kei=0
for i in range(m):
  get_.extend(c[i])
  kei=kei+a[i]
  if(len(list(set(get_)))==n):
    money.append(kei)
  
print(min(money))

Buggy submission (verdict: Runtime Error):
x,y = map(int,input().split())

#print(x,y)

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
x_li=(make_divisors(x))
y_li=(make_divisors(y))
z_li=(list(set(x_li)&set(y_li)))
#print(z_li)

import math
count=1
c=[]
"""
for n in z_li:
  if n == 1:
    count=count+1
    continue
  for k in range(2, int(math.sqrt(n)) + 1):
    print(n,k)
    if n % k == 0:
      break;
    else:
      c.append(n)
      count = count+1
print(c,count)
"""

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True
  
  
for n in z_li:
  if(is_prime(n)==True):
    count=count+1
print(count)
Problem p03464 (python)

Fixed submission:
#
K = int(input())
A = list(map(int, input().split()))

#
if A[-1]!=2:
    print(-1)
    exit()
if K>1 and A[-2]!=2 and A[-2]!=3:
    print(-1)
    exit()

#
min_n = 2
max_n = 3
for i in A[::-1][1:]:
    a = (min_n - 1)//i
    b = max_n//i
    if a==b:
        print(-1)
        exit()

    if min_n%i==0:
        pass
    else:
        min_n = min_n + (i - min_n%i)
    max_n = max_n - max_n%i + i - 1
    #print(min_n, max_n)

#
print(min_n, max_n)

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

#
if A[-1]!=2:
    print(-1)
    exit()
if A[-2]!=2 and A[-2]!=3:
    print(-1)
    exit()

#
min_n = 2
max_n = 3
for i in A[::-1][1:]:
    a = (min_n - 1)//i
    b = max_n//i
    if a==b:
        print(-1)
        exit()

    if min_n%i==0:
        pass
    else:
        min_n = min_n + (i - min_n%i)
    max_n = max_n - max_n%i + i - 1
    #print(min_n, max_n)

#
print(min_n, max_n)
Problem p03127 (python)

Fixed submission:
import fractions
from functools import reduce
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)    

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

print(gcd_list(a))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd, numbers)    

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

print(gcd_list(a))
Problem p03209 (python)

Fixed submission:
p = [1]*51
t = [1]*51
def f(n,x):
    if n==0:
        return 1
    if x==1:
        return 0
    if x==t[n]:
        return p[n]
    if x==p[n]:
        return p[n-1]+1
    if x<p[n]:
        return f(n-1,x-1)
    return p[n-1]+f(n-1,x-p[n])+1

for i in range(1,51):
    p[i] = p[i-1]*2+1
    t[i] = t[i-1]*2+3
n,x = map(int,input().split())    
print(f(n,x))

Buggy submission (verdict: Runtime Error):
p = [1]*51
t = [1]*51
def f(n,x):
    if n==0:
        return f
    if x==1:
        return 0
    if x==t[n]:
        return p[n]
    if x==p[n]:
        return p[n-1]+1
    if x<p[n]:
        return f(n-1,x-1)
    return p[n-1]+f(n-1,x-p[n])+1

for i in range(1,51):
    p[i] = p[i-1]*2+1
    t[i] = t[i-1]*2+3
n,x = map(int,input().split())    
print(f(n,x))
Problem p03221 (python)

Fixed submission:
n,m=map(int,input().split())
l=[[] for i in range(n)]
for i in range(m):
    p,y=input().split()
    l[int(p)-1].append(y.zfill(10)+str(i).zfill(6))
for i in range(n):
    l[i].sort()
s=[0]*m
for i in range(n):
    for j in range(len(l[i])):
        s[int(l[i][j][10:16])]=str(i+1).zfill(6)+str(j+1).zfill(6)
for i in s:
    print(i)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=[[] for i in range(n)]
for i in range(m):
    p,y=input().split()
    l[int(p)-1].append(y.zfill(6)+str(i).zfill(6))
for i in range(n):
    l[i].sort()
s=[0]*m
for i in range(n):
    for j in range(len(l[i])):
        s[int(l[i][j][6:12])]=str(i+1).zfill(6)+str(j+1).zfill(6)
for i in s:
    print(i)