Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list()
for x in range(n):
    a.append(int(input()))

for x in range(n):
    tmp = a.pop(x)
    print(max(a))
    a.insert(x, tmp)


Fixed submission:
n = int(input())
a = list()
for x in range(n):
    a.append(int(input()))

copy_a = sorted(a, reverse=True)

A_Max = copy_a[0]
A_Second = copy_a[1]

for x in range(n):
    if a[x] == A_Max:
        print(A_Second)
    else:
        print(A_Max)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list()
for x in range(n):
    a.append(int(input()))

for x in range(n):
    ans = a[:x] + a[x+1:]
    print(max(ans))


Fixed submission:
n = int(input())
a = list()
for x in range(n):
    a.append(int(input()))

copy_a = sorted(a, reverse=True)

A_Max = copy_a[0]
A_Second = copy_a[1]

for x in range(n):
    if a[x] == A_Max:
        print(A_Second)
    else:
        print(A_Max)
Buggy python submission (verdict: Runtime Error):
S = input()

length = 0
chain = -1
ans = []

for a in S:
    if a == 'A' or a == 'C' or a == 'G' or a == 'T':
        length += 1
        chain = 1
        continue
    else:
        chain = -1
        ans.append(length)
        length = 0

print(max(ans))


Fixed submission:
S = input()

N = len(S)
T = ['A', 'C', 'G', 'T']
ans = 0
now = 0

for a in S:
    isATCG = False
    if a in T:
        isATCG = True

    if isATCG:
        now += 1
        ans = max(ans, now)
    else:
        now = 0
        isATCG = False

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


def gcd(a, b):
    x = max(a, b)
    y = min(a, b)
    mod = x % y
    if mod == 0:
        return y

    return gcd(y, mod)


mx = gcd(A, B)
count = 0
for a in range(mx, 1, -1):
    print(a)
    if A % a == 0 and B % a == 0:
        count += 1
    if count == K:
        ans = a
        break
print(ans)


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


def gcd(a, b):
    x = max(a, b)
    y = min(a, b)
    mod = x % y
    if mod == 0:
        return y

    return gcd(y, mod)


mx = gcd(A, B)
count = 0

for a in range(mx, 0, -1):
    if A % a == 0 and B % a == 0:
        count += 1
    if count == K:
        ans = a
        break

print(ans)

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


def gcd(a, b):
    x = max(a, b)
    y = min(a, b)
    mod = x % y
    if mod == 0:
        return y

    return gcd(y, mod)


mx = gcd(A, B)
count = 0
for a in range(mx+1, 1, -1):
    if A % a == 0 and B % a == 0:
        count += 1
    if count == K:
        ans = a
        break
print(ans)


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


def gcd(a, b):
    x = max(a, b)
    y = min(a, b)
    mod = x % y
    if mod == 0:
        return y

    return gcd(y, mod)


mx = gcd(A, B)
count = 0

for a in range(mx, 0, -1):
    if A % a == 0 and B % a == 0:
        count += 1
    if count == K:
        ans = a
        break

print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().split())

num_list = list(range(a, b+1))

length = len(num_list)

for x in range(0, min(length, k)):
    print(num_list[x])

for x in range(max(k, length-k+1), length):
    print(num_list[x])


Fixed submission:
a, b, k = map(int, input().split())

for x in range(a, min(b+1, a+k)):
    print(x)

for x in range(max(a+k, b-k+1), b+1):
    print(x)

Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().split())

num_list = list(range(a, b+1))

length = len(num_list)

for x in range(0, min(length, k)):
    print(num_list[x])

for x in range(max(0, length-k), length):
    print(num_list[x])


Fixed submission:
a, b, k = map(int, input().split())

for x in range(a, min(b+1, a+k)):
    print(x)

for x in range(max(a+k, b-k+1), b+1):
    print(x)

Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().split())

num_list = list(range(a, b+1))

length = len(num_list)

for x in range(min(length, k)):
    print(num_list[x])

for x in range(max(k, length-k), length):
    print(num_list[x])


Fixed submission:
a, b, k = map(int, input().split())

for x in range(a, min(b+1, a+k)):
    print(x)

for x in range(max(a+k, b-k+1), b+1):
    print(x)

Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().split())

num_list = list(range(a, b+1))

length = len(num_list)

for x in range(min(length, k)):
    print(num_list[x])

for x in range(max(k, length-k+1), length):
    print(num_list[x])


Fixed submission:
a, b, k = map(int, input().split())

for x in range(a, min(b+1, a+k)):
    print(x)

for x in range(max(a+k, b-k+1), b+1):
    print(x)

Buggy python submission (verdict: Runtime Error):
a, b, k = map(int, input().split())

num_list = list(range(a, b+1))

length = len(num_list)

for x in range(min(length, k)):
    print(num_list[x])

for x in range(max(k, length-k), length):
    print(num_list[x])


Fixed submission:
a, b, k = map(int, input().split())

for x in range(a, min(b+1, a+k)):
    print(x)

for x in range(max(a+k, b-k+1), b+1):
    print(x)
Buggy python submission (verdict: Runtime Error):
n = int(input())
s = list()

for a in range(n):
    s.append(input())

t = list()
m = int(input())

for a in range(m):
    t.append(input())

kind = list(set(s))
kind_length = len(kind)

counter = dict()
for a in range(kind_length):
    counter[kind[a]] = 0

for a in range(n):
    counter[s[a]] += 1

for a in range(m):
    if t[a] not in counter:
        continue
    counter[t[a]] -= 1

print(max(counter.values(), 0))


Fixed submission:
n = int(input())
s = list()

for a in range(n):
    s.append(input())

t = list()
m = int(input())

for a in range(m):
    t.append(input())

kind = list(set(s))
kind_length = len(kind)

counter = dict()
for a in range(kind_length):
    counter[kind[a]] = 0

for a in range(n):
    counter[s[a]] += 1

for a in range(m):
    if t[a] not in counter:
        continue
    counter[t[a]] -= 1

print(max(max(counter.values()), 0))

Buggy python submission (verdict: Runtime Error):
n = int(input())
s = list()

for a in range(n):
    s.append(input())

t = list()
m = int(input())

for a in range(m):
    t.append(input())

kind = list(set(s))
kind_length = len(kind)

counter = dict()
for a in range(kind_length):
    counter[kind[a]] = 0

for a in range(n):
    counter[s[a]] += 1

for a in range(m):
    if t[a] not in counter:
        continue
    counter[t[a]] -= 1

print(max(counter.values(), 0))


Fixed submission:
n = int(input())
s = list()

for a in range(n):
    s.append(input())

t = list()
m = int(input())

for a in range(m):
    t.append(input())

kind = list(set(s))
kind_length = len(kind)

counter = dict()
for a in range(kind_length):
    counter[kind[a]] = 0

for a in range(n):
    counter[s[a]] += 1

for a in range(m):
    if t[a] not in counter:
        continue
    counter[t[a]] -= 1

print(max(max(counter.values()), 0))
Buggy python submission (verdict: Runtime Error):
n = int(input())

t_list = list()
x_list = list()
y_list = list()

for a in range(n):
    t, x, y = map(int, input().split())
    t_list.append(t)
    x_list.append(x)
    y_list.append(y)

for a in range(1, n):
    dt = t_list[a] - t_list[a-1]
    dx = x_list[a] - x_list[a-1]
    dy = y_list[a] - y_list[a-1]

    if abs(dx) + abs(dy) <= dt:
        if (dx + dy) % 2 == dt % 2:
            ans = True
        else:
            ans = False
            break
    else:
        ans = False
        break

if ans:
    print('Yes')
else:
    print('No')

Fixed submission:
n = int(input())

t_list = [0]
x_list = [0]
y_list = [0]

for a in range(n):
    t, x, y = map(int, input().split())
    t_list.append(t)
    x_list.append(x)
    y_list.append(y)

for a in range(1, n+1):
    dt = t_list[a] - t_list[a-1]
    dx = x_list[a] - x_list[a-1]
    dy = y_list[a] - y_list[a-1]

    if abs(dx) + abs(dy) <= dt:
        if (dx + dy) % 2 == dt % 2:
            ans = True
        else:
            ans = False
            break
    else:
        ans = False
        break

if ans:
    print('Yes')
else:
    print('No')

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

t_list = list()
x_list = list()
y_list = list()

for a in range(n):
    t, x, y = map(int, input().split())
    t_list.append(t)
    x_list.append(x)
    y_list.append(y)

for a in range(1, n):
    dt = t_list[a] - t_list[a-1]
    dx = x_list[a] - x_list[a-1]
    dy = y_list[a] - y_list[a-1]

    if abs(dx) + abs(dy) <= dt:
        if (dx + dy) % 2 == dt % 2:
            ans = True
        else:
            ans = False
            break
    else:
        ans = False
        break

if ans:
    print('Yes')
else:
    print('No')


Fixed submission:
n = int(input())

t_list = [0]
x_list = [0]
y_list = [0]

for a in range(n):
    t, x, y = map(int, input().split())
    t_list.append(t)
    x_list.append(x)
    y_list.append(y)

for a in range(1, n+1):
    dt = t_list[a] - t_list[a-1]
    dx = x_list[a] - x_list[a-1]
    dy = y_list[a] - y_list[a-1]

    if abs(dx) + abs(dy) <= dt:
        if (dx + dy) % 2 == dt % 2:
            ans = True
        else:
            ans = False
            break
    else:
        ans = False
        break

if ans:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))

count = [0] * n

for x in range(n):
    count[a[x]-1] += 1

count.sort()
length = len(count)

for x in range(length):
    if len(count[x:]) == k:
        break

print(sum(count[:x]))


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

count = [0] * n

for x in range(n):
    count[a[x]-1] += 1

count.sort()
length = len(count)

print(sum(count[:length - k]))

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = list(map(int, input().split()))

count = [0] * n

for x in range(n):
    count[a[x]-1] += 1

count.sort()
length = len(count)

for x in range(length):
    if len(count[x:]) == k:
        break

print(sum(count[:x]))


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

count = [0] * n

for x in range(n):
    count[a[x]-1] += 1

count.sort()
length = len(count)

print(sum(count[:length - k]))
Buggy python submission (verdict: Runtime Error):
N,A,B - map(int,input().split())

print(min(N*A,B))

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

print(min(N*A,B))
Buggy python submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())

print(max(min(b, d) - max(a, c)), 0)


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

print(max(min(b, d) - max(a, c), 0))
Buggy python submission (verdict: Runtime Error):
a, b, c = input().split()

if b-a == c - b:
    print('YES')
else:
    print('NO')


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

if b - a == c - b:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())

student = list()

for x in range(n):
    student.append(list(map(int, input().split())))

checkpoint = list()

for y in range(m):
    checkpoint.append(list(map(int, input().split())))

tmp = 10**8+1

for x in range(n):
    for y in range(m-1, -1, -1):
        distance = abs(student[x][0] - checkpoint[y][0]) + \
            abs(student[x][1] - checkpoint[y][1])
        if tmp >= distance:
            tmp = distance
            ans = y
    print(ans+1)


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

student = list()

for x in range(n):
    student.append(list(map(int, input().split())))

checkpoint = list()

for y in range(m):
    checkpoint.append(list(map(int, input().split())))

INF = 4*(10**8) + 1
tmp = INF
ans = 51

for x in range(n):
    for y in range(m-1, -1, -1):
        distance = abs(student[x][0] - checkpoint[y][0]) + \
            abs(student[x][1] - checkpoint[y][1])

        if tmp >= distance:
            tmp = distance
            ans = y
    print(ans+1)
    tmp = INF
Buggy python submission (verdict: Runtime Error):
w, a, b = map(int, input().split())

if a <= b and b <= a + w:
    print(0)
elif a <= b + w and b + w <= a + w
elif b+w < a:
    print(a - (b+w))
elif a+w < b:
    print(b - (a+w))


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

if a <= b and b <= a + w:
    print(0)
elif a <= b + w and b + w <= a + w:
    print(0)
elif b+w < a:
    print(a - (b+w))
elif a+w < b:
    print(b - (a+w))
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())

ans = 0

for a in range(0, k+1):
    for b in range(0, k+1):
        for c in range(0, k+1):
            if a+b+c == s:
                ans += 1

print(ans)


Fixed submission:
k, s = map(int, input().split())

ans = 0

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

print(ans)
Buggy python submission (verdict: Runtime Error):
A, op, B = input().split()

if op == '+':
    print(A+B)
else:
    print(A-B)


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

A = int(A)
B = int(B)

if op == '+':
    print(A+B)
else:
    print(A-B)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()

length = len(s)
t = ''
word = ''

for a in range(length-1, -1, -1):
    t += s[a]
    reverse_t = t[::-1]
    if reverse_t == 'dream' or reverse_t == 'dreamer' or reverse_t == 'erase' or reverse_t == 'eraser':
        word = reverse_t + word
        t = ''

if s == word:
    print('YES')
else:
    print('NO')


Fixed submission:
s = input()

length = len(s)
t = ''
word = ''

for a in range(length-1, -1, -1):
    t += s[a]
    if t == 'maerd' or t == 'remaerd' or t == 'esare' or t == 'resare':
        word += t
        t = ''

if s == word[::-1]:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
SA = list(input())
SB = list(input())
SC = list(input())

LenSA = len(SA)
LenSB = len(SB)
LenSC = len(SC)

NowCard = SA.pop()

while True:
    if NowCard == 'a':
        NowList = SA
    elif NowCard == 'b':
        NowList = SB
    elif NowCard == 'c':
        NowList = SC

    NowCard = NowList.pop()

    if SA == [] or SB == [] or SC == []:
        break

if SA == []:
    print('A')
if SB == []:
    print('B')
if SC == []:
    print('C')


Fixed submission:
from collections import deque

SA = deque(input())
SB = deque(input())
SC = deque(input())

NowCard = SA.popleft()
ans = 'A'

while True:
    if NowCard == 'a':
        NowList = SA
        ans = 'A'
    elif NowCard == 'b':
        NowList = SB
        ans = 'B'
    elif NowCard == 'c':
        NowList = SC
        ans = 'C'

    if len(NowList) == 0:
        break

    NowCard = NowList.popleft()

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
import math


A, B, N = MAP()


def f(x, A, B):
    return math.floor(A * x / B) - A * math.floor(x / B)


x = 0
flag = 0
while True:
    if f(x, A, B) > 0:
        flag = 1
    if f(x, A, B) == 0:
        y = x - 1
        if flag == 1:
            break
    x += 1

if N < y:
    print(f(N, A, B))
else:
    print(f(y, A, B))


Fixed submission:
import sys
import numpy as np
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
import math


A, B, N = MAP()


def f(x, A, B):
    return math.floor(A * x / B) - A * math.floor(x / B)


if N < B - 1:
    print(f(N, A, B))
else:
    print(f(B - 1, A, B))
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import numpy as np
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def combinations_count(n, r):
    if n - r < 0:
        return 0
    else:
        return factorial(n) // (factorial(n - r) * factorial(r))


N = INT()
A = LIST()

ans = 0

C = Counter(A)
for i in list(C.values()):
    ans += combinations_count(i, 2)

for i in range(N):
    tmp = ans - combinations_count(C[A[i]], 2) + combinations_count(C[A[i]] - 1, 2)
    print(tmp)


Fixed submission:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()

A_c = Counter(A)

A_c_c = 0
for i in A_c.values():
    A_c_c += i*(i-1)//2

for k in range(N):
    ans = A_c_c - (A_c[A[k]] - 1)
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
from sys import stdin


def main():
    # コンソール入力を受け取る
    N = int(stdin.readline().rstrip())
    P = stdin.readline().rstrip().split()
    P = [int(i) for i in P]

    ans = 0
    for i in range(N):
        for j in range(i+1):
            if P[i] > P[j]:
                break
            if i == j:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
# coding: utf-8
from sys import stdin


def main():
    # コンソール入力を受け取る
    N = int(stdin.readline().rstrip())
    P = stdin.readline().rstrip().split()
    P = [int(i) for i in P]

    ans = 1
    min = P[0]
    for i in range(N-1):
        if P[i+1] < min:
            ans += 1
            min = P[i+1]
    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b = map(int, input().split())
print(a * b // gcd(a, b))


Fixed submission:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B = MAP()

def euclid(a, b):
    if a < b:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b

print(A * B // euclid(A, B))
Buggy python submission (verdict: Runtime Error):
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = [_ for _ in input()]

left_w = 0
right_e = S[1:].count('E')
min_sum = left_w + right_e

for i in range(N-1):
    if S[i] == 'W':
        left_w -= 1
    if S[i+1] == 'E':
        right_e += 1
    if min_sum < left_w + right_e:
        min_sum = left_w + right_e
        ans = i
print(ans)


Fixed submission:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = [_ for _ in input()]

left, right = 0, S[1:].count('E')
ans = left + right
for i in range(N-1):
    if S[i] == 'W':
        left += 1
    if S[i+1] == 'E':
        right -= 1

    ans = min(ans, left + right)

print(ans)