Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n,x,y=map(int,input().split())
ans=[0 for i in range(n)]
for start in range(n):
  gone=[0 for i in range(n)]
  gone[start]=1
  now ={start}
  for i in range(1,n):
    go=set()
    for s in now:
      if s!=0 and gone[s-1]==0:
        go.add(s-1)
        gone[s-1]=1
        ans[i]+=1
      if s!=n-1 and gone[s+1]==0:
        go.add(s+1)
        gone[s+1]=1
        ans[i]+=1
      if s==x-1 and gone[y-1]==0:
        go.add(y-1)
        gone[y-1]=1
        ans[i]+=1
      if s==y-1 and gone[x-1]==0:
        go.add(x-1)
        gone[x-1]=1
        ans[i]+=1
    now=go
for i in range(1,n):
  print(ans[i]//2)


Fixed submission:
n,x,y=map(int,input().split())
ans=[0 for i in range(n)]
for start in range(n):
  gone=[0 for i in range(n)]
  gone[start]=1
  now ={start}
  for i in range(1,n):
    go=set()
    for s in now:
      if s!=0 and gone[s-1]==0:
        go.add(s-1)
        gone[s-1]=1
        ans[i]+=1
      if s!=n-1 and gone[s+1]==0:
        go.add(s+1)
        gone[s+1]=1
        ans[i]+=1
      if s==x-1 and gone[y-1]==0:
        go.add(y-1)
        gone[y-1]=1
        ans[i]+=1
      if s==y-1 and gone[x-1]==0:
        go.add(x-1)
        gone[x-1]=1
        ans[i]+=1
    now=go
for i in range(1,n):
  print(ans[i]//2)

Buggy python submission (verdict: Runtime Error):
n,x,y=map(int,input().split())
ans=[0 for i in range(n-1)]
for start in range(n):
  gone=[0 for i in range(n)]
  gone[start]=1
  now ={start}
  for i in range(1,n):
    go=set()
    for s in now:
      if s!=0 and gone[s-1]==0:
        go.add(s-1)
        gone[s-1]=1
        ans[i]+=1
      if s!=n-1 and gone[s+1]==0:
        go.add(s+1)
        gone[s+1]=1
        ans[i]+=1
      if s==x-1 and gone[y-1]==0:
        go.add(y-1)
        gone[y-1]=1
        ans[i]+=1
      if s==y-1 and gone[x-1]==0:
        go.add(x-1)
        gone[x-1]=1
        ans[i]+=1
    now=go
for i in range(1,n):
  print(ans[i]//2)

Fixed submission:
n,x,y=map(int,input().split())
ans=[0 for i in range(n)]
for start in range(n):
  gone=[0 for i in range(n)]
  gone[start]=1
  now ={start}
  for i in range(1,n):
    go=set()
    for s in now:
      if s!=0 and gone[s-1]==0:
        go.add(s-1)
        gone[s-1]=1
        ans[i]+=1
      if s!=n-1 and gone[s+1]==0:
        go.add(s+1)
        gone[s+1]=1
        ans[i]+=1
      if s==x-1 and gone[y-1]==0:
        go.add(y-1)
        gone[y-1]=1
        ans[i]+=1
      if s==y-1 and gone[x-1]==0:
        go.add(x-1)
        gone[x-1]=1
        ans[i]+=1
    now=go
for i in range(1,n):
  print(ans[i]//2)
Buggy python submission (verdict: Runtime Error):
x,y,a,b,c=map(int,input().split())
lia=list(map(int,input().split()))
lib=list(map(int,input().split()))
lic=list(map(int,input().split()))
lia.sort(reverse=True)
lib.sort(reverse=True)
lic.sort(reverse=True)
ans=lia[:x]+lib[:y]
ans.sort(reverse=True)
cnt=0
now=0
while cnt < a+b and now < c:
  if lic[now] > ans[cnt]:
    ans[cnt]=lic[now]
    now+=1
  cnt+=1
print(sum(ans))

Fixed submission:
x,y,a,b,c=map(int,input().split())
lia=list(map(int,input().split()))
lib=list(map(int,input().split()))
lic=list(map(int,input().split()))
lia.sort(reverse=True)
lib.sort(reverse=True)
lic.sort(reverse=True)
ans=lia[:x]+lib[:y]
ans.sort()
cnt=0
now=0
while cnt < x+y and now < c:
  if lic[now] > ans[cnt]:
    ans[cnt]=lic[now]
    now+=1
  cnt+=1
print(sum(ans))
Buggy python submission (verdict: Runtime Error):
import math

h,w,k = map(int,input().split())
s = [str(input()) for i in range(h)]
ans = h * w

if h == 1:
    onecnt = 0
    for i in range(w):
        if s[0][i] == "1":
            onecnt += 1
    print(math.ceil(onecnt/k))
    exit()

for i in range(2 ** (h-1)):
    ss = str(format(i,"b").zfill(h-1))
    cnt = 0
    zerocnt = 0
    for j in range(len(ss)):
        if ss[j] == "0":
            zerocnt += 1
    now = [0 for i in range(zerocnt+1)]
    for j in range(w):
        next = []
        num = 0
        for n in range(h):
            if s[n][j] == "1":
                num += 1
            if num > k:
                break
            if n < h-1 and ss[n] == "0":
                next.append(num)
                num = 0
        next.append(num)
  #        print(next,now)
        for n in range(zerocnt+1):
            if now[n] + next[n] > k:
                now = next
                cnt += 1
                break
            else:
                now[n] += next[n]
  #    print(now)
  #    print(ans,cnt,zerocnt)
    ans = min(ans,cnt+zerocnt)
print(ans)



Fixed submission:
n,m = map(int,input().split())
print((n*(n-1))//2+(m*(m-1))//2)
Buggy python submission (verdict: Runtime Error):
n = int(input())
lis = list(map(int,input().split()))
num = [0 for i in range(n)]
for nn in lis:
  num[nn-1] += 1
ans = 0
for nnn in num:
  ans += (nnn*(nnn-1))//2
for i in range(n):
  print(ans-(num[lis[i]]*(num[lis[i]]-1))//2+((num[lis[i]]-1)*(num[lis[i]]-2))//2)

Fixed submission:
n = int(input())
lis = list(map(int,input().split()))
num = [0 for i in range(n+1)]
for nn in lis:
  num[nn] += 1
ans = 0
for nnn in num:
  ans += (nnn*(nnn-1))//2
for i in range(n):
  print(ans-(num[lis[i]]*(num[lis[i]]-1))//2+((num[lis[i]]-1)*(num[lis[i]]-2))//2)
Buggy python submission (verdict: Runtime Error):

ab=""
cnt = 0
while ab=="" and cnt<len(a):
  for i in range(min(len(b),len(a)-cnt)):
    if a[i+cnt]!="?" and b[i]!="?" and a[i+cnt]!=b[i]:
      ab=""
      break
    else:
      if a[i+cnt]!="?":
        ab += a[i+cnt]
      else:
        ab +=b[i]
if ab=="":
  ab =a+b
abc=""
cnt=0
while abc=="" and cnt<len(ab):
  for i in range(min(len(c),len(ab)-cnt)):
    if ab[i+cnt]!="?" and c[i+cnt]!="?" and ab[i+cnt]!=c[i+cnt]:
      abc=""
      break
    else:
      if ab[i+cnt]!="?":
        abc+=ab[i+cnt]
      else:
        abc+=c[i]
if abc!="":
  ans =min(ans,len(abc))


Fixed submission:
lis=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k=int(input())
print(lis[k-1])

Buggy python submission (verdict: Runtime Error):
import math
a,b,c =map(int,input().split())
if math.sqrt(a)+math.sqrt(b)==math.sqrt(c):
  print("Yes")
else:
  print("No")


Fixed submission:
lis=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k=int(input())
print(lis[k-1])
Buggy python submission (verdict: Runtime Error):
import math
a,b,c =map(int,input().split())
if math.sqrt(a)+math.sqrt(b)=math.sqrt(c):
  print("Yes")
else:
  print("No")

Fixed submission:
a,b,c=map(int,input().split())
if 0>=c-a-b:
  print("No")
  exit()
if 4*a*b<(c-a-b)**2:
  print("Yes")
else:print("No")
Buggy python submission (verdict: Runtime Error):
s=str(input())
q=int(input())
now = 0
mae,usiro="",""
for _ in range(q):
  lis = list(map(str,input().split()))
  if int(lis[0]) == 1:
    now = (now+1)%2
  else:
    if (int(lis[1])+now)%2 == 1:
      mae = lis[2]+mae
    else:
      usiro= usiro +lis[2]
s = mae+s+usiro
if now ==0:
  print(s)
else:
  print(s[::-1])
    
  


Fixed submission:
s =str(input())
if "A" not in s or "B" not in s:
  print("No")
else:
  print("Yes")

Buggy python submission (verdict: Runtime Error):
s=list(str(input()))
q=int(input())
now = 0
for _ in range(q):
  lis = list(map(str,input().split()))
  if int(lis[0]) == 1:
    now = (now+1)%2
  else:
    if (int(lis[1])+now)%2 == 1:
      s.insert(0,lis[2])
    else:
      s.append(lis[2])
if now ==0:
  for i in range(len(s)):
    print(s[i],end="")
else:
  for i in range(len(s)):
    print(s[-i-1],end="")
    
  


Fixed submission:
s =str(input())
if "A" not in s or "B" not in s:
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
ans = [-1 for i in range(n)]
for i in range(n):
  s,c = map(int,input().split())
  if ans[s-1] != -1 and ans[s-1] != str(c):
    print(-1)
    exit()
  ans[s-1] = str(c)
for i in range(n):
  if ans[i] == -1:
    ans[i] = "0"
print(int("".join(ans)))

Fixed submission:
n,m = map(int,input().split())
ans = [-1 for i in range(n)]
for i in range(m):
  s,c = map(int,input().split())
  if s == 1 and c == 0 and n != 1:
    print(-1)
    exit()
  if ans[s-1] != -1 and ans[s-1] != str(c):
    print(-1)
    exit()
  ans[s-1] = str(c)
for i in range(n):
  if ans[i] == -1:
    if i == 0 and n != 1:
      ans[0] = "1"
    else:
      ans[i] = "0"
print(int("".join(ans)))
Buggy python submission (verdict: Runtime Error):
s,t = map(int,input().split())
a,b = map(int,input().split())
u = str(input())
if u == s:
    a -= 1
else:
    b -= 1
print(a,b)

Fixed submission:
s,t = map(str,input().split())
a,b = map(int,input().split())
u = str(input())
if u == s:
    a -= 1
else:
    b -= 1
print(a,b)
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
from functools import reduce

mod = 10 ** 9 + 7

def lcm(a,b):
    return a * b//gcd(a,b)

n = int(input())
lis = list(map(int,input().split()))
now = reduce(lcm,lis)

num = list(map(lambda x:now//x,lis))

print(sum(num) % mod)


Fixed submission:
from fractions import gcd
from functools import reduce

mod = 10 ** 9 + 7

def lcm(a,b):
    return a * b//gcd(a,b)

n = int(input())
lis = list(map(int,input().split()))
now = reduce(lcm,lis)

print(sum(list(map(lambda x:now//x,lis)))%mod)

Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
from functools import reduce

mod = 10 ** 9 + 7

def lcm(a,b):
    return a * b//gcd(a,b)

n = int(input())
lis = list(map(int,input().split()))
now = reduce(lcm,lis)

num = list(map(lambda x:now//x,lis))

print(sum(num) % mod)


Fixed submission:
from fractions import gcd
from functools import reduce

mod = 10 ** 9 + 7

def lcm(a,b):
    return a * b//gcd(a,b)

n = int(input())
lis = list(map(int,input().split()))
now = reduce(lcm,lis)

print(sum(list(map(lambda x:now//x,lis)))%mod)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
import math
n = int(input())
lis = list(map(int,input().split()))
lis.sort()
nu = []
for i in range(1,math.floor(math.sqrt(lis[0]))+1):
    if lis[0] % i == 0:
        nu.append(lis[0]//i)
        nu.append(i)
nu.sort(reverse = True)
for num in nu:
    key = 1
    for i in range(n):
        if lis[i] % num != 0:
            key = 0
            break
    if key == 1:
        for i in range(n):
            lis[i] = lis[i] // num
        break
nn = 1
for i in range(n):
    nn = (nn * lis[i]) // fractions.gcd(nn,lis[i])
ans = 0
for i in range(n):
    ans += nn//lis[i]
    ans %= 10 ** 9 + 7
print(ans)

Fixed submission:
from fractions import gcd
from functools import reduce

mod = 10 ** 9 + 7

def lcm(a,b):
    return a * b//gcd(a,b)

n = int(input())
lis = list(map(int,input().split()))
now = reduce(lcm,lis)

print(sum(list(map(lambda x:now//x,lis)))%mod)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
import math
n = int(input())
lis = list(map(int,input().split()))
lis.sort()
nu = []
for i in range(1,math.floor(math.sqrt(lis[0]))+1):
    if lis[0] % i == 0:
        nu.append(lis[0]//i)
        nu.append(i)
nu.sort(reverse = True)
for num in nu:
    key = 1
    for i in range(n):
        if lis[i] % num != 0:
            key = 0
            break
    if key == 1:
        for i in range(n):
            lis[i] = lis[i] // num
        break
nn = 1
for i in range(n):
    nn = (nn * lis[i]) // fractions.gcd(nn,lis[i])
ans = 0
for i in range(n):
    ans += nn//lis[i]
    ans %= 10 ** 9 + 7
print(ans)

Fixed submission:
from fractions import gcd
from functools import reduce

mod = 10 ** 9 + 7

def lcm(a,b):
    return a * b//gcd(a,b)

n = int(input())
lis = list(map(int,input().split()))
now = reduce(lcm,lis)

print(sum(list(map(lambda x:now//x,lis)))%mod)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lis = []
for i in range(n):
    a,b =map(int,input().split())
    lis.append([a-b,a+b])
lis.sort(key = lambda x:x[1])
dp = {(-2 * 10 ** 9,0)}
for aa,bb in lis:
    now = set()
    for nowa,ans in dp:
        if nowa <= aa:
            now.add((bb,ans+1))
        now.add((nowa,ans))
    dp = now
an = 0
for aaa,ans in dp:
    an = max(an,ans)
print(an)

Fixed submission:
n = int(input())
lis = []
for i in range(n):
    a,b =map(int,input().split())
    lis.append([a-b,a+b])
lis.sort(key = lambda x:x[1])
ans = 0
now = -10 ** 10
for a,b in lis:
    if now <= a:
        ans += 1
        now = b
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lis = []
for i in range(n):
    a,b =map(int,input().split())
    lis.append([a-b,a+b])
lis.sort(key = lambda x:x[1])
dp = {(-2 * 10 ** 9,0)}
for aa,bb in lis:
    now = set()
    for nowa,ans in dp:
        if nowa <= aa:
            now.add((bb,ans+1))
        now.add((nowa,ans))
    dp = now
an = 0
for aaa,ans in dp:
    an = max(an,ans)
print(an)

Fixed submission:
n = int(input())
lis = []
for i in range(n):
    a,b =map(int,input().split())
    lis.append([a-b,a+b])
lis.sort(key = lambda x:x[1])
ans = 0
now = -10 ** 10
for a,b in lis:
    if now <= a:
        ans += 1
        now = b
print(ans)
Buggy python submission (verdict: Runtime Error):
n,k,s = map(int,input().split())
if s == 10 ** 9:
    num = 10 ** 9-1
else:
    num == 10 ** 9
print(" ".join([str(s)]+["0" for i in range(k-1)]+[str(num) for j in range(n-k)]))

Fixed submission:
n,k,s = map(int,input().split())
ans = []
if s == 10 ** 9:
    num = 10 ** 9-1
else:
    num = 10 ** 9
for i in range(k):
    ans.append(str(s))
for i in range(n-k):
    ans.append(str(num))
print(" ".join(ans))
Buggy python submission (verdict: Runtime Error):
s = str(input())
print(char(ord(s)+1))

Fixed submission:
s = str(input())
print(chr(ord(s)+1))
Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = 0
s = [list(map(str(input().split()))) for i in range(n)]
key_s = str(input())
key = 0
for _ in range(n):
  for t,tt in s:
    if key == 1:
      ans += int(tt)
    if t == key_s:
      key = 1
print(ans)
    

Fixed submission:
n = int(input())
ans = 0
s = [list(map(str,input().split())) for i in range(n)]
key_s = str(input())
key = 0
for t,tt in s:
  if key == 1:
    ans += int(tt)
  if t == key_s:
    key = 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
if abs(a-b)%2 == 0:
  print(abs(a-b)//2)
else:
  print(min((a+b+1)//2,(n-a+n-b+1)//2)

Fixed submission:
n,a,b = map(int,input().split())
if abs(a-b)%2 == 0:
  print(abs(a-b)//2)
else:
  print(min((a+b-1)//2,(n-a+n-b+1)//2))
Buggy python submission (verdict: Time Limit Exceeded):
import math
n= int(input())
s = str(input())
num = len(s)
ans = 0
for i in range(1000):
    t = (3-len(str(i))) * "0" + str(i)
    key1,key2 = 0,0
    num= len(s)
    for j in range(num):
        if s[j] == t[2] and key2:
            ans += 1
            break
        if s[j] == t[1] and key1:
            key2 = 1
        if s[j] == t[0]:
            key1 = 1
print(ans)

Fixed submission:
import math
n= int(input())
s = str(input())
num = len(s)
ans = 0
for i in range(1000):
    t = (3-len(str(i))) * "0" + str(i)
    key1,key2 = 0,0
    num= len(s)
    for j in range(num):
        if s[j] == t[2] and key2:
            ans += 1
            break
        if s[j] == t[1] and key1:
            key2 = 1
        if s[j] == t[0]:
            key1 = 1
print(ans)
Buggy python submission (verdict: Runtime Error):
lis = ["SUN","MON","TUE","WEN","THU","FRI","SAT"]
s = str(input())
print((7-lis.index(s))%7)

Fixed submission:
lis = ["SUN","MON","TUE","WED","THU","FRI","SAT"]
s = str(input())
print((7-lis.index(s)))
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
s = str(input())
now = n
ans = ""
while now != 0:
    for num in range(min(m,now),0,-1):
        if s[now-num] == "0":
            now -= num
            ans=str(num)+" "+ans
            break
        else:
            if num == 1:
                print(-1)
                exit()
print(ans)

Fixed submission:
n,m = map(int,input().split())
s = str(input())
now = n
ans = ""
while now != 0:
    for num in range(min(m,now),0,-1):
        if s[now-num] == "0":
            now -= num
            ans=str(num)+" "+ans
            break
        else:
            if num == 1:
                print(-1)
                exit()
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
s = str(input())
now = n
ans = []
while now != 0:
    for num in range(min(m,now),0,-1):
        if s[now-num] == "0":
            now -= num
            ans.insert(0,num)
            break
        else:
            if num == 1:
                print(-1)
                exit()
print(" ".join(map(str,ans)))

Fixed submission:
n,m = map(int,input().split())
s = str(input())
now = n
ans = ""
while now != 0:
    for num in range(min(m,now),0,-1):
        if s[now-num] == "0":
            now -= num
            ans=str(num)+" "+ans
            break
        else:
            if num == 1:
                print(-1)
                exit()
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int,input().split())
s = str(input())
now = n
ans = []
while now != 0:
    for num in range(min(m,now),0,-1):
        if s[now-num] == "0":
            now -= num
            ans.insert(0,num)
            break
        else:
            if num == 1:
                print(-1)
                exit()
print(" ".join(map(str,ans)))

Fixed submission:
n,m = map(int,input().split())
s = str(input())
now = n
ans = ""
while now != 0:
    for num in range(min(m,now),0,-1):
        if s[now-num] == "0":
            now -= num
            ans=str(num)+" "+ans
            break
        else:
            if num == 1:
                print(-1)
                exit()
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
ans = -1
num = 0
for i in range(n):
    a,b = map(int,input().split())
    ans += b
    num += a * b
    if num > 9:
        ans += num // 9
        num %= 9
        if num == 0:
            ans -= 1
            num = 9
print(ans)

Fixed submission:
a,b = map(int,input().split())
ans = 0
if a == 1:ans += 300000
elif a == 2:ans += 200000
elif a == 3:ans += 100000
if b == 1:ans += 300000
elif b == 2:ans += 200000
elif b == 3:ans += 100000
if ans == 600000:ans += 400000
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,t = map(int,input().split())
time = [-1 for i in range(6030)]
time[0] = 0
now = 0
lis = [list(map(int,input().split())) for i in range(n)]
lis.sort(key = lambda x:x[0])
for i in range(n):
    for j in range(t-1,-1,-1):
        if time[j] != -1:
            time[j+lis[i][0]] = max(time[j+lis[i][0]],time[j]+lis[i][1])
print(max(time))

Fixed submission:
n,t = map(int,input().split())
time = [0 for i in range(3000)]
now = 0
ans = 0
lis = [list(map(int,input().split())) for i in range(n)]
lis.sort(key=lambda x:x[0])
for i in range(n):
    for j in range(t-1,-1,-1):
        if lis[i][0] + j >= t:
            ans = max(ans,time[j]+lis[i][1])
        else:
            time[j+lis[i][0]] = max(time[j+lis[i][0]],time[j]+lis[i][1])
print(max(ans,max(time)))
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
lis = list(map(int,input().split()))
li = list(map(int,input().split()))
lis.sort(reverse=True)
li.sort()
hi = 10 ** 12
low = 0
while hi > low+1:
    mid = (hi + low)//2
    cnt = 0
    for i in range(n):
        cnt += max(0,lis[i]-mid//li[i])
    if cnt <= k:
        hi = mid
    else:
        low = mid
    ans1 = low
    ans2 = hi
cnt = 0
for i in range(n):
    cnt += max(0,lis[i]-ans1//li[i])
if cnt <= k:
    print(ans1)
else:
    print(ans2)

Fixed submission:
n,k = map(int,input().split())
lis = list(map(int,input().split()))
li = list(map(int,input().split()))
lis.sort(reverse=True)
li.sort()
hi = 10 ** 12
low = 0
while hi > low+1:
    mid = (hi + low)//2
    cnt = 0
    for i in range(n):
        cnt += max(0,lis[i]-mid//li[i])
    if cnt <= k:
        hi = mid
    else:
        low = mid
    ans1 = low
    ans2 = hi
cnt = 0
for i in range(n):
    cnt += max(0,lis[i]-ans1//li[i])
if cnt <= k:
    print(ans1)
else:
    print(ans2)
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
a,b = map(int,input().split())
ans = 1
now = fractions.gcd(a,b)
for num in range(2,fractions.gcd(a,b)+1):
  if num > now:
    break
  if now % num == 0:
    ans += 1
    while now % num == 0:
      now //= num
print(ans)

Fixed submission:
import fractions
a,b = map(int,input().split())
c = fractions.gcd(a,b)

ans = [1]
while c % 2 == 0:
  ans.append(2)
  c //= 2
i = 3
while c >= i ** 2:
  if c % i == 0:
    ans.append(i)
    c //= i
  else:
    i += 2
if c != 1:
  ans.append(c)
print(len(set(ans)))

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
a,b = map(int,input().split())
ans = 1
now = fractions.gcd(a,b)
for num in range(2,fractions.gcd(a,b)+1):
  if num > now:
    break
  if now % num == 0:
    ans += 1
    while now % num == 0:
      now //= num
print(ans)

Fixed submission:
import fractions
a,b = map(int,input().split())
c = fractions.gcd(a,b)

ans = [1]
while c % 2 == 0:
  ans.append(2)
  c //= 2
i = 3
while c >= i ** 2:
  if c % i == 0:
    ans.append(i)
    c //= i
  else:
    i += 2
if c != 1:
  ans.append(c)
print(len(set(ans)))

Buggy python submission (verdict: Time Limit Exceeded):
import math
import fractions
a,b = map(int,input().split())
ans = 1
now = fractions.gcd(a,b)
for num in range(2,fractions.gcd(a,b)+1):
  if num > now:
    break
  if now % num == 0:
    ans += 1
    while now % num == 0:
      now = now//num
print(ans)

Fixed submission:
import fractions
a,b = map(int,input().split())
c = fractions.gcd(a,b)

ans = [1]
while c % 2 == 0:
  ans.append(2)
  c //= 2
i = 3
while c >= i ** 2:
  if c % i == 0:
    ans.append(i)
    c //= i
  else:
    i += 2
if c != 1:
  ans.append(c)
print(len(set(ans)))

Buggy python submission (verdict: Time Limit Exceeded):
import math
a,b = map(int,input().split())
ans = 1
nowa = a
nowb = b
for num in range(2,min(a,b)):
  if num > nowa and num > nowb:
    print(ans)
    exit()
  if nowa % num == 0 and nowb % num == 0:
    ans += 1
    while nowa % num == 0 and nowb % num == 0:
      nowa = nowa//num
      nowb = nowb//num
print(ans)

Fixed submission:
import fractions
a,b = map(int,input().split())
c = fractions.gcd(a,b)

ans = [1]
while c % 2 == 0:
  ans.append(2)
  c //= 2
i = 3
while c >= i ** 2:
  if c % i == 0:
    ans.append(i)
    c //= i
  else:
    i += 2
if c != 1:
  ans.append(c)
print(len(set(ans)))
Buggy python submission (verdict: Runtime Error):
n = int(input())
lis = list(map(int,input().split()))
ans = lis[0] + lis[-1]
for i in range(n-1):
    ans += min(lis[i],lis[i+1])
print(ans)

Fixed submission:
n = int(input())
lis = list(map(int,input().split()))
ans = lis[0] + lis[-1]
for i in range(n-2):
    ans += min(lis[i],lis[i+1])
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input)
lis=list(map(int,input().split()))
an=0
ans=0
for i in range(n-1):
  if lis[i]>=lis[i+1]:
    an += 1
  else:
    ans =max(ans,an)
    an=0
ans=max(ans,an)
print(ans)

Fixed submission:
n=int(input())
lis=list(map(int,input().split()))
an=0
ans=0
for i in range(n-1):
  if lis[i]>=lis[i+1]:
    an += 1
  else:
    ans =max(ans,an)
    an=0
ans=max(ans,an)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0
for i in range(n):
  ans += i
print(ans)

Fixed submission:
n = int(input())
print((n * (n-1))//2)
Buggy python submission (verdict: Runtime Error):
s = str(input())
num = len(s)
dp = [[0,0] for i in range(n+1)]
for i in range(n):
  for j in [1,2]:
    for k in [1,2]:
      if i + k <= n:
        a = s[i-j:i]
        b = s[i:i+k]
        if a != b:
          dp[i+k][k-1] = max(dp[i+k][k-1],dp[i][j-1]+1)
print(max(dp[n]))

Fixed submission:
s = str(input())
n = len(s)
dp = [[0,0] for i in range(n+1)]
for i in range(n):
  for j in [1,2]:
    for k in [1,2]:
      if i + k <= n:
        a = s[i-j:i]
        b = s[i:i+k]
        if a != b:
          dp[i+k][k-1] = max(dp[i+k][k-1],dp[i][j-1]+1)
print(max(dp[n]))