Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):

n=int(input())
p=list(map(int,input().split()))
count=0
for i in range(1,n):
    if p[i-1]<p[i] and p[i]<p[i+1]:
        count+=1
for i in range(1,n-1):     
    if p[i-1]>p[i] and p[i]>p[i+1]:
        count+=1
print(count)

Fixed submission:

n=int(input())
p=list(map(int,input().split()))
count=0
for i in range(1,n-1):
    if (p[i-1]<p[i] and p[i]<p[i+1]) or (p[i-1]>p[i] and p[i]>p[i+1]):
        count+=1
    else:
        continue
print(count)

Buggy python submission (verdict: Runtime Error):

n=int(input())
p=list(map(int,input().split()))
count=0
for i in range(1,n):
    if p[i-1]<p[i] and p[i]<p[i+1]:
        count+=1
for i in range(1,n-1):     
    if p[i-1]>p[i] and p[i]>p[i+1]:
        count+=1
print(count)

Fixed submission:

n=int(input())
p=list(map(int,input().split()))
count=0
for i in range(1,n-1):
    if (p[i-1]<p[i] and p[i]<p[i+1]) or (p[i-1]>p[i] and p[i]>p[i+1]):
        count+=1
    else:
        continue
print(count)
Buggy python submission (verdict: Runtime Error):
import numpy as np
from numba import jit#import numbaで関数前で@numba.jitでもok
@jit
n,l=map(int,input().split())
a = np.arange(l,l+n)
d = abs(a).argmin() # argmin: ndarrayで最小値の要素のインデックスを取得
print(a.sum() - a[d])

Fixed submission:

n,l=map(int,input().split())
aji_lis=[int(l+i-1) for i in range(1,n+1)]

N_sum=sum(aji_lis)
ap=min([abs(i) for i in aji_lis])

if N_sum >=0:
    print(N_sum-ap)
else:
    print(N_sum+ap)

Buggy python submission (verdict: Runtime Error):
import numpy as np
from numba import jit#import numbaで関数前で@numba.jitでもok
@jit
n,l=map(int,input().split())
a = np.arange(l,l+n)
d = abs(a).argmin() # argmin: ndarrayで最小値の要素のインデックスを取得
print(a.sum() - a[d])

Fixed submission:

n,l=map(int,input().split())
aji_lis=[int(l+i-1) for i in range(1,n+1)]

N_sum=sum(aji_lis)
ap=min([abs(i) for i in aji_lis])

if N_sum >=0:
    print(N_sum-ap)
else:
    print(N_sum+ap)

Buggy python submission (verdict: Runtime Error):
import numpy as np
n,l=map(int,input().split())
a = np.arange(l,l+n)
d = abs(a).argmin() # argmin: ndarrayで最小値の要素のインデックスを取得
print(a.sum() - a[d])

Fixed submission:

n,l=map(int,input().split())
aji_lis=[int(l+i-1) for i in range(1,n+1)]

N_sum=sum(aji_lis)
ap=min([abs(i) for i in aji_lis])

if N_sum >=0:
    print(N_sum-ap)
else:
    print(N_sum+ap)

Buggy python submission (verdict: Runtime Error):
import numpy as np
n,l=map(int,input().split())
a = np.arange(l,l+n)
d = abs(a).argmin() # argmin: ndarrayで最小値の要素のインデックスを取得
print(a.sum() - a[d])

Fixed submission:

n,l=map(int,input().split())
aji_lis=[int(l+i-1) for i in range(1,n+1)]

N_sum=sum(aji_lis)
ap=min([abs(i) for i in aji_lis])

if N_sum >=0:
    print(N_sum-ap)
else:
    print(N_sum+ap)

Buggy python submission (verdict: Runtime Error):
import numpy as np
a = np.arange(L, L + N)
d = abs(a).argmin() # argmin: ndarrayで最小値の要素のインデックスを取得
print(a.sum() - a[d])

Fixed submission:

n,l=map(int,input().split())
aji_lis=[int(l+i-1) for i in range(1,n+1)]

N_sum=sum(aji_lis)
ap=min([abs(i) for i in aji_lis])

if N_sum >=0:
    print(N_sum-ap)
else:
    print(N_sum+ap)
Buggy python submission (verdict: Runtime Error):


import sys
read = sys.stdin.buffer.read # 全読み込み
readline = sys.stdin.buffer.readline # 一行読み込み
readlines = sys.stdin.buffer.readlines # 一行ずつ全読み込み
sys.setrecursionlimit(10**7) # 再帰限界変更（デフォルトは1000）

"""
# 文字列（数値変換も含む）
n = readline().rstrip() # １行に１文字列のみ
lis = readline().rstrip().split() # # １行に複数の文字列

# 数値（文字変換も含む）
n = int(readline().rstrip()) # １行に数値１個のみ
a, b, c = map(int,readline().rstrip().split()) # １行に複数の数値
A = list(map(int,readline().rstrip().split()))  # １行に複数の数値（リスト受け取り）
lis = [readline().rstrip().split() for _ in range(n)] # １行に複数の数値(m個)かつ、n行続く場合（出力は二次元リスト：[['1', '2'], ['4', '5']]）

# dとAの行が交互に並んでいる場合
s = sys.stdin.readlines()
n, k=map(int, s[0].split())
d=[]
A=[]
for i in s[1:2*k:2]:
    d.append(int(i))
for i in s[2:2*k+1:2]:
    A.append(list(map(int, i.split())))
"""

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

import math
f = math.gcd(a,b) # 最大公約数
f2 = a*b // f # 最小公倍数

# b以下で条件を満たす個数
shou1=b//c
shou2=b//d
shou3=b//f2
num_b=b-(shou1+shou2-shou3)

# a-1以下で条件を満たす個数
shou4=(a-1)//c
shou5=(a-1)//d
shou6=(a-1)//f2
num_a=(a-1)-(shou4+shou5-shou6)

print(num_b-num_a)

Fixed submission:


import sys
read = sys.stdin.buffer.read # 全読み込み
readline = sys.stdin.buffer.readline # 一行読み込み
readlines = sys.stdin.buffer.readlines # 一行ずつ全読み込み
sys.setrecursionlimit(10**7) # 再帰限界変更（デフォルトは1000）

"""
# 文字列（数値変換も含む）
n = readline().rstrip() # １行に１文字列のみ
lis = readline().rstrip().split() # # １行に複数の文字列

# 数値（文字変換も含む）
n = int(readline().rstrip()) # １行に数値１個のみ
a, b, c = map(int,readline().rstrip().split()) # １行に複数の数値
A = list(map(int,readline().rstrip().split()))  # １行に複数の数値（リスト受け取り）
lis = [readline().rstrip().split() for _ in range(n)] # １行に複数の数値(m個)かつ、n行続く場合（出力は二次元リスト：[['1', '2'], ['4', '5']]）

# dとAの行が交互に並んでいる場合
s = sys.stdin.readlines()
n, k=map(int, s[0].split())
d=[]
A=[]
for i in s[1:2*k:2]:
    d.append(int(i))
for i in s[2:2*k+1:2]:
    A.append(list(map(int, i.split())))
"""

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

import fractions
f = fractions.gcd(c,d) # 最大公約数
f2 = c*d // f # 最小公倍数

# b以下で条件を満たす個数
shou1=b//c
shou2=b//d
shou3=b//f2
num_b=b-(shou1+shou2-shou3)

# a-1以下で条件を満たす個数
shou4=(a-1)//c
shou5=(a-1)//d
shou6=(a-1)//f2
num_a=(a-1)-(shou4+shou5-shou6)

print(num_b-num_a)
Buggy python submission (verdict: Runtime Error):

# 解答（@maspy）

# switchが10個以下
N,M = map(int,input().split())
sw = [[] for _ in range(M)]
# print(sw) # [[], [], ..., []]

for i in range(M):
    sw[i] = list(map(int,input().split()[1:]))
# print(sw) # [[１行目], [２行目], ..., [M行目]]

import itertools

answer = 0
for tpl in itertools.product([0,1],repeat=N):
  bl = True
  for i in range(M):
    # 電球iを計算
    s = sum([tpl[s-1] for s in sw[i]])
    if (s-p[i])%2 != 0:
      bl = False
      break
  if bl:
    answer += 1
print(answer)

Fixed submission:

# 解答（@maspy）

# switchが10個以下
N,M = map(int,input().split())
sw = [[] for _ in range(M)]
# print(sw) # [[], [], ..., []]

for i in range(M):
    sw[i] = list(map(int,input().split()[1:]))
# print(sw) # [[１行目], [２行目], ..., [M行目]]

p = [int(x) for x in input().split()]
import itertools

answer = 0
for tpl in itertools.product([0,1],repeat=N):
  bl = True
  for i in range(M):
    # 電球iを計算
    s = sum([tpl[s-1] for s in sw[i]])
    if (s-p[i])%2 != 0:
      bl = False
      break
  if bl:
    answer += 1
print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
zahyo=[0]*m
for i in range(m):
    zahyo[i]=list(map(int,input().split()))
 
collec_lis=[]
for i in range(m):
    collec_lis.extend(list(range(int(zahyo[i][0]),int(zahyo[i][1])+1)))
    
import collections
c = collections.Counter(collec_lis)
 
kyotu=[int(i) for i in list(c.values()) if i==m]
print(len(kyotu))

Fixed submission:

# 左右の範囲を絞っていくことで共通要素のみを炙り出す
n,m = map(int,input().split())
l = -1
r = n+1
for i in range(m):
    l_i,r_i = map(int,input().split())
    l = max(l,l_i)
    r = min(r,r_i)
print(max(0,r-l+1))

Buggy python submission (verdict: Runtime Error):

n,m = map(int,input().split())
s = -1
t = n+1
for i in range(m):
    l_i,r_i = map(int,input().split())
    l = max(l,l_i)
    r = min(r,r_i)
print(max(0,r-l+1))

Fixed submission:

# 左右の範囲を絞っていくことで共通要素のみを炙り出す
n,m = map(int,input().split())
l = -1
r = n+1
for i in range(m):
    l_i,r_i = map(int,input().split())
    l = max(l,l_i)
    r = min(r,r_i)
print(max(0,r-l+1))

Buggy python submission (verdict: Time Limit Exceeded):

n,m=map(int,input().split())
zahyo=[0]*m
for i in range(m):
    zahyo[i]=list(map(int,input().split()))

collec_lis=[]
for i in range(m):
    collec_lis.extend(list(range(int(zahyo[i][0]),int(zahyo[i][1])+1)))
    
import collections
c = collections.Counter(collec_lis)

kyotu=[int(i) for i in list(c.values()) if i==m]
print(len(kyotu))

Fixed submission:

# 左右の範囲を絞っていくことで共通要素のみを炙り出す
n,m = map(int,input().split())
l = -1
r = n+1
for i in range(m):
    l_i,r_i = map(int,input().split())
    l = max(l,l_i)
    r = min(r,r_i)
print(max(0,r-l+1))
Buggy python submission (verdict: Runtime Error):
s = input()
n = len(s)


def dfs(i, f):
    if i == n - 1:
        return sum(list(map(int, f.split("+"))))

	return dfs(i + 1, f + s[i + 1]) + dfs(i + 1, f + "+" + s[i + 1])
    
print(dfs(0, s[0]))

Fixed submission:
s = input()
n = len(s)

def dfs(i, f):
    if i == n - 1:
        return sum(list(map(int, f.split("+"))))

    # 式 f の末尾に "+" を追加するかしないかして次の数字を追加
    # 関数の足し算はメソッドを記憶したまま、各関数に分岐していく
    # → (2:返る関数が2個) ^ (n-1:再帰回数が i=0,1...でn-1回) ＝ 最終的な関数は2^(n-1)個
    return dfs(i + 1, f + s[i + 1]) + dfs(i + 1, f + "+" + s[i + 1])
    
print(dfs(0, s[0]))

Buggy python submission (verdict: Runtime Error):
s = input()
n = len(s)

start = time.time()

def dfs(i, f):
    if i == n - 1:
        return sum(list(map(int, f.split("+"))))

    return dfs(i + 1, f + s[i + 1]) + dfs(i + 1, f + "+" + s[i + 1])
    
print(dfs(0, s[0]))

Fixed submission:
s = input()
n = len(s)

def dfs(i, f):
    if i == n - 1:
        return sum(list(map(int, f.split("+"))))

    # 式 f の末尾に "+" を追加するかしないかして次の数字を追加
    # 関数の足し算はメソッドを記憶したまま、各関数に分岐していく
    # → (2:返る関数が2個) ^ (n-1:再帰回数が i=0,1...でn-1回) ＝ 最終的な関数は2^(n-1)個
    return dfs(i + 1, f + s[i + 1]) + dfs(i + 1, f + "+" + s[i + 1])
    
print(dfs(0, s[0]))
Buggy python submission (verdict: Runtime Error):
n,k = map(int,input().split())
d=[]
for i in range(k*2):
    d.append(list(map(int,input().split())))

ans=[]
for i in range(1,len(d),2):
    ans.append(*d[i])

ans=len(set(ans))
print(n-ans)

Fixed submission:
n,k = map(int,input().split())
sunuke=[0]*n
for i in range(k):
    d=int(input())
    a=list(map(int,input().split()))
    for j in a:
        sunuke[j-1]+=1

print(sunuke.count(0))
Buggy python submission (verdict: Time Limit Exceeded):
import math
a,b,n=map(int,input().split())
ans=0
for i in range(1,n+1):
    tmp=math.floor(a*i/b)- a*math.floor(i/b)
    ans=max(ans,tmp)
print(ans)

Fixed submission:
a,b,n = map(int,input().split())
x=min(b-1,n)
ans=a*x//b-a*(x//b)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
for i in range(1,n+1):
    cnt=a.count(i)
    print(cnt)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
boss=[0]*n
for i in a:
    boss[i-1]+=1
for i in boss:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
import math
k=int(input())
ans=0
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            x=math.gcd(a,b)
            ans+=math.gcd(x,c)
print(ans)

Fixed submission:
from math import gcd
k=int(input())
ans=0
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            ans+=gcd(gcd(a,b),c)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
k=int(input())
ans=0
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            x=math.gcd(a,b)
            ans+=math.gcd(x,c)
print(ans)

Fixed submission:
from math import gcd
k=int(input())
ans=0
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            ans+=gcd(gcd(a,b),c)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
ans=float('inf')
if k == 1:
    print(0)
    exit()
elif n < k :
    print(min(n,k-n))
else:
    for i in range(n):
        n=abs(n-k)
        ans=min(ans,n)
    
    print(ans)

Fixed submission:
n,k=map(int,input().split())
print(min(n%k,k-n%k))
Buggy python submission (verdict: Runtime Error):
a=[list(map(int,input().split())) for i in range(3)]
n=int(input())
for i in range(int(input())):
  b=int(input())
  for j in range(3):
    for k in range(3):
      if a[j][k]==b:a[j][k]=0
ans='No'
for i in range(3):
    if a[i][0]==a[i][1]==a[i][2]==0:
        ans='Yes'
    if a[0][i]==a[1][i]==a[2][i]==0:
        ans='Yes'
if a[0][0]==a[1][1]==a[2][2]==0:
    ans='Yes'
if a[2][0]==a[1][1]==a[0][2]==0:
    ans='Yes'
print(ans)

Fixed submission:
a=[list(map(int,input().split()))for _ in range(3)]
for i in range(int(input())):
  b=int(input())
  for j in range(3):
    for k in range(3):
      if a[j][k]==b:a[j][k]=0
ans="No"
for i in range(3):
  if a[i][0]==a[i][1]==a[i][2]==0:ans="Yes"
  if a[0][i]==a[1][i]==a[2][i]==0:ans="Yes"
if a[0][0]==a[1][1]==a[2][2]==0:ans="Yes"
if a[2][0]==a[1][1]==a[0][2]==0:ans="Yes"
print(ans)
Buggy python submission (verdict: Runtime Error):
h = int(input())
a = int(input())
if h % a == 0:
    print(h//a)
else:
    print(h//a + 1)

Fixed submission:
h,a = map(int,input().split())
if h % a == 0:
    print(h//a)
else:
    print(h//a + 1)
Buggy python submission (verdict: Runtime Error):
n,k,m = map(int,input().split())
a = list(map(int,input().split()))
x = 0
for i in range(n-1):
    x+=a[i]
if n*m - x <= k:
    print(n*m-x)
else:
    print(-1)

Fixed submission:
c = input()
print(chr(ord(c) + 1))
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = list(input())
count = 0
for i in range (n-2):
    if s[i]=="A" and s[i+1]=="B" and s[i+2]=="C":
        count += 1
print(count)

Fixed submission:
k,x = map(int,input().split())
if 500*k >= x:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
s,t = map(input().split())
print(t+s)


Fixed submission:
s,t = input().split()
print(t+s)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,k = map(int,input().split())
for i in range(k):
    if a > 0:
        a-=1
    else:
        b-=1

print(a, b)

Fixed submission:
a,b,k = map(int,input().split())
if a >= k:
    print(a-k, b)
else:
    print(0, max(b+a-k,0))
Buggy python submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
gcd=math.gcd(a,b)
ans=a*b//gcd
print(int(ans))

Fixed submission:
from fractions import gcd
a,b=map(int,input().split())
gcd=gcd(a,b)
ans=a*b//gcd
print(ans)

Buggy python submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
gcd=math.gcd(a,b)
ans=a*b//gcd
print(ans)

Fixed submission:
from fractions import gcd
a,b=map(int,input().split())
gcd=gcd(a,b)
ans=a*b//gcd
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k,q = map(int,input().split())
a=[]
for i in range(q):
    a.append(int(input()))

point=[k]*n

for i in a:
    for j in range(1,n+1):
        if i!=j:
            point[j-1]-=1

for i in point:
    if i > 0:
        print('Yes')
    else:
        print('No')

Fixed submission:
from collections import Counter
n,k,q = map(int,input().split())
a=[]
for i in range(q):
    a.append(int(input()))
point=[k-q]*n
r=Counter(a)
for i,j in r.items():
    point[i-1] += j
for i in point:
    if i>0:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=[int(input())for _ in range(n)]
b=sorted(a)
for i in range(n):
    if a[i]==max(a):
        print(b[-2])
    else:
        print(max(a))

Fixed submission:
n=int(input())
a=[int(input())for _ in range(n)]
b=sorted(a)
max_a=max(a)
second=b[-2]
for i in range(n):
    if a[i] != max_a:
        print(max_a)
    else:
        print(second)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
d=list(map(int,input().split()))
cnt=0
for i in range(min(d),max(d)+1):
    abc=0
    arc=0
    for j in range(len(d)):
        if d[j] <= i:
            abc+=1
        else:
            arc+=1
    if abc == arc:
        cnt+=1
print(cnt)

Fixed submission:
n=int(input())
d=list(map(int,input().split()))
A=sorted(d)
print(A[len(d)//2]-A[(len(d)//2)-1])
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
lr=[list(map(int,input().split())) for _ in range(m)]
card=[0]*n

for i in range(m):
    l,r=lr[i]
    for j in range(l-1,r):
        card[j]+=1
print(card.count(m))

Fixed submission:
n,m=map(int,input().split())
l=1
r=n
for i in range(m):
    ll,rr = map(int,input().split())
    l=max(l,ll)
    r=min(r,rr)
if l<=r:
    print(r-l+1)
else:
    print(0)

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
lr=[list(map(int,input().split())) for _ in range(m)]
card=[0]*n

for i in range(m):
    l,r=lr[i]
    for j in range(l-1,r):
        card[j]+=1
ans=0
for k in range(n):
    if card[k] == m:
        ans+=1
print(ans)

Fixed submission:
n,m=map(int,input().split())
l=1
r=n
for i in range(m):
    ll,rr = map(int,input().split())
    l=max(l,ll)
    r=min(r,rr)
if l<=r:
    print(r-l+1)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n,k=map(int,input().split())
h=[int(input()) for _ in range(n)]
ans=float('inf')
for i in itertools.permutations(h,k):
    tmp=max(i)-min(i)
    ans=min(ans,tmp)
print(ans)

Fixed submission:
n,k=map(int,input().split())
h=[int(input()) for _ in range(n)]
h.sort()
ans=float('inf')
for i in range(n-k+1):
    tmp=h[i+k-1]-h[i]
    ans=min(tmp,ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
s=input()
k=int(input())
ans=1
for i in range(k+1):
    if s[i] != '1':
        ans=s[i]
        break
print(ans)

Fixed submission:
s=input()
k=int(input())
ans=1
for i in range(k):
    if s[i] != '1':
        ans=s[i]
        break
print(ans)

Buggy python submission (verdict: Runtime Error):
s=input()
k=int(input())
ans=1
for i in range(k+1):
    if s[i] != '1':
        ans=s[i]
        break
print(ans)

Fixed submission:
s=input()
k=int(input())
ans=1
for i in range(k):
    if s[i] != '1':
        ans=s[i]
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
alice=0
bob=0
a=sorted(a)
while a:
    alice+=a[-1]
    a.pop()
    bob+=a[-1]
    a.pop()
print(alice-bob)

Fixed submission:
N = int(input())
a = list(map(int,input().split()))
alice = 0
bob = 0
a.sort(reverse=True)
for i in range(N):
    if i%2 == 0:
        alice += a[i]
    else:
        bob += a[i]
print(alice - bob)
Buggy python submission (verdict: Runtime Error):
n=int(input())
t=[0]*3
x=[0]*3
y=[0]*3
for i in range(n):
    t[i+1],x[i+1],y[i+1] = map(int,input().split())

flag=True
for i in range(n):
    time=t[i+1]-t[i]
    dist=abs(x[i+1]-x[i])+abs(y[i+1]-y[i])
    if dist>time:
        flag=False
    if dist%2 != time%2:
        flag=False
if flag == True:
    print('Yes')
else:
    print('No')

Fixed submission:
n=int(input())
t=[0]*(n+1)
x=[0]*(n+1)
y=[0]*(n+1)
for i in range(n):
    t[i+1],x[i+1],y[i+1] = map(int,input().split())

flag=True
for i in range(n):
    time=t[i+1]-t[i]
    dist=abs(x[i+1]-x[i])+abs(y[i+1]-y[i])
    if dist>time:
        flag=False
    if dist%2 != time%2:
        flag=False
if flag == True:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
    tmp=0
    for j in range(n):
        if abs(a[j]-a[i])<=1:
            tmp+=1
            ans=max(ans,tmp)
print(ans)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=[0]*100002
for i in a:
    ans[i]+=1
    ans[i+1]+=1
    ans[i+2]+=1
print(max(ans))
Buggy python submission (verdict: Runtime Error):
,a,b=map(int,input().split())
if a<b:
    if b-(a+w) < 0:
        print(0)
    else:
        print(b-(a+w))
else:
    if a-(b+w) < 0:
        print(0)
    else:
        print(a-(b+w))

Fixed submission:
w,a,b=map(int,input().split())
if a<b:
    if b-(a+w) < 0:
        print(0)
    else:
        print(b-(a+w))
else:
    if a-(b+w) < 0:
        print(0)
    else:
        print(a-(b+w))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
p=1
for i in range(1,n+1):
    p=p*i
print(p%(10**9+7))

Fixed submission:
n=int(input())
p=1
for i in range(1,n+1):
    p=(p*i)%(10**9+7)
print(p)
Buggy python submission (verdict: Time Limit Exceeded):
k,s =map(int,input().split())
cnt=0
for x in range(0,k+1):
    for y in range(0,k+1):
        for z in range(0,k+1):
            if x+y+z == s:
                cnt+=1

print(cnt)

Fixed submission:
k,s = map(int,input().split())
cnt = 0
for x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if z >= 0 and z <= k:
            cnt += 1

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
k,s=map(int,input().split())
ans=0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x+y+z==s:
                ans+=1
print(ans)

Fixed submission:
k,s = map(int,input().split())
cnt = 0
for x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if z >= 0 and z <= k:
            cnt += 1

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
k,s = map(int,input().split())
cnt = 0
for x in range(k+1):
    for y in range(k+1):
        for z in range(k+1):
            if x+y+z ==s:
                cnt += 1
print(cnt)

Fixed submission:
k,s = map(int,input().split())
cnt = 0
for x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if z >= 0 and z <= k:
            cnt += 1

print(cnt)
Buggy python submission (verdict: Runtime Error):
s=input()
cnt=0
for i in range(n):
    if s[i] == 'a' and cnt < a+b:
        print('Yes')
        cnt+=1
    elif s[i] == 'b' and cnt < a+b and i+1 <=b:
        print('Yes')
        cnt+=1
    elif s[i] == 'c':
        print('No')
    else:
        print('No')

Fixed submission:
n,a,b=map(int,input().split())
s=input()
cnt=0
cnt_f=0
for i in range(n):
    if s[i] == 'a' and cnt < a+b:
        print('Yes')
        cnt+=1
    elif s[i] == 'b' and cnt < a+b and cnt_f < b:
        print('Yes')
        cnt+=1
        cnt_f+=1
    elif s[i] == 'c':
        print('No')
    else:
        print('No')
Buggy python submission (verdict: Runtime Error):
n=int(input())
arr=list(map(int,input().split()))
c=0
for i in range n:
  if i%2!=0 and arr[i]%2!=0:
    c+=1
print(c)

Fixed submission:
n=int(input())
arr=list(map(int,input().split()))
c=0
for i in range(n):
  if (i+1)%2!=0 and arr[i]%2!=0:
    c+=1
print(c)

Buggy python submission (verdict: Runtime Error):
n=int(input())
arr=list(map(int,input().split()))
c=0
for i in range n:
  if 1%2!=0 and arr[i]%2!=0:
    c+=1
print(c)

Fixed submission:
n=int(input())
arr=list(map(int,input().split()))
c=0
for i in range(n):
  if (i+1)%2!=0 and arr[i]%2!=0:
    c+=1
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0

a.insert(0, 0)
b.insert(0, 0)

for i in range(n+1):
    if sum(a[0:i+1]) > k:
        break
    for j in range(m+1):
        if sum(a[0:i+1]) + sum(b[0:j+1]) > k:
            break
        if sum(a[0:i+1]) + sum(b[0:j+1]) <= k and i + j > ans:
            ans = i + j

print(ans)

Fixed submission:
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
amax = 0
samax = 0

for i in range(n):
    if samax + a[i]<=k:
        amax += 1
        samax += a[i]
    else:
        break
        
book = amax
ans = book
samax = sum(a[0:amax])
sbmax = 0

for j in range(m):
    sbmax += b[j]
    while samax + sbmax > k and amax >= 1:
        amax -= 1
        samax = samax - a[amax]
        book -= 1
    if samax + sbmax <= k:
        book += 1
        if book > ans:
            ans = book
    else:
        break

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0

a.insert(0, 0)
b.insert(0, 0)

for i in range(n+1):
    for j in range(m+1):
        if sum(a[0:i+1]) + sum(b[0:j+1]) <= k and i + j > ans:
            ans = i + j

print(ans)

Fixed submission:
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
amax = 0
samax = 0

for i in range(n):
    if samax + a[i]<=k:
        amax += 1
        samax += a[i]
    else:
        break
        
book = amax
ans = book
samax = sum(a[0:amax])
sbmax = 0

for j in range(m):
    sbmax += b[j]
    while samax + sbmax > k and amax >= 1:
        amax -= 1
        samax = samax - a[amax]
        book -= 1
    if samax + sbmax <= k:
        book += 1
        if book > ans:
            ans = book
    else:
        break

print(ans)