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

Fixed submission:
from functools import reduce
from fractions import gcd

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers)
mod = 10**9 + 7
n = int(input())
As = list(map(int, input().split()))

lcm = lcm_list(As)
b = [lcm//As[i] for i in range(n)]

print(sum(b) % mod)

Buggy submission (verdict: Runtime Error):
from functools import reduce
from fractions import gcd
import numpy as np

n = int(input())
As = list(map(int, input().split()))
mod = 10**9 + 7

def lcm_base(x, y):
    return (x * y) // gcd(x, y)
 
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
lcm = lcm_list(As)
As = np.array(As)
b = np.array([lcm]*n)
c = b / As
print(int(round(np.sum(c)))  % mod)

Buggy submission (verdict: Runtime Error):
from functools import reduce
from fractions import gcd
import numpy as np

n = int(input())
As = list(map(int, input().split()))
mod = 10**9 + 7

def lcm_base(x, y):
    return (x * y) // gcd(x, y)
 
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
lcm = lcm_list(As)
As = np.array(As)
b = np.array([lcm]*n)
c = b / As
print(int(round(np.sum(c) % mod)))

Buggy submission (verdict: Runtime Error):
from functools import reduce
from fractions import gcd
import numpy as np

n = int(input())
As = list(map(int, input().split()))
mod = 10**9 + 7

def lcm_base(x, y):
    return (x * y) // gcd(x, y)
 
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
lcm = lcm_list(As)
As = np.array(As)
b = np.array([lcm]*n)
c = b / As
print(int(np.sum(c) % mod))

Buggy submission (verdict: Runtime Error):
import numpy as np

n = int(input())
As = list(map(int, input().split()))
As = np.array(As)
mod = 10**9 + 7



k = np.lcm.reduce(As)
ans = 0
for i in range(n):
    ans += k // As[i]
    ans %= mod
print(ans)

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

n = int(input())
As = list(map(int, input().split()))
mod = 10**9 + 7
def lcm(l):
    if len(l) == 2:
        return l[1]*l[0] // gcd(l[1], l[0])
    else:
        k = lcm(l[:-1])
        return k*l[-1] // gcd(k, l[-1])

k = lcm(As)
ans = 0
for i in range(n):
    ans += k // As[i]
    ans %= mod
print(ans)
Problem p02880 (python)

Fixed submission:
import math

n = int(input())

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

def main(divisors, o):
    for i in range(o):
        a = divisors[i]
        b = divisors[::-1][i]
        
        if a <= 9 and b <= 9:
            return 'Yes'
    return 'No'


divs = make_divisors(n)

o = int(len(divs)/2 + len(divs) % 2)

print(main(divs, o))

Buggy submission (verdict: Runtime Error):
import math

n = int(input())

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

def main(divisors, o):
    for i in range(o):
        a = divisors[i]
        b = divisors[::-1][i]
        
        if a <= 9 and b <= 9:
            return 'Yes'
    return 'No'


divs = make_divisors(n)

o = len(divs)/2 + len(divs) % 2

print(main(divs, o))

Buggy submission (verdict: Runtime Error):
import math


n = int(input())


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

def main(divisors, o):
    for i in range(o):
        a = divisors[i]
        b = list(reversed(divisors))[i]
        
        if a <= 9 and b <= 9:
            return 'Yes'
    return 'No'


divs = make_divisors(n)

o = len(divs)/2 + len(divs) % 2

print(main(divs, o))

Buggy submission (verdict: Runtime Error):
import math


n = int(input())


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

def main(divisors, o):
    for i in range(o):
        a = divisors[i]
        b = list(reversed(divisors))[i]
        
        if a <= 9 and b <= 9:
            return 'Yes'
    return 'No'


divs = make_divisors(n)

o = len(divs)/2 + len(divs) % 2

print(main(divs, o))

Buggy submission (verdict: Runtime Error):
import math


n = int(input())


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

def main(divisors, o):
    for i in range(o):
        a = divisors[o]
        b = divisors[-o]
        if a < 9 and b < 9:
            return 'Yes'
    return 'No'


divs = make_divisors(n)
if len(divs) % 2 == 0:
    o = len(divs) / 2
else:
    o = int(math.ceil(len(divs) / 2))

print(main(divs, o))
Problem p03805 (python)

Fixed submission:
import sys
from math import *
from collections import deque, Counter, defaultdict
from fractions import gcd
from itertools import permutations
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return


def main():
    n,m = map(int, input().split())
    graph = [[0 for _ in range(n)] for _ in range(n)]
    for i in range(m):
        a,b = map(int, input().split())
        graph[a-1][b-1] = 1
        graph[b-1][a-1] = 1
    # n!通りの並べ方があり，各並べ方について成立するかどうかを調べる．
    # 成立しないと判明した時点で探索をやめる
   
    a = [i+1 for i in range(n)]
    p = permutations(a)

    def check(x):
        # x: (1,3,4,6,7,2)
        for i in range(n-1):
            if not graph[x[i]-1][x[i+1]-1]:
                return False
        return True
    cnt = 0
    for x in p:
        if x[0] != 1:
            continue
        if check(x):
            cnt += 1       
    print(cnt)
    return

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
from math import *
from collections import deque, Counter, defaultdict
from fractions import gcd
from itertools import permutations
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return


def main():
    n,m = map(int, input().split())
    graph = [[0 for _ in range(m)] for _ in range(m)]
    for i in range(m):
        a,b = map(int, input().split())
        graph[a-1][b-1] = 1
        graph[b-1][a-1] = 1
    # n!通りの並べ方があり，各並べ方について成立するかどうかを調べる．
    # 成立しないと判明した時点で探索をやめる
   
    a = [i+1 for i in range(n)]
    p = permutations(a)

    def check(x):
        # x: (1,3,4,6,7,2)
        for i in range(n-1):
            if not graph[x[i]-1][x[i+1]-1]:
                return False
        return True
    cnt = 0
    for x in p:
        if x[0] != 1:
            continue
        if check(x):
            cnt += 1       
    print(cnt)
    return

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
from math import *
from collections import deque, Counter, defaultdict
from fractions import gcd
from itertools import permutations
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return


def main():
    n,m = map(int, input().split())
    graph = [[0 for _ in range(m)] for _ in range(m)]
    for i in range(m):
        a,b = map(int, input().split())
        graph[a-1][b-1] = 1
        graph[b-1][a-1] = 1
    # n!通りの並べ方があり，各並べ方について成立するかどうかを調べる．
    # 成立しないと判明した時点で探索をやめる
   
    a = [i+1 for i in range(n)]
    p = permutations(a)

    def check(x):
        # x: (1,3,4,6,7,2)
        for i in range(n-1):
            if not graph[x[i]-1][x[i+1]-1]:
                return False
        return True
    cnt = 0
    for x in p:
        if x[0] != 1:
            continue
        if check(x):
            cnt += 1       
    print(cnt)
    return

if __name__ == '__main__':
    main()
Problem p03986 (python)

Fixed submission:
from collections import deque

x = input()
n = len(x)

deq = deque()

for i in range(n):
    if x[i] == 'S':
        deq.appendleft(x[i])
    elif x[i] == 'T' and  deq and deq[0] == 'S':
        deq.popleft()
    else:
        deq.appendleft('T')

print(len(deq))

Buggy submission (verdict: Runtime Error):
x = input()
i = len(x)
cnt = 0

while True:
    if cnt > 
    
    p = x.find('ST')
    if p != -1:
        cnt += 1
    else:
        break
    
    n = p
    while True:
        if len(x) -1 > 0:
            
            if x[n-1] == 'S':
                cnt += 1
                n -= 1
            else:
                break
    x = x[:p] + x[p+2:]

print(len(x))
Problem p02777 (python)

Fixed submission:
def main():
 s,t = input().split()
 a,b = map(int,input().split())
 u = input()
 if s == u:
     a -= 1
 else:
     b -= 1
 print(a,b)
main()

Buggy submission (verdict: Runtime Error):
def main():
 s,t = input().split()
 a,b = int(input().split())
 u = input()
 if s == u:
     a -= 1
 else:
     b -= 1
 print(a,b)
main()

Buggy submission (verdict: Runtime Error):
def main():
 s,t = input().split()
 a,b = int(input().split())
 u = input()
 if s == u:
     a -= 1
 else:
     b -= 1
main()
Problem p02835 (python)

Fixed submission:
def main():
  a,b,c = map(int,input().split())
  if a + b + c >= 22:
      print('bust')
  else:
      print('win')
main()

Buggy submission (verdict: Runtime Error):
def main():
	a,b,c = map(int,input().split())
	if a + b + c >= 22:
    	print('bust')
	else:
    	print('win')
main()
Problem p02987 (python)

Fixed submission:
def main():
 s = sorted(input())
 if s[0] == s[1] and s[3] == s[2] and s[1] != s[2]:
     print('Yes')
 else:
     print('No')
main()

Buggy submission (verdict: Runtime Error):
def main():
 s = input()
 if s[0] == s[4] and s[1] == s[2] and s[2] != s[3]:
     print('Yes')
 else:
     print('No')
main()
Problem p03041 (python)

Fixed submission:
def main():
    n,k = map(int,input().split())
    s = list(input())
    s[k - 1] = chr(ord(s[k - 1]) + 32)
    t = ''
    for i in s:
        t = t + i
    print(t)
main()

Buggy submission (verdict: Runtime Error):
def main():
    n,k = map(int,input().split())
    s = list(input())
    s[k - 1] = chr(ord(s[k]) + 32)
    t = ''
    for i in s:
        t = t + i
    print(t)
main()

Buggy submission (verdict: Runtime Error):
def main():
    n,k = map(int,input().split())
    s = list(input())
    s[k] = chr(ord(s[k]) + 32)
    t = ''
    for i in s:
        t = t + i
    print(t)
main()
Problem p02689 (python)

Fixed submission:


i = list(map(int, input().split())) 
j = list(map(int, input().split())) 

lis=[]
ans = 0
for a in range (i[0]):
    tendata=[a+1,j[a],0]
    lis.append(tendata)

for b in range(i[1]):
    miti = list(map(int, input().split()))
    if ((lis[miti[0]-1][1]) > (lis[miti[1]-1][1])):
        lis[miti[1]-1][2] = 1
    
    elif ((lis[miti[0]-1][1]) == (lis[miti[1]-1][1])):
        lis[miti[1]-1][2] = 1
        lis[miti[0]-1][2] = 1

    else:
        lis[miti[0]-1][2] = 1

for c in  lis:
    if not (c[2] == 1 ):
        ans = ans+1

print(ans)

Buggy submission (verdict: Runtime Error):


i = list(map(int, input().split())) 
j = list(map(int, input().split())) 

lis=[]
for i in range (i[0]):
    tendata=[i+1,j[i],0]
    lis.append(tendata)

for i in range(i[1]):
    miti = list(map(int, input().split()))
    if ((lis[miti[0]-1][1]) > (lis[miti[1]][1])):
        lis[miti[0]-1][2] = (lis[miti[0]-1][2]+100)
        lis[miti[1]-1][2] = (lis[miti[1]-1][2]+2)

    elif ((lis[miti[0]-1][1]) < (lis[miti[1]][1])):
        lis[miti[1]-1][2] = (lis[miti[1]-1][2]+100)
        lis[miti[0]-1][2] = (lis[miti[0]-1][2]+2)


print(lis)
Problem p02580 (python)

Fixed submission:
import sys
import random
H,W,M=map(int,input().split())

hlist=[0]*H
wlist=[0]*W
hwset=set()
for _ in range(M):
  h,w=map(int,input().split())
  hlist[h-1]+=1
  wlist[w-1]+=1
  hwset.add((h-1,w-1))
  
hmax=max(hlist)
wmax=max(wlist)

hlist2=[]
for i in range(H):
  if hlist[i]==hmax:
    hlist2.append(i)
hlist2.sort(reverse=True)
random.shuffle(hlist2)

wlist2=[]
for i in range(W):
  if wlist[i]==wmax:
    wlist2.append(i)
wlist2.sort(reverse=True)
random.shuffle(wlist2)

#print(hlist2,wlist2)
H2=len(hlist2)
W2=len(wlist2)

if H2*W2>=10**7:
  norm=(H2*W2)//(10**7)
  H2=int(H2/(norm**0.5))
  W2=int(W2/(norm**0.5))

for i in range(H2):
  ii=hlist2[i]
  for j in range(W2):
    jj=wlist2[j]
    if not (ii,jj) in hwset:
      print(hmax+wmax)
      sys.exit(0)
else:
  print(hmax+wmax-1)

Buggy submission (verdict: Runtime Error):
import sys
import random
H,W,M=map(int,input().split())

hlist=[0]*H
wlist=[0]*W
hwset=set()
for _ in range(M):
  h,w=map(int,input().split())
  hlist[h-1]+=1
  wlist[w-1]+=1
  hwset.add((h-1,w-1))
  
hmax=max(hlist)
wmax=max(wlist)

hlist2=[]
for i in range(H):
  if hlist[i]==hmax:
    hlist2.append(i)
hlist2.sort(reverse=True)
random.shuffle(hlist2)

wlist2=[]
for i in range(W):
  if wlist[i]==wmax:
    wlist2.append(i)
wlist2.sort(reverse=True)
random.shuffle(wlist2)

#print(hlist2,wlist2)
H2=len(hlist2)
W2=len(wlist2)

if H2*W2>10**7:
  norm=(H2*W2)//(10**7)+1
  H2=int(H2/(norm**0.5))
  W2=int(W2/(norm**0.5))

for i in range(H2):
  ii=hlist2[i]
  for j in range(W2):
    jj=wlist2[j]
    if not (ii,jj) in hwset:
      print(hh+ww)
      sys.exit(0)
else:
  print(hmax+wmax-1)

Buggy submission (verdict: Runtime Error):
import sys
import random
H,W,M=map(int,input().split())

hlist=[0]*H
wlist=[0]*W
hwset=set()
for _ in range(M):
  h,w=map(int,input().split())
  hlist[h-1]+=1
  wlist[w-1]+=1
  hwset.add((h-1,w-1))
  
hmax=max(hlist)
wmax=max(wlist)

hlist2=[]
for i in range(H):
  if hlist[i]==hmax:
    hlist2.append(i)
hlist2.sort(reverse=True)
random.shuffle(hlist2)

wlist2=[]
for i in range(W):
  if wlist[i]==wmax:
    wlist2.append(i)
wlist2.sort(reverse=True)
random.shuffle(wlist2)

#print(hlist2,wlist2)
H2=len(hlist2)
W2=len(wlist2)

if H2*W2>10**7:
  norm=(H2*W2)//(10**7)
  H2=int(H2/(norm**0.5))
  W2=int(W2/(norm**0.5))

for i in range(H2):
  ii=hlist2[i]
  for j in range(W2):
    jj=wlist2[j]
    if not (ii,jj) in hwset:
      print(hh+ww)
      sys.exit(0)
else:
  print(hmax+wmax-1)
Problem p02598 (python)

Fixed submission:
N,K=map(int,input().split())
alist=list(map(int,input().split()))
#print(alist)

def num_cut(x):
  if x==0:
    return float("inf")
  
  ret=0
  for a in alist:
    ret+=-(-(a-x)//x)
  return ret

#for i in range(1,max(alist)):
#  print(i,num_cut(i))

l=1
r=max(alist)+1
while l<=r:
  mid=(l+r)//2
  #print(l,mid,r)
  
  if num_cut(mid-1)>K and num_cut(mid)<=K:
    print(mid)
    break
  elif num_cut(mid)<=K:
    r=mid
  else:
    l=mid

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

def num_cut(x):
  ret=0
  for a in alist:
    ret+=-(-(a-x)//x)
  return ret

#for i in range(1,max(alist)):
#  print(i,num_cut(i))

l=1
r=max(alist)+1
while l<=r:
  mid=(l+r)//2
  #print(l,mid,r)
  
  if num_cut(mid-1)>K and num_cut(mid)<=K:
    print(mid)
    break
  elif num_cut(mid)<=K:
    r=mid
  else:
    l=mid

Buggy submission (verdict: Runtime Error):
import sys
N,K=map(int,input().split())
alist=list(map(int,input().split()))
#print(alist)

memo={}
def num_cut(x):
  if x in memo:
    return memo[x]
  
  ret=0
  for a in alist:
    ret+=-(-(a-x)//x)
    
  memo[x]=ret
  return ret

#for i in range(1,max(alist)):
#  print(i,num_cut(i))

l=1
r=max(alist)+1
while l<=r:
  mid=(l+r)//2
  #print(l,mid,r)
  
  if num_cut(mid-1)>K and num_cut(mid)<=K:
    print(mid)
    break
  elif num_cut(mid)<=K:
    r=mid
  else:
    l=mid

Buggy submission (verdict: Runtime Error):
import sys
N,K=map(int,input().split())
alist=list(map(int,input().split()))
#print(alist)

if K==0:
  print(max(alist))
  sys.exit(0)

memo={}
def isOK(x):
  if x in memo:
    return memo[x]
  
  num_cut=0
  for a in alist:
    num_cut+=-(-(a-x)//x)
    if num_cut>K:
      memo[x]=False
      return False  
    
  memo[x]=True
  return True

l=1
r=max(alist)
while l<=r:
  mid=(l+r)//2
  
  if not isOK(mid-1) and isOK(mid):
    print(mid)
    break
  elif isOK(mid-1):
    r=mid
  else:
    l=mid
Problem p02659 (python)

Fixed submission:
As,Bs=input().split()
A=int(As)
Bi,Bf=map(int,Bs.split("."))

print(A*Bi+A*Bf//100)

Buggy submission (verdict: Runtime Error):
As,Bs=input().split()
A=int(As)
B=float(Bs)
B100=int((Bs+0.001)*100)
print(A*B100//100)
Problem p02769 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**9)

MOD=10**9+7
n,k=map(int,input().split())

def pow_mod(x,n):
  if n==0:
    return 1
  elif n==1:
    return x
  else:
    xn2=pow_mod(x,n//2)
    if n%2==0:
      return (xn2*xn2)%MOD
    else:
      return (xn2*xn2*x)%MOD

def fact_mod(a):
  if a<=1:
    return 1
  else:
    return a*fact_mod(a-1)%MOD
  
def perm_mod(n,a):
  if a==1:
    return n
  else:
    return (n*perm_mod(n-1,a-1))%MOD

def inv_mod(a):
  return pow_mod(a,MOD-2)%MOD
  
def comb_mod(na,fa):
  ainv=inv_mod(fa)
  return (na*ainv)%MOD
  
if k>=n-1:  
  #nHn=(2n-1)Cn
  perm=perm_mod(2*n-1,n)
  fact=fact_mod(n)
  comb=comb_mod(perm,fact)
  #print(perm,fact,comb)
  print(comb)
else:
  inv_table = [0]+[1]
  for i in range(2,k+1):
    inv_table+=[inv_table[MOD%i]*(MOD-int(MOD/i))%MOD]
  
  comb_sum=1
  fact=1
  comb1=1
  comb2=1
  for i in range(1,k+1):
    #comb1=comb1*(n-i+1)//i
    comb1=(comb1*(n-i+1)*inv_table[i])%MOD
    #comb2=comb2*(n-i)//i
    comb2=(comb2*(n-i)*inv_table[i])%MOD
    comb=(comb1*comb2)%MOD
    comb_sum+=comb
  
  print(comb_sum%MOD)

Buggy submission (verdict: Runtime Error):
MOD=10**9+7
n,k=map(int,input().split())

def pow_mod(x,n):
  if n==0:
    return 1
  elif n==1:
    return x
  else:
    xn2=pow_mod(x,n//2)
    if n%2==0:
      return (xn2*xn2)%MOD
    else:
      return (xn2*xn2*x)%MOD

def fact_mod(a):
  if a<=1:
    return 1
  else:
    return a*fact_mod(a-1)%MOD
  
def perm_mod(n,a):
  if a==1:
    return n
  else:
    return (n*perm_mod(n-1,a-1))%MOD

def inv_mod(a):
  return pow_mod(a,MOD-2)%MOD
  
def comb_mod(na,fa):
  ainv=inv_mod(fa)
  return (na*ainv)%MOD
  
if k>=n-1:  
  #nHn=(2n-1)Cn
  perm=perm_mod(2*n-1,n)
  fact=fact_mod(n)
  comb=comb_mod(perm,fact)
  #print(perm,fact,comb)
  print(comb)
else:
  print(-1)
Problem p02912 (python)

Fixed submission:
#from heapq import heappush, heappop
import heapq

N,M=map(int,input().split())
alist=list(map(int,input().split()))

hq=[]
for a in alist:
  heapq.heappush(hq,-a)
  
while(M>0):
  target=-1*heapq.heappop(hq)
  target//=2
  heapq.heappush(hq,-target)
  M-=1

answer_list=[heapq.heappop(hq) for i in range(len(hq))]
#print(answer_list)
print(-sum(answer_list))

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
alist=list(map(int,input().split()))
alist.sort(reverse=True)

while(M>0):
  alist[0]//=2
  if alist[0]<alist[1]:
    alist.sort(reverse=True)
  M-=1

print(sum(alist))
Problem p02954 (python)

Fixed submission:
S=input()
ans_list=[0]*len(S)

rmode=True
cnt_R=0
cnt_L=0
border_R=0
border_L=0
for i in range(len(S)):
  if rmode:
    if S[i]=="R":
      cnt_R+=1
    else:
      border_R=i-1
      border_L=i      
      rmode=False
      cnt_L=1
  else:
    if S[i]=="L":
      cnt_L+=1
    else:
      ans_list[border_R]+=(cnt_R+1)//2
      ans_list[border_L]+=cnt_R//2
      ans_list[border_R]+=cnt_L//2
      ans_list[border_L]+=(cnt_L+1)//2
      rmode=True
      cnt_R=1
      cnt_L=0
else:
  ans_list[border_R]+=(cnt_R+1)//2
  ans_list[border_L]+=cnt_R//2
  ans_list[border_R]+=cnt_L//2
  ans_list[border_L]+=(cnt_L+1)//2
  
      
ans_list_str=map(str,ans_list)
print(" ".join(ans_list_str))

Buggy submission (verdict: Runtime Error):
times=10**100
S=input()
bs=[True if s=="L" else False for s in S]
#print(bs)

start=-1
cycle=-1
list_list=[]

clist=[1]*len(bs)
list_list.append(clist)
dic_list[str(clist)]=0

dic_list={}
for i in range(1,10**100):  
  new_clist=[0]*len(bs)
  for j,b in enumerate(bs):
    if b:
      new_clist[j-1]+=clist[j]
    else:
      new_clist[j+1]+=clist[j]

  clist=new_clist
  list_list.append(clist)
  #print(clist)
  
  if str(clist) in dic_list:
    #print(i,i-dic_list[str(clist)],str(clist))
    start=dic_list[str(clist)]
    cycle=i-dic_list[str(clist)]
    break
  else:
    dic_list[str(clist)]=i
    
#print(start,cycle,list_list[start])
index=((10**100-start)%cycle)+start
ans_list=map(str,list_list[index])
print(" ".join(ans_list))

Buggy submission (verdict: Runtime Error):
times=10**100
S=input()

start=-1
cycle=-1

clist=[1]*len(S)
dic_list={}
for i in range(1,10):  
  new_clist=[0]*len(S)
  for j,s in enumerate(S):
    if s=="L":
      new_clist[j-1]+=clist[j]
    elif s=="R":
      new_clist[j+1]+=clist[j]

  clist=new_clist
  #print(clist)
  
  if str(clist) in dic_list:
    #print(i,i-dic_list[str(clist)],str(clist))
    ans_list=clist
    start=i
    cycle=i-dic_list[str(clist)]
    break
  else:
    dic_list[str(clist)]=i
    
ans_list_str = map(str,ans_list)
print(" ".join(ans_list_str))
Problem p03045 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)

def get_par(x):
  if x == par_list[x]:
    return x
  else:
    par_list[x] = get_par(par_list[x])
    return par_list[x]

N,M=map(int,input().split())
par_list = list(range(N))
for i in range(M):
  Xi,Yi,Zi=map(int,input().split())
  par_Xi = get_par(Xi-1)
  par_Yi = get_par(Yi-1)
  if par_Xi != par_Yi:
    par_list[par_Yi] = par_Xi
    
set_uf = set()
for par in par_list:
  set_uf.add(get_par(par))
  
print(len(set_uf))

Buggy submission (verdict: Runtime Error):
def get_par(x):
  if x == par_list[x]:
    return x
  else:
    par = get_par(par_list[x])
    par_list[x] = par
    return par

N,M=map(int,input().split())
par_list = [i for i in range(N+1)]
for i in range(M):
  Xi,Yi,Zi=map(int,input().split())
  par_Xi = get_par(Xi)
  par_Yi = get_par(Yi)
  if par_Xi != par_Yi:
    par_list[par_Yi] = par_Xi
    
#print(par_list)
set_uf = set()
for par in par_list[1:]:
  set_uf.add(get_par(par))
  
print(len(set_uf))

Buggy submission (verdict: Runtime Error):
def get_par(x):
  if x == par_list[x]:
    return x
  else:
    par = get_par(par_list[x])
    par_list[x] = par
    return par

N,M=map(int,input().split())
par_list = [i for i in range(N+1)]
for i in range(M):
  Xi,Yi,Zi=map(int,input().split())
  par_Xi = get_par(Xi)
  par_Yi = get_par(Yi)
  if par_Xi != par_Yi:
    par_list[par_Yi] = par_list[par_Xi]
    
#print(par_list)
set_uf = set()
for par in par_list[1:]:
  set_uf.add(get_par(par))
  
print(len(set_uf))

Buggy submission (verdict: Runtime Error):
def get_par(x):
  if x == par_list[x]:
    return x
  else:
    par = get_par(par_list[x])
    par_list[x] = par
    return par

N,M=map(int,input().split())
par_list = [i for i in range(N)]
for i in range(M):
  Xi,Yi,Zi=map(int,input().split())
  par_Xi = get_par(Xi-1)
  par_Yi = get_par(Yi-1)
  if par_Xi != par_Yi:
    par_list[par_Yi] = par_list[par_Xi]
    
#print(par_list)
set_uf = set()
for par in par_list:
  set_uf.add(get_par(par))
  
print(len(set_uf))

Buggy submission (verdict: Runtime Error):
def get_par(x):
  if x == par_list[x]:
    return x
  else:
    return get_par(par_list[x])

N,M=map(int,input().split())
par_list = [i for i in range(N)]
for i in range(M):
  Xi,Yi,Zi=map(int,input().split())
  par_Xi = get_par(Xi-1)
  par_Yi = get_par(Yi-1)
  if par_Xi != par_Yi:
    par_list[par_Yi] = par_list[par_Xi]
    
set_uf = set()
for par in par_list:
  set_uf.add(par)
  
print(len(set_uf))
Problem p02793 (python)

Fixed submission:
def gcd(a,b):
	return gcd(b,a%b) if b else a
n = int(input())
a = list(map(int,input().split()))
lcm = 1
for v in a:
	lcm *= v//gcd(v,lcm)
ans = 0
for v in a:
	ans += lcm // v
print(ans%1000000007)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
a = list(map(int,input().split()))
lcm = 1
for v in a:
	lcm *= v//math.gcd(v,lcm)
ans = 0
for v in a:
	ans += lcm // v
print(ans%1000000007)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
a = list(map(int,input().split()))
lcm = 1
for v in a:
	lcm *= v//math.gcd(v,lcm)
ans = 0
for v in a:
	ans += lcm // v
print(ans%1000000007)