Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import bisect,copy,heapq,string
from collections import *
from math import *
from itertools import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, m = MAP()
s = input()
t = input()
l = n*m//gcd(n,m)

for i in range(0,l,l-1):
        if (n*i) % l == (m*i) % l == 0 and s[n*i//l] != t[m*i//l]:
                print(-1)
                exit()
print(l)

Fixed submission:
import bisect,copy,heapq,string
from collections import *
from math import *
from itertools import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, m = MAP()
s = input()
t = input()
k = gcd(n,m)
l = n*m//k

for i in range(0,l,l//k):
        if (n*i) % l == (m*i) % l == 0 and s[n*i//l] != t[m*i//l]:
                print(-1)
                exit()
print(l)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect,copy,heapq,string
from collections import *
from math import *
from itertools import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, m = MAP()
s = input()
t = input()
l = n*m//gcd(n, m)

for i in range(l):
        if (n*i) % l == (m*i) % l == 0 and s[n*i//l] != t[m*i//l]:
                print(-1)
                exit()
print(l)

Fixed submission:
import bisect,copy,heapq,string
from collections import *
from math import *
from itertools import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, m = MAP()
s = input()
t = input()
k = gcd(n,m)
l = n*m//k

for i in range(0,l,l//k):
        if (n*i) % l == (m*i) % l == 0 and s[n*i//l] != t[m*i//l]:
                print(-1)
                exit()
print(l)
Buggy python submission (verdict: Time Limit Exceeded):
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, m = MAP()

for i in range(n, m+1):
    if m % i == 0:
        print(m//i)
        exit()

Fixed submission:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

def divisor(n): 
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table

n, m = MAP()
a = sorted(divisor(m))
print(m//a[bisect_left(a,n)])
Buggy python submission (verdict: Time Limit Exceeded):
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def MAP1()  : return map(lambda x:int(x)-1,input().split())
def LIST()  : return list(MAP())

def solve():
    N = INT()

    print(0)
    s0 = input()
    if s0 == 'Vacant':
        exit()

    ng = -1
    ok = N
    while True:
        mid = (ok + ng) // 2
        print(mid, flush=True)
        s = input()
        if s == 'Vacant':
            exit()

        if ( mid % 2 == 0 and s == s0 ) or ( mid % 2 == 1 and s != s0 ):
            ng = mid
        else:
            ok = mid

if __name__ == '__main__':
    solve()

Fixed submission:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def MAP1()  : return map(lambda x:int(x)-1,input().split())
def LIST()  : return list(MAP())

def solve():
    N = INT()

    print(0, flush=True)
    s0 = input()
    if s0 == 'Vacant':
        exit()

    ng = -1
    ok = N
    while True:
        mid = (ok + ng) // 2
        print(mid, flush=True)
        s = input()
        if s == 'Vacant':
            exit()

        if ( mid % 2 == 0 and s == s0 ) or ( mid % 2 == 1 and s != s0 ):
            ng = mid
        else:
            ok = mid

if __name__ == '__main__':
    solve()
Buggy python submission (verdict: Time Limit Exceeded):
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

a = [1]*(10**5+1)
a[0] = a[1] = 0

for i in range(2, ceil(sqrt(10**5)+1)):
    if a[i] == 0:
        continue
    else:
        if i == 2:
            a[i] = 0
        for j in range(i*2, len(a), i):
            a[j] = 0
            if j*2 - 1 < len(a):
                a[j*2-1] = 0

q = INT()
p = [LIST() for i in range(q)]

for i in range(q):
    print(sum(a[p[i][0]:p[i][1]+1]))

Fixed submission:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

a = [1]*(10**5+1)
a[0] = a[1] = a[2] = 0

for i in range(2, ceil(sqrt(10**5)+1)):
    for j in range(i*2, len(a), i):
        a[j] = 0
        if j*2 - 1 < len(a):
            a[j*2-1] = 0

q = INT()
p = [LIST() for i in range(q)]
s = list(accumulate(a))

for i in range(q):
    print(s[p[i][1]]-s[p[i][0]-1])
Buggy python submission (verdict: Runtime Error):
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

s = input()
t = input()

if len(s) < len(t):
    ans = "UNRESTORABLE"
else:
    reg = -1
    for i in range(len(s)-len(t),-1,-1):
        for j in range(len(t)):
            if s[i+j] != '?' and s[i+j] != t[j]:
                break
        else:
            reg = i
            break
    if reg == -1:
        ans = "UNRESTORABLE"
    elif reg == len(s)-len(t):
        s = s[:i]+t
        ans = s.replace('?','a')
    else:
        s = s[:i]+t+s[i+len(t):]
print(ans)

Fixed submission:
from math import ceil,floor,comb,factorial,gcd,pow,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heappop,heappush
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

s = input()
t = input()

if len(s) < len(t):
    ans = "UNRESTORABLE"
else:
    reg = -1
    for i in range(len(s)-len(t),-1,-1):
        for j in range(len(t)):
            if s[i+j] != '?' and s[i+j] != t[j]:
                break
        else:
            reg = i
            break
    if reg == -1:
        ans = "UNRESTORABLE"
    elif reg == len(s)-len(t):
        s = s[:i]+t
        ans = s.replace('?','a')
    else:
        s = s[:i]+t+s[i+len(t):]
        ans = s.replace('?','a')
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect,collections,copy,heapq,itertools,math,string
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
d = LIST()
m = INT()
t = LIST()
for x in t:
    if(x in d):
        d.remove(x)
    else:
        print("NO")
        exit()
print("YES")

Fixed submission:
import bisect,collections,copy,heapq,itertools,math,string
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
d = LIST()
m = INT()
t = LIST()
d.sort()
t.sort()
j = 0
for i in range(n):
    if(d[i]==t[j]):
        j += 1
    if(j == m):
        break
if(j == m):
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Time Limit Exceeded):
import bisect,copy,heapq,itertools,math,string
from collections import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = LIST()
b = [i for i in range(n)]

for i in range(n):
    b.remove(i)
    b.append(i)
    b.reverse()

c = [a[b[i]] for i in range(n)]
print(*c)

Fixed submission:
import bisect,copy,heapq,itertools,math,string
from collections import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = LIST()
b = deque()

for i in range(n):
    if(i%2==0):
        b.append(i)
    else:
        b.appendleft(i)

if(n%2==1):
    b.reverse()

c = [a[b[i]] for i in range(n)]
print(*c)
Buggy python submission (verdict: Runtime Error):
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

ans = []

def dfs(m):
    if m == 1:
        ans.append(1)
        return 0
    elif m == 3:
        ans.append(2)
        ans.append(1)
        return 0
    elif m == 4:
        ans.append(3)
        ans.append(1)
        return 0
    elif m == 5:
        ans.append(3)
        ans.append(2)
        return 0
    else:
        k = ceil((sqrt(1+8*m)-1)/2)
        ans.append(k)
        dfs(m-k)

n = INT()
dfs(n)
for x in ans:
    print(x)

Fixed submission:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

ans = []

def dfs(m):
    if m == 1:
        ans.append(1)
        return 0
    elif m == 2:
        ans.append(2)
        return 0
    elif m == 3:
        ans.append(2)
        ans.append(1)
        return 0
    elif m == 4:
        ans.append(3)
        ans.append(1)
        return 0
    elif m == 5:
        ans.append(3)
        ans.append(2)
        return 0
    else:
        k = ceil(sqrt(1+8*m))//2
        ans.append(k)
        dfs(m-k)

n = INT()
dfs(n)
for x in ans:
    print(x)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
alist = list(map(int,input().split()))

prev = 1
curr = 1
prev_a = []
for i in range(n):
    prev_a.append(alist[i])
    prev = curr
    curr *= alist[i]
    if i >= k:
        curr /= prev_a.pop(0)
        curr = int(curr)
        if prev < curr:
            print("Yes")
        else:
            print("No")
        

Fixed submission:
n,k = map(int,input().split())
alist = list(map(int,input().split()))

prev_a = []
for i in range(n):
    prev_a.append(alist[i])
    if i >= k:

        if prev_a.pop(0) < alist[i]:
            print("Yes")
        else:
            print("No")
Buggy python submission (verdict: Time Limit Exceeded):

import math
n = int(input())

sqn = int(math.sqrt(n))+1
count = 0
aset = [0]*(n+1)
for x in range(1,sqn):
    for y in range(x,sqn):
        for z in range(y,n):
            a = x**2+y**2+z**2+x*y+y*z+z*x
            if a <= n:
                if x == y and y ==z:
                    aset[a] +=1
                else:
                    aset[a] +=3

for i in range(1,n+1):
    print(aset[i])

Fixed submission:

import math
n = int(input())

sqn = int(math.sqrt(n))+1
count = 0
aset = [0]*(n+1)
for x in range(1,sqn):
    for y in range(x,sqn):
        for z in range(y,sqn):
            a = x**2+y**2+z**2+x*y+y*z+z*x
            if a <= n:
                if x == y and y ==z:
                    aset[a] +=1
                else:
                    if x == y or y ==z:
                        aset[a] +=3
                    else:
                        aset[a] +=6

for i in range(1,n+1):
    print(aset[i])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

count = 0
aset = [0]*(n+1)
for x in range(1,n-1):
    for y in range(x,n-1):
        for z in range(y,n-1):
            a = x**2+y**2+z**2+x*y+y*z+z*x
            if a <= n:
                if x == y and y ==z:
                    aset[a] +=1
                else:
                    aset[a] +=3

for i in range(1,n+1):
    print(aset[i])


Fixed submission:

import math
n = int(input())

sqn = int(math.sqrt(n))+1
count = 0
aset = [0]*(n+1)
for x in range(1,sqn):
    for y in range(x,sqn):
        for z in range(y,sqn):
            a = x**2+y**2+z**2+x*y+y*z+z*x
            if a <= n:
                if x == y and y ==z:
                    aset[a] +=1
                else:
                    if x == y or y ==z:
                        aset[a] +=3
                    else:
                        aset[a] +=6

for i in range(1,n+1):
    print(aset[i])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

for b in range(1,n+1):
    count = 0
    for x in range(1,n-1):
        for y in range(x,n-1):
            for z in range(y,n-1):
                a = x**2+y**2+z**2+x*y+y*z+z*x
                if a == b:
                    if x == y and y ==z:
                        count+=1
                    else:
                        count+=3

    print(count)

Fixed submission:

import math
n = int(input())

sqn = int(math.sqrt(n))+1
count = 0
aset = [0]*(n+1)
for x in range(1,sqn):
    for y in range(x,sqn):
        for z in range(y,sqn):
            a = x**2+y**2+z**2+x*y+y*z+z*x
            if a <= n:
                if x == y and y ==z:
                    aset[a] +=1
                else:
                    if x == y or y ==z:
                        aset[a] +=3
                    else:
                        aset[a] +=6

for i in range(1,n+1):
    print(aset[i])
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

n = int(input())
alist = list(map(int,input().split()))
q = int(input())


dict_n = defaultdict(lambda:0)

for i in alist:
    dict_n[i] += 1

bclist = []
for i in range(q):
    b,c  = map(int,input().split())
    bclist.append([b,c])


for i in range(q):
    
    b = bclist[i][0]
    c = bclist[i][1]

    dict_n[c] += dict_n[b]
    del(dict_n[b])
    
    sum = 0
    for key in dict_n:
        sum += key * dict_n[key]
    print(sum)

Fixed submission:
from collections import defaultdict

n = int(input())
alist = list(map(int,input().split()))
q = int(input())


dict_n = defaultdict(lambda:0)

for i in alist:
    dict_n[i] += 1

bclist = []
for i in range(q):
    b,c  = map(int,input().split())
    bclist.append([b,c])

sum = sum(alist)
for i in range(q):
    
    b = bclist[i][0]
    c = bclist[i][1]

    sum += dict_n[b]*c - dict_n[b]*b
    dict_n[c] += dict_n[b]
    del(dict_n[b])

    print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

n = int(input())
alist = list(map(int,input().split()))
q = int(input())


dict_n = defaultdict(lambda:0)

for i in alist:
    dict_n[i] += 1

bclist = []
for i in range(q):
    b,c  = map(int,input().split())
    bclist.append([b,c])


for i in range(q):
    
    b = bclist[i][0]
    c = bclist[i][1]

    dict_n[c] += dict_n[b]
    dict_n[b] = 0

    sum = 0
    for key in dict_n:
        sum += key * dict_n[key]
    print(sum)

Fixed submission:
from collections import defaultdict

n = int(input())
alist = list(map(int,input().split()))
q = int(input())


dict_n = defaultdict(lambda:0)

for i in alist:
    dict_n[i] += 1

bclist = []
for i in range(q):
    b,c  = map(int,input().split())
    bclist.append([b,c])

sum = sum(alist)
for i in range(q):
    
    b = bclist[i][0]
    c = bclist[i][1]

    sum += dict_n[b]*c - dict_n[b]*b
    dict_n[c] += dict_n[b]
    del(dict_n[b])

    print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
def index(a, x):
    i = bisect.bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return i
    raise ValueError

n = int(input())
alist = list(map(int,input().split()))
q = int(input())

bclist = []
for i in range(q):
    b,c  = map(int,input().split())
    bclist.append([b,c])

alist = sorted(alist)

for i in range(q):
    
    b = bclist[i][0]
    c = bclist[i][1]
    try:
        ind = index(alist,b)
        while alist[ind] == b:
            alist.remove(b)
            bisect.insort(alist, c)
            if b > c:
                ind+=1

    except:
        None
    print(sum(alist))


Fixed submission:
from collections import defaultdict

n = int(input())
alist = list(map(int,input().split()))
q = int(input())


dict_n = defaultdict(lambda:0)

for i in alist:
    dict_n[i] += 1

bclist = []
for i in range(q):
    b,c  = map(int,input().split())
    bclist.append([b,c])

sum = sum(alist)
for i in range(q):
    
    b = bclist[i][0]
    c = bclist[i][1]

    sum += dict_n[b]*c - dict_n[b]*b
    dict_n[c] += dict_n[b]
    del(dict_n[b])

    print(sum)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))

import math 
  
# A function to print all prime factors of  
# a given number n 
def primeFactors(n): 
    p = set()
    while n % 2 == 0: 
        p.add(2) 
        n = int(n / 2)
    for i in range(3,int(math.sqrt(n))+1,2): 
        while n % i== 0: 
            p.add(int(i)) 
            n = int(n / i)
    if n > 2: 
        p.add(n)
    return p 

def largestPrimeFactor(n): 
    p = set()
    while n % 2 == 0: 
        p.add(2) 
        n = n / 2
    for i in range(3,int(math.sqrt(n))+1,2): 
        while n % i== 0: 
            p.add(i) 
            n = int(n / i)
    if n > 2: 
        p.add(n)
    return max(p) 

a = sorted(a)
max_v = max(a)
ans = 0
if len(set(a))==1:
    print(0)
    exit()
product = 1
ans = set()
for i in range(len(a)):
    next = primeFactors(a[i])
    if len(ans.intersection(next)) == 0:
        ans.add(max(next))

print(len(ans))

Fixed submission:
from collections import defaultdict
import math
n = int(input())
a = list(map(int,input().split()))
max_a = 10**6 +1 
a = sorted(a)
dic = defaultdict(lambda: False)

count = 0 
for i in range(n):
    ai = a[i]
    if dic[ai] == True:
        count+=1
    else:
        for j in range(1,math.ceil(max_a/ai)):
            dic[j*ai] = True
        if (i+1) < n and a[i]==a[i+1]:
            count+=1
print(n-count)