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

Fixed submission:
def gcd(a,b):
    if b == 0:
        return a
    if b > a:
        return gcd(b,a)
    return gcd(b,a%b)

def main():
    a,b = map(int,input().split())
    g = gcd(max(a,b),min(a,b))
    lcm = a*b//g

    print(lcm)

main()

Buggy submission (verdict: Runtime Error):
import math

def main():
    a,b = map(int,input().split())
    gcd = math.gcd(max(a,b),min(a,b))
    lcm = a*b//gcd

    print(lcm)

main()
Problem p02552 (python)

Fixed submission:
print(1-int(input()))

Buggy submission (verdict: Runtime Error):
print(1-int(input())
Problem p02659 (python)

Fixed submission:
a,b=input().split()
a=int(a)
intb=int(b[0])
flob=int(b[2:])
ans=(a*100*intb+a*flob)//100
print(ans)

Buggy submission (verdict: Runtime Error):
a,b=[int(s) for s in input().split()]
print(int(a*b))
Problem p02712 (python)

Fixed submission:
N=int(input())
ans=0
for i in range(N+1):
  if i%3!=0 and i%5!=0:
    ans+=i
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
ans=0
for i in range(N+1):
  if i%3!=0 and a%5!=0:
    ans+=i
print(ans)
Problem p02757 (python)

Fixed submission:
N,P=[int(s) for s in input().split()]
S=list(input())
if P!=2 and P!=5:
  ls=[0 for _ in range(N)]
  mod=[0 for _ in range(P)]
  d=10
  ls[0]=int(S[-1])%P
  mod[ls[0]]+=1
  for i in range(1,N):
    ls[i]=(ls[i-1]+d*int(S[-1-i]))%P
    d=(d*10)%P
    mod[ls[i]]+=1
  #print(ls)
  #print(mod)  
  ans=mod[0]
  for i in range(N):
    m=ls[i]
    mod[ls[i]]-=1
    ans+=mod[ls[i]]
else:
  ans=0
  for i in range(N):
    if int(S[i])%P==0:
      ans+=i+1
print(ans)

Buggy submission (verdict: Runtime Error):
N,P=[int(s) for s in input().split()]
S=list(input())
if P!=2 and P!=5:
  ls=[0 for _ in range(N)]
  mod=[0 for _ in range(P)]
  d=10
  ls[0]=int(S[-1])
  mod[ls[0]]+=1
  for i in range(1,N):
    ls[i]=(ls[i-1]+d*int(S[-1-i]))%2019
    d=(d*10)%2019
    mod[ls[i]]+=1
  #print(ls)
  #print(mod)  
  ans=mod[0]
  for i in range(N):
    m=ls[i]
    mod[ls[i]]-=1
    ans+=mod[ls[i]]
else:
  ans=0
  for i in range(N):
    if int(S[i])%P==0:
      ans+=i+1
print(ans)
Problem p02897 (python)

Fixed submission:
x=int(input())
y=x//2
z=x-y
print(z/x)

Buggy submission (verdict: Runtime Error):
x=int(input())
y=x//2
z=x-y
print(z/y)

Buggy submission (verdict: Runtime Error):
x=int(input())
y=x//2
z=x-1
print(z/y)
Problem p02970 (python)

Fixed submission:
import math

N,D = [int(s) for s in input().split()]
print(math.ceil(N/(2*D+1)))

Buggy submission (verdict: Runtime Error):
N,D = [int(s) for s in input().split()]
print(math.ceil(N/(2*D+1)))
Problem p02989 (python)

Fixed submission:
N=int(input())
ls=[int(s) for s in input().split()]
ls.sort()
print(ls[N//2]-ls[N//2-1])

Buggy submission (verdict: Runtime Error):
N=input()
ls=[int(s) for s in input().split()]
ls.sort()
print(ls[N//2]-ls[N//2-1])
Problem p03075 (python)

Fixed submission:
ls=[]
for i in range(5):
  ls.append(int(input()))
ls.sort()
if ls[4]-ls[0]>int(input()):
  print(":(")
else:
  print("Yay!")

Buggy submission (verdict: Runtime Error):
ls=[]
for i in range(5):
  ls.append(int(input()))
ls.sort()
if ls[4]-ls[0]>k:
  print(":(")
else:
  print("Yay!")
Problem p03286 (python)

Fixed submission:
n=int(input())
if n==0:
  print('0')
else:
  ls=[]
  while(n!=0):
    ls.append(str(n%2))
    n=-1*(n-n%2)//2
  ls.reverse()
  oneLinerString="".join(ls)
  print(oneLinerString)

Buggy submission (verdict: Runtime Error):
n=int(input())
if n==0:
  print('0')
else:
  ls=[]
  while(n!=0):
    ls.append(n%2)
    n=-1*(n-n%2)//2
ls.sort(reverse:True)
print(ls)
Problem p03317 (python)

Fixed submission:
N,K=[int(s) for s in input().split()]
x=1
for i in range(1,N):
  x+=(K-1)
  if x>=N:
    print(i)
    break

Buggy submission (verdict: Runtime Error):
N,K=[int(s) for s in input().split()]
ls=[int(s) for s in input().split()]
def ceil(n,m):
  if n%m==0:
    return n//m
  else:
    return (n//m)+1
a=ls.index(1)
if K==N:
  print(1)
elif (K==N-1 and (a==0 or a==N-1)):
  print(1):
else:
  print(ceil(a,K-1)+ceil(N-a-1,K-1))
Problem p03327 (python)

Fixed submission:
x=int(input())
a=x//1000
if a==0:
  print("ABC")
else:
  print("ABD")

Buggy submission (verdict: Runtime Error):
x=int(input())
a=x//999
b=x%999+1000
B=text(b)
C=B[1:]
if a==0:
  print("ABC"+C)
else:
  print("ABD"+C)
Problem p02659 (python)

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

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

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

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

Buggy submission (verdict: Runtime Error):
a,b = map(double,input().split())
print(int(a*b))
Problem p02779 (python)

Fixed submission:
n=int(input())
al=list(map(int,input().split()))
if len(al)==len(list(set(al))):
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
n=int(input())
al=list(map(int,input().split())
if len(al)==len(set(al)):
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
n=int(input())
al=list(map(int,input().split())
if al==set(al):
    print('YES')
else:
    print('NO')
Problem p02820 (python)

Fixed submission:
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=list(input())

dp=[0]*n
a = {"r":p, "s":r, "p":s}

for i in range(n):
    if i>=k and t[i]==t[i-k]: # どうせ得点できないので、次に影響しないように'x'
        dp[i]=0
        t[i]='x'
    else:
        dp[i]=a[t[i]]   
print(sum(dp))

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

dp=[0]*n
a = {"r":p, "s":r, "p":s}

for i in range(n):
    if i>=k and t[i]==t[i-k]: # どうせ得点できないので、次に影響しないように'x'
        dp[i]=0
        t[i]='x'
    else:
        dp[i]=d[t[i]]   
print(sum(dp))
Problem p02831 (python)

Fixed submission:
a, b = map(int, input().split())
m,n=max(a,b),min(a,b)
if m%n==0:
    print(m)
else:
    while m%n!=0 and n!=1:
        m%=n
        m,n=max(m,n),min(m,n)
    print(int(a*b/n))

Buggy submission (verdict: Runtime Error):
import fractions
a,b=map(int, input().split())
f2=a*b//f # 最小公倍数はf2
print(f2)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
m,n=max(a,b),min(m,n)
while m%n!=0:
    m%=n
    m,n=max(m,n),min(m,n)
print(int(a*b/n))

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

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

Fixed submission:
from collections import deque

H,W=map(int,input().split())
S=[input() for _ in range(H)]

paint=((1,0),(-1,0),(0,1),(0,-1))
que=deque([])

dark=[[0]*W for _ in range(H)] # 1が黒、0はまだ白

for i in range(H): # 初期化(最初に黒いマスをdarkリストに入れて、キューに入れる。)
    for j in range(W):
        if S[i][j]=='#':
            que.append((i,j,0))
            dark[i][j]=1
ans=0
while len(que)>0:
    di,dj,c=que.popleft()
    
    for pi,pj in paint:
        ni,nj=pi+di,pj+dj # 移動先がni,nj
        if 0<=ni<H and 0<=nj<W and dark[ni][nj]==0:
            dark[ni][nj]=1
            que.append((ni,nj,c+1))
            ans=c+1
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque

H,W=map(int,input().split())
S=[input() for _ in range(H)]

paint=((1,0),(-1,0),(0,1),(0,-1))
que=deque([])

dark=[[0]*W for _ in range(H)] # 1が黒、0はまだ白

for i in range(H): # 初期化(最初に黒いマスをdarkリストに入れて、キューに入れる。)
    for j in range(W):
        if S[i][j]=='#':
            que.append((i,j,0))
            dark[i][j]=1

while len(que)>0:
    di,dj,c=que.popleft()
    
    for pi,pj in paint:
        ni,nj=pi+di,pj+dj # 移動先がni,nj
        if 0<=ni<H and 0<=nj<W and dark[ni][nj]==0:
            dark[ni][nj]=1
            que.append((ni,nj,c+1))
            ans=c+1
print(ans)
Problem p02793 (python)

Fixed submission:
from fractions import gcd
n=int(input())
a=list(map(int,input().split()))
b=1
for i in a:
  b=b//gcd(b,i)*i
ans=0
for i in a:
  ans+=(b//i)
print(ans%(10**9+7))

Buggy submission (verdict: Runtime Error):
from fraction import gcd
n=int(input())
a=list(map(int,input().split()))
b=1
for i in a:
  b=gcd(b,i)
ans=0
for i in a:
  ans+=(b//i)
print(ans%(10**9+7))

Buggy submission (verdict: Runtime Error):
from fraction import gcd
n=int(input())
a=list(map(int,input().split()))
t=1
for i in a:
  t=t/gcd(t,i)*i
ans=0
MOD=1000000007
for i in a:
  ans+=t/i
  ans%=MOD
print(ans)
Problem p03013 (python)

Fixed submission:
n,m=map(int,input().split())
dp=[1]*(n+1)
for i in range(m):
  dp[int(input())]=0
for i in range(2,n+1):
  if dp[i]>0:
    dp[i]=dp[i-1]+dp[i-2]
print(dp[n]%1000000007)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input()split())
dp=[1]*(n+1)
for i in range(m):
  dp[int(input())]=0
for i in range(2,n+1):
  if dp[i]>0:
    dp[i]=dp[i-1]+dp[i-2]
print(dp[n])
Problem p03186 (python)

Fixed submission:
a,b,c=map(int,input().split())
print(b+min(a+b+1,c))

Buggy submission (verdict: Runtime Error):
a,b,c=int(input().split())
print(b+min(a+b+1,c))
Problem p03307 (python)

Fixed submission:
_=int(input())
print(_<<(_&1))

Buggy submission (verdict: Runtime Error):
o=input()
a=list(map(int,input().split()))
print(max(a)-min(a))

Buggy submission (verdict: Runtime Error):
input()
a=list(map(int,input().split()))
print(max(a)-min(a))
Problem p03631 (python)

Fixed submission:
s=input()
if(s[0]==s[2]):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
import fractions
n=int(input())
a=1
for i in range(n):
  b=int(input())
  a=a//fractions.gcd(a,b)*b
print(int(a))
Problem p03723 (python)

Fixed submission:
def f(a,b,c):
  if a%2+b%2+c%2>0:
    return 0
  if a==b==c:
    return -1
  return f((b+c)//2,(c+a)//2,(a+b)//2)+1

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

Buggy submission (verdict: Runtime Error):
def(a,b,c):
  if a%2+b%2+c%2>0:
    return 0
  if a==b==c:
    return -1
  return f((b+c)//2,(c+a)//2,(a+b)//2)+1

a,b,c=map(int,input().split())
print(f(a,b,c))
Problem p02552 (python)

Fixed submission:
x = int(input())

if x == 0:
    print(1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
x = int(input())

if x == 0:
    print(1)
else x == 1:
    print(0)
Problem p02580 (python)

Fixed submission:
h, w, m = map(int, input().split())
h_cnt = [0] * h
w_cnt = [0] * w

bomb_set = set()

for i in range(m):
    h_, w_ = map(int, input().split())
    h_ -= 1
    w_ -= 1
    h_cnt[h_] += 1
    w_cnt[w_] += 1
    bomb_set.add((h_, w_))

max_h = max(h_cnt)
max_h_idx = []
for i in range(h):
    if h_cnt[i] == max_h:
        max_h_idx.append(i)

max_w = max(w_cnt)
max_w_idx = []
for i in range(w):
    if w_cnt[i] == max_w:
        max_w_idx.append(i)

minus = -1
for i in max_h_idx:
    for j in max_w_idx:
        if (i, j) not in bomb_set:
            print(max_h + max_w)
            exit()
print(max_h + max_w - 1)

Buggy submission (verdict: Runtime Error):
h, w, m = map(int, input().split())
h_cnt = [0] * h
w_cnt = [0] * w

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

for i in range(m):
    h_, w_ = map(int, input().split())
    h_ -= 1
    w_ -= 1
    h_cnt[h_] += 1
    w_cnt[w_] += 1
    mat[h_][w_] = 1

max_h = max(h_cnt)
max_h_idx = []
for i in range(h):
    if h_cnt[i] == max_h:
        max_h_idx.append(i)

max_w = max(w_cnt)
max_w_idx = []
for i in range(w):
    if w_cnt[i] == max_w:
        max_w_idx.append(i)

for i in max_h_idx:
    for j in max_w_idx:
        if mat[i][j] == 0:
            print(max_h + max_w)
            exit()
print(max_h + max_w - 1)
Problem p02627 (python)

Fixed submission:
a = input()

if a.isupper():
    print('A')
else:
    print('a')

Buggy submission (verdict: Runtime Error):
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    K = int(input())
    S = input()

    mod = 10 ** 9 + 7
    n = len(S)
    ans = 0

    fact =[1]*(K+n)
    factinv = [1]*(K+n)


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

    def nCr(n,r):
        return (fact[n] * factinv[r] * factinv[n-r]) % mod

    for i in range(K+1):
        #ans += ((25 ** i * nCr(i+n-1,n-1)) * (26 ** (K - i))) % mod
        ans += ((25 ** i * fact[i+n-1] * factinv[n-1] * factinv[i] ) * (26 ** (K - i))) % mod
    print(ans)

if __name__ == "__main__":
    main()
Problem p02729 (python)

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

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

if N == 1 or N == 0:
    a = 0
else:
    a = cmb(N,2)
if M == 1 or M == 0:
    b = 0
else:
    b = cmb(M,2)
print(a+b)

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

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

if N == 1:
    a = 0
else:
    a = cmb(N,2)
if M == 1:
    b = 0
else:
    b = cmb(M,2)
print(a+b)
Problem p02754 (python)

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

ans = N // (A+B) * A
rem = N % (A+B)
ans += min(rem,A)

print(ans)

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

Blue='b'*A
Red='r'*B
BlueRed=Blue+Red
ans = ''
time = (N // len(BlueRed))+1
ans= BlueRed*time
ans2=ans[:N]
print(ans2.count('b'))

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

Blue='b'*A
Red='r'*B
BlueRed=Blue+Red
ans = ''
time = (N // 7)+1
ans= BlueRed*time
ans2=ans[:N]
print(ans2.count('b'))

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

Blue='b'*A
Red='r'*B
ans = ''
for i in range(1,N):
    ans = ans + Blue + Red
    if N <= len(ans):
        ans2=ans[:N]
        print(ans2.count('b'))
        break
Problem p02771 (python)

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

if A == B:
    if A == C:
        print('No')
    else:print('Yes')
elif A == C:
    print('Yes')
elif B == C:
    print('Yes')
else: print('No')

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
A = list(map(int,input().split()))
ans = []
for i,num in enumerate(A):
    for j in range(i+1,N):
        ans.append(num * A[j])
ans.sort()
print(ans[K-1])
Problem p02912 (python)

Fixed submission:
import heapq
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N,M = map(int,input().split())
    A = list(map(int,input().split()))
    A = list(map(lambda x: x*(-1),A))

    heapq.heapify(A)

    for _ in range(M):
        max_value = heapq.heappop(A) * (-1)
        heapq.heappush(A,max_value//2 * (-1))

    print(sum(A) * (-1))

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import bisect

N,M = map(int,input().split())
A = sorted(list(map(int,input().split())))

for _ in range(M):
    max_value = max(A)
    max_index = bisect.bisect_left(A,max_value)
    A[max_index] = max_value // 2

print(sum(A))
Problem p03038 (python)

Fixed submission:
import sys

def input():
    return sys.stdin.readline().strip()

def main():

    N,M = map(int,input().split())
    A = sorted(list(map(int,input().split())))
    BC = [list(map(int,input().split())) for _ in range(M)]
    BC = sorted(BC,reverse=True,key=lambda x: x[1])
    D = []

    for B,C in BC:
        for b in range(B):
            if len(D) != N:
                D.append(C)
            else:
                break
        else:
            continue
        break

    for i in range(len(D)):
        if A[i] < D[i]:
            A[i] = D[i]
        else:
            break

    print(sum(A))

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = sorted(list(map(int,input().split())))
BC = [list(map(int,input().split())) for _ in range(M)]
BC = sorted(BC,reverse=True,key=lambda x: x[1])
i = 0

for B,C in BC:
    if A[i] > C:
        break
    for a in A[i:]:
        if a < C and B != 0:
            A[i] = C
            B -= 1
            i += 1
        else:
            break
print(sum(A))

Buggy submission (verdict: Runtime Error):
import heapq

N,M = map(int,input().split())
A = sorted(list(map(int,input().split())))
BC = [list(map(int,input().split())) for _ in range(M)]
BC = sorted(BC,reverse=True,key=lambda x: x[1])
i = 0

for B,C in BC:
    if A[i] >= C:
        break
    for a in A[i:]:
        if a < C and B != 0:
            A[i] = C
            B -= 1
            i += 1
        else:
            break
print(sum(A))
Problem p03053 (python)

Fixed submission:
import sys
from collections import deque

def input():
    return sys.stdin.readline().strip()

def main():
    H,W = map(int,input().split())
    A = [list(input()) for _ in range(H)]

    que = deque()
    for x in range(W):
        for y in range(H):
            if A[y][x] == '#':
                que.append((x,y,0))        
    ans = 0
    while que:
        x,y,c = que.popleft()
        for dx,dy in ((-1,0),(1,0),(0,-1),(0,1)):
            sx = x + dx
            sy = y + dy
            if sx < 0 or sx >= W or sy < 0 or sy >= H or A[sy][sx] == '#':
                continue
            if A[sy][sx] == '.':
                que.append((sx,sy,c+1))
                A[sy][sx] = c + 1
                ans = max(ans,c+1)
    print(ans)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque

def input():
    return sys.stdin.readline().strip()

def main():
    H,W = map(int,input().split())
    A = [list(input()) for _ in range(H)]

    def bfs(x,y,A):
        que = deque()
        que.append((x,y))

        while que:
            x,y = que.popleft()
 
            for dx,dy in ((-1,0),(1,0),(0,-1),(0,1)):
                sx = x + dx
                sy = y + dy
                if sx < 0 or sx >= H or sy < 0 or sy >= W or A[sy][sx] == '#':
                    continue
                cnt = 1 if A[y][x] == '#' else A[y][x] + 1
                if A[sy][sx] == '.':
                    que.append((sx,sy))
                    A[sy][sx] = cnt
                elif A[sy][sx] > cnt:
                    que.append((sx,sy))
                    A[sy][sx] = cnt

    for x in range(W):
        for y in range(H):
            if A[y][x] == '#':
                bfs(x,y,A)
    ans = 0
    for a in A:
        a = [i if i != '#' else 0 for i in a]
        ans = max(ans,max(a))
    print(ans)

if __name__ == "__main__":
    main()
Problem p03775 (python)

Fixed submission:
import math

N = int(input())
ans = len(str(N))

f = 1
while f * f <= N:
    if N % f == 0:
        ans = min(ans,max(len(str(f)),len(str(N//f))))
    f += 1

print(ans)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())

def prime(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

l = prime(N)

sqrt = str(int(math.sqrt(N)))
print(max(len(sqrt),len(str(l[-1]))))
Problem p03805 (python)

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

line = [[] for _ in range(N)]
for _ in range(M):
    a,b = map(int,input().split())
    line[a-1].append(b-1)
    line[b-1].append(a-1)

check = [False] * N

def dfs(now):
    global cnt
    global ans
    if cnt == N:
        ans += 1
    else:
        for i in line[now]:
            if check[i] == False:
                check[i] = True
                cnt += 1
                dfs(i)
                check[i] = False
                cnt -= 1

check[0] = True
cnt = 1
ans = 0
dfs(0)
print(ans)

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

line = [[] for _ in range(M)]
for _ in range(N):
    a,b = map(int,input().split())
    line[a-1].append(b-1)
    line[b-1].append(a-1)

check = [False] * N

def dfs(now):
    global cnt
    global ans
    if cnt == N:
        ans += 1
    else:
        for i in line[now]:
            if check[i] == False:
                check[i] = True
                cnt += 1
                dfs(i)
                check[i] = False
                cnt -= 1

check[0] = True
cnt = 1
ans = 0
dfs(0)
print(ans)

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

line = [[] for _ in range(M)]
for _ in range(M):
    a,b = map(int,input().split())
    line[a-1].append(b-1)
    line[b-1].append(a-1)

check = [False] * N

def dfs(now):
    global cnt
    global ans
    if cnt == N:
        ans += 1
    else:
        for i in line[now]:
            if check[i] == False:
                check[i] = True
                cnt += 1
                dfs(i)
                check[i] = False
                cnt -= 1

check[0] = True
cnt = 1
ans = 0
dfs(0)
print(ans)
Problem p02571 (python)

Fixed submission:
S=input()
T=input()
ls=len(S)
lt=len(T)

ans=float('inf')
for i in range(0,ls-lt+1):
    ans=min(ans, sum([l!=m for l,m in zip(S[i:i+lt], T)]))
print(ans)

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

def x():
    for i in range(len(T),0,-1): # 文字列の長さ
        for j in range(len(T)-i): # T検索の開始位置=その前にある文字数
            t=T[j:i+j]
            for m in re.finditer(t, S):
                p=m.start()
                if p!=-1:
                    if j<=p and len(T)-j-1 <=len(S)-p-1:
                        return i
    return 0
print(len(T)-t)

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

def x():
    for i in range(len(T),0,-1): # 文字列の長さ
        for j in range(len(T)-i): # T検索の開始位置=その前にある文字数
            t=T[j:i+j]
            for m in re.finditer(t, S):
                p=m.start()
                if p!=-1:
                    # print(j,i,t,p,j<=p and len(T)-j-1 <=len(S)-p-1,len(T)-i)
                    if j<=p and len(T)-j-1 <=len(S)-p-1:
                        return i

print(len(T)-x())
Problem p03774 (python)

Fixed submission:
N, M = map(int, input().split())
# ab = [int(x) for _ in range(N) for x in input().split()]
ab = [list(map(int, input().split())) for _ in range(N)]
cd = [list(map(int, input().split())) for _ in range(M)]

for st in range(len(ab)):
    dis = [abs(ab[st][0] - cd[cp][0]) + abs(ab[st][1] - cd[cp][1])  for cp in range(len(cd))]
    print(dis.index(min(dis))+1)

Buggy submission (verdict: Runtime Error):
N = int(input())

y = []

for i in range(1, N//2):
    if N % i == 0:
        y.append( max( len(str(i)),  len(str(int(N/i))) ) )
print(min(y))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(N)]
y = [list(map(int, input().split())) for _ in range(M)]
for a,b in ab:
    z = [abs(a-c) + abs(b-d) for c,d in cd]
    print(z.index(min(z))+1)
Problem p03775 (python)

Fixed submission:
N = int(input())

ans = 10**18

for i in range(1, int(N**0.5)+1):
    if N % i == 0:
        b = N//i
        ans = min(ans, max( len(str(i)),  len(str(b))))
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())

y = []

for i in range(1, N//2):
    if N % i == 0:
        y.append( max( len(str(i)),  len(str(int(N/i))) ) )
print(min(y))
Problem p03821 (python)

Fixed submission:
N=int(input())
A=[list(map(int,input().split())) for _ in range(N)]

ans=0
for i in range(N-1,-1,-1):
    a,b=A[i]
    a+=ans
    #print(a,-(-a//b)*A[i][1],-(-a//b)*A[i][1]-a)
    ans+=-(-a//b)*A[i][1]-a
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=[map(int,input().split()) for _ in range(N)]

r=0
for i in range(N-1,-1,-1):
    a,b=A[i]
    a+=r
    r+=-(-a//b)*A[i][1]-a
print(r)
Problem p02596 (python)

Fixed submission:

K=int(input())

if(K%2==0 or K%5==0):
  print("-1")

else:
  ans = 1
  s = 7
  while True:
    if s%K==0:
      print(ans)
      break
    else:
      s=(s%K)*10+7
      ans += 1

Buggy submission (verdict: Runtime Error):
K=int(input())

if(K%2==0):
    print(-1)
else:
    seven=7
    seven=seven%K
    for i in range(K+1):
        if(seven==0):
            ans=i+1
            break
        seven=(seven*10+7)%K
    
    print(ans)