Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
def main():
    N, M = map(int, input().split())
    W, V = [0]*N, [0]*N
    for i in range(N):
        W[i], V[i] = map(int, input().split())
    dp = [[float('inf')]*(10**5+10) for i in range(N+1)]
    # for i in range(150):
    #     dp[0][i] = 0
    dp[0][0] = 0

    for i in range(N):
        for v in range(10**5+10):
            if v - V[i] >= 0:
                dp[i+1][v] = min(dp[i+1][v], dp[i][v - V[i]] + W[i])
            dp[i+1][v] = min(dp[i+1][v], dp[i][v])
    ans = 0
    for v in range(10**5 + 10):
        if dp[N][v] <= M:
            ans = v
    print(ans)

if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = sys.stdin.readline
def main():
    N, M = map(int, input().split())
    W, V = [0]*N, [0]*N
    for i in range(N):
        W[i], V[i] = map(int, input().split())
    dp = [[float('inf')]*(10**5+10) for i in range(N+1)]
    # for i in range(150):
    #     dp[0][i] = 0
    dp[0][0] = 0

    for i in range(N):
        for v in range(10**5+10):
            if v - V[i] >= 0:
                dp[i+1][v] = min(dp[i+1][v], dp[i][v - V[i]] + W[i])
            dp[i+1][v] = min(dp[i+1][v], dp[i][v])
    ans = 0
    for v in range(10**5 + 10):
        if dp[N][v] <= M:
            ans = v
    print(ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
def main():
    N, K = map(int, input().split())
    h = [int(input()) for i in range(N)]
    H = sorted(h)
    ans = 10**9 +1
    for i in range(N-K+1):
        high = max(H[i:i+K]) - min(H[i:i+K])
        ans = min(ans, high)
    print(ans)

if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = sys.stdin.readline
def main():
    N, K = map(int, input().split())
    h = [int(input()) for i in range(N)]
    H = sorted(h)

    ans = 10**9 +1
    for i in range(N-K+1):
        high = H[i+K-1] - H[i] 
        ans = min(ans, high)
    print(ans)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
def main():
    N, K = map(int, input().split())
    h = [int(input()) for i in range(N)]
    H = sorted(h)
    ans = 10**9 +1
    for i in range(N-K+1):
        high = max(H[i:i+K]) - min(H[i:i+K])
        ans = min(ans, high)
    print(ans)

if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = sys.stdin.readline
def main():
    N, K = map(int, input().split())
    h = [int(input()) for i in range(N)]
    H = sorted(h)

    ans = 10**9 +1
    for i in range(N-K+1):
        high = H[i+K-1] - H[i] 
        ans = min(ans, high)
    print(ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = int(input())
coin = n%500
if a >= coin:
  print("Yes")
else:
  priont("No")

Fixed submission:
n = int(input())
a = int(input())
coin = n%500
if a >= coin:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**9) 
input = sys.stdin.readline
def gdc(a, b):
    if b == 0:
        return a
    return gdc(b, a%b)
def lcm(a,b):
    return a*b//gdc(a,b)

def main():
    N = int(input())
    T = [int(input()) for i in range(N)]
    ans = lcm(max(T[0], T[1]), min(T[0], T[1]))
    if N == 2:
        print(ans)
        return
    for i in range(2,N):
        ans = lcm(max(ans, T[i]), min(ans, T[i]))
    print(ans)

if __name__ == '__main__':
    main()

Fixed submission:
import sys
sys.setrecursionlimit(10**9) 
input = sys.stdin.readline
def gdc(a, b):
    if b == 0:
        return a
    return gdc(b, a%b)
def lcm(a,b):
    return a*b//gdc(a,b)

def main():
    N = int(input())
    T = [int(input()) for i in range(N)]
    if N == 1:
        return print(T[0])
    ans = lcm(max(T[0], T[1]), min(T[0], T[1]))
    if N == 2:
        print(ans)
        return
    for i in range(2,N):
        ans = lcm(max(ans, T[i]), min(ans, T[i]))
    print(ans)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def gdc(a, b):
    if b == 0:
        return a
    return gdc(b, a%b)
def lcm(a,b):
    return a*b//gdc(a,b)

def main():
    N = int(input())
    T = [int(input()) for i in range(N)]
    ans = lcm(max(T[0], T[1]), min(T[0], T[1]))
    if N == 2:
        print(ans)
        return
    for i in range(2,N):
        ans = lcm(max(ans, T[i]), min(ans, T[i]))
    print(ans)

if __name__ == '__main__':
    main()

Fixed submission:
import sys
sys.setrecursionlimit(10**9) 
input = sys.stdin.readline
def gdc(a, b):
    if b == 0:
        return a
    return gdc(b, a%b)
def lcm(a,b):
    return a*b//gdc(a,b)

def main():
    N = int(input())
    T = [int(input()) for i in range(N)]
    if N == 1:
        return print(T[0])
    ans = lcm(max(T[0], T[1]), min(T[0], T[1]))
    if N == 2:
        print(ans)
        return
    for i in range(2,N):
        ans = lcm(max(ans, T[i]), min(ans, T[i]))
    print(ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
k, s = map(int, input().split())
ans = 0
for x in range(k+1):
    for y in range(k+1):
        z = s-x-y
        if k >= z >= 0:
            ans += 1
print(ans))

Fixed submission:
k, s = map(int, input().split())
arr = [1 for x in range(k+1) for y in range(k+1) if k >= s-x-y >= 0]
print(sum(arr))

Buggy python submission (verdict: Runtime Error):
k, s = map(int, input().split())
ans = 0
for x in range(k+a):
    for y in range(k+1):
        z = s-x-y
        if k >= z >= 0:
            ans += 1
print(ans))

Fixed submission:
k, s = map(int, input().split())
arr = [1 for x in range(k+1) for y in range(k+1) if k >= s-x-y >= 0]
print(sum(arr))

Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
arr = [[x, y, s-x-y] for x in range(k+1) for y in range(k+1) if k >= s-x-y >= 0]
print(len(arr))

Fixed submission:
k, s = map(int, input().split())
arr = [1 for x in range(k+1) for y in range(k+1) if k >= s-x-y >= 0]
print(sum(arr))

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

Fixed submission:
k, s = map(int, input().split())
arr = [1 for x in range(k+1) for y in range(k+1) if k >= s-x-y >= 0]
print(sum(arr))
Buggy python submission (verdict: Runtime Error):
if int(input()) % 9 == 0 : print("Yes")
else print("No")

Fixed submission:
if int(input()) % 9 == 0 : print("Yes")
else : print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

ans = [0] * n
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        ans[i] ^= a[j]

print(*ans)

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

tmp = int(0)
for t in a:
    tmp ^= t

ans = [0] * n
for i in range(n):
    ans[i] = tmp ^ a[i]

print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int, input().split())
to = [[0] * n for i in range(60)]
to[0] = list(map(int, input().split()))

# ダブリング
for i in range(n):
    to[0][i] -= 1
DOUBLING = 60
for i in range(DOUBLING-1):
    for j in range(n):
        to[i+1][j] = to[i][to[i][j]]
v = 0
for d in range(DOUBLING, -1, -1):
    l = (1 << d)
    if l <= k:
        v = to[d][v]
        k -= l

print(v + 1)

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

visit = []
step = [-1] * (n + 1)
v = 1
while step[v] == -1:
    step[v] = len(visit)
    visit.append(v)
    v = a[v - 1]
cycle = len(visit) - step[v]
nonCycle = step[v]

if k < nonCycle:
    print(visit[k])
else:
    k -= nonCycle
    k %= cycle
    print(visit[nonCycle + k])
Buggy python submission (verdict: Time Limit Exceeded):
l, r = map(int, input().split())

mod = 2019
ans = mod
for i in range(l, r):
    res = 0
    for j in range(i+1, r+1):
        res = (i*j) % mod
        ans = min(ans, res)
    if res == 0:
        print(ans)
        exit()

print(ans)

Fixed submission:
l, r = map(int, input().split())

mod = 2019
ans = mod
for i in range(l, r):
    for j in range(i+1, r+1):
        res = (i*j) % mod
        ans = min(ans, res)
        if res == 0:
            print(ans)
            exit()

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
l, r = map(int, input().split())

mod = 2019
ans = mod
for i in range(l, r):
    res = 0
    for j in range(i+1, r+1):
        res = (i*j) % mod
        ans = min(ans, res)
    if res == 0:
        print(ans)
        exit()

print(ans)

Fixed submission:
l, r = map(int, input().split())

mod = 2019
ans = mod
for i in range(l, r):
    for j in range(i+1, r+1):
        res = (i*j) % mod
        ans = min(ans, res)
        if res == 0:
            print(ans)
            exit()

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
l, r = map(int, input().split())

mod = 2019
ans = mod
for i in range(l, r):
    res = 0
    for j in range(i+1, r+1):
        res = i*j % mod
        ans = min(ans, res)
    if res == 0:
        break

print(ans)

Fixed submission:
l, r = map(int, input().split())

mod = 2019
ans = mod
for i in range(l, r):
    for j in range(i+1, r+1):
        res = (i*j) % mod
        ans = min(ans, res)
        if res == 0:
            print(ans)
            exit()

print(ans)
Buggy python submission (verdict: Runtime Error):
import bisect

N, X = map(int, input().split())
x = list(map(int, input().split()))

x.sort()
lb = bisect.bisect_left(x, X)
ub = bisect.bisect_right(x, X)
left = abs(x[lb] - X)
right = abs(x[ub] - X)
ans = min(left, right)

print(ans)

Fixed submission:
import fractions

N, X = map(int, input().split())
x = list(map(int, input().split()))

ans = abs(X-x[0])
for pos in x:
    ans = fractions.gcd(ans, abs(X-pos))

print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
k = input()

if s[0] == '1':
    print(s[1])
else:
    print(s[0])

Fixed submission:
s = input()
k = int(input())

for i in range(min(len(s), k)):
    if int(s[i]) > 1:
        print(s[i])
        exit(0)

print(1)
Buggy python submission (verdict: Runtime Error):
n = int(input())
p = list(map(int, input().split()))
for i in range(n): p[i] -= 1

ans = 0
for i in range(n):
    if p[i] == i:
        ans += 1
        p[i], p[i+1] = p[i+1], p[i]

print(ans)

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
p.append(0)
for i in range(n): p[i] -= 1

ans = 0
for i in range(n):
    if p[i] == i:
        ans += 1
        p[i], p[i+1] = p[i+1], p[i]

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

b = []
for t in a:
    b.append(t)
    b.reverse()

print(" ".join(map(str, b)))


Fixed submission:
from collections import deque

n = int(input())
a = list(map(int, input().split()))

b = deque()
for i in range(n):
    if i % 2 == 0:
        b.append(a[i])
    else:
        b.appendleft(a[i])
if n % 2 == 1:
    b.reverse()

print(" ".join(map(str, b)))

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

b = []
for t in a:
    b.append(t)
    b.reverse()

print(" ".join(map(str, b)))


Fixed submission:
from collections import deque

n = int(input())
a = list(map(int, input().split()))

b = deque()
for i in range(n):
    if i % 2 == 0:
        b.append(a[i])
    else:
        b.appendleft(a[i])
if n % 2 == 1:
    b.reverse()

print(" ".join(map(str, b)))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]

for a, b in ab:
    res = 10**8
    for i in range(m):
        (c, d) = cd[i]
        dist = abs(a-c)+abs(b-d)
        if dist < res:
            ans = i
        res = min(res, dist)
    print(ans+1)

Fixed submission:
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]

for a, b in ab:
    dis = 4 * 10**8
    for i in range(m):
        (c, d) = cd[i]
        tmp = abs(a-c)+abs(b-d)
        if dis > tmp:
            ans = i
            dis = tmp
    print(ans+1)
Buggy python submission (verdict: Time Limit Exceeded):
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
N = int(input())
count = 0
for i in range(0,N):
    count = count + len(make_divisors(i))
print(count)

Fixed submission:
N = int(input())
count = 0
for i in range(1,N):
    count = count + (N-1)//i
print(count)

Buggy python submission (verdict: Runtime Error):
import sympy
N = int(input())
count = 0
for i in range(0,N):
    count = count + sympy.divisor_count(i)
print(count)

Fixed submission:
N = int(input())
count = 0
for i in range(1,N):
    count = count + (N-1)//i
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
X,K,D=map(int,input().split())
kai = 0
xy = abs(X)
ds = D
if xy >= K*D:
    kotae = abs(xy-(K*D))
if xy < K*D:
    while xy >ds:
        ds=ds+D
        kai = kai+1
    ds = ds-D
    if (K-kai)%2==0:
        kotae = abs(xy-ds)
    if (K-kai)%2!=0:
        kouho1 = abs(xy-ds-D)
        kouho2 = abs(xy-ds+D)
        if kouho1>=kouho2:
            kotae = kouho2
        if kouho1<kouho2:
            kotae = kouho1
print(kotae)

Fixed submission:
X,K,D=map(int,input().split())
kai = 0
xy = abs(X)
if xy >= K*D:
    kotae = abs(xy-(K*D))
if xy < K*D:
    kai, mod = divmod(xy, D)
    ds = kai*D
    if (K-kai)%2==0:
        kotae = abs(xy-ds)
    if (K-kai)%2!=0:
        kouho1 = abs(xy-ds-D)
        kouho2 = abs(xy-ds+D)
        if kouho1>=kouho2:
            kotae = kouho2
        if kouho1<kouho2:
            kotae = kouho1
print(kotae)
Buggy python submission (verdict: Runtime Error):
A = input(int())
if 30 <= A:
    print("Yes")
else:
    print("No")

Fixed submission:
A = int(input())
if 30 <= A:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate
import bisect

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a_acc = [0] + list(accumulate(a))  # aを0冊読む=1冊も読まない場合があるので、[0]を先頭に追加します
b_acc = list(accumulate(b))  # bisect_rightでは、x以下の要素がいくつあるか？を求めるので、こちらに0は入れません

ans = 0
for an in range(n + 1):
    rem = k - a_acc[an]
    if rem < 0:
        # aをこれ以上読めません
        break

    bn = bisect.bisect_right(b_acc, rem)
    ans = max(ans, an + bn)

print(ans)

Fixed submission:
N = int(input())
print(N+N*N+N*N*N)
Buggy python submission (verdict: Runtime Error):
A,B=map(int,input().split())
C = list(map(int,input().split()))
C.sort()
D = C[0]+C[1]+C[2]
print(D)


Fixed submission:
A,B=map(int,input().split())
C = list(map(int,input().split()))
C.sort()
D = 0
for i in range(0,B):
    D = D + C[i]
print(D)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
alist = list(map(int, input().split()))
k = 1
for i in range(0,N):
    k = k*alist[i]
if k > 1000000000000000000:
    k= -1
print(k)

Fixed submission:
N = int(input())
alist = list(map(int, input().split()))
k = 1
if 0 in alist:
    print(0)
else:
    for i in range(0,N):
        k = k*alist[i]
        if k > 1000000000000000000:
            k= -1
            break
    print(k)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
alist = list(map(int, input().split()))
k = 1
for i in range(0,N):
    k = k*alist[i]
if k > 1000000000000000000:
    k= -1
print(k)

Fixed submission:
N = int(input())
alist = list(map(int, input().split()))
k = 1
if 0 in alist:
    print(0)
else:
    for i in range(0,N):
        k = k*alist[i]
        if k > 1000000000000000000:
            k= -1
            break
    print(k)
Buggy python submission (verdict: Runtime Error):
A,B=map(int,input().split())
print((A*(B*100))/100)


Fixed submission:
A,B=input().split()
A =int(A)
B =int(B.replace('.', ''))
print(A*B//100)
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
e,d,f=map(int,input().split())
g,h,i=map(int,input().split())
bingo = [a,b,c,d,e,f,g,h,i]
a_list= []
yes = 0
N = int(input())
for i in range(0,N):
    b = int(input())
    if b in bingo:
        a_list.append(bingo.index(b))
if 0 in a_list:
    if 1 in a_list:
        if 2 in a_list:
            yes = 1
    if 3 in a_list:
        if 6 in a_list:
            yes = 1
    if 4 in a_list:
        if 8 in a_list:
            yes = 1
if 1 in a_list:
    if 4 in a_list:
        if 7 in a_list:
            yes = 1
if 2 in a_list:
    if 4 in a_list:
        if 6 in a_list:
            yes = 1
    if 5 in a_list:
        if 8 in a_list:
            yes = 1
if 3 in a_list:
    if 4 in a_list:
        if 5 in a_list:
            yes = 1
if 6 in a_list:
    if 7 in a_list:
        if 8 in a_list:
            yes = 1
if yes == 1:
    print("Yes")
if yes == 0:
    print("No")

Fixed submission:
a = int(input())
if a%2==0:
    n = a/2
else:
    n = (a+1)/2
print(int(n))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
alist = list(map(int, input().split()))
blist = []
for i in range(1,N+1):
    blist.append(alist.index(i)+1)
print(' '.join(map(str, blist)))

Fixed submission:
N = int(input())
alist = list(map(int, input().split()))
blist = []
for i in range(N):
    blist.append([alist[i],i+1])
blist.sort()
for i in range(N):
    print(blist[i][1],end=" ")

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
alist = list(map(int, input().split()))
blist = []
for i in range(1,N+1):
    blist.append(alist.index(i)+1)
print(' '.join(map(str, blist)))

Fixed submission:
N = int(input())
alist = list(map(int, input().split()))
blist = []
for i in range(N):
    blist.append([alist[i],i+1])
blist.sort()
for i in range(N):
    print(blist[i][1],end=" ")
Buggy python submission (verdict: Time Limit Exceeded):
N,K,Q=map(int,input().split())
A = []
def minus(n):
    return n-1
for _ in range(Q):
    A.append(int(input()))#縦入力
Nlist = []
for i in range(N):
    Nlist.append(K)
for j in range(0,Q):
    Nlist = list(map(minus,Nlist))
    Nlist[A[j]-1] += 1
for k in range(0,N):
    if Nlist[k]>=1:
        print("Yes")
    else:
        print("No")

Fixed submission:
N,K,Q=map(int,input().split())
A = []
for _ in range(Q):
    A.append(int(input()))#縦入力
Nlist = []
for i in range(N):
    Nlist.append(K-Q)
for j in range(0,Q):
    Nlist[A[j]-1] += 1
for k in range(0,N):
    if Nlist[k]>=1:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Runtime Error):
a = input().split(" ")

x = [int(a[0]),int(a[1])]
y = [int(a[2]),int(a[3])]

ans = []

for i in x:
  for j in y:
    s = i*j
    
    ans.append(s)
ans.sort(reverse = True)  
print(ans[0])
    


Fixed submission:
n = int(input())

if n == 1:
  print(0)
elif n == 0:
  print(1)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,d = input().split(" ")
a = int(a)
b = int(b)
c = int(c)
d = int(d)

s = []

for x in range(a,b+1):
  for y in range(c,d+1):
    n = x*y
    s.append(n)

s.sort(reverse = True)
print(s[0])

Fixed submission:
a = input().split(" ")

x = [int(a[0]),int(a[1])]
y = [int(a[2]),int(a[3])]

ans = []

for i in x:
  for j in y:
    s = i*j
    
    ans.append(s)
ans.sort(reverse = True)  
print(ans[0])
Buggy python submission (verdict: Runtime Error):
d,t,s = input().split(" ")

if d <= int(t)*int(s):
  print("Yes")
else:
  print("No")

Fixed submission:
d,t,s = input().split(" ")

if int(d) <= int(t)*int(s):
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

s = input().split(" ")

ans = 0
for i in range(n):
  for j in range(int(i)+1,n):
    
    ans += int(s[i])*int(s[j])
    
print(ans%(10**9+7))

Fixed submission:
n = int(input())

s = input().split(" ")

sumup = 0
for i in s:
  sumup += int(i) 

ans = 0
for i in s:
  r = int(i)
  
  sumup -= r
  
  ans += r*sumup
    
print(ans%(10**9+7))
Buggy python submission (verdict: Runtime Error):
n,d = input()

count = 0
for i in range(n):
  x,y = input()
  
  r = (int(x)**2+int(y)**2)**(1/2)
  
  if r <= int(d):
    count += 1
print(count)

Fixed submission:
n,d = input().split(" ")

count = 0
for i in range(int(n)):
  x,y = input().split(" ")
  
  r = (int(x)**2+int(y)**2)**(1/2)
  
  if r <= int(d):
    count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
n = input()

s = abcdefghijklmnopqrstuvwxyz

if n in s:
  print("a")
else:
  print("A")

Fixed submission:
n = input()

s = "abcdefghijklmnopqrstuvwxyz"

if n in s:
  print("a")
else:
  print("A")
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int,input().split())
S=[]
NUM=998244353
for _ in range(K):
    l,r=map(int,input().split())
    for i in range(l,r+1):
        S.append(i)
S.sort()
dp=[0]*(N+1)
dp[1]=1
for i in range(2,N+1):
    for s in S:
        if i-s<=0: break
        dp[i]+=dp[i-s]
        dp[i]%=NUM

print(dp[N])


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

NUM=998244353
dp=[0]*(N+1)
dp[1]=1
sums=[0]*(N+1)
sums[1]=1
for i in range(2,N+1):
    for s in S:
        _l,_r=i-s[0],i-s[1]-1
        if _l<0:
            continue
        elif _r<0:
            _r=0
        dp[i]+=sums[_l]-sums[_r]
        dp[i]%=NUM
    sums[i]=dp[i]+sums[i-1]
    sums[i]%=NUM

print(dp[N])
Buggy python submission (verdict: Runtime Error):
ans=max(max(a*c,a*d),max(b*c,b*d))
print(ans)

Fixed submission:
a,b,c,d=map(int,input().split())
ans=0
if a>=0:
    if c>=0:
        ans=b*d
    elif d>=0:
        ans=b*d
    else:
        ans=a*d
elif b>=0:
    if c>=0:
        ans=b*d
    elif d>=0:
        ans=max(b*d,a*c)
    else:
        ans=a*c
else:
    if c>=0:
        ans=b*c
    elif d>=0:
        ans=a*c
    else:
        ans=a*c
print(ans)

Buggy python submission (verdict: Runtime Error):
ans=max(a*c,a*d,b*c,b*d)
print(ans)

Fixed submission:
a,b,c,d=map(int,input().split())
ans=0
if a>=0:
    if c>=0:
        ans=b*d
    elif d>=0:
        ans=b*d
    else:
        ans=a*d
elif b>=0:
    if c>=0:
        ans=b*d
    elif d>=0:
        ans=max(b*d,a*c)
    else:
        ans=a*c
else:
    if c>=0:
        ans=b*c
    elif d>=0:
        ans=a*c
    else:
        ans=a*c
print(ans)
Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
s=[list(map(int,input().split())) for _ in range(M)]

f=[[] for _ in range(N+1)]
for i in range(M):
    f[s[i][0]].append(s[i][1])

found=[0 for _ in range(N+1)]
ans=0

def find(bi,i,root,found):
    if root[i]:
        return
    root[i]=1
    found[i]=1
    f[i].append(bi)
    for j in range(len(f[i])):
        find(i,f[i][j],root,found)

for i in range(1,N+1):
    if found[i]: continue
    root=[0 for _ in range(N+1)]
    find(i,i,root,found)
    tmp=root.count(1)
    if ans<tmp:
        ans=tmp
print(ans)


Fixed submission:
from collections import deque

N,M=map(int,input().split())
G=[[] for _ in range(N)]
for _ in range(M):
    a,b=map(int,input().split())
    a-=1
    b-=1
    G[a].append(b)
    G[b].append(a)

group=[]
seen=[0]*N
ans=0
for i in range(N):
    if seen[i]: continue
    que=deque()
    seen[i]=1
    cnt=0
    que.append(i)
    while que:
        cnt+=1
        v=que.popleft()
        for nv in G[v]:
            if seen[nv]: continue
            seen[nv]=1
            que.append(nv)
    ans=max(ans,cnt)

print(ans)