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

Fixed submission:
import sys


from math import pi

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(get_ints())
def input(): return sys.stdin.readline().strip()

r = int(input())
print(2*pi*r)

Buggy submission (verdict: Runtime Error):
import sys

from math import pi

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(get_ints())
def input(): return sys.stdin.readline().strip().split()

r = int(input())
print(2*pi*r)

Buggy submission (verdict: Runtime Error):
import sys

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(get_ints())
def input(): return sys.stdin.readline().strip().split()

r = int(input())
print(2*pi*r)

Buggy submission (verdict: Runtime Error):
import sys
from math import pi
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(get_ints())
def input(): return sys.stdin.readline().strip().split()

r = int(input())
print(2*pi*r)
Problem p02899 (python)

Fixed submission:
import sys
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()

n=int(input())
Arr=get_array()
result=[]
for i in range(n):
  result.append((Arr[i],i+1))
result.sort()
ans=[]
for i in result:
  ans.append(i[1])
print(*ans)

Buggy submission (verdict: Runtime Error):
#
# Yet I'm feeling like
# 	There is no better place than right by your side
# 		I had a little taste
# 			And I'll only spoil the party anyway
# 				'Cause all the girls are looking fine
# 					But you're the only one on my mind

import sys
# import re
inf = float("inf")
# sys.setrecursionlimit(1000000)

# abc='abcdefghijklmnopqrstuvwxyz'
# abd={'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod,MOD=1000000007,998244353
# vow=['a','e','i','o','u']
# dx,dy=[-1,1,0,0,-1,1,-1,1],[0,0,1,-1,1,1,-1,-1]

# import operator as op
# from functools import reduce
# from collections import deque, Counter, OrderedDict,defaultdict
# from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
from math import ceil,floor,log,sqrt,factorial,pow,pi,gcd,log10,atan,tan
# from bisect import bisect_left,bisect_right,insort_left
# import numpy as np
# import queue
# from copy import deepcopy
# import random

def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()

n=int(input())
Arr=get_array()
result=[]
for i in range(n):
    result.append((Arr[i],i))
result.sort()
ans=[]
for i in result:
    ans.append(i[1]+1)
print(*ans)
Problem p02741 (python)

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]
S = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"
L = S.split(', ')
N = int(input())
print(L[N-1])

Buggy submission (verdict: Runtime Error):
import sys
def input():
    return sys.stdin.readline()[:-1]
H,W = map(int,input().split(' '))
A = W//2+1
if W==1 or H==1:
    print(1)
    exit()
if H%2==0:
    print(W*H//2)
else:
    print(W*(H-1)//2+A)
Problem p02787 (python)

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]

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

A = [None]*N
B = [None]*N
for i in range(N):
    a,b = list(map(int, input().split()))
    A[i] = a
    B[i] = b

INF = float('inf')
dp = [INF]*(H+1)
dp[H] = 0

for i in range(N):
    a = A[i]
    b = B[i]
    for j in range(H,0,-1):
        aft = j - a
        if aft<=0:
            dp[0] = min(dp[0],dp[j]+b)
        else:
            dp[aft] = min(dp[aft],dp[j]+b)
print(dp[0])

Buggy submission (verdict: Runtime Error):
import sys
def input():
    return sys.stdin.readline()[:-1]

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

A = [None]*N
B = [None]*N
for i in range(N):
    a,b = list(map(int, input().split()))
    A[i] = a
    B[i] = b

INF = float('inf')
dp = [INF]*(H+1)
dp[H] = 0

for i in raneg(N):
    a = A[i]
    b = B[i]
    for j in range(H,0,-1):
        aft = j - a
        if aft<=0:
            dp[0] = min(dp[0],dp[j]+b)
        else:
            dp[aft] = min(dp[aft],dp[j]+b)
print(dp[0])
Problem p02844 (python)

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]

N = int(input())
S = input()
ans = 0
for i in range(1000):
    num = str(i).zfill(3)
    _idx = 0
    flag = True
    for n in num:
        ind = S[_idx:].find(n)
        if ind==-1:
            flag = False
            break
        else:
            _idx = _idx + ind+1
    if flag:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):

import sys
def input():
    return sys.stdin.readline()[:-1]

N = int(input())
S = list(input())
dp = {}
st = [None]*9
ok = []
l = [None]*N
las = 0
for i in range(N-1,-1,-1):
    s = S[i]
    st[int(s)] = i
    l[i] = las
    if s in dp:
        dp[s].append(i)
    else:
        dp[s] = [i]
        las += 1

ans = 1
for i in range(0,9):
    if st[i]==None:
        continue
    start = st[i] #iが初めて出てくる位置
    for j in range(1,10):
        k = str(j)
        if not k in dp:
            continue
        middle = dp[k]
        ok = len(dp)-1
        ng = 0
        while ok-ng>1:
            m = (ok+ng)//2
            if middle[m]>start:
                ng = m
            else:
                ok = m
        ans *= l[ok]
print(ans)
Problem p02882 (python)

Fixed submission:
import sys,math
def input():
    return sys.stdin.readline()[:-1]


a,b,x = map(int,input().split(' '))

t = x/(a**2)
half = b/2
if t<half:
    a_2 = ((x/a)/b)*2
    b_2 = b
else:
    a_2 = a
    b_2 = (b-t)*2
c = (a_2**2+b_2**2)**0.5
cos1 = ((a_2**2)+(c**2)-(b_2**2))/(2*a_2*c)
print(math.degrees(math.acos(cos1)))

Buggy submission (verdict: Runtime Error):
import sys,math
def input():
    return sys.stdin.readline()[:-1]


a,b,x = map(int,input().split(' '))

t = x/(a**2)
half = b/2
if t<half:
    a_2 = x/b
    b_2 = b
else:
    a_2 = a
    b_2 = (b-t)*2
c = (a_2**2+b_2**2)**0.5
cos1 = (a_2**2+c**2-b_2**2)/(2*a*c)
print(math.degrees(math.acos(cos1)))
Problem p02927 (python)

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]
M,D = map(int,input().split(' '))

cnt = 0
for i in range(1,M+1):
    for j in range(1,D+1):
        dd = j // 10
        d  = j % 10
        if dd>=2 and d>=2 and d*dd==i:
            cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
import sys
def input():
    return sys.stdin.readline()[:-1]

N = int(input())
S = list(input())

if S[0]!='B' or S[-1]!='B':
    print(0)
    exit()

mod = 10**9 + 7
cnt_l = 1
cnt_r = 0
pre_s = 'B'
pre_d = 1 #1がleft
ans = 1

for i in range(1,N*2):
    s = S[i]

    if pre_s==s:
        if pre_d==1:
            d = 0
            ans *= cnt_l - cnt_r #ここまでに出てきたLeftの総数 - ここまでに出てきたrightの総数
            cnt_r += 1
        else:
            d = 1
            cnt_l += 1
    else:
        if pre_d==1:
            d = 1
            cnt_l += 1
        else:
            d = 0
            ans *= cnt_l - cnt_r #ここまでに出てきたLeftの総数 - ここまでに出てきたrightの総数
            cnt_r += 1
    pre_s = s
    pre_d = d

for i in range(1,N+1):
    ans *= i
    ans %= mod
if cnt_l!=N:
    print(0)
    exit()

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
def input():
    return sys.stdin.readline()[:-1]

N = int(input())
S = list(input())

if S[0]!='B' or S[-1]!='B':
    print(0)
    exit()

mod = 10**9 + 7
cnt_l = 1
cnt_r = 0
pre_s = 'B'
pre_d = 1 #1がleft
ans = 1

for i in range(1,N*2):
    s = S[i]

    if pre_s==s:
        if pre_d==1:
            d = 0
            ans *= cnt_l - cnt_r #ここまでに出てきたLeftの総数 - ここまでに出てきたrightの総数
            cnt_r += 1
        else:
            d = 1
            cnt_l += 1
    else:
        if pre_d==1:
            d = 1
            cnt_l += 1
        else:
            d = 0
            ans *= cnt_l - cnt_r #ここまでに出てきたLeftの総数 - ここまでに出てきたrightの総数
            cnt_r += 1
    pre_s = s
    pre_d = d

for i in range(1,N+1):
    ans *= i
    ans %= mod
if cnt_l!=N:
    print(0)
    exit()
Problem p02995 (python)

Fixed submission:
a,b,c,d = map(int,input().split(' '))

def gcd(m,n):
    x = max(m,n)
    y = min(m,n)
    if x%y == 0:
        return y
    else:
        while x%y != 0:
            z = x%y
            x = y
            y = z
        else:
            return z

def lcm(x, y):
    ans = (x * y) // gcd(x, y)
    return ans

l_c = (a-1)//c
l_d = (a-1)//d
l_c_d = (a-1)//lcm(c, d)

l_ans = a - 1 - (l_c + l_d - l_c_d)


g_c = b//c
g_d = b//d
g_c_d = b//lcm(c, d)
g_ans = b - (g_c + g_d - g_c_d)

print(g_ans - l_ans)

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

def lcm(x, y):
    return (x * y) // math.gcd(x, y)
    
l_c = int((a-1)/c)
l_d = int((a-1)/d)
l_c_d = int((a-1)/lcm(c, d))

l_ans = a - 1 - (l_c + l_d - l_c_d)


g_c = int(b/c)
g_d = int(b/d)
g_c_d = int(b/lcm(c, d))
g_ans = b - (g_c + g_d - g_c_d)

print(g_ans - l_ans)
Problem p02996 (python)

Fixed submission:
N = int(input())
l = [None]*N
s = []
for i in range(N):
    k = list(map(int,input().split()))
    if k[0]==k[1]:
        s.append(k)
        l[i] = [0,0]
    else:
        l[i] = k

if len(s)>1:
    print("No")
else:
    l = sorted(l, key=lambda x: x[1])
    cnt = 0
    if len(s)==1:
        cnt += s[0][1]

    flag = True
    for j in l:
        if j==[0,0]:
            continue
        else:
            cnt += j[0]
        if cnt>j[1]:
            print("No")
            flag = False
            break
    if flag:
        print("Yes")

Buggy submission (verdict: Runtime Error):
N = int(input())
l = [None]*N
s = []
for i in range(N):
    k = list(map(int,input().split()))
    if k[0]==k[1]:
        s.append(k)
    else:
        l[i] = k

if len(s)>1:
    print("No")
else:
    l = sorted(l, key=lambda x: x[1])
    cnt = 0
    if len(s)==1:
        cnt += s[0][1]

    flag = True
    for j in l:
        if j==None:
            continue
        else:
            cnt += j[0]
        if cnt>j[1]:
            print("No")
            flag = False
            break
    if flag:
        print("Yes")

Buggy submission (verdict: Runtime Error):
N = int(input())
l = [None]*N
s = []
for i in range(N):
    k = list(map(int,input().split()))
    if k[0]==k[1]:
        s.append(k)
    else:
        l[i] = k

if len(s)>1:
    print("No")
else:
    l = sorted(l, key=lambda x: x[1])
    cnt = 0
    if len(k)==1:
        cnt += s[0][1]

    flag = True
    for j in l:
        if j==None:
            continue
        else:
            cnt += j[0]
        if cnt>j[1]:
            print("No")
            flag = False
            break
    if flag:
        print("Yes")
Problem p03005 (python)

Fixed submission:
H,W = map(int,input().split(' '))
if not W==1:
    print(H-W)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
H,W = map(int,input().split(' '))
if not K==1:
    print(H-K)
else:
    print(0)
Problem p03050 (python)

Fixed submission:
import math

N = int(input())
n = int(math.sqrt(N))
count=0
for i in range(1,n+1):
    d = N - i
    if d%i==0 and i < (N // i) -1:
        k = d//i
        count+=k
print(count)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
n = int(math.sqrt(N))
count=0
for i in range(1,n+1)
    d = N - i
    if d%i==0:
        k = int(d/i)
        count+=k
print(count)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
n = int(math.sqrt(N))
count=0
for i in range(1,n+1:
    d = N - i
    if d%i==0:
        k = int(d/i)
        count+=k
print(count)
Problem p03067 (python)

Fixed submission:
a,b,c = map(int,input().split(' '))
if a<b:
    if c>a and c<b:
        print('Yes')
    else:
        print('No')
else:
    if c<a and c>b:
        print('Yes')
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
w=b=0
mn=0
for sk in s:
    if sk=="#":
        b+=1
    else:
        w-=1
    if mn>b+w:
        mn=b+w
print(mn-w)
Problem p03085 (python)

Fixed submission:
b = input()
if b=="A":
    print("T")
elif b=="T":
    print("A")
elif b=="G":
    print("C")
elif b=="C":
    print("G")

Buggy submission (verdict: Runtime Error):
N,Q = map(int,input().split())
S = input()
c_l=[]
for i in range(Q):
    a,b = map(int,input().split())
    if b==N:
        l=S[a-1:]
    else:
        l=S[a-1:b]
    c = l.count("AC")
    c_l.append(c)
for i in c_l:
    print(i)

Buggy submission (verdict: Runtime Error):
N,Q = map(int,input().split())
S = input()
count_l=[]
for i in range(Q):
    a,b = map(int,input().split())
    flag=False
    counting=0
    if b==N:
        l=S[a-1:]
    else:
        l=S[a-1:b]
    #print(l)
    counting = l.count("AC")
    """for ii in l:
        #print(ii)
        if ii=="A":
            flag=True
        elif ii=="C" and flag==True:
            counting+=1
            flag=False"""
    count_l.append(counting)
for i in count_l:
    print(i)
Problem p03436 (python)

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]

"""
H Wの後に
#.#.
###.
みたいな文字列を受け取る
"""
H,W = map(int,input().split(' '))
MAP = [['#']*(W+1)] + [None]*H

for i in range(1,H+1):
    MAP[i] = ['#'] + list(map(str,input()))
import queue
q = queue.Queue()


MAP[H][W] = 'G'
visited = [None]*(H+1)
for i in range(H+1):
    visited[i] = [False]*(W+1)

d_num = 0
for i in range(1,H+1):
    for j in range(1,W+1):
        if MAP[i][j]=='#':
            d_num += 1

def is_okay(x,y):
    if not (0<x<W+1) or not (0<y<H+1):
        return False
    if visited[y][x] or MAP[y][x]=='#':
        return False
    return True

n = 0
q.put([1,1,n])
ans = 10**7 + 7

while not q.empty():
    x,y,n = q.get()
    k = MAP[y][x]

    n += 1
    if k=='G':
        ans = min(ans,n)
        break

    if is_okay(x+1,y):
        q.put([x+1,y,n])
        visited[y][x+1] = True
    if is_okay(x-1,y):
        q.put([x-1,y,n])
        visited[y][x-1] = True
    if is_okay(x,y+1):
        q.put([x,y+1,n])
        visited[y+1][x] = True
    if is_okay(x,y-1):
        q.put([x,y-1,n])
        visited[y-1][x] = True


if not ans==10**7 + 7:
    ANS = H*W - ans - d_num
else:
    ANS = -1

print(ANS)

Buggy submission (verdict: Runtime Error):

import sys
def input():
    return sys.stdin.readline()[:-1]

"""
H Wの後に
#.#.
###.
みたいな文字列を受け取る
"""
H,W = map(int,input().split(' '))
MAP = [['#']*(W+1)] + [None]*H

for i in range(1,H+1):
    MAP[i] = ['#'] + list(map(str,input()))
import queue
q = queue.Queue()


MAP[H][W] = 'G'
visited = [None]*(H+1)
for i in range(H+1):
    visited[i] = [False]*(W+1)

d_num = 0
for i in range(1,H+1):
    for j in range(1,W+1):
        if MAP[i][j]=='#':
            d_num += 1

def is_okay(x,y):
    if not (0<x<W+1) or not (0<y<H+1):
        return False
    if visited[y][x] or MAP[y][x]=='#':
        return False
    return True

n = 0
q.put([1,1,n])
ans = 10**7 + 7

while not q.empty():
    x,y,n = q.get()
    k = MAP[y][x]

    n += 1
    if k=='G':
        ans = min(ans,n)
        break

    if is_okay(x+1,y): q.put([x+1,y,n]),visited[y][x+1] = True
    if is_okay(x-1,y): q.put([x-1,y,n]),visited[y][x-1] = True
    if is_okay(x,y+1): q.put([x,y+1,n]),visited[y+1][x] = True
    if is_okay(x,y-1): q.put([x,y-1,n]),visited[y-1][x] = True


if not ans==10**7 + 7:
    ANS = H*W - ans - d_num
else:
    ANS = -1

print(ANS)
Problem p03455 (python)

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

if a*b%2==0:
  print("Even")
else:
  print("Odd")

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a*b%2==0:
  print("Even")
 else:
  print("Odd")
Problem p03471 (python)

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

t = int(Y/10000)
end=False
for x in range(0,t+1):
    for y in range(0,N+1):
        if x+y>N:
            break
        z = N-x-y
        num = x*10000+y*5000+z*1000
        if num==Y:
            print(str(x)+" "+str(y)+" "+str(z))
            end=True
            break
    if end:
        break
if end==False:
    print("-1 -1 -1")

Buggy submission (verdict: Runtime Error):
N,Y = map(int, input().split(" "))
f = False
t = int(Y/10000)
for a in range(t+1):
    for b in range(N+1):
        if a+b>N:
            break
        c=N-a-b
        num = a*10000+b*5000+c*1000
        if num==Y:
            print(str(a)+" "+ str(b)+" "+str(c)')
            f=True
            break
    if f:
        break
if f==False:
    print('-1 -1 -1')

Buggy submission (verdict: Runtime Error):
N,Y = map(int, input().split(" "))
f = False
t = int(Y/10000)
for a in range(t+1):
    for b in range(N+1):
        if a+b>N:
            break
        c=N-a-b
        tot = a*10000+b*5000+c*1000
        if tot==Y:
            print(f'{a} {b} {c}')
            f=True
            break
    if f:
        break
if f==False:
    print('-1 -1 -1')

Buggy submission (verdict: Runtime Error):
N,Y = map(int, input().split(" "))
flag = False
t = int(Y/10000)
for a in range(t+1):
    for b in range(N+1):
        if a+b>N:
            break
        c=N-(a+b)
        tot = a*10000+b*5000+c*1000
        if tot==Y:
            flag=True
            break
    if flag:
        break
if flag:
    print(f'{a} {b} {c}')
else:
    print('-1 -1 -1')

Buggy submission (verdict: Runtime Error):
N,Y = map(int, input().split(" "))
flag = False
t = int(Y/10000)
for a in range(t+1):
    for b in range(N+1):
        c=N-(a+b)
        if c<0:
            break
        tot = a*10000+b*5000+c*1000
        if tot==Y:
            flag=True
            break
    if flag:
        break
if flag:
    print(f'{a} {b} {c}')
else:
    print('-1 -1 -1')

Buggy submission (verdict: Runtime Error):
N,Y = map(int, input().split(" "))
flag = False
for a in range(N+1):
    for b in range(N+1):
        c=N-(a+b)
        if c<0:
            break
        tot = a*10000+b*5000+c*1000
        if tot==Y:
            flag=True
            break
    if flag:
        break
if flag:
    print(f'{a} {b} {c}')
else:
    print('-1 -1 -1')

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

t = int(Y/10000)
end=False
for x in range(1,t+1):
    for y in range(1,20001):
        for z in range(1,20001):
            ans = x*10000+y*5000+z*1000
			if ans==Y and x+y+z==N:
                print(str(x)+" "+str(y)+" "+str(z))
                end=True
                break
        if end:
            break
    if end:
        break
if end==False:
    print("-1 -1 -1")
Problem p03493 (python)

Fixed submission:
abc = input()
abc = str(abc)
print(abc.count("1"))

Buggy submission (verdict: Runtime Error):
a,b,c = map(str, input().split())
al = [a,b,c]
print(al.count("1"))

Buggy submission (verdict: Runtime Error):
abc = map(int, input().split())
print(abc.count(1))
Problem p02705 (python)

Fixed submission:
from math import pi
R = int(input())
print(2*R*pi)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
N = int(input())
A = list(map(int,input().split()))
d = defaultdict(int)
for a in A:
    d[a-1] += 1
for i in range(N):
    print(d[i])
Problem p02861 (python)

Fixed submission:
import math
import numpy as np
import itertools
N = int(input())
x = []; y= []
for _ in range(N):
    x_,y_ = map(int,input().split())
    x.append(x_)
    y.append(y_)
lis = np.zeros((8,8))
for i in range(N):
    for j in range(N):
        lis[i,j] = math.sqrt((x[i]-x[j])**2 + (y[i]-y[j])**2)
num = 0
su = 0
ite = itertools.permutations([i for i in range(N)])
for it in ite:
    for i in range(len(it)-1):
        su += lis[it[i],it[i+1]]
    num += 1
print(su/num)

Buggy submission (verdict: Runtime Error):
import math
import numpy as np
import itertools
N = int(input())
x = []; y= []
for _ in range(N):
    x_,y_ = map(int,input().split())
    x.append(x_)
    y.append(y_)
lis = np.zeros((8,8))
for i in range(N):
    for j in range(N):
        lis[i,j] = math.sqrt((x[i]-x[j])**2 + (y[i]-y[j])**2)
num = 0
su = 0
ite = itertools.permutations([i for i in range(N)])
for it in ite:
    for i in range(len(it)-1):
        su += lis[it[i],it[i+1]]
    num += 1
print(su/num)

Buggy submission (verdict: Runtime Error):
import math
import numpy as np
from itertools import permutations
N = int(input())
x = []; y= []
for _ in range(N):
    x_,y_ = map(int,input().split())
    x.append(x_)
    y.append(y_)
lis = np.zeros((8,8))
for i in range(N):
    for j in range(N):
        lis[i,j] = math.sqrt((x[i]-x[j])**2 + (y[i]-y[j])**2)
num = 0
su = 0
ite = permutations([i for i in range(N)])
for it in ite:
    for i in range(len(it)-1):
        su += lis[it[i],it[i+1]]
    num += 1
print(su/num)
Problem p02913 (python)

Fixed submission:
#https://atcoder.jp/contests/abc141/submissions/7539109
#Z-Algorithm
n = int(input())
s = input()
 
a = ""
ans = 0
for i in range(n):
    a += s[i]
    while(len(a) > 0):
        if a in s[i+1:]:    #見つかる限りこの処理
            ans = max(ans,len(a))
            break
        else:               #ダメなら次の文字を接頭辞に、短いものは調べなくてよい
            a = a[1:]
print(ans)

Buggy submission (verdict: Runtime Error):
#https://atcoder.jp/contests/abc141/submissions/7539109
#Z-Algorithm
n = int(input())
s = input()
 
a = ""
ans = 0
for i in range(n):
    a += s[i]
    while(len(a) > 0):
        if a in s[i+1:]:    #見つかる限りこの処理
            ans = max(ans,len(a))
            break
        else:               #ダメなら次の文字を接頭辞に、短いものは調べなくてよい
        a = a[1:]
print(ans)
Problem p02921 (python)

Fixed submission:
S = list(input())
T = list(input())
ans = 0
for i in range(3):
    if S[i] == T[i]:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque
N = int(input())
A = [deque(list(map(int, input().split()))) for _ in range(N)]
ans = 0
t = 0
for i in range(10**3+1):
    for k in range(N):
        if A[k] != deque([]):
            if A[k][0] == 0:
                A[k].popleft()
        else:
            t += 1
    if t == N:
        break
    t = 0
    for j in range(N):
        if A[j]:
            tmp = A[j][0]
        else:
            continue
        if tmp-1 > j and A[tmp-1][0] -1 == j:
            A[j][0] = 0
            A[tmp-1][0] = 0
    ans += 1
if ans == 1001:
    print(-1)
    exit()
print(ans-1)
Problem p02923 (python)

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
ans = 0
ansk = 0
tmp = -1
while tmp < N:
    tmp += 1
    if ans > 0:
        tmp += ans-1
        ans = 0
        continue
    for j in range(tmp+1,N):
            if H[j-1] < H[j]:
                ansk = max(ansk,ans)
                break
            ans += 1
            if j == N-1:
                ansk = max(ansk,ans)
                tmp = N
                break
print(ansk)

Buggy submission (verdict: Runtime Error):
A,B = map(int, input().split())
ans = 0
b = A
for i in range(21):
    ans += 1
    if b >= B:
        break
    b += A-1
print(ans)
Problem p02927 (python)

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

ans = 0

if D <= 21:
    ans = 0
else:
    for d_ in range(22,D+1):
        d = list(map(int, str(d_)))
        if int(d[0])<2 or int(d[1])<2:
            continue
        for m in range(1,M+1):
            if d[0] * d[1] == m:
                ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):

M = 10**9+7
N = int(input())
S = list(input())
s = []

#0ならW、1ならB
s_append = s.append
for i in range(2*N):
    if S[i] == "B":
        s_append(1)
    else:
        s_append(0)

#端が0なら0を返す
if s[0] == 0 or s[2*N-1] == 0:
    print(0)
    exit()

ans = 0
lis = [0] #0なら左、1なら右
#全て0にする
lis_append = lis.append
for j in range(1,2*N):
    j1 = lis[j-1]
    if s[j-1] != s[j]:
        lis_append(j1)
    elif j1 == 0:
        lis_append(1)
    else:
        lis_append(0)

#左と右の数が違ったら0を返す
if lis.count(0) != lis.count(1):
    print(0)
    exit()

#"右"が選べる"左"の選択肢を掛けていく
cnt = 1
ans = 1
for k in range(1,2*N):
    if lis[k] == 0:
        cnt += 1
    else:
        ans *= cnt
        cnt -= 1

#N!をかける
for l in range(1,N+1):
    ans *= l
    ans %= M
print(ans)