Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, m = map(int, readline().split())
lr = [list(map(int, readline().split())) for _ in range(m)]

id_list = [i for i in range(lr[0][0], lr[0][1] + 1)]
for i in range(1, m):
    x = 1
    id_list = [j for j in id_list if lr[i][0] <= j <= lr[i][1]]
print(len(id_list))

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, m = map(int, readline().split())
lr = [list(map(int, readline().split())) for _ in range(m)]

left = 0
right = n
for i in range(m):
    left = max(left, lr[i][0])
    right = min(right,lr[i][1])
print(max(0,right-left+1))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, q = map(int, readline().split())
s = readline().decode().rstrip()

lis = [0]*n
for i in range(n - 1):
    if s[i] + s[i + 1] == 'AC':
        # l.append(i+1)
        lis[i] = 1

for _ in range(q):
    l, r = map(int, readline().split())
    print(sum(lis[l-1:r-1:]))


Fixed submission:
import itertools
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, q = map(int, readline().split())
s = readline().decode().rstrip()

lis = [0]*n
for i in range(n - 1):
    if s[i] + s[i + 1] == 'AC':
        lis[i+1] = 1

a = list(itertools.accumulate(lis))

for _ in range(q):
    l, r = map(int, readline().split())
    print(a[r-1]-a[l-1])
Buggy python submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, s, *x = map(int, read().split())
x.append(s)
x.sort()
k = x.index(s)
r = min(abs(x[k + 1] - s), abs(x[k - 1] - s))
for i in reversed(range(r + 1)):
    div = s % i
    bl = True
    for a in x:
        if a % i != div:
            bl = False
            break
    if bl == True:
        print(i)
        exit()

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)


n, s = map(int, readline().split())
x = [v-s for v in list(map(int, readline().split()))]

print(abs(gcd(*x)))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = sorted(map(int,input().split()))
print(a[n-1]-a[0])

Fixed submission:
n = int(input())
if n % 2 == 0:
	print(n)
else:
  	print(n*2)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr

n, *a = map(int, read().split())

ans = 0
for x in a:
    arr = factorization(x)
    for y in arr:
        if y[0] == 2:
            ans += y[1]
print(ans)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, *a = map(int, read().split())

ans = 0
for x in a:
    while x % 2 == 0:
        x = x // 2
        ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a, b = map(int, readline().split())
print(a*b)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a, b, c = map(int, readline().split())

print('Yes' if (a+b) >= c else 'No')
Buggy python submission (verdict: Runtime Error):
C = [input() for _ in range(3)]
ans = C[0][0] + C[1][1] + C[2][2]
print(ans)

Fixed submission:
N = int(input())
ans = N // 3
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


n = int(readline())
csf = [tuple(map(int, readline().split())) for _ in range(n-1)]

for i in range(n):
    now = 0
    for c, s, f in csf[i::]:
        while now > s:
            s += f
        now += s - now
        now += c
    print(now)


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


n = int(readline())
csf = [tuple(map(int, readline().split())) for _ in range(n-1)]

for i in range(n):
    now = 0
    for c, s, f in csf[i::]:
        if now <= s:
            now = s
        else:
            if now % f == 0:
                pass
            else:
                now = (now // f + 1) * f
        now += c
    print(now)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]
count = 0
while all(i % 2 == 0 for i in a):
    a = [i/2 for i in a]
    count += 1
print(count)

Fixed submission:
list=str(input())
print(list.count("1"))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
s = []
for i in range(1, N):
    s.append(abs(sum(A[0:i]) - sum(A[i:])))
print(min(s))

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

ans = float('inf')
snu = 0
ara = sum(A)
for a in A[0:-1]:
    snu += a
    ara -= a
    ans = min(ans, abs(snu - ara))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools

N, M = map(int, input().split())
np = len(list(itertools.permutations(list(range(N))))) % (10**9+7)
mp = len(list(itertools.permutations(list(range(M))))) % (10**9+7)
if N == M:
    ans = np*mp % (10**9+7)*2
elif abs(N - M) == 1:
    ans = np * mp % (10 ** 9 + 7)
else:
    ans = 0
print(ans)

Fixed submission:
N, M = map(int, input().split())
mod = 10**9+7


def for_factorial(n):
    mod = 10**9+7
    val = 1
    for i in range(2, n + 1):
        val = (val*i) % mod
    return val


f = for_factorial(N)*for_factorial(M) % mod
if N == M:
    ans = f*2 % mod
elif abs(N - M) == 1:
    ans = f % mod
else:
    ans = 0

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = [int(input()) for _ in range(n)]

score = sum(s)
s.sort()
i = 0
while score % 10 == 0:
    score -= s[i]
    i += 1
    if score == 0:
        break
print(score)


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a, b = map(int, readline().split())
ans = a+b if (a+b) < 10 else 'error'
print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = [input() for i in range(N)]
B = [input() for j in range(M)]

ans = True
for k in range(len(B)):
    if B[k] not in A[k]:
        ans = False
        break
print("Yes" if ans == True else "No")

Fixed submission:
A, B = map(int, input().split())
if A == B:
    ans = 'Draw'
elif A == 1:
    ans = 'Alice'
elif B == 1:
    ans = 'Bob'
elif A > B:
    ans = 'Alice'
else:
    ans = 'Bob'
print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = [input() for i in range(N)]
B = [input() for i in range(M)]

ans = 'No'
for i in range(N):
    if A[i].find(B[0]) > -1:
        x = A[i].find(B[0])
        y = i + 1
        ans = 'Yes'
        break
for j in range(1, M):
    if B[j] != A[y][x:M]:
        ans = 'No'
print(ans)

Fixed submission:
N, M = map(int, input().split())
A = [input() for i in range(N)]
B = [input() for j in range(M)]

ans = True
for k in range(len(B)):
    if B[k] not in A[k]:
        ans = False
        break
print("Yes" if ans == True else "No")
Buggy python submission (verdict: Time Limit Exceeded):
import math
N = int(input())

for i in range(1,N+1,1):
    ans = 0
    for x in range(1,101,1):
        if x*2 >= i:
            break
        for y in range(1,101,1):
            if x**2+y**2 >= i:
                break
            for z in range(1,101,1):
                if x**2+y**2+z**2 >= i:
                    break
                if x**2+y**2+z**2+x*y+y*z+x*z ==i:
                    ans +=1
    print(ans)


Fixed submission:
N = int(input())
ans = [0]*N

for x in range(1,100,1):
    for y in range(1,100,1):
        for z in range(1,100,1):
            if x**2+y**2+z**2+x*y+y*z+x*z <=N:
                ans[x**2+y**2+z**2+x*y+y*z+x*z-1] += 1

for i in ans:
    print(i)
Buggy python submission (verdict: Runtime Error):
N, M, K = map(int, input().split())
arr_a = list(map(int, input().split()))
arr_b = list(map(int, input().split()))
ans_a =0
ans_b =0
time =0

for i in range(N):
    if time + arr_a[i] > K:
        break
    else:
        ans_a +=1
        time += arr_a[i]
for i in range(M):
    if time + arr_b[i] > K:
        break
    else:
        ans_b +=1
        time += arr_b[i]

ans = ans_a + ans_b
ans_koho = ans_a + ans_b
cnt_b = ans_b

for i in range(ans_a):
    ans_koho -= 1
    time -= arr_a[-1*(i+1)]

    while True:
        if cnt_b == M:
            break
        elif time + arr_b[cnt_b] > K:
            break
        else:
            time += B[cnt_b]
            cnt_b += 1
            ans_koho += 1
    ans = max(ans, ans_koho)

print(ans)



Fixed submission:
N, M, K = map(int, input().split())
arr_a = list(map(int, input().split()))
arr_b = list(map(int, input().split()))
ans_a =0
ans_b =0
time =0

for i in range(N):
    if time + arr_a[i] > K:
        break
    else:
        ans_a +=1
        time += arr_a[i]
for i in range(M):
    if time + arr_b[i] > K:
        break
    else:
        ans_b +=1
        time += arr_b[i]

ans = ans_a + ans_b
ans_koho = ans_a + ans_b
cnt_b = ans_b

for i in range(ans_a):
    ans_koho -= 1
    time -= arr_a[ans_a-i-1]

    while True:
        if cnt_b == M:
            break
        elif time + arr_b[cnt_b] > K:
            break
        else:
            time += arr_b[cnt_b]
            cnt_b += 1
            ans_koho += 1
    ans = max(ans, ans_koho)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
arr = list(map(int, input().split()))
Q = int(input())
que = [list(map(int, input().split())) for _ in range(Q)]

for i in que:
    for j in range(N):
        if arr[j] == i[0]:
            arr[j] = i[1]
    print(sum(arr))


Fixed submission:
N = int(input())
arr = list(map(int, input().split()))
Q = int(input())
que = [list(map(int, input().split())) for _ in range(Q)]

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

for i in range(N):
    count_list[arr[i]] +=1

ans = sum(arr)

for i in que:
    keep = count_list[i[0]]
    c_ans = ans+keep*(i[1]-i[0])
    print(c_ans)
    ans =c_ans
    if count_list[i[0]] == 0:
        continue
    if count_list[i[0]] != 0:
        count_list[i[1]] += count_list[i[0]]
        count_list[i[0]] = 0
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
arr = sorted(list(map(int, input().split())))
ans_list = []
chohuku = [x for x in set(arr) if arr.count(x) > 1]
count_arr = [0]*arr[-1]

ans = 0
for i in arr:
    if count_arr[i-1] == 0:
        ans += 1
        ans_list.append(i)
    for j in range(1,(arr[-1]//i)+1):
        count_arr[(i*j)-1] += 1

for i in ans_list:
    if i in chohuku:
        ans -= 1

print(ans)

Fixed submission:
N = int(input())
arr = sorted(list(map(int, input().split())))
count_arr = [0]*arr[-1]

ans = 0
for i in arr:
    for j in range(1,(arr[-1]//i)+1):
        count_arr[(i*j)-1] += 1
for i in arr:
    if count_arr[i-1] == 1:
        ans +=1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import collections

N = int(input())
arr = list(map(int, input().split()))
i_arr =[]
j_arr =[]

ans = 0
for i in range(N):
    i_arr.append(i+arr[i])
    dic = collections.Counter(i_arr)
    j_arr.append(-1*arr[i]+i)
    ans += dic[j_arr[-1]]

print(ans)


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

dic = {}
j_arr =[]

ans = 0
for i in range(N):
    if i+arr[i] not in dic:
        dic[i+arr[i]] = 0
    dic[i+arr[i]] += 1
    j_arr.append(-1*arr[i]+i)
    if -1*arr[i]+i in dic:
        ans += dic[-1*arr[i]+i]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
arr = list(map(int, input().split()))
i_arr =[]
j_arr =[]

for i in range(N):
    i_arr.append(i+arr[i])
    j_arr.append(-1*arr[i]+i)

ans = 0
for i in range(N):
    for j in range(i,N):
        if i_arr[i] == j_arr[j]:
            ans += 1

print(ans)


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

dic = {}
j_arr =[]

ans = 0
for i in range(N):
    if i+arr[i] not in dic:
        dic[i+arr[i]] = 0
    dic[i+arr[i]] += 1
    j_arr.append(-1*arr[i]+i)
    if -1*arr[i]+i in dic:
        ans += dic[-1*arr[i]+i]

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
arr = list(map(int, input().split()))

for i in range(1,N+1,1):
    print(arr.count(i))

Fixed submission:
N = int(input())
arr = list(map(int, input().split()))
ans = [0]*N

for i in range(N-1):
    ans[(arr[i])-1] += 1

for i in range(len(ans)):
    print(ans[i])
Buggy python submission (verdict: Time Limit Exceeded):
import math

K=int(input())
ans=0
for i in range(1,K+1,1):
    for j in range(1,K+1,1):
        for k in range(1,K+1,1):
            a = math.gcd(i,j)
            b = math.gcd(a,k)
            ans += b
print(ans)            

Fixed submission:
import math

N=int(input())
ans=0
for i in range(1,N+1,1):
    for j in range(i,N+1,1):
        for k in range(j,N+1,1):
            list =[i,j,k]
            ff=len(set(list))
            a = math.gcd(i,j)
            b = math.gcd(a,k)
            if ff == 1:
                ans += b
            elif ff == 2:
                ans += 3*b
            else:
                ans += 6*b
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S =input()

count = 0
for i in range(0,N,1):
    for j in range(i+1,N,1):
        if S[i] == S[j]:
            continue
        for k in range(j+1,N,1):
            if S[j] != S[k] and S[i] != S[k] and abs(k-j) != abs(j-i):
                count +=1

print(count)


Fixed submission:
N = int(input())
S =input()
r = S.count('R')
b = S.count('B')
g = S.count('G')
x = r*b*g

count = 0
for i in range(0,N,1):
    for j in range(i+1,N,1):
        if 2*j-i > len(S)-1:
            continue
        if S[i] != S[j] and S[j] != S[2*j-i] and S[i] != S[2*j-i]:
            count +=1

print(x-count)

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

count = 0
for i in range(0,N,1):
    for j in range(i+1,N,1):
        for k in range(j+1,N,1):
            if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]  and abs(k-j) != abs(j-i):
                count +=1

print(count)


Fixed submission:
N = int(input())
S =input()
r = S.count('R')
b = S.count('B')
g = S.count('G')
x = r*b*g

count = 0
for i in range(0,N,1):
    for j in range(i+1,N,1):
        if 2*j-i > len(S)-1:
            continue
        if S[i] != S[j] and S[j] != S[2*j-i] and S[i] != S[2*j-i]:
            count +=1

print(x-count)
Buggy python submission (verdict: Time Limit Exceeded):
N, X, Y= map(int, input().split())
List=[]
for i in range(1,N+1,1):
	for j in range(i,N+1,1):
		saitan = min(abs(i-j), abs(i-X)+abs(Y-j)+1, abs(i-Y)+abs(X-j)+1)
		List.append(saitan)

for i in range(1,N):
    	print(List.count(i))

Fixed submission:
N, X, Y= map(int, input().split())
List=N*[0]

for i in range(1,N+1,1):
	for j in range(i,N+1,1):
		saitan = min(abs(i-j), abs(i-X)+abs(Y-j)+1, abs(i-Y)+abs(X-j)+1)
		List[saitan] += 1


for i in range(1,N):
    	print(List[i])

Buggy python submission (verdict: Time Limit Exceeded):
N, X, Y= map(int, input().split())
List=[]
for i in range(1,N+1,1):
	for j in range(i,N+1,1):
		saitan = min(abs(i-j), abs(i-X)+abs(Y-j)+1, abs(i-Y)+abs(X-j)+1)
		List.append(saitan)

for i in range(1,N):
    	print(List.count(i))


Fixed submission:
N, X, Y= map(int, input().split())
List=N*[0]

for i in range(1,N+1,1):
	for j in range(i,N+1,1):
		saitan = min(abs(i-j), abs(i-X)+abs(Y-j)+1, abs(i-Y)+abs(X-j)+1)
		List[saitan] += 1


for i in range(1,N):
    	print(List[i])
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
arr = [list(map(int, input().split())) for _ in range(M)]


for i in range(1000):
    t = str(i)
    if len(t) != N:
        continue
    flg=True
    for item in arr:
        if t[item[0]-1] != str(item[i]):
            flg=False
            break

    if flg:
        print(i)
        exit()

print(-1)


Fixed submission:
N, M = map(int, input().split())
arr = [list(map(int, input().split())) for _ in range(M)]

for i in range(1000):
    s = str(i)
    if len(s) != N:
        continue

    flg = True
    for j in range(len(arr)):
        if s[arr[j][0]-1] != str(arr[j][1]):
            flg = False
            break

    if flg:
        print(i)
        exit()

print(-1)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
arr = [list(map(int, input().split())) for _ in range(M)]


for i in range(1000):
    t = str(i)
    if len(t) != N:
        continue
    flg=True
    for j in arr:
        if t[j[0]-1] != str(j[i]):
            flg=False
            break

    if flg:
        print(i)
        exit()

print(-1)


Fixed submission:
N, M = map(int, input().split())
arr = [list(map(int, input().split())) for _ in range(M)]

for i in range(1000):
    s = str(i)
    if len(s) != N:
        continue

    flg = True
    for j in range(len(arr)):
        if s[arr[j][0]-1] != str(arr[j][1]):
            flg = False
            break

    if flg:
        print(i)
        exit()

print(-1)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
arr = [list(map(int, input().split())) for _ in range(M)]


for i in range(10**(N-1),10**N,1):
    t = str(i)
    flg=True
    for j in arr:
        if t[j[0]-1] != str(j[i]):
            flg=False
            break

    if flg:
        print(i)
        exit()

print(-1)


Fixed submission:
N, M = map(int, input().split())
arr = [list(map(int, input().split())) for _ in range(M)]

for i in range(1000):
    s = str(i)
    if len(s) != N:
        continue

    flg = True
    for j in range(len(arr)):
        if s[arr[j][0]-1] != str(arr[j][1]):
            flg = False
            break

    if flg:
        print(i)
        exit()

print(-1)
Buggy python submission (verdict: Runtime Error):
N = int(input())

for i in range(100000):
    if 2**i <= N and N<2**(i+1):
        print(2**(i+1)-1)
        break


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

import math
print(math.ceil(H/A))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
arr = list(map(int, input().split()))

count = 0
for i in range(N):
    if min(arr[0:i+1]) >= arr[i]:
        count += 1

print(count)

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

count = 0
mn = float('inf')
for i in range(N):
    if mn >= arr[i]:
        count += 1
        mn =min(mn,arr[i])

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
arr = list(map(int, input().split()))

count = 0
for i in range(N):
    if min(arr[0:i+1]) >= arr[i]:
        count += 1

print(count)

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

count = 0
mn = float('inf')
for i in range(N):
    if mn >= arr[i]:
        count += 1
        mn =min(mn,arr[i])

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
arr = list(map(int, input().split()))

count = 0
for i in range(N):
    new_arr = arr[0:i+1]
    if min(new_arr) >= arr[i]:
        count += 1

print(count)

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

count = 0
mn = float('inf')
for i in range(N):
    if mn >= arr[i]:
        count += 1
        mn =min(mn,arr[i])

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
arr = list(map(int, input().split()))

count = 0
for i in range(N):
    flg = True
    for j in range(0,i,1):
        if arr[j] < arr[i]:
            flg = False
            break

    if flg:
        count += 1

print(count)

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

count = 0
mn = float('inf')
for i in range(N):
    if mn >= arr[i]:
        count += 1
        mn =min(mn,arr[i])

print(count)
Buggy python submission (verdict: Runtime Error):
S, T = map(input().split())
print(S+T)


Fixed submission:
X, Y = input().split()
print(Y+X)
Buggy python submission (verdict: Runtime Error):
import math
X, Y = map(int, input().split())

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(X,Y))

Fixed submission:
import fractions
X, Y = map(int, input().split())

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

print(lcm(X,Y))
Buggy python submission (verdict: Runtime Error):
S = input()
arr =['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
print(arr[arr.index(S)+1])

Fixed submission:
S = input()
arr =['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
print(7-arr.index(S))

Buggy python submission (verdict: Runtime Error):
S = input()
arr =['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
print(arr[arr.index(S)+1])



Fixed submission:
S = input()
arr =['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
print(7-arr.index(S))