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

Fixed submission:
N, A = map(int, input().split())
X = list(map(lambda x: int(x) - A, input().split()))
maxn = max(max(X), A)
 
dp = [[0 for _ in range(2 * N * maxn + 1)] for _ in range(N + 1)]
dp[0][N * maxn] = 1
 
for i in range(N):
    for k in range(2 * N * maxn + 1):
        dp[i + 1][k] = dp[i][k]
        if 0 <= k - X[i] <= 2 * N * maxn:
            dp[i + 1][k] += dp[i][k - X[i]]
 
print(dp[N][N * maxn] - 1)

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

dp = [[[0]*(n*M+1) for _ in range(n+1)] for _ in range(n+1)]
dp[0][0][0] = 1
for j in range(n):
    for k in range(n+1):
        for s in range(n*M+1):
            if dp[j][k][s]:
                dp[j+1][k][s] += dp[j][k][s]
                dp[j+1][k+1][s + x[j]] += dp[j][k][s]
 
ans = 0
for k in range(1, n+1):
    ans += dp[n][k][k*a]
print(ans)

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

dp = [[[0]*(n*M+1) for _ in range(n+1)] for _ in range(n+1)]
dp[0][0][0] = 1
for j in range(n):
    for k in range(n+1):
        for s in range(n*M+1):
            if dp[j][k][s]:
                dp[j+1][k][s] += dp[j][k][s]
                dp[j+1][k+1][s + x[j]] += dp[j][k][s]
 
ans = 0
for k in range(1, n+1):
    ans += dp[n][k][k*a]
print(ans)

Buggy submission (verdict: Runtime Error):
N, A = map(int, input().split())
X = list(map(lambda x: int(x) - A, input().split()))
maxn = max(max(X), A)
 
dp = [[0 for _ in range(2 * N * maxn + 1)] for _ in range(N + 1)]
dp[0][N * maxn] = 1
 
for i in range(N):
    for k in range(2 * N * maxn + 1):
        dp[i + 1][k] = dp[i][k]
        if 0 <= k - X[i] <= 2 * N * maxn:
            dp[i + 1][k] += dp[i][k - X[i]]
 
print(dp[N][N * maxn] - 1)
N, A = map(int, input().split())
X = list(map(lambda x: int(x) - A, input().split()))
maxn = max(max(X), A)

dp = [[0 for _ in range(2 * N * maxn + 1)] for _ in range(N + 1)]
dp[0][N * maxn] = 1

for i in range(N):
    for k in range(2 * N * maxn + 1):
        dp[i + 1][k] = dp[i][k]
        if 0 <= k - X[i] <= 2 * N * maxn:
            dp[i + 1][k] += dp[i][k - X[i]]

print(dp[N][N * maxn] - 1)

Buggy submission (verdict: Runtime Error):
N, A = map(int, input().split())
X = list(map(lambda x: int(x) - A, input().split()))
maxn = max(max(X), A)
 
dp = [[0 for _ in range(2 * N * maxn + 1)] for _ in range(N + 1)]
dp[0][N * maxn] = 1
 
for i in range(N):
    for k in range(2 * N * maxn + 1):
        dp[i + 1][k] = dp[i][k]
        if 0 <= k - X[i] <= 2 * N * maxn:
            dp[i + 1][k] += dp[i][k - X[i]]
 
print(dp[N][N * maxn] - 1)
N, A = map(int, input().split())
X = list(map(lambda x: int(x) - A, input().split()))
maxn = max(max(X), A)

dp = [[0 for _ in range(2 * N * maxn + 1)] for _ in range(N + 1)]
dp[0][N * maxn] = 1

for i in range(N):
    for k in range(2 * N * maxn + 1):
        dp[i + 1][k] = dp[i][k]
        if 0 <= k - X[i] < 2 * N * maxn:
            dp[i + 1][k] += dp[i][k - X[i]]

print(dp[N][N * maxn] - 1)
Problem p02803 (python)

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

max_step = 0
for i in range(H * W):
    sy, sx = i // W, i % W
    if S[sy][sx] == "#":
        continue

    steps = [[-1] * W for _ in range(H)]
    steps[sy][sx] = 0
    queue = [(sy, sx)]
    while len(queue) >= 1:
        cy, cx = queue.pop(0)
        for dy, dx in ((0, 1), (0, -1), (1, 0), (-1, 0)):
            ny, nx = cy + dy, cx + dx
            if not (0 <= ny <= H - 1 and 0 <= nx <= W - 1):
                continue
            if S[ny][nx] == "#" or steps[ny][nx] >= 0:
                continue
            queue.append((ny, nx))
            steps[ny][nx] = steps[cy][cx] + 1

    ms = max(max(r) for r in steps)
    max_step = max(ms, max_step)

print(max_step)

Buggy submission (verdict: Runtime Error):
    H, W = map(int, input().split())
    S = [list(input()) for _ in range(H)]
     
    max_step = 0
    for i in range(H * W):
        sy, sx = i // W, i % W
        if S[sy][sx] == "#":
            continue
     
        steps = [[-1] * W for _ in range(H)]
        steps[sy][sx] = 0
        queue = [(sy, sx)]
        while len(queue) >= 1:
            cy, cx = queue.pop(0)
            for dy, dx in ((0, 1), (0, -1), (1, 0), (-1, 0)):
                ny, nx = cy + dy, cx + dx
                if not (0 <= ny <= H - 1 and 0 <= nx <= W - 1):
                    continue
                if S[ny][nx] == "#" or steps[ny][nx] >= 0:
                    continue
                queue.append((ny, nx))
                steps[ny][nx] = steps[cy][cx] + 1
     
        ms = max(max(r) for r in steps)
        max_step = max(ms, max_step)
     
    print(max_step)
Problem p02947 (python)

Fixed submission:
from collections import Counter

N = int(input())
S = []
for _ in range(N):
    S.append("".join(sorted(input())))

c = Counter(S)
print(sum([k*(k-1)//2 for k in c.values()]))

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

N = int(input())
S = ["".join(sorted(input())) for _ in range(N)]
c = Counter(S)
print(sum([k*(k-1)//2 for k in c.values()]))
Problem p02995 (python)

Fixed submission:
from fractions import gcd


def wari(x, c, d):
    nc = x // c
    nd = x // d
    ncd = x // ((c * d) // gcd(c, d))
    return x - nc - nd + ncd


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

nb = wari(B, C, D)
na = wari(A - 1, C, D)
print(nb - na)

Buggy submission (verdict: Runtime Error):
import math

A, B, C, D = map(int, input().split(" "))
r = B - A + 1
n_C = round(r / C)
n_D = round(r / D)
n_CD = round(r / ((C * D) // math.gcd(C, D)))
print(r - (n_C + n_D - n_CD))

Buggy submission (verdict: Runtime Error):
import math

A, B, C, D = map(int, input().split(" "))
r = B - A + 1
n_C = round(r / C)
n_D = round(r / D)
n_CD = round(r / ((C * D) // math.gcd(C, D)))
print(r - (n_C + n_D - n_CD))
Problem p03006 (python)

Fixed submission:
N = int(input())
x_list, y_list = [], []
for _ in range(N):
    x, y = map(int, input().split(" "))
    x_list.append(x)
    y_list.append(y)

vec_counts = {0: 0}
for x1, y1 in zip(x_list, y_list):
    for x2, y2 in zip(x_list, y_list):
        v = x1 - x2, y1 - y2
        if v != (0, 0):
            if v in vec_counts:
                vec_counts[v] += 1
            else:
                vec_counts[v] = 1

print(N - max(vec_counts.values()))

Buggy submission (verdict: Runtime Error):
N = int(input())
x_list, y_list = [], []
for _ in range(N):
    x, y = map(int, input().split(" "))
    x_list.append(x)
    y_list.append(y)

vec_counts = {}
for x1, y1 in zip(x_list, y_list):
    for x2, y2 in zip(x_list, y_list):
        v = x1 - x2, y1 - y2
        if v != (0, 0):
            if v in vec_counts:
                vec_counts[v] += 1
            else:
                vec_counts[v] = 1

print(N - max(vec_counts.values()))
Problem p03060 (python)

Fixed submission:
import numpy as np

N = int(input())
V = np.array([int(v) for v in input().split()])
C = np.array([int(c) for c in input().split()])
R = V - C
print(R[R > 0].sum())

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

N = int(input())
V = np.array([int(v) for v in input().split()])
C = np.array([int(c) for c in input().split()])
R = V - C
print(R[R > 0].sum())
Problem p03244 (python)

Fixed submission:
from collections import Counter

input()
V = [int(v) for v in input().split()]
count1 = 0
count2 = 0
c11 = Counter(V[::2]).most_common()[0][0]
c12 = Counter(V[1::2]).most_common()[0][0]
for v1, v2 in zip(V[::2], V[1::2]):
    if v1 != c11:
        count1 += 1
    if v2 != c12:
        count2 += 1
c21 = Counter(V[1::2]).most_common()
c22 = Counter(V[::2]).most_common()
c21.append((0, 1))
c22.append((0, 1))
c21 = c21[0][0] if c21[0][0] != c11 else c21[1][0]
c22 = c22[0][0] if c22[0][0] != c12 else c22[1][0]
for v1, v2 in zip(V[1::2], V[::2]):
    if v1 != c21:
        count1 += 1
    if v2 != c22:
        count2 += 1
print(min(count1, count2))

Buggy submission (verdict: Runtime Error):
input()
V = [int(v) for v in input().split()]
count = 0
c1 = Counter(V[::2] + [0]).most_common()[0][0]
for v in V[::2]:
    if v != c1:
        count += 1
c2 = Counter(V[1::2] + [0]).most_common()
c2 = c2[0][0] if c1 != c2[0][0] else c2[1][0]
for v in V[1::2]:
    if v != c2:
        count += 1
print(count)
Problem p02600 (python)

Fixed submission:
x = int(input())
p = 599
for i in range(8):
    
    if x <= p:
        print(8-i)
        exit()
    p += 200

Buggy submission (verdict: Runtime Error):
from copy import deepcopy
n,k=map(int, input().split())
a=list(map(int,input().split()))
tmp = 1
for i in range(k):
    tmp*=a[i]
p = tmp
p //= a[0]
p *= a[k]
for j in range(n-k):
    #print(tmp,p)
    if tmp < p:
        print("Yes")
    else:
        print("No")
    if k+j+1 > n-1:
        break
    tmp = p
    #print(a[j+1],a[k+j])
    p //= a[j+1]
    p *= a[k+j+1]
Problem p02639 (python)

Fixed submission:
num = list(map(int, input().split()))
print(num.index(0)+1)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
a.sort()
M = a[-1]+1
t=[True]*M


for i in a:
    if t[i] == False:
        continue
    if a.count(i)>1:
        t[i] = False
    for j in range(2*i,M,i):
        t[j] = False
ans = 0
for k in a:
    if t[k] == True:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
M = max(a)+1
t=[True]*M
a.sort()

for i in a:
    if t[i] == False:
        continue
    if a.count(i)>1:
        t[i] = False
    for j in range(2*i,M,i):
        t[j] = False
ans = 0
for k in a:
    if t[k] == True:
        ans += 1

print(ans)
Problem p02642 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
M = max(a)+1
t=[True]*M
a.sort()
s=set(a)
pre = 0
for i in a:
    if t[i] == 0:
        continue
    if pre == i:
        t[i] = False
    for j in range(2*i,M,i):
        t[j] = False
    pre = i
ans = 0
for k in a:
    if t[k] == True:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int, input().split()))
a.sort()
ans = 0
c= 0 #調べ始める位置する数
if a[0] != a[1]:
    c = 1
    ans = 1
else:
    c = a.count(a[0])

for i in range(c,n,1):
    for j in a[:i]:
        if a[i]%j == 0:
            break
    else:
        ans += 1
print(ans)
Problem p02743 (python)

Fixed submission:
a, b, c = map(int, input().split())
if c > a+b and 4*a*b < (c-a-b)**2:
  print("Yes")
else:
  print("No")
'''
浮動小数点は長い数を扱うと誤差が生じる
また、整数で計算しようとした時も√の中身は0以上であるという条件から
c > a+b　を忘れてはいけない
'''

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
if a, b, c < 10**5:
  if 4*a*b < (c-a-b)**2 and c-a-b >0:
    print("Yes")
  else:
    print("No")

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
if a, b, c < 10**5:
  if 4*a*b < (c-a-b)**2:
    print("Yes")
  else:
    print("No")
else:
  if a+b-c < 2*(a**0.5)*(b**0.5) < c-a-b:
    print("Yes")
  else:
    print("No")
Problem p02760 (python)

Fixed submission:
a = [list(map(int,input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
for number in b:
    for i in range(3):
        if number in a[i]:
            a[i][a[i].index(number)] = 0
if a[0][0] == a[1][1] == a[2][2] == 0 or a[2][0] == a[1][1] == a[0][2] == 0:
    print('Yes')
else:
    for i in range(3):
        if a[i][0] == a[i][1] == a[i][2] == 0:
            print('Yes')
            break
        elif a[0][i] == a[1][i] == a[2][i] == 0:
            print('Yes')
            break
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
a = [list(map(int,input().split())) for i in range(3)]
n = int(input())
b = [int(input()) for i in range(n)]
for number in b:
    for i in range(3):
        if number in a[i]:
            a[i][a[i].index(number)] = 0
if a[0][0] == a[1][1] == a[2][2] == 0 or a[2][0] == a[1][1] == a[0][2] == 0:
    print('Yes')
else:
    for i in range(3):
        if a[i][0] == a[i][1] == a[i][2] == 0:
            print('Yes')
            break
        elif a[0][i] == a[1][i] == a[2][i] == 0:
            print('Yes')
            break
    	else:
        	print('No')

Buggy submission (verdict: Runtime Error):
a = [list(map(int,input().split())) for i in range(3)] #ビンゴ表
n = int(input()) #回数
b = [int(input()) for i in range(n)] #出た数字

for number in b: #出た目を順番に確認
    for i in range(3):
        if number in a[i]: #numberがビンゴ表にあるかチェック
            a[i][a[i].index(number)] = 0 #i行のnumberに該当する要素を0に書き変え

if a[0][0] == a[1][1] == a[2][2] == 0 or a[2][0] == a[1][1] == a[0][2] == 0:
    print('Yes')　#斜めのビンゴをチェック
else:
    for i in range(3):
        if a[i][0] == a[i][1] == a[i][2] == 0:
            print('Yes') #行のビンゴをチェック
            break
        elif a[0][i] == a[1][i] == a[2][i] == 0:
            print('Yes') #列のビンゴをチェック
            break
        else:
            print('No')
Problem p02761 (python)

Fixed submission:
n,m=map(int,input().split())
sc=[list(map(int,input().split())) for i in range(m)]

for i in range(10**n): #n桁の数字の全パターン
  number =str(i)
  if len(number)==n and all([number[s-1]==str(c) for s,c in sc]):
      print(number) #all すべての要素がTrueならTrue
      exit()
print(-1)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
list = [list(map(int, input().split())) for _ in range(M)]
ans = ["0"]*M

for i in range(M):
    for  j in range(M):
            if list[i] == [1, 0] and list[i] != list[j] :
                print(-1)
                exit() #答えが0以外で先頭の数字が0になる場合
            elif list[i][0] == list[j][0] and list[i][1] != list[j][1]:
                print(-1)
                exit() #ある桁の数字が異なる場合
            elif list[i] == [1, 0] and N != 1:
                print(-1)
                exit() #Nが1でないのに答えが0になる場合
            elif list[i][0] > N:
                print(-1)
                exit() #指定の桁数と入力が異なる場合

for i in range(M):
    for j in range(M):
        if list[i][0] == j+1 :
            ans[j] = str(list[i][1])

print(int("".join(ans)))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
list = [list(map(int, input().split())) for _ in range(M)]
ans = ["0"]*M

for i in range(M):
    for  j in range(M):
            if list[i] == [1, 0] and list[i] != list[j] :
                print(-1)
                exit() #答えが0以外で先頭の数字が0になる場合
            elif list[i][0] == list[j][0] and list[i][1] != list[j][1]:
                print(-1)
                exit() #ある桁の数字が異なる場合
            elif list[i] == [1, 0] and N != 1:
                print(-1)
                exit() #Nが1でないのに答えが0になる場合
            elif list[i][0] > N:
                print(-1)
                exit() #指定の桁数よりも大きな桁の数が入力された場合
            

for i in range(M):
    for j in range(M):
        if list[i][0] == j+1 :
            ans[j] = str(list[i][1])

print(int("".join(ans)))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
list = [list(map(int, input().split())) for _ in range(M)]
ans = ["0"]*M

for i in range(M):
    for  j in range(M):
            if list[i] == [1, 0] and list[i] != list[j] :
                print(-1)
                exit() #答えが0以外で先頭の数字が0になる場合 
            elif list[i][0] == list[j][0] and list[i][1] != list[j][1]:
                print(-1)
                exit() #ある桁の数字が異なる場合
            elif list[i] == [1, 0] and N != 1:
                print(-1)
                exit() #Nが1でないのに答えが0になる場合

for i in range(M):
    for j in range(M):
        if list[i][0] == j+1 :
            ans[j] = str(list[i][1])

print(int("".join(ans)))
Problem p02780 (python)

Fixed submission:
import itertools
n, k = map(int, input().split())
num = list(map(int, input().split()))
sumNum = [(1+i)/2 for i in num]
res = [0] + list(itertools.accumulate(sumNum))
ans = -1
for i in range(n-k+1):
  r = res[i+k] - res[i]
  ans = max(ans, r)
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
num = list(map(int, input().split()))
import numpy
res = numpy.cumsum(num)
maxRange = 0
for i in range(n-k+1):
  r = res[i+k-1] - res[i]
  if maxRange < r:
    maxRange = max(r, maxRange)
    p, q = i, i+k-1
ans = 0
for j in range(p, q+1):
  ans += (num[j]-1)//2　
print(ans)
Problem p02784 (python)

Fixed submission:
HP, n = map(int, input().split())
damege = list(map(int, input().split()))
if sum(damege) >= HP:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
HP, n = map(int, input().split())
damege = list(input().split())
if sum(damege) >= HP:
  print("Yes")
else:
  print("No")
Problem p02803 (python)

Fixed submission:
from collections import deque

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

S = [['#'] * (W + 2)]
for _ in range(H):
    tmp = ['#'] + list(input()) + ['#']
    S.append(tmp)
S.append(['#'] * (W + 2))
#迷路の周りを全て壁で覆うことでどの場所からでも四方に探索できるようにした

move = [[1, 0], [-1, 0], [0, 1], [0, -1]]#上下左右どこかに1マス移動する

ans = 0
# スタート位置を変えながら全探索
for X in range(1, H + 1):
    for Y in range(1, W + 1):
        if S[X][Y] == '#':
            continue
#if ~ continue分はtrueなら下の操作を行うことなく次の番号に移るという意味
        check = [[-1] * (W + 2) for _ in range(H + 2)]
        check[X][Y] = 0
#cheakには壁には-1、道にはそこまでの距離、未探索地には0を入れる
        que = deque()
        que.append([X, Y])
        while que:
            tmp = que.popleft()
            x = tmp[0]
            y = tmp[1]
            flag = True
            for dx, dy in move:
                nx = x + dx
                ny = y + dy
                if S[nx][ny] == '.' and check[nx][ny] == -1:#次の移動場所が"道"かつ"未探索"ならqueに突っ込む
                    que.append([nx, ny])
                    check[nx][ny] = check[x][y] + 1 #cheakにそこまでの距離を代入
                    flag = False
#flagの使い方が上手、真似したい
            if flag:#ある一点のスタート地点からの探索がすべて終わってから、その中の
                ans = max(ans, check[x][y])


print (ans)

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

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

S = [['#'] * (W+2)]
for _ in range(H):
  tmp = ['#'] + list(input()) + ['#']
  S.append(tmp)
S.append(['#'] * (W+2))

move = [[1,0], [-1,0], [0,1], [0,-1]]

ans = 0
for X in range(1, H+1):
  for Y in range(1, W+1):
    if S[x][Y] == '#':
      continue
    check = [[-1] * (W+2) for _ in range(H+2)]
    check[X][Y] = 0
    que = deque()
    que.append([X, Y])
    while que:
      tmp = que.popleft()
      x = tmp[0]
      y = tmp[1]
      flag = True
      for dx, dy in move:
        nx = x + dx
        ny = y + dy
        if S[nx][ny] == '.' and check[nx][ny] == -1:
          que.append([nx, ny])
          check[nx][ny] = check[x][y] + 1
          flag =False
      if flag:
        ans = max(ans, check[x][y])
print(ans)
Problem p02813 (python)

Fixed submission:
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

import itertools
l = list(itertools.permutations(range(1, n+1)))
#permutations:順列 combinations:組み合わせ (list, 数字)rCnのnが「数字」で決まる
print(abs(l.index(p) - l.index(q)))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = input()
b = input()

import itertools
l = list(itertools.permutations(range(1,n+1))
print(abs(l.index(a)-l.index(b)))
Problem p02848 (python)

Fixed submission:
n = int(input())
s = input()
ans = ''
for i in s:
  j = ((ord(i)-ord("A")) + n )%26 
  ans += chr(j + ord("A"))
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
ans = ""
for i in s:
  j = ((ord(i)-ord("A")) + n )//26 
'''
ord(D)-ord(A) = 68-65 = 3
n文字進める 3+n
26で割ることでたとえ3+nがAsciiコードの範囲を超えても大丈夫
'''
  ans += j
print(chr(ans))
Problem p02861 (python)

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

ans=0
for x1, y1 in xy:
	for x2, y2 in xy:
		ans+=((x1-x2)**2+(y1-y2)**2)**0.5
print(ans/n)

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for x1, y1 in xy:[1,2,3]
    for x2, y2 in xy:
        ans += ((x1-x2)**2+(y1-y2)**2)**0.5

ans = ans/n
print(ans)
Problem p02885 (python)

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

Buggy submission (verdict: Runtime Error):
a b = map(int, input().split())
ans = a-2*b
if ans >= 0:
  print(ans)
else:
  print(0)
Problem p02887 (python)

Fixed submission:
n = int(input())
s = input()
ans = 1
for i in range(n-1):
  if s[i] != s[i+1]:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
ans = 1
for i in range(n):
  if s[i] != s[i+1]:
    ans += 1
print(ans+1)
Problem p02888 (python)

Fixed submission:
import bisect

def solve():
    N = int(input())
    Ls = list(map(int, input().split()))
    Ls.sort()

    # O(N^2 * logN)の全探索で解く
    ans = 0
    for a_i in range(N):
        for b_i in range(a_i+1, N):
            c_i = bisect.bisect_left(Ls, Ls[a_i]+Ls[b_i])
            if c_i > b_i:
                ans += c_i - b_i - 1
            else:
                pass

    print(ans)

if __name__ == "__main__":
    solve()

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

    # O(N^2 * logN)の全探索で解く
    ans = 0
    for a_i in range(N):
        for b_i in range(a_i+1, N):
            c_i = bisect.bisect_left(Ls, Ls[a_i]+Ls[b_i])
            if c_i > b_i:
                ans += c_i - b_i - 1
            else:
                pass

    print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
Ls = list(map(int, input().split()))
Ls.sort()
# O(N^2 * logN)の全探索で解く
ans = 0
for a_i in range(N):
  for b_i in range(a_i+1, N):
    c_i = bisect.bisect_left(Ls, Ls[a_i]+Ls[b_i])
    if c_i > b_i:
　     ans += c_i - b_i - 1
    else:
       pass
print(ans)
Problem p02921 (python)

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

Buggy submission (verdict: Runtime Error):
s = input()
n = input()
ans = 0
for i in range(n):
  if s[0] == n[i]:
    ans += 1
print(ans)
Problem p02923 (python)

Fixed submission:
n = int(input())
graph = list(map(int, input().split()))
pre = 1000000
ans = 0
cnt = -1
for i in graph:
  if i <= pre:
    cnt += 1
    pre = i
  else:
    ans = max(ans, cnt)
    cnt = 0
    pre = i
ans = max(ans, cnt)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
graph = list(map(int, input().split()))
right = 0
h2 = 0
cnt = -1
for i in graph:
  if i >= right:
    cnt += 1
    right = i
  else:
    ans = max(ans, cnt)
    cnt = 0
print(ans)
Problem p02971 (python)

Fixed submission:
n = int(input())
num = [int(input()) for _ in range(n)]
Sort_num = sorted(num)
for i in range(n):
  if num[i] == Sort_num[n-1]:
    print(Sort_num[n-2])
  else:
    print(Sort_num[n-1])

Buggy submission (verdict: Runtime Error):
n = int(input())
num = [list(map(int, input())) for _ in range(n)]
Sort_num = sorted(num)
for i in range(n):
  if num[i] == Sort_num[i-1]:
    print(Sort_num[i-2]
  else:
    print(Sort_num[i-1])
Problem p02999 (python)

Fixed submission:
x, a = map(int, input().split())
if a<=x:
  print(10)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
x, a = map(int, input())
if a<=x:
  print(10)
else:
  print(0)
Problem p03037 (python)

Fixed submission:
n, m = map(int, input().split())
l = [0]*m
r = [0]*m
for i in range(m):
  l[i], r[i] = map(int, input().split())
print(max(min(r) - max(l) + 1, 0))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
l = [0]*m
r = [0]*m
for i in range(m):
  p, q = map(int, input().split())
  l[i], r[i] = map(int, input().split())
print(max(min[r] - max[l] + 1, 0))

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
cnt = [0]*(n+1)
for i in range(n):
  l, r = map(int, input().split())
  for j in range(l, r+1):
    cnt[j] += 1
print(cnt.count(m))