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

Fixed submission:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

H, W = map(int, input().split())
grid = [[v for v in input()[:-1]] for _ in range(H)]

Q = []
cnt = 0
for i in range(H):
    for j in range(W):
        if grid[i][j] == "#":
            Q.append([i, j])
            cnt += 1

DX = [-1, 1, 0, 0]
DY = [0, 0, -1, 1]
d = 0
# for _ in range(5):
while cnt < H*W:
    d += 1
    tmp = []
    #print("d->", d)
    # print(Q)
    # print(dist)
    # print(cnt)
    # print("-------")
    for x, y in Q:
        for dx, dy in zip(DX, DY):
            nx = x+dx
            ny = y+dy
            if 0 <= nx < H and 0 <= ny < W:
                if grid[nx][ny] == ".":
                    grid[nx][ny] = "#"
                    tmp.append([nx, ny])
                    cnt += 1
            else:
                continue
    Q = tmp
# print(dist)
print(d)

Buggy submission (verdict: Runtime Error):
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

H, W = map(int, input().split())

grid = [[v for v in input()[:-1]] for _ in range(H)]
dist = [[float('inf')]*W for _ in range(H)]

Q = []
cnt = 0
for row in range(H):
    for col in range(W):
        if grid[row][col] == "#":
            dist[row][col] = 0
            Q.append([row, col])
            cnt += 1

dx = [1, -1, 0, 0]
dy = [0, 0, 1, -1]
current_dist = 0
while cnt < H*W and Q:
    current_dist += 1
    tmp = []
    for sx, sy in Q:
        for x, y in zip(dx, dy):
            new_x = sx+x
            new_y = sy+y
            if 0 <= new_x < H and 0 <= new_y < W:
                if dist[new_x][new_y] == float('inf'):
                    dist[new_x][new_y] = current_dist
                    tmp.append([new_x, new_y])
                    cnt += 1
    Q = tmp
print(d)
Problem p03054 (python)

Fixed submission:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

H, W, N = map(int, input().split())
sr, sc = map(int, input().split())
stS = [v for v in input()[:-1]]
stT = [v for v in input()[:-1]]

ans = "YES"
# T=U,A=D
T = "U"
A = "D"
m = sr
# print("U")
for s, t in zip(stS, stT):
    #print("m->", m)
    if s == T:
        m -= 1
        if m <= 0:
            ans = "NO"
            print(ans)
            exit()
    if t == A:
        if m < H:
            m += 1

T = "D"
A = "U"
m = sr
# print("D")
for s, t in zip(stS, stT):
    #print("m->", m)
    if s == T:
        m += 1
        if m > H:
            ans = "NO"
            print(ans)
            exit()
    if t == A:
        if m > 1:
            m -= 1

T = "R"
A = "L"
m = sc
# print("R")
for s, t in zip(stS, stT):
    #print("m->", m)
    if s == T:
        m += 1
        if m > W:
            ans = "NO"
            print(ans)
            exit()
    if t == A:
        if m > 1:
            m -= 1
T = "L"
A = "R"
m = sc
# print("L")
for s, t in zip(stS, stT):
    #print("m->", m)
    if s == T:
        m -= 1
        if m <= 0:
            ans = "NO"
            print(ans)
            exit()
    if t == A:
        if m < H:
            m += 1
print(ans)

Buggy submission (verdict: Runtime Error):
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

H,W,N=map(int,input().split())

sr,sc=map(int,input().split())
S=input()[:-1]
T=input()[:-1]

#gridのindexは入力値のまま扱う(grid=[1,1]~[H,W])
#left<x<rightの間が生存範囲(初めはグリッド全てが生存可能状態)
left=0
right=W+1
up=0
down=H+1

ans="YES"
#手を逆順で見ていく。
for s,t in zip(reversed(S),reversed(T)):
    if t=='R':#生存可能範囲を広げる(0より小さくならないようにする)
        left=max(0,left-1)
    elif t=="L":
        right=min(W+1,right+1)
    elif t=="D":
        up = max(0,up-1)
    else:
        down=min(H+1,down+1)


    if s=="R"
        right-=1
    elif s=="L":
        left+=1
    elif s=="D":
        down-=1
    else:
        up+=1

    #もし、途中でright-left==1。つまり、生存可能範囲がなくなってしまったら、
    #落とされてしまうため、ans=NOにして終了する
    if right-left==1 or down-up==1:
        ans="NO"
        break

#全ての手を見た後で、スタート地点が生存可能範囲に入っていればOK
if not left<sc<right or not up<sr<down:
    ans="NO"
print(ans)

Buggy submission (verdict: Runtime Error):
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

H,W,N=map(int,input().split())

sr,sc=map(int,input().split())
S=input()[:-1]
T=input()[:-1]

left=0
right=W+1
up=0
down=H+1

ans="YES"
for i,(s,t) in enumerate(zip(reversed(S),reversed(T))):
    if i!=0:
        if t=='R':
            left=max(0,left-1)
        elif t=="L":
            right=min(W+1,right+1)
        elif t=="D":
            up = max(0,up-1)
        else:
            down=min(H+1,down+1)


    if s=="R":
        right-=1
    elif s=="L":
        left+=1
    elif s=="D":
        down-=1
    else:
        up+=1

    if right-left==1 or down-upp==1:
        ans="NO"
        break

if not left<sc<right or not up<sr<down:
    ans="NO"
print(ans)
Problem p03077 (python)

Fixed submission:
N=int(input())
L=[int(input()) for _ in range(5)]
print(5 if min(L)>=N else 4 -((-N)//min(L)))

Buggy submission (verdict: Runtime Error):
from math import ceil
N=int(input())
L=[int(input()) for _ in range(5)]
print(5 if min(L)>=5 else 4 +ceil(N/min(L))

Buggy submission (verdict: Runtime Error):
N=int(input())
L=[int(input()) for _ in range(5)]
print(5 if min(L)>=5 else 4 -((-N)//min(L))
Problem p03222 (python)

Fixed submission:
h, w, k = (list)(map(int, input().split()))

mat = [[0 for _ in range(w)] for __ in range(h+1)]
mat[0][0] = 1


def num(n):
    ret = 0
    if n == 0:
        return 1
    for i in range(2**(n-1)):
        dig = format(i, 'b')
        if not '11' in dig:
            ret += 1

    return ret


if w == 1:
    print('1')
    exit()

for col in range(1, h+1):
    for row in range(w):
        if row == 0:
            mat[col][row] = mat[col-1][row] * \
                num(w-1) + mat[col-1][row+1]*num(w-2)
        elif row == w-1:
            mat[col][row] = mat[col-1][row] * \
                num(w-1) + mat[col-1][row-1]*num(w-2)
        else:
            mat[col][row] = mat[col-1][row] * (num(row)*num(w-row-1)) \
                + mat[col-1][row-1]*(num(row-1)*num(w-row-1))\
                + mat[col-1][row+1]*(num(row)*num(w-row-2))
print(mat[h][k-1] % 1000000007)

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

mat = [[0 for i in range(w)] for j in range(h)]
mat[0][0]=1

for i in range(1,h):
    for j in range(w):
        if j==0:
            mat[i][j]=mat[i-1][j]+mat[i-1][j+1]
        elif j==w-1:
            mat[i][j]=mat[i-1][j]+mat[i-1][j-1]
        else:
            mat[i][j]=mat[i-1][j]+mat[i-1][j-1]+mat[i-1][j+1]

print(mat[h-1][k-1] % 1000000007)
Problem p03242 (python)

Fixed submission:
s=str(input())
dst=s.translate({
    ord('1'):'9',
    ord('9'):'1',
    })
print(dst)

Buggy submission (verdict: Runtime Error):
import collections
n = (int)(input())
l = list(map(int,input().split()))
a = l[::2]
b=l[1::2]

a_c=collections.Counter(a).most_common()
b_c=collections.Counter(b).most_common()
if a_c[0][0]==b_c[0][0]:
    if a_c[0][1]==b_c[0][1]:
        print(n//2)
    elif a_c[0][1]>b_c[0][1]:
        if len(b_c)>1:
            print(n-a_c[0][1]-b_c[1][1])
        else:
            print(n-a_c[0][1])
    else:
        if len(a_c)>1:
            print(n-a_c[1][1]-b_c[0][1])
        else:
            print(n-b_c[0][1])
else:
    print(n-a_c[0][1]-b_c[0][1])
Problem p03250 (python)

Fixed submission:
l=list(map(int,input().split()))
l=sorted(l,reverse=True)
print(l[0]*10+l[1]+l[2])

Buggy submission (verdict: Runtime Error):
mod = 10 ** 9 + 7
n, m = map(int, input().split())

f = []
p = 2
while p * p <= m:
    if m % p != 0:
        p += 1
        continue
    c = 0
    while m % p == 0:
        c += 1
        m //= p
    f.append(c)
    p += 1
if m != 1:
    f.append(1)


def comb(a, b):
    ret = 1
    r = min(b, a-b)
    for i in range(a-r+1, a+1):
        ret *= i
    for j in range(1, r+1):
        ret /= j
    return (int)(ret)


res = 1
for ele in f:
    ret = comb(ele+n-1, n-1)
    res *= ret

print(res % mod)
Problem p03252 (python)

Fixed submission:
import collections
s=(str)(input())
t=(str)(input())

s_c=collections.Counter(s)
s_t=collections.Counter(t)
for i in range(len(s_c)):
    if s_c.get(s[i]) != s_t.get(t[i]):
        print("No")
        exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
mod = 10 ** 9 + 7
n, m = map(int, input().split())

f = []
p = 2
while p * p <= m:
    if m % p != 0:
        p += 1
        continue
    c = 0
    while m % p == 0:
        c += 1
        m //= p
    f.append(c)
    p += 1
if m != 1:
    f.append(1)


def comb(a, b):
    ret = 1
    r = min(b, a-b)
    for i in range(a-r+1, a+1):
        ret *= i
    for j in range(1, r+1):
        ret //= j
    return (int)(ret)


ans = 1
for i in f:
    c = 1
    for j in range(i):
        c = c * (n+j) // (j+1)
    ans *= c
print(ans % mod)
Problem p03253 (python)

Fixed submission:
import math
mod = 10 ** 9 + 7
n, m = map(int, input().split())

f = []
p = 2
while p * p <= m:
    if m % p != 0:
        p += 1
        continue
    c = 0
    while m % p == 0:
        c += 1
        m //= p
    f.append(c)
    p += 1
if m != 1:
    f.append(1)


def comb(a, b):
    ret = 1
    r = min(b, a-b)
    for i in range(a-r+1, a+1):
        ret *= i
    for j in range(1, r+1):
        ret //= j

    return (int)(ret)


ans = 1
for i in f:
    ans *= comb(i+n-1, i)
print(ans % mod)

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

l_prime = [0]*(n+1)
N = n
ran = range(3, N+1)

while n % 2 == 0:
    l_prime[2] += 1
    n /= 2

for i in ran:
    while n != 1:
        if n % i == 0:
            n /= i
            l_prime[i] += 1
        else:
            i += 2


def fact(n):
    tmp = 1
    while n != 0:
        tmp *= n
        n -= 1

    return tmp


def comb(a, b):
    if a < b:
        print("err")

    return (int)(fact(a)/(fact(a-b)*fact(b)))


res = 1
for i in range(1, N+1):
    ele = l_prime[i]
    if ele != 0:
        ret = comb(ele+m-1, ele)
        res *= ret

print(res % (10**9+1))
Problem p03307 (python)

Fixed submission:
N = int(input())
if N%2==0:
  print(N)
else:
  print(2*N)

Buggy submission (verdict: Runtime Error):
print((lambda x:x+x*(x%2)))(int(input()))

Buggy submission (verdict: Runtime Error):
print(map(lambda x:x*((x%2*2),int(input()))

Buggy submission (verdict: Runtime Error):
if N%2==0:
	print(N)
else:
	print(2*N)

Buggy submission (verdict: Runtime Error):
#include<iostream>
using namespace std;

int main(){
    int n;
    cin >> n;
    if (n%2==0){
        cout<< n << endl;
    }else{
        cout << 2*n <<endl;
    }
}

Buggy submission (verdict: Runtime Error):
def median_low(A):
    A.sort()
    b=A
    n = len(A)
    if n%2==1:
        med =b[n//2]
    else:
        x=b[n//2-1]
        y=b[n//2]
        med=(x+y)/2
        if med!=int(med):
            med=x
        else:
            med=int(med)
    return med


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

A = [v-i-1 for i,v in enumerate(A)]
x = median_low(A)

print(sum(abs(v - x) for v in A))
Problem p03317 (python)

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

print(-(-(n-1)//(k-1)))

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

if n <= k:
  print(1)
else:
  print(n//k+1
Problem p03326 (python)

Fixed submission:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, M = map(int, input().split())
cakes = []
for _ in range(N):
    cakes.append(list(map(int, input().split())))


def sum_cake(a, b, c):
    ret = []
    for x in cakes:
        ret.append(x[0]*a+x[1]*b+x[2]*c)

    ret = sorted(ret, reverse=True)
    return sum(ret[:M])


def solve2():
    ans = 0
    p = [1, -1]
    for a in p:
        for b in p:
            for c in p:
                ans = max(sum_cake(a, b, c), ans)
    print(ans)


solve2()

Buggy submission (verdict: Runtime Error):
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def point(p):
    ret = 0
    for a in p:
        ret += abs(a)
    return ret


def add(p1, p2):
    ret = []
    for a, b in zip(p1, p2):
        ret.append(a+b)
    return ret


def bigger(p1, p2):
    return point(p1) > point(p2)


N, M = map(int, input().split())
cakes = []
for _ in range(N):
    cakes.append(list(map(int, input().split())))


def solve():
    dp = [[0, 0, 0] for _ in range(M+1)]

    used = []
    for i in range(1, M+1):
        tmp = [0, 0, 0]
        for c in cakes:
            n = add(dp[i-1], c)
            if bigger(n, tmp):
                tmp = n
                used = c
        dp[i] = tmp
        #print("dp->", dp)
        cakes.remove(used)

    # print(dp[-1])
    print(point(dp[-1]))


solve()
Problem p03332 (python)

Fixed submission:
# -*- coding: utf-8 -*-


class FactMod():
    '''
    modの値が素数の時のfactと組み合わせを求める
    フェルマーの小定理を用いているため、modが素数以外の時は使えない
    '''

    def __init__(self, n, mod):
        '''
        コンストラクタ
        f:nまでの i!の値を　配列に入れる
        inv: (i!)^-1　の値を配列に入れる
        '''
        self.mod = mod
        self.f = [1]*(n+1)
        for i in range(1, n+1):
            self.f[i] = self.f[i-1]*i % mod

        self.inv = [pow(self.f[-1], mod-2, mod)]
        for i in range(1, n+1)[::-1]:
            self.inv.append(self.inv[-1]*i % mod)
        self.inv.reverse()

    def fact(self, n):
        '''
        n!の値を返す
        '''
        return self.f[n]

    def comb(self, n, r):
        '''
        nCrの値を返す
        '''
        ret = self.f[n] * self.inv[n-r]*self.inv[r]
        ret %= self.mod
        return ret

    def perm(self, n, r):
        """
        nPrの値を返す
        """
        ret = self.f[n] * self.inv[n-r]
        ret %= self.mod
        return ret

N,A,B,K = map(int,input().split())
ans=0
MOD=998244353

F=FactMod(N+1,MOD)

for a in range(N+1):
    Ascore = a*A
    Bscore=K-Ascore
    if Bscore%B==0:
        b=Bscore//B
        if 0<=b<=N:
            ans+=(F.comb(N,a)*F.comb(N,b))%MOD
            ans%=MOD
print(ans)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-


class FactMod():
    '''
    modの値が素数の時のfactと組み合わせを求める
    フェルマーの小定理を用いているため、modが素数以外の時は使えない
    '''

    def __init__(self, n, mod):
        '''
        コンストラクタ
        f:nまでの i!の値を　配列に入れる
        inv: (i!)^-1　の値を配列に入れる
        '''
        self.mod = mod
        self.f = [1]*(n+1)
        for i in range(1, n+1):
            self.f[i] = self.f[i-1]*i % mod

        self.inv = [pow(self.f[-1], mod-2, mod)]
        for i in range(1, n+1)[::-1]:
            self.inv.append(self.inv[-1]*i % mod)
        self.inv.reverse()

    def fact(self, n):
        '''
        n!の値を返す
        '''
        return self.f[n]

    def comb(self, n, r):
        '''
        nCrの値を返す
        '''
        ret = self.f[n] * self.inv[n-r]*self.inv[r]
        ret %= self.mod
        return ret

    def perm(self, n, r):
        """
        nPrの値を返す
        """
        ret = self.f[n] * self.inv[n-r]
        ret %= self.mod
        return ret

N,A,B,K = map(int,input().split())
ans=0
MOD=10**9+7

F=FactMod(N+1,MOD)

for a in range(1,N+1):
    Ascore = a*A
    Bscore=K-Ascore
    if Bscore%B==0:
        b=Bscore//B
        ans+=F.comb(N,a)*F.comb(N,b)
        ans%=MOD
print(ans)
Problem p03426 (python)

Fixed submission:
# use faster method than input()
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def manhattan(pos1, pos2):
    return abs(pos1[0]-pos2[0]) + abs(pos2[1]-pos1[1])


H, W, D = map(int, input().split())
A = [(0, 0)]*(H*W)
for r in range(H):
    l = list(map(int, input().split()))
    for c in range(W):
        A[l[c]-1] = (r, c)

dist = [0]*(H*W)
for i in range(D, H*W):
    dist[i] = dist[i-D]+manhattan(A[i], A[i-D])


Q = int(input())
L = []

ans_list = [0]*Q
for i in range(Q):
    ans = 0
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    ans = dist[b]-dist[a]
    ans_list[i] = ans

for ans in ans_list:
    print(ans)

Buggy submission (verdict: Runtime Error):
# use faster method than input()
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def manhattan(pos1, pos2):
    return abs(pos1[0]-pos2[0]) + abs(pos2[1]-pos1[1])


H, W, D = map(int, input().split())
A = [(0, 0)]*(H*W)
for r in range(H):
    l = list(map(int, input().split()))
    for c in range(W):
        A[l[c]-1] = (r, c)

dist = [0]*(H*W)
for i in range(D, H*W):
    dist[i] = dist[i-D]+manhattan(A[i], A[i+D])


Q = int(input())
L = []

ans_list = [0]*Q
for i in range(Q):
    ans = 0
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    ans = dist[b]-dist[a]
    ans_list[i] = ans

for ans in ans_list:
    print(ans)
Problem p03634 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**6)
N = (int)(input())
edges = []
for _ in range(N-1):
    edges.append((list)(map(int, input().split())))

Q, K = (list)(map(int, input().split()))
querys = []
for _ in range(Q):
    querys.append((list)(map(int, input().split())))

'''
 N:num of nodes
 Q: num of query
 K: node must passed in query

'''
dist = [-1]*(N+1)
for e in edges:
    if dist[e[0]] == -1:
        dist[e[0]] = [[e[1], e[2]]]
    else:
        dist[e[0]].append([e[1], e[2]])

    if dist[e[1]] == -1:
        dist[e[1]] = [[e[0], e[2]]]
    else:
        dist[e[1]].append([e[0], e[2]])

dist_from_k = [-1]*(N+1)


def dfs(v, cost):
    if dist_from_k[v] != -1:
        return

    dist_from_k[v] = cost
    for e in dist[v]:
        dfs(e[0], cost+e[1])


dfs(K, 0)

for q in querys:
    print(dist_from_k[q[0]] + dist_from_k[q[1]])

Buggy submission (verdict: Runtime Error):
N = (int)(input())
edges = []
for _ in range(N-1):
    edges.append((list)(map(int, input().split())))

Q, K = (list)(map(int, input().split()))
querys = []
for _ in range(Q):
    querys.append((list)(map(int, input().split())))

'''
 N:num of nodes
 Q: num of query
 K: node must passed in query

'''
dist = [-1]*(N+1)
for e in edges:
    if dist[e[0]] == -1:
        dist[e[0]] = [[e[1], e[2]]]
    else:
        dist[e[0]].append([e[1], e[2]])

    if dist[e[1]] == -1:
        dist[e[1]] = [[e[0], e[2]]]
    else:
        dist[e[1]].append([e[0], e[2]])

dist_from_k = [-1]*(N+1)


def dfs(v, p, cost):
    if dist_from_k[v] != -1:
        return

    dist_from_k[v] = cost
    for e in dist[v]:
        if e[0] == p:
            continue
        dfs(e[0], v, cost+e[1])


dfs(K, -1, 0)

for q in querys:
    print(dist_from_k[q[0]] + dist_from_k[q[1]])

Buggy submission (verdict: Runtime Error):
N = (int)(input())
edges = []
for _ in range(N-1):
    edges.append((list)(map(int, input().split())))

Q, K = (list)(map(int, input().split()))
querys = []
for _ in range(Q):
    querys.append((list)(map(int, input().split())))

'''
 N:num of nodes
 Q: num of query
 K: node must passed in query

'''
dist = [-1]*(N+1)
for e in edges:
    if dist[e[0]] == -1:
        dist[e[0]] = [[e[1], e[2]]]
    else:
        dist[e[0]].append([e[1], e[2]])

    if dist[e[1]] == -1:
        dist[e[1]] = [[e[0], e[2]]]
    else:
        dist[e[1]].append([e[0], e[2]])

dist_from_k = [-1]*(N+1)


def dfs(v, cost):
    if dist_from_k[v] != -1:
        return

    dist_from_k[v] = cost
    for e in dist[v]:
        dfs(e[0], cost+e[1])


dfs(K, 0)

for q in querys:
    print(dist_from_k[q[0]] + dist_from_k[q[1]])
Problem p03652 (python)

Fixed submission:
from collections import Counter
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


N, M = map(int, input().split())
mat = [list(map(lambda x:int(x)-1, input().split())) for _ in range(N)]

ans = N
Q = [set([v for v in range(M)])]
while Q:
    C = Counter()
    sports_cand = Q.pop(0)
    for n in range(N):
        for m in range(M):
            if mat[n][m] in sports_cand:
                C[mat[n][m]] += 1
                break
    tmp = 0
    for key, val in C.most_common():
        if val > tmp:
            tmp = val
            ans = min(ans, val)
            if len(sports_cand) > 2:
                Q.append(sports_cand-{key})
        else:
            break
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import Counter
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


N, M = map(int, input().split())
mat = [list(map(lambda x:int(x)-1, input().split())) for _ in range(N)]

ans = N
Q = [set([v for v in range(M)])]
while Q:
    C = Counter()
    sports_cand = Q.pop(0)
    for n in range(N):
        for m in range(M):
            if mat[n][m] in sports_cand:
                C[mat[n][m]] += 1
                break
    tmp = 0
    rem_key = {}
    for key, val in C.most_common():
        if val >= tmp:
            tmp = val
            ans = min(ans, val)
            rem_key.add(key)
        else:
            break
    if len(sports_cand) > 2:
        Q.append(sports_cand-rem_key)
print(ans)
Problem p03723 (python)

Fixed submission:
def log_2(n):
    t = 0
    while n:
        if n % 2 == 1:
            break
        t += 1
        n //= 2
    return t


def solve(A, B, C)->int:

    s = A+B+C
    odd = min(log_2(s-A), log_2(s-B), log_2(s-C))
    even = min(log_2(s+A), log_2(s+B), log_2(s+C))

    if odd == even:
        return odd
    else:
        return odd+1


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

ans = 0
if A % 2 == 1 or A % 2 == 1 or A % 2 == 1:
    ans = 0
elif A == B == C:
    ans = -1
else:
    ans = solve(A, B, C)
print(ans)

Buggy submission (verdict: Runtime Error):
def log_2(n):
    t = 0
    while n:
        if n % 2 == 1:
            break
        t += 1
        n //= 2
    return t


def solve(A, B, C)->int:

    s = A+B+C
    odd = log_2(s-C)
    even = log_2(s+A)

    if odd == even:
        return odd
    else:
        return odd+1


A, B, C = map(int, input().split())
A, B, C = sort([A, B, C])

ans = 0
if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
    ans = 0
elif A == B == C:
    ans = -1
else:
    ans = solve(A, B, C)
print(ans)
Problem p03724 (python)

Fixed submission:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
N, M = map(int, input().split())
node = [0]*(N+1)
for _ in range(M):
    a, b = map(lambda x: int(x)-1, input().split())
    node[a] += 1
    node[b] += 1

if all(x % 2 == 0 for x in node):
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, M = int(input())
node = [0]*(N+1)
for _ in range(M):
    a, b = map(lambda x: int(x)-1, input().split())
    node[a] += 1
    node[b] += 1

if all(x % 2 == 0 for x in node):
    print("YES")
else:
    print("NO")