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

Fixed submission:
N, K  = map(int, input().split())
M = 10 ** 9 + 7

C = [[0 for j in range(N+3)] for i in range(N+3)]
C[1][1] = 1

for i in range(2, N+2):
    for j in range(1, i+2):
        C[i][j] = C[i-1][j] + C[i-1][j-1]

for i in range(1, K+1):
    print(C[N-K+2][i+1] * C[K][i] %  M)

Buggy submission (verdict: Runtime Error):
N, K  = map(int, input().split())
M = 10 ** 9 + 7

C = [[0 for j in range(N+1)] for i in range(N+1)]
C[1][1] = 1

for i in range(2, N):
    for j in range(1, i+2):
        C[i][j] = C[i-1][j] + C[i-1][j-1] % M

for i in range(1, K+1):
    print(C[N-K+2][i+1] * C[K][i] %  M)

Buggy submission (verdict: Runtime Error):
N, K  = map(int, input().split())
M = 10 ** 9 + 7

C = [[0 for j in range(N+1)] for i in range(N+1)]
C[1][1] = 1

for i in range(2, N):
    for j in range(1, i+2):
        C[i][j] = C[i-1][j] + C[i-1][j-1]

for i in range(1, K+1):
    print(C[N-K+2][i+1] * C[K][i] %  M)

Buggy submission (verdict: Runtime Error):
N, K  = map(int, input().split())
M = 10 ** 9 + 7
from math import factorial as f
def c(n, r):
    return f(n)//(f(r)*f(n-r))

def h(s, n):
    return c(s-1, n-1)

for i in range(1, K+1):
    a = h(K, i)
    b = c(N-K+1, i)
    print(a*b%M)
Problem p03045 (python)

Fixed submission:
class DisjointSet:
    def __init__(self):
        self.rank = {}
        self.p = {}

    def makeSet(self, x):
        self.p[x] = x
        self.rank[x] = 0

    def same(self, x, y):
        return self.findSet(x) == self.findSet(y)

    def unite(self, x, y):
        self.link(self.findSet(x), self.findSet(y))

    def link(self, x, y):
        if x == y:
            return
        if(self.rank[x] > self.rank[y]):
            self.p[y] = x
        else:
            self.p[x] = y
            if(self.rank[x] == self.rank[y]):
                self.rank[y] += 1

    def findSet(self, x):
        if(x != self.p[x]):
            self.p[x] = self.findSet(self.p[x])
        return self.p[x]



N, M = map(int, input().split())

ds = DisjointSet()
for i in range(N):
    ds.makeSet(i+1)

for i in range(M):
    X, Y, Z = map(int, input().split())
    ds.unite(X, Y)

ans = set()

for i in range(1, N+1):
    a = ds.findSet(i)
    ans.add(a)

print(len(ans))

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
g = defaultdict(list)

N, M = map(int, input().split())
for i in range(M):
    X, Y, Z = map(int, input().split())
    g[X].append(Y)
    g[Y].append(X)

ans = 0
not_visited = {i:True for i in range(1, N+1)}

def dfs(v):
    if v in not_visited:
        del not_visited[v]
    for c in g[v]:
        if c in not_visited:
            dfs(c)

s = 1
while True:
    dfs(s)
    ans += 1
    if not len(not_visited):
        break
    for v in not_visited.keys():
        s = v
        break

print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
g = defaultdict(list)

N, M = map(int, input().split())
for i in range(M):
    X, Y, Z = map(int, input().split())
    g[X].append(Y)
    g[Y].append(X)

ans = 0
not_visited = {i:True for i in range(1, N+1)}

def dfs(v):
    if v in not_visited:
        del not_visited[v]
    for c in g[v]:
        if c in not_visited:
            dfs(c)

s = 1
while True:
    dfs(s)
    ans += 1
    if not len(not_visited):
        break
    for v in not_visited.keys():
        s = v
        break

print(ans)
Problem p03053 (python)

Fixed submission:
H,W = map(int, input().split())
B = [list(input()) for i in range(H)]

l = []

for i in range(H):
    for j in range(W):
        if B[i][j] == '#':
            l.append((i,j))

def a(l):
    n = []
    d = [(1, 0), (-1, 0), (0, 1), (0, -1)]
    for y, x in l:
        for dy, dx in d:
            ny = y + dy
            nx = x + dx
            if 0 <= ny < H and 0 <= nx < W and B[ny][nx] == '.':
                B[ny][nx] = '#'
                n.append((ny, nx))
    return set(n)

ans = 0
while len(l) != 0:
    l = a(l)
    ans += 1
print(ans-1)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
N = int(input())
A = [int(i) for i in input().split()]
L = [A[0]] * N
R = [A[-1]] * N
for i, a in enumerate(A[1:]):
    L[i+1] = gcd(a, L[i])
for i, a in enumerate(A[::-1][1:]):
    R[i+1] = gcd(a, R[i])
L = [0] + L
R = R[::-1] + [0]
ans = 0
for i in range(N):
    ans = max(ans, gcd(L[i], R[i+1]))
print(ans)
Problem p03127 (python)

Fixed submission:
from functools import reduce
from fractions import gcd
N = int(input())
A = sorted([int(i) for i in input().split()])
print(reduce(lambda a, b: gcd(a, b), A))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = sorted([int(i) for i in input().split()])

if A[0] == A[N-1]:
    print(A[0])
elif all([a % A[0] == 0 for a in A]):
    print(A[0])
elif all([a % 2 == 0 for a in A]):
    print(2)
    exit()
a = sorted(list(set(A)))
a1 = a[0] 
a2 = a[1]
a = max(a1,a2)
b = min(a1,a2)
while a != b:
    t = a - b
    a = max(t, b)
    b = min(t, b)
if a != 0:
    print(a)
else:
    print(1)
Problem p03137 (python)

Fixed submission:
N, M = map(int, input().split())
X = sorted([int(i) for i in input().split()])
d = sorted([X[i] - X[i-1] for i in range(1, M)])
ans = 0
c = 0
for i in d:
    if c > M - N - 1:
        break
    ans += i
    c += 1
print(ans)

Buggy submission (verdict: Runtime Error):
print(d)
Problem p03252 (python)

Fixed submission:
S = input()
T = input()
ans ='Yes'
d = {}
d2 = {}
for s, t in zip(S, T):

    if d.get(s) is not None:
        if d[s] != t:
            ans = 'No'
            break
    else:
        d[s] = t

    if d2.get(t) is not None:
        if d2[t] != s:
            ans = 'No'
            break
    else:
        d2[t] = s

print(ans)

Buggy submission (verdict: Runtime Error):
from math import sqrt, ceil, factorial
from collections import Counter

m = 10**9+7
def is_prime(n):
    if n == 1: return False
    if n == 2: return True
    for i in range(2, ceil(sqrt(n))+1):
        if n % i == 0: return False
    return True

def prime_factorization(n):
    if is_prime(n):return [n]
    factor = []
    f = 2
    while n > 1:
        if n % f == 0:
            factor.append(f)
            n /= f
        else:
            f += 1
    return factor

def comb(n, r):
    a = 1
    for i in range(n-r+1, n+1):
        a *= i
    return a//factorial(r)

N, M = map(int, input().split())
p = prime_factorization(M)
c = Counter(p)
ans = 1
for v in c.values():
    ans *= (comb(v + N - 1, v) % m)
print(ans%m)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
ans ='Yes'
d = {}
for i, (s, t) in enumerate(zip(S, T)):
    if s == t:
        continue
    if d.get(s) is not None or d.get(t) is not None:
        if d[s] != t or d[t] != s:
            ans = 'No'
            break
    d[s] = t
    d[t] = s
    
print(ans)
Problem p03253 (python)

Fixed submission:
from math import sqrt, ceil, factorial
from collections import Counter

m = 10**9+7
def is_prime(n):
    if n == 1: return False
    if n == 2: return True
    for i in range(2, ceil(sqrt(n))+1):
        if n % i == 0: return False
    return True

def prime_factorization(n):
    if is_prime(n):return [n]
    factor = []
    f = 2
    while n > 1:
        if n % f == 0:
            factor.append(f)
            n /= f
        else:
            f += 1
    return factor

def comb(n, r):
    a = 1
    for i in range(n-r+1, n+1):
        a *= i
    return a//factorial(r)

N, M = map(int, input().split())
p = prime_factorization(M)
c = Counter(p)
ans = 1
for v in c.values():
    ans *= (comb(v + N - 1, v) % m)
print(ans%m)

Buggy submission (verdict: Runtime Error):
from math import sqrt, ceil
from collections import Counter
from scipy.special import comb

m = 10**9+7
def is_prime(n):
    if n == 1: return False
    if n == 2: return True
    for i in range(2, ceil(sqrt(n))+1):
        if n % i == 0: return False
    return True

def prime_factorization(n):
    if is_prime(n):return [n]
    factor = []
    for i in range(2, ceil(sqrt(n))+1):
        if not is_prime(i): continue
        q,r = divmod(n, i)
        if r == 0:
            n = q
            factor.append(i)
            q,r = divmod(n, i)
            while r == 0:
                n = q
                factor.append(i)
                q,r = divmod(n, i)
    return factor

N, M = map(int, input().split())
p = prime_factorization(M)
c = Counter(p)
print(c)
ans = 1
for v in c.values():
    ans *= comb(v + N - 1, v, exact=True) % m
print(ans)

Buggy submission (verdict: Runtime Error):
from math import sqrt, ceil
from collections import Counter
from scipy.special import comb

m = 10**9+7
def is_prime(n):
    if n == 1: return False
    if n == 2: return True
    for i in range(2, ceil(sqrt(n))+1):
        if n % i == 0: return False
    return True

def prime_factorization(n):
    if is_prime(n):return [n]
    factor = []
    for i in range(2, ceil(sqrt(n))+1):
        if not is_prime(i): continue
        q,r = divmod(n, i)
        if r == 0:
            n = q
            factor.append(i)
            q,r = divmod(n, i)
            while r == 0:
                n = q
                factor.append(i)
                q,r = divmod(n, i)
    return factor

N, M = map(int, input().split())
p = prime_factorization(M)
c = Counter(p)
print(c)
ans = 1
for v in c.values():
    ans *= comb(v + N - 1, v, exact=True) % m
print(ans)
Problem p03291 (python)

Fixed submission:
S=input()
s=len(S)
dp=[[0,0,0,0]for i in range(s+1)]
dp[s][3]=1
for i in range(s-1,-1,-1):
    for j in[3,2,1,0]:
        dp[i][j]=(3 if S[i]=='?'else 1)*dp[i+1][j]
        if j!=3:dp[i][j]+=(1 if S[i]=='?'or S[i]=='ABC'[j]else 0)*dp[i+1][j+1]
        dp[i][j]%=(10**9+7)
print(dp[0][0])

Buggy submission (verdict: Runtime Error):
????C?????B??????A???????
Problem p03631 (python)

Fixed submission:
N = input()
if N == N[::-1]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
g = {i: []for i in range(1, N+1)}    

cache = {}
def dfs(g,start,end):
    stack = [(start, [start], 0)]
    while stack:
        (v, path, length) = stack.pop()
        for next,l in g[v]:
            if next in path: continue
            if next == end:
                return length + l
            else:
                stack.append((next, path + [next], length + l))

for i in range(N-1):
    a, b, c = map(int,input().split())
    g[a].append((b,c))
    g[b].append((a,c))
Q, K = map(int,input().split())

for v in range(1,N+1):
    cache[v] = dfs(g,v,K)

for q in range(Q):
    x, y = map(int,input().split())
    print(cache[x] + cache[y])
Problem p03634 (python)

Fixed submission:
N = int(input())
g = {i: [] for i in range(1, N+1)}    

l = [0] * (N + 1)

for i in range(N-1):
    a, b, c = map(int,input().split())
    g[a].append((b,c))
    g[b].append((a,c))

Q, K = map(int,input().split())

stack = [K]

while len(stack):
    v = stack.pop()
    for c,ln in g[v]:
        if l[c] != 0:
            continue
        l[c] = l[v] + ln
        stack.append(c)

for q in range(Q):
    x, y = map(int,input().split())
    print(l[x] + l[y])

Buggy submission (verdict: Runtime Error):
N = int(input())
g = {i: [] for i in range(1, N+1)}    

l = [0] * (N + 1)
visited = []
def dfs2(v, p, d):
    l[v] = d
    visited.append(v)
    for i,ln in g[v]:
        if i == p or i in visited:
            continue
        dfs2(i, v, d+ln)

for i in range(N-1):
    a, b, c = map(int,input().split())
    g[a].append((b,c))
    g[b].append((a,c))

Q, K = map(int,input().split())

dfs2(K, -1 , 0)

for q in range(Q):
    x, y = map(int,input().split())
    print(l[x] + l[y])
Problem p03821 (python)

Fixed submission:
N = int(input())
A = []
B = []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

A = A[::-1]
B = B[::-1]

ans = 0
for a, b in zip(A, B):
    a += ans
    if a % b != 0: 
        m = b - (a % b) 
        ans += m
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
B = []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

A = A[::-1]
B = B[::-1]

ans = 0
for a, b in zip(A, B):
    a += ans
    if a % b!= 0:
        m = b - (a % b) 
    ans += m
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = []
B = []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

A = A[::-1]
B = B[::-1]

ans = 0
for a, b in zip(A, B):
    a += ans
    m = b - (a % b) if b != 1 else 0
    m = b if a == 0
    ans += m
print(ans)
Problem p03835 (python)

Fixed submission:
from itertools import  product
K, S = map(int, input().split())
ans = 0
for x,y in product(range(K+1),repeat=2):
    z = S - x - y
    if 0 <= z <= K and x + y + z == S:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
K, S = map(int,input().split())
from itertools import product
ans = 0
for x,y,z in product(range(K+1),3):
  if x + y + z == S:ans += 1
print(ans)
Problem p02659 (python)

Fixed submission:
a,b=input().split()
a=int(a)
b=str(b)
b=b.replace('.','')

b=int(b)
print(a*b//100)

Buggy submission (verdict: Runtime Error):
a,b=input().split()
a=int(a)
b=str(b)
b.replace(".","")
b=int(b)
print(a*b//100)
Problem p02723 (python)

Fixed submission:
s=input()
if s[2]==s[3] and s[4]==s[5]:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s=input()
if s[2]==s[3] and s[4]==s[5]:
    print("Yes")
elif
    print("No")
Problem p02948 (python)

Fixed submission:
import heapq

n,m=map(int,input().split())
task=[[0] for _ in range(m+1)]

for i in range(n):
    a,b=map(int,input().split())
    if a<=m:
        task[a].append(b)

task=task[::-1]

tmp=[]
heapq.heapify(tmp)
ans=0

for i in range(m,-1,-1):
    cnt=0
    for j in task[i]:
        heapq.heappush(tmp,-j)
    cnt=heapq.heappop(tmp)
    ans-=cnt
print(ans)

Buggy submission (verdict: Runtime Error):
import heapq
from heapq import _heappop_max, _heapify_max
n,m=map(int,input().split())
task=[[0] for _ in range(m+1)]

for i in range(n):
    a,b=map(int,input().split())
    if a<=m:
        task[a].append(b)

task=task[::-1]

tmp=[]
heapq.heapify(tmp)
ans=0

for i in range(m,-1,-1):
    cnt=0
    for j in task[i]:
        heapq.heappush(tmp,-j)
    cnt=heapq.heappop(tmp)
    ans-=cnt
print(ans)
Problem p03017 (python)

Fixed submission:
N,A,B,C,D=map(int,input().split())
S=input()
A-=1
B-=1
C-=1
D-=1
if "##" in S[A:C+1] or "##" in S[B:D+1]:
    print('No')
else:
    if C<D:
        print('Yes')
    else:
        if "..." in S[B-1:D+2]:
            print('Yes')
        else:
            print('No')

Buggy submission (verdict: Runtime Error):
n,a,b,c,d=map(int,input().split())
s=input()
flag=True
for i in range(len(s)-1):
    if s[i]=="#" and s[i+1]=="#":
        flag=False
        break

if c<d:
    if flag:
        print("Yes")
    else:
        print("No")
elif c>d:
    flag=False
    for i in range(b,d+1):
        if s[i-1]=="." and s[i]=="." and s[i+1]==".":
            flag=True
            break
    if flag:
        print("Yes")
    else:
        print("No")
Problem p03209 (python)

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

a,p=[1],[1]

for i in range(N):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)

def solve(n,x): #n,x
    if n==0:
        if x<=0:
            return 0
        else:
            return 1
    elif x<=1+a[n-1]:
        return  solve(n-1,x-1)
    else:
        return p[n-1]+1+solve(n-1,x-2-a[n-1])

print(solve(N,X))

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

a,p=[1],[1]

for i in range(N):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)

def solve(n,x): #n,x
    if n==0:
        if x<=0:
            return 0
        else:
            return 1
    elif x<=1+a[N-1]:
        return  solve(N-1,X-1)
    else:
        return p[N-1]+1+solve(N-1,X-2-a[N-1])

print(solve(N,X))
Problem p03252 (python)

Fixed submission:
from collections import defaultdict

S=input()
T=input()
L=len(S)

dds=defaultdict(int)
ddt=defaultdict(int)

for i in range(L):
    s=S[i]
    t=T[i]
    if dds[s]==0:
        dds[s]=t
    else:
        if dds[s]!=t:
            print("No")
            exit()
    if ddt[t]==0:
        ddt[t]=s
    else:
        if ddt[t]!=s:
            print("No")
            exit()
print("Yes")

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

dds=defaultdict(int)
ddt=defaultdict(int)

for i in range(L):
    s=S[i]
    t=T[i]
    if dds[s]==0:
        dds[s]=t
    else:
        if dds[s]!=t:
            print("No")
            exit()
    if ddt[t]==0:
        ddt[t]=s
    else:
        if ddt[t]!=s:
            print("No")
            exit()
print("Yes")
Problem p02779 (python)

Fixed submission:
n = int(input())
nums = list(map(int,input().split()))
c = 0
nums = sorted(nums)

for i in range(n-1):
    if nums[i] == nums[i+1]:
        c += 1
        break
    
if c != 0:
    print('NO')

else:
    print('YES')

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

l = [0]*200001

for num in nums:
    l[num] += 1

if max(l) == 1:
    print('YES')

else:
    print('NO')

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

l = [0]*200001

for num in nums:
    l[num] += 1

if max(nums) == 1:
    print('YES')

else:
    print('NO')
Problem p02831 (python)

Fixed submission:
import fractions
a,b = map(int,input().split())

print((a*b) // fractions.gcd(a,b))

Buggy submission (verdict: Runtime Error):
import math
a,b = map(int,input().split())

print((a*b) // math.gcd(a,b))
Problem p02897 (python)

Fixed submission:
n = int(input())

c = 0
for i in range(1,n+1):
    if i % 2 != 0:
        c += 1

print(c/n)

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

order = []


for i in range(1,n+1):
    order.append(a.index(i)+1)
    

for i in range(n):
    order[i] = str(order[i])

print(' '.join(order))
Problem p03038 (python)

Fixed submission:
from heapq import heappush, heappop

n,m = map(int,input().split())
heap = []

for i in map(int,input().split()):
    heappush(heap,i)

bc = [list(map(int, input().split())) for _ in range(m)]
bc.sort(key = lambda x: -x[1])

for b,c in bc:
    for j in range(b):
        a = heappop(heap)
        if a < c:
            heappush(heap,c)
        
        else:
            heappush(heap, a)
            break
        
print(sum(heap))

Buggy submission (verdict: Runtime Error):
import bisect

n,m = map(int,input().split())
l = list(map(int,input().split()))
b_c = [list(map(int,input().split())) for i in range(m)]
b_c.sort(key=lambda x: x[1],reverse=True)
c_l = []
l.sort()

for i in range(m):
    c_l.extend([b_c[i][1]]*b_c[i][0])


idx = 0
for i in range(len(c_l)):
    if i == len(c_l)-1:
        idx = n-1
        break
    
    if c_l[i] < l[i]:
        idx = i
        break
l.sort(reverse=True)
print(sum(c_l[:idx])+sum(l[:n-idx]))

Buggy submission (verdict: Runtime Error):
import bisect

n,m = map(int,input().split())
l = list(map(int,input().split()))
b_c = [list(map(int,input().split())) for i in range(m)]

l.sort()
b_c.sort(key=lambda x:x[1],reverse=True)

idx = 0
ans = 0

for i in range(m):
    if l[idx:][0] >= b_c[i][1]:
        break
    
    temp = bisect.bisect_left(l[idx:],b_c[i][1])
    if temp > b_c[i][0]:
        temp = b_c[i][0]
    ans += temp*b_c[i][1]
    idx += temp

ans += sum(l[idx:])
print(ans)

Buggy submission (verdict: Runtime Error):
import bisect

n,m = map(int,input().split())
l = list(map(int,input().split()))
b_c = [list(map(int,input().split())) for i in range(m)]

l.sort()
b_c.sort(key=lambda x:x[1],reverse=True)

idx = 0
ans = 0

for i in range(m):
    if l[idx:][0] >= b_c[i][1]:
        break
    
    temp = bisect.bisect_left(l[idx:],b_c[i][1])
    if temp > b_c[i][0]:
        temp = b_c[i][0]
    ans += temp*b_c[i][1]
    idx += temp

ans += sum(l[idx:])
print(ans)

Buggy submission (verdict: Runtime Error):
import bisect

n,m = map(int,input().split())
l = list(map(int,input().split()))
b_c = [list(map(int,input().split())) for i in range(m)]

l.sort()
b_c.sort(key=lambda x:x[1],reverse=True)

print(b_c)

idx = 0
ans = 0

for i in range(m):
    if l[idx:][0] >= b_c[i][1]:
        break
    
    temp = bisect.bisect_left(l[idx:],b_c[i][1])
    if temp > b_c[i][0]:
        temp = b_c[i][0]
    ans += temp*b_c[i][1]
    idx += temp

ans += sum(l[idx:])
print(ans)
Problem p03135 (python)

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

ans = float(T/X)

print(ans)

Buggy submission (verdict: Runtime Error):
N = input().split()

l = list(map(int,input().split()))

c = 0

for i in l:
	if i >= (sum(l) - i):
		c += 1
    
if c == 0:
  print('Yes')
else:
  print('No')
Problem p03242 (python)

Fixed submission:
n =input()

n = n.replace('9','0')
n = n.replace('1','9')
n = n.replace('0','1')
print(n)

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

for i in range(n):
	if n[i] == '9':
		n[i] = '1'
	else:
		n[i] = '9'
print(n)
Problem p03272 (python)

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

print(n-k+1)

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

print(n-k+1)
Problem p03307 (python)

Fixed submission:
n = int(input())

m = 10000000000000000

for i in range(n,m,n):
	if i % 2 == 0:
		print(i)
		break

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())


print(int((b-a)*(b-a+1)/2-b))
Problem p02682 (python)

Fixed submission:
A,B,C,K = map(int, input().split())
num = 0
ans = 0
 
if(A>=K):
  print(K)
elif (A<K) and (K<=(A+B)):
  print(A)
else:
  ans = A-(K-(A+B))
  print(ans)

Buggy submission (verdict: Runtime Error):
A,B,C,K = map(int, input().split())
num = 0
ans = 0
 
if(A>=K):
  print(K)
elif(A<K　and K<=(A+B)):
  print(A)
else:
  ans = A-(K-(A+B))
  print(ans)
Problem p02862 (python)

Fixed submission:
def cmd(n,r,mod=10**9+7):
    fac = [0] * (n+1)
    finv = [0] * (n+1)
    inv = [0]*(n+1)

    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    
    for i in range(2, n+1):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod%i] * (mod//i) % mod
        finv[i] = finv[i-1] * inv[i] % mod

    if n < r: return 0
    if n < 0 or r < 0: return 0
    return (fac[n]*(finv[r]*finv[n-r]%mod)%mod)

x,y  = map(int, input().split())

if (x+y) % 3 != 0:
    print(0)
    exit()

i = (x+y)//3
j = x-i

print(cmd(i,j))

Buggy submission (verdict: Runtime Error):
def cmb(n,r,mod=10**9+7):
    fac = [0] * (n+1)
    finv = [0] * (n+1)
    inv = [0]*(n+1)

    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    
    for i in range(2, n+1):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod%i] * (mod//i) % mod
        finv[i] = finv[i-1] * inv[i] % mod

    if n < r: return 0
    if n < 0 or r < 0: return 0
    return (fac[n]*(finv[r]*finv[n-r]%mod)%mod)

x,y  = map(int, input().split())

if (x+y) % 3 != 0:
    print(0)
    exit()

i = (x+y)//3
j = x-i

print(cmd(i,j))
Problem p02881 (python)

Fixed submission:
import math

N = int(input())

ans = 1e18
for i in range(int(math.sqrt(N)), 0, -1):
    if N%i != 0:
        continue
    j = N/i
    ans = min(ans, i+j-2)
print(int(ans))

Buggy submission (verdict: Runtime Error):
import math

N = int(input())

ans = 1e18
for i in range(int(0,math.sqrt(N))):
    if N%i != 0:
        continue
    j = N/i
    ans = min(ans, i+j-2)
print(int(ans))