Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
res=0
ans=1
while res<n:
  res+=1
  ans*=res
  
print(ans%(10**9+7))

Fixed submission:
n = int(input())

pw = 1
num = 1
for i in range(n):
  pw = pw*num % (10**9+7)
  num += 1
  
print(pw)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
res=1
for i in range(1,n+1):
  res*=i
print(res%(10**9+7))

Fixed submission:
n = int(input())

pw = 1
num = 1
for i in range(n):
  pw = pw*num % (10**9+7)
  num += 1
  
print(pw)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

p = 1
for i in range(1, n+1):
  p *= i
print(p % (10**9 + 7))

Fixed submission:
n = int(input())

pw = 1
num = 1
for i in range(n):
  pw = pw*num % (10**9+7)
  num += 1
  
print(pw)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

pw = 1
num = 1
for i in range(n):
  pw = pw  * num
  num += 1
  
print(pw % (10**9+7))

Fixed submission:
n = int(input())

pw = 1
num = 1
for i in range(n):
  pw = pw*num % (10**9+7)
  num += 1
  
print(pw)
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())

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

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

ans = 0

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

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

ans = 0
for i in range(k+1):
  for j in range(k+1):
    for l in range(k+1):
      if i+j+l==s:
        ans += 1
        
print(ans)

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

ans = 0

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

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

ans = 0

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

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

ans = 0

for x in range(k+1):
  for y in range(k+1):
      if s-x-y <= k and s-x-y>=0:
        ans += 1
        
print(ans)
Buggy python submission (verdict: Runtime Error):
print(n-m)

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

n = b // x
m = (a-1) // x

print(n-m)
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
  for j in range(n):
    if a[i]==j+1 and a[j]==i+1:
      ans+=1
print(ans//2)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n):
  if a[a[i]-1]==i+1:
    ans+=1
print(ans//2)
Buggy python submission (verdict: Runtime Error):
N, L = map(int, input().split())
S = [input() for i in range(N)]
s = sorted(S)
print(*s, sep='')

Fixed submission:
A,B,C = map(int, input().split())
if A==5 and B==5 and C==7:
  print("YES")
elif A==5 and B==7 and C==5:
  print("YES")
elif A==7 and B==5 and C==5:
  print("YES")
else:
  print("NO")

Buggy python submission (verdict: Runtime Error):
N, L = map(int, input().split())
P = [input().split() for i in range(L)]

p = sorted(P)
ppp = "".join(map(str, p))
print(ppp)

Fixed submission:
A,B,C = map(int, input().split())
if A==5 and B==5 and C==7:
  print("YES")
elif A==5 and B==7 and C==5:
  print("YES")
elif A==7 and B==5 and C==5:
  print("YES")
else:
  print("NO")

Buggy python submission (verdict: Runtime Error):
A, B, C = int(input())
if A == 5 and B == 5 and C == 7:
  print("YES")
elif A == 5 and B == 7 and C == 5:
  print("YES")
elif A == 7 and B == 5 and C == 5:
  print("YES")
else:
  print("NO")

Fixed submission:
A,B,C = map(int, input().split())
if A==5 and B==5 and C==7:
  print("YES")
elif A==5 and B==7 and C==5:
  print("YES")
elif A==7 and B==5 and C==5:
  print("YES")
else:
  print("NO")

Buggy python submission (verdict: Runtime Error):
if A==5 and B==5 and C==7
  or A==5 and B==7 and C==5
  or A==7 and B==5 and C==5;
  print("YES");
else;
  print("NO");
end

Fixed submission:
A,B,C = map(int, input().split())
if A==5 and B==5 and C==7:
  print("YES")
elif A==5 and B==7 and C==5:
  print("YES")
elif A==7 and B==5 and C==5:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
N, L = map(int, input().split())
S = [input() for i in range(L)]
s = sorted(S)
print(*s, sep='')

Fixed submission:
N, L = map(int, input().split())
S = [input() for i in range(N)]
s = sorted(S)
print(*s, sep='')

Buggy python submission (verdict: Runtime Error):
N, L = map(int, input().split())
S = [input() for i in range(L)]
s = sorted(S)
print(*s, sep='')


Fixed submission:
N, L = map(int, input().split())
S = [input() for i in range(N)]
s = sorted(S)
print(*s, sep='')

Buggy python submission (verdict: Runtime Error):
L = int(input())
print(*sorted(input() for i in range(L)), sep='')


Fixed submission:
N, L = map(int, input().split())
S = [input() for i in range(N)]
s = sorted(S)
print(*s, sep='')

Buggy python submission (verdict: Runtime Error):
N, L = map(int, input().split())
print(*sorted(input() for i in range(L)))

Fixed submission:
N, L = map(int, input().split())
S = [input() for i in range(N)]
s = sorted(S)
print(*s, sep='')

Buggy python submission (verdict: Runtime Error):
N, L = map(int, input().split())
print(*sorted(input() for i in range(L)), sep='')

Fixed submission:
N, L = map(int, input().split())
S = [input() for i in range(N)]
s = sorted(S)
print(*s, sep='')

Buggy python submission (verdict: Runtime Error):
N, L = map(int, input().split())
S = [input().split() for i in range(L)]

s = sorted(S)
print(*s)

Fixed submission:
N, L = map(int, input().split())
S = [input() for i in range(N)]
s = sorted(S)
print(*s, sep='')

Buggy python submission (verdict: Runtime Error):
N, L = map(int, input().split())
S = [input().rstrip() for i in range(L)]

print(sorted(S))

Fixed submission:
N, L = map(int, input().split())
S = [input() for i in range(N)]
s = sorted(S)
print(*s, sep='')

Buggy python submission (verdict: Runtime Error):
N, L = map(int, input().split())
S = [input().split() for i in range(L)]

P = []
s = sorted(S)
for q in s:
  P.append(q)

print(P)

Fixed submission:
N, L = map(int, input().split())
S = [input() for i in range(N)]
s = sorted(S)
print(*s, sep='')

Buggy python submission (verdict: Runtime Error):
N, L = map(int, input().split())
P = [input().split() for i in range(L)]

p = sorted(P)
ppp = "".join(map(str, p))
print(ppp)

Fixed submission:
N, L = map(int, input().split())
S = [input() for i in range(N)]
s = sorted(S)
print(*s, sep='')

Buggy python submission (verdict: Runtime Error):
N, L = map(int, input().split())
P = [input().split() for i in range(L)]

p = sorted(P)
print(p[0] + p[1] + p[2])

Fixed submission:
N, L = map(int, input().split())
S = [input() for i in range(N)]
s = sorted(S)
print(*s, sep='')
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
from fractions import gcd
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

# input = sys.stdin.readline


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


def check(n, ans):
    for v in n:
        if v in ans and v != 1:
            return False

    return True


def main():
    a, b = map(int, input().split())

    ans = []

    nums = make_divisors(gcd(a, b))
    nums.sort()

    for n in nums:
        if check(make_divisors(n), ans):
            ans.append(n)

    print(len(ans))


if __name__ == '__main__':
    main()

Fixed submission:
import sys
import math
from fractions import gcd
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

# input = sys.stdin.readline


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


def check(n, ans):
    for v in n:
        if v in ans and v != 1:
            return False

    return True


def main():
    a, b = map(int, input().split())

    ans = []

    nums = make_divisors(gcd(a, b))
    nums.sort()

    for n in nums:
        if check(make_divisors(n), ans):
            ans.append(n)

    print(len(ans))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

# input = sys.stdin.readline


def main():
    n, k, q = map(int, input().split())

    winners = []
    for w in range(q):
        winners.append(int(input()))

    score = [k] * n

    for w in winners:
        winner = w - 1

        for i in range(len(score)):
            score[i] -= 1

        score[winner] += 1

    for s in score:
        if s > 0:
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    main()

Fixed submission:
import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

# input = sys.stdin.readline


def main():
    n, k, q = map(int, input().split())

    winners = []
    for w in range(q):
        winners.append(int(input()))

    score = [k - q] * n

    for w in winners:
        winner = w - 1

        score[winner] += 1

    for s in score:
        if s > 0:
            print('Yes')
        else:
            print('No')


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

# input = sys.stdin.readline


def main():
    N = int(input())
    Ps = list(map(int, input().split()))

    count = 0

    ans = []

    for i in range(len(Ps) - 1):
        if Ps[i] >= Ps[i+1]:
            count += 1
        else:
            ans.append(count)
            count = 0

        if i == len(Ps) - 2:
            ans.append(count)

    print(max(ans))


if __name__ == '__main__':
    main()

Fixed submission:
import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

# input = sys.stdin.readline


def main():
    N = int(input())
    Ps = list(map(int, input().split()))

    count = 0

    ans = [0]

    for i in range(len(Ps) - 1):
        if Ps[i] >= Ps[i+1]:
            count += 1
        else:
            ans.append(count)
            count = 0

        if i == len(Ps) - 2:
            ans.append(count)

    print(max(ans))


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

# input = sys.stdin.readline


def main():
    N = int(input())
    Ps = list(map(int, input().split()))

    count = 0

    ans = []

    for i in range(len(Ps) - 1):
        if Ps[i] >= Ps[i+1]:
            count += 1
        else:
            ans.append(count)
            count = 0

        if i == len(Ps) - 2:
            ans.append(count)

    print(max(ans))


if __name__ == '__main__':
    main()


Fixed submission:
import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

# input = sys.stdin.readline


def main():
    N = int(input())
    Ps = list(map(int, input().split()))

    count = 0

    ans = [0]

    for i in range(len(Ps) - 1):
        if Ps[i] >= Ps[i+1]:
            count += 1
        else:
            ans.append(count)
            count = 0

        if i == len(Ps) - 2:
            ans.append(count)

    print(max(ans))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

# input = sys.stdin.readline


def main():
    n = int(input())

    ans = 0

    for i in range(1, n):
        ans += i

    print(ans)


if __name__ == '__main__':
    main()

Fixed submission:
import sys
import math
from copy import deepcopy
from collections import deque, defaultdict
from operator import mul
from functools import reduce
sys.setrecursionlimit(20000000)

# input = sys.stdin.readline


def main():
    n = int(input()) - 1
    ans = 0

    if n % 2:
        print((1 + n) * (n // 2) + (n // 2 + 1))

    else:
        print((1 + n) * (n // 2))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
sys.setrecursionlimit(20000000)
input = sys.stdin.readline


def main():
    n, limit = map(int, input().split())
    jobs = [list(map(int, input().split())) for _ in range(n)]

    for j in jobs:
        j.append(True)

    money = 0

    for d in range(1, limit+1):
        available_jobs = []

        for j in jobs:
            if j[0] <= d:
                available_jobs.append(j)
        
        if available_jobs:
            available_jobs.sort(key=lambda x: x[1], reverse=True)
            for aj in available_jobs:
                if aj[2]:
                    money += aj[1]
                    aj[2] = False
                    break

    print(money)


if __name__ == '__main__':
    main()



Fixed submission:
import sys
from collections import deque, defaultdict
from heapq import heappop, heappush
sys.setrecursionlimit(20000000)
input = sys.stdin.readline


def main():
    n, limit = map(int, input().split())
    
    jobs = defaultdict(deque)

    for _ in range(n):
        d, v = map(int, input().split())
        jobs[d].append(v)

    money = 0
    available_jobs = []

    for d in range(1, limit+1):
        if d in jobs:
            for j in jobs[d]:
                heappush(available_jobs, -j)

        if available_jobs:
            money += -heappop(available_jobs)

    print(money)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
sys.setrecursionlimit(20000000)
input = sys.stdin.readline


def main():
    n, limit = map(int, input().split())
    jobs = [list(map(int, input().split())) for _ in range(n)]

    for j in jobs:
        j.append(True)
        j.append(True)

    money = 0

    available_jobs = []

    for d in range(1, limit+1):

        for j in jobs:
            if j[0] <= d and j[3]:
                available_jobs.append(j)
                j[3] = False

        if available_jobs:
            available_jobs.sort(key=lambda x: x[1], reverse=True)
            for aj in available_jobs:
                if aj[2]:
                    money += aj[1]
                    aj[2] = False
                    break

    print(money)


if __name__ == '__main__':
    main()



Fixed submission:
import sys
from collections import deque, defaultdict
from heapq import heappop, heappush
sys.setrecursionlimit(20000000)
input = sys.stdin.readline


def main():
    n, limit = map(int, input().split())
    
    jobs = defaultdict(deque)

    for _ in range(n):
        d, v = map(int, input().split())
        jobs[d].append(v)

    money = 0
    available_jobs = []

    for d in range(1, limit+1):
        if d in jobs:
            for j in jobs[d]:
                heappush(available_jobs, -j)

        if available_jobs:
            money += -heappop(available_jobs)

    print(money)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
from collections import deque
sys.setrecursionlimit(20000000)
input = sys.stdin.readline


# def main():
#     n = int(input())
#
#     nums = list(map(int, input().split()))
#
#     ans = 'Yes'
#
#     for x in reversed(range(1, len(nums))):
#         if nums[x-1] - nums[x] >= 2:
#             ans = 'No'
#
#         elif nums[x-1] - nums[x] == 1:
#             nums[x-1] -= 1
#
#         else:
#             continue
#
#     print(ans)
#
#
# if __name__ == '__main__':
#     main()


def main():
    n = int(input())

    nums = list(map(int, input().split()))

    for x in reversed(range(1, len(nums))):
        if nums[x-1] > nums[x]:
            nums[x-1] -= 1

        if nums[x-1] > nums[x]:
            print('No')
            os.exit()

    print('Yes')


if __name__ == '__main__':
    main()

Fixed submission:
import sys
from collections import deque
sys.setrecursionlimit(20000000)
input = sys.stdin.readline


def main():
    n = int(input())

    nums = list(map(int, input().split()))

    ans = 'Yes'

    for x in reversed(range(1, len(nums))):
        if nums[x-1] - nums[x] >= 2:
            ans = 'No'

        elif nums[x-1] - nums[x] == 1:
            nums[x-1] -= 1

        else:
            continue

    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
from copy import deepcopy
from collections import deque
sys.setrecursionlimit(20000000)


def main():
    N = int(input())
    nums = [int(input()) for _ in range(N)]

    for i in range(len(nums)):
        tmp = nums[i]
        nums[i] = 0
    
        print(max(nums))
        
        nums[i] = tmp


if __name__ == '__main__':
    main()



Fixed submission:
import sys
import math
from copy import deepcopy
from collections import deque
sys.setrecursionlimit(20000000)


def main():
    N = int(input())
    nums = [int(input()) for _ in range(N)]
    a = deepcopy(nums)
    a.sort(reverse=True)

    for i in range(len(nums)):
        if a[0] == nums[i]:
            print(a[1])
        else:
            print(a[0])


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
from copy import deepcopy
from collections import deque
sys.setrecursionlimit(20000000)


def main():
    N = int(input())
    nums = [int(input()) for _ in range(N)]

    for i in range(len(nums)):
        t = deepcopy(nums)
        t.pop(i)

        print(max(t))


if __name__ == '__main__':
    main()



Fixed submission:
import sys
import math
from copy import deepcopy
from collections import deque
sys.setrecursionlimit(20000000)


def main():
    N = int(input())
    nums = [int(input()) for _ in range(N)]
    a = deepcopy(nums)
    a.sort(reverse=True)

    for i in range(len(nums)):
        if a[0] == nums[i]:
            print(a[1])
        else:
            print(a[0])


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
from copy import deepcopy
from collections import deque
sys.setrecursionlimit(20000000)


def main():
    N = int(input())
    nums = [int(input()) for _ in range(N)]

    for i in range(len(nums)):
        t = deepcopy(nums)
        t.pop(i)

        print(max(t))


if __name__ == '__main__':
    main()



Fixed submission:
import sys
import math
from copy import deepcopy
from collections import deque
sys.setrecursionlimit(20000000)


def main():
    N = int(input())
    nums = [int(input()) for _ in range(N)]
    a = deepcopy(nums)
    a.sort(reverse=True)

    for i in range(len(nums)):
        if a[0] == nums[i]:
            print(a[1])
        else:
            print(a[0])


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import math
from copy import deepcopy
from collections import deque
sys.setrecursionlimit(20000000)


def main():
    L, R = map(int, input().split())

    ans = 200000000

    for a in range(L, R+1):
        for b in range(a+1, R+1):
            if a * b % 2019 < ans:
                ans = a * b % 2019

    print(ans)


if __name__ == '__main__':
    main()



Fixed submission:
import sys
import math
from copy import deepcopy
from collections import deque
sys.setrecursionlimit(20000000)


def main():
    L, R = map(int, input().split())

    ans = 200000000

    for a in range(L, R+1):
        for b in range(a+1, R+1):
            if a * b % 2019 < ans:
                ans = a * b % 2019
                if ans == 0:
                    print(ans)
                    sys.exit()

    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
pre_n, city_n = map(int, input().split())
cities = [list(map(int, input().split())) for x in range(city_n)]

history = {}

A = {}

for x in sorted(cities):
    pref = str(x[0])
    if pref not in history:
        history[pref] = '1'

    A[str(x)] = '0'*(6-len(pref)) + pref + '0'*(6-len(history[pref])) + history[pref]

    history[pref] = str(int(history[pref]) + 1)

for x in cities:
    print(A[str(x)])


Fixed submission:
pre_n, city_n = map(int, input().split())
cities = [list(map(int, input().split())) for x in range(city_n)]

history = {}

A = {}

for x in sorted(cities):
    pref = str(x[0])
    if pref not in history:
        history[pref] = '1'

    A.setdefault(str(x), '0'*(6-len(pref)) + pref + '0'*(6-len(history[pref])) + history[pref])

    history[pref] = str(int(history[pref]) + 1)

for x in cities:
    print(A[str(x)])

Buggy python submission (verdict: Time Limit Exceeded):
pre_n, city_n = map(int, input().split())
cities = [list(map(int, input().split())) for x in range(city_n)]

history = {}

A = {}

for x in sorted(cities):
    pref = str(x[0])
    if pref not in history:
        history[pref] = '1'

    A.setdefault(str(x), '0'*(6-len(pref)) + pref + '0'*(6-len(history[pref])) + history[pref])

    history[pref] = str(int(history[pref]) + 1)

for x in cities:
    print(A[str(x)])


Fixed submission:
pre_n, city_n = map(int, input().split())
cities = [list(map(int, input().split())) for x in range(city_n)]

history = {}

A = {}

for x in sorted(cities):
    pref = str(x[0])
    if pref not in history:
        history[pref] = '1'

    A.setdefault(str(x), '0'*(6-len(pref)) + pref + '0'*(6-len(history[pref])) + history[pref])

    history[pref] = str(int(history[pref]) + 1)

for x in cities:
    print(A[str(x)])
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
A = sorted(A)[::-1]

ans = A[0]
cnt = 1
n = N - 2

while(1):
    
    ans += A[cnt]
    n -= 1
    if n == 0:  break
        
    ans += A[cnt]
    n -= 1
    if n == 0:  break
        
    cnt += 1
    
print(ans)

Fixed submission:
N = int(input())
A = list(map(int,input().split()))
A = sorted(A)[::-1]

if N == 2:
    print(A[0])

else:
    ans = A[0]
    cnt = 1
    n = N - 2

    while(1):

        ans += A[cnt]
        n -= 1
        if n == 0:  break

        ans += A[cnt]
        n -= 1
        if n == 0:  break

        cnt += 1

    print(ans)