Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [long(input_raw[0])]
    H = []
    input_raw = read_func().strip().split()
    for i in range(N):
        H.append(long(input_raw[i]))

    dp = [{} for i in range(N + 1)]
    dp[0][0] = 0
    min_dist = sys.maxint
    for i in range(N):
        for x in dp[i]:
            if x + 1 < N:
                dp[i + 1][x + 1] = min(dp[i + 1][x + 1] if x + 1 in dp[i + 1] else sys.maxint,
                                    dp[i][x] + abs(H[x] - H[x + 1]))
                if x + 1 == N - 1:
                    min_dist = min(dp[i + 1][x + 1], min_dist)
            if x + 2 < N:
                dp[i + 1][x + 2] = min(dp[i + 1][x + 2] if x + 2 in dp[i + 1] else sys.maxint,
                                    dp[i][x] + abs(H[x] - H[x + 2]))
                if x + 2 == N - 1:
                    min_dist = min(dp[i + 1][x + 2], min_dist)

    print min_dist


if __name__ == '__main__':
    main()

Fixed submission:
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [long(input_raw[0])]
    H = []
    input_raw = read_func().strip().split()
    for i in range(N):
        H.append(long(input_raw[i]))

    dp = [sys.maxint for i in range(N + 1)]
    dp[0] = 0
    for i in range(N):
        if i + 1 < N:
            dp[i + 1] = min(dp[i + 1], dp[i] + abs(H[i] - H[i + 1]))
        if i + 2 < N:
            dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i] - H[i + 2]))

    print dp[N - 1]


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    P = []
    input_raw = read_func().strip().split()
    for i in range(N):
        P.append(float(input_raw[i]))

    dp = [[0 for i in range(N + 1)] for j in range(N + 1)]
    dp[0][0] = 1
    for i in range(0, N):
        for j in range(0, i + 1):
            dp[i + 1][j] += (1.0 - P[i]) * dp[i][j]
            dp[i + 1][j + 1] += P[i] * dp[i][j]

            #dp[i][j] += p[i] * dp[i - 1][j - 1] + (1 - p[i])

    count = 0L
    for j in range(N/2 + N%2, N + 1):
        count += dp[N][j]
    print count
if __name__ == '__main__':
    main()


Fixed submission:
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    P = []
    input_raw = read_func().strip().split()
    for i in range(N):
        P.append(float(input_raw[i]))

    dp = [[0 for i in range(N + 1)] for j in range(N + 1)]
    dp[0][0] = 1
    for i in range(0, N):
        for j in range(0, i + 1):
            dp[i + 1][j] += (1.0 - P[i]) * dp[i][j]
            dp[i + 1][j + 1] += P[i] * dp[i][j]

            #dp[i][j] += p[i] * dp[i - 1][j - 1] + (1 - p[i])

    count = 0L
    for j in range(N/2 + N%2, N + 1):
        count += dp[N][j]
    print count
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#-------------------------------------------------------------------------------
# Name:        module2
# Purpose:
#
# Author:      ysakamot
#
# Created:     15/12/2018
# Copyright:   (c) ysakamot 2018
# Licence:     <your licence>
#-------------------------------------------------------------------------------

import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    A = []
    input_raw = read_func().strip().split()
    for i in range(N):
        A.append(int(input_raw[i]))

    pair_count = 0
    already_set = set([])
    for t in range(31, 0, -1):
        x = 2**t
        count_dict = {}
        for i in range(N):
            if i in already_set:
                continue
            if x - A[i] <= 0:
                continue
            if x - A[i] in count_dict and len(count_dict[x - A[i]]) > 0:
                pair_count += 1
                j = count_dict[x - A[i]].pop()
                already_set.add(i)
                already_set.add(j)
            else:
                if A[i] not in count_dict:
                    count_dict[A[i]] = [i]
                else:
                    count_dict[A[i]].append(i)

    print pair_count

if __name__ == '__main__':
    main()


Fixed submission:

import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    A = []
    input_raw = read_func().strip().split()
    for i in range(N):
        A.append(int(input_raw[i]))

    pair_count = 0
    already_set = set([])
    for t in range(31, 0, -1):
        x = 2**t
        count_dict = {}
        for i in range(N):
            if i in already_set:
                continue
            if x - A[i] <= 0:
                continue
            if x - A[i] in count_dict and len(count_dict[x - A[i]]) > 0:
                pair_count += 1
                j = count_dict[x - A[i]].pop()
                already_set.add(i)
                already_set.add(j)
            else:
                if A[i] not in count_dict:
                    count_dict[A[i]] = [i]
                else:
                    count_dict[A[i]].append(i)

    print pair_count

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
from collections import deque
import copy
import heapq

from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [S] =  [(input_raw[0])]
    input_raw = read_func().strip().split()
    [K] = [long(input_raw[0])]
    count = 0;
    for s in S:
        if s != "1":
            break;
        count += 1
    if count >= K:
        print S[K]
    else:
        print S[count]

if __name__ == '__main__':
    main()

Fixed submission:
import sys
from collections import deque
import copy
import heapq

from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [S] =  [(input_raw[0])]
    input_raw = read_func().strip().split()
    [K] = [long(input_raw[0])]
    count = 0L;
    for s in S:
        if s != "1":
            break;
        count += 1
    if count >= K:
        print S[K-1]
    else:
        print S[count]

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
from collections import deque
import copy

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    input_raw = read_func().strip().split()
    A_i = []
    for i in range(N):
        A_i.append(long(input_raw[i]) - i)


    ave_A = (sum(A_i)/N)
    A_i.sort()
    
    b1 = (ave_A)
    b2 = ave_A + 1
    b3 = A_i[N/2]
    b4 = A_i[N/2 + 1]
    b5 = -b1
    b6 = -b2
    score1 = 0L
    score2 = 0L
    score3 = 0L
    score4 = 0L
    score5 = 0L
    score6 = 0L
    for i in range(N):
        score1 += abs(b1 - A_i[i])
        score2 += abs(b2 - A_i[i])
        score3 += abs(b3 - A_i[i])
        score4 += abs(b4 - A_i[i])
        score5 += abs(b5 - A_i[i])
        score6 += abs(b6 - A_i[i])

    print min(score1, score2, score3, score4,score5,score6)




if __name__ == '__main__':
    main()


Fixed submission:
import sys
from collections import deque
import copy

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    input_raw = read_func().strip().split()
    A_i = []
    for i in range(N):
        A_i.append(long(input_raw[i]) - i)


    ave_A = (sum(A_i)/N)
    A_i.sort()
    
    b1 = (ave_A)
    b2 = ave_A + 1
    b3 = A_i[N/2]
    b4 = b3
    b5 = -b1
    b6 = -b2
    score1 = 0L
    score2 = 0L
    score3 = 0L
    score4 = 0L
    score5 = 0L
    score6 = 0L
    for i in range(N):
        score1 += abs(b1 - A_i[i])
        score2 += abs(b2 - A_i[i])
        score3 += abs(b3 - A_i[i])
        score4 += abs(b4 - A_i[i])
        score5 += abs(b5 - A_i[i])
        score6 += abs(b6 - A_i[i])

    print min(score1, score2, score3, score4,score5,score6)




if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
from collections import deque
import copy

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def power_func(a,b,p):
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, A, B, K] = [long(input_raw[0]), long(input_raw[1]), long(input_raw[2]), long(input_raw[3])]
    cnt = 0
    li = []
    for t in range(N + 1):
        if (K - t * A)%B == 0:
            u = (K - t * A)/B
            if t >= 0 and u >= 0 and t <= N and u <= N:
                li.append((t, u))


    frac_N = [0 for i in range(N + 1)]
    power_N = [0 for i in range(N + 1)]
    frac_N[0] = 1
    power_N[0] = 1
    p = 998244353L
    for i in range(1, N + 1):
        frac_N[i] = (frac_N[i - 1] * i ) % p
        power_N[i] = -1

    s = 0L
    for i in range(len(li)):
        t = li[i][0]
        u = li[i][1]
        if power_N[t] == -1:
            power_N[t] = power_func(frac_N[t], p - 2, p)
        if power_N[N - t] == -1:
            power_N[N - t] = power_func(frac_N[N - t], p - 2, p)
        if power_N[u] == -1:
            power_N[u] = power_func(frac_N[u], p - 2, p)
        if power_N[N - u] == -1:
            power_N[N - u] = power_func(frac_N[N - u], p - 2, p)

        s = (s + ((frac_N[N] * power_N[t] * power_N[N - t]) % p) * ((frac_N[N] * power_N[u] * power_N[N - u]) % p)) % p
    print s


if __name__ == '__main__':
    main()


Fixed submission:
import sys
from collections import deque
import copy

from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    N = int(input_raw[0])
    min_s = sys.maxint
    for i in range(1, N):
        A = str(i)
        A = A.zfill(6)
        B = str(N - i)
        B = B.zfill(6)
        s = 0
        for j in range(6):
            s += int(A[j]) + int(B[j])
        min_s = min(s, min_s)

    print min_s
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
mport sys
import copy

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [A, B, X] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
    if A + B >= X and A <= X:
        print 'YES'
    else:
        print 'NO'

if __name__ == '__main__':
    main()


Fixed submission:
import sys
import copy

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [A, B, X] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
    if A + B >= X and A <= X:
        print 'YES'
    else:
        print 'NO'

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial
import sys

def comb(n,k,p):
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p

def power_func(a,b,p):
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    input_raw = read_func().strip().split()
    A = []
    for i in range(N):
        A.append(int(input_raw[i]))

    n = max(A)
    A.remove(n)
    p = int(1e+9 + 7)
    max_num = 0
    max_r = 0
    for i in range(N - 1):
        cm = comb(n, A[i], p)
        if max_num < cm:
            max_r = A[i]
            max_num = cm
    print n, max_r


if __name__ == '__main__':
    main()

Fixed submission:
from math import factorial
import sys

def comb(n,k,p):
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p

def power_func(a,b,p):
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    input_raw = read_func().strip().split()
    A = []
    for i in range(N):
        A.append(int(input_raw[i]))

    n = max(A)
    A.remove(n)
    A.sort()
    max_r = n/2
    max_r_2 = n - max_r
    min_sub = sys.maxint
    r = 0
    for i in range(len(A)):
        if abs(max_r - A[i]) < min_sub or abs(max_r_2 - A[i]) < min_sub:
            min_sub = min(abs(max_r - A[i]), abs(max_r_2 - A[i]))
            r = A[i]
##    for i in range(N - 1):
##        cm = comb(n, A[i], p)
##        if max_num < cm:
##            max_r = A[i]
##            max_num = cm
    print n, r


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    dic = {}
    for i in range(N):
        input_raw = read_func().strip().split()
        if input_raw[0] in dic:
            dic[input_raw[0]] += 1
        else:
            dic[input_raw[0]] = 1
    input_raw = read_func().strip().split()
    [M] = [int(input_raw[0])]
    for i in range(N):
        input_raw = read_func().strip().split()
        if input_raw[0] in dic:
            dic[input_raw[0]] -= 1

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


if __name__ == '__main__':
    main()


Fixed submission:
import sys
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    dic = {}
    for i in range(N):
        input_raw = read_func().strip().split()
        if input_raw[0] in dic:
            dic[input_raw[0]] += 1
        else:
            dic[input_raw[0]] = 1
    input_raw = read_func().strip().split()
    [M] = [int(input_raw[0])]
    for i in range(M):
        input_raw = read_func().strip().split()
        if input_raw[0] in dic:
            dic[input_raw[0]] -= 1

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


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):

import sys
from collections import deque
import copy
import math

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [S] = [(input_raw[0])]
    head = 0
    tail = len(S) - 1
    count = 0
    #for i in range(len(S)/2 + len(S) % 2):
    while 1:
        if head == tail:
            break
        if S[head] != S[tail]:
            if S[head] == "x":
                count += 1
                head += 1
            elif S[tail] == "x":
                count += 1
                tail -= 1
            else:
                print -1
                return
        else:
            head += 1
            tail -= 1
    print count


if __name__ == '__main__':
    main()


Fixed submission:

import sys
from collections import deque
import copy
import math

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [S] = [(input_raw[0])]
    head = 0
    tail = len(S) - 1
    count = 0
    #for i in range(len(S)/2 + len(S) % 2):
    while 1:
        if head >= tail:
            break
        if S[head] != S[tail]:
            if S[head] == "x":
                count += 1
                head += 1
            elif S[tail] == "x":
                count += 1
                tail -= 1
            else:
                print -1
                return
        else:
            head += 1
            tail -= 1
    print count


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import sys
from collections import deque
import copy
import heapq
import math

from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, K] = [long(input_raw[0]), long(input_raw[1])]
    A_list = []
    B_list = []
    for i in range(N):
        input_raw = read_func().strip().split()
        [A, B] = [long(input_raw[0]), long(input_raw[1])]
        A_list.append(A)
        B_list.append(B)

    max_value = 0
    for r in range(int(math.log(K, 2))+1 + 1):
        if ((K>>r) & 0x01) == 1 or r > int(math.log(K, 2)):
            if r <= int(math.log(K, 2)):
                Kr = ((K & ~(0x01<<r)) | ((0x01<<r) - 1))
            else:
                Kr = K
            value = 0
            for i in range(N):

                if (A_list[i] | Kr) == Kr:
                    value += B_list[i]
            max_value = max(max_value, value)

    print max_value



if __name__ == '__main__':
    main()


Fixed submission:

import sys
from collections import deque
import copy
import heapq
import math

from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, K] = [long(input_raw[0]), long(input_raw[1])]
    A_list = []
    B_list = []
    for i in range(N):
        input_raw = read_func().strip().split()
        [A, B] = [long(input_raw[0]), long(input_raw[1])]
        A_list.append(A)
        B_list.append(B)

    if K == 0:
        value = 0
        for i in range(N):
            if A_list[i] == 0:
                value += B_list[i]
        print value
        exit()
    max_value = 0
    for r in range(int(math.log(K, 2))+1 + 1):
        if ((K>>r) & 0x01) == 1 or r > int(math.log(K, 2)):
            if r <= int(math.log(K, 2)):
                Kr = ((K & ~(0x01<<r)) | ((0x01<<r) - 1))
            else:
                Kr = K
            value = 0
            for i in range(N):

                if (A_list[i] | Kr) == Kr:
                    value += B_list[i]
            max_value = max(max_value, value)

    print max_value



if __name__ == '__main__':
    main()