Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from sys import stdin

n, k = map(int, stdin.readline().rstrip().split())
a = map(int, stdin.readline().rstrip().split())

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
  
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
  
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
 
bit = Bit(n*k)
ans = 0
a = list(a)*k
for i, p in enumerate(a):
    ans += (i - bit.sum(p)) % (10^9+7)
    bit.add(p, 1)
print(ans)

Fixed submission:
from sys import stdin

n, k = map(int, stdin.readline().rstrip().split())
a = map(int, stdin.readline().rstrip().split())

a = list(a) 
count = 0 
for i in range(1, n):
    for j in range(i):
        if a[j] > a[i]:
            count += 1
import copy
b = copy.copy(a)
b.sort()
count *= k
import bisect
ans2 = 0
for i in range(n):
  ans2 += bisect.bisect_left(b, a[i])
print((count + ans2 * (((k-1)* k)//2))%(1000000007))
Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

r, g, b, n = map(int, stdin.readline().rstrip().split())
count = 0
for i in range(n + 1):
    for j in range(n + 1):
        if i * r + j * g <= n:
            if (n - (i * r + j * g)) % b == 0:
                # print(i, j, int((n - (i * r + j * i)) / b))
                count += 1
print(count)

Fixed submission:
from sys import stdin

r, g, b, n = map(int, stdin.readline().rstrip().split())
count = 0
for i in range(n + 1):
    for j in range(n + 1):
        if i * r + j * g <= n:
            if (n - (i * r + j * g)) % b == 0:
                # print(i, j, int((n - (i * r + j * i)) / b))
                count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
import math
from sys import stdin

n, m = map(int, stdin.readline().rstrip().split())
s = stdin.readline().rstrip()
t = stdin.readline().rstrip()


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


if max(n, m) % min(n, m) == 0:
    print(-1)
else:
    print(lcm(n, m))

Fixed submission:
import fractions
import sys
from sys import stdin

n, m = map(int, stdin.readline().rstrip().split())
s = stdin.readline().rstrip()
t = stdin.readline().rstrip()


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


g = fractions.gcd(n, m)
for i in range(g):
    if s[n // g * i] != t[m // g * i]:
        print(-1)
        sys.exit()
print(lcm(n, m))
Buggy python submission (verdict: Runtime Error):
import bisect
import math
import sys
from bisect import bisect_left
from math import ceil, sqrt

q = int(sys.stdin.readline().rstrip())
lr = [list(map(int, sys.stdin.readline().rstrip().split())) for i in range(q)]


def era_prime(N):
    temp = [True]*(N+1)
    temp[0] = temp[1] = False
    for i in range(2, ceil(sqrt(N+1))):
        if temp[i]:
            temp[i+i::i] = [False]*(len(temp[i+i::i]))
    primes = [n for n in range(N+1) if temp[n]]
    return primes


primes = era_prime(100000)
post_primes = []
ind = 0
tmp = 0
p = [0]
for pi in primes:
    if (pi + 1) // 2 in primes:
        post_primes.append(pi)

for i in range(1, 100000):
    if ind >= len(post_primes):
        break
    if i == post_primes[ind]:
        tmp += 1
        ind += 1
    p.append(tmp)
for lri in lr:
    ans = 0
    print(p[lri[1]]-p[lri[0]-1])

Fixed submission:
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
c=[0]
ci=0
for i in range(1,10**5+1):
  if is_prime(i) and is_prime((i+1)//2):
    ci+=1
  c.append(ci)
q=int(input())
lr=[list(map(int,input().split())) for _ in range(q)]
for lri in lr:
  print(c[lri[1]]-c[lri[0]-1])

Buggy python submission (verdict: Runtime Error):
import math
import sys
from bisect import bisect_left
from math import ceil, sqrt

q = int(sys.stdin.readline().rstrip())
lr = [list(map(int, sys.stdin.readline().rstrip().split())) for i in range(q)]


def era_prime(N):
    temp = [True]*(N+1)
    temp[0] = temp[1] = False
    for i in range(2, ceil(sqrt(N+1))):
        if temp[i]:
            temp[i+i::i] = [False]*(len(temp[i+i::i]))
    primes = [n for n in range(N+1) if temp[n]]
    return primes


primes = era_prime(100000)
post_primes = []
for pi in primes:
    if (pi + 1) // 2 in primes:
        post_primes.append(pi)


for lri in lr:
    l = bisect_left(post_primes, lri[0])
    r = bisect_left(post_primes, lri[1])
    ans = r - l
    # if post_primes[l] == post_primes[r] and post_primes[l] in lri:
    #     ans += 1
    if post_primes[r] in lri:
        ans += 1
    print(ans)

Fixed submission:
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True
c=[0]
ci=0
for i in range(1,10**5+1):
  if is_prime(i) and is_prime((i+1)//2):
    ci+=1
  c.append(ci)
q=int(input())
lr=[list(map(int,input().split())) for _ in range(q)]
for lri in lr:
  print(c[lri[1]]-c[lri[0]-1])
Buggy python submission (verdict: Time Limit Exceeded):
import sys

n = int(sys.stdin.readline().rstrip())
a = list(map(int, sys.stdin.readline().rstrip().split()))
a.sort()
# print(a)
ans = 0
for i in range(n):
    a = a[1:]
    a = a[:-1]
    ans += a[-1]
    a = a[:-1]
print(ans)

Fixed submission:
import sys

n = int(sys.stdin.readline().rstrip())
a = list(map(int, sys.stdin.readline().rstrip().split()))
a.sort()

# print(a)
ans = 0
a = a[n:]
a.reverse()
print(sum(a[1::2]))

Buggy python submission (verdict: Time Limit Exceeded):
import sys

n = int(sys.stdin.readline().rstrip())
a = list(map(int, sys.stdin.readline().rstrip().split()))
a.sort()
# print(a)
ans = 0
for i in range(n):
    a.pop(0)
    a.pop(-1)
    ans += a[-1]
    a.pop(-1)
print(ans)

Fixed submission:
import sys

n = int(sys.stdin.readline().rstrip())
a = list(map(int, sys.stdin.readline().rstrip().split()))
a.sort()

# print(a)
ans = 0
a = a[n:]
a.reverse()
print(sum(a[1::2]))

Buggy python submission (verdict: Time Limit Exceeded):
import sys

n = int(sys.stdin.readline().rstrip())
a = list(map(int, sys.stdin.readline().rstrip().split()))
a.sort()
# print(a)
ans = 0
for i in range(n):
    a.pop(0)
    a.pop(-1)
    ans += a[-1]
    a.pop(-1)
print(ans)

Fixed submission:
import sys

n = int(sys.stdin.readline().rstrip())
a = list(map(int, sys.stdin.readline().rstrip().split()))
a.sort()

# print(a)
ans = 0
a = a[n:]
a.reverse()
print(sum(a[1::2]))
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

flag = False
s_tmp = S
for cnt in range(len(s)):
    s_tmp = s_tmp[-1] + s_tmp[:-1]
    if s_tmp == T:
        flag = True
        break

if flag:
    print("Yes")
else:
    print("No")

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

flag = False
s_tmp = S
for cnt in range(len(S)):
    s_tmp = s_tmp[-1] + s_tmp[:-1]
    if s_tmp == T:
        flag = True
        break

if flag:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import math
def nCr(n, r): 

  return (math.fact(n) // (math.fact(r)  
                           * math.fact(n - r))) 
n,m=list(map(int,input().split()))
total=0
if n>1:
  total+=nCr(n,2)
if m>1:
  total+=nCr(m,2)
print(total)

Fixed submission:
import math
def nCr(n, r): 
  
    return (math.factorial(n) // (math.factorial(r)  
                * math.factorial(n - r))) 
n,m=list(map(int,input().split()))
total=0
if n>1:
  total+=nCr(n,2)
if m>1:
  total+=nCr(m,2)
print(total)

Buggy python submission (verdict: Runtime Error):
import math
def nCr(n, r): 
  
    return (math.fact(n) // (math.fact(r)  
                * math.fact(n - r))) 
n,m=list(map(int,input().split()))
total=0
if n>1:
  total+=nCr(n,2)
if m>1:
  total+=nCr(m,2)
print(total)


Fixed submission:
import math
def nCr(n, r): 
  
    return (math.factorial(n) // (math.factorial(r)  
                * math.factorial(n - r))) 
n,m=list(map(int,input().split()))
total=0
if n>1:
  total+=nCr(n,2)
if m>1:
  total+=nCr(m,2)
print(total)
Buggy python submission (verdict: Runtime Error):
def check(s):
  n=len(s)
  if s!==s[::-1]:
    return "No"
  temp=s[:(n-1)//2]
  if temp!=temp[::-1]:
    return "No"
  temp=s[((n+3)//2)-1:]
  if temp!=temp[::-1]:
    return "No"
  return "Yes"
s=input()
print(check(s))

Fixed submission:
def check(s):
  n=len(s)
  if s!=s[::-1]:
    return "No"
  temp=s[:(n-1)//2]
  if temp!=temp[::-1]:
    return "No"
  temp=s[((n+3)//2)-1:]
  if temp!=temp[::-1]:
    return "No"
  return "Yes"
s=input()
print(check(s))
Buggy python submission (verdict: Runtime Error):
print(48 - input())

Fixed submission:
# coding = SJIS

m = int(input())

ans = 48 - m

print(ans)
Buggy python submission (verdict: Runtime Error):
# coding = SJIS

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

print(min(n * a), b)

Fixed submission:
# coding = SJIS

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

print(min((n * a), b))
Buggy python submission (verdict: Time Limit Exceeded):
# coding = SJIS

n = int(input())
pap = []
for i in range(n):
    p = int(input())
    if p not in pap:
        pap.append(p)
    else:
        pap.remove(p)

print(len(pap))

Fixed submission:
# coding = SJIS

n = int(input())
a = [int(input()) for i in range(n)]
ans = 0

a.sort()

i = 0

while i < n:
    ko = 1
    while (i + ko) < n and a[i] == a[i + ko]:
        ko += 1
    if ko % 2 == 1:
        ans += 1
    i += ko

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# coding = SJIS

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
pap = []

for i in range(n):
    if a[i] not in pap:
        pap.append(a[i])
    elif a[i] in pap:
        pap.remove(a[i])

print(len(pap))

Fixed submission:
# coding = SJIS

n = int(input())
a = [int(input()) for i in range(n)]
ans = 0

a.sort()

i = 0

while i < n:
    ko = 1
    while (i + ko) < n and a[i] == a[i + ko]:
        ko += 1
    if ko % 2 == 1:
        ans += 1
    i += ko

print(ans)
Buggy python submission (verdict: Runtime Error):
# coding = SJIS

a, b = map(int, input())

if a + b >= 10:
    print("error")
else:
    print(a + b)

Fixed submission:
# coding = SJIS

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

if a + b >= 10:
    print("error")
else:
    print(a + b)
Buggy python submission (verdict: Runtime Error):
# coding = SJIS

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

if a + b >= 10:
    print("error")
else:
    print(a + b)

Fixed submission:
# coding = SJIS

s = str(input())
if len(set(s)) == len(s):
    print("yes")
else:
    print("no")
Buggy python submission (verdict: Time Limit Exceeded):
# coding = SJIS

k, s = map(int, input().split())
ans = 0

for x in range(0, k + 1):
    for y in range(0, k + 1):
        for z in range(0, k + 1):
            if x + y + z == s:
                ans += 1

print(ans)

Fixed submission:
# coding = SJIS

k, s = map(int, input().split())
ans = 0

if s < k:
    ans = (s + 1) * (s + 2) / 2
elif s <= 2 * k:
    t = 2 * k - s
    a = (k + 1) * (k + 2) / 2
    b = t * (t + 1) / 2
    c = t * (2 * k - (t - 1)) / 2
    ans = a - b + c
elif s <= 3 * k:
    t = 3 * k - s + 1
    ans = t * (t + 1) / 2
print(int(ans))
Buggy python submission (verdict: Runtime Error):
    vals = [int(i) for i in input().split()]
    a = vals[0]
    b = vals[1]
    c = vals[2]
    d = vals[3]
    res2 = a//d + (1 if(a % d > 0) else 0)
    res1 = c//b + (1 if(c % b > 0) else 0)
    res = "Yes" if(res1 <= res2) else "No"
    print(res)

Fixed submission:
vals = [int(i) for i in input().split()]
a = vals[0]
b = vals[1]
c = vals[2]
d = vals[3]
res2 = a//d + (1 if(a % d > 0) else 0)
res1 = c//b + (1 if(c % b > 0) else 0)
res = "Yes" if(res1 <= res2) else "No"
print(res)

Buggy python submission (verdict: Runtime Error):
    vals = [int(i) for i in input().split()]
    a = vals[0]
    b = vals[1]
    c = vals[2]
    d = vals[3]
    res2 = a//d + (1 if(a % d > 0) else 0)
    res1 = c//b + (1 if(c % b) > 0 else 0)
    res = "Yes" if(res1 <= res2) else "No"
    print(res)

Fixed submission:
vals = [int(i) for i in input().split()]
a = vals[0]
b = vals[1]
c = vals[2]
d = vals[3]
res2 = a//d + (1 if(a % d > 0) else 0)
res1 = c//b + (1 if(c % b > 0) else 0)
res = "Yes" if(res1 <= res2) else "No"
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
import math
nums = [int(i) for i in input().split()]
n = nums[0]
x = nums[1]
y = nums[2]
res = {}
for i in range(1, n):
    res[i] = 0
for i in range(1, n+1):
    for j in range(i+1, n+1):
        dis = j - i
        disI = min(abs(i-x), abs(i-y))
        disJ = min(abs(j-x), abs(j-y))
        dis = min(dis, disI+disJ+1)
        res[dis] += 1
for i in range(1, n):
    print(res[i])


Fixed submission:
import math
nums = [int(i) for i in input().split()]
n = nums[0]
x = nums[1]
y = nums[2]
res = [0 for i in range(2010)]

for i in range(1, n+1):
    for j in range(i+1, n+1):
        dis = j - i
        dis = min(dis, abs(i-x)+abs(j-y)+1)
        res[dis] += 1
for i in range(1, n):
    print(res[i])
Buggy python submission (verdict: Runtime Error):
import math
if(math.ceil(a/d)>=math.ceil(c/b)):
    print("Yes")
else:
    print("No")

Fixed submission:
a, b, c, d = map(int, input().split())
if ((a + d - 1) // d) >= ((c + b - 1) // b):
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
A,B,C,D=input().split()
num = 0
while(int(A)>=0 and int(C)>=0):
    if int(A)<= 100 and 0 <= int(B)<= 100 and int(C)<= 100 and 0 <= int(D)<= 100:
        if num %2 ==0:
            C = int(C)-int(B)
            if int(C)<=0:
                print("Yes")
                break
            num += 1
        elif num %2 !=0:
            A = int(A)-int(D)
            if int(A)<=0:
                print("No")
                break
            num += 1
    else:
        break


Fixed submission:
S,W = input().split()

if 0 <= int(S) <= 100 and 0 <= int(W) <= 100:
    if int(S) <= int(W):
        print("unsafe")
    else:
        print("safe")
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(x,y):
  while (y):
    x, y = y, x%y
  return x

def tgcd(x,y,z):
  return gcd(x,gcd(y,z))

a = int(input())
s = 0
for i in range(1,a+1):
  for j in range(1,a+1):
    for k in range(1,a+1):
      s+=tgcd(i,j,k)
print(s)


Fixed submission:
l=[1,9,30,76,141,267,400,624,885,1249,1590,2208,2689,3411,4248,5248,6081,7485,8530,10248,11889,13687,15228,17988,20053,22569,25242,28588,31053,35463,38284,42540,46581,50893,55362,61824,65857,71247,76884,84388,89349,97881,103342,111528,120141,128047,134580,146316,154177,164817,174438,185836,194157,207927,218812,233268,245277,257857,268182,288216,299257,313635,330204,347836,362973,383709,397042,416448,434025,456967,471948,499740,515581,536073,559758,583960,604833,633651,652216,683712,709065,734233,754734,793188,818917,846603,874512,909496,933081,977145,1006126,1041504,1073385,1106467,1138536,1187112,1215145,1255101,1295142,1342852,1373253,1422195,1453816,1502376,1553361,1595437,1629570,1691292,1726717,1782111,1827492,1887772,1925853,1986837,2033674,2089776,2145333,2197483,2246640,2332104,2379085,2434833,2490534,2554600,2609625,2693919,2742052,2813988,2875245,2952085,3003306,3096024,3157249,3224511,3306240,3388576,3444609,3533637,3591322,3693924,3767085,3842623,3912324,4027884,4102093,4181949,4270422,4361548,4427853,4548003,4616104,4718640,4812789,4918561,5003286,5131848,5205481,5299011,5392008,5521384,5610705,5739009,5818390,5930196,6052893,6156139,6239472,6402720,6493681,6623853,6741078,6864016,6953457,7094451,7215016,7359936,7475145,7593865,7689630,7886244,7984165,8130747,8253888,8403448,8523897,8684853,8802826,8949612,9105537,9267595,9376656,9574704,9686065,9827097,9997134,10174780,10290813,10493367,10611772,10813692]
print(l[int(input())-1])
Buggy python submission (verdict: Runtime Error):
N = int(input())
num = [0] * (2 * 10 ** 5)
A = list(map(int,input().split()))
for i in range(len(A)):
	num[A[i]] += 1
for i in range(1,N + 1):
	print(num[i])

Fixed submission:
N = int(input())
num = [0] * (3 * 10 ** 5)
A = list(map(int,input().split()))
for i in range(len(A)):
	num[A[i]] += 1
for i in range(1,N + 1):
	print(num[i])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
for i in range(1,N + 1):
	print(A.count(i))

Fixed submission:
N = int(input())
num = [0] * (3 * 10 ** 5)
A = list(map(int,input().split()))
for i in range(len(A)):
	num[A[i]] += 1
for i in range(1,N + 1):
	print(num[i])
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
P = list(map(int,input().split()))
ans = 0
n_max = 0
place = 0
for i in range(N - K + 1):
	n_max = max(n_max , sum(P[i:i+K]))
	if n_max == sum(P[i:i+K]):
		place = i
for i in range(place,place + K):
	ans += (1 + P[i]) /2 
print(ans)

Fixed submission:
N,K = map(int,input().split())
P = list(map(int,input().split()))
ans = 0
n_max = 0
place = 0
n_sum = sum(P[:K])
for i in range(N - K):
	n_sum = n_sum - P[i] + P[i+K]
	if n_max <= n_sum:
		n_max = n_sum
		place = i + 1
for i in range(place,place + K):
	ans += (1 + P[i]) /2 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
P = list(map(int,input().split()))
ans = 0
n_max = 0
place = 0
for i in range(N - K + 1):
	n_max = max(n_max , sum(P[i:i+K]))
	if n_max == sum(P[i:i+K]):
		place = i
for i in range(place,place + K):
	semi = 0
	for j in range(P[i] + 1):
		semi += j
	ans += semi / P[i]
print(ans)

Fixed submission:
N,K = map(int,input().split())
P = list(map(int,input().split()))
ans = 0
n_max = 0
place = 0
n_sum = sum(P[:K])
for i in range(N - K):
	n_sum = n_sum - P[i] + P[i+K]
	if n_max <= n_sum:
		n_max = n_sum
		place = i + 1
for i in range(place,place + K):
	ans += (1 + P[i]) /2 
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
H = list(map(int,input().split()))
if(N<=K):
	print(0)
	exit()
H.sort(reverse=True)
for i in range(K):
	H.pop(0)
print(sum(H))

Fixed submission:
N,K = map(int,input().split())
H = list(map(int,input().split()))
if(N<=K):
	print(0)
	exit()
H.sort(reverse=True)
print(sum(H[K:]))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
num = list(map(int,input().split()))
cnt = 0
flag = False
for i in range(N):
	if(i == 0):
		cnt+=1
		continue
	sub = num[0:i]
	sub_min = min(sub)
	if (num[i] <= sub_min):
		cnt+=1
print(cnt)

Fixed submission:
N = int(input())
num = list(map(int,input().split()))
cnt = 0
flag = False
num_min = 10**8
for i in range(N):
	if(i == 0):
		cnt+=1
		continue
	num_min = min(num_min,num[i-1])
	if (num[i] <= num_min):
		cnt+=1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
num = list(map(int,input().split()))
cnt = 0
flag = False
for i in range(N):
	for j in range(i):
		if num[i] > num[j]:
			flag = True
			break
	if(flag == False):
		cnt+=1
	flag = False
print(cnt)

Fixed submission:
N = int(input())
num = list(map(int,input().split()))
cnt = 0
flag = False
num_min = 10**8
for i in range(N):
	if(i == 0):
		cnt+=1
		continue
	num_min = min(num_min,num[i-1])
	if (num[i] <= num_min):
		cnt+=1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
XL = []
flag = [0]*N
for i in range(N):
	xl = list(map(int,input().split()))
	XL.append(xl)
XL.sort()
for i in range(N-1):
	for j in range(i+1,N-i):
		if(flag[i] == 0 ):
			if(XL[i][0]+XL[i][1]>=XL[j][0]):
				flag[j]=1
			else:
				break
sum = 0
for i in range(N):
	sum+=flag[i]
print(N-sum)

Fixed submission:
N = int(input())
XL = []
for i in range(N):
	x,l = map(int,input().split())
	S = x + l
	T = x - l
	XL.append((S,T))
XL.sort()
#print(XL)

ans = 0

min = -float("inf")
for s,t in XL:
	if min <= t:
		ans+=1
		min = s
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
XL = []
flag = [0]*N
for i in range(N):
	xl = list(map(int,input().split()))
	XL.append(xl)
XL.sort()
for i in range(N-1):
	for j in range(i+1,N-i):
		if(flag[i] == 0 ):
			if(XL[i][0]+XL[i][1]>=XL[j][0]):
				flag[j]=1
sum = 0
for i in range(N):
	sum+=flag[i]
print(N-sum)

Fixed submission:
N = int(input())
XL = []
for i in range(N):
	x,l = map(int,input().split())
	S = x + l
	T = x - l
	XL.append((S,T))
XL.sort()
#print(XL)

ans = 0

min = -float("inf")
for s,t in XL:
	if min <= t:
		ans+=1
		min = s
print(ans)
Buggy python submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
if (B - A) % 2 == 0:
	print((B - A)//2))
else:
	print(min(A - 1,N - B) + 1 + (B - A - 1)//2)

Fixed submission:
N,A,B = map(int,input().split())
if (B - A) % 2 == 0:
	print((B - A)//2)
else:
	print(min(A - 1,N - B) + 1 + (B - A - 1)//2)

Buggy python submission (verdict: Runtime Error):
N,A,B = map(int,input().split())
if (B - A) % 2 == 0:
	print(B - A//2))
else:
	print(min(A - 1,N - B) + 1 + (B - A - 1)//2)

Fixed submission:
N,A,B = map(int,input().split())
if (B - A) % 2 == 0:
	print((B - A)//2)
else:
	print(min(A - 1,N - B) + 1 + (B - A - 1)//2)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(map(int,input().split()))
for i in range(N):
	print(S.index(i+1)+1 ,end=" ")

Fixed submission:
N = int(input())
num = list(map(int,input().split()))
S = {}
for i in range(N):
	S[num[i]] = i+1
S_sorted = sorted(S.items(),key=lambda x:x[0])
for i in range(N):
	print(S_sorted[i][1],end=" ")
Buggy python submission (verdict: Time Limit Exceeded):
N,K,Q = map(int,input().split())
attend = [K for i in range(N)]
A = 0
for i in range(Q):
	A = int(input())
	for j in range(N):
		if not(j == A-1):
			attend[j]-=1
for i in range(N):
	if(attend[i] <= 0):
		print("No")
	else:
		print("Yes")

Fixed submission:
N,K,Q = map(int,input().split())
attend = [K-Q for i in range(N)]
A = 0
for i in range(Q):
	A = int(input())
	attend[A-1]+=1
for i in range(N):
	if(attend[i] <= 0):
		print("No")
	else:
		print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ans = 0
for i in range(1,N ):
	ans += i
print(ans)

Fixed submission:
N = int(input())
ans = (N * (N - 1)) // 2
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ans = 0
for i in range(1,N + 1):
	if i < N:
		ans += i % (i + 1)
print(ans)

Fixed submission:
N = int(input())
ans = (N * (N - 1)) // 2
print(int(ans))
Buggy python submission (verdict: Runtime Error):
from scipy.special import comb
N = int(input())
S = []
for i in range(N):
    S.append("".join(sorted(input())))
S.sort()
C = []
cnt = 1
for i in range(N - 1):
    if S[i] == S[i + 1]:
        cnt += 1
    else:
        C.append(cnt)
        cnt = 1
C.append(cnt)
ans = 0
for cnt in C:
    ans += int(comb(cnt,2))
print(ans)

Fixed submission:
N = int(input())
S = []
for i in range(N):
    S.append("".join(sorted(input())))
S.sort()
C = []
cnt = 1
for i in range(N - 1):
    if S[i] == S[i + 1]:
        cnt += 1
    else:
        C.append(cnt)
        cnt = 1
C.append(cnt)
ans = 0
for cnt in C:
    ans += cnt * (cnt-1) // 2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
list = [int(input()) for i in range(N)]
list_max = sorted(list)
for i in range(N):
	if(list[i] == max(list)):
		print(list_max[-2])
	else:
		print(max(list))

Fixed submission:
N = int(input())
list = [int(input()) for i in range(N)]
list_max = sorted(list)
max = max(list)
for i in range(N):
	if(list[i] == max):
		print(list_max[-2])
	else:
		print(max)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
list = []
for i in range(N):
	list.append(int(input()))
for i in range(N):
	if(list[i] == max(list)):
		list_max = sorted(list)
		print(list_max[-2])
	else:
		print(max(list))

Fixed submission:
N = int(input())
list = [int(input()) for i in range(N)]
list_max = sorted(list)
max = max(list)
for i in range(N):
	if(list[i] == max):
		print(list_max[-2])
	else:
		print(max)
Buggy python submission (verdict: Runtime Error):
#from fractions import gcd
import math
A,B,C,D = map(int,input().split())
num_gcd = C*D//math.gcd(C,D)
ans_B = 0 - B//C - B//D + B//num_gcd
ans_A = 0 - (A-1)//C - (A-1)//D + (A-1)//num_gcd
ans = B - A + 1 + ans_B - ans_A
print(ans)

Fixed submission:
import fractions
A,B,C,D = map(int,input().split())
num_gcd = C*D//fractions.gcd(C,D)
ans_B = 0 - B//C - B//D + B//num_gcd
ans_A = 0 - (A-1)//C - (A-1)//D + (A-1)//num_gcd
ans = B - A + 1 + ans_B - ans_A
print(ans)