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

Fixed submission:
h, w, a, b = map(int, input().split())
mod = 1000000007

def modpow(x, y):   
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return modpow(x, y//2)**2 % mod
    else            : return modpow(x, y//2)**2 * x % mod

stairs = [1]
for i in range(1, h+w+1):
    stairs.append(stairs[i-1]*i%mod)

inverse_stairs = [0]*(h+w)
inverse_stairs[h+w-1] = modpow(stairs[h+w-1], mod-2)
for i in range(h+w-2, -1, -1):
    inverse_stairs[i] = inverse_stairs[i+1] * (i+1) % mod
    
ret = 0
for i in range(w-b):
    com = stairs[w-i+h-a-2]%mod
    com = com*inverse_stairs[w-i-1]%mod
    com = com*inverse_stairs[h-a-1]%mod
    com = com*stairs[i+a-1]%mod
    com = com*inverse_stairs[i]%mod
    com = com*inverse_stairs[a-1]%mod
    ret += com

print(ret%mod)

Buggy submission (verdict: Runtime Error):
h, w, a, b = map(int, input().split())
mod = 1000000007

stairs = [1]
for i in range(1, h+w+1):
    stairs.append(stairs[i-1]*i%mod)

inverse_stairs = [0]*(h+w)
inverse_stairs[h+w-1] = modpow(stairs[h+w-1], mod-2)
for i in range(h+w-2, -1, -1):
    inverse_stairs[i] = inverse_stairs[i+1] * (i+1) % mod
    
def modpow(x, y):   
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return modpow(x, y//2)**2 % mod
    else            : return modpow(x, y//2)**2 * x % mod

ret = 0

for i in range(w-b):
    com = stairs[w-i+h-a-2]%mod
    com = com*inverse_stairs[w-i-1]%mod
    com = com*inverse_stairs[h-a-1]%mod
    com = com*stairs[i+a-1]%mod
    com = com*inverse_stairs[i]%mod
    com = com*inverse_stairs[a-1]%mod
    ret += com

print(ret%mod)
Problem p02720 (python)

Fixed submission:
from collections import deque

k = int(input())

d = deque(list(range(1, 10)))
c = 0
v = 0
while c < k:
    v = d.popleft()
    c += 1
    if v % 10 == 9:
        d.append(v * 10 + 8)
        d.append(v * 10 + 9)
    elif v % 10 == 0:
        d.append(v * 10)
        d.append(v * 10 + 1)
    else:
        t = v % 10
        d.append(v * 10 + t - 1)
        d.append(v * 10 + t)
        d.append(v * 10 + t + 1)
print(v)

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

d = deque(list(range(1, 10)))
c = 0
v = 0
while c < k:
    v = d.popleft()
    c += 1
    if v % 10 == 9:
        d.append(v * 10 + 8)
        d.append(v * 10 + 9)
    elif v % 10 == 0:
        d.append(v * 10)
        d.append(v * 10 + 1)
    else:
        t = v % 10
        d.append(v * 10 + t - 1)
        d.append(v * 10 + t)
        d.append(v * 10 + t + 1)
print(v)
Problem p02727 (python)

Fixed submission:


x, y, a, b, c = list(map(int, input().split(' ')))
pa = list(map(int, input().split(' ')))
qb = list(map(int, input().split(' ')))
rc = list(map(int, input().split(' ')))

pa = sorted(pa)[len(pa) - x:]
qb = sorted(qb)[len(qb) - y:]
rc = sorted(rc, reverse=True)

ai = 0
bi = 0
result = sum(pa) + sum(qb)

for r in rc:
    if bi >= len(qb) and ai >= len(pa):
        break
    
    elif bi >= len(qb) or pa[ai] <= qb[bi]:
        if r > pa[ai]:
            result = result - pa[ai] + r
            ai += 1
            
    elif ai >= len(pa) or pa[ai] >= qb[bi]:
        if r > qb[bi]:
            result = result - qb[bi] + r
            bi += 1
print(result)

Buggy submission (verdict: Runtime Error):
x, y, a, b, c = list(map(int, input().split(' ')))
pa = list(map(int, input().split(' ')))
qb = list(map(int, input().split(' ')))
rc = list(map(int, input().split(' ')))

pa = sorted(pa)[len(pa) - x:]
qb = sorted(qb)[len(qb) - y:]
rc = sorted(rc, reverse=True)

ai = 0
bi = 0
result = sum(pa) + sum(qb)

for r in rc:
    if bi >= b and ai >= a:
        break
    
    if bi >= b or pa[ai] <= qb[bi]:
        if r > pa[ai]:
            result = result - pa[ai] + r
            ai += 1
    elif ai >= a or pa[ai] >= qb[bi]:
        if r > qb[bi]:
            result = result - qb[bi] + r
            bi += 1
print(result)

Buggy submission (verdict: Runtime Error):
x, y, a, b, c = list(map(int, input().split(' ')))
pa = list(map(int, input().split(' ')))
qb = list(map(int, input().split(' ')))
rc = list(map(int, input().split(' ')))

pa = sorted(pa)[len(pa) - x:]
qb = sorted(qb)[len(qb) - y:]
rc = sorted(rc, reverse=True)

ai = 0
bi = 0
result = sum(pa) + sum(qb)
for r in rc:
    if bi >= b or pa[ai] < qb[bi]:
        if r > pa[ai]:
            result = result - pa[ai] + r
            ai += 1
    elif ai >= a or pa[ai] > qb[bi]:
        if r > qb[bi]:
            result = result - qb[bi] + r
            bi += 1
print(result)
Problem p03161 (python)

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

hs = list(map(int, input().split(' ')))

dp = [float('inf')] * (n + k + 1)
dp[0] = 0

for i in range(n - 1):
    for j in range(1, k + 1):
        if i + j < n:
            dp[i + j] = min([
                dp[i + j],
                dp[i] + abs(hs[i] - hs[i + j])
            ])

print(dp[n - 1])

Buggy submission (verdict: Runtime Error):
INF = 10**9

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

dp = [INF] * (n + 10000 * k)
dp[0] = 0

for i in range(1, n):
    a = INF
    hsi = hs[i]
    for m in range(1, k + 1):
        j = i - m
        v = dp[j] + abs(hs[j] - hsi)
        if a > v:
            a = v
    dp[i] = a
print(dp[n - 1])
Problem p03212 (python)

Fixed submission:
from collections import deque

n = int(input())
nums = [3, 5, 7]

d = deque([0])

count = 0
while True:
    if len(d) == 0:
        break
    x = d.popleft()
    if x > n:
        continue
    else:
        if '3' in str(x) and '5' in str(x) and '7' in str(x):
            count += 1
        for num in nums:
            d.append(x * 10 + num)
print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
nums = [3, 5, 7]

d = deque([0])

count = 0
while True:
    if len(d) == 0:
        break
    x = d.popleft()
    if x > n:
        continue
    else:
        if '3' in str(x) and '5' in str(x) and '7' in str(x):
            count += 1
        for num in nums:
            d.append(x * 10 + num)
print(count)
Problem p03220 (python)

Fixed submission:
n = int(input())
t, a = list(map(int, input().split(' ')))
hn = list(map(int, input().split(' ')))

def get_dif(h):
    temp = t - h * 0.006
    dif = abs(temp - a)
    return dif

result = hn.index(min(hn, key=get_dif)) + 1
print(result)

Buggy submission (verdict: Runtime Error):
n = int(input())
t, a = list(map(int, input().split(' ')))
hs = list(map(int, input().split(' ')))

diff_a = list(map(lambda h: int(abs(a - t + h * 0.006)), hs))
ans = 100_000
result = -1
for i in range(n):
    if diff_a[i] <= ans:
        result = i + 1
        ans = diff_a[i]

print(result)

Buggy submission (verdict: Runtime Error):

n = int(input())
t, a = list(map(int, input().split(' ')))
hs = list(map(int, input().split(' ')))

diff_a = list(map(lambda h: int(abs(a - t + h * 0.006)), hs))
ans = 100_000
result = -1
for i in range(n):
    if diff_a[i] <= ans:
        result = i + 1
        ans = diff_a[i]

print(result)

Buggy submission (verdict: Runtime Error):

n = int(input())
t, a = list(map(int, input().split(' ')))
hs = list(map(int, input().split(' ')))

diff_a = list(map(lambda h: int(abs(a - t + h * 0.006)), hs))
print(diff_a)
ans = 100_000
result = -1
for i in range(n):
    if diff_a[i] <= ans:
        result = i + 1
        ans = diff_a[i]

print(result)
Problem p03282 (python)

Fixed submission:
s = input()
k = int(input())

if sum(map(int, list(s[:k]))) == len(s[:k]):
    print('1')
else:
    ans = s.replace('1', '')[0]
    print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())

if sum(map(int, list(s))) == k:
    print('1')
else:
    ans = s.replace('1', '')[0]
    print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())

if s[:k] in '1' * k:
    print('1')
else:
    ans = s.replace('1', '')[0]
    print(ans)
Problem p03408 (python)

Fixed submission:
n = int(input())
ss = []
for i in range(n):
    ss.append(input())

m = int(input())
ts = []
for i in range(m):
    ts.append(input())

counter = dict()

for s in ss:
    counter.setdefault(s, 0)
    c = counter.get(s)
    counter[s] = c + 1
    
for t in ts:
    counter.setdefault(t, 0)
    c = counter.get(t)
    counter[t] =  c - 1
    
ans = max(counter.values())
if ans < 0:
    ans = 0
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
ss = []
for i in range(n):
    ss.append(input())

m = int(input())
ts = []
for i in range(m):
    ts.append(input())

counter = dict()

for s in ss:
    counter.setdefault(s, 0)
    c = counter.get(s)
    counter[s] = c + 1
    
for t in ts:
    counter.setdefault(t, 0)
    c = counter.get(t)
    counter[t] =  c - 1
    
ans = max(counter.values()
if ans < 0:
    ans = 0
print(ans)
Problem p03425 (python)

Fixed submission:
import itertools
from collections import Counter

n = int(input())
c = Counter()
for i in range(n):
    tmp = input().strip()
    if tmp[0] in ['M', 'A', 'R', 'C', 'H']:
        c[tmp[0]] += 1

result = 0
for v in itertools.permutations(c.values(), 3):
    result += v[0] * v[1] * v[2]

print(result // 6)

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

n = int(input())
c = Counter()
for i in range(n):
    tmp = input().strip()
    if tmp[0] in ['M', 'A', 'R', 'C', 'H']:
        c[tmp[0]] += 1

result = 0
for v in itertools.permutations(c.values(), 3):
    result += v[0] * v[1] * v[2]

print(result // 6)
Problem p03433 (python)

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

m = n % 500
if m <= a:
    print('Yes')
else:
    print('No')

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

m = n mod 500
if m <= a:
    print('Yes')
else:
    print('No')
Problem p03533 (python)

Fixed submission:
s = input().strip()

t = 'AKIHABARA'
si = 0
result = True

if len(s) > len(t):
    print('NO')
    exit()

for ti in range(len(t)):
    if si >= len(s):
        if t[ti:] == 'A' * (len(t) - ti):
            result = True
        else:
            result = False
        break
    elif s[si] == t[ti]:
        si += 1
    elif t[ti] == 'A':
        continue
    else:
        result = False
        break

if result:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
s = input().strip()

t = 'AKIHABARA'
ti = 0
result = True

for i in range(len(s)):
    if s[i] == t[ti]:
        ti += 1
    elif s[i] == 'A':
        continue
    else:
        result = False

if result:
    print('YES')
else:
    print('NO')
Problem p02687 (python)

Fixed submission:
s = input()
if s=="ABC":
  print("ARC")
else:
  print("ABC")

Buggy submission (verdict: Runtime Error):
s = input()
if s=="ABC":
print("ARC")
else:
  print("ABC")

Buggy submission (verdict: Runtime Error):
s = input()
if s=="ABC:
print("ARC")
else:
  print("ABC")
Problem p02742 (python)

Fixed submission:
H,W = list(map(lambda x:int(x),input().split(" ")))
if H==1 or W==1:
  ans=1
elif H*W%2==0:
  ans=H*W/2
else:
  ans=(H*W+1)/2

print(int(ans))

Buggy submission (verdict: Runtime Error):
H,W = list(map(lambda x:int(x),input().split("")))
if H*W%2==0:
  ans=H*W/2
else:
  ans=(H*W+1)/2

print(ans)
Problem p02830 (python)

Fixed submission:
N= int(input())
S,T = input().split(" ")

ans = ""
for i in range(N):
  ans = ans+S[i]+T[i]
print(ans)

Buggy submission (verdict: Runtime Error):
N= int(input())
S = input()
T = input()
ans = ""
for i in range(N):
  ans = ans+S[i]+T[i]
print(ans)
Problem p02981 (python)

Fixed submission:
n,a,b  = list(map(lambda x: int(x),input().split()))
print(min(n*a,b))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(lambda x: int(x),input().split()))
X = [(-1)**(i) for i in range(N)]
for i in range(N):
    c = 0
    for j in range(N):
        c += A[j]*X[(N+j-i)%N]
    print(c,end=" ")
Problem p03062 (python)

Fixed submission:
import numpy as np

N = int(input())
A = np.array(list(map(lambda x: int(x),input().split())))

A_allplus = np.where(A>=0,A,-A)
#print(A_allplus)
plus = A[A>=0]
minus = A[A<0]
#print(minus)
d = 0
if len(minus)%2==1:
    a = np.inf
    b = np.inf
    if len(minus)>0:
        a = max(minus)
    if len(plus)>0:
        b = min(plus)
    
    
    d = min(abs(a),abs(b))*2

print(sum(A_allplus)-d)

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

N = int(input())
A = np.array(list(map(lambda x: int(x),input().split())))

A_allplus = np.where(A>=0,A,-A)
#print(A_allplus)
plus = A[A>=0]
minus = A[A<0]
#print(minus)
d = 0
if len(minus)%2==1:
    a = max(minus)
    b = min(plus)
    
    d = min(abs(a),abs(b))*2

print(sum(A_allplus)-d)
Problem p03085 (python)

Fixed submission:
import numpy as np

s=input()

if s=='A':
    print('T')

if s=='T':
    print('A')

if s=='G':
    print('C')

if s=='C':
    print('G')

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
2 S = input()
3 t = [0] * (N + 1)
4 for i in range(N):
5 t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
6 for i in range(Q):
7 l, r = map(int, input().split())
8 print(t[r-1] - t[l-1])
Problem p03086 (python)

Fixed submission:
import numpy as np

s=input()
isContinue=0
part=[0]

for i in range(len(s)):
    if s[i]=='A' or s[i]=='T' or s[i]=='C' or s[i]=='G':
        isContinue+=1
        if i==len(s)-1:
            part.append(isContinue)
    else:
        part.append(isContinue)
        isContinue=0

print(max(part))

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

s=input()
isContinue=0
part=[]

for c in s:
    if c=='A' or c=='T' or c=='C' or c=='G':
        isContinue+=1
    else:
        part.append(isContinue)
        isContinue=0

print(max(part))
Problem p03087 (python)

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
2 S = input()
3 t = [0] * (N + 1)
4 for i in range(N):
5     t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
6 for i in range(Q):
7     l, r = map(int, input().split())
8     print(t[r-1] - t[l-1])

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
2 S = input()
3 t = [0] * (N + 1)
4 for i in range(N):
5 t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
6 for i in range(Q):
7 l, r = map(int, input().split())
8 print(t[r-1] - t[l-1])
Problem p03101 (python)

Fixed submission:
lst=input().split(" ")
H=int(lst[0])
W=int(lst[1])
lst=input().split(" ")
h=int(lst[0])
w=int(lst[1])

print(H*W-(h*W+H*w-h*w))

Buggy submission (verdict: Runtime Error):
import Math

lst=input().split(" ")
H=int(lst[0])
W=int(lst[1])
lst=input().split(" ")
h=int(lst[0])
w=int(lst[1])

print(H*W-(h*W+H*w-h*w))
Problem p02803 (python)

Fixed submission:
import bisect
import math
from queue import Queue
import sys
from copy import copy, deepcopy
from collections import defaultdict, Counter, deque
from itertools import combinations, permutations
from heapq import heapify, heappop, heappush

read = sys.stdin.read
readline = sys.stdin.readline 
readlines = sys.stdin.readlines 


inf = float("inf")

def main():

    H, W = map(int, readline().split())
    S = [[s for s in input()] for h in range(H)]
    
    ret = 0
    
    delta = [(-1, 0), (1, 0), (0, -1), (0, 1)]
    
    
    
    for h in range(H):
        for w in range(W):
            if S[h][w] == '.':
                tmp_ret = 0
                maze = deepcopy(S)
                maze[h][w] = tmp_ret
                
                q1 = Queue()
                q1.put((h, w))
                
                q2 = Queue()
                
                while not (q1.empty() and q2.empty()):
                    while not q1.empty():
                        h, w = q1.get()
                        for dh, dw in delta:
                            if h + dh < H and h + dh >= 0 \
                            and w + dw < W and w + dw >= 0 \
                            and maze[h + dh][w + dw] == '.':
                                maze[h + dh][w + dw] = tmp_ret
                                q2.put((h + dh, w + dw))

                    if not q2.empty():
                        q1 = q2
                        q2 = Queue()
                        tmp_ret += 1
                        
                ret = max(ret, tmp_ret)
    
    print(ret)


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
from copy import copy
from queue import Queue

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

maze = []
for _ in range(H):
  maze.append([i for i in input()])
  
# 無向グラフを作ってワーシャルフロイド法で解く
d = {}
for i in range(H):
  for j in range(W):
    if maze[i][j] == '.':
      d[((i, j), (i, j))] = 0

directions = [(-1, 0), (1, 0), (0, -1), (0, 1)]
for i in range(H):
  for j in range(W):
    if maze[i][j] == '.':
      for di, dj in directions:
        if i + di >= 0 and i + di < H\
        and j + dj >= 0 and j + dj < W\
        and maze[i + di][j + dj] == '.':
          d[((i, j), (i + di, j + dj))] = 1
          d[((i + di, j + dj), (i, j))] = 1

            
# 連結成分ごとにワーシャルフロイド法を実行し、最大距離を計算する
for i1 in range(H):
  for j1 in range(W):
    for i2 in range(H):
      for j2 in range(W):
        for i3 in range(H):
          for j3 in range(W):
            if maze[i1][j1] == '.'\
            and maze[i2][j2] == '.'\
            and maze[i3][j3] == '.':
              d[((i1, j1), (i3, j3))]\
              = min(
                d[((i1, j1), (i3, j3))],
                d[((i1, j1), (i2, j2))] + d[((i2, j2), (i3, j3))]
              )

# 全ての連結成分の最大距離を求めて出力

ret = 0
for i1 in range(H):
  for j1 in range(W):
    for i2 in range(H):
      for j2 in range(W):
        if d[((i1, j1), (i2, j2))] != inf\
        and d[((i1, j1), (i2, j2))] > ret:
          ret = d[((i1, j1), (i2, j2))]
          
print(ret)
Problem p02882 (python)

Fixed submission:
import numpy as np

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

bottom = 2 * x / a**2 - b

if bottom == b:
    print(0)

else:    
    if bottom > 0:
        tan =  a / (b -  bottom)

    else:
        bottom = 2 / (a * b) * x
        tan = bottom / b

    theta = np.arctan(tan)
    ret = 90 - np.rad2deg(theta)

    print(ret)

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

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

bottom = 2 * x / a**2 - b
if bottom > 0:
    tan =  a / (b -  bottom)
    
else:
    bottom = 2 / (a * b) * x
    tan = bottom / b
    
theta = np.arctan(tan)
ret = 90 - np.rad2deg(theta)

print(ret)
Problem p02921 (python)

Fixed submission:
S = input()
T = input()

ret = 0
for s, t in zip(S, T):
  if s == t:
    ret += 1
    
print(ret)

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

ret = 0
for s, t in zip(S, T):
  is s == t:
    ret += 1
    
print(ret)
Problem p02945 (python)

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

print(max(max(A+B, A - B), A * B))

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

print(max(max(A+B, A - B), A * B))
Problem p02957 (python)

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

if A % 2 == B % 2:
  print((A+B)//2)
else:
  print("IMPOSSIBLE")

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

if A % 2 == B % 2:
  print((A+B)//2)
else:
  print("IMPOSSIBLE")
Problem p02848 (python)

Fixed submission:
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
alphabet += alphabet
n = int(input())
s = list(input())
res = "".join([alphabet[alphabet.index(_) + n] for _ in s])
print(res)

Buggy submission (verdict: Runtime Error):
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
alphabet += alphabet
n = int(input())
s = input()
res = alphabet[alphabet.index(_) + n] for _ in s
print(res)
Problem p03030 (python)

Fixed submission:
n = int(input())
restaurants_list = []
for _ in range(n):
  s, p = input().split()
  restaurants_list.append([s, -int(p), _+1])
restaurants_list.sort()
for _ in range(n):
  print(restaurants_list[_][2])

Buggy submission (verdict: Runtime Error):
n = int(input())
restaurants_list = []
for _ in range(n):
  s, p = input().split()
  restaurants_list.append([s, p, _])
restaurants_list.sort()
for _ in range(n):
  print(restaurants_list[2])
Problem p03493 (python)

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

Buggy submission (verdict: Runtime Error):
print(list(str(intput())).count("1"))
Problem p02684 (python)

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
now=1
arr=[0]*(n+1)
for i in range(1,10**6):
  now=a[now-1]
  if i==k:
    print(now)
    quit()
  if arr[now]!=0:
    first=arr[now]
    break
  arr[now]=i
# print(arr)
cycle=max(arr)-first+1
# print(cycle)
mod=(k-first)%cycle
# print(mod)
ans=arr.index(first+mod)
print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
now=a[0]
his=[now]
for i in range(20):
  now=a[now-1]
#  print(now)
  if i==k-1:
    quit()
  if now in his:
    first=his.index(now)
    last=i
    break
  his.append(now)
print(his[first+(k-first)%(last-first+1)-1])
Problem p02928 (python)

Fixed submission:
n,k=map(int,input().split())
a=list(map(int,input().split()))
mod=10**9+7
c=[]
ans=0
for i in range(2002):
    c.append([0,0])
for i in range(n):
    c[a[i]][0]+=1
    for j in range(a[i]+1,2001):
        ans+=c[j][0]
for i in range(1999,-1,-1):
    c[i][0]+=c[i+1][0]
d=0
for i in a:
    d+=c[i+1][0]
print((k*ans+d*(k*(k-1))//2)%mod)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))
mod=10**9+7
c=[]
ans=0
for i in range(2001):
    c.append([0,0])
for i in range(n):
    c[a[i]][0]+=1
    for j in range(a[i]+1,2001):
        ans+=c[j][0]
for i in range(1999,-1,-1):
    c[i][0]+=c[i+1][0]
d=0
for i in a:
    d+=c[i+1][0]
print((k*ans+d*(k*(k-1))//2)%mod)
Problem p02995 (python)

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

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

def div(a, b, x):
    if a%x!=0:
        return b//x-a//x
    else:
        return b//x-(a//x-1)

print(int(b-a+1-(div(a,b,c)+div(a,b,d)-div(a,b,lcm(c,d)))))

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)

cc=math.floor(b/c)-math.ceil(a/c)+1
dd=math.floor(b/d)-math.ceil(a/d)+1
cd=math.floor(b/(lcm(c, d)))-math.ceil(a/(lcm(c, d)))+1

print(b-a+1-(cc+dd-cd))
Problem p03030 (python)

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

for i in range(n):
    if int(sp[i][1])==0:
        sp[i][1]=float('inf')
    else:
        sp[i][1]=1/int(sp[i][1])
ps=sorted(sp)
for i in range(n):
    print(sp.index(ps[i])+1)

Buggy submission (verdict: Runtime Error):
n=int(input())
sp=[list(map(str,input().split())) for i in range(n)]

for i in range(n):
    sp[i][1]=1/int(sp[i][1])
ps=sorted(sp)
for i in range(n):
    print(sp.index(ps[i])+1)
Problem p03324 (python)

Fixed submission:
d,n=map(int,input().split())
if n==100:
    print(100**d*(n+1))
else:
    print(100**d*n)

Buggy submission (verdict: Runtime Error):
d,n=map(int,input().split())
print(100**d*n)d,n=map(int,input().split())
if n==100:
    print(100**d*(n+1))
else:
    print(100**d*n)
Problem p02687 (python)

Fixed submission:
S=str(input())
if S=="ABC":
  print("ARC")
else:
  print("ABC")

Buggy submission (verdict: Runtime Error):
N=int(input())
for A in range(-118,120):
  for B in range(-119,119):
    if A**5-B**5==N:
      print(A,B)
      exit()
Problem p02690 (python)

Fixed submission:
N=int(input())
for A in range(-118,120):
  for B in range(-119,119):
    if A**5-B**5==N:
      print(A,B)
      exit()

Buggy submission (verdict: Runtime Error):
N=int(input())
for A in range(-118,120):
  for B in range(-119.119):
    if A**5-B**5==N:
      print(A,B)

Buggy submission (verdict: Runtime Error):
N=int(input())
for A in range(-118,120):
  for B in range(-119.119):
    if A**5-B**5==N:
      print(A,B)
Problem p02696 (python)

Fixed submission:
A,B,N=map(int,input().split())
x=min(B-1,N)
print(int(A*x/B))

Buggy submission (verdict: Runtime Error):
A,B,N=map(int,input().split())
x=min(B-1,N)
print(int(A*x/B)-A*int(x/B)