ZhenlongDai/ACPR huggingface dataset:
Problem: p03221
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M=map(int,input().split())
PY=[list(map(int,input().split())) for _ in range(M)]
PY.sort(key=lambda x:x[1])
flag=[1]*N
ans=[]
for P,Y in PY:
  ans.append(str(P).zfill(6)+str(flag[P-1]).zfill(6))
  flag[P-1]+=1
  
ans.sort
for a in ans:
  print(a)

Failing test case input:
4 3
2 5
4 49
1 12

Expected output:
000002000001
000004000001
000001000001


Actual output:
000002000001
000001000001
000004000001


Fixed submission (verdict: Accepted):
N,M=map(int,input().split())
PY=[list(map(int,input().split())) for _ in range(M)]
idx=sorted(range(M),key=lambda x:PY[x][1])
PY.sort(key=lambda x:x[1])
flag=[1]*N
keep=[]
for P,Y in PY:
  keep.append(str(P).zfill(6)+str(flag[P-1]).zfill(6))
  flag[P-1]+=1
  
ans=[0]*M
for i,k in zip(idx,keep):
  ans[i]=k
  
for a in ans:
  print(a)

Problem: p03221
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m = map(int,input().split())
py = [list(map(int,input().split())) +[i] for i in range(m)]
py.sort(key=lambda x: [x[0], x[1]])
ans_list = [0]*m
tmp = py[0][0]
cnt = 0
for p,y,idx in py:
    if tmp == p:
        cnt +=1
    else:
        cnt = 1
    ans_list[idx] = format(p ,'06') + format(cnt, '06')

for ans in ans_list:
  print(ans)

Failing test case input:
2 3
2 26
2 59
1 359

Expected output:
000002000001
000002000002
000001000001


Actual output:
000002000001
000002000001
000001000001


Fixed submission (verdict: Accepted):
n,m = map(int,input().split())
py = [list(map(int,input().split())) +[i] for i in range(m)]
py.sort(key=lambda x: [x[0], x[1]])
ans_list = [0]*m
tmp = py[0][0]
cnt = 0
for p,y,idx in py:
    if tmp == p:
        cnt +=1
    else:
        cnt = 1
        tmp = p
    ans_list[idx] = format(p ,'06') + format(cnt, '06')

for ans in ans_list:
  print(ans)

Problem: p03221
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,M=[int(i) for i in input().split()]
PY=[[] for _ in range(N)]

for i in range(M):
    p,y=[int(i) for i in input().split()]
    PY[p-1].append((y,i))

ans=[None]*M
for j,py in enumerate(PY): 
    py.sort()
    for k,(y,i) in enumerate(py):
        print(k,y,i) 
        ans[i]=str(j+1).zfill(6) + str(k+1).zfill(6)

print(*ans,sep="\n")

Failing test case input:
2 3
2 37
2 59
1 195

Expected output:
000002000001
000002000002
000001000001


Actual output:
0 195 2
0 37 0
1 59 1
000002000001
000002000002
000001000001


Fixed submission (verdict: Accepted):
N,M=[int(i) for i in input().split()]
PY=[[] for _ in range(N)]
py=[]

for i in range(M):
    p,y=[int(i) for i in input().split()]
    PY[p-1].append((y,i))

ans=[None]*M
for j,py in enumerate(PY): 
    py.sort()
    for k,(y,i) in enumerate(py):
        ans[i]=str(j+1).zfill(6) + str(k+1).zfill(6)

print(*ans,sep="\n")
Problem: p03221
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n, m = map(int, input().split())
py = sorted([[i] + list(input().split()) for i in range(m)], key=lambda x: (x[1], x[2]))

x = sorted(py)[0][1]
a = 1
ans = []
for i, p, y in py:
    if x != int(p):
        x = int(p)
        a = 1
    
    ans.append([i, p.zfill(6)+str(a).zfill(6)])
    a += 1

for i, v in sorted(ans):
    print(v)

Failing test case input:
2 3
1 32
2 63
1 4

Expected output:
000001000002
000002000001
000001000001


Actual output:
000001000001
000002000001
000001000002


Fixed submission (verdict: Accepted):
n, m = map(int, input().split())
py = sorted([[i] + list(input().split()) for i in range(m)], key=lambda x: (int(x[1]), int(x[2])))

x = 1
a = 1
ans = []
for i, p, y in py:
    if x != int(p):
        x = int(p)
        a = 1
    
    ans.append([i, p.zfill(6)+str(a).zfill(6)])
    a += 1

for i, v in sorted(ans):
    print(v)

Problem: p03221
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect
from collections import defaultdict
n,m = map(int,input().split())
p = [list(map(int, input().split())) for _ in range(m)]

a = defaultdict(list)
for x,y in sorted(p):
    a[x].append(y)
for x,y in p:
    z=bisect.bisect(a[x],y)
    print("{0:06d}{0:06d}".format(x,z))

Failing test case input:
3 3
2 26
2 77
1 131

Expected output:
000002000001
000002000002
000001000001


Actual output:
000002000002
000002000002
000001000001


Fixed submission (verdict: Accepted):
import bisect
from collections import defaultdict
n,m = map(int,input().split())
p = [list(map(int, input().split())) for _ in range(m)]
 
a = defaultdict(list)
for x,y in sorted(p):
    a[x].append(y)
for x,y in p:
    
    z=bisect.bisect(a[x],y)
    print("{0:06d}{1:06d}".format(x,z))

Problem: p03221
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import defaultdict
N, M = map(int, input().split())
PY = [list(map(int, input().split())) for i in range(M)]
PY.sort(key=lambda x: x[1])
pydict = defaultdict(lambda: 0)

for i in PY:
    pydict[i[0]] += 1
    print("{:0=6}".format(i[0]) + "{:0=6}".format(pydict.get(i[0])))

Failing test case input:
4 3
2 5
4 49
1 12

Expected output:
000002000001
000004000001
000001000001


Actual output:
000002000001
000001000001
000004000001


Fixed submission (verdict: Accepted):
from collections import defaultdict
N, M = map(int, input().split())
py = [list(map(int, input().split())) for i in range(M)]
PY = sorted(py, key=lambda x: x[1])
pydict = defaultdict(lambda: 0)
ans = {}
for i in PY:
    pydict[i[0]] += 1
    ans[str(i[0]) + str(i[1])] = "{:0=6}".format(i[0]) + "{:0=6}".format(pydict.get(i[0]))

for i in py:
    print(ans.get(str(i[0]) + str(i[1])))
Problem: p03221
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m=map(int, input().split())
pl=[0]*m
yl=[0]*m
cl=[0]*m
ppl=[[] for j in range(n+1)]
for i in range(m):
    pl[i],yl[i] = map(int, input().split())
    ppl[pl[i]].append((yl[i], i))

for i in range(m):
    print("%06d%06d" % (pl[i], cl[i]))

Failing test case input:
2 3
2 26
2 59
1 139

Expected output:
000002000001
000002000002
000001000001


Actual output:
000002000000
000002000000
000001000000


Fixed submission (verdict: Accepted):
import bisect
n,m=map(int, input().split())
pl=[0]*100000
yl=[0]*100000
ol=[[] for i in range(100001)]
for i in range(m):
    pl[i],yl[i] = map(int, input().split())
    ol[pl[i]].append(yl[i])
for i in range(1,n+1):
    ol[i].sort()
for i in range(m):
    print("%06d%06d" % (pl[i], bisect.bisect_right(ol[pl[i]], yl[i])))

Problem: p03221
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,m=list(map(int,input().split()))
city=[]
for i in range(m):
    city.append(list(map(int,input().split()))+[i])
city.sort()
ans=[]
count=0
precity=city[0][0]
for i in city:
    if i[0]==precity:
        count+=1
    else:
        count=1
    ans.append([i[2],str(i[0]).zfill(6)+str(count).zfill(6)])
ans.sort()
for i in ans:
    print(i[1])

Failing test case input:
2 3
1 16
2 77
2 195

Expected output:
000001000001
000002000001
000002000002


Actual output:
000001000001
000002000001
000002000001


Fixed submission (verdict: Accepted):
n,m=list(map(int,input().split()))
city=[]
for i in range(m):
    city.append(list(map(int,input().split()))+[i])
city.sort()
ans=[]
count=0
precity=city[0][0]
for i in city:
    if i[0]==precity:
        count+=1
    else:
        precity=i[0]
        count=1
    ans.append([i[2],str(i[0]).zfill(6)+str(count).zfill(6)])
ans.sort()
for i in ans:
    print(i[1])

Problem: p03221
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import defaultdict
import bisect
N, M = map(int, input().split())
P = [[int(i) for i in input().split()] for _ in range(M)]
D = defaultdict(list)

for p, y in sorted(P):
  D[p] += [y]
  
for p, y in sorted(P):
  z = D[p].index(y)
  print ("%06d%06d"%(p, z+1))


Failing test case input:
2 3
1 32
2 63
1 6

Expected output:
000001000002
000002000001
000001000001


Actual output:
000001000001
000001000002
000002000001


Fixed submission (verdict: Accepted):
from collections import defaultdict
import bisect
N, M = map(int, input().split())
P = [[int(i) for i in input().split()] for _ in range(M)]
D = defaultdict(list)

for p, y in sorted(P):
  D[p] += [y]
  
for p, y in P:
  z = bisect.bisect(D[p], y)
  print ("%06d%06d"%(p, z))
Problem: p03221
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N,M=map(int,input().split())
li=[input().split() for i in range(M)]
li=sorted(li, key=lambda x:(x[0],x[1]))
prev=li[0][0]
counter=0

for j in li:
    if prev==j[0]:
        counter+=1
    else:
        counter=1
    y=str(counter)
    ID=('0'*(6-len(j[0])))+j[0]+('0'*(6-len(y)))+y
    print(ID)

Failing test case input:
2 3
1 32
2 63
1 12

Expected output:
000001000002
000002000001
000001000001

Actual output:
000001000001
000001000002
000002000001


Fixed submission (verdict: Accepted):
N,M=map(int,input().split())
li=[[list(map(int,input().split())),i] for i in range(M)]
li=sorted(li, key=lambda x:x[0][1])
counter=[0]*N
li_id=[]

for j in li:
    counter[int(j[0][0])-1]+=1
    x=str(j[0][0])
    y=str(counter[int(j[0][0])-1])
    ID=('0'*(6-len(x)))+x+('0'*(6-len(y)))+y
    li_id.append([j[1],ID])
li_id=sorted(li_id)
for k in li_id:
    print(k[1])
Problem: p02685
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n,m,k=map(int,input().split())
ans=0
mod=998244353
c=1
for i in range(k+1):
    ans+=c*m*pow(m-1,n-i-1,mod)
    ans%=mod
    c*=max(1,n-i-1)
print(ans)

Failing test case input:
145188 7606 4452

Expected output:
534415352


Actual output:
827127815


Fixed submission (verdict: Accepted):
n,m,k=map(int,input().split())
ans=0
mod=998244353
c=1
for i in range(k+1):
    ans+=c*m*pow(m-1,n-i-1,mod)
    ans%=mod
    c*=(n-i-1)*pow(i+1,mod-2,mod)
    c%=mod
print(ans)

Problem: p02685
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

import math



def main():
    (N, M, K) = map(int, input().split())
    MOD = 998244353
    
    fact = [1]*(N+1)
    factinv = [1]*(N+1)
    for i in range(1,K+1):
        fact[i] = fact[i-1]*i % MOD
        factinv[i] = pow(fact[i], MOD-2, MOD)
    def comb(n, k):
        return fact[n] * factinv[k] * factinv[n-k] % MOD

    ans = 0
    for k in range(K+1):
        ans += (comb(N-1,k)*M*pow(M-1, N-k-1, MOD))%MOD

    print(ans%MOD)

main()


Failing test case input:
244911 114575 3371

Expected output:
846291996


Actual output:
449073829


Fixed submission (verdict: Accepted):

import math



def main():
    (N, M, K) = map(int, input().split())
    MOD = 998244353
    
    fact = [1]*(N+1)
    factinv = [1]*(N+1)
    for i in range(1,N+1):
        fact[i] = fact[i-1]*i % MOD
        factinv[i] = pow(fact[i], MOD-2, MOD)
    def comb(n, k):
        return fact[n] * factinv[k] * factinv[n-k] % MOD

    ans = 0
    for k in range(K+1):
        ans += (comb(N-1,k)*M*pow(M-1, N-k-1, MOD))%MOD

    print(ans%MOD)

main()

Problem: p02685
Buggy submission (Python (3.8.2), verdict: Wrong Answer):



def main():
  MAX = 998244353
  n, m, k = map(int, input().split())
  
  
  ncp = m * pow(m-1, n-1, MAX)
  divmm1 = pow(m-1, MAX-2, MAX)
  cnt = ncp
  cmb = 1
  for ik in range(1, k+1):
    ncp *= divmm1
    ncp %= MAX
    
    cmb *= ((n-ik) * pow(ik, MAX-2, MAX))
    cmb %= MAX
    
    cnt += ncp * cmb
    cnt %= MAX
    
  print(cnt % MAX)

if __name__=='__main__':
  main()


Failing test case input:
100 010 -1

Expected output:
0


Actual output:
113759282


Fixed submission (verdict: Accepted):



def main():
  MAX = 998244353
  n, m, k = map(int, input().split())
    
  cnt = 0
  cmb = 1
  for ik in range(k+1):
    ncp = m * pow(m-1, n-ik-1, MAX)
    ncp %= MAX
    
    if ik == 0:
      cmb = 1
    else:
      cmb *= ((n-ik) * pow(ik, MAX-2, MAX))
    cmb %= MAX
    
    cnt += ncp * cmb
    cnt %= MAX
    
  print(cnt % MAX)

if __name__=='__main__':
  main()
Problem: p02685
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
mod = 998244353

n, m, k = map(int, input().split())
count = 0

comb = 1
for i in range(k + 1):
  tmp = comb * m * pow(m-1, n-i-1, mod) % mod
  count = (count + tmp) % mod
  comb = comb * (n - i) * pow(i+1, mod-2, mod) % mod
print(count)

Failing test case input:
5 8 3

Expected output:
32760


Actual output:
37408


Fixed submission (verdict: Accepted):
mod = 998244353

n, m, k = map(int, input().split())
count = 0

comb = 1
for i in range(k + 1):
  tmp = comb * m * pow(m-1, n-i-1, mod) % mod
  count = (count + tmp) % mod
  comb = comb * (n - i - 1) * pow(i+1, mod-2, mod) % mod
print(count)

Problem: p02685
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
M = 998244353
n,m,K = map(int,input().split())
ans = 0
c = 1
for k in range(K+1):
    ans += c * m * pow(m-1,n-k-1,M)
    c *= (n-k+1) * pow(k+1,M-2,M)
    ans %= M
    c %= M
print(ans)
    


Failing test case input:
244911 128436 2794

Expected output:
325464666


Actual output:
609500107


Fixed submission (verdict: Accepted):
M = 998244353
n,m,K = map(int,input().split())
ans = 0
c = 1
for k in range(K+1):
    ans += c * m * pow(m-1,n-k-1,M)
    c *= (n-k-1) * pow(k+1,M-2,M)
    ans %= M
    c %= M
print(ans)

Problem: p02685
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

N, M, K = map(int, input().split())
MOD = 998244353
if M > N:
  M = N

if M == 1:
  print("1")
  quit()
  

B = [1] * N
ans1 = 1
for i in range(1, N):
  ans1 = (ans1 * (M - 1)) % MOD
  B[i] = ans1
  
ans = 0
ans2 = 1

for i in range(K + 1):
  if i == 0:
    X = 1
  else:
    X = int(X * (N - i) / i) % MOD
  ans2 = X * B[N - 1 - i] % MOD 
  ans += ans2
  ans = ans % MOD
  
ans = (M * ans) %MOD
print(ans)

          
          

Failing test case input:
57583 19261 6864

Expected output:
126487944


Actual output:
168968520


Fixed submission (verdict: Accepted):

N, M, K = map(int, input().split())
MOD = 998244353

P = MOD
Y = max(N, M)
inv_t = [0]+[1]
for i in range(2, Y):
  inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

          
if K == N - 1:
  ans = 1
  for i in range(N):
    ans = ans * M % MOD
  print(ans % MOD)
  quit()
  

  
  
 
  

B = [1] * N
ans1 = 1
for i in range(1, N):
  ans1 = (ans1 * (M - 1)) % MOD
  B[i] = (ans1 * M) % MOD
  
ans = 0
ans2 = 1

for i in range(K + 1):
  if i == 0:
    X = 1
  else:
    X = (X * (N - i) * inv_t[i]) % MOD
  ans2 = X * B[N - 1 - i] % MOD 
  ans += ans2
  ans = ans % MOD
      
print(ans)
Problem: p02685
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N, M, K = list(map(int, input().split()))
mod = 998244353

c = 1
answer = M * pow(M-1, N-1,mod)

for i in range(1, K+1):
    c = (c * (N-i) * pow(i, mod-2, mod)) % mod
    answer += (M * c  * pow(M-1, N -1- i, mod)) % mod
    answer %= mod
    
print(answer)

Failing test case input:
101 110 0

Expected output:
599627031


Actual output:
53506577740


Fixed submission (verdict: Accepted):
N, M, K = list(map(int, input().split()))
mod = 998244353

c = 1
answer = 0

for i in range(K+1):
    answer += (M * c  * pow(M-1, N - i - 1, mod)) % mod
    answer %= mod
    c = (c * (N-i-1) * pow(i+1, mod-2, mod)) % mod
    
print(answer)

Problem: p02685
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N,M,K=map(int,input().split())

mod=998244353

fact=[1 for i in range(N+1)]
for i in range(1,N):
    fact[i+1]=(fact[i]*(i+1))%mod

def nCk(n,k):
    return fact[n]

result=0
for k in range(K+1):
    result+=nCk(N-1,k)*M*pow(M-1,N-k-1,mod)
    result=int(result)%mod
print(result)

Failing test case input:
19 3 2

Expected output:
37945344


Actual output:
672829579


Fixed submission (verdict: Accepted):
N,M,K=map(int,input().split())

mod=998244353

fact=[1 for i in range(N+1)]
for i in range(1,N):
    fact[i+1]=(fact[i]*(i+1))%mod

def nCk(n,k):
    return fact[n]*pow(fact[n-k]*fact[k],mod-2,mod)

result=0
for k in range(K+1):
    result+=nCk(N-1,k)*M*pow(M-1,N-k-1,mod)
    result=int(result)%mod
print(result)

Problem: p02685
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N, M, K = map(int, input().split())
MOD = 998244353
MAX_N = 10**6
fac = [0]*(MAX_N)
fac_inv = [0]*(MAX_N)
fac[0] = 1
for i in range(MAX_N-1):
    fac[i+1] = fac[i]*(i+1) % MOD
fac_inv[-1] = pow(fac[-1], MOD-2, MOD)
for i in range(MAX_N-2, -1, -1):
    fac_inv[i] = fac_inv[i+1]*(i+1) % MOD


def nCk(n, k):
    return fac[n] * fac_inv[k] * fac_inv[n-k]


ans = 0
for k in range(K+1):
    temp = M*nCk(N-1, k)*pow(M-1, N-K-1, MOD) % MOD
    ans += temp
    ans %= MOD
print(ans)


Failing test case input:
247804 36905 6864

Expected output:
593386427


Actual output:
989828744


Fixed submission (verdict: Accepted):
N, M, K = map(int, input().split())
MOD = 998244353
MAX_N = 10**6
fac = [0]*(MAX_N)
fac_inv = [0]*(MAX_N)
fac[0] = 1
for i in range(MAX_N-1):
    fac[i+1] = fac[i]*(i+1) % MOD
fac_inv[-1] = pow(fac[-1], MOD-2, MOD)
for i in range(MAX_N-2, -1, -1):
    fac_inv[i] = fac_inv[i+1]*(i+1) % MOD


def nCk(n, k):
    return fac[n] * fac_inv[k] % MOD * fac_inv[n-k] % MOD


ans = 0
for k in range(K+1):
    
    temp = (M*nCk(N-1, k)) % MOD*pow(M-1, N-k-1, MOD) % MOD
    ans += temp
    ans %= MOD
print(ans)
Problem: p02685
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n,m,k=map(int,input().split())
n-=1
mod=998244353
pat=1
res=0
for i in range(0,k+1):
  res+=pat*pow(m-1,n-i,mod)
  pat=pat*(n-i)
  pat=pat%mod
  
print((m*res)%mod)

Failing test case input:
19 3 2

Expected output:
37945344


Actual output:
68026368


Fixed submission (verdict: Accepted):
n,m,k=map(int,input().split())
mod=998244353
res=0
pat=1
for i in range(0,k+1):
  res+=pat*pow(m-1,n-1-i,mod)
  pat*=(n-1-i)*pow(i+1,mod-2,mod)
  pat%=mod
  
print((m*res)%mod)

Problem: p02685
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
mod= 998244353

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

ans=0
cmb=1
for i in range(k+1):
    ans+=cmb*m*pow(m-1,n-1-i,mod)
    ans%=mod
    X=(n-1-i)*pow(i+1,mod-2,mod)
    X%=mod
print(ans)

Failing test case input:
145188 34286 8988

Expected output:
538357075


Actual output:
20598198


Fixed submission (verdict: Accepted):
mod= 998244353

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

ans=0
cmb=1
for i in range(k+1):
    ans+=cmb*m*pow(m-1,n-1-i,mod)
    ans%=mod
    cmb*=(n-1-i)*pow(i+1,mod-2,mod)
    cmb%=mod
print(ans)

Problem: p02685
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n,m,k=[int(x) for x in input().split()]

sumi=0
mod=998244353
prodi=pow(m-1,n-1,mod)
invi=pow(m-1,mod-2,mod)
for j in range(n-1,n-1-k-1,-1):
  sumi+=prodi
  sumi%=mod
  prodi*=n-j
  prodi%=mod
  prodi*=pow(j+1,mod-2,mod)
  prodi%=mod
  prodi*=invi
  prodi%=mod
sumi*=m
sumi%=mod
print(sumi)
  

Failing test case input:
145188 114575 5625

Expected output:
70524932


Actual output:
103499257


Fixed submission (verdict: Accepted):
n,m,k=[int(x) for x in input().split()]

if m==1:
  if k==n-1: print(1)
  else: print(0)
  exit()
sumi=0
mod=998244353
prodi=pow(m-1,n-1,mod)
invi=pow(m-1,mod-2,mod)
for j in range(n-1,n-1-k-1,-1):
  sumi+=prodi
  sumi%=mod
  prodi*=j
  prodi%=mod
  prodi*=pow(n-j,mod-2,mod)
  prodi%=mod
  prodi*=invi
  prodi%=mod 
sumi*=m
sumi%=mod
print(sumi)

Problem: p02685
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n, m, k = [int(t) for t in open(0).read().split()]
mod = 998244353
mem = [0] * max(k + 3, n + 1)
for i in range(k + 2):
    mem[i] = pow(m, i, mod)
mem[k + 2] = (pow(m, k + 2, mod) + mod - m) % mod
for i in range(k + 3, n + 1):
    mem[i] = (m * mem[i - 1] - (m - 1) * mem[i - k - 2]) % mod
print(mem[n])


Failing test case input:
145188 114575 6864

Expected output:
539675612


Actual output:
413574700


Fixed submission (verdict: Accepted):
n, m, k = [int(t) for t in open(0).read().split()]
mod = 998244353
mem = [0] * max(k + 3, n + 1)
for i in range(k + 2):
    mem[i] = pow(m, i, mod)
c = 1
for i in range(k + 2, n + 1):
    mem[i] = (m * mem[i - 1] - m * c * pow(m - 1, i - k - 2, mod)) % mod
    c = (c * (i - 1) * pow(i - k - 1, - 1, mod)) % mod
print(mem[n])
Problem: p02685
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

N, M, K = map(int, input().split())
MOD = 998244353

if M == 1:
  print("1")
  quit()
  

B = [1] * N
ans1 = 1
for i in range(1, N):
  ans1 = (ans1 * (M - 1)) % MOD
  B[i] = ans1
  
ans = 0
ans2 = 1

for i in range(K + 1):
  if i == 0:
    X = 1
  else:
    X = int(X * (N - i) / i) % MOD
  ans2 = X * B[N - 1 - i] % MOD 
  ans += ans2
  ans = ans % MOD
  
ans = (M * ans) %MOD
print(ans)

          
          

Failing test case input:
57583 20097 6864

Expected output:
716697264


Actual output:
276035773


Fixed submission (verdict: Accepted):

N, M, K = map(int, input().split())
MOD = 998244353

P = MOD
Y = max(N, M)
inv_t = [0]+[1]
for i in range(2, Y):
  inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

          
if K == N - 1:
  ans = 1
  for i in range(N):
    ans = ans * M % MOD
  print(ans % MOD)
  quit()
  

  
  
 
  

B = [1] * N
ans1 = 1
for i in range(1, N):
  ans1 = (ans1 * (M - 1)) % MOD
  B[i] = (ans1 * M) % MOD
  
ans = 0
ans2 = 1

for i in range(K + 1):
  if i == 0:
    X = 1
  else:
    X = (X * (N - i) * inv_t[i]) % MOD
  ans2 = X * B[N - 1 - i] % MOD 
  ans += ans2
  ans = ans % MOD
      
print(ans)

Problem: p02685
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N, M, K = map(int, input().split())
mod = 998244353

c = [1 for i in range(K+1)]
if K > 1:
    c[1] = N-1
for i in range(2, K+1):
    c[i] = ( c[i-1] * (N-i) / i ) %mod
ans = 0
for k in range(K+1):
    x = M * pow(M-1, N-1-k, mod) * c[k]
    ans += x%mod
    ans = ans %mod
print(ans)

Failing test case input:
213676 36905 6864

Expected output:
794412565


Actual output:
458685674.0


Fixed submission (verdict: Accepted):
N, M, K = map(int, input().split())
mod = 998244353

fact = [1 for i in range(N+1)]
fact_inv = [1 for i in range(N+1)]
for i in range(1, N+1):
    fact[i] = fact[i-1] * i %mod
    fact_inv[i] = pow(fact[i], mod-2, mod)

ans = 0
for k in range(K+1):
    x = M *pow(M-1, N-1-k, mod) *fact[N-1] *fact_inv[k] *fact_inv[N-1-k]
    ans += x %mod
    ans = ans %mod
print(ans)
Problem: p02682
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
A,B,C,K = list(map(int, input().split()))

if A > K:
  print(A)
elif A <= K and A + B > K:
  print(A)
elif A <= K and A + B <= K:
  print(A - (K - A - B))

Failing test case input:
4 2 1 2

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):
A,B,C,K = map(int,input().split())
 
if K <= A:
    print(str(K))
elif K <= A + B:
    print(str(A))
else:
    print(str(A - (C - (A + B + C - K))))

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A, B, C, K = map(int, input().split())
Ts = 0
sA = K - A
if sA > 0:
    sB = sA - B
    if sB > 0:
        sC = sB - C
        if sC < 0:
            Ts = ((K - sA) * 1) + ((sA - sB) * 0) + (sB * -1)
        elif sC == 0:
            Ts = ((K - sA) * 1) + ((sA - sB) * 0) + (sB * -1)
    elif sB == 0:
        Ts = ((K - sA) * 1) + (sB * 0)
    else:
        Ts = ((K - sA) * 1) + ((sA - sB) * 0)
elif sA == 0:
    Ts = A * 1
else:
    Ts = sA * 1
print(Ts)

Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
-1


Fixed submission (verdict: Accepted):
A, B, C, K = map(int, input().split())
Ts = 0
sA = K - A
if sA > 0:
    sB = sA - B
    if sB > 0:
        sC = sB - C
        if sC < 0:
            Ts = ((K - sA) * 1) + ((sA - sB) * 0) + (sB * -1)
        elif sC == 0:
            Ts = ((K - sA) * 1) + ((sA - sB) * 0) + (sB * -1)
    elif sB == 0:
        Ts = ((K - sA) * 1) + (sB * 0)
    else:
        Ts = ((K - sA) * 1) + ((sA - sB) * 0)
elif sA == 0:
    Ts = A * 1
else:
    Ts = K * 1
print(Ts)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,c,k = map(int, input().split())
if a>=k:
  print(k)
elif a+b>=k:
  print(a)
else:
  l = k-a-b
  print(a - (c*l))

Failing test case input:
-1 6 5 6

Expected output:
-2


Actual output:
-6


Fixed submission (verdict: Accepted):
a,b,c,k = map(int, input().split())
if a>=k:
  print(k)
elif a+b>=k:
  print(a)
else:
  l = k-a-b
  print(a - l)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,c,k = map(int,input().split())
if k<=a+b:
    print(a)
else:
    print(int(a-(k-a-b)))

Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
a,b,c,k = map(int,input().split())
if k<=a+b:
    print(min(a,k))
else:
    c = k-a-b
    print(int(a-c))

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,c,k = map(int,input().split())

if a+b >= k:
    print(a)
else:
    k = k - (a + b)
    print(a - k)

Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
a,b,c,k = map(int,input().split())

if a > k:
    print(k)
elif a+b >= k:
    print(a)
else:
    k = k - (a + b)
    print(a - k)
Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a, b, c, d = map(int, input().split())

ans = 0

if d > a:
    ans += a
else:
    ans += d

if d-a-b > c:
    ans -= c
else:
    ans -= d-a-b

print(ans)


Failing test case input:
2 6 5 6

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):
a, b, c, k = map(int, input().split())

ans = 0

if a >= k:
    ans += k
else:
    ans += a

if k > a+b:
    ans -= k-a-b
    
print(ans)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from sys import stdin

A, B, C, K = map(int, stdin.readline().rstrip().split())
res = int(0)

def f(p, n, k, res):
    if k - n > 0:
        return k - n, p * (k - n) + res
    else:
        return 0, p * k + res


nokori, res = f(1, A, K, res)
nokori, res = f(0, B, K, res)
nokori, res = f(-1, C, K, res)
print(res)

Failing test case input:
1 3 10 9

Expected output:
-4


Actual output:
-1


Fixed submission (verdict: Accepted):
from sys import stdin

A, B, C, K = map(int, stdin.readline().rstrip().split())
res = int(0)

def f(p, n, k, res):
    if (k - n) >= 0:
        return k - n, p * n + res
    else:
        return 0, p * k + res


K, res = f(1, A, K, res)
K, res = f(0, B, K, res)
_, res = f(-1, C, K, res)
print(res)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a, b, c, k = [int(i) for i in input().split()]

sum = 0

if a >= k or a + b >= k:
    sum = a
else:
    sum = a - (k - a - b)

print(sum)

Failing test case input:
10 2 4 8

Expected output:
8


Actual output:
10


Fixed submission (verdict: Accepted):
a, b, c, k = [int(i) for i in input().split()]

if a >= k:
    print(k)
elif  a + b >= k:
    print(a)
else:
    print(a - (k - a - b))

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A, B, C, K = map(int, input().split())
P = 0
while True:
    P += A
    K -= A
    if K < 0:
        P = K
        break
    elif K == 0:
        break
    K -= B
    if K <= 0:
        break

    P -= C
    K -= C
    if K <= 0:
        P += abs(K)
        break
print(P)





Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
-1


Fixed submission (verdict: Accepted):
A, B, C, K = map(int, input().split())
P = 0
S = 0
while S==0:
    P += A
    K -= A
    if K < 0:
        P -= abs(K)
        break
    elif K == 0:
        break

    K -= B
    if K <= 0:
        break

    P -= C
    K -= C
    if K <= 0:
        P += abs(K)
        break
    S=1
print(P)

Problem: p02682
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
A, B, C, K = map(int, input().split())

if K < A:
    print(A)
elif A < K and K <= A + B:
    print(A)
else:
    print(A - (K - A - B))


Failing test case input:
10 2 4 8

Expected output:
8


Actual output:
10


Fixed submission (verdict: Accepted):
A, B, C, K = map(int, input().split())

if K <= (A + B):
    if K < A:
        ans = K
    else:
        ans = A
else:
    ans = A - (K - A - B)

print(ans)
Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def main():
    a, b, c, k = map(int, input().split())
    res = 0

    res += a
    k -= a
    if k > 0:
        k -= b
    if k > 0:
        res += (-1 * min(c, k))
    print(res)
    
if __name__ == '__main__':
    main()

Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
def main():
    a, b, c, k = map(int, input().split())
    res = 0

    res += 1 * min(a, k)
    k -= a
    if k > 0:
        k -= b
    if k > 0:
        res += (-1 * min(c, k))
    print(res)

if __name__ == '__main__':
    main()

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a, b, c, k = map(int, input().split())
num = a
k -= a

if k>0:
    k-=b
    if k>0:
        print(num-k)
        exit()
    else:
        print(num)

print(num)

Failing test case input:
-1 6 1 1

Expected output:
-1


Actual output:
-1
-1


Fixed submission (verdict: Accepted):
a, b, c, k = map(int, input().split())
num = 0

if k-a>0:
    num += a
    k-=a
    if k-b>0:
        k -= b
        print(num-k)
    else:
        print(num)
else:
    print(k)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a, b, c, k = map(int, input().split())
ans = 0
if k >= a:
    k -= a
    ans += a
    if k >= b:
        k -= b
        if k >= c:
            k -= c
            ans -= c
            print(ans)
        else:
            print(ans - k)
    else:
        print(ans)
else:
    print(a)

Failing test case input:
4 2 1 2

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):
a, b, c, k = map(int, input().split())
ans = 0
if k >= a:
    k -= a
    ans += a
    if k >= b:
        k -= b
        if k >= c:
            k -= c
            ans -= c
            print(ans)
        else:
            print(ans - k)
    else:
        print(ans)
else:
    print(k)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,c,k=map(int,input().split())
if k<=a+b:
    print(a)
else:
    print(a-(k-a-b))


Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
a,b,c,k=map(int,input().split())
if k<=a:
    print(k)
elif k<=a+b:
    print(a)
else:
    print(a-(k-a-b))

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys
A, B, C, K = map(int, input().split())
if K-A <= 0:
    print(A)
    sys.exit()
else:
    if K - A - B <= 0:
        print(A)
        sys.exit()
    else:
        print(A-(K-A-B))

Failing test case input:
4 2 1 2

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):
A, B, C, K = map(int, input().split())
if K-A <= 0:
    print(K)
else:
    if K - A - B <= 0:
        print(A)
    else:
        print(A-(K-A-B))

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A, B, C, K = map(int, input().split())

print(min(A, K)-min(K-A-B, C))

Failing test case input:
0 6 2 1

Expected output:
0


Actual output:
5


Fixed submission (verdict: Accepted):
A, B, C, K = map(int, input().split())

print(min(A, K)-min(max(0, K-A-B), C))
Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a, b, c, k = map(int, input().split())

max_sum = 0

if a+b < k:
    max_sum = a+b-c
else:
    max_sum = a

print(max_sum)


Failing test case input:
0 3 10 8

Expected output:
-5


Actual output:
-7


Fixed submission (verdict: Accepted):
a, b, c, k = map(int, input().split())

max_sum = 0

if a > k:
    max_sum = k
elif a+b >= k:
    max_sum = a
else:
    max_sum = a*2+b-k

print(max_sum)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A, B, C, K = map(int, input().split())
ans = min(A, K) - min(C, K - A - B)
print(ans)

Failing test case input:
-1 6 3 1

Expected output:
-1


Actual output:
3


Fixed submission (verdict: Accepted):
A, B, C, K = map(int, input().split())
ans = min(A, K) - max(0, K - A - B)
print(ans)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A,B,C,K = list(map(int, input().split()))
sum = 0

if A <= K:
  sum += A
  K -= A
else:
  sum += K
  
if B <= K:
  sum += 0
  K -= B
else:
  sum += 0
  
if K > 0:
  sum -= K
else:
  sum += 0 
  
print(sum)

Failing test case input:
1 3 1 3

Expected output:
1


Actual output:
-1


Fixed submission (verdict: Accepted):
A,B,C,K = list(map(int, input().split()))
sum = 0

if A <= K:
  sum += A
  K -= A
else:
  sum += K
  K = 0
  
if B < K:
  sum += 0
  K -= B
else:
  sum += 0
  K = 0
  
if K > 0:
  sum -= K
else:
  sum += 0 
  
print(sum)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A, B, C, K =map(int, input().split())

ans = 0

if A <= K:
    ans = ans + A
    K = K-A
    if B <= K:
        K = K-B
        if C <= K:
            ans = ans - C
            print(ans)
        else:
            print(ans-K)
    else:
        print(ans)
else:
    print(A)


Failing test case input:
10 2 4 8

Expected output:
8


Actual output:
10


Fixed submission (verdict: Accepted):
A, B, C, K =map(int, input().split())

ans = 0

if A <= K:
    ans = ans + A
    K = K-A
    if B <= K:
        K = K-B
        if C >= K:
            ans = ans - K
            print(ans)
    else:
        print(ans)
else:
    print(K)
Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A, B, C, K = map(int, input().split())


def f(A, B, C, K) :
    
    sum = 0

    K = K - A
    if K >= 0 :
        sum = sum + (1 * A)
    elif K < 0 :
        sum = sum + (1 * K)

    if K <= 0 :
       return sum

    K = K - B
    if K >= 0 :
        sum = sum + (0 * B)
    elif K < 0 :
        sum = sum + (0 * K)

    if K <= 0 :
       return sum

    K = K - C
    if K >= 0 :
        sum = sum - (-1 * C)
    elif K < 0 :
        sum = sum - (-1 * K)

    if K <= 0 :
       return sum


print(f(A, B, C, K))


Failing test case input:
1 2 18 4

Expected output:
0


Actual output:
-16


Fixed submission (verdict: Accepted):
A, B, C, K = map(int, input().split())


def f(A, B, C, K) :
    
    sum = 0

    if K - A >= 0 :
        K = K - A
        sum = sum + (1 * A)
    else :
        sum = sum + (1 * K)
        K = 0

    if K <= 0 :
       return sum

    if K - B >= 0 :
        K = K - B
        sum = sum + (0 * B)
    else :
        sum = sum + (0 * K)
        K = 0

    if K <= 0 :
       return sum

    if K - C >= 0 :
        K = K - C
        sum = sum + (-1 * C)
    else :
        sum = sum + (-1 * K)
        K = 0

    if K <= 0 :
       return sum


print(f(A, B, C, K))

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a, b, c, k = map(int, input().split(" "))



if a >= k:
    print(a)

elif (a + b) >= k:
    print(a + 0)

else:
    print(a - (k - a - b))


Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
a, b, c, k = map(int, input().split(" "))



if a >= k:
    print(k)

elif (a + b) >= k:
    print(a)

else:
    print(a - (k - a - b))

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a, b, c, k = map(int, input().split())

if k == 1:
    print(k)
elif k <= a + b:
    print(k)
else:
    r = k - a - b
    print(a-r)


Failing test case input:
5 21 5 20

Expected output:
5


Actual output:
20


Fixed submission (verdict: Accepted):
a, b, c, k = map(int, input().split())


if k <= a:
    print(k)
elif k <= a + b:
    print(a)
else:
    r = k - a - b
    print(a-r)

Problem: p02682
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
a,b,c,k = map(int,input().split())
ans = 0
k = k - a
if k >= 0:
    ans = a
    k = k - b
    if k >= 0:
        k = k - c
        if k >= 0:
            ans -= c
        else:
            ans -= k+c
print(ans)

Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
0


Fixed submission (verdict: Accepted):
a,b,c,k = map(int,input().split())
ans = 0
if k - a >= 0:
    ans = a
else:
    ans = k
k -= a
k -= b
if k > 0:
    if k - c >= 0:
        ans -= c
    else:
        ans -= k
print(ans)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,c,k = map(int,input().split())
if a >= k:
    print(a)
elif a+b >= k:
    print(a)
else:
    print(a-(k-a-b))

Failing test case input:
4 2 1 2

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):
a,b,c,k = map(int,input().split())
if a>k:
    print(k)
elif a+b >= k:
    print(a)
else:
    print(a-(k-a-b))
Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,c,k = map(int,input().split())
sum=0
if(k==0):
  print(sum)
  exit()
if(a>k):
  sum+=k
else:
  sum+=a
  k=k-a
  if(k==0):
    print(sum)
    exit()
  if(b>k):
    print(sum)
  else:
    k = k-b
    if(k==0):
      print(sum)
      exit()
    if(c>k):
      sum-=k
      print(sum)
    else:
      sum-=c
      print(sum)


Failing test case input:
4 3 4 3

Expected output:
3


Actual output:

Fixed submission (verdict: Accepted):
a,b,c,k = map(int,input().split())
sum=0
if(k==0):
  print(sum)
  exit()
if(a>=k):
  sum+=k
  print(sum)
  exit()
else:
  sum+=a
  k=k-a
  if(b>=k):
    print(sum)
    exit()
  else:
    k = k-b
    if(c>=k):
      sum-=k
      print(sum)
    else:
      sum-=c
      print(sum)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
plus, zero, minus, number = map(int, input().split(" "))

if(plus + zero <= number):
  print(plus)
else:
  print(2 * plus + zero - number)

Failing test case input:
-1 6 3 6

Expected output:
-2


Actual output:
-1


Fixed submission (verdict: Accepted):
plus, zero, minus, number = map(int, input().split(" "))

if(plus > number):
  print(number)
elif(plus + zero >= number):
  print(plus)
else:
  print(plus - number + plus + zero)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A,B,C,K = map(int, input().split())
total = 0
if A < K:
    total = A
    if B < K - A:
        total = total - (K-A)
else:
    total = A
print(total)

Failing test case input:
-2 3 5 5

Expected output:
-6


Actual output:
-9


Fixed submission (verdict: Accepted):
A,B,C,K = map(int, input().split())
total = K
if total <= A:
    print(total)
else:
    if K-A <= B:
        print(A)
    else:
        print(A - (K-A-B))

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):



a,b,c,k = map(int, input().split())

if a + b >= k:
    if a >= k:
        print(a)
    else:
        print(k)
else:
    print(a - (k - (a + b)))

Failing test case input:
2 2 0 4

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):



a,b,c,k = map(int, input().split())

if a + b >= k:
    if a <= k:
        print(a)
    else:
        print(k)
else:
    print(a - (k - (a + b)))

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,c,k=(map(int,input().split()))
if k>=a:
	if b>=(k-a):
		print(a)
	else:
		rem=k-(a+b)
		print(a-rem)




Failing test case input:
4 2 1 2

Expected output:
2


Actual output:

Fixed submission (verdict: Accepted):
a,b,c,k=(map(int,input().split()))
if k>=a:
	if b>=(k-a):
		print(a)
	else:
		rem=k-(a+b)
		print(a-rem)
else:
	print(k)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A,B,C,K=map(int,input().split())
b=0

if A<=K:
    b=A
    
if A+B<K:
    b+=-(K-A-B)
print(b)

Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
0


Fixed submission (verdict: Accepted):
A,B,C,K=map(int,input().split())
b=0

if A<=K:
    b=A

elif A>K:
    b=K
    
if A+B<K:
    b+=-(K-A-B)
print(b)
Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a, b, c, k = map(int, input().split())

if k <= a:
  print(a)
elif k <= a+b:
  print(a)
else:
  print(2*a-k+b)

Failing test case input:
4 2 1 2

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):
a, b, c, k = map(int, input().split())

if k <= a:
  print(k)
elif k <= a+b:
  print(a)
else:
  print(a-(k-a-b))

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,c,k=map(int,input().split())
if k<=a:
    print(a)
elif k<=a+b:
    print(a)
else:
    print(2*a+b-4)

Failing test case input:
-1 3 5 5

Expected output:
-4


Actual output:
-3


Fixed submission (verdict: Accepted):
a,b,c,k=map(int,input().split())
if k<=a:
    print(k)
elif k>a and k<=a+b:
    print(a)
else:
    print(2*a+b-k)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def main():
    a,b,c,k=map(int,input().split())
    if a>=k:
        print(a)
    elif a+b>=k:
        print(a)
    else:
        print(a-c*(k-a-b))
main()

Failing test case input:
0 3 8 8

Expected output:
-5


Actual output:
-40


Fixed submission (verdict: Accepted):
a,b,c,k=map(int,input().split())
if a>=k:
    print(k)
elif a<k and a+b>=k:
    print(a)
else:
    print(a-(k-a-b))

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a , b, c, k = map(int,input().split())
if 0 < k <= a + b:
    print(a)
elif a + b < k <= a + b + c:
    print(a-(c-b))

Failing test case input:
1 3 10 9

Expected output:
-4


Actual output:
-6


Fixed submission (verdict: Accepted):
a , b, c, k = map(int,input().split())
if 0 < k < a:
    print(k)
if a <= k <= a + b:
    print(a)
elif a + b < k <= a + b + c:
    print(a-(k-a-b))

Problem: p02682
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
A, B, C, K = map(int, input().split())
if K <= A:
    print(K)
elif A < K <= A + B:
    print(A)
elif A + B < K < A + B + C:
    print(A - (K - (A + B)))

Failing test case input:
-1 2 5 6

Expected output:
-6


Actual output:

Fixed submission (verdict: Accepted):
A, B, C, K = map(int, input().split())
if K <= A:
    print(K)
elif A < K <= A + B:
    print(A)
elif A + B < K <= A + B + C:
    print(A - (K - (A + B)))

Problem: p02682
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
a, b, c, k = map(int, input().split())
if k <= a: 
  print(k)
if a < k <= b:
  print(a)
if b < k <= c:
  print(a+(-1)*(k-a-b))


Failing test case input:
0 3 10 12

Expected output:
-9


Actual output:

Fixed submission (verdict: Accepted):
a, b, c, k = map(int, input().split())
if k <= a:
  print(k)
if a < k <= a+b:
  print(a)
if a+b < k <= a+b+c:
  print(a+(-1)*(k-a-b))

Problem: p02682
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
A, B, C, K = tuple(map(int, input().split()))


if K <= (A + B):
    print(A)
else:
    print(A - (K - (A + B)))


Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
A, B, C, K = tuple(map(int, input().split()))


if K <= A:
    print(K)
elif K <= (A + B):
    print(A)
else:
    print(A - (K - (A + B)))
Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,c,k=map(int,input().split())
if k <= a:
    print(k)
elif k <= a+b:
    print(0)
else:
    print(2*a-k+b)

Failing test case input:
1 3 1 3

Expected output:
1


Actual output:
0


Fixed submission (verdict: Accepted):
a,b,c,k=map(int,input().split())
if k <= a:
    print(k)
elif k <= a+b:
    print(a)
else:
    print(2*a-k+b)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A, B, C, K = map(int,input().split())
sum = 0
n = 0
if K - A > 0:
    sum = A*1
    n = K - A
    if B > n:
        n = n - B
        sum = C * n
else:
    sum = A*1
print(sum)

Failing test case input:
0 6 3 2

Expected output:
0


Actual output:
-12


Fixed submission (verdict: Accepted):
A, B, C, K = map(int,input().split())
sum = 0
n = 0
if K - A > 0:
    sum = A
    n = K - A
    if B < n:
        n = n - B
        sum += (-1) * n
else:
    sum = K
print(sum)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def main():
    import sys
    sys.setrecursionlimit(10**6)
    input = sys.stdin.readline
    A, B, C, K = [int(x) for x in input().strip().split()]
    if K <= A + B:
        print(min(K, A))
    else:
        print(A - (B - (K - A - B)))
    
if __name__ == '__main__':
    main()

Failing test case input:
2 0 1 3

Expected output:
1


Actual output:
3


Fixed submission (verdict: Accepted):
def main():
    import sys
    sys.setrecursionlimit(10**6)
    input = sys.stdin.readline
    A, B, C, K = [int(x) for x in input().strip().split()]
    if K <= A + B:
        print(min(K, A))
    else:
        print(A - (K - A - B))
    
if __name__ == '__main__':
    main()

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a, b, c, k = map(int, input().split())

if a + b < k:
    print(a - (k - a - b))
else:
    print(a)


Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
a, b, c, k = map(int, input().split())

if a > k:
    print(k)
elif a + b > k:
    print(a)
else:
    print(a - (k - a - b))

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def main():
    A,B,C,K=map(int,input().split())
    cal=0

    if K<=A:
        cal=K
        print(cal)
        return

    else :
        cal+=A
        K-=A
        if K<=B:
            print(cal)
            return

    K-=B
    print(cal-C)
    return


main()


Failing test case input:
-1 3 8 3

Expected output:
-2


Actual output:
-9


Fixed submission (verdict: Accepted):
def main():
    A,B,C,K=map(int,input().split())
    cal=0

    if K<=A:
        cal=K
        print(cal)
        return

    cal+=A
    K-=A
    if K<=B:
        print(cal)
        return

    K-=B
    print(cal-K)
    return


main()
Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,c,k=map(int,input().split())
if k<=a+b:
  max_value=a
else:
  max_value=a*2-k+b
print(max_value)


Failing test case input:
4 3 4 3

Expected output:
3


Actual output:
4


Fixed submission (verdict: Accepted):
a,b,c,k=map(int,input().split())
if a<=k<=a+b:
  max_value=a
elif k<a:
	max_value=k
else:
  max_value=a*2-k+b
print(max_value)

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def main():
    a, b, c, k = map(int, input().split())
    if k <= a: 
        return k
    if a < k <= a+b:
        return a
    if a+b < k <= a+b+c:
        return a + (k - a-b)*(-1)

main()

Failing test case input:
2 3 14 2

Expected output:
2


Actual output:

Fixed submission (verdict: Accepted):
def main():
    a, b, c, k = map(int, input().split())
    if k <= a: 
        return k
    if a < k <= a+b:
        return a
    if a+b < k <= a+b+c:
        return a + (k - a-b)*(-1)

print(main())

Problem: p02682
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a,b,c,k=map(int,input().split())

if k<=a or k<=a+b:
    print(a)
else:
    print((k-(a+b))*-1+a)

Failing test case input:
10 2 4 8

Expected output:
8


Actual output:
10


Fixed submission (verdict: Accepted):
a,b,c,k=map(int,input().split())

if k<=a+b:
    if k<=a:
        print(k)
    else:
        print(a)
else:
    print((k-(a+b))*(-1)+a)

Problem: p02682
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):


A, B, C, K = map(int, input().split())

ans = 0
while(K!=0):
    print(A, B, C, K)
    if A!=0:
        if A <= K:
            ans += A*1
            A =0
            K -= A
        else:
            ans += K*1
            A -= K
            K = 0
    elif B!=0:
        if B <= K:
            ans += B*0
            B =0
            K -= B
        else:
            ans += K*0
            B -= K
            K = 0
    elif C!=0:
        if C <= K:
            ans += C*-1
            C =0
            K -= C
        else:
            ans += K*-1
            C -= K
            K = 0

    if A==0 and B==0 and C==0:
        break
print(ans)

Failing test case input:
2 6 5 6

Expected output:
2


Actual output:
2 6 5 6
0 6 5 6
0 0 5 6
-3


Fixed submission (verdict: Accepted):


A, B, C, K = map(int, input().split())

ans = 0
while(K!=0):
    
    
    if A!=0:
        if A <= K:
            ans += A*1
            K -= A
            A = 0
        else:
            ans += K*1
            A -= K
            K = 0
    elif B!=0:
        if B <= K:
            ans += B*0
            K -= B
            B = 0
        else:
            ans += K*0
            B -= K
            K = 0
    elif C!=0:
        if C <= K:
            ans += C*-1
            K -= C
            C = 0
        else:
            ans += K*-1
            C -= K
            K = 0

    if A==0 and B==0 and C==0:
        break
print(ans)