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

Fixed submission:
#d  tree
#code自体はあっている。ただ、そもそもアルゴリズムが違う。
#下から調べていかないと最適でない。
#Right Answer. 
import sys
sys.setrecursionlimit(2 * 10 ** 5 + 10)

n,k =  [int(i) for i in input().split()]
a   =  [int(i)-1 for i in input().split()]

#this is directed tree so every node is not reached yet
#return the depth from its lowest bottom
def dfs(u):
    global cnt
    depth = 0 #default, this value is used when bottom
    
    for v in edges[u]:
        depth = max(depth, (dfs(v)+1)%k) #apply the maximum depth
        #because the edge was alerady cut, by the following procedure
    
    if depth==k-1 and u!=0 and a[u] != 0:
        cnt += 1
        
    return depth


cnt = 0
if a[0]!=0:
    cnt += 1

edges = [[] for _ in range(n)]
for i in range(1,n):
    pa = a[i]
    edges[a[i]].append(i)   

dfs(0)    
print(cnt)

Buggy submission (verdict: Runtime Error):
#d  tree
n,k =  [int(i) for i in input().split()]
a   =  [int(i)-1 for i in input().split()]

#this is directed tree so every node is not reached yet
def dfs(u, d):
    change = 0
    if d>k:
        d = 1
        change += 1
    for v in edges[u]:
        if u!=v:
            change += dfs(v, d+1)
    return change


cnt = 0
if a[0]!=0:
    a[0] = 0
    cnt += 1

edges = [[] for _ in range(n)]
for i in range(0,n):
    pa = a[i]
    edges[a[i]].append(i)   

cnt += dfs(0,0)    
print(cnt)

Buggy submission (verdict: Runtime Error):
#d  tree
n,k =  [int(i) for i in input().split()]
a   =  [int(i)-1 for i in input().split()]

#this is directed tree so every node is not reached yet
def dfs(u, d):
    change = 0
    if d>k:
        d = 1
        change += 1
    for v in edges[u]:
        if u==v:
            continue
        change += dfs(v, d+1)
    return change


cnt = 0
if a[0]!=0:
    a[0] = 0
    cnt += 1

edges = [[] for _ in range(n)]
for i in range(0,n):
    pa = a[i]
    edges[a[i]].append(i)   

cnt += dfs(0,0)    
print(cnt)

Buggy submission (verdict: Runtime Error):
#d  tree
n,k =  [int(i) for i in input().split()]
a   =  [int(i)-1 for i in input().split()]

#this is directed tree so every node is not reached yet
def dfs(u, d):
    change = 0
    if d>k:
        d = 1
        change += 1
    for v in edges[u]:
        change += dfs(v, d+1)
    return change


cnt = 0
if a[0]!=0:
    cnt += 1

edges = [[] for _ in range(n)]
for i in range(1,n):
    pa = a[i]
    edges[a[i]].append(i)   

cnt += dfs(0,0)    
print(cnt)
Problem p02598 (python)

Fixed submission:
#template
def inputlist(): return [int(j) for j in input().split()]
#template
N,K = inputlist()
A = inputlist()
left = 0
right = 10**9+1
while right - left > 1:
    mid = (left+right)//2
    count = 0
    for i in range(N):
        count += A[i]//mid
        if A[i] % mid == 0:
            count -=1
    if count > K:
        left = mid
    else:
        right = mid
print(right)

Buggy submission (verdict: Runtime Error):
#template
def inputlist(): return [int(j) for j in input().split()]
#template
N,K = inputlist()
A = inputlist()
left = -1
right = 10**9+1
while right - left > 1:
    mid = (left+right)//2
    count = 0
    for i in range(N):
        count += A[i]//mid
        if A[i] % mid == 0:
            count -=1
    if count > K:
        left = mid
    else:
        right = mid
print(right)
Problem p02819 (python)

Fixed submission:
import sys
input = sys.stdin.readline
import math
def get_primenumber(number):
    prime_list = []
    #2からnumberまでの数字をsearch_listに入れる
    search_list = list(range(2,number+1))
    while True:
      #search_listの先頭の値が√nの値を超えたら処理終了
      if search_list[0] > math.sqrt(number):
        #prime_listにsearch_listを結合
        prime_list.extend(search_list)
        break
      else:
        #search_listの先頭をprime_listに入れる
        head_num = search_list[0]
        prime_list.append(head_num)
        #search_listの先頭をpopする
        search_list.pop(0)
        #head_numの倍数を取り除く
        search_list = [num for num in search_list if num % head_num != 0]
    return prime_list
X = int(input())
K = 0
li = get_primenumber(100010)
for i in range(len(li)) :
    if li[i] >= X :
        K = li[i]
        break
print(K)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
X = int(input())
import sympy
from sympy import nextprime
print(nextprime(X))
Problem p02948 (python)

Fixed submission:
#template
def inputlist(): return [int(k) for k in input().split()]
#template

N,M = inputlist()
li = []
for i in range(N):
    A,B = inputlist()
    B *= -1
    li.append([A,B])
ans = 0
from heapq import *
li.sort()
k = []
heapify(k)
flag = 0
for i in range(1,M+1):
    if flag == N:
        for i in range(M+1-i):
            ans -= heappop(k)
        break
    while li[flag][0] <= i:
        heappush(k,li[flag][1])
        flag = flag + 1
        if flag == N:
            break
    if len(k)>=1:
        ans -= heappop(k)
print(ans)

Buggy submission (verdict: Runtime Error):
#template
def inputlist(): return [int(k) for k in input().split()]
#template

N,M = inputlist()
li = []
for i in range(N):
    A,B = inputlist()
    B *= -1
    li.append([A,B])
ans = 0
from heapq import *
li.sort()
k = []
heapify(k)
flag = 0
for i in range(1,M+1):
    if flag == N:
        for t in range(M+1-i):
            ans -= heappop(k)
		break
    while li[flag][0] <= i:
        heappush(k,li[flag][1])
        flag = flag + 1
        if flag == N:
            break
    if len(k)>=1:
        ans -= heappop(k)
print(ans)
Problem p02984 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[sum(a)-2*sum(a[1:n-1:2])]
for i in range(1,n):
  b.append(2*a[i-1]-b[-1])
print(*b)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(i) for i in input().split()]
for i in range(N):
    A[i] *= 2
import numpy as np
mat = [[0] * N for _ in range(N)]
for i in range(N):
    j = i + 1
    if j == N:
        j = 0
    mat[i][i] = 1
    mat[i][j] = 1
AB = np.array(mat)
inv_A = np.linalg.inv(AB)
ans = list(np.dot(inv_A,A))
for i in range(N):
    ans[i] = int(ans[i])
print(*ans)
Problem p03038 (python)

Fixed submission:
n, m = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A)

cb_dict = {}
for _ in range(m):
    b, c = map(int, input().split())
    new = {c:b}
    if c in cb_dict.keys():
        cb_dict[c] += b
    else:
        cb_dict.update(new)

cb_dict = sorted(cb_dict.items(), key=lambda x:x[0], reverse=True)

now_c = 0
now_b = 0
for i in range(n):
    if A[i] >= cb_dict[now_c][0]:
        break
    else:
        A[i] = cb_dict[now_c][0]
        now_b += 1
        if now_b == cb_dict[now_c][1]:
            now_c += 1
            now_b = 0
        if now_c > len(cb_dict)-1:
            break

ans = sum(A)
print(ans)

Buggy submission (verdict: Runtime Error):
N,M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
li = [0] * M
for i in range(M):
    B,C = [int(j) for j in input().split()]
    li[i] = [C,B]
li.sort()
li.reverse()
A.sort()
Ba = [0] * M
for i in range(M):
    Ba[i] = li[i][1]
from numpy import cumsum
from bisect import bisect_left
B_sum = list(cumsum(Ba))
count = B_sum[-1]
N = min(N,count)
for i in range(N):
    indexa = bisect_left(B_sum,i+1)
    if A[i] >= li[indexa][0]:
        break
    if A[i] < li[indexa][0]:
        A[i] = li[indexa][0]
print(sum(A))
Problem p03252 (python)

Fixed submission:
import sys
import itertools
import numpy
input = sys.stdin.readline
Sa = input()
Ta = input()
S = ['0'] * len(Sa)
T = ['0'] * len(Ta)
for i in range(len(Sa)) :
    S[i] = Sa[i]
for i in range(len(Ta)) :
    T[i] = Ta[i]
ans = {}
for cs,ct in zip(S,T) :
    if cs not in ans.keys() and ct not in ans.values() :
        ans[cs] = ct
    else :
        try :
            if ans[cs] == ct :
                continue
            else :
                print("No")
                break
        except KeyError :
            print("No")
            break
else :
    print("Yes")

Buggy submission (verdict: Runtime Error):
import sys
import itertools
import numpy
input = sys.stdin.readline
Sa = input()
Ta = input()
S = ['0'] * len(Sa)
T = ['0'] * len(Ta)
for i in range(len(Sa)) :
    S[i] = Sa[i]
for i in range(len(Ta)) :
    T[i] = Ta[i]
ans = {}
for cs,ct in zip(S,T) :
    if cs not in ans.keys() and ct not in ans.values() :
        ans[cs] = ct
    else :
        if ans[cs] == ct :
            continue
        else :
            print("No")
            break
else :
    print("Yes")
Problem p02951 (python)

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

Buggy submission (verdict: Runtime Error):
import sys
A = int(sys.argv[1])
B = int(sys.argv[2])
C = int(sys.argv[3])
if C - (A - B) >= 0:
    print(C - (A - B))
else:
    print(0)
Problem p02729 (python)

Fixed submission:
a,b=map(int,input().split())
ans=0
if a>=2:
  ans+=a*(a-1)*0.5
if b>=2:
  ans+=b*(b-1)*0.5
ans=int(ans)
print(ans)

Buggy submission (verdict: Runtime Error):
def cmb(n):
	if n<=1:
		return 0
	else:
		return int(n*(n-1)*0.5)
N = int(input())
A = [int(x) for x in input().split()]
ans=[0]*N
lists={}
k=0
for i in range(N):
  if not A[i] in lists:
    l=cmb(A.count(A[i]))
    m=cmb(A.count(A[i])-1)-l
    k+=l
    lists[A[i]]=m
    ans[i]=m
  else:
    ans[i]=lists[A[i]]
    
for i in range(N):
  ans[i]+=k
  print(ans[i])
Problem p02912 (python)

Fixed submission:
N,M=map(int,input().split())
A=list(map(int,input().split()))
for i in range(N):
  A[i]*=-1
import heapq
heapq.heapify(A)
import math
for i in range(M):
  maxi=heapq.heappop(A)
  maxi=math.ceil(maxi/2)
  heapq.heappush(A,maxi)
  
ans=sum(A)*(-1)
print(ans)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
t=0
while True:
  maxi=A[0]
  if len(A)>1 :
    maxi_2=A[1]
    t+=1
    maxi=maxi//2
    if t==M :
      A[0]=maxi
      break
    elif maxi_2>maxi :
      A[0]=maxi_2
      A[1]=maxi
      for i in range(1,N):
        if A[i]<A[i+1]:
          A[i]=A[i+1]
          A[i+1]=maxi
        else:
          break     
      continue
    else:
      continue
  else :
    maxi=maxi//(2**M)
    A[0]=maxi
    break

amount=sum(A)
print(amount)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
t=0
while True:
  maxi=A[0]
  if len(A)>1 :
    maxi_2=A[1]
    t+=1
    maxi=maxi//2
    if t==M :
      A[0]=maxi
      break
    elif maxi_2>maxi :
      A[0]=maxi_2
      A[1]=maxi
      for i in range(1,N):
        if A[i]<A[i+1]:
          A[i]=A[i+1]
          A[i+1]=maxi
        else:
          break     
      continue
    else:
      continue
  else :
    maxi=maxi//(2**M)
    A[0]=maxi
    break

amount=sum(A)
print(amount)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
t=0
while True:
  maxi=A[0]
  maxi_2=A[1]
  t+=1
  maxi=maxi//2
  if t==M :
    A[0]=maxi
    break
  elif maxi_2>maxi :
    A[0]=maxi
    A.sort(reverse=True)
    continue
  else:
    continue

amount=sum(A)
print(amount)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
t=0
while True:
  maxi=A[0]
  maxi_2=A[1]
  t+=1
  maxi=maxi//2
  if t==M :
    A[0]=maxi
    break
  elif maxi_2>maxi :
    A[0]=maxi_2
    A[1]=maxi
    continue
  else:
    continue

amount=sum(A)
print(amount)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input.split())
A=list(map(int,input().split()))
A.sort(reverse=True)
t=0
while True:
  maxi=A[0]
  maxi_2=A[1]
  t+=1
  maxi=maxi//2
  if t==M :
    A[0]=maxi
    break
  elif maxi_2>maxi :
    A[0]=maxi_2
    A[1]=maxi
    continue
  else:
    continue

amount=sum(A)
print(amount)
Problem p02933 (python)

Fixed submission:
a=int(input())
s=input()

if a<3200 :
  s='red'

print(s)

Buggy submission (verdict: Runtime Error):
N,Q=map(int,input().split())
a=[0]*(N-1)
b=[0]*(N-1)
p=[0]*Q
x=[0]*Q
for i in range(N-1):
  a[i],b[i]=map(int,input().split())
for i in range(Q):
  p[i],x[i]=map(int,input().split())
v=[0]*N
 
for i in range(Q):
  box=[]
  box.append(p[i])
  for k in range(N-1):
    if a[k] in box :
      box.append(b[k])
  for l in range(len(box)):
    num=box[l]-1
    v[num]+=x[i]
 
for h in range(N):
  print(v[h], end=" ")
Problem p02754 (python)

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

r = n % (a + b)
ans = n // (a + b) * a + min(r, a)
print(ans)

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

s = ""
while True:
    s += "b" * a +  "r" * b
    if len(s) >= n:
        break

print(s[:n].count("b"))
Problem p02836 (python)

Fixed submission:
S = input()
ans = 0
if len(S) % 2 == 0:
    a = S[:len(S) // 2]
    b = S[len(S) // 2:]

    for i in range(len(a)):
        if a[i] != b[-i - 1]:
            ans += 1

else:
    mid = len(S) // 2
    a = S[:mid]
    b = S[mid:]
    for i in range(len(a)):
        if a[i] != b[-i - 1]:
            ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
ans = 0
if len(S) % 2 == 0:
    a = S[:len(S) // 2]
    b = S[len(S) // 2:]

    for i in range(len(a)):
        if a[i] != b[-i - 1]
            ans += 1

else:
    mid = len(S) // 2
    a = S[:mid]
    b = S[mid:]
    for i in range(len(a)):
        if a[i] != b[-i - 1]:
            ans += 1

print(ans)
Problem p02987 (python)

Fixed submission:
S = input()

sorted_S = sorted(S)

if sorted_S[0] == sorted_S[1] and sorted_S[2] == sorted_S[3] and sorted_S[1] != sorted_S[2]:
	print("Yes")
else:
	print("No")

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

sorted_S = sorted(S)

if S[0] == S[1] and S[2] == S[3] ans S[1] != S[2]:
	print("Yes")
else:
	print("No")
Problem p03705 (python)

Fixed submission:
n, a, b = map(int, input().split())
x = a * n - a + b
y = b * n - b + a


if a > b:
    print(0)
elif a == b and n == 1:
    print(1)
elif a != b and n == 1:
    print(0)
else:
    print(y - x + 1)

Buggy submission (verdict: Runtime Error):
n, a, b = map(int, input().split())A
print((b - a) * (n - 2) + 1)
Problem p02699 (python)

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

Buggy submission (verdict: Runtime Error):
n,m=map(input,int().split())
if(n>m):
  print("safe")
else:
  print("unsafe")
Problem p03013 (python)

Fixed submission:
fib=[0,1]
for i in range(100000):
  fib.append(fib[-1]+fib[-2])
  
n,m=map(int,input().split())
hoge=[-1]
ans=1
for i in range(m):
  hoge.append(int(input()))
hoge.append(n+1)

for i in range(len(hoge)-1):
  if(hoge[i+1]-hoge[i]==1):
    print(0)
    exit()
    
for i in range(len(hoge)-1):
  sa=hoge[i+1]-hoge[i]-1
  ans=ans*fib[sa]
  ans=ans%1000000007
print(ans)

Buggy submission (verdict: Runtime Error):
fib=[0,1]
for i in range(10001):
  fib.append(fib[-1]+fib[-2])
  
n,m=map(int,input().split())
hoge=[-1]
ans=1
for i in range(m):
  hoge.append(int(input()))
hoge.append(n+1)

for i in range(len(hoge)-1):
  if(hoge[i+1]-hoge[i]==1):
    print(0)
    exit()
    
for i in range(len(hoge)-1):
  sa=hoge[i+1]-hoge[i]-1
  ans=ans*fib[sa]
  ans=ans%1000000007
print(ans)

Buggy submission (verdict: Runtime Error):
fib=[0,1]
for i in range(9999):
  fib.append(fib[-1]+fib[-2])
  
n,m=map(int,input().split())
hoge=[-1]
ans=1
for i in range(m):
  hoge.append(int(input()))
hoge.append(n+1)

for i in range(len(hoge)-1):
  if(hoge[i+1]-hoge[i]==1):
    print(0)
    exit()
    
for i in range(len(hoge)-1):
  sa=hoge[i+1]-hoge[i]-1
  ans=ans*fib[sa]
  ans=ans%1000000007
print(ans)

Buggy submission (verdict: Runtime Error):
fib=[0,1]
for i in range(9999):
  fib.append(fib[-1]+fib[-2])
  
n,m=map(int,input().split())
hoge=[0]
ans=1
for i in range(m):
  hoge.append(int(input()))
hoge.append(n+1)

for i in range(len(hoge)-1):
  if(hoge[i+1]-hoge[i]==1):
    print(0)
    exit()
    
  ans=ans*max(1,fib[hoge[i+1]-hoge[i]-1])
  ans=ans%1000000007
  
print(ans%1000000007)
Problem p03803 (python)

Fixed submission:
a,b=map(int,input().split())
if(a==1):
  a=14
if(b==1):
  b=14

if(a>b):
  print("Alice")
elif(a<b):
  print("Bob")
else:
  print("Draw")

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

if(a==1):
  a=14
if(b==1):
  b=14
  
if(a>b):
  print("Alice")
elif(a<b):
  print("Bob")
else:
  print("Drow")
Problem p02699 (python)

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

Buggy submission (verdict: Runtime Error):
s,w=mpa(int,input().split())
if(w>=s):
	print("unsafe")
else:
	print("safe")
Problem p02970 (python)

Fixed submission:
from math import *
n,d=map(int,input().split())
print(ceil(n/(2*d+1)))

Buggy submission (verdict: Runtime Error):
n,d=map(int,input().split())
print(ceil(n/(2*d+1)))
Problem p02891 (python)

Fixed submission:
s = input()
k = int(input())

if len(s) == 1:
    print(k//2)
    exit(0)

if len(list(set(s))) == 1 and len(s)%2 == 1:
    print((len(s)//2)*k+k//2)
    exit(0)

count = 0
    
ngo = 1
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        ngo+=1
    else:
        count += ngo//2
        ngo=1
count += ngo//2

ngongo = 0
while ngongo < len(s) and s[len(s)-ngongo-1] == s[-1]:
    ngongo+=1

ngongongo = 0
while ngongongo < len(s) and s[ngongongo] == s[0]:
    ngongongo += 1
    
f = 0
if ngongo %2 == 1 and ngongongo %2 == 1 and s[0] == s[-1]:
    count += 1
    f += 1

print(count*k-f)

Buggy submission (verdict: Runtime Error):
import queue
import numpy as np
n = int(input())
class Node:
    def __init__(self):
        self.nextNode = []
        self.checkNgo = -1
        self.group = -1
        
Nodes = [Node() for i in range(n)]
for i in range(n):
    s = input()
    for j in range(len(s)):
        if s[j] == '1':
            Nodes[i].nextNode.append(j)
            
def check(node,ngo):
    if node.checkNgo == -1:
        node.checkNgo = ngo
    elif node.checkNgo != ngo:
        return False
    elif node.checkNgo == ngo:
        return True
    for i in node.nextNode:
        if not check(Nodes[i],(ngo+1)%2):
            return False
    return True
    
def ngoCheck():
    stack = [Nodes[0]]
    Nodes[0].checkNgo = 0
    while stack:
        node = stack.pop()
        for i in node.nextNode:
            if Nodes[i].checkNgo != -1 and Nodes[i].checkNgo == node.checkNgo:
                return False
            if Nodes[i].checkNgo == -1:
                Nodes[i].checkNgo = (node.checkNgo+1)%2
                stack.append(Nodes[i])
    return True
    
if not ngoCheck():
    print(-1)
    exit(0)
    
def solv():
    d = [[0 for i in range(n)] for j in range(n)]
    for i in range(n):
        for j in range(n):
            if j in Nodes[i].nextNode:
                d[i][j] = 1
            else:
                d[i][j] = np.inf
    for k in range(n):
        for i in range(n):
            for j in range(n):
                if d[i][j] > d[i][k]+d[k][j]:
                    d[i][j] = d[i][k]+d[k][j]
    return d
    
def saidai(d):
    maxi = 0
    for i in range(n):
        for j in range(n):
            maxi = max(maxi,d[i][j])
    return maxi
    
d = solv()
print(saidai(d)+1)
Problem p02990 (python)

Fixed submission:
import math
n,k = map(int,input().split())
for i in range(1,k+1):
    if n-k-i+1 < 0:
        print(0)
        continue
    c = math.factorial(n-k+1)//(math.factorial(i)*math.factorial(n-k+1-i))
    h = math.factorial(k-1)//(math.factorial(k-i)*math.factorial(i-1))
    print((c*h)%(10**9+7))

Buggy submission (verdict: Runtime Error):
import math
n,k = map(int,input().split())
for i in range(1,k+1):
    t = 1
    c = math.factorial(n-k+1)//(math.factorial(i)*math.factorial(n-k+1-i))
    h = math.factorial(i+(k-i)-1)//(math.factorial(k-i)*math.factorial(i-1))
    print((c*h)%(10**9+7))
Problem p02688 (python)

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

d = [0] * k
a = []
snuk = [False] * n
for i in range(k):
    d[i] = int(input())
    a = list(map(int, input().split()))
    for j in a:
        snuk[j - 1] = True
    

ans = 0
for i in range(n):
    if snuk[i] == False:
        ans += 1


print(ans)

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

d = [0] * n
a = []
snuk = [False] * n
for i in range(k):
    d[i] = int(input())
    a = list(map(int, input().split()))
    for j in a:
        snuk[j - 1] = True
    

ans = 0
for i in range(n):
    if snuk[i] == False:
        ans += 1


print(ans)

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

d = [0] * n
a = []
snuk = [False] * n
for i in range(k):
    d[i] = int(input())
    a = list(map(int, input().split()))
    for j in a:
        snuk[j - 1] = True
    

ans = 0
for i in range(n):
    if snuk[i] == False:
        ans += 1


print(ans)
Problem p03327 (python)

Fixed submission:
n = int(input())
if n >= 1000:
    ans = "ABD"
else:
    ans = "ABC"
print(ans)

Buggy submission (verdict: Runtime Error):
n = input()
if n >= 1000:
    ans = "ABD"
else:
    ans = "ABC"
print(ans)

Buggy submission (verdict: Runtime Error):
n = input()
if n >= 1000:
    ans = "ABD"
else:
    ans = "ABC"
print(ans)
Problem p03805 (python)

Fixed submission:
n, m = map(int, input().split())
graph = {i: [] for i in range(1, n + 1)}
for _ in range(m):
    u, v = map(int, input().split())
    graph[u].append(v)
    graph[v].append(u)

def dfs(i):
    ret = 0
    if all(han):
        return 1
    for j in range(1, n + 1):
        if han[j] == False and j in graph[i]:
            han[j] = True
            ret += dfs(j)
            han[j] = False
    return ret

han = [False] * (n + 1)
han[0] = True
han[1] = True
ans = dfs(1)
    
print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
graph = {i: [] for i in range(1, m + 1)}
for _ in range(m):
    u, v = map(int, input().split())
    graph[u].append(v)
    graph[v].append(u)

def dfs(i):
    ret = 0
    if all(han):
        return 1
    for j in range(1, n + 1):
        if han[j] == False and j in graph[i]:
            han[j] = True
            ret += dfs(j)
            han[j] = False
    return ret

han = [False] * (n + 1)
han[0] = True
han[1] = True
ans = dfs(1)
    
print(ans)
Problem p02793 (python)

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

def lcm(a,b):
	return a*b//gcd(a,b)

n=int(input())
a=[int(i) for i in input().split()]
tmp=1
for i in a:
	tmp=lcm(i,tmp)
mod=1000000007
print(sum(tmp//i for i in a)%mod)

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
	if b==0:
		return a
	else:
		return gcd(b,a%b)

def lcm(a,b):
	return a*b//gcd(a,b)

n=int(input())
a=[int(i) for i in input().split()]
tmp=1
for i in a:
	tmp=lcm(i,tmp)
mod=1e9+7
print(int(sum(tmp//i for i in a)%mod))

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
	if b==0:
		return a
	else:
		return gcd(b,a%b)

def lcm(a,b):
	return a*b/gcd(a,b)

n=int(input())
a=[int(i) for i in input().split()]
tmp=1
for i in a:
	tmp=lcm(i,tmp)
mod=1e9+7
ans=int(0)
for i in a:
	ans=(ans+tmp//i)%mod
print(int(ans))

Buggy submission (verdict: Runtime Error):
def gcd(a,b):
	if b==0:
		return a
	else:
		return gcd(b,a%b)

def lcm(a,b):
	return a*b/gcd(a,b)

n=int(input())
a=[int(i) for i in input().split()]
tmp=1
for i in a:
	tmp=lcm(i,tmp)
mod=1e9+7
ans=int(0)
for i in a:
	ans=(ans+tmp/i)%mod
print(int(ans))
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):
d = int(input())
t = int(input())
s = int(input())
if (t*s >= d):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
d = int(input())
t = int(input())
s = int(input())
if t*s >= d:
  print("Yes")
else:
  print("No")
Problem p02676 (python)

Fixed submission:
k = int(input())
s = input()
 
if k < len(s):
  print(s[0:k] + "...")
else:
  print(s)

Buggy submission (verdict: Runtime Error):
k = int(input())
s = input()

if k > s:
  print(s[0:k+1] + "...")
else:
  print(s)
Problem p02552 (python)

Fixed submission:
x=int(input())
if x==0: print (1)
else:    print (0)

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