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

Fixed submission:
import fractions
from functools import reduce

N = int(input())
T = [int(input()) for _ in range(N)]

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(L):
    return reduce(lcm_base, L, 1)

print(lcm(T))

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

N = int(input())
T = [int(input()) for _ in range(N)]

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(L):
    return reduce(lcm_base, L, 1)

print(lcm(T))
Problem p04025 (python)

Fixed submission:
from statistics import mean
import math

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

mean_num = mean(A)
Ceil = math.ceil(mean_num)
Floor = math.floor(mean_num)

Ceil_sum = 0
Floor_sum = 0
for i in A:
    Ceil_sum += (Ceil - i) ** 2
for i in A:
    Floor_sum += (Floor - i) ** 2

print(min(Floor_sum, Ceil_sum))

Buggy submission (verdict: Runtime Error):
from statistics import mean
import math

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

mean_num = mean(A)
Ceil = math.ceil(mean_num)
Floor = math.floor(mean_num)

Ceil_sum = 0
Floor_sum = 0
for i in A:
    Ceil_sum += (Ceil - i) ** 2
for i in A:
    Floor_sum += (Floor - i) ** 2

print(min(Floor_sum, Ceil_sum))
Problem p02780 (python)

Fixed submission:
n,k=map(int,input().split())
p=list(map(int,input().split()))
new_p=[]
s=[]
ans=-(10**9)
for i in range(n):
    new_p.append((1+p[i])/2)
s.append(new_p[0])
for i in range(n-1):
    s.append(s[i]+new_p[i+1])
s.insert(0,0)
for i in range((len(s)-k)):
    val=s[k+i]-s[i]
    ans=max(ans,val)
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
p=list(map(int,input().split()))
new_p=[]
s=[]
ans=-1
for i in range(n):
    new_p.append((((p[i]*(1+p[i]))/2)/p[i]))
s.append(new_p[0])
for i in range(n-1):
    s.append(s[i]+new_p[i+1])
for i in range((len(s)-k)):
    val=s[k+i]-s[i]
    ans=max(ans,max)
print(ans)
Problem p02802 (python)

Fixed submission:
n,m=map(int,input().split())
ac=[0]*n
wa=[0]*n
for i in range(m):
    p,s=input().split()
    p=int(p)
    if ac[p-1] == 1:
        continue
    if s=='AC':
        ac[p-1] = 1
    else:
        wa[p-1] += 1
AC=0
WA=0
for i in range(n):
    AC += ac[i]
    if ac[i] == 1:
        WA += wa[i]
print("{} {}".format(AC,WA))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
p=[]
s=[]
start=0
idx=0
AC=0
WA=0
count=0
for i in range(m):
    p_,s_=input().split()
    p.append(int(p_))
    s.append(s_)
for i in range(m):
    count=p.count(p[idx])
    if s[start:start+count].count('AC')>=1:
        AC+=1
        WA+=s[start:s[start:start+count].index('AC')+start].count('WA')
    else:
        WA+=s[start:start+count].count('WA')
    start=start+count
    idx=start
    if start==m:
        break
print("{} {}".format(AC,WA))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
p=[]
s=[]
idx=0
AC=0
WA=0
for i in range(m):
    p_,s_=input().split()
    p.append(int(p_))
    s.append(s_)
for i in range(m):
    cp=p.count(p[idx])
    for i in range(idx,(cp+idx)):
        ##print(i)
        if s[i]=='WA':
            WA+=1
        elif s[i]=='AC':
            AC+=1
            break
    idx=cp+idx
    if idx==m:
        break
print("{} {}".format(AC,WA))
Problem p03494 (python)

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

def func(i, c):
    return func(i // 2, c + 1) if i % 2 == 0 else c

print(min([func(i, 0) for i in A]))

Buggy submission (verdict: Runtime Error):
(lambda f: int(input()) == print(min([f(f, i, 0) for i in list(map(int, input().split()))])))(lambda f, i, c: f(i // 2, c + 1) if i % 2 == 0 else c)
Problem p03014 (python)

Fixed submission:

def main(H, W, s_list):
    row_count = [[0]*W for _ in range(H)]
    for i_row in range(H):
        i_col = 0
        j_col = 0
        s = s_list[i_row]
        while(i_col < W):
            char = s[i_col]
            j_col = i_col
            
            if char == '.':
                while(True):
                    j_col += 1
                    if j_col == W:
                        break
                    c = s[j_col]
                    if c == '#':
                        break
                
                for k in range(i_col, j_col):
                    row_count[i_row][k] = j_col - i_col
            i_col = j_col + 1


    col_count = [[0]*W for _ in range(H)]
    for i_col in range(W):
        i_row = 0
        j_row = 0
        s_col = [s[i_col] for s in s_list]
        while(i_row < H):
            char = s_col[i_row]
            j_row = i_row
            if char == '.':
                while(True):
                    j_row += 1
                    if j_row == H:
                        break
                    c = s_col[j_row]
                    if c == '#':
                        break
                for k in range(i_row, j_row):
                    col_count[k][i_col] = j_row - i_row
            i_row = j_row + 1

    m = 0
    for i_row in range(H):
        for i_col in range(W):
            sumation = row_count[i_row][i_col] + col_count[i_row][i_col]
            if sumation > m:
                m = sumation
    print(int(m) - 1)



if __name__ == "__main__":
    H, W = [int(x) for x in input().split()]
    s_list = []
    for _ in range(H):
        s_list.append(input())

    main(H, W, s_list)

Buggy submission (verdict: Runtime Error):
import numpy as np
 
def main(H, W, s_list):
    row_count = np.zeros((H, W))
    for i_row in range(H):
        i_col = 0
        j_col = 0
        s = s_list[i_row]
        while(i_col < W):
            char = s[i_col]
            j_col = i_col
            
            if char == '.':
                while(True):
                    j_col += 1
                    if j_col == W:
                        break
                    c = s[j_col]
                    if c == '#':
                        break
 
                row_count[i_row, i_col:j_col] = j_col - i_col
            i_col = j_col + 1
 
 
    col_count = np.zeros((H, W))
    for i_col in range(W):
        i_row = 0
        j_row = 0
        s_col = [s[i_col] for s in s_list]
        while(i_row < H):
            char = s_col[i_row]
            j_row = i_row
            if char == '.':
                while(True):
                    j_row += 1
                    if j_row == H:
                        break
                    c = s_col[j_row]
                    if c == '#':
                        break
                
                col_count[i_row:j_row, i_col] = j_row - i_row
            i_row = j_row + 1
    print(int(np.max(row_count + col_count)) - 1)
 
 
 
if __name__ == "__main__":
    H, W = [int(x) for x in input().split()]
    s_list = []
    for _ in range(H):
        s_list.append(input())
 
    main(H, W, s_list)
Problem p02684 (python)

Fixed submission:
import sys
from collections import deque
N,K = map(int,input().split())
A = [0] + list(map(int,input().split()))
G = dict([(i,[]) for i in range(1,N+1)])
for i in range(1,N+1):
  G[i].append(A[i])

l = deque([A[1]])
seen = [False for i in range(N+1)]
seen[1] = True
d = [0 for i in range(N+1)]
d[A[1]] = 1
if A[1] == 1:
  print(1)
  sys.exit()

for i in range(K):
  v = l.popleft()
  if seen[v] == False:
    seen[v] = True
    l.append(A[v])
    if seen[A[v]] == True: 
      a = d[A[v]]
      b = d[v] + 1 - a
    else:  
      d[A[v]] = d[v] + 1
  else:  
    start = v
    break  
  if i == K-1:
    print(v)
    sys.exit()

kaisu = (K-a)%b
p = start
for i in range(kaisu):
  p = A[p]
print(p)

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque
N,K = map(int,input().split())
A = [0] + list(map(int,input().split()))
G = dict([(i,[]) for i in range(1,N+1)])
for i in range(1,N+1):
  G[i].append(A[i])

l = deque([A[1]])
seen = [False for i in range(N+1)]
seen[1] = True
d = [0 for i in range(N+1)]
d[A[1]] = 1
if A[1] == 1:
  print(1)
  sys.exit()
  
for i in range(K):
  v = l.popleft()
  if seen[v] != True:
    seen[v] = True
    l.append(A[v])
    if seen[A[v]] == True: 
      a = d[A[v]]
      b = d[v] + 1 - a
    else:  
      d[A[v]] = d[v] + 1
  else:  
    start = v
    break

kaisu = (K-a)%b
p = start
for i in range(kaisu):
  p = A[p]
print(p)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
A = [0] + list(map(int,input().split()))
G = dict([(i,[]) for i in range(1,N+1)])
for i in range(1,N+1):
  G[i].append(A[i])

l = [A[1]]
seen = [False for i in range(N+1)]
seen[1] = True
d = [0 for i in range(N+1)]
d[A[1]] = 1
for i in range(K):
  v = l.pop(0)
  if seen[v] != True:
    seen[v] = True
    l.append(A[v])
    if seen[A[v]] == True: 
      a = d[A[v]]
      b = d[v] + 1 - a
    else:  
      d[A[v]] = d[v] + 1
  else:  
    start = v
    break

kaisu = (K-a)%b
p = start
for i in range(kaisu):
  p = A[p]
print(p)

Buggy submission (verdict: Runtime Error):
from collections import deque
N,K = map(int,input().split())
A = [0] + list(map(int,input().split()))
G = dict([(i,[]) for i in range(1,N+1)])
for i in range(1,N+1):
  G[i].append(A[i])

l = deque([A[1]])
seen = [False for i in range(N+1)]
seen[1] = True
d = [0 for i in range(N+1)]
d[A[1]] = 1
for i in range(K):
  v = l.popleft()
  if seen[v] != True:
    seen[v] = True
    l.append(A[v])
    if seen[A[v]] == True: 
      a = d[A[v]]
      b = d[v] + 1 - a
    else:  
      d[A[v]] = d[v] + 1
  else:  
    start = v
    break

kaisu = (K-a)%b
p = start
for i in range(kaisu):
  p = A[p]
print(p)
Problem p02733 (python)

Fixed submission:
import re

H,W,K = map(int,input().split())
grid = [[0 for i in range(W+1)]]
for i in range(H):
  S = input()
  grid.append([0]+[ int(S[i]) for i in range(W) ])

#累積和gridの作成
#行について
for i in range(H+1):
  for j in range(W):
    grid[i][j+1] += grid[i][j]
#列について
for j in range(W+1):
  for i in range(H):
    grid[i+1][j] += grid[i][j]   

min_cnt = (H-1)*(W-1)
#横の区切りを作る
for h in range(2**(H-1)):
  cnt = 0
  #二進数の文字列を取得
  bin_str = format(h,"0{}b".format(H-1)) 
  #区切りのインデックスリスト
  l_p =[1]+[ x.start()+2 for x in re.finditer("1",bin_str) ] +[H+1]

  #cntに区切りの分だけ付け加える
  cnt = cnt + len(l_p) - 2
  
  ws = 0
  for w in range(1,W+1):
    for k in range(len(l_p)-1):
      if grid[l_p[k+1]-1][w]-grid[l_p[k+1]-1][w-1] > K:
        min_cnt=(H-1)*(W-1)+1
      if grid[l_p[k+1]-1][w]- (grid[l_p[k]-1][w]+grid[l_p[k+1]-1][ws]-grid[l_p[k]-1][ws]) > K:
        cnt = cnt + 1
        ws = w-1
        break    
  min_cnt = min(min_cnt,cnt)

###
print(min_cnt)

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

H,W,K = map(int,input().split())
grid = [[0 for i in range(W+1)]]
for i in range(H):
  S = input()
  grid.append([0]+[ int(S[i]) for i in range(W) ])

#累積和gridの作成
#行について
for i in range(H+1):
  for j in range(W):
    grid[i][j+1] += grid[i][j]
#列について
for j in range(W+1):
  for i in range(H):
    grid[i+1][j] += grid[i][j]   

min_cnt = 10011
#横の区切りを作る
for h in range(2**(H-1)):
  cnt = 0
  #二進数の文字列を取得
  bin_str = format(h,"0{}b".format(H-1)) 
  #区切りのインデックスリスト
  l_p =[1]+[ x.start()+2 for x in re.finditer("1",bin_str) ] +[H+1]

  #cntに区切りの分だけ付け加える
  cnt = cnt + len(l_p) - 2
  
  ws = 0
  for w in range(1,W+1):
    for k in range(len(l_p)-1):
      if grid[l_p[k+1]-1][w]- (grid[l_p[k]-1][w]+grid[l_p[k+1]-1][ws]-grid[l_p[k]-1][ws]) > K:
        cnt = cnt + 1
        ws = w-1
        break    
  min_cnt = min(min_cnt,cnt)

###
print(min_cnt)

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

H,W,K = map(int,input().split())
grid = []
for i in range(H):
  S = input()
  grid.append( [S[i] for i in range(W) ])
grid = np.array(grid,dtype='int64')

min_cnt = 1000*10+1
#横の区切りを作る
for j in range(2**(H-1)):
  cnt = 0
  #二進数の文字列を取得
  bin_str = format(j,"0{}b".format(H-1)) 
  #区切りのインデックスリスト
  l_p =[0]+[ x.start()+1 for x in re.finditer("1",bin_str) ] +[H]

  #cntに区切りの分だけ付け加える
  cnt = cnt + len(l_p)-2
  
  #決めた行の区切りに対して、列ごとの和の配列を取得
  L = np.empty((0,W),int)
  for i in range(len(l_p)-1):
    slice_wa = [np.sum(grid[l_p[i]:l_p[i+1],:],axis=0)]
    L = np.append(L, slice_wa ,axis=0)

  tate = np.zeros( len(l_p)-1 ,dtype='int64')
  for w in range(W):#k以上の要素があるか
    n_tate = tate + L[:,w]
    if True in (n_tate > K):
      cnt = cnt + 1
      tate = np.zeros( len(l_p)-1 ,dtype='int64')+L[:,w]   
    else:
      tate = n_tate
  min_cnt = min(cnt,min_cnt)   
###
print(min_cnt)
Problem p02830 (python)

Fixed submission:
num = input()
moji_list = input().split()
new_moji = ""
for i in range(int(num)):
	new_moji += moji_list[0][i]+moji_list[1][i]
print(new_moji)

Buggy submission (verdict: Runtime Error):
num = input()
moji_list = input().split()
new_moji = ""
for i in range(num):
	new_moji = moji_list[0][i]+moji_list[1][i]
print(new_moji)
Problem p03160 (python)

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

l_cost = [0,abs(l_h[1]-l_h[0])]

for i in range(2,N):
  min_cost=min(abs(l_h[i]-l_h[i-1]) + l_cost[i-1] , abs(l_h[i]-l_h[i-2]) + l_cost[i-2])
  l_cost.append(min_cost) 

print(l_cost[N-1])

Buggy submission (verdict: Runtime Error):
[N,K] = list(map(int,input().split()))
l_h = list(map(int,input().split()))

l_cost = [0]+[float("inf") for i in range(N-1)]

for i in range(N): #ノードを全土に渡り更新する
  for k in range(1,K+1):#1ノードにつきKこ先のコストを更新する
    if (k+i>N-1):
      break
    else:
      min_cost=min(abs(l_h[k+i]-l_h[i]) + l_cost[i] ,l_cost[k+i])  
      l_cost[k+i] = min_cost

print(l_cost[-1])
Problem p03290 (python)

Fixed submission:
import re

d,g = map(int,input().split() )
l = [list(map(int,input().split() ))+[100*(x+1)] for x in range(d) ] 

mondai_num = []

for k in range(2**d):

  #先に全完するカテゴリ(何百点問題を全完するか)を決め、回す
  bin_str = format(k, "0{}b".format(d) )#二進数の文字列を取得
  #これが全完する問題のリスト
  zenkan_list = [ x.start() for x in re.finditer("1",bin_str)  ] 
  

  #0~9のリストと和の初期化
  d_list = [i for i in range(d)]
  wa = 0
  cnt = 0
  #全完した点数のみ先に足す
  for i in zenkan_list:
    wa = wa+(l[i][0])*((i+1)*100)
    wa = wa + l[i][1]  
    cnt = cnt + l[i][0]
  #全完したやつだけで目標を超えたらそこでストップ
  if wa>=g:
    mondai_num.append( cnt )

  #全完したやつだけでたらなかったら素点が大きいやつを全完一歩手前まで足す
  else:
    #全完したカテゴリを除外
    for i in zenkan_list:
      d_list.remove(i)
    #残ったカテゴリの中で最大の点数のカテゴリを探す
    max_set = l[max(d_list)]

    for i in range( max_set[0]  ):
      wa = wa + max_set[2]
      if wa >= g:
        mondai_num.append(cnt + i+1 )
        break
print(min(mondai_num))

Buggy submission (verdict: Runtime Error):
d,g = map(int,input().split() )
l = [list(map(int,input().split() ))+[100*(x+1)] for x in range(d) ] 

mondai_num = []

for k in range(2**d):

  #先に全完するカテゴリ(何百点問題を全完するか)を決め、回す
  bin_str = format(k, "0{}b".format(d) )#二進数の文字列を取得
  #これが全完する問題のリスト
  zenkan_list = [ x.start() for x in re.finditer("1",bin_str)  ] 
  

  #0~9のリストと和の初期化
  d_list = [i for i in range(d)]
  wa = 0
  cnt = 0
  #全完した点数のみ先に足す
  for i in zenkan_list:
    wa = wa+(l[i][0])*((i+1)*100)
    wa = wa + l[i][1]  
    cnt = cnt + l[i][0]
  #全完したやつだけで目標を超えたらそこでストップ
  if wa>=g:
    mondai_num.append( cnt )

  #全完したやつだけでたらなかったら素点が大きいやつを全完一歩手前まで足す
  else:
    #全完したカテゴリを除外
    for i in zenkan_list:
      d_list.remove(i)
    #残ったカテゴリの中で最大の点数のカテゴリを探す
    max_set = l[max(d_list)]

    for i in range( max_set[0]  ):
      wa = wa + max_set[2]
      if wa >= g:
        mondai_num.append(cnt + i+1 )
        break
print(min(mondai_num))
Problem p03433 (python)

Fixed submission:
N = int(input())
A = int(input())

if N % 500 <= A:
        print("Yes")
else:
        print("No")

Buggy submission (verdict: Runtime Error):
N,A = map(int,input().split())
if N%500 <= A:
        print("YES")
else:
        print("NO")

Buggy submission (verdict: Runtime Error):
N,A = map(int,input().split())
if N%500 < A:
        print("YES")
else:
        print("NO")

Buggy submission (verdict: Runtime Error):
A,N = map(int,input().split())
if N%500 < A:
        print("YES")
else:
        print("NO")
Problem p03854 (python)

Fixed submission:
import sys
import resource
sys.setrecursionlimit(10 ** 9)

S = input()
l = []
def dfs(n):
  if n == len(S):
    l.append("YES")
  if n < len(S):
    if S[n:n+5] == "erase":
      dfs(n+5)    
    if S[n:n+5] == "dream":
      dfs(n+5)  
    if S[n:n+6] == "eraser":
      dfs(n+6)              
    if S[n:n+7] == "dreamer":
      dfs(n+7)
dfs(0)
if len(l) == 0:
  l.append("NO")
print(l[0])

Buggy submission (verdict: Runtime Error):
S = input()
l = []
def dfs(n):
  print(n)
  if n == len(S):
    l.append("Yes")
  if S[n:n+5] == "dream":
    dfs(n+5)
  if S[n:n+7] == "dreamer":
    dfs(n+7)
  if S[n:n+5] == "erase":
    dfs(n+5)
  if S[n:n+6] == "eraser":
    dfs(n+6)   
dfs(0)
if len(l) == 0:
  l.append("No")
print(l[0])
Problem p03866 (python)

Fixed submission:
xs,yx,xt,yt = map(int,input().split())
N = int(input())
l = [[],[xs,yx,0],[xt,yt,0]]
for i in range(N):
  l.append(list(map(int,input().split())))
##距離リスト
d = [[0]*(N+3) for _ in range(N+3)]
for i in range(1,N+3):
  d[i][i] = 0
#O(10**6)
for i in range(1,N+3):
  for j in range(i+1,N+3):
    sa = (l[i][0]-l[j][0])**2 + (l[i][1]-l[j][1])**2
    kyori = max(0,sa**(1/2)-l[i][2]-l[j][2])
    d[i][j] = kyori
    d[j][i] = kyori

md = [float("inf")]*(N+3)
h = [i for i in range(1,N+3)]
for i in range(1,N+3):
  md[i]=d[1][i]
seen = [False]*(N+3)
seen[1] = True
while True:
  #vを出す
  v = -1
  for i in h:
    if seen[i] == False and v == -1:
      v = i
    elif seen[i] == False and md[i] < md[v]:
      v = i
  if v == -1:
    break
  seen[v] = True
  for j in range(1,N+3):
    md[j] = min(md[j],md[v]+d[v][j])
print(md[2])

Buggy submission (verdict: Runtime Error):
import heapq
xs,yx,xt,yt = map(int,input().split())
N = int(input())
l = [[],[xs,yx,0],[xt,yt,0]]
for i in range(N):
  l.append(list(map(int,input().split())))
##距離リスト
d = [[0]*(N+3) for _ in range(N+3)]
for i in range(1,N+3):
  d[i][i] = 0
#O(10**6)
for i in range(1,N+3):
  for j in range(i+1,N+3):
    sa = (l[i][0]-l[j][0])**2 + (l[i][1]-l[j][1])**2
    kyori = max(0,sa**(1/2)-l[i][2]-l[j][2])
    d[i][j] = kyori
    d[j][i] = kyori

md = [float("inf")]*(N+3)
heap = [[d[1][i],i] for i in range(2,N+3)]
heapq.heapify(heap)
for i in range(1,N+3):
  md[i]=d[1][i]
cnt = 0
seen = [False]*(N+3)
seen[1] = True
while cnt != N+1:
  v = heapq.heappop(heap) 
  if seen[v[1]] == False:
    for i in range(1,N+3):
      if md[i] > md[v[1]]+d[i][v[1]]:
        md[i] = md[v[1]]+d[i][v[1]]
        seen[v[1]] = True
        cnt += 1
        heapq.heappush(heap,[md[i],i])
print(md[2])
Problem p02641 (python)

Fixed submission:
X,N = map(int,input().split())
P = list(map(int,input().split()))
num = sorted([[abs(X - i),i] for i in range(-200,200) if i not in P],key = lambda x: x[0])

inf = 10 ** 3
inf2 = 10 ** 3 * -1

for i in range(X,inf):
  if i in P:
    continue
  plus = abs(X - i)
  break

for j in range(X,inf * -1,-1):
  if j in P:
    continue
  minus = abs(X - j)
  break

if plus < minus:
  print(i)

else:
  print(j)

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

num = sorted([[abs(X - i),i] for i in range(1,101) if i not in P],key = lambda x: x[0])

print(num[0][1])
Problem p02690 (python)

Fixed submission:
X = int(input())

ans = []

for i in range(-118,120):
  for j in range(-119,119):
    if i ** 5 - j ** 5 == X:
      ans = [i,j]
      break

print(*ans)

Buggy submission (verdict: Runtime Error):
import bisect

X = int(input())
five = [i ** 5 for i in range(0,1000)]

left = bisect.bisect_left(five, X) - 1
right = bisect.bisect(five, X)

if abs(five[left]  - X) < abs(five[right]  - X):
  dif = X - five[left]
  b = five.index(dif) * -1
  a = left
else:
  dif = five[right] - X
  b = five.index(dif)
  a = right
  
print(a,b)
Problem p02748 (python)

Fixed submission:
a,b,m = map(int,input().split())
ref = list(map(int,input().split()))
ran = list(map(int,input().split()))

ans = min(ref) + min(ran)

for i in range(m):
  t = list(map(int,input().split()))
  p = t[0] 
  q = t[1]
  c = t[2]
  if (len(ref) >= p and len(ran) >= q):
    if ref[p - 1] + ran[q - 1] - c < ans:
      ans = ref[p - 1] + ran[q - 1] - c
      
print(ans)

Buggy submission (verdict: Runtime Error):
a,b,m = map(int,input().split())
ref = list(map(int,input().split()))
ran = list(map(int,input().split()))
ticket = []
ans = min(ref) + min(ran)
for i in range(m):
  t = list(map(int,input().split()))
  p = t[0] - 1
  q = t[1] - 1
  if ref[p] + ran[p] < ans:
    ans = ref[p] + ran[p]
print(ans)
Problem p02761 (python)

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

for i in range(M):
  sc = list(map(int,input().split()))
  SC.append(sc)

num = [0] * N

for i in range(M):
  s = SC[i][0]
  c = SC[i][1]
  #すでに値が入っており異なる値か、人ケタメに0を指定しているか
  if (num[s - 1] != 0 and num[s - 1] != c) or (N > 1 and s == 1 and c == 0):
    num = -1
    break
  else:
    num[s - 1] = SC[i][1]

if num == -1:
  print(-1)
else:
  ans = ""
  for i in range(N):
    if num[0] == 0 and len(num) > 1:
      num[0] = 1
    ans += str(num[i])
  ans = int(ans)
  print(ans)

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

for i in range(M):
  sc = list(map(int,input().split()))
  SC.append(sc)

num = [0] * N

for i in range(M):
  s = SC[i][0]
  c = SC[i][1]
  if (num[s - 1] != 0 and num[s - 1] != c) or (s == 1 and c == 0):
    num = -1
    break
  else:
    num[s - 1] = SC[i][1]

if num == -1:
  print(-1)
else:
  ans = ""
  for i in range(M):
    if num[0] == 0:
      num[0] = 1
    ans += str(num[i])
  print(int(ans))
Problem p02823 (python)

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

if (B - A) % 2 == 0:
  print((B - A) // 2)
else:
  NA = N - A
  B1 = B - 1
  if NA < B1:
    distance = N - B
    adjust = distance + 1
    moveA = A + adjust
    print(((N - moveA) // 2) + adjust)
  else:
    distance = A - 1
    adjust = distance + 1
    moveB = B - adjust
    print(((moveB - 1) // 2) + adjust)

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

if (B - A) % 2 == 0:
  print((B - A) // 2)
else:
  if 
  print(min(B - 1 , N - A))
Problem p02824 (python)

Fixed submission:
N,M,V,P = map(int,input().split())
A = sorted([int(i) for i in input().split()],reverse = True)

pps = 0
con = P

for i in range(P,N):
  #P以降でi番目に大きい数を加算
  pps += A[i - 1]

  #xの上限が順位に入らない
  if A[i] + M < A[P - 1]:
    break
  #点数をいくら振り分けてもいいスコアの数
  fv = min(P - 1 + N - i, V)
  #左辺第二項は、P以降とi以前の、点数の振り分け可能数に上限がある数
  #左辺は振り分けた後にA[i]がP入りを果たせる区間の総和の上限を示す
  #右辺第一項は、振り分け可能数に上限がある数の総和
  #右辺第二項は、振り分けないといけない数の残り
  #右辺は、点数を振り分けた後の値の区間の総和を示すため、
  #右辺が左辺を上回った場合、ループは終了となる
  if (A[i] + M) * (i - P + 1) < pps + M * (V - fv):
    break
  con += 1
  
print(con)

Buggy submission (verdict: Runtime Error):
N,M,V,P = map(int,input().split())
A = [int(i) for i in input().split()]

#A = [[int(i),x]for x,i in enumerate(input().split())]

maxA = max(A)
amount = A.count(maxA)
numorder = sorted(list(set(A)),reverse = True)
target = P - amount

con = 0

for i in range(N):
  x = A[i]
  x = x + M
  Y = [k for k in A if k < x]
  y = len(Y)

  if y > V - 1:
    if x >= numorder[target]:
      con += 1
  else:
    Z = [j for j in A if j >= x]
    z = len(Z)

    if V - y < z and target + 1 > z:
      con += 1

print(con)
Problem p02865 (python)

Fixed submission:
N = int(input())

sup = int(N // 2) + 1

L = []

for i in range(1,sup):
  diff = N - i
  pair = [i,diff]
  pair = set(pair)
  if len(pair) == 2:
    L.append(pair)


    
print(len(L))

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

INF = 10 ※※ 8

L = []

for i in range(1,N):
  diff = N - i
  pair = set(i,diff)
  if len(pair) == 2 and pair not in L:
    L.append(pair)

print(len(L))
Problem p02909 (python)

Fixed submission:
S = input()
 
if S == "Sunny":
  print("Cloudy")
elif S == "Cloudy":
  print("Rainy")
elif S == "Rainy":
  print("Sunny")

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

P = [0] * N


 
for i in range(Q):
	A = int(input())
	P[A-1] += 1


for j in range(0,len(P)):
	if K - Q + P[j] > 0:
		print('Yes')
	else:
		print('No')

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

if S == "Sunny":
  print("Cloudy")
elif S == "Cloudy":
  print("Rainy"):
elif S == "Rainy":
  print("Sunny")