Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02984 (python)

Fixed submission:
from sys import stdin

if __name__ == '__main__':

    N = int(stdin.readline())
    A = [int(x) for x in stdin.readline().rstrip().split()]

    tmp = list()
    for i in range(N):
        if i % 2 == 0:
            continue

        tmp.append(A[i])

    X = list()
    X.append(sum(A) - sum(tmp) * 2)

    for i in range(N):
        if i == 0:
            continue

        X.append(2 * A[i-1] - X[i-1])

    print(' '.join([str(x) for x in X]))

Buggy submission (verdict: Runtime Error):
from sys import stdin
import numpy as np

if __name__ == '__main__':

    N = int(stdin.readline())
    # A だけどNUMPYにあわせてｂ
    b = [int(x) for x in stdin.readline().rstrip().split()]

    # [NumPyで全要素を同じ値で初期化した配列ndarrayを生成 \| note\.nkmk\.me](https://note.nkmk.me/python-numpy-zeros-ones-full/)
    A = np.zeros((N, N), np.int8)
    for i in range(N):
        if i == N - 1:
            A[i][0] = 1
            A[i][i] = 1
        else:
            A[i][i] = 1
            A[i][i+1] = 1

    B = np.array(b)

    # [\[Pythonで数値解析\]\(第5回\)連立一次方程式の数値解法 \- Qiita](https://qiita.com/Y_F_Acoustics/items/b386ff8da11e2c912712)
    ans = np.linalg.solve(A, B)

    int_ans = [str(int(x) * 2) for x in ans]
    print(' '.join(int_ans))

Buggy submission (verdict: Runtime Error):
from sys import stdin
import numpy as np

if __name__ == '__main__':

    N = int(stdin.readline())
    # A だけどNUMPYにあわせてｂ
    b = [int(x) for x in stdin.readline().rstrip().split()]

    # [NumPyで全要素を同じ値で初期化した配列ndarrayを生成 \| note\.nkmk\.me](https://note.nkmk.me/python-numpy-zeros-ones-full/)
    A = np.zeros((N, N))
    for i in range(N):
        if i == N - 1:
            A[i][0] = 0.5
            A[i][i] = 0.5
        else:
            A[i][i] = 0.5
            A[i][i+1] = 0.5

    B = np.array(b)

    # [\[Pythonで数値解析\]\(第5回\)連立一次方程式の数値解法 \- Qiita](https://qiita.com/Y_F_Acoustics/items/b386ff8da11e2c912712)
    ans = np.linalg.solve(A, B)

    int_ans = [str(int(x)) for x in ans]
    print(' '.join(int_ans))
Problem p02987 (python)

Fixed submission:
from sys import stdin
from collections import Counter

S = stdin.readline().rstrip()
cnt = Counter(S)

if len(cnt.keys()) == 2 and set(cnt.values()) == {2}:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
from sys import stdin
from math import factorial

if __name__ == '__main__':

    N, K = [int(x) for x in stdin.readline().rstrip().split()]

    tmp = 1000000007
    r = 0
    while True:
        r += 1
        n = N - K + 1

        if n - r < 0:
            break

        ret = factorial(n) // factorial(r) // factorial(n - r)
        ret2 = factorial(K-1) // factorial(r-1) // factorial((K - 1) - (r - 1))

        print((ret * ret2) % tmp)
Problem p02990 (python)

Fixed submission:
from sys import stdin
from math import factorial

if __name__ == '__main__':

    N, K = [int(x) for x in stdin.readline().rstrip().split()]

    tmp = 1000000007
    r = 0
    for r in range(K):
        r += 1
        n = N - K + 1

        if n - r < 0 or K - r < 0:
            print(0)
            continue

        ret = factorial(n) // factorial(r) // factorial(n - r)
        ret2 = factorial(K-1) // factorial(r-1) // factorial((K - 1) - (r - 1))

        print((ret * ret2) % tmp)

Buggy submission (verdict: Runtime Error):
from sys import stdin
from math import factorial
 
if __name__ == '__main__':
 
    N, K = [int(x) for x in stdin.readline().rstrip().split()]
 
    tmp = 1000000007
    r = 0
    for r in range(K)
        r += 1
        n = N - K + 1
 
        if n - r < 0 or K - r < 0:
            print(0)
            continue
 
        ret = factorial(n) // factorial(r) // factorial(n - r)
        ret2 = factorial(K-1) // factorial(r-1) // factorial((K - 1) - (r - 1))
 
        print((ret * ret2) % tmp)

Buggy submission (verdict: Runtime Error):
from sys import stdin
from math import factorial

if __name__ == '__main__':

    N, K = [int(x) for x in stdin.readline().rstrip().split()]

    tmp = 1000000007

    for r in range(K):
        r += 1
        n = N - K + 1

        ret = factorial(n) // factorial(r) // factorial(n - r)
        ret2 = factorial(K-1) // factorial(r-1) // factorial((K - 1) - (r - 1))

        print((ret * ret2) % tmp )

Buggy submission (verdict: Runtime Error):
from sys import stdin
from math import factorial

if __name__ == '__main__':

    N, K = [int(x) for x in stdin.readline().rstrip().split()]

    tmp = 100000007
    ret = 0
    for r in range(K):
        r += 1
        n = N - K + 1

        ret = factorial(n) // factorial(r) // factorial(n - r)
        ret2 = factorial(K-1) // factorial(r-1) // factorial((K - 1) - (r - 1))

        print(ret * ret2)
Problem p02623 (python)

Fixed submission:
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
if K >= sum(A) + sum(B):
    print(M + N)
    exit()
acc = 0
ans = 0
for j, b in enumerate(B):
    acc += b
    if K >= acc:
        ans = j + 1
for i in range(N):
    acc += A[i]
    if K >= acc:
        ans = max(ans, i + j + 2)
        continue
    else:
        while (K < acc) & (j > -1):
            acc -= B[j]
            j -= 1
        if K >= acc:
            ans = max(ans, i + j + 2)
print(ans)

Buggy submission (verdict: Runtime Error):
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
acc = sum(B)
j = M - 1
if acc + sum(A) <= K:
    print(M + N)
    exit()
ans = 0
for i in range(N):
    acc += A[i]
    if acc <= K:
        ans = max(ans, i + j + 2)
        continue
    else:
        while acc > K:
            acc -= B[j]
            j -= 1
            if (j == -1) & (acc > K):
                print(ans)
                exit()
        ans = max(ans, i + j + 2)
print(ans)
Problem p03013 (python)

Fixed submission:
n, m = map(int, input().split())
A = list(int(input()) for i in range(m))

mod = 10 ** 9 + 7

def Fib(n):
    a, b = 0, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b


if m > 0:
    ans = Fib(A[0] + 1) % mod
    for i in range(m - 1):
        if A[i] == A[i + 1]:
            continue
        ans *= Fib(A[i + 1] - A[i])
        ans %= mod
    ans *= Fib(n - A[-1] + 1)
    ans %= mod
else:
    ans = Fib(n + 2) % mod
print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())

mod = 10 ** 9 + 7


def Fib(n, memo={}):
    if n == 1:
        return 0
    elif n == 2:
        return 1
    elif n in memo:
        return memo[n] % mod
    else:
        memo[n] = Fib(n - 1, memo) + Fib(n - 2, memo)
        return memo[n] % mod


A = list(int(input()) for i in range(m))


if m > 0:
    ans = Fib(A[0] + 1) % mod
    for i in range(m - 1):
        if A[i + 1] == A[i]:
            continue
        ans *= Fib(A[i + 1] - A[i])
        ans %= mod
        if A[i] + 1 == A[i + 1]:
            print(0)
            exit()
    ans *= Fib(n - A[-1] + 1)
    ans %= mod
else:
    ans = Fib(n + 2) % mod
print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())

mod = 10 ** 9 + 7


def Fib(n, memo={}):
    if n == 1:
        return 0
    elif n == 2:
        return 1
    elif n in memo:
        return memo[n] % mod
    else:
        memo[n] = Fib(n - 1, memo) + Fib(n - 2, memo)
        return memo[n] % mod


A = list(int(input()) for i in range(m))


if m > 0:
    ans = Fib(A[0] + 1) % mod
    for i in range(m - 1):
        ans *= Fib(A[i + 1] - A[i])
        ans %= mod
        if A[i] + 1 == A[i + 1]:
            print(0)
            exit()
    ans *= Fib(n - A[-1] + 1)
    ans %= mod
else:
    ans = Fib(n + 2) % mod
print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())

mod = 10 ** 9 + 7


def Fib(n, memo={}):
    if n == 1:
        return 0
    elif n == 2:
        return 1
    elif n in memo:
        return memo[n] % mod
    else:
        memo[n] = Fib(n - 1, memo) + Fib(n - 2, memo)
        return memo[n] % mod


A = list(int(input()) for i in range(m))


if m > 0:
    ans = Fib(A[0] + 1) % mod
    for i in range(m - 1):
        ans *= Fib(A[i + 1] - A[i])
        ans %= mod
        if A[i] + 1 == A[i + 1]:
            print(0)
            exit()
    ans *= Fib(n - A[-1] + 1)
    ans %= mod
else:
    ans = Fib(n + 1) % mod
print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())

mod = 10 ** 9 + 7


def Fib(n, memo={}):
    if n == 1:
        return 0
    elif n == 2:
        return 1
    elif n in memo:
        return memo[n] % mod
    else:
        memo[n] = Fib(n - 1, memo) + Fib(n - 2, memo)
        return memo[n] % mod


A = list(int(input()) for i in range(m))

ans = Fib(A[0] + 1)
for i in range(m - 1):
    ans *= Fib(A[i + 1] - A[i])
    ans %= mod
    if A[i] + 1 == A[i + 1]:
        print(0)
        exit()
ans *= Fib(n - A[-1] + 1)
ans %= mod
print(ans % mod)
Problem p03038 (python)

Fixed submission:
n, m = map(int, input().split())
A = sorted(map(int, input().split()))
BC = []
for j in range(m):
    b, c = map(int, input().split())
    BC.append((b, c))
BC = sorted(BC, key=lambda x: x[1], reverse=True)
D = []
for b, c in BC:
    D.extend([c for i in range(b)])
    if len(D) >= n:
        D = D[:n]
        break
for x in range(len(D)):
    if A[x] > D[x]:
        break
else:
    x += 1
print(sum(A[x:]) + sum(D[:x]))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
A = sorted(map(int, input().split()))
BC = []
for j in range(m):
    b, c = map(int, input().split())
    BC.append((b, c))
BC = sorted(BC, key=lambda x: x[1], reverse=True)
for b, c in BC:
    i = bisect.bisect_left(A, c)
    if i == 0:
        break
    else:
        start = min(i, b)
        conect = [c for j in range(start)]
        A.extend(conect)
        A = A[start:]
print(sum(A))
Problem p03108 (python)

Fixed submission:
import sys
n , m, *e = map(int,sys.stdin.read().split())
total = n*(n-1)//2
ans =[total]
u = [-1]*(n+1)

def find(x):
    if u[x] < 0 :
        return x
    else:
        return find(u[x])

for x , y in zip(e[-2:1:-2],e[:1:-2]):
    x = find(x)
    y = find(y)
    x, y = sorted((x, y))
    if x != y:
        total -= u[x] * u[y]
        u[x] += u[y]
        u[y] = x
    ans += [total]

print(*ans[::-1], sep="\n")

Buggy submission (verdict: Runtime Error):
import sys
n , m, *e = map(int,sys.stdin.read().split())
total = n*(n-1)//2
ans =[total]
u = [-1]*(n+1)

def find(x):
    if u[x] < 0 :
        return x
    else:
        return find(u[x])

for x , y in zip(e[-2:1:-2],e[:1:-2]):
    x = find(x)
    y = find(y)
    if x != y:
        total -= u[x] * u[y]
        u[x] += u[y]
        u[y] = x
    ans += [total]

print(*ans[::-1], sep="\n")

Buggy submission (verdict: Runtime Error):
import sys
n , m, *e = map(int,sys.stdin.read().split())
total = n*(n-1)//2
ans =[total]
u = [-1]*(n+1)

def find(x):
    if u[x] < 0 :
        return x
    else:
        return find(u[x])

for x , y in zip(e[-2:1:-2],e[:1:-2]):
    x = find(x)
    y = find(y)
    if x != y:
        total -= u[x] * u[y]
        u[x] += u[y]
        u[y] = x　　
    ans += [total]
    print(u)

print(*ans[::-1], sep="\n")
Problem p02622 (python)

Fixed submission:
a = input()
b = input()
count = 0
for i in range(len(a)):
  if (a[i]!= b[i]):
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
a, b = input().split()
count = 0
for i in range(len(a)):
  if (a[i]!= b[i]):
    count += 1
print(count)

Buggy submission (verdict: Runtime Error):
a, b = input().split()
count = 0
for i in range(len(a)):
  if (a[i]!= b[i]):
    count += 1
print(count)
Problem p02570 (python)

Fixed submission:
D, T, S = map(int, input().split())

if T*S >= D:
    print("Yes")
else:
    print ("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))

k = 1000000007

sm = sum(A)

ans = 0
for s in range(len(A)-1):
    #ans += A[s]*sum(A[s+1:])
    sm -= A[s]
    ans += A[s]*sm

if ans>1000000007:
    print(ans%k)
else:
    print(ans)
Problem p02571 (python)

Fixed submission:
S = input()
T = input()

if T in S:
    print("0")
else:
    slen = len(S)
    tlen = len(T)
    ansCnt = tlen

    for i in range(slen-tlen+1):
        cnt = 0
        for j in range(tlen):
            if T[j]!=S[i+j]:
                cnt += 1
        
        if ansCnt>cnt:
            ansCnt = cnt

    print(ansCnt)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()

if T in S:
    print("0")
else:
    slen = len(S)
    tlen = len(T)
    ansCnt = tlen

    for i in range(slen-tlen):
        cnt = 0
        for j in range(tlen):
            if T[j]!=S[i+j]:
                cnt += 1
        
        if ansCnt>cnt:
            ansCnt = cnt

print(ansCnt)
Problem p02623 (python)

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

a, b = [0], [0]
for i in range(N):
    a.append(a[i]+A[i])

for i in range(M):
    b.append(b[i]+B[i])

#print(a)
#print(b)
    
ans =0
j = M

for i in range(N+1):
    if a[i]>K:
        break
    
    while b[j]+a[i] > K :
        j -= 1
    ans = max(ans, i + j)

print(ans)

Buggy submission (verdict: Runtime Error):
N, M, K = map(int, input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i]+A[i])

for i in range(M):
    b.append(b[i]+B[i])

#print(a)
#print(b)
    
ans =0
j = M

for i in range(N+1):
    if a[i]>k:
        break
    
    while b[j]+a[i] > K :
        j -= 1
    ans = max(ans, i + j)

print(ans)
Problem p02627 (python)

Fixed submission:
s = input()
if s.isupper():
    print("A")
else:
    print("a")

Buggy submission (verdict: Runtime Error):
# 371 ms, 27032 KB
n = int(input())
a = list(map(int, input().split()))
q = int(input())
b = []
c = []
 
bc = [map(int, input().split()) for _ in range(q)]
b, c = [list(i) for i in zip(*bc)]
 
dic = {}
for aa in a:
    dic[aa] = dic.get(aa, 0) + 1
 
s = sum(a)
for i in range(q):
    if b[i] not in dic:
        print (str(s))
        continue
    s += (c[i]-b[i]) * dic[b[i]]
    dic[c[i]] = dic.get(c[i], 0) + dic[b[i]]
    del dic[b[i]]
    print(s)
Problem p02594 (python)

Fixed submission:
n=int(input())
if n<30:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
from math imort*
m,n=input.split()
c=0
for i in range(int(m)):
  a,b=input.split()
  d=(int(a)**2)+(int(b)**2)
  if d>=int(n):
    c=c+1
print(c)

Buggy submission (verdict: Runtime Error):
n=int(input)
if n<30:
    print("No")
else:
    print("Yes")
Problem p02570 (python)

Fixed submission:
d,t,s= map(int, input().split(' '))

if s*t<d:
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
n= int(input())
aas= list(map(int, input().split(' ')))

ans=0
for i in range(n-1):
  for j in range(i+1, n):
    ans+= aas[i]*aas[j]
    if ans>(10**9+7):
      ans= ans% (10**9+7)

print(ans)
Problem p02629 (python)

Fixed submission:
n= int(input())
ans= ''
trans= {}
for x in range(1, 27):
	trans[x]= chr(x+96)

while n!=0:
	if n%26==0:
		ans= 'z'+ ans
		n= n//26-1
	else:
		ans= trans[n%26] + ans
		n= n//26
print(ans)

Buggy submission (verdict: Runtime Error):
n= int(input())
ans= ''
trans= {}
for x in range(1, 27):
	trans[x]= chr(x+96)

while n!=0:
	ans= trans[n%26] + ans
	n= n//26
print(ans)
Problem p02659 (python)

Fixed submission:
from decimal import *

line= input().split(' ')
a= Decimal(int(line[0]))
b= Decimal((line[1]))

x= Decimal(a)*Decimal(b)
x= Decimal(x)-Decimal(x)%1
print(int(x))

Buggy submission (verdict: Runtime Error):
n= int(input())
line= input().split(' ')
 
tot=1

for a in line:
	if a=='0':
		tot=0
		break

if tot==1:
	for a in line:
		tot*= int(a)
		if tot>10**18:
			tot=-1
			break

print(tot)
Problem p02701 (python)

Fixed submission:
n= int(input())
l= set()
for _ in range(n):
	s= input()
	l.add(s)
print(len(l))

Buggy submission (verdict: Runtime Error):
n= int(input())
l= {}
for _ in range(n):
	s= input()
	l.add(s)
print(len(l))
Problem p02688 (python)

Fixed submission:
N, K = map(int, input().split())
j = 0
ls1 = []
ls2 = []

for i in range(1, K+1):
    d = int(input())
    ls1.append(input().split())
for i in range(len(ls1)):
    for j in ls1[i]:
        ls2.append(j)
        x = set(ls2)
print(N - len(x))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = 0
li = []
for x in range(n):
    li.append(input().split())
    if n - k == 0:
        a = n - 1
    else:
        a = n - k
print(a)
Problem p02831 (python)

Fixed submission:
from fractions import gcd

# input
a , b = map(int, list(input().split()))

# output
print(int(a*b/gcd(a, b)))

Buggy submission (verdict: Runtime Error):
from math import gcd

# input
a , b = map(int, list(input().split()))

# output
print(int(a*b/gcd(a, b)))
Problem p02847 (python)

Fixed submission:
# input
s = input()

# process
week = ["SUN","MON","TUE","WED","THU","FRI","SAT"]
windex = week.index(s)
ans = 7 if windex == 0 else 7-windex

# output
print(ans)

Buggy submission (verdict: Runtime Error):
# input
n = int(input())

edges = [[] for i in range(n)]
for i in range(n-1):
    a ,b = map(int, list(input().split()))
    edges[a-1].append((b-1, i))

# process
ans = [0]*(n-1)

def f(a, c):
    color = 1
    for b, i in edges[a]:
        if color == c: color += 1
        ans[i] = color 
        f(b, color)
        color += 1

f(0, 0)

# output
print(max(ans))
for i in ans:
    print(i)
Problem p02753 (python)

Fixed submission:
a = input()
if a[0] == a[1] and a[1] == a[2]:
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
a = input().split()
if a[0] == a[1] == a[2]:
  print('No')
else:
  print('Yes')
Problem p02820 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10000)
def conv(r,s,p,j):
    if j == 'r':
        return p
    if j == 's':
        return r
    if j == 'p':
        return s
def listint():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a
def perse(t,k,num):
    stri = []
    for i in range(k):
        stri.append([])
    for i in range(num):
        stri[i%k].append(t[i])
    return stri
def main(q):
    i = 0
    ans = 0
    while i < len(q)-1:
        if q[i] == q[i+1]:
            ans = ans + conv(r,s,p,q[i])
            i = i+2
        else:
            ans = ans + conv(r,s,p,q[i])
            i = i+1
    if i == len(q)-1:
        ans = ans + conv(r,s,p,q[i])
    return ans
num,k = listint()
r,s,p = listint()
t = input()
afterperse = perse(t,k,num)
ans = 0
for i in range(k):
    ans = ans + main(afterperse[i])
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)
def conv(r,s,p,j):
    if j == 'r':
        return p
    if j == 's':
        return r
    if j == 'p':
        return s
def listint():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a
def perse(t,k,num):
    stri = []
    point = []
    for i in range(k):
        stri.append([])
        point.append([])
    for i in range(num):
        stri[i%k].append(t[i])
        point[i%k].append(conv(r,s,p,t[i]))
    return stri,point
def main(q,r,s,p):
    if len(q) == 1:
        return point[0]
    if len(q) == 0:
        return 0
    if q[0] != q[1]:
        return main(q[1:],point[1:]) + point[0]
    else:
        return main(q[2:],point[2:]) + point[0]
num,k = listint()
r,s,p = listint()
t = input()
afterperse,point = perse(t,k,num)
ans = 0
for i in range(k):
    ans = ans + main(afterperse[i],point)
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)
def conv(r,s,p,j):
    if j == 'r':
        return p
    if j == 's':
        return r
    if j == 'p':
        return s
def listint():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a
def perse(t,k,num):
    stri = []
    for i in range(k):
        stri.append([])
    for i in range(num):
        stri[i%k].append(t[i])
    return stri
def main(q,r,s,p):
    if len(q) == 1:
        return conv(r,s,p,q[0])
    if len(q) == 0:
        return 0
    if q[0] != q[1]:
        return main(q[1:],r,s,p) + conv(r,s,p,q[0])
    else:
        return main(q[2:],r,s,p) + conv(r,s,p,q[0])
num,k = listint()
r,s,p = listint()
t = input()
afterperse = perse(t,k,num)
ans = 0
for i in range(k):
    ans = ans + main(afterperse[i],r,s,p)
print(ans)
Problem p02754 (python)

Fixed submission:
line = input().rstrip().split(' ')
n = int(line[0])
a = int(line[1])
b = int(line[2])

i = 0
ans = 0

t = int(n / (a + b))
ans = t * a

if n > (a + b) * t:
    t2 = n - (a + b) * t
    if t2 > a:
        ans += a
    else:
        ans += n - (a + b) * t

print(ans)

Buggy submission (verdict: Runtime Error):
line = input().rstrip().split(' ')
n = int(line[0])
a = int(line[1])
b = int(line[2])

i = 0
s = ''
while i <= n:
    s += 'b' * a
    s += 'r' * b
    i += a + b

ans = 0
for i in range(n):
    if s[i] == 'b':
        ans += 1

print(ans)
Problem p02682 (python)

Fixed submission:
a = list(map(int, input().split()))
n = a[0]
m = a[1]
l = a[2]
k = a[3]

if 0 < k <= n:
    print(k)

elif n < k <= n + m:
    print(n)

elif n+m <= k < n+m+l:
    print(n -1*(k -n -m))

elif n+m+l <= k:
    print(n - l)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
if n > k:
    print(n)
elif n + m > k:
    print(n)
else:
    print(n - l)
Problem p02623 (python)

Fixed submission:
import sys
readline = sys.stdin.readline

N, M, K = map(int, readline().split())
A = list(map(int, readline().split()))
B = list(map(int, readline().split()))

a = [0]
b = [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])

max = 0
j = M
for i in range(N+1):
  t = K - a[i]
  if t < 0:
    break
  while b[j] > t:
    j -= 1
  if i + j > max:
    max = i + j
print(max)

Buggy submission (verdict: Runtime Error):
import sys
readline = sys.stdin.readline

N, M, K = map(int, readline().split())
A = list(map(int, readline().split()))
B = list(map(int, readline().split()))

n = 0
m = 0
t = 0
for i in range(N):
  if t + A[i] <= K:
    n += 1
    t += A[i]
  else:
    break
for i in range(M):
  if t + B[i] <= K:
    m += 1
    t += B[i]
  else:
    break
max = n + m
for i in range(N):
  if n == 0 or m == M :
    break
  t -= A[n]
  n -= 1
  for j in range(M):
    if t + B[m + 1] <= K:
      m += 1
      t += B[m]
    else:
      break
    if m == M:
      break
  if n + m > max:
    max = n + m
print(max)
Problem p02699 (python)

Fixed submission:
s, w =map(int, input().split())
if s > w:
  print("safe")
else:
  print("unsafe")

Buggy submission (verdict: Runtime Error):
N = int(input())
l = []
for i in range(N):
  Si = input()
  if not Si in l:
    l.append(Si)
print(len(l))
Problem p02659 (python)

Fixed submission:
from decimal import *
getcontext().prec = 32

a,b= input().split()
d = Decimal(a)*Decimal(b)
print(Decimal(d).quantize(Decimal('0'), rounding=ROUND_DOWN))

Buggy submission (verdict: Runtime Error):
from decimal import *
getcontext().prec = 2

a,b= input().split()
d = Decimal(a)*Decimal(b)
print(Decimal(d).quantize(Decimal('0'), rounding=ROUND_DOWN))
Problem p02711 (python)

Fixed submission:
l = list(input())
 
for i in range(3):
  if l[i] == "7":
    print("Yes")
    exit()
 
print("No")

Buggy submission (verdict: Runtime Error):
l = list(input())

for i in range(3):
  if list[i] == "7":
    print("Yes")
    exit()

print("No")