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

bond = dict(('A', 'T'), ('T', 'A',), ('C', 'G'), ('G', 'C'))

def main():
    b = sys.stdin.readline().rstrip()
    print(bond[b])

if __name__ == "__main__":
    main()


Fixed submission:
# 2019-11-12 22:21:08(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    b = sys.stdin.readline().rstrip()
    if b == 'A':
        ans = 'T'
    elif b == 'T':
        ans = 'A'
    elif b == 'G':
        ans = 'C'
    else:
        ans = 'G'
    
    print(ans)


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
# 2019-11-12 22:21:08(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    s = sys.stdin.readline().rstrip()
    
    permitted = 'ACGT'
    continuous_count = []
    count = 0

    for i in range(len(s)):
        char = s[i]
        if char in permitted:
            count += 1
        else:
            continuous_count.append(count)
            count = 0
    
    print(max(continuous_count))



if __name__ == "__main__":
    main()


Fixed submission:
# 2019-11-12 22:21:08(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    s = sys.stdin.readline().rstrip()
    
    all_words = []
    for i in range(1, len(s) + 1):
        for letters in itertools.product('ATCG', repeat=i):
            word = ''.join(letters)
            all_words.append(word)
    
    for i in range(len(all_words)-1, 0-1, -1):
        if all_words[i] in s:
            print(len(all_words[i]))
            sys.exit()
    print(0)




if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys

s = sys.stdin.readline().rstrip()
n = len(s)

def main():
    c = s.cout('0')
    print(min(n-c, c) * 2)

if __name__ ==  '__main__':
    main()

Fixed submission:
import sys

s = sys.stdin.readline().rstrip()

def main():
    return min(s.count('0'), s.count('1')) * 2

if __name__ == '__main__':
    ans = main()
    print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
from functools import lru_cache
inf = float('inf')

n, A, B, C, *l = map(int, sys.stdin.read().split())

@lru_cache
def cost(a, b, c, cnt, i):
    if i == n:
        if not (a and b and c): return inf
        return abs(A - a) + abs(B - b) + abs(C - c) + 10 * (cnt - 3)
    return min(cost(a, b, c, cnt, i+1), 
               cost(a+l[i], b, c, cnt+1, i+1),
               cost(a, b+l[i], c, cnt+1, i+1),
               cost(a, b, c+l[i], cnt+1, i+1))

def main():
    print(cost(0, 0, 0, 0, 0))

if __name__ ==  '__main__':
    main()

Fixed submission:
import sys
from itertools import product

inf = float('inf')

n, *target = map(int, sys.stdin.readline().split())
target = [None] + target
*l,  = map(int, sys.stdin.read().split())

def main():
    costs = []
    for p in product(range(4), repeat=n):
        tmp = [[] for _ in range(4)]
        p = list(p)
        for i in range(n):
            tmp[p[i]].append(l[i])

        cost = [0] * 4
        for i in range(1, 4):
            if not tmp[i]:
                break
            cost[i] += 10 * (len(tmp[i]) - 1)
            cost[i] += abs(target[i] - sum(tmp[i]))
        else:
            costs.append(sum(cost))

    return min(costs)

if __name__ == '__main__':
    ans = main()
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
# 2019-11-11 18:30:26(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n, k, *h = (int(x) for x in sys.stdin.read().split())
    h.sort()
    min_diff = h[-1] - h[0] # default value
    for i in range(n - k + 1):
        heights = h[i:i+k]
        diff = heights[-1] - heights[0]
        min_diff = min(min_diff, diff)
    print(min_diff)



if __name__ == "__main__":
    main()


Fixed submission:
# 2019-11-11 18:30:26(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n, k, *h = (int(x) for x in sys.stdin.read().split())
    h.sort()
    min_diff = h[-1] - h[0] # default value
    for i in range(n - k + 1):
        diff = h[i+k-1] - h[i]
        min_diff = min(min_diff, diff)
    print(min_diff)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
# 2019-11-11 16:07:35(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

digits = ['3', '5', '7']

def main():
    # 357 以上
    # 3, 5, 7 のいずれかを使わない数字の個数をnから引けばいい
    n = int(sys.stdin.readline().rstrip())

    if n < 357:
        print(0)
        sys.exit()

    count = 0
    for m in range(357, n+1):
        m = str(m)
        c3, c5, c7 = 0, 0, 0
        for d in m:
            if d == '3':
                c3 += 1
            elif d == '5':
                c5 += 1
            elif d == '7':
                c7 += 1
            else:
                break
        else:
            if c3 >= 1 and c5 >= 1 and c7 >= 1:
                count += 1

    print(count)


if __name__ == "__main__":
    main()


Fixed submission:
# 2019-11-11 16:07:35(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

shichigosan = '357'

def main():

    n = int(sys.stdin.readline().rstrip())
    
    count = 0
    for i in range(3, len(str(n)) + 1):
        sub_shichigosan = list(''.join(s) for s in itertools.product(shichigosan, repeat=i))
        for sub in sub_shichigosan:
            for d in shichigosan:
                if d in sub:
                    continue
                else:
                    break
            else:
                if 357 <= int(sub) <= n:
                    count += 1
    
    print(count)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
import sys

MOD = 10 ** 9 + 7

h, w, k = map(int, sys.stdin.readline().split())

def main():
    ok = []
    for i in range(2 ** (w - 1)):
        prev = False
        for j in range(w-1):
            if i >> j & 1:
                if prev:
                    break
                else:
                    prev = True
            else:
                prev = False
        else:
            ok.append(i)

    lcr = [(letter, 0) for letter in 'lcr']
    a = [dict(lcr) for _ in range(w)]
    for i in ok:
        j = 0
        while j < w:
            if i >> j & 1:
                a[j]['r'] += 1
                a[j+1]['l'] += 1
                j += 2
            else:
                a[j]['c'] += 1
                j += 1

    res = [0] * w
    res[0] = 1
    for _ in range(h):
        nex = [0] * w
        for j in range(w):
            if j == 0:
                nex[j] = res[j] * a[j]['c'] + res[j+1] * a[j]['r']
            elif j < w - 1:
                nex[j] = res[j-1] * a[j]['l'] + res[j] * a[j]['c'] + res[j+1] * a[j]['r']
            else:
                nex[j] = res[j-1] * a[j]['l'] + res[j] * a[j]['c']
        for j in range(w):
            nex[j] %= MOD
        res = nex
        
    return res[k-1]
    
if __name__ == '__main__':
    ans = main()
    print(ans)

Fixed submission:
import sys

MOD = 10 ** 9 + 7

h, w, k = map(int, sys.stdin.readline().split())

def main():
    ok = []
    for i in range(2 ** (w - 1)):
        prev = False
        for j in range(w-1):
            if i >> j & 1:
                if prev:
                    break
                else:
                    prev = True
            else:
                prev = False
        else:
            ok.append(i)
        
    res = [0] * w
    res[0] = 1
    for _ in range(h):
        nex = [0] * w
        for i in ok:
            j = 0
            while j < w:
                if i >> j & 1:
                    nex[j] += res[j+1]
                    nex[j+1] += res[j] 
                    j += 2
                else:
                    nex[j] += res[j]
                    j += 1
        for j in range(w):
            nex[j] %= MOD
        res = nex
    
    return res[k-1]
    
if __name__ == '__main__':
    ans = main()
    print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
from math import sqrt, floor
from bisect import bisect_right as bi_r

def factorize(n):
    res = []
    for i in range(1, floor(sqrt(n)) + 1):
        if not n % i:
            res.append(i, n // i)
    return sorted(res)

n, m = map(int, sys.stdin.readline().split())


def main():
    res = factorize(m)
    ans = res[bi_r(res, m / n) - 1]
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Fixed submission:
import sys
from math import sqrt, floor
from bisect import bisect_right as bi_r

def factorize(n):
    res = []
    for i in range(1, floor(sqrt(n)) + 1):
        if not n % i:
            res.append(i)
            res.append(n // i)
    return sorted(res)

n, m = map(int, sys.stdin.readline().split())

def main():
    res = factorize(m)
    ans = res[bi_r(res, m / n) - 1]
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)
Buggy python submission (verdict: Runtime Error):
#                         author:  kagemeka 
#                         created: 2019-11-10 12:28:14(JST)
### modules
## from standard library
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## from external libraries
# import scipy.special   
# import scipy.misc      
# import numpy as np 

def main():
    a, b = (int(x) for x in sys.stdin.readline().split())
    if (a * b) % 2 !- 0:
        ans = 'Yes'
    else:
        ans = 'No'
    
    print(ans)


if __name__ == "__main__":
    # execute only if run as a script
    main()


Fixed submission:
#                         author:  kagemeka 
#                         created: 2019-11-10 12:28:14(JST)
### modules
## from standard library
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## from external libraries
# import scipy.special   
# import scipy.misc      
# import numpy as np 

def main():
    a, b = (int(x) for x in sys.stdin.readline().split())
    if (a * b) % 2 != 0:
        ans = 'Yes'
    else:
        ans = 'No'
    
    print(ans)


if __name__ == "__main__":
    # execute only if run as a script
    main()
Buggy python submission (verdict: Runtime Error):
#                         author:  kagemeka 
#                         created: 2019-11-10 12:28:14(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n, *w = sys.stdin.read().split()
    n = int(n)
    for i in range(1, n):
        if w[i][0] == w[i-1][-1] and not w[i] in w[:i]:
            continue
        else:
            sys.exit('No')
    
    print('Yes')


if __name__ == "__main__":
    # execute only if run as a script
    main()


Fixed submission:
#                         author:  kagemeka 
#                         created: 2019-11-10 12:28:14(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n, *w = sys.stdin.read().split()
    n = int(n)
    for i in range(1, n):
        if w[i][0] == w[i-1][-1] and not w[i] in w[:i]:
            continue
        else:
            print('No')
            exit()
    
    print('Yes')


if __name__ == "__main__":
    # execute only if run as a script
    main()
Buggy python submission (verdict: Runtime Error):
import sys

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

def main():
    c1 = n // k
    c2 = n // (k // 2)
    if (k & 1): cnt = pow(c1, 3)
    else: cnt = pow(c1, 3) + pow(c2 - c1, 3)
    print(cnt)

if __name__ ==  '__main__':
    main()

Fixed submission:
import sys
from functools import reduce
from operator import mul
import math

def nCr(n, r):
    r = min(r, n-r)
    upper = reduce(mul, range(n, n-r, -1), 1)
    lower = reduce(mul, range(r, 0, -1), 1)
    return upper // lower


def oddCaseK(n, k):
    cand = 0
    for x in range(1, n+1):
        if x % k == 0:
            cand += 1
    
    number_of_possibles = 0
    if cand >= 1:
        number_of_possibles += cand
    if cand >= 2:
        number_of_possibles += nCr(cand, 2) * nCr(2, 1) * 3
    if cand >= 3:
        number_of_possibles += nCr(cand, 3) * math.factorial(3)
    
    return number_of_possibles

    

def evenCaseK(n, k):
    cand1 = 0
    cand2 = 0
    for x in range(1, n+1):
        if x % k == 0:
            cand1 += 1
        elif x % k == k // 2:
            cand2 += 1
    
    number_of_possibles = 0
    number_of_possibles = 0
    if cand1 >= 1:
        number_of_possibles += cand1
    if cand1 >= 2:
        number_of_possibles += nCr(cand1, 2) * nCr(2, 1) * 3
    if cand1 >= 3:
        number_of_possibles += nCr(cand1, 3) * math.factorial(3)

    if cand2 >= 1:
        number_of_possibles += cand2
    if cand2 >= 2:
        number_of_possibles += nCr(cand2, 2) * nCr(2, 1) * 3
    if cand2 >= 3:
        number_of_possibles += nCr(cand2, 3) * math.factorial(3)

    return number_of_possibles


def main():
    n, k = [int(x) for x in sys.stdin.readline().split()]
    if k % 2 == 0:
        ans = evenCaseK(n, k)
    else:
        ans = oddCaseK(n, k)
    
    print(ans)



if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#                         author:  kagemeka 
#                         created: 2019-11-09 16:39:51(JST)
### modules
## from standard library
import sys
# import collections
# import math
# import string
import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## from external libraries
# import scipy.special   
# import scipy.misc      
# import numpy as np 

def main():
    n, k, *x = (int(i) for i in sys.stdin.read().split())

    minimums = []
    for i in range(n - k + 1):
        cur_range = x[i: i+k]
        if cur_range[-1] <= 0:
            mi = abs(cur_range[0])
        elif cur_range[0] >= 0:
            mi = abs(cur_range[-1])
        else:
            mi = min(abs(cur_range[0]) * 2 + cur_range[-1], abs(cur_range[0]) + cur_range[-1] * 2)
        minimums.append(mi)
    
    ans = min(minimums)
    print(ans)


if __name__ == "__main__":
    # execute only if run as a script
    main()


Fixed submission:
#                         author:  kagemeka 
#                         created: 2019-11-09 16:39:51(JST)
### modules
## from standard library
import sys
# import collections
# import math
# import string
import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## from external libraries
# import scipy.special   
# import scipy.misc      
# import numpy as np 

def main():
    n, k, *x = (int(i) for i in sys.stdin.read().split())

    minimums = []
    for i in range(n - k + 1):

        left = x[i]
        right = x[i + k - 1]
        mi = min(abs(left) + abs(right - left), abs(right) + abs(left - right))
        minimums.append(mi)
    
    ans = min(minimums)
    print(ans)


if __name__ == "__main__":
    # execute only if run as a script
    main()
Buggy python submission (verdict: Runtime Error):
import sys
import numpy as np

I = np.array(sys.stdin.read().split(), dtype=np.int64)
n, m, q = I[:3]
l, r = I[3:3+m*2].reshape(-1, 2).T
p, q = I[3+m*2:].reshape(-1, 2).T

def main():
    res = np.zeros((n+2, n+2), dtype=np.int64)

    np.add.at(res, (np.full(m, 1), r), 1)
    np.add.at(res, (l+1, r), -1)
    np.add.at(res, (np.full(m, 1), np.full(m, n+1)), -1)
    np.add.at(res, (l+1, np.full(m, n+1)), 1)
    res = np.cumsum(res, axis=0)
    res = np.cumsum(res, axis=1)
    
    ans = res[p, q]
    return ans

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

Fixed submission:
import sys
import numpy as np

I = np.array(sys.stdin.read().split(), dtype=np.int64)
n, m, q = I[:3]
l, r = I[3:3+m*2].reshape(-1, 2).T
p, q = I[3+m*2:].reshape(-1, 2).T

def main():
    res = np.zeros((n+2, n+2), dtype=np.int64)
    
    np.add.at(res, (1, r), 1)
    np.add.at(res, (l+1, r), -1)
    np.add.at(res, (1, n+1), -1)
    np.add.at(res, (l+1, n+1), 1)
    res = np.cumsum(res, axis=0)
    res = np.cumsum(res, axis=1)

    ans = res[p, q]
    return ans

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')
Buggy python submission (verdict: Runtime Error):
import sys

r = map(int, sys.stdin.readline().rstrip())

def main():
    if r < 1200:
        return 'ABC'
    elif r < 2800:
        return 'ARC'
    else:
        return 'AGC'

if __name__ == '__main__':
    ans = main()
    print(ans)

Fixed submission:
#                         author:  kagemeka 
#                         created: 2019-11-08 18:39:24(JST)
### modules
## from standard library
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## from external libraries
# import scipy.special   # if use comb function on AtCoder, 
# import scipy.misc      # select scipy.misc.comb (old version)  
# imort numpy as np 

def main():
    r = int(sys.stdin.readline().rstrip())
    if r < 1200:
        ans = 'ABC'
    elif r < 2800:
        ans = 'ARC'
    else:
        ans = 'AGC'

    print(ans)


if __name__ == "__main__":
    # execute only if run as a script
    main()
Buggy python submission (verdict: Runtime Error):
import sys

*a = map(int, sys.stdin.readline().split())

def main():
    return max(a) - min(a)

if __name__ == '__main__':
    ans = main()
    print(ans)

Fixed submission:
#                         author:  kagemeka 
#                         created: 2019-11-08 15:54:47(JST)
### modules
## from standard library
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## from external libraries
# import scipy.special   # if use comb function on AtCoder, 
# import scipy.misc      # select scipy.misc.comb (old version)  

def main():
    *n, = (int(x) for x in sys.stdin.readline().split())
    n.sort()
    print(n[-1] - n[0])


if __name__ == "__main__":
    # execute only if run as a script
    main()
Buggy python submission (verdict: Runtime Error):
import sys

n, s = sys.stdin.read().split()

def main():
    cnt = s.count('E')
    cur = 'E'
    res = cnt
    for c in s:
        if cur == 'W': cnt += 1
        if c == 'E': cnt -= 1
        res = min(res, cnt)
        cur = c
    print(min(res))
    
if __name__ ==  '__main__':
    main()

Fixed submission:
#                         author:  kagemeka 
#                         created: 2019-11-07 23:33:56(JST)
## internal modules
import sys
import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator
## external modules
# import scipy.special   # if use comb function on AtCoder, 
# import scipy.misc      # select scipy.misc.comb (old version) 

def main():
    n = int(sys.stdin.readline().rstrip())
    s = sys.stdin.readline().rstrip()

    opposite = collections.Counter(s)
    opposite['W'] = 0
    minimum = n
    for i in range(n):
        if s[i] == 'E':
            opposite['E'] -= 1
        minimum = min(minimum, sum(opposite.values()))
        if s[i] == 'W':
            opposite['W'] += 1
    print(minimum)




if __name__ == "__main__":
    # execute only if run as a script
    main()
Buggy python submission (verdict: Time Limit Exceeded):
# 2019-11-19 01:10:02(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import array
# from scipy.misc import comb # (default: exact=False)
# import numpy as np 


def main():
    n, *a = [int(x) for x in sys.stdin.read().split()]
    s = list(itertools.accumulate(a))

    count = s.count(0)
    for i in range(n-1):
        for j in range(i+1, n):
            if s[j] - s[i] == 0:
                count += 1

    print(count)

if __name__ == "__main__":
    main()


Fixed submission:
# 2019-11-19 01:10:02(JST)
import sys
import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import array
from scipy.misc import comb # (default: exact=False)
# import numpy as np

# def nCr(n, r):
#     r = min(n, r)
#     return np.cumprod(range(n, n-r, -1)) // np.cumprod(range(r, 0, -1))

def main():
    n, *a = [int(x) for x in sys.stdin.read().split()]
    s = list(itertools.accumulate(a))

    
    res = s.count(0)
    for x in [x for x in collections.Counter(s).values() if x >= 2]:
        res += comb(x, 2, exact=True)

    print(res)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n, d, x;
  cin >> n >> d >> x;
  int tot = x;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    tot += (d - 1) / a + 1;
  }
  cout << tot << '\n';
  return 0;
}

Fixed submission:
#                         author:  kagemeka 
#                         created: 2019-11-07 00:57:57(JST)
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator

def main():
    n, d, x, *a = (int(i) for i in sys.stdin.read().split())
    d -= 1
    c = n
    for i in range(n):
        c += d // a[i]
    total = c + x
    print(total)


if __name__ == "__main__":
    # execute only if run as a script
    main()