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

Fixed submission:
import math

def dictcheck(dict):
    min = 0
    for k,v in dict.items():
        if k == 1:
            min = v
            break
        elif min == 0:
            min=(int(k)-1)+(int(v)-1)
        elif min > (int(k)-1)+(int(v)-1):
            min = (int(k)-1)+(int(v)-1)
        else:
            continue
    print(min)

def main():
    N = int(input())
    i = 2
    tmpdict= {}
    while i <= math.sqrt(N):
        if N % i == 0:
            tmpdata = {i:N/i}
            tmpdict.update(tmpdata)
            i+=1
        else:
            i+=1
    if len(tmpdict)==0:
        tmpdata = {1:N-1}
        tmpdict.update(tmpdata)
#    print(tmpdict)
    dictcheck(tmpdict)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import math

def dictcheck(dict):
    min = 0
    for k,v in dict.items():
#        print("k:",k ,"+", "v:",v)
        if min == 0:
            min=(int(k)-1)+(int(v)-1)
        elif min > (int(k)-1)+(int(v)-1):
            min = (int(k)-1)+(int(v)-1)
        else:
            continue
    print(min)

def main():
    N = int(input())
    i = 2
    tmpdict= {}
    while i < math.sqrt(N):
        if N % i == 0:
            tmpdata = {i:N/i}
            tmpdict.update(tmpdata)
            i+=1
        else:
            i+=1
    if len(tmpdict)==0:
        tmpdata = {1,N-1}
        tmpdict.update(tmpdata)
#    print(tmpdict)
    dictcheck(tmpdict)

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

Fixed submission:
if __name__ == "__main__":
    N = int(input())
    tmp = int()
    for i in range(1,N+1):
        if i % 2 == 0:
            continue
        else:
            tmp+=1
    print(tmp/N)

Buggy submission (verdict: Runtime Error):
if __name__ == "__main__":
    num,limit=map(int,input().split())
    list = input().split()
    tmp = int()
    for i in list:
        if int(i)>=limit:
            tmp += 1
    print(tmp)
Problem p02948 (python)

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

import heapq

def main2():
    n,m=map(int,input().split())
    jobs_list=[list(map(int,input().split())) for _ in range(n)]
    #breakするタイミングを作るため、Mより大きい値の仕事を作成
    banpei_list=[[i,0] for i in range(1,m+2)]
    #リストの統合
    jobs_list.extend(banpei_list)
    jobs_list=sorted(jobs_list)
    ans=0
    index=0
    que=[]
    while 1:
        day,pay=jobs_list[index]
        #dayがMを超えていればbreak
        if day>m:
            break
        #同じdayのデータが次にもあれば-1倍してheapにpush
        if day==jobs_list[index+1][0]: 
            heapq.heappush(que,-pay)
        #仕事の報酬の最大値を答えに加える
        #前の日のデータからも報酬が良い仕事は選べるようにqueにデータは貯めておく
        else:
            heapq.heappush(que,-pay)
            ans-=heapq.heappop(que)
        index+=1
    print(ans)

if __name__ == "__main__":
    main2()

Buggy submission (verdict: Runtime Error):
import heapq

def main2():
    n,m=map(int,input().split())
    jobs_list=[list(map(int,input().split())) for _ in range(n)]
    #breakするタイミングを作るため、Mより大きい値の仕事を作成
    banpei_list=[[i,0] for i in range(1,m+2)]
    #リストの統合
    jobs_list.extend(banpei_list)
    jobs_list=sorted(jobs_list)
    print(jobs_list)
    ans=0
    index=0
    que=[]
    while 1:
        day,pay=jobs_list[index]
        print(jobs_list[index])
        #dayがMを超えていればbreak
        if day>m:
            break
        #同じdayのデータが次にもあれば-1倍してheapにpush
        if day==jobs_list[index+1][0]: 
            heapq.heappush(que,-pay)
        #仕事の報酬の最大値を答えに加える
        #前の日のデータからも報酬が良い仕事は選べるようにqueにデータは貯めておく
        else:
            heapq.heappush(que,-pay)
            print(que)
            ans-=heapq.heappop(que)
        index+=1
    print(ans)

if __name__ == "__main__":
    main2()

Buggy submission (verdict: Runtime Error):
def main2():
    n,m=map(int,input().split())
    jobs_list=[list(map(int,input().split())) for _ in range(n)]
    #breakするタイミングを作るため、Mより大きい値の仕事を作成
    banpei_list=[[i,0] for i in range(1,m+2)]
    #リストの統合
    jobs_list.extend(banpei_list)
    jobs_list=sorted(jobs_list)
    print(jobs_list)
    ans=0
    index=0
    que=[]
    while True:
        day,pay=jobs_list[index]
        print(jobs_list[index])
        #dayがMを超えていればbreak
        if day>m:
            break
        #同じdayのデータが次にもあれば-1倍してheapにpush
        if day==jobs_list[index+1][0]: 
            heapq.heappush(que,-pay)
        #仕事の報酬の最大値を答えに加える
        #前の日のデータからも報酬が良い仕事は選べるようにqueにデータは貯めておく
        else:
            heapq.heappush(que,-pay)
            print(que)
            ans-=heapq.heappop(que)
        index+=1
    print(ans)

if __name__ == "__main__":
    main2()
Problem p02598 (python)

Fixed submission:
import math

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

left = 0
right = max(a)

while True:
  mid = (left + right) // 2
  
  if mid == 0:
    cnt = 10 ** 10
  else:
    cnt = 0
    for _a in a:
      cnt += math.ceil(_a / mid - 1)
  
  if cnt > k:
    left = mid
  else:
    right = mid
  
  if right - left <= 1:
    break

print(right)

Buggy submission (verdict: Runtime Error):
import math

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

left = 0
right = max(a)

while True:
  mid = (left + right) // 2
  
  cnt = 0
  for _a in a:
    cnt += math.ceil(_a / mid - 1)
  
  if cnt > k:
    left = mid
  else:
    right = mid
  
  if right - left <= 1:
    break

print(right)
Problem p02781 (python)

Fixed submission:
from scipy.misc import comb

def f(n_str, k):
  while len(n_str) > 0 and n_str[0] == '0':
    n_str = n_str[1:]
  if len(n_str) < k:
    return 0
  if k == 1:
    return int(n_str[0]) + 9 * (len(n_str) - 1)
  else:
    return (int(n_str[0]) - 1) * f('9' * (len(n_str) - 1), k - 1) + f(n_str[1:], k - 1) + 9 ** k * (comb(len(n_str) - 1, k, exact=True) if len(n_str) > k else 0)

n = input()
k = int(input())

print(f(n, k))

Buggy submission (verdict: Runtime Error):
from scipy.misc import comb

def f(n_str, k):
  while n_str[0] == '0':
    n_str = n_str[1:]
  if n_str == "":
    return 0
  if k == 1:
    return int(n_str[0]) + 9 * (len(n_str) - 1)
  else:
    return (int(n_str[0]) - 1) * f('9' * (len(n_str) - 1), k - 1) + f(n_str[1:], k - 1) + 9 ** k * comb(len(n_str) - 1, k, exact=True)

n = input()
k = int(input())

print(f(n, k))
Problem p02851 (python)

Fixed submission:
import bisect

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

memo = {0 : []}
for i in range(n):
  if a[i] % k not in memo.keys():
    memo[a[i] % k] = [i]
  else:
    memo[a[i] % k].append(i)

ans = bisect.bisect_left(memo[0], k - 1)

for i in memo.keys():
  for j in range(len(memo[i]) - 1):
    ans += bisect.bisect_left(memo[i], memo[i][j] + k) - 1 - j

print(ans)

Buggy submission (verdict: Runtime Error):
import bisect

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

memo = {}
for i in range(n):
  if a[i] % k not in memo.keys():
    memo[a[i] % k] = [i]
  else:
    memo[a[i] % k].append(i)

ans = bisect.bisect_left(memo[0], k - 1)

for i in memo.keys():
  for j in range(len(memo[i]) - 1):
    ans += bisect.bisect_left(memo[i], memo[i][j] + k) - 1 - j

print(ans)
Problem p02984 (python)

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

ans = map(str, c)
print(" ".join(ans))

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

n = int(input())
a = np.matrix(list(map(int, input().split()))).T
_a = np.eye(n) + np.roll(np.eye(n),1, axis=1)
ans = map(int, np.linalg.inv(_a) * a * 2)
ans = map(str, ans)
print(" ".join(ans))

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

n = int(input())
a = np.array(list(map(int, input().split())))
_a = np.eye(n) + np.roll(np.eye(n),1, axis=1)
ans = map(int, np.linalg.solve(_a, a) * 2)
ans = map(str, ans)
print(" ".join(ans))
Problem p02577 (python)

Fixed submission:
n=input()
num=0
for i in n:
  num+=int(i)

print('Yes' if num%9==0 else 'No')

Buggy submission (verdict: Runtime Error):
n=input()
print('Yes' if n%9==0 else 'No')
Problem p02580 (python)

Fixed submission:
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
from collections import Counter

h,w,m=nii()

h_bomb=[0 for i in range(h)]
w_bomb=[0 for i in range(w)]

l=set()
for i in range(m):
  th,tw=nii()
  th-=1
  tw-=1
  h_bomb[th]+=1
  w_bomb[tw]+=1
  l.add((th,tw))

h_max=max(h_bomb)
w_max=max(w_bomb)

h_cand=[]
w_cand=[]

for i in range(len(h_bomb)):
  if h_bomb[i]==h_max:
    h_cand.append(i)

for i in range(len(w_bomb)):
  if w_bomb[i]==w_max:
    w_cand.append(i)

for i in h_cand:
  for j in w_cand:
    if (i,j) not in l:
      print(h_max+w_max)
      exit()

print(h_max+w_max-1)

Buggy submission (verdict: Runtime Error):
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
import numpy as np

h,w,m=nii()

h_b=[0 for i in range(h)]
w_b=[0 for i in range(w)]

l=[]
for i in range(m):
  h,w=nii()
  h-=1
  w-=1
  h_b[h]+=1
  w_b[w]+=1
  l.append([h,w])

h_s=np.argsort(h_b)
w_s=np.argsort(w_b)

ans=0
for i in range(min(100,len(h_s))):
  for j in range(min(100,len(w_s))):
    t_ans=h_b[i]+w_b[j]
    num=l.count([i,j])
    t_ans-=num
    ans=max(ans,t_ans)

print(ans)
Problem p02623 (python)

Fixed submission:
from bisect import bisect_right

n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

a_ac=[0]
for i in range(1,n+1):
  a_ac.append(a_ac[i-1]+a[i-1])

b_ac=[0]
for i in range(1,m+1):
  b_ac.append(b_ac[i-1]+b[i-1])

#print(a_ac)
#print(b_ac)

ans=0
for i in range(n+1):
  remain=k-a_ac[i]
  if remain<0:
    continue
  t_ans=i
  t_ans+=bisect_right(b_ac,remain)-1
  ans=max(ans,t_ans)

print(ans)

Buggy submission (verdict: Runtime Error):
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())

def eratosthenes(lim):
  is_p=[2]*lim

  is_p[0]=0
  is_p[1]=1

  for i in range(2,lim):
    for j in range(i*2,lim,i):
      is_p[j] += 1

  return is_p

lim=n+1
is_p=eratosthenes(lim)

ans=0
for i in range(1,n+1):
  ans+=i*is_p[i]
print(ans)
Problem p02726 (python)

Fixed submission:
from collections import Counter

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

x-=1
y-=1

dist=[]
for i in range(n-1):
  for j in range(i+1,n):
    dist.append(min(j-i,abs(i-x)+1+abs(j-y)))

c=Counter(dist)
for i in range(1,n):
  print(c[i])

Buggy submission (verdict: Runtime Error):
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra

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

fr,to,w=[],[],[]

for i in range(n-1):
  fr.append(i)
  to.append(i+1)
  w.append(1)

fr.append(x-1)
to.append(y-1)
w.append(1)

g=csr_matrix((w, (fr, to)), shape=(n, n))

ans_l=[]

'''for i in range(n):
  d=dijkstra(g,indices=i,directed=False)
  ans_l+=list(d)'''

d=dijkstra(g,directed=False).astype(int)
ans_l=np.bincount(d.ravel(), minlength=n)//2

print(*ans_l[1:], sep='\n')

'''
for i in ans_l[1:]:
  print(i)
'''

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

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

x-=1
y-=1

dist=[]
for i in range(n-1):
  for j in range(i+1,n):
    dist.append(min(j-i,abs(i-x)+1+abs(j-y)))

c=Counter(dist)
for i in range(1,n):
  print(c[i]

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

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

x-=1
y-=1

dist=[]
for i in range(n-1):
  for j in range(i+1,n):
    dist.append(min(j-i,abs(i-x)+1+abs(j-y)))

c=Counter(dist)
for i in range(1,n):
  print(c[i]
Problem p02779 (python)

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

Buggy submission (verdict: Runtime Error):
2
10000000 10000000
Problem p02862 (python)

Fixed submission:
def make_tables(m):
    fac=[1,1]
    finv=[1,1]
    inv=[0,1]
    for i in range(2,m+1):
        fac.append((fac[-1]*i)%mod)
        inv.append((-inv[mod%i]*(mod//i))%mod)
        finv.append(finv[i-1]*inv[i]%mod)
    return fac,finv

def calc_nCk(n,k,fac,finv):
    if n<k or (n<0 or k<0):
        return 0
#    k=min(k,n-k)
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod

x,y=map(int,input().split())
mod=10**9+7
n=(y-0.5*x)/1.5
if int(n)!=n:
    print(0)
else:
    m=(y+x)//3
    l=int(n)
    fac,finv=make_tables(m)
    ans = calc_nCk(m,l,fac,finv)
    print(ans)

Buggy submission (verdict: Runtime Error):
def make_tables(m):
    fac=[1,1]
    finv=[1,1]
    inv=[0,1]
    for i in range(2,m+1):
        fac.append((fac[-1]*i)%mod)
        inv.append((-inv[mod%i]*(mod//i))%mod)
        finv.append(finv[i-1]*inv[i]%mod)
    return fac,finv
 calc_nCk(n,k,fac,finv):
    if n<k or (n<0 or k<0):
        return 0
    k=min(k,n-k)
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod

x,y=map(int,input().split())
mod=10**9+7
n=(y-0.5*x)/1.5
if int(n)!=n:
    print(0)
else:
    m=(y+x)//3
    l=int(n)
    fac,finv=make_tables(m)
    ans = calc_nCk(m,l,fac,finv)
    print(ans)
Problem p02935 (python)

Fixed submission:
n=int(input())
v=list(map(int, input().split()))
vv=sorted(v)
for i in range(n-2):
    vv[i+1] = (vv[i]+vv[i+1]) / 2
print((vv[n-2]+vv[n-1])/2)

Buggy submission (verdict: Runtime Error):
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
v=lnii()
v.sort()

ans=v[0]
for i in range(1,n):
  ans=(ans+v[i])/2

print(ans
Problem p02987 (python)

Fixed submission:
s = input()
s_l = list(s)
s_ll = sorted(s_l)
if s_ll[0] == s_ll[1] and s_ll[2] == s_ll[3] and s_ll[1] != s_ll[2]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s=input()
print('Yes' if len(set(s))==2 and s.count(s[0]==2) else 'No')
Problem p03041 (python)

Fixed submission:
n, k = map(int, input().split())
s = list(input())
ans = ''
for i in range(len(s)):
    if i == k-1:
        ans += s[i].lower()
    else:
        ans += s[i]
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
s=input()
print(s[:k]+s[k].lower()+s[k+1:])
Problem p03221 (python)

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

ans=[[] for i in range(m)]
p_list=[[] for i in range(n+1)]

for i in range(m):
 p,y=map(int,input().split())

 ans[i]=str(p).zfill(6)

 p_list[p].append([i,y])

for pp in p_list:
 pp=sorted(pp,key=lambda x:x[1])
 num=0
 for ppp in pp:
  num+=1
  ans[ppp[0]]+=str(num).zfill(6)
 num=0

for i in ans:
 print(i)

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

ans=[[] for i in range(m)]
p_list=[[] for i in range(n)]

for i in range(m):
 p,y=map(int,input().split())

 ans[i]=str(p).zfill(6)
 p_list[p].append([i,y])

for pp in p_list:
 pp=sorted(pp,key=lambda x:x[1])
 num=0
 for ppp in pp:
  num+=1
  ans[ppp[0]]+=str(num).zfill(6)
 num=0

for i in ans:
 print(i)

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

ans=[[] for i in range(m)]
p_list=[[] for i in range(m)]

for i in range(m):
 p,y=map(int,input().split())

 ans[i]=str(p).zfill(6)
 p_list[p].append([i,y])

for pp in p_list:
 pp=sorted(pp,key=lambda x:x[1])
 num=0
 for ppp in pp:
  num+=1
  ans[ppp[0]]+=str(num).zfill(6)
 num=0

for i in ans:
 print(i)
Problem p03252 (python)

Fixed submission:
from collections import Counter
s=input()
t=input()
c1=Counter(s)
c2=Counter(t)
if sorted(c1.values())==sorted(c2.values()):
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
chokudai
redcoder

Buggy submission (verdict: Runtime Error):
s=input()
t=input()

d={}
for i in range(len(s)):
  if s[i]!=t[i]:
    if s[i] in d:
      if d[s[i]]!=t[i]
        print('No')
        exit()
      else:
       pass
    else:
      d[s[i]]=t[i]
  else:
    if s[i] in d and d[s[i]]!=t[i]:
      print('No')
      exit()
print('Yes')
Problem p03426 (python)

Fixed submission:
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

h,w,d=nii()

a_dict={}
for i in range(h):
  a=lnii()
  for j in range(w):
    a_dict[a[j]]=(i,j)

b_dict={}
for i in range(1,d+1):
  num=i
  cy,cx=a_dict[num]
  b_dict[num]=0
  while num+d<=h*w:
    num+=d
    ny,nx=a_dict[num]
    b_dict[num]=b_dict[num-d]+abs(cy-ny)+abs(cx-nx)
    cy=ny
    cx=nx

q=int(input())
for i in range(q):
  l,r=nii()
  ans=b_dict[r]-b_dict[l]
  print(ans)

Buggy submission (verdict: Runtime Error):
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

h,w,d=nii()

a_dict={}
for i in range(h):
  a=lnii()
  for j in range(w):
    a_dict[a[j]]=(i,j)

b_dict={}
for i in range(1,h*w):
  if i-d<=0:
    b_dict[i]=0
  else:
    oy,ox=a_dict[i-d]
    ny,nx=a_dict[i]
    b_dict[i]=b_dict[i-d]+abs(ny-oy)+abs(nx-ox)

q=int(input())
for i in range(q):
  l,r=nii()
  ans=b_dict[r]-b_dict[l]
  print(ans)

Buggy submission (verdict: Runtime Error):
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

h,w,d=nii()

a_dict={}
for i in range(h):
  a=lnii()
  for j in range(w):
    a_dict[a[j]]=(i,j)

b_dict={}
for i in range(1,d+1):
  num=i
  cy,cx=a_dict[num]
  b_dict[num]=0
  while num+d<h*w:
    num+=d
    ny,nx=a_dict[num]
    b_dict[num]=b_dict[num-d]+abs(cy-ny)+abs(cx-nx)
    cy=ny
    cx=nx

q=int(input())
for i in range(q):
  l,r=nii()
  ans=b_dict[r]-b_dict[l]
  print(ans)
Problem p03805 (python)

Fixed submission:
from itertools import permutations

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

cnt=0
for i in permutations(range(1,n)):
    if i[0] in tree[0]:
        t_cnt=1
        for j in range(1,len(i)):
            if i[j] in tree[i[j-1]]:
                t_cnt+=1
            else:
                break
        if t_cnt==n-1:
            cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
from itertools import permutations

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

cnt=0
for i in permutations(range(1,n)):
    if i[0] in tree[0]:
        t_cnt=1
        for j in range(1,len(i)):
            if i[j] in tree[i[j-1]]:
                t_cnt+=1
            else:
                break
        if t_cnt==n-1:
            cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
from itertools import permutations

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

cnt=0
for i in permutations(range(1,n)):
    if i[0] in tree[0]:
        t_cnt=1
        for j in range(1,len(i)):
            if i[j] in tree[i[j-1]]:
                t_cnt+=1
            else:
                break
        if t_cnt==m-1:
            cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
from itertools import permutations

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

cnt=0
for i in permutations(range(1,m)):
    if i[0] in tree[0]:
        t_cnt=1
        for j in range(1,len(i)):
            if i[j] in tree[i[j-1]]:
                t_cnt+=1
        if t_cnt==m-1:
            cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
from itertools import permutations

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

cnt=0
for i in permutations(range(1,m)):
    if i[0] in tree[0]:
        t_cnt=1
        for j in range(1,len(i)):
            if i[j] in tree[i[j-1]]:
                t_cnt+=1
        if t_cnt==m-1:
            cnt+=1
print(cnt)
Problem p03986 (python)

Fixed submission:
x=input()

c_s=0
c_t=0

for i in x:
  if i=='S':
    c_s+=1
  else:
    if c_s==0:
      c_t+=1
    else:
      c_s-=1

print(c_s+c_t)

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
for i in range(h):
    s=input()
    print(s+'\n'+s)
Problem p02592 (python)

Fixed submission:
n=97
def c(i,j,k):print('<',i,j,k)
def a(i,j,k):print('+',i,j,k)
def m(i,j,k):
	for t in range(59):
		a(k,k,k)
		for s in range(t+1):
			if t-30<s<30:a(i+t-s,j+s,98);c(n,98,99);a(k,99,k)
def d(x,i,j):
	for t in range(30):
		a(j+t-1,j+t-1,j+t)
		a(j+t,n,j+t)
		for s in range(j+t,j+29):a(s,s,s+1)
		c(j+29,x,i+t)
		a(j+t-1,j+t-1,j+t)
		a(j+t,i+t,j+t)
print(3933)
a(0,1,n)
c(2,n,n)
a(0,n,3)
a(1,n,4)
d(3,5,36)
d(4,36,67)
m(5,36,2)

Buggy submission (verdict: Runtime Error):
p=print
r=range
def a(i,j,k,l=0):p("+<"[l],i,j,k)
def b(i):a(i,i,i+1)
def d(x,i,j):
	for t in r(30):b(p:=j+t-1);a(q:=j+t,n,q);[*map(b,r(q,j+29))];a(j+29,x,i+t,1);b(p);a(q,i+t,q)
p(3933)
a(0,1,n:=97)
a(2,n,n,1)
a(0,n,3)
a(1,n,4)
d(3,5,36)
d(4,36,67)
for t in r(59):a(2,2,2);[t-30<s<30<(a(5+t-s,36+s,98),a(n,98,99,1),a(2,99,2))for s in r(t+1)]

Buggy submission (verdict: Runtime Error):
n=97
def c(i,j,k):print('<',i,j,k)
def a(i,j,k):print('+',i,j,k)
def d(x,i,j):
	for t in range(30):
		a(j+t-1,j+t-1,j+t)
		a(j+t,n,j+t)
		for s in range(j+t,j+29):a(s,s,s+1)
		c(j+29,x,i+t)
		a(j+t-1,j+t-1,j+t)
		a(j+t,i+t,j+t)
print(3932)
a(0,1,n)
c(2,n,n)
a(0,n,3)
a(1,n,4)
d(3,5,36)
d(4,36,67)
m(5,36,2)
for t in range(59):
	a(2,2,2)
	for s in range(t+1):
		if t-30<s<30:a(5+t-s,36+s,98);c(n,98,99);a(2,99,2)
Problem p02597 (python)

Fixed submission:
n = int(input())
s = input()
l = 0
r = n - 1
ans = 0

while l < r:
    while l < r and s[l] == 'R':
        l += 1
    while l < r and s[r] == 'W':
        r -= 1
    if l >= r:
        break
    ans += 1
    l += 1
    r -= 1

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
l = 0
r = n - 1
ans = 0
while l < r:
    while l < r && s[l] == 'R':
        l += 1
    while l < r && s[r] == 'W':
        r -= 1
    ans += 1
    l += 1
    r -= 1

print(ans)
Problem p02624 (python)

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

N = int(input())
Answer = 0

for i in range(1,N+1):
    cnt = N // i
    num = cnt * (cnt + 1) >> 1
    num *= i
    Answer += num

print(Answer)

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

@njit
def main():
    N = int(input())
    Answer = 0

    for i in range(1,N+1):
        cnt = N // i
        num = cnt * (cnt + 1) >> 1
        num *= i
        Answer += num

print(Answer)
main()
Problem p02831 (python)

Fixed submission:
from fractions import gcd
a, b = map(int, input().split())
print(a * b // gcd(a, b))

Buggy submission (verdict: Runtime Error):
from fractions import gcd
a = int(input())
b = int(input())
print(a * b // gcd(a, b))

Buggy submission (verdict: Runtime Error):
from fractions import gcd
a = int(input())
b = int(input())
print(a * b / gcd(a, b))
Problem p02627 (python)

Fixed submission:
a = str(input())
b = a.upper()
c = a.lower()
if b == a :
    print("A")
if c == a :
    print("a")

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
mylist = input().split()
mylist.sort()
c = 0
for i in range(b-1):
    c = c + int(mylist[i-1])
print(c)
Problem p02676 (python)

Fixed submission:
K = int(input())
S = input()
if K < len(S):
    A = ""
    for i in range(K):
        A = str(A) + S[i]
    A = str(A) + "..."
    S = A
print(S)

Buggy submission (verdict: Runtime Error):
K = int(input())
S = input()
A = ""
if K < len(S):
	for i in range(K):
    	A = A + S[i]
    A = A + "..."
else:
	A = S
print(A)
Problem p02693 (python)

Fixed submission:
K = int(input())
A, B = list(map(int,input().split()))
S = 0
for i in range(A,B+1):
	if i % K == 0:
		S = 1
		break
if S == 1:
	print("OK")
else:
	print("NG")

Buggy submission (verdict: Runtime Error):
a = int(input())
b, c = int(list(map(int, input().split())))
d = b//a
e = c//a
if d == e:
    print("Yes")
else:
    print("No")