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

Fixed submission:
import sys
input = sys.stdin.readline
import math
def solve():
  a,b,x = (int(i) for i in input().split())
  L  = a*a*b
  if L <= x:
    print(0)
  else:
    mi = 0
    ma = 89.999999999
    while ma-mi >= 10**(-9):
      next = (mi+ma)/2
      bairitu = math.tan(math.radians(next))
      if x >= L/2 :
        lim = L-(a**3/2)*round(bairitu, 10)
      else:
        lim = (0.5)*a*b*b*math.tan(math.radians(90-next))
      if x > lim:
        ma  = next
      else:
        mi = next
    print(ma)
solve()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import math
def solve():
  a,b,x = (int(i) for i in input().split())
  L  = a*a*b
  if L <= x:
    print(0)
  else:
    mi = 0
    ma = 89.999999999
    while ma-mi >= 10**(-9):
      next = (mi+ma)/2
      bairitu = math.tan(math.radians(next))
      if x >= L/2 :
        lim = L-(a**3/2)*round(bairitu, 10)
      else:
        lim = a**2/2*b*math.tan(math.radians(next-si))
      if x > lim:
        ma  = next
      else:
        mi = next
    print(ma)
solve()
Problem p02889 (python)

Fixed submission:
from scipy.sparse.csgraph import floyd_warshall
import sys
input = sys.stdin.readline
def solve():
  inf = float("Inf")
  n,m,l = (int(i) for i in input().split())
  path = [[-1*inf]*n for _ in range(n)]
  for i in range(m):
    a,b,c = (int(i) for i in input().split())
    path[a-1][b-1] = c
    path[b-1][a-1] = c
  d = floyd_warshall(path)
  q = int(input())
  minipath = [[-1*inf]*n for _ in range(n)]
  for i in range(n):
    for j in range(n):
      if d[i][j] <= l:
        minipath[i][j] = 1
  d2 = floyd_warshall(minipath)

  for i in range(q):
    s,t = (int(i) for i in input().split())
    s,t = s-1,t-1
    cost = d2[s][t]
    if cost == inf:
      print(-1)
    else:
      print(int(cost)-1)

solve()

Buggy submission (verdict: Runtime Error):
from scipy.sparse.csgraph import johnson
import sys
input = sys.stdin.readline

def solve():
  minf = -1*float("inf")
  n,m,l = (int(i) for i in input().split())
  path = [[minf]*n for _ in range(n)]
  for i in range(m):
    a,b,c = (int(i) for i in input().split())
    path[a-1][b-1] = c
  d = johnson(path,directed=False)
  q = int(input())
  
  minipath = [[None]*n for _ in range(n)]
  for i in range(n):
    for j in range(n):
      if d[i][j] <= l:
        minipath[i][j] = 1
      else:
        minipath[i][j] = minf
  d2 = johnson(minipath,directed=False)

  for i in range(q):
    s,t = (int(i) for i in input().split())
    s,t = s-1,t-1
    cost = d2[s][t]
    if cost == minf:
      print(-1)
    else:
      print(int(cost)-1)

solve()

Buggy submission (verdict: Runtime Error):
from scipy.sparse.csgraph import dijkstra
import sys
input = sys.stdin.readline
def solve():
  inf = 0
  n,m,l = (int(i) for i in input().split())
  path = [[-1*inf]*n for _ in range(n)]
  for i in range(m):
    a,b,c = (int(i) for i in input().split())
    path[a-1][b-1] = c
    path[b-1][a-1] = c
  d = dijkstra(path)
  q = int(input())
  minipath = [[-1*inf]*n for _ in range(n)]
  for i in range(n):
    for j in range(n):
      if d[i][j] <= l:
        minipath[i][j] = 1
  d2 = dijkstra(minipath)

  for i in range(q):
    s,t = (int(i) for i in input().split())
    s,t = s-1,t-1
    cost = d2[s][t]
    if cost == inf:
      print(-1)
    else:
      print(int(cost)-1)

solve()

Buggy submission (verdict: Runtime Error):
from scipy.sparse.csgraph import dijkstra
import sys
input = sys.stdin.readline
def solve():
  inf = float("Inf")
  n,m,l = (int(i) for i in input().split())
  path = [[-1*inf]*n for _ in range(n)]
  for i in range(m):
    a,b,c = (int(i) for i in input().split())
    path[a-1][b-1] = c
    path[b-1][a-1] = c
  d = dijkstra(path)
  q = int(input())
  minipath = [[-1*inf]*n for _ in range(n)]
  for i in range(n):
    for j in range(n):
      if d[i][j] <= l:
        minipath[i][j] = 1
  d2 = dijkstra(minipath)

  for i in range(q):
    s,t = (int(i) for i in input().split())
    s,t = s-1,t-1
    cost = d2[s][t]
    if cost == inf:
      print(-1)
    else:
      print(int(cost)-1)

solve()
Problem p02947 (python)

Fixed submission:
import collections
import sys
sys.setrecursionlimit(100000000)

from math import factorial
def ncr(n,r):
 if n==r:
  return 1
 elif n>2:
  return factorial(n) // factorial(r) // factorial(n - r)
 else:
  return 1
def solve():
  n = int(input())
  query = []
  for i in range(n):
    a = sorted(input())
    query.append("".join(a))

  c = collections.Counter(query)
  ans = 0
  tmp = list(c.values())

  for i in tmp:
    if i >=2:
      ans += ncr(i,2)
  print(int(ans))
solve()

Buggy submission (verdict: Runtime Error):
import collections
import sys
sys.setrecursionlimit(100000000)

from math import factorial
def ncr(n,r):
 if n>2:
  return factorial(n) / factorial(r) / factorial(n - r)
 else:
  return 1
def solve():
  n = int(input())
  query = []
  for i in range(n):
    a = sorted(input())
    query.append("".join(a))

  c = collections.Counter(query)
  ans = 0
  tmp = c.values()

  for i in tmp:
    if i >=2:
      ans += ncr(i,2)
  print(int(ans))
  
solve()

Buggy submission (verdict: Runtime Error):
import collections

from math import factorial
def ncr(n,r):
 if n>2:
  return factorial(n) / factorial(r) / factorial(n - r)
 else:
  return 1
def solve():
  n = int(input())
  query = []
  for i in range(n):
    a = sorted(input())
    query.append("".join(a))

  c = collections.Counter(query)
  ans = 0
  tmp = c.values()
  for i in tmp:
    if i >=2:
      ans += ncr(i,2)
  print(int(ans))
solve()
Problem p02988 (python)

Fixed submission:
def solve():
  n = int(input())
  p = list(int(i) for i in input().split())
  ans = 0
  for i in range(n-2):
   query = [p[i],p[i+1],p[i+2]]
   query.sort()
   if query[1] == p[i+1]:
    ans += 1
  print(ans)
solve()

Buggy submission (verdict: Runtime Error):
def solve():
  n = int(input())
  p = list(int(i) for i in input().split())
  ans = 0
  try:
    for i in range(n):
      if p[i-1]>p[i]>p[i+1]:
        ans += 1
      elif p[i-1]<p[i]<p[i+1]:
        ans += 1
  finally:
   print(ans)
solve()
Problem p03006 (python)

Fixed submission:
import collections
def solve():
  n = int(input())
  queue = []
  queue2 = []
  if n == 1:
    print(1)
    exit()
  for i in range(n):
   x,y = (int(i) for i in input().split())
   queue.append((x,y))
  for i in range(n):
    for j in range(n):
      if i!=j:
        x1,y1 = queue[i]
        x2,y2 = queue[j]
        p = x2-x1
        q = y2-y1
        queue2.append((p,q))
  #print(queue2)
  
  c = collections.Counter(queue2)
  ans = n
  print(ans-c.most_common()[0][1])
solve()

Buggy submission (verdict: Runtime Error):
import collections
def solve():
  n = int(input())
  queue = []
  queue2 = []
  for i in range(n):
   x,y = (int(i) for i in input().split())
   queue.append((x,y))
  for i in range(n):
    for j in range(n):
      if i!=j:
        x1,y1 = queue[i]
        x2,y2 = queue[j]
        p = x2-x1
        q = y2-y1
        queue2.append((p,q))
  #print(queue2)
  c = collections.Counter(queue2)
  ans = n
  
  print(ans-c.most_common()[0][1])
solve()
Problem p03069 (python)

Fixed submission:
def solve():
  n = int(input())
  s = input()
  
  leftblack = 0
  leftwhite = 0
  rightblack = s.count('#')
  rightwhite = s.count(".")
  
  ans = leftblack+rightwhite
  
  for i in range(n):
    if s[i] == "#":
      leftblack += 1
      rightblack -= 1
    else:
      leftwhite += 1
      rightwhite -= 1
    ans = min(ans,leftblack+rightwhite)
  
  print(ans)
solve()

Buggy submission (verdict: Runtime Error):
def solve():
  n = int(input())
  s = input()

  ans = 10**15
  a = s.count(".")
  b = s.count("#")
  sharp = []
  dot = []
  tp = 1
  if a == n:
    print("0")
  else:
    for i in range(n-1):

        if s[i] == s[i+1]:
           tp += 1
               
        if s[i] != s[i+1]:
            if s[i]==".":
                dot.append(tp)
                sharp.append(0)
            else:
                dot.append(0)
                sharp.append(tp)
            tp = 1
        if i == n-2:
           if s[i+1]==".":
                dot.append(tp)
                sharp.append(0)
           else:
                dot.append(0)
                sharp.append(tp)
           tp = 1
    
    e = len(sharp)
    ans = min(b-sharp[-1],a-dot[0])
    #print(dot,sharp)
    #print(ans)
    for i in range(e):
      do = dot[i]
      sh = sharp[i]
      a += do
      b += sh
      ans = min(ans,min(b-sharp[-1],a-dot[0]))
      
        
    print(ans)
solve()

Buggy submission (verdict: Runtime Error):
def solve():
  n = int(input())
  s = input()

  ans = 10**15
  a = s.count(".")
  b = s.count("#")
  sharp = []
  dot = []
  tp = 1
  if a == n:
    print("0")
  else:
    for i in range(n-1):

        if s[i] == s[i+1]:
           tp += 1
               
        if s[i] != s[i+1] or i+1 ==n-1:
            if s[i]==".":
                dot.append(tp)
                sharp.append(0)
            else:
                dot.append(0)
                sharp.append(tp)
            tp = 1
    e = len(sharp)
    ans = min(b-sharp[-1],a-dot[0])
    
    for i in range(e):
      do = dot[i]
      sh = sharp[i]
      a += do
      b += sh
      ans = min(ans,min(b-sharp[-1],a-dot[0]))
      
        
    print(ans)
solve()
Problem p03074 (python)

Fixed submission:
def solve():
  n,k = (int(i) for i in input().split())
  s = input()
  one = []
  zero = []  
  for i in range(n):
    if i == 0:
      if s[i] == "0":
        one.append(0)
        zero.append(1)
      else:
        one.append(1)
    
    else:     
     if s[i] == s[i-1]:
      if s[i] == "0":
        zero[-1]+= 1
      else:
        one[-1] += 1
     else:
      if s[i] == "0":
        zero.append(1)
      else:
        one.append(1)
  ans = 0 
  if len(zero) <= k:
    ans = n

  else:
   one = one + [0]*5
   zero = zero + [0]*5
   tmp = 0
   for i in range(k+1):
    tmp += one[i]
   for i in range(k):
    tmp += zero[i]
   ans = max(tmp,ans)
   for i in range(len(zero)-k-1):
        
       tmp -=  one[i]
       tmp +=  one[i+k+1]
       tmp -=  zero[i]
       tmp +=  zero[i+k]
       ans = max(ans,tmp)

  #print (one) 
 # print(zero)
  print(ans)
    
solve()

Buggy submission (verdict: Runtime Error):
def solve():
  n,k = (int(i) for i in input().split())
  s = input()
  one = []
  zero = []  
  for i in range(n):
    if i == 0:
      if s[i] == "0":
        one.append(0)
        zero.append(1)
      else:
        one.append(1)
    
    else:     
     if s[i] == s[i-1]:
      if s[i] == "0":
        zero[-1]+= 1
      else:
        one[-1] += 1
     else:
      if s[i] == "0":
        zero.append(1)
      else:
        one.append(1)
  ans = 0 
  if len(zero) <= k:
    ans = n
  one = one + [0]*5
  zero = zero + [0]*5
  
  tmp = 0
  for i in range(k+1):
   tmp += one[i]
  for i in range(k):
   tmp += zero[i]
  ans = max(tmp,ans)
  for i in range(len(zero)-k-1):
       
       tmp -=  one[i]
       tmp +=  one[i+k+1]
       tmp -=  zero[i]
       tmp +=  zero[i+k]
       ans = max(ans,tmp)

  #print (one) 
 # print(zero)
  print(ans)
    
solve()

Buggy submission (verdict: Runtime Error):
def solve():
  n,k = (int(i) for i in input().split())
  s = input()
  one = []
  zero = []  
  for i in range(n):
    if i == 0:
      if s[i] == "0":
        zero.append(1)
      else:
        one.append(1)
    
    else:     
     if s[i] == s[i-1]:
      if s[i] == "0":
        zero[-1]+= 1
      else:
        one[-1] += 1
     else:
      if s[i] == "0":
        #zero.append(0)
        zero.append(1)
      else:
        #one.append(0)
        one.append(1)
  ans = 0 
  if len(zero) <= k:
    ans = n
  elif len(one) > len(zero):
    tmp = 0
    for i in range(k+1):
     tmp += one[i]
    for i in range(k):
     tmp += zero[i]
    for i in range(len(zero)-k):
       
       tmp -=  one[i]
       tmp +=  one[i+k+1]
       tmp -=  zero[i]
       tmp +=  zero[i+k]
       ans = max(ans,tmp)
  else:
    tmp = 0
    for i in range(k):
      tmp += one[i]
    for i in range(k):
      tmp += zero[i]
    ans = max(ans,tmp)
    tmp -= zero[i]
    tmp += zero[i+1]
    ans = max(ans,tmp)
    for i in range(len(zero)-k-1):
       
       tmp -=  one[i]
       tmp +=  one[i+k+1]
       tmp -=  zero[i+1]
       tmp +=  zero[i+2]
       ans = max(ans,tmp)
  print(ans)
    
solve()
Problem p03096 (python)

Fixed submission:
def solve():
 n = int(input())
 c = [int(input()) for _ in range(n)]
 mod = 10**9 +7
 dp = [1]*n
 dp[0] = 1
 place = [-1]*200001

 for i in range(n):    
    if place[c[i]-1] != -1:
      if place[c[i]-1] == i-1:
        dp[i] = dp[i-1]
      else:
        dp[i] = (dp[i-1]+dp[place[c[i]-1]])%mod
        
    else:
     dp[i] = dp[i-1]
    place[c[i]-1] = i
 #print(dp)
 #print(place)
 return dp[-1]%mod

print(solve())

Buggy submission (verdict: Runtime Error):
def solve():
 n = int(input())
 c = [int(input()) for _ in range(n)]
 mod = 10**9 +7
 dp = [1]*(n)
 place = [-1]*n
 stack = []
 memo = c[0]

 for i in range(n):
    
    
    if c[i] in stack:
      if memo == c[i]:
        dp[i] = dp[i-1]
      else:
        dp[i] = (dp[i-1]+dp[place[c[i]-1]])%mod
    else:
      dp[i] = dp[i-1]
      stack.append(c[i])
    memo = c[i]
    place[c[i]-1] = i
    #print(place)
    #print(dp)
 return dp[-1]%mod

print(solve())
Problem p03101 (python)

Fixed submission:
H,W = (int(i) for i in input().split())
h,w = (int(i) for i in input().split())
print((H-h)*(W-w))

Buggy submission (verdict: Runtime Error):
H,W　= (int(i) for i in input().split())
h,w　= (int(i) for i in input().split())

print ((H-h)*(W-w))
Problem p03240 (python)

Fixed submission:
import sys
input = sys.stdin.readline
def solve():
  n = int(input())
  query = []
  candi = []
  for i in range(n):
    x,y,h = (int(i) for i in input().split())
    query.append((x,y,h))
  if n == 1:
    print(*[x,y,h])
    exit()
  for cx in range(0,101):
    for cy in range(0,101):
      judge = True
      for j in range(n):
        x,y,h = query[j]
        if not h == 0:
          karih = h +abs(cx-x)+abs(cy-y)
          karih2 = 0
      for i in range(n):
        nx,ny,nh = query[i]
        if nh == max(karih-abs(nx-cx)-abs(ny-cy),0):
          pass
        else:
          judge = False
      if judge:
        candi.append((cx,cy,karih))
        
      judge = True 
      for i in range(n-1):
        nx,ny,nh = query[i+1]
        if nh == max(karih2-abs(nx-cx)-abs(ny-cy),0):
          pass
        else:
          judge = False
      if judge:
        candi.append((cx,cy,karih2))
  print(*candi[0])
        
          
      
      
solve()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def solve():
  n = int(input())
  query = []
  candi = []
  for i in range(n):
    x,y,h = (int(i) for i in input().split())
    query.append((x,y,h))
  if n == 1:
    print(*[x,y,h])
    exit()
  for cx in range(0,101):
    for cy in range(0,101):
      judge = True
      x,y,h = query[0]
      karih = h +abs(cx-x)+abs(cy-y)
      karih2 = 0
      for i in range(n-1):
        nx,ny,nh = query[i+1]
        if nh == max(karih-abs(nx-cx)-abs(ny-cy),0):
          pass
        else:
          judge = False
      if judge:
        candi.append((cx,cy,karih))
        
      judge = True 
      for i in range(n-1):
        nx,ny,nh = query[i+1]
        if nh == max(karih2-abs(nx-cx)-abs(ny-cy),0):
          pass
        else:
          judge = False
      if judge:
        candi.append((cx,cy,karih2))
  print(*candi[0])
        
          
      
      
solve()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def solve():
  n = int(input())
  query = []
  candi = []
  for i in range(n):
    x,y,h = (int(i) for i in input().split())
    query.append((x,y,h))
  if n == 1:
    print(*[x,y,h])
    exit()
  for cx in range(0,101):
    for cy in range(0,101):
      judge = True
      x,y,h = query[0]
      karih = h +abs(cx-x)+abs(cy-y)
      for i in range(n-1):
        nx,ny,nh = query[i+1]
        if nh == max(karih-abs(nx-cx)-abs(ny-cy),0):
          pass
        else:
          judge = False
      if judge:

        candi.append((cx,cy,karih))
  print(*candi[0])
        
          
      
      
solve()
Problem p03486 (python)

Fixed submission:
from sys import stdin
 
s = stdin.readline().rstrip()
t = stdin.readline().rstrip()
s = sorted(s)
t = sorted(t,reverse =True)
tmp1 =("".join(s))
tmp2 =("".join(t))
if tmp1 < tmp2 :print('Yes')
else:print('No')

Buggy submission (verdict: Runtime Error):
from sys import stdin

s = stdin.readline().rstrip()
t = stdin.readline().rstrip()
sa = ''.join(sorted(s))
ts = ''.join(sorted(t,reverse=True))
ans = 'No'
for i in range(len(s)):
  if ord(sa[i]) < ord(ts[i]):
   ans = 'Yes'
   break
  elif sa[i] == ts[i]:
    if len(s) == i+1:
      if len(t) > len(s):
       ans = 'Yes'
      
  else:
   continue

print(ans)
Problem p03550 (python)

Fixed submission:
import sys
input = sys.stdin.readline
def solve():
  n,z,w = (int(i) for i in input().split())
  a = list(int(i) for i in input().split())
  if n == 1:
    ans = abs(w-a[0])
  else:
    ans = 0
    #最小化する方向に動く
    tmp = abs(a[n-2]-a[n-1])
    tmp2 = abs(a[n-1]-w)
    ans = max(tmp,tmp2)
  print(ans)
solve()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def solve():
  n,z,w = (int(i) for i in input().split())
  a = list(int(i) for i in input().split())
  if n == 1:
    ans = abs(w-a[0])
  else:
    ans = 0
    #最小化する方向に動く
    tmp = abs([n-2]-a[n-1])
    tmp2 = abs(a[n-1]-w)
    ans = max(tmp,tmp2)
  print(ans)
solve()
Problem p03635 (python)

Fixed submission:
n,m =  (int(_) for _ in input().split())  
print((n-1)*(m-1))

Buggy submission (verdict: Runtime Error):

n= int(input())
m= int(input())
print((n-1)*(m-1))
Problem p03945 (python)

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

Buggy submission (verdict: Runtime Error):
s = input()
n = len(s)
ct = 0
if len(set(s)) == 1:
  ans = 0
else:
 for i in range(n-1):
  if s[i] != s[i+1]:
    ans+= 1
print(ans)
Problem p04013 (python)

Fixed submission:
def solve():
  n,a = (int(i) for i in input().split())
  x = list(int(i) for i in input().split())
  tp = max(x)
  if tp < a:
    print(0)
    exit()
  
  dp = [[[0 for i in range(n*tp +1)] for j in range(n+1)] for k in range(n+1)]
  query = a*n
  dp[0][0][0] = 1
  for i in range(1,n+1):
    for j in range(n+1):
      for k in range(n*tp +1):
        #選ばない
        dp[i][j][k] = dp[i-1][j][k]
        if x[i-1] <= k and j > 0:
         dp[i][j][k] += dp[i-1][j-1][k-x[i-1]]
        
  ans = 0
  for j in range(1,n+1):
    ans += dp[n][j][j*a]
  #print(dp)
  print(ans)
  
  
  
  
  
  
solve()

Buggy submission (verdict: Runtime Error):
def solve():
  n,a = (int(i) for i in input().split())
  x = list(int(i) for i in input().split())
  tp = max(x)
  dp = [[[0 for i in range(n*tp +1)] for j in range(n+1)] for k in range(n+1)]
  query = a*n
  dp[0][0][0] = 1
  for i in range(1,n+1):
    for j in range(n+1):
      for k in range(n*tp +1):
        #選ばない
        dp[i][j][k] = dp[i-1][j][k]
        if x[i-1] <= k and j > 0:
         dp[i][j][k] += dp[i-1][j-1][k-x[i-1]]
        
  ans = 0
  for j in range(1,n+1):
    ans += dp[n][j][j*a]
  #print(dp)
  print(ans)
  
  
  
  
  
  
solve()
Problem p04034 (python)

Fixed submission:
n,m = (int(i) for i in input().split())
dp = [0]*(n+1)
ball = [1]*(n+1)
dp[0] = 1
for i in range(m):
  x,y = (int(i) for i in input().split())
  if dp[x-1] == 1:
    dp[y-1] = 1
  ball[x-1] -= 1
  ball[y-1] += 1
  if ball[x-1] == 0:
    dp[x-1] = 0
print(sum(dp))

Buggy submission (verdict: Runtime Error):
n,m = (int(i) for i in input().split())
dp = [0]*(m+1)
ball = [1]*(m+1)
dp[0] = 1
for i in range(m):
  x,y = (int(i) for i in input().split())
  if dp[x-1] == 1:
    dp[y-1] = 1
  ball[x-1] -= 1
  ball[y-1] += 1
  if ball[x-1] == 0:
    dp[x-1] = 0
print(sum(dp))
Problem p02732 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()));
lis = [0]*(N+1)
ans = [0]*(N+1)
ans_selected = [0]*(N+1)
ans_sum = 0

for i in A:
    lis[i] += 1

for num, i in enumerate(lis):
    ans[num] = i * (i-1) // 2
    ans_sum += i * (i-1) // 2
    if i != 0:
        ans_selected[num] = (i-1) * (i-2) // 2

for i in A:
    print(ans_sum - ans[i] + ans_selected[i])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()));
lis = [0]*N
ans = [0]*N
ans_selected = [0]*N
ans_sum = 0

for i in A:
    lis[i] += 1

for num, i in enumerate(lis):
    ans[num] = i * (i-1) // 2
    ans_sum += i * (i-1) // 2
    if i != 0:
        ans_selected[num] = (i-1) * (i-2) // 2

for i in A:
    print(ans_sum - ans[i] + ans_selected[i])
Problem p03030 (python)

Fixed submission:
def merge_sort(arr):
    if len(arr) <= 1:
        return arr

    mid = len(arr) // 2
    # ここで分割を行う
    left = arr[:mid]
    right = arr[mid:]

    # 再帰的に分割を行う
    left = merge_sort(left)
    right = merge_sort(right)

    # returnが返ってきたら、結合を行い、結合したものを次に渡す
    return merge(left, right)


def merge(left, right):
    merged = []
    l_i, r_i = 0, 0

    # ソート済み配列をマージするため、それぞれ左から見ていくだけで良い
    while l_i < len(left) and r_i < len(right):
        # ここで=をつけることで安定性を保っている
        if left[l_i] <= right[r_i]:
            merged.append(left[l_i])
            l_i += 1
        else:
            merged.append(right[r_i])
            r_i += 1

    # 上のwhile文のどちらかがFalseになった場合終了するため、あまりをextendする
    if l_i < len(left):
        merged.extend(left[l_i:])
    if r_i < len(right):
        merged.extend(right[r_i:])
    return merged

# 以上マージソート

N = int(input())
 
list = []
 
for i in range(N):
    A, B = input().split()
 
    A = A + "000000000000"
    A = A[:10]
    B = str(2000-int(B))+str(i+1001)
    list.append(A+B)
 
list = merge_sort(list)
 
for i in list:
    print(int(i[-3:]))

Buggy submission (verdict: Runtime Error):

N = int(input())

list = []

for i in range(N):
    A, B = input().split()

    A = A + "000000000000"
    A = A[:10]
    B = str(2000-int(B))+str(i+1001)
    list.append(A+B)

list = merge_sort(list)

for i in list:
    print(int(i[-3:]))
Problem p02772 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
for i in A:
         if  i % 2 ==0:
           if (i % 3 != 0) and ( i % 5 != 0):
             print('DENIED')
             exit()
print ('APPROVED')

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

count = 0
for i in range (1,N+1):
  if i % 3 == 0 or i % 5 == 0:
    count += i
  print(count)
Problem p03597 (python)

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

print (n * n - a)

Buggy submission (verdict: Runtime Error):
a,n = input().split()
a = int(a)
n = int(n)
print (n * n - a)

Buggy submission (verdict: Runtime Error):
a,n = input().split()
a = int(a)
n = int(n)
print (n * n - a)
Problem p03494 (python)

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

# n = 5
# A = [2,4, 6]

cnt = 0

flag=True
while flag:
    for a in A:
        if a % 2 == 0:
            continue
        else:
            flag=False
            break 
    if not flag: 
        break
    A = [a/2 for a in A]
    cnt = cnt + 1
print(cnt)

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

int cnt=0

while True:
    exist_odd = False
    for a in A:
        if a % 2 == 0:
            continue
        else:
            exist_odd = True
            break 
    if exist_odd: 
        break
    A = [a/2 for a in A]
    cnt = cnt + 1
print(cnt)
Problem p02657 (python)

Fixed submission:
a,b = (int(x) for x in input().split())
print(a*b)

Buggy submission (verdict: Runtime Error):
x = input.split()
y = int(x[0])*int(x[1])
print(y)

Buggy submission (verdict: Runtime Error):
a,b = (int(x) for x in input.split())
print(a*b)

Buggy submission (verdict: Runtime Error):
num[]=input()
x = num[0]*num[1]
print(x)

Buggy submission (verdict: Runtime Error):
A=input()
B=input()
print(A*B)

Buggy submission (verdict: Runtime Error):
print(A*B)

Buggy submission (verdict: Runtime Error):
A*B