Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
#pypyは内包表記使わない, rstrip注意
#提出前に見返すこと！
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 1000000007

    x = int(input())
    for i in range(x, 0, -1):
        for b in range(1, 35):
            for p in range(2, 10):
                if b**p==i:
                    print(i)
                    eixt()

if __name__ == '__main__':
    main()

Fixed submission:
#pypyは内包表記使わない, rstrip注意
#提出前に見返すこと！
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 1000000007

    x = int(input())
    for i in range(x, 0, -1):
        for b in range(1, 35):
            for p in range(2, 10):
                if b**p==i:
                    print(i)
                    exit()

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())
    p = list(map(int, input().split()))
    adj = [[] for _ in range(n)] #頂点数, 場合によって変える
    for _ in range(m):
        a,b = map(int, input().split())
        adj[a-1].append(b-1)
        adj[b-1].append(a-1)

    swap = [[] for _ in range(n)]
    res = 0
    for i in range(n):
        if i == p[i]-1:
            res += 1
            continue
        d = deque([i])
        visited = [0]*n
        visited[i] = 1
        while d:
            v = d.popleft()
            for nv in adj[v]:
                if visited[nv] == 0:
                    if nv == p[i]-1:
                        res += 1
                    d.append(nv)
                    visited[nv] = 1
                    swap[i].append(nv)
    print(res)

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())
    p = list(map(int, input().split()))
    xy = [list(map(int, input().split())) for _ in range(m)]

    def find(x):
        if par[x] < 0:
            return x
        else:
            par[x] = find(par[x])
            return par[x]
    
    def unite(x,y):
        x = find(x)
        y = find(y)
        if x == y:
            return False
        else:
            if par[x] > par[y]:
                x,y = y,x
            par[x] += par[y]
            par[y] = x
            return True
    
    def same(x,y):
        return find(x) == find(y)
    
    par = [-1]*n

    for x, y in xy:
        if same(x-1, y-1) == False:
            unite(x-1, y-1)
    res = 0
    for i in range(n):
        if i == p[i]-1:
            res += 1
        else:
            if same(i, p[i]-1):
                res += 1
    print(res)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = int(input())
print('Yes') if n%500 <= a print('No')

Fixed submission:
n = int(input())
a = int(input())
print('Yes') if n%500 <= a else print('No')
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())

    #[行先, 距離]
    adj = [[] for _ in range(n)] #頂点数, 場合によって変える
    for _ in range(m):
        l,r,d = map(int, input().split())
        adj[l-1].append([r-1, d])
        adj[r-1].append([l-1, -d])

    x = [inf]*n

    def dfs(v):
        if x[v]==inf:
            x[v] = 0
        d = deque([v])
        while d:
            v  = d.popleft()
            for nv, cost in adj[v]:
                if x[nv] == inf:
                    x[nv] = x[v] + cost
                else:
                    if x[nv] - x[v] != cost:
                        return False
                d.append(nv)
        return True


    for v in range(n):
        if not dfs(v):
            print('No')
            exit()
    print('Yes')


if __name__ == '__main__':
    main()




Fixed submission:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())

    #[行先, 距離]
    adj = [[] for _ in range(n)] #頂点数, 場合によって変える
    for _ in range(m):
        l,r,d = map(int, input().split())
        adj[l-1].append([r-1, d])
        adj[r-1].append([l-1, -d])

    x = [inf]*n

    def dfs(v):
        if x[v]==inf:
            x[v] = 0
        d = deque([v])
        while d:
            v  = d.popleft()
            for nv, cost in adj[v]:
                if x[nv] == inf:
                    x[nv] = x[v] + cost
                    d.append(nv)
                else:
                    if x[nv] - x[v] != cost:
                        return False
        return True


    for v in range(n):
        if not dfs(v):
            print('No')
            exit()
    print('Yes')


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
s = sorted(s)
t = sorted(t, reverse=1)
if s<t:
    print('Yes')
else:
    print('No')


Fixed submission:
a,b = map(int, input().split())
s = (a+b)//2
if (a+b)%2:
  print(s+1)
else:
  print(s)
Buggy python submission (verdict: Runtime Error):
s = input()
s.sort()
t = input()
t.sort(reverse=True)
if s<t:
    print('Yes')
else:
    print('No')


Fixed submission:
s = list(input())
t = list(input())
if s==t:
    print('No')
    exit()

s = sorted(s)
s = ''.join(s)
t = sorted(t, reverse=1)
t = ''.join(t)
l = [s,t]
k = sorted(l)
if l==k:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
s = input()
s = s.sort()
t = input()
t = t.sort(reverse=True)
if s<t:
    print('Yes')
else:
    print('No')

Fixed submission:
s = list(input())
t = list(input())
if s==t:
    print('No')
    exit()

s = sorted(s)
s = ''.join(s)
t = sorted(t, reverse=1)
t = ''.join(t)
l = [s,t]
k = sorted(l)
if l==k:
    print('Yes')
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
s = input().sort()
t = input().sort(reverse=True)
if s<t:
    print('Yes')
else:
    print('No')

Fixed submission:
s = list(input())
t = list(input())
if s==t:
    print('No')
    exit()

s = sorted(s)
s = ''.join(s)
t = sorted(t, reverse=1)
t = ''.join(t)
l = [s,t]
k = sorted(l)
if l==k:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
ans = 0
for num, cnt in c.items():
    if cnt>=num:
        ans += cnt - num
    else:
        ans += cnt
print(ans)


Fixed submission:
from collections import Counter
from collections import deque

n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
c = c.most_common()
ans = 0
for num, cnt in c:
    if cnt>=num:
        ans += cnt - num
    else:
        ans += cnt
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
F = [int(input().replace(' ',''), 2) for _ in range(n)]
P = [list(map(int, input().split())) for _ in range(n)]
ans=-10**7*n
for sp in range(1, 1033):
  total = 0
  for i in range(n):
    total += P[i][bin(F[i] & sp).count('1')]
  if total>ans:
    ans = total
  else:
    ans = ans
print(ans)


Fixed submission:
n,a,b = map(int, input().split())
if n*a<b:
  print(n*a)
else:
  print(b)
Buggy python submission (verdict: Runtime Error):
n = input()
a = int(n[0])
b = int(n[1])
c = int(n[2])
d = int(n[3])

if a+b+c+d==7:
    print(f'{a}+{b}+{c}+{d}=7')
    exit()
if a+b+c-d==7:
    print(f'{a}+{b}+{c}-{d}=7')
    exit()
if a+b-c+d==7:
    print(f'{a}+{b}-{c}+{d}=7')
    exit()
if a-b+c+d==7:
    print(f'{a}-{b}+{c}+{d}=7')
    exit()
if a-b-c+d==7:
    print(f'{a}-{b}-{c}+{d}=7')
    exit()
if a-b+c-d==7:
    print(f'{a}-{b}+{c}-{d}=7')
    exit()
if a+b-c-d==7:
    print(f'{a}+{b}-{c}-{d}=7')
    exit()
if a-b-c-d==7:
    print(f'{a}-{b}-{c}-{d}=7')
    exit()

Fixed submission:
n = input()
a = int(n[0])
b = int(n[1])
c = int(n[2])
d = int(n[3])

if a+b+c+d==7:
    print('{}+{}+{}+{}=7'.format(a, b, c, d))
elif a+b+c-d==7:
    print('{}+{}+{}-{}=7'.format(a, b, c, d))
elif a+b-c+d==7:
    print('{}+{}-{}+{}=7'.format(a, b, c, d))
elif a-b+c+d==7:
    print('{}-{}+{}+{}=7'.format(a, b, c, d))
elif a-b-c+d==7:
    print('{}-{}-{}+{}=7'.format(a, b, c, d))
elif a-b+c-d==7:
    print('{}-{}+{}-{}=7'.format(a, b, c, d))
elif a+b-c-d==7:
    print('{}+{}-{}-{}=7'.format(a, b, c, d))
elif a-b-c-d==7:
    print('{}-{}-{}-{}=7'.format(a, b, c, d))
Buggy python submission (verdict: Runtime Error):
#どっちで出すか注意, rstrip注意
#提出前に見返すこと！
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    N,Z,W = map(int, input().split())
    a = list(map(int, input().split()))
    print(max(abs(a[-1]-W), abs(a[-1]-a[-2])))


if __name__ == '__main__':
    main()

Fixed submission:
#どっちで出すか注意, rstrip注意
#提出前に見返すこと！
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    N,Z,W = map(int, input().split())
    a = list(map(int, input().split()))
    if N>=2:
        print(max(abs(a[-1]-W), abs(a[-1]-a[-2])))
    else:
        print(abs(a[0]-W))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
'''
https://atcoder.jp/contests/abc077/tasks/arc084_a
'''
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    n = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    A.sort()
    B.sort()
    C.sort()

    def nibu(num, l):
        L = 0
        R = n-1
        mid = (L+R)//2
        if l[L]>num:
            return n, L
        if l[R]<num:
            return 0, n
        while 1:
            if l[L]<=num and num<l[L+1]:
                return n-(L+1), L+1
            elif l[mid]<=num:
                L = mid
            else:
                R = mid
            mid = (L+R)//2
    res = 0
    for i in A:
        x, na = nibu(i, B)
        for j in B[na:]:
            y, nb = nibu(j, C)
            res += y
    print(res)

if __name__ == '__main__':
    main()

Fixed submission:
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    n = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    A.sort()
    C.sort()

    res = 0
    for j in B:
        res += bisect_left(A, j) * (n-bisect_right(C, j))
    print(res)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
a, b, c = list(map(int, input().split()))
if a==b:
  print(c)
elif a==c:
  print(b):
else:
  print(a)

Fixed submission:
a, b, c = list(map(int, input().split()))
if a==b:
  print(c)
elif a==c:
  print(b)
else:
  print(a)
Buggy python submission (verdict: Runtime Error):
#pypyは内包表記使わない
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    A, B, C, D, E, F = map(int, input().split())
    rate = 0
    res_water = min(A, B) * 100
    res_sugar = 0
    for i in range(30//A+1):
        for j in range(30//B+1):
            if i==0 and j==0:
                continue
            water = A*i + B*j
            if water*100 > F:
                continue
            limit = water * E
            for s in range(limit//C+1):
                sugar = limit - (limit-C*s)%D
                if water*100 + sugar > F:
                    continue
                if rate < sugar/(sugar+water*100):
                    rate = sugar/(sugar+water*100)
                    res_water = water * 100
                    res_sugar = sugar
    print(res_water+res_sugar, res_sugar)

if __name__ == '__main__':
    main()

Fixed submission:
#pypyは内包表記使わない
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    N = int(input())
    A = int(input())
    print(N**2-A)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
t = [int(input()) for _ in range(n)]

f, ans, x = 0, 1, 2

while x<=max(t):
    for i in range(n):
        if t[i]%x==0:
            t[i] //= x
            f = 1
    if f:
        ans *= x
        f = 0
    else:
        x += 1
for i in t:
    ans *= i
print(ans)


Fixed submission:
n = int(input())
t = [int(input()) for _ in range(n)]


#a>b
def gcd(a, b):
    if b:
        return gcd(b, a%b)
    else:
        return a

def lcm(a, b):
    if a>b:
        g = gcd(a, b)
        return a*b//g
    else:
        g = gcd(b, a)
        return a*b//g

ans = 1
for i in range(n):
    ans = lcm(ans, t[i])

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
t = [int(input()) for _ in range(n)]

f, ans, x = 0, 1, 2

while x<=max(t):
    for i in range(n):
        if t[i]%x==0:
            t[i] //= x
            f = 1
    if f:
        ans *= x
        f = 0
    else:
        x += 1
for i in t:
    ans *= i
print(ans)


Fixed submission:
n = int(input())
t = [int(input()) for _ in range(n)]


#a>b
def gcd(a, b):
    if b:
        return gcd(b, a%b)
    else:
        return a

def lcm(a, b):
    if a>b:
        g = gcd(a, b)
        return a*b//g
    else:
        g = gcd(b, a)
        return a*b//g

ans = 1
for i in range(n):
    ans = lcm(ans, t[i])

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
t = [int(input()) for _ in range(n)]

f, ans, x = 0, 1, 2

while x<=max(t):
    for i in range(n):
        if t[i]%x==0:
            t[i] //= x
            f = 1
    if f:
        ans *= x
        f = 0
    else:
        x += 1
for i in t:
    ans *= i
print(ans)

Fixed submission:
n = int(input())
t = [int(input()) for _ in range(n)]


#a>b
def gcd(a, b):
    if b:
        return gcd(b, a%b)
    else:
        return a

def lcm(a, b):
    if a>b:
        g = gcd(a, b)
        return a*b//g
    else:
        g = gcd(b, a)
        return a*b//g

ans = 1
for i in range(n):
    ans = lcm(ans, t[i])

print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
print('{}{}{}'.format(s[0], len(s)-2, s[-1])

Fixed submission:
s = input()
print('{}{}{}'.format(s[0], len(s)-2, s[-1]))
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    n = int(input())
    a = input().split()
    b = []
    for i in range(n):
        b.append(a[i])
        b = b[::-1]
    print(' '.join(b))


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    n = int(input())
    a = input().split()
    b = []
    c = []
    if n%2==0:
        for i in range(n):
            if i%2:
                b.append(a[-i])
            else:
                c.append(a[i])
        print(' '.join(b+c))
    else:
        m = [a[-1]]
        a = a[:-1]
        n -= 1
        for i in range(n):
            if i%2:
                b.append(a[-i])
            else:
                c.append(a[i])
        print(' '.join((b+c+m)[::-1]))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int, input().split())
res = []
for _ in range(n):
    a,b = map(int, input().split())
    res += [a]*b
res.sort()
print(res[k-1])

Fixed submission:
n,k = map(int, input().split())
res = [0]*(10**5+1)
for _ in range(n):
    a,b = map(int, input().split())
    res[a] += b

for i, x in enumerate(res):
    if k>x:
        k -= x
    else:
        print(i)
        exit()
Buggy python submission (verdict: Runtime Error):

a,b,c = map(int, input().split())
if b-a==c-b:
    pirnt('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):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
import math
from math import gcd

#inf = 10**17
#mod = 10**9 + 7

n = int(input())
a = list(map(int, input().split()))
a.sort()
res = 0
for i in range(n, 3*n, 2):
    res += a[i]
print(res)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
#from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
import math

#inf = 10**17
#mod = 10**9 + 7

n = int(input())
a = list(map(int, input().split()))
a.sort()
res = 0
for i in range(n, 3*n, 2):
    res += a[i]
print(res)