Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
num = int(input())
prices = []

for i in range(num):
  prices[i].append(input())

max = prices[0]
for i in range(1,num):
  if prices[i]>max:
    max=prices[i]
    max_i = i

sum=0
for i in range(num):
  if i==max_i:
    sum = sum + int(prices[i]/2)
  else:
    sum = sum + prices[i]

Fixed submission:
num = int(input())
prices = []
 
for i in range(num):
  prices.append(int(input()))

max_i=0
max = prices[0]
for i in range(1,num):
  if prices[i]>max:
    max=prices[i]
    max_i = i
 
sum=0
for i in range(num):
  if i==max_i:
    sum += int(prices[i]/2)
  else:
    sum += prices[i]

print(sum)
Buggy python submission (verdict: Runtime Error):
N = int(input())
com = [0]
u = [i+1 for i in range(16)]
a = 0
v = 0
j = 0
str1 = "abcdefghijklmnopqrstuvwxyz"

if N < 27:
    print(str1[N-1])
else:
    for i in range(1,17):
        a += 26**i
        com.append(a)
    for i in range(17):
        if N < com[i]+1:
            v = com[i-1]
            j = i
            break
    N = N - v
    ans = []
    for i in range(j-1,-1,-1):
        if i == 0:
            ans.append(str1[N-1])
        else:
            ans.append(str1[N//(26**i)])
        if N >= 26**i:
            N -= N//(26**i) * 26**i

    print("".join(ans))

Fixed submission:
N = int(input())
com = [0]
a = 0
v = 0
j = 0
str1 = "abcdefghijklmnopqrstuvwxyz"

if N < 27:
    print(str1[N-1])
else:
    for i in range(1,13):
        a += 26**i
        com.append(a)
    for i in range(13):
        if N < com[i]+1:
            v = com[i-1]
            j = i
            break
    N = N - v - 1
    ans = []
    for i in range(j-1,-1,-1):
        ans.append(str1[N//(26**i)])
        if N >= 26**i:
            N = N - N//(26**i) * (26**i)

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

listp = [[0 for j in range(31)] for i in range(N)] 
li = [0]*31
for i in range(N):
    for j in range(30,-1,-1):
        if A[i] >= 2**j:
            listp[i][j] = 1
            A[i] -= 2**j
            li[j] = li[j]+1
            if li[j] > 2:
                li[j] = 1
for i in range(N):
    ans = 0
    for j in range(31):
        if li[j] - listp[i][j] == 1:
            ans += 2**j
    print(ans, end=" ")

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

s = 0
for i in range(N):
    s ^= A[i]
for i in range(N):
    ans = s^A[i]
    print(ans, end=" ")

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


listp = [[0 for j in range(31)] for i in range(N)] 
li = [0]*31
for i in range(N):
    for j in range(30,-1,-1):
        if A[i] >= 2**j:
            listp[i][j] = 1
            A[i] -= 2**j
            li[j] = li[j]+1
            if li[j] > 2:
                li[j] %= 2
for i in range(N):
    ans = 0
    for j in range(31):
        if li[j] - listp[i][j] %2 == 1:
            ans += 2**j
    print(ans, end=" ")

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

s = 0
for i in range(N):
    s ^= A[i]
for i in range(N):
    ans = s^A[i]
    print(ans, end=" ")
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
ans = 1
if 0 in A:
    print(0)
else:
    for i in range(N):
        ans = ans*A[i]
        if(ans > 10*:18):
            print(-1)
            break
        elif(i == N-1):
            print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = 1
if 0 in A:
    print(0)
else:
    for i in range(N):
        a = A[i]
        for j in range(19):
            if a <= 10**j:
                m = j
                break
        for k in range(19):
            if ans <= 10**k:
                n = k
                break
        if(m+n > 19):
            print(-1)
            break
        elif(ans*a == 10**18):
            ans = ans*a
        elif(ans*a > 10**18):
            print(-1)
            break
        else:
            ans = ans*a
        if i == N-1:
            print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
ans = 1
if 0 in A:
    print(0)
else:
    for i in range(N):
        a = A[i]
        for j in range(1,18):
            if a <= 10**j:
                m = j
                break
        for k in range(1,18):
            if ans <= 10**k:
                n = k
                break
        if(m+n > 18):
            print(-1)
            break
        elif(m+n == 18 and ans*a == 10**18):
            ans = ans*a
        elif(m+n == 18):
            print(-1)
            break
        else:
            ans = ans*a
        if i == N-1:
            print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans = 1
if 0 in A:
    print(0)
else:
    for i in range(N):
        a = A[i]
        for j in range(19):
            if a <= 10**j:
                m = j
                break
        for k in range(19):
            if ans <= 10**k:
                n = k
                break
        if(m+n > 19):
            print(-1)
            break
        elif(ans*a == 10**18):
            ans = ans*a
        elif(ans*a > 10**18):
            print(-1)
            break
        else:
            ans = ans*a
        if i == N-1:
            print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
ans = 0

for i in range(N-2):
    j = i + 1
    while j <= N-1:
        if A[j] + A[i] == j - i:
            ans += 1
        else:
        	pass
        j += 1
print(ans)

Fixed submission:
N = int(input())
dic = {}
ans = 0
A = list(map(int, input().split()))
for i in range(N):
    dic[i] = 0

for i in range(N):
    b = A[i]+N-i-1
    if A[i] < N-i:
        a = N-i-A[i]-1
        dic[a] += 1
    if b < N:
        ans += dic[b]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
ans = 0
listmod = [0]*2019
for i in range(1,len(S)+1):
    if(i == 1):
        T = int(S[-1])
        listmod[T] = 1
        mod2 = T
    else:
        T = int(S[-i])
        mod1 = (T*10**(i-1)%2019 + mod2)%2019
        listmod[mod1] += 1
        mod2 = mod1
for i in range(2019):
    if(i == 0):
        ans += listmod[0]
    else:
        n = listmod[i]
        ans += int((n-1)*n/2)
print(ans)

Fixed submission:
S = input()
ans = 0
nd = 1
mod1 = 0
listmod = [0]*2019
for i in S[::-1]:
    mod1 = (int(i)*nd + mod1)%2019
    listmod[mod1] += 1
    nd = (nd*10)%2019
for i in range(2019):
    n = listmod[i]
    if(i == 0):
        if(n == 1):
            ans += 1
        elif(n >= 2):
            ans += ((n+1)*n)//2
    else:
        if(n > 1):
            ans += ((n-1)*n)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
ans = 0
listmod = [0]*2019
for i in range(1,len(S)+1):
    T = int(S[-i:])
    modT = T%2019
    listmod[modT] += 1
for i in range(2019):
    if(i == 0):
        ans += listmod[0]
    else:
        if(listmod[i] > 1):
            ans += listmod[i] - 1
print(ans)

Fixed submission:
S = input()
ans = 0
nd = 1
mod1 = 0
listmod = [0]*2019
for i in S[::-1]:
    mod1 = (int(i)*nd + mod1)%2019
    listmod[mod1] += 1
    nd = (nd*10)%2019
for i in range(2019):
    n = listmod[i]
    if(i == 0):
        if(n == 1):
            ans += 1
        elif(n >= 2):
            ans += ((n+1)*n)//2
    else:
        if(n > 1):
            ans += ((n-1)*n)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
X, Y, A, B, C = map(int, input().split())
P = sorted(list(map(int, input().split())), reverse=True)
Q = sorted(list(map(int, input().split())), reverse=True)
R = sorted(list(map(int, input().split())), reverse=True)

red = sorted(P[:X])
gre = sorted(Q[:Y])
ans = sum(red) + sum(gre) 
j, k = 0, 0

for i in range(min(X+Y,C)):
    if(red[j] <= gre[k]):
        if R[i] > red[j] :
            ans = ans - red[j] + R[i]
            j += 1
        else:
            break
    else:
        if R[i] > gre[k] :
            ans = ans - gre[k] + R[i]
            k += 1
        else:
            break
print(ans)

Fixed submission:
X, Y, A, B, C = map(int, input().split())
P = sorted(list(map(int, input().split())), reverse=True)
Q = sorted(list(map(int, input().split())), reverse=True)
R = sorted(list(map(int, input().split())), reverse=True)

red = sorted(P[:X])
gre = sorted(Q[:Y])
m = min((X+Y),C)
n = R[:m]
red.extend(gre)
red.extend(n)
red = sorted(red, reverse=True)

print(sum(red[:X+Y]))

Buggy python submission (verdict: Runtime Error):
X, Y, A, B, C = map(int, input().split())
P = sorted(list(map(int, input().split())), reverse=True)
Q = sorted(list(map(int, input().split())), reverse=True)
R = sorted(list(map(int, input().split())), reverse=True)

red = sorted(P[:X])
gre = sorted(Q[:Y])
ans = sum(red) + sum(gre) 
j, k = 0, 0

for i in range(min(X+Y),C):
    if(red[j] <= gre[k]):
        if R[i] > red[j] :
            ans = ans - red[j] + R[i]
            j += 1
        else:
            break
    else:
        if R[i] > gre[k] :
            ans = ans - gre[k] + R[i]
            k += 1
        else:
            break
print(ans)

Fixed submission:
X, Y, A, B, C = map(int, input().split())
P = sorted(list(map(int, input().split())), reverse=True)
Q = sorted(list(map(int, input().split())), reverse=True)
R = sorted(list(map(int, input().split())), reverse=True)

red = sorted(P[:X])
gre = sorted(Q[:Y])
m = min((X+Y),C)
n = R[:m]
red.extend(gre)
red.extend(n)
red = sorted(red, reverse=True)

print(sum(red[:X+Y]))

Buggy python submission (verdict: Runtime Error):
X, Y, A, B, C = map(int, input().split())
P = sorted(list(map(int, input().split())), reverse=True)
Q = sorted(list(map(int, input().split())), reverse=True)
R = sorted(list(map(int, input().split())), reverse=True)

red = sorted(P[:X])
gre = sorted(Q[:Y])
ans = sum(red) + sum(gre) 
j, k = 0, 0

for i in range(X+Y):
    if(red[j] <= gre[k]):
        if R[i] > red[j] :
            ans = ans - red[j] + R[i]
            j += 1
        else:
            break
    else:
        if R[i] > gre[k] :
            ans = ans - gre[k] + R[i]
            k += 1
        else:
            break
print(ans)

Fixed submission:
X, Y, A, B, C = map(int, input().split())
P = sorted(list(map(int, input().split())), reverse=True)
Q = sorted(list(map(int, input().split())), reverse=True)
R = sorted(list(map(int, input().split())), reverse=True)

red = sorted(P[:X])
gre = sorted(Q[:Y])
m = min((X+Y),C)
n = R[:m]
red.extend(gre)
red.extend(n)
red = sorted(red, reverse=True)

print(sum(red[:X+Y]))
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = [0]
D = [0]

for i in range(N):
    s = B[i] - A[i]
    if(s > 0):
        C.append(s)
    elif(s < 0):
        D.append(s)

D = sorted(D)

csum = sum(C)
dsum = sum(D)

if(csum + dsum > 0):
    print(-1)
elif(csum == 0):
    print(0)
else:
    ans = len(C)
    for i in D:
        csum += D
        ans += 1
        if(csum <= 0):
            break
    print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = [0]
D = [0]

for i in range(N):
    s = B[i] - A[i]
    if(s > 0):
        C.append(s)
    elif(s < 0):
        D.append(s)

D = sorted(D)

csum = sum(C)
dsum = sum(D)

if(csum + dsum > 0):
    print(-1)
elif(csum == 0):
    print(0)
else:
    ans = len(C) -1
    for i in D:
        csum += i
        ans += 1
        if(csum <= 0):
            break
    print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = []
D = []

for i in range(N):
    s = B[i] - A[i]
    if(s > 0):
        C.append(s)
    elif(s < 0):
        D.append(s)

D = sorted(D)

csum = sum(C)
dsum = sum(D)

if(csum + dsum > 0):
    print(-1)
elif(csum == 0):
    print(0)
else:
    ans = len(C)
    for i in D:
        csum += D
        ans += 1
        if(csum <= 0):
            break
    print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = [0]
D = [0]

for i in range(N):
    s = B[i] - A[i]
    if(s > 0):
        C.append(s)
    elif(s < 0):
        D.append(s)

D = sorted(D)

csum = sum(C)
dsum = sum(D)

if(csum + dsum > 0):
    print(-1)
elif(csum == 0):
    print(0)
else:
    ans = len(C) -1
    for i in D:
        csum += i
        ans += 1
        if(csum <= 0):
            break
    print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
l = [list(map(int, input().split())) for i in range(N)]
l.sort(key=lambda x: x[2], reverse=True)

for i in range(101):
    for j in range(101):
        h = l[0][2] + abs(i - l[0][0]) + abs(j - l[0][1])
        for k in range(N):
            tmp = l[k][2] + abs(i - l[k][0]) + abs(j - l[k][1])
            if tmp != h:
                break
            elif k == N-1:
                X = i
                Y = j
                H = h
print(X,Y,H)

Fixed submission:
N = int(input())
l = [list(map(int, input().split())) for i in range(N)]
l.sort(key=lambda x: x[2], reverse=True)

for i in range(101):
    for j in range(101):
        h = l[0][2] + abs(i - l[0][0]) + abs(j - l[0][1])
        for k in range(N):
            tmp = max(h - abs(i - l[k][0]) - abs(j - l[k][1]), 0)
            if tmp != l[k][2]:
                break
            elif k == N-1:
                X = i
                Y = j
                H = h
print(X,Y,H)
Buggy python submission (verdict: Runtime Error):
lst = map(int, input().split())
x_lst = []
y_lst = []
max_lst = []
for i in range(2):
  x_lst.append(lst[i])
  y_lst.append(lst[(i+1)*-1])
for j in range(len(x_lst)):
  for k in range(len(y_lst)):
    max_lst.append(x_lst[j] * y_lst[k])
print(max(max_lst))


Fixed submission:
lst = list(map(int, input().split()))
x_lst = []
y_lst = []
max_lst = []
for i in range(2):
  x_lst.append(lst[i])
  y_lst.append(lst[(i+1)*-1])
for j in range(len(x_lst)):
  for k in range(len(y_lst)):
    max_lst.append(x_lst[j] * y_lst[k])
print(max(max_lst))

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
x_lst = [a, b]
y_lst = [c,d]
max_lst = []
for i in range(len(x_lst)):
  for j in range(len(y_lst)):
    max_lst.append(x_lst[i] * y_lst[j])
print(max(max_lst))

Fixed submission:
lst = list(map(int, input().split()))
x_lst = []
y_lst = []
max_lst = []
for i in range(2):
  x_lst.append(lst[i])
  y_lst.append(lst[(i+1)*-1])
for j in range(len(x_lst)):
  for k in range(len(y_lst)):
    max_lst.append(x_lst[j] * y_lst[k])
print(max(max_lst))

Buggy python submission (verdict: Runtime Error):
lst = []
x_lst = []
y_lst = []
max_lst = []
lst.append(input())
for x in range(2):
    x_lst.append(int(lst[x]))
    y_lst.append(int(lst[(x+1) * -1])
for i in range(len(x_lst)):
    for j in range(len(y_lst)):
        max_lst.append(x_lst[i] * y_lst[j])
print(max(max_lst))
        

Fixed submission:
lst = list(map(int, input().split()))
x_lst = []
y_lst = []
max_lst = []
for i in range(2):
  x_lst.append(lst[i])
  y_lst.append(lst[(i+1)*-1])
for j in range(len(x_lst)):
  for k in range(len(y_lst)):
    max_lst.append(x_lst[j] * y_lst[k])
print(max(max_lst))

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
x_lst = [a, b]
y_lst = [c, d]
max_lst = []
for i in range(len(x_lst)):
    for j in range(len(y_lst)):
        max_lst.append(x_lst[i] * y_lst[j])
print(max(max_lst))

Fixed submission:
lst = list(map(int, input().split()))
x_lst = []
y_lst = []
max_lst = []
for i in range(2):
  x_lst.append(lst[i])
  y_lst.append(lst[(i+1)*-1])
for j in range(len(x_lst)):
  for k in range(len(y_lst)):
    max_lst.append(x_lst[j] * y_lst[k])
print(max(max_lst))

Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
x_lst = [a, b]
y_lst = [c, d]
max_lst = []
for i in range(len(x_lst)):
    for j in range(len(y_lst)):
        max_lst.append(x_lst[i] * y_lst[j])
print(max(max_lst))

Fixed submission:
lst = list(map(int, input().split()))
x_lst = []
y_lst = []
max_lst = []
for i in range(2):
  x_lst.append(lst[i])
  y_lst.append(lst[(i+1)*-1])
for j in range(len(x_lst)):
  for k in range(len(y_lst)):
    max_lst.append(x_lst[j] * y_lst[k])
print(max(max_lst))
Buggy python submission (verdict: Runtime Error):
def solve(shoki):
    global n,k,p,c
    sude=[-1]*n
    sude[shoki]=0
    ten=[0]
    now=shoki
    ishuu_kai=0
    ishuu_ten=0
    for i in range(n):
        now=p[now]
        if(sude[now]<0):
            sude[now]=i+1
            ten.append(ten[-1]+c[now])
        else:
            ten.append(ten[-1]+c[now])
            ishuu_kai=i+1-sude[now]
            ishuu_ten=ten[-1]-ten[sude[now]]
            break
    if(ishuu_ten>0):
        now=shoki
        for i in range(ishuu_kai):
            ten[i]+=((k-i)//ishuu_kai)*ishuu_ten
            now=p[now]
    if(k>ishuu_kai):
        return max(ten[1:])
    else:
        return max(ten[1:k])
n,k=map(int,input().split())
p=list(map(int,input().split()))
c=list(map(int,input().split()))

for i in range(n):
    p[i]-=1


ans=[]
for i in range(n):
    ans.append(solve(i))

print(max(ans))

Fixed submission:
def solve(shoki):
    global n,k,p,c
    sude=[-1]*n
    sude[shoki]=0
    ten=[0]
    now=shoki
    ishuu_kai=0
    ishuu_ten=0
    for i in range(n):
        now=p[now]
        if(sude[now]<0):
            sude[now]=i+1
            ten.append(ten[-1]+c[now])
        else:
            ten.append(ten[-1]+c[now])
            ishuu_kai=i+1-sude[now]
            ishuu_ten=ten[-1]-ten[sude[now]]
            break
    #print(shoki)
    #print(ten,ishuu_kai,ishuu_ten)
    if(ishuu_ten>0):
        now=shoki
        for i in range(ishuu_kai):
            ten[i]+=((k-i)//ishuu_kai)*ishuu_ten
            now=p[now]

    #print(ten,ishuu_kai,ishuu_ten)
    if(k>ishuu_kai):
        return max(ten)
    else:
        return max(ten[1:k+1])


n,k=map(int,input().split())
p=list(map(int,input().split()))
c=list(map(int,input().split()))

for i in range(n):
    p[i]-=1


ans=[]
for i in range(n):
    ans.append(solve(i))

print(max(ans))
Buggy python submission (verdict: Runtime Error):
n=int(input())
data=[[0]*30 for i in range(30)]

for i in range(n):
    s=input()
    l=len(s)
    num=0
    sho=0
    keta=1
    for i in range(l):
        if(s[l-i-1]!='.'):
            num+=keta*int(s[l-i-1])
            keta*=10
        else:
            sho=i
    #print(num,sho)
    two=-sho
    five=-sho
    for i in range(100):
        if(num%2==0):
            two+=1
            num//=2
        else:
            break
    for i in range(100):
        if(num%5==0):
            five+=1
            num//=5
        else:
            break
    #print(two,five)
    data[two+9][five+9]+=1


ans=0
for i in range(30):
    for j in range(30):
        jibun=data[i][j]
        if(jibun==0):
            continue
        aite=0
        for p in range(max(0,18-i),30):
            for q in range(max(0,18-j),30):
                aite+=data[p][q]
                if(p==i and j==q):
                    aite-=1
        ans+=jibun*aite
        #print(i-9,j-9,jibun,aite)

print(ans//2)

Fixed submission:
n=int(input())
data=[[0]*50 for i in range(50)]

for i in range(n):
    s=input()
    l=len(s)
    num=0
    sho=0
    keta=1
    for i in range(l):
        if(s[l-i-1]!='.'):
            num+=keta*int(s[l-i-1])
            keta*=10
        else:
            sho=i
    #print(num,sho)
    two=-sho
    five=-sho
    for i in range(100):
        if(num%2==0):
            two+=1
            num//=2
        else:
            break
    for i in range(100):
        if(num%5==0):
            five+=1
            num//=5
        else:
            break
    #print(two,five)
    data[two+9][five+9]+=1


ans=0
for i in range(50):
    for j in range(50):
        jibun=data[i][j]
        if(jibun==0):
            continue
        aite=0
        for p in range(max(0,18-i),50):
            for q in range(max(0,18-j),50):
                aite+=data[p][q]
                if(p==i and j==q):
                    aite-=1
        ans+=jibun*aite
        #print(i-9,j-9,jibun,aite)

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



sho=1
dai=max(a)
for jfdlas in range(100):
    now=(sho+dai)//2
    gokei=0
    for i in range(n):
        gokei+=(a[i]-1)//now
        #print(gokei)
    if(gokei<=k):
        dai=now
    else:
        sho=now
    #print(now,gokei,sho,dai)


print(dai)
#gokei=0
#for i in range(n):
#    gokei+=(a[i]-1)//
#if(gokei>k):
#    print(sho)
#else:
#    print(dai)

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



sho=1
dai=max(a)
for jfdlas in range(100):
    now=(sho+dai)//2
    gokei=0
    for i in range(n):
        gokei+=(a[i]-1)//now
        #print(gokei)
        if(gokei>k):
            sho=now
            continue
    if(gokei<=k):
        dai=now
    else:
        sho=now
    #print(now,gokei,sho,dai)


print(dai)
#gokei=0
#for i in range(n):
#    gokei+=(a[i]-1)//
#if(gokei>k):
#    print(sho)
#else:
#    print(dai)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,c,d=map(int,input().split())
p=998244353
n=c-a+2
m=d-b+2
data=[[0]*(m)for i in range(n)]

data[1][1]=1

#print(data)

for i in range(1,n):
    gyou=a+i-1
    for j in range(1,m):
        retu=b+j-1
        if(i*j==1):
            continue
        data[i][j]=data[i-1][j]*retu+data[i][j-1]*gyou-data[i-1][j-1]*(gyou-1)*(retu-1)%p
        #print(gyou,retu,i,j,data[i][j])
#print(data)
print(data[n-1][m-1]%p)

Fixed submission:
a,b,c,d=map(int,input().split())
p=998244353
n=c-a+2
m=d-b+2
data=[[0]*(m)for i in range(n)]

data[1][1]=1

#print(data)

for i in range(1,n):
    gyou=a+i-1
    for j in range(1,m):
        retu=b+j-1
        if(i*j==1):
            continue
        data[i][j]=(data[i-1][j]*retu%p)+(data[i][j-1]*gyou%p)-((data[i-1][j-1]*(gyou-1)%p)*(retu-1)%p)
        data[i][j]=data[i][j]%p
        #print(gyou,retu,i,j,data[i][j])
#print(data)
print(data[n-1][m-1]%p)
Buggy python submission (verdict: Time Limit Exceeded):
n,s=map(int,input().split())
a=list(map(int,input().split()))
p=998244353

data=[[0]*(s+1) for i in range(n)]

gen=data[0]
gen[0]=2
if(a[0]<=s):
    gen[a[0]]+=1

for i in range(1,n):
    gen=data[i]
    mae=data[i-1]
    for j in range(s+1):
        gen[j]=mae[j]*2
        if(j-a[i]>=0 and j-a[i]<=s):
            gen[j]+=mae[j-a[i]]
        gen[j]%=p

print(data[-1][-1])

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

data=[[0]*(s+1) for i in range(n)]

gen=data[0]
gen[0]=2
if(a[0]<=s):
    gen[a[0]]+=1

for i in range(1,n):
    gen=data[i]
    mae=data[i-1]
    for j in range(s+1):
        gen[j]=mae[j]*2
        if(j-a[i]>=0 and j-a[i]<=s):
            gen[j]+=mae[j-a[i]]
        gen[j]%=p

print(data[-1][-1])
Buggy python submission (verdict: Runtime Error):
def check(num,k):
    if(num<k):
        return num==1
    if(num % k==0):
        return check(num//k,k)
    else:
        return check(num%k,k)

n=int(input())

yakusu=[[],[]]
for i in range(2):
    kazu=n-i
    for j in range(1,kazu+1):
        if(j*j>kazu):
            break
        if(kazu%j==0):
            if(j!=1):
                yakusu[i].append(j)
            yakusu[i].append(kazu//j)
    yakusu[i].sort()

#for i in range(2):
#    print(yakusu[i])


ans=[]

for i in range(2):
    for y in yakusu[i]:
        if(check(n,y)):
            ans.append(y)

ans.sort()
#print(ans)
print(len(ans))


Fixed submission:
def check(num,k):
    if(num<k):
        return num==1
    if(num % k==0):
        return check(num//k,k)
    else:
        return check(num%k,k)

n=int(input())

yakusu=[[],[]]
for i in range(2):
    kazu=n-i
    for j in range(1,kazu+1):
        if(j*j>kazu):
            break
        if(kazu%j==0):
            if(j!=1):
                yakusu[i].append(j)
            if(j*j!=kazu):
                yakusu[i].append(kazu//j)
    yakusu[i].sort()

#for i in range(2):
#    print(yakusu[i])


ans=[]

for i in range(2):
    for y in yakusu[i]:
        if(check(n,y)):
            ans.append(y)

ans.sort()
#print(ans)
print(len(ans))