Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
K,S=map(int,input().split())
ANS=0
for i in range(K+1):
  if i > S:
    break
  for j in range(K+1):
    zz = i + j
    if zz > S:
      break
    for k in range(K+1):
      z = i + j + k
      if z == S:
        #print(i,j,k)
        ANS+=1
      elif z >= S:
        break
print(ANS)

Fixed submission:
K,S=map(int,input().split())
ANS=0
for i in range(K+1):
  if i > S:
    break
  for j in range(K+1):
    z = i + j
    
    if S - z >= 0 and S - z <= K:
      #print(i,j,S-z)
      ANS+=1
    else:
      if S - z <= 0:
      	break
print(ANS)

Buggy python submission (verdict: Time Limit Exceeded):
K,S=map(int,input().split())
ANS=0
for i in range(K+1):
  if i > S:
    break
  for j in range(K+1):
    zz = i + j
    if zz > S:
      break
    for k in range(K+1):
      z = i + j + k
      if z == S:
        #print(i,j,k)
        ANS+=1
      elif z >= S:
        break
print(ANS)

Fixed submission:
K,S=map(int,input().split())
ANS=0
for i in range(K+1):
  if i > S:
    break
  for j in range(K+1):
    z = i + j
    
    if S - z >= 0 and S - z <= K:
      #print(i,j,S-z)
      ANS+=1
    else:
      if S - z <= 0:
      	break
print(ANS)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
L=list(map(int,input().split()))
avg = sum(L)/len(L)
import math
avg_u = math.ceil(avg)
avg_d = math.floor(avg)
ans_u = 0
ans_d = 0
for i in L:
  ans_u += (i - avg_u)**2
  ans_d += (i - ans_d)**2

if ans_u >= ans_d:
  print(ans_d)
else:
  print(ans_u)


Fixed submission:
def pow_k(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2

    return K * x

N=int(input())
L=list(map(int,input().split()))
import sys
ans = sys.maxsize

for i in range(-100,101):
  m_diffs = 0
  for j in range(N):
    m_diffs += pow_k((L[j] - i),2)
  ans = min(ans, m_diffs)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    start_len = sum(A)
    temp_len = sum(A)
    sousa = 0
    if(start_len % 2 == 1):
        sousa += 1
    while(1):
        seikou1 = kazoe(N, A, start_len + sousa, sousa, "+", start_len)
        seikou2 = kazoe(N, A, start_len - sousa, sousa, "-", start_len)
        if(seikou1 == True or seikou2 == True):
            break
        sousa += 2
    print(sousa)
            
            
def kazoe(N,A,temp_len, sousa, mi_pl, start_len):
    if(temp_len == 0):
        return False
    mokuteki = temp_len/2
    temp = 0
    for i in range(N):
        temp += A[i]
        if(temp > mokuteki):
            break
    i1 = i-1
    kouho1 = temp - A[i]
    i2 = i
    kouho2 = temp
    if(mi_pl == "+"):
        if(kouho1 + sousa == mokuteki or start_len - kouho2 + sousa == mokuteki):
            return True
        else:
            return False
    else:
        if(start_len - kouho1 - sousa == mokuteki or kouho2 - sousa == mokuteki):
            return True
        else:
            return False

if __name__ == "__main__":
    main()


Fixed submission:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    start_len = sum(A)
    mokuteki = start_len/2
    temp = 0
    for n in range(N):
        temp += A[n]
        if(temp >= mokuteki):
            break
    n1 = n-1
    kouho1 = temp - A[n]
    n2 = n
    kouho2 = temp
    kouho1_ = start_len - kouho1*2
    kouho2_ = kouho2*2 - start_len
    res = min(kouho1_, kouho2_)
    print(res)
            

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
def main():
  str = input()
  first = str[:2]
  second = str[2:]
  first = change(first)
  second = change(second)
  f_y = 0; s_y = 0;
  f_y = check_y(first)
  s_y = check_y(second)
  if(f_y == 0 and s_y == 0):
    print("AMBIGUOUS")
  elif(f_y == 0 and s_y == 1):
    print("MMYY")
  elif(f_y == 1 and s_y == 0):
    print("YYMM")
  elise:
    print("NA")
    
def change(str):
  if(str[0] == "0"):
    return int(str[1])
  else:
    return int(str)
  
def check_y(num):
  if(num == 0 or num > 12):
    return 1
  else:
    return 0
  
if __name__ == "__main__":
  main()

Fixed submission:
def main():
  str = input()
  first = str[:2]
  second = str[2:]
  first = change(first)
  second = change(second)
  f_y = 0; s_y = 0;
  f_y = check_y(first)
  s_y = check_y(second)
  if(f_y == 0 and s_y == 0):
    print("AMBIGUOUS")
  elif(f_y == 0 and s_y == 1):
    print("MMYY")
  elif(f_y == 1 and s_y == 0):
    print("YYMM")
  else:
    print("NA")
    
def change(str):
  if(str[0] == "0"):
    return int(str[1])
  else:
    return int(str)
  
def check_y(num):
  if(num == 0 or num > 12):
    return 1
  else:
    return 0
  
if __name__ == "__main__":
  main()
Buggy python submission (verdict: Time Limit Exceeded):
k,q = input().split()
k = int(k)
q = int(q)

d = input().split()
for i in range(k):
    d[i] = int(d[i])

for r in range(q):
    n,x,m = input().split()
    n = int(n)
    x = int(x)
    m = int(m)

    dd = [0]*k
    DD = [0]*(k+1)
    for i in range(k):
        dd[i] = (d[i]-1)%m + 1
        DD[i+1] = DD[i] + dd[i]
        
    #最後のこう
    
    alast = x + DD[k]*((n-1)//k) + DD[(n-1)%k]
    kuriagari = alast // m - x//m

#    print([x%m, alast, alast%m, n - kuriagari - 1])
    print (n - 1 - kuriagari)

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

d = input().split()
for i in range(k):
    d[i] = int(d[i]) - 1

import numpy as np
d = np.array(d)

for r in range(q):
    n,x,m = input().split()
    n = int(n)
    x = int(x)
    m = int(m)

    dd = d % m + np.ones(k,dtype="int")
    DD = np.concatenate((np.zeros(1, dtype="int"),np.cumsum(dd) ))
    
    alast = x + DD[k]*((n-1)//k) + DD[(n-1)%k]
    kuriagari = alast // m - x//m

#    print([x%m, alast, alast%m, n - kuriagari - 1])
    print (n - 1 - kuriagari)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8

import sys
import math

import array
import bisect
import collections
from collections import Counter, defaultdict
import fractions
import heapq
import re

sys.setrecursionlimit(1000000)


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

def argsort(l, reverse=False):
    return sorted(range(len(l)), key=lambda i: l[i], reverse=reverse)

def argmin(l):
    return l.index(min(l))

def YESNO(ans, yes="YES", no="NO"):
    print([no, yes][ans])

II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIT = lambda: tuple(MI())
MIS = lambda: input().split()


def get(V, n):
    if n >= len(V):
        yield V
    else:
        yield V[:n]
        for i in range(1, n):
            yield V[:n-i] + V[-i:]
        yield V[-n:]


def main():
    N, K = MI()
    V = MIL()
    ans = 0

    for i in range(K//2, K + 1):
        # 左右からi個まで取る
        for vs in get(V, i):
            # K-i個まで、負を捨てる
            vs = sorted(vs)
            for j, v in enumerate(vs):
                if v >= 0: break
            ans = max(ans, sum(vs[min(K-i, j):]))
    return ans


if __name__ == "__main__":
    print(main())


Fixed submission:
# coding: utf-8

import sys
import math

import array
import bisect
import collections
from collections import Counter, defaultdict
import fractions
import heapq
import re

sys.setrecursionlimit(1000000)


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

def argsort(l, reverse=False):
    return sorted(range(len(l)), key=lambda i: l[i], reverse=reverse)

def argmin(l):
    return l.index(min(l))

def YESNO(ans, yes="YES", no="NO"):
    print([no, yes][ans])

II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIT = lambda: tuple(MI())
MIS = lambda: input().split()


def get(V, n):
    if n >= len(V):
        yield V
    else:
        yield V[:n]
        for i in range(1, n):
            yield V[:n-i] + V[-i:]
        yield V[-n:]


def main():
    N, K = MI()
    V = MIL()
    ans = 0

    for i in range(max(K//2, 1), K + 1):
        # 左右からi個まで取る
        for vs in get(V, i):
            # K-i個まで、負を捨てる
            vs = sorted(vs)
            for j, v in enumerate(vs):
                if v >= 0: break
            ans = max(ans, sum(vs[min(K-i, j):]))
    return ans


if __name__ == "__main__":
    print(main())
Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8

import sys
import math

import array
import bisect
import collections
from collections import Counter, defaultdict
import fractions
import heapq
import re

sys.setrecursionlimit(1000000)


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

def argsort(l, reverse=False):
    return sorted(range(len(l)), key=lambda i: l[i], reverse=reverse)

def argmin(l):
    return l.index(min(l))

def YESNO(ans, yes="YES", no="NO"):
    print([no, yes][ans])

II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIS = lambda: input().split()


def main():
    M, K = MI()

    if M == 1 and K == 1:
        return -1
    if K >= 2**M:
        return -1
    if K == 0:
        return " ".join(map(str, sum([[i, i] for i in range(2**M)], [])))

    ans = []
    ans.append(K)
    for i in range(0, 2**M):
        if i != K:
            ans.append(i)
    ans.append(K)
    for i in range(2**M - 1, -1, -1):
        if i != K:
            ans.append(i)
    return " ".join(map(str, ans))


if __name__ == "__main__":
    print(main())


Fixed submission:
# coding: utf-8

import sys
import math

import array
import bisect
import collections
from collections import Counter, defaultdict
import fractions
import heapq
import re

sys.setrecursionlimit(1000000)


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

def argsort(l, reverse=False):
    return sorted(range(len(l)), key=lambda i: l[i], reverse=reverse)

def argmin(l):
    return l.index(min(l))

def YESNO(ans, yes="YES", no="NO"):
    print([no, yes][ans])

II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIS = lambda: input().split()


def main():
    M, K = MI()

    if M == 1 and K == 1:
        return -1
    if K >= 2**M:
        return -1
    if K == 0:
        ans = []
        for i in range(0, 2**M):
            ans.append(i)
            ans.append(i)
        return " ".join(map(str, ans))

    ans = []
    ans.append(K)
    for i in range(0, 2**M):
        if i != K:
            ans.append(i)
    ans.append(K)
    for i in range(2**M - 1, -1, -1):
        if i != K:
            ans.append(i)
    return " ".join(map(str, ans))


if __name__ == "__main__":
    print(main())
Buggy python submission (verdict: Runtime Error):
# coding: utf-8

import sys
import math

import array
import bisect
import collections
from collections import Counter, defaultdict
import fractions
import heapq
import re

sys.setrecursionlimit(1000000)


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

def argsort(l, reverse=False):
    return sorted(range(len(l)), key=lambda i: l[i], reverse=reverse)

def argmin(l):
    return l.index(min(l))

def YESNO(ans, yes="YES", no="NO"):
    print([no, yes][ans])

II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIS = lambda: input().split()


def prev_multi(num, multi):
    return math.floor(num / multi) * multi

def next_multi(num, multi):
    return math.ceil(num / multi) * multi


def main():
    A, B = MI()
    ans = (math.ceil(B/2) - math.floor(A/2)) % 2
    for i in range(1, math.ceil(math.log2(B)) + 1):
        p = 2**i

        na = next_multi(A, p)
        if (na > B):
            d = 0 if (na / p) % 2 else B - A + 1
        else:
            da = 0 if (na / p) % 2 else na - A
            pb = prev_multi(B, p)
            db = 0 if (pb / p) % 2 == 0 else B - pb + 1
            d = da + db
        ans += d % 2 * p

    return ans

if __name__ == "__main__":
    print(main())


Fixed submission:
# coding: utf-8

import sys
import math

import array
import bisect
import collections
from collections import Counter, defaultdict
import fractions
import heapq
import re

sys.setrecursionlimit(1000000)


def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

def argsort(l, reverse=False):
    return sorted(range(len(l)), key=lambda i: l[i], reverse=reverse)

def argmin(l):
    return l.index(min(l))

def YESNO(ans, yes="YES", no="NO"):
    print([no, yes][ans])

II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIS = lambda: input().split()


def prev_multi(num, multi):
    return math.floor(num / multi) * multi

def next_multi(num, multi):
    return math.ceil(num / multi) * multi


def main():
    A, B = MI()
    if B == 0: return 0
    ans = (math.ceil(B/2) - math.floor(A/2)) % 2
    for i in range(1, math.ceil(math.log2(B)) + 1):
        p = 2**i

        na = next_multi(A, p)
        if (na > B):
            d = 0 if (na / p) % 2 else B - A + 1
        else:
            da = 0 if (na / p) % 2 else na - A
            pb = prev_multi(B, p)
            db = 0 if (pb / p) % 2 == 0 else B - pb + 1
            d = da + db
        ans += d % 2 * p

    return ans

if __name__ == "__main__":
    print(main())
Buggy python submission (verdict: Runtime Error):
N=input()
print(sum(map(int, input().split()))-N)

Fixed submission:
N=int(input())
print(sum(map(int, input().split()))-N)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
t = 100 * N + 1800 * M
total = 0
i = 1
p = 1 / 2**M
while True:
    d = i * (1-p)**(i-1) * p * t
    total += d
    if d < 0.001:
        break
print(total)

Fixed submission:
N, M = map(int, input().split(" "))
t = 100 * N + 1800 * M
print(t * (2**M))
Buggy python submission (verdict: Runtime Error):
print([NO,YES][input().strip()[::-1]==input().strip()])

Fixed submission:
print(["NO","YES"][input().strip()[::-1]==input().strip()])
Buggy python submission (verdict: Runtime Error):
s=input()
print(s[0]+(len(s)-2)+s[-1])

Fixed submission:
s=input()
print(s[0]+str(len(s)-2)+s[-1])
Buggy python submission (verdict: Runtime Error):
# coding: utf-8

import collections


class Graph(object):
    def __init__(self, N):
        self.N = N
        self.paths = collections.defaultdict(set)

    def path(self, n1, n2):
        self.paths[n1].add(n2)
        self.paths[n2].add(n1)

    def dfs(self, n, f):
        # fからNへの最短経路を探す
        if n == self.N:
            return [n]
        for nn in self.paths[n]:
            if nn != f:
                path = self.dfs(nn, n)
                if path is not None:
                    path.append(n)
                    return path
        return None

    def region(self, start, block, f):
        # startからblockを経由せず行ける範囲のnode数
        s = 1
        for nn in self.paths[start]:
            if nn != f and nn != block:
                s += self.region(nn, block, start)
        return s


def main():
    N = int(input())
    graph = Graph(N)
    for i in range(N-1):
        n1, n2 = map(int, input().split())
        graph.path(n1, n2)
    path = graph.dfs(1, None)
    l = len(path)
    fb = path[l // 2]
    sb = path[l // 2 - 1]
    fr = graph.region(1, sb, None)
    sr = graph.region(N, fb, None)
    # print(fr)
    # print(sr)
    if fr > sr:
        print("Fennec")
    else:
        print("Snuke")


main()


Fixed submission:
# coding: utf-8


import sys
sys.setrecursionlimit(int(1e6))


class Graph(object):
    def __init__(self, N):
        self.N = N
        self.paths = [None] * (N + 1)
        for i in range(1, N + 1):
            self.paths[i] = set()

    def path(self, n1, n2):
        self.paths[n1].add(n2)
        self.paths[n2].add(n1)

    def dfs(self, n, f):
        # fからNへの最短経路を探す
        if n == self.N:
            return [n]
        for nn in self.paths[n]:
            if nn != f:
                path = self.dfs(nn, n)
                if path is not None:
                    path.append(n)
                    return path
        return None

    def region(self, start, block, f):
        # startからblockを経由せず行ける範囲のnode数
        s = 1
        for nn in self.paths[start]:
            if nn != f and nn != block:
                s += self.region(nn, block, start)
        return s


def main():
    N = int(input())
    graph = Graph(N)
    for i in range(N-1):
        n1, n2 = map(int, input().split())
        graph.path(n1, n2)
    path = graph.dfs(1, None)
    l = len(path)
    fb = path[l // 2]
    sb = path[l // 2 - 1]
    fr = graph.region(1, sb, None)
    sr = graph.region(N, fb, None)
    # print(fr)
    # print(sr)
    if fr > sr:
        print("Fennec")
    else:
        print("Snuke")


main()
Buggy python submission (verdict: Runtime Error):
# coding: utf-8

import collections

def dfs(i):
    if visited[i] == 1:
        return
    visited[i] = 1
    for j in speakers[i]:
        for k in langs[j]:
            dfs(k)


N, M = map(int, input().split())

langs = collections.defaultdict(list)
speakers = [[] for _ in range(N)]

for i in range(N):
    ls = list(map(int, input().split()))
    for j in range(1, ls[0] + 1):
        langs[ls[j]-1].append(i)
        speakers[i].append(ls[j]-1)

visited = [0] * N
dfs(0)

if 0 not in visited:
    print("YES")
else:
    print("NO")


Fixed submission:
# coding: utf-8

import collections
import sys
sys.setrecursionlimit(100000)

def dfs(i):
    if visited[i] == 1:
        return
    visited[i] = 1
    for j in speakers[i]:
        if used_lang[j] == 1:
            continue
        used_lang[j] = 1
        for k in langs[j]:
            dfs(k)


N, M = map(int, input().split())

langs = collections.defaultdict(list)
speakers = [[] for _ in range(N)]

for i in range(N):
    ls = list(map(int, input().split()))
    for j in range(1, ls[0] + 1):
        langs[ls[j]-1].append(i)
        speakers[i].append(ls[j]-1)

visited = [0] * N
used_lang = [0] * M
dfs(0)

if 0 not in visited:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
# coding: utf-8

import math
import fractions
import heapq
import collections
import re
import array
import bisect

from collections import Counter, defaultdict


II = lambda: int(input())
MI = lambda: map(int, input().split())


def main():
    N, x = MI()
    if x in [1, 2 * N - 1]:
        print("No")
        return
    print("Yes")
    s = set([i for i in range(1, 2 * N)])
    a = [None] * (2 * N - 1)
    MED = N - 1
    if x == 2 * N - 2:
        l = (x - 1, x, x + 1, x - 2)
        a[MED - 1:MED + 3] = l
        for i in l:
            s.remove(i)
    else:
        l = x + 1, x, x - 1, x + 2
        a[MED - 1:MED + 3] = l
        for i in l:
            s.remove(i)
    for i in range(2 * N - 1):
        if a[i] is None:
            a[i] = s.pop()
    for i in range(2 * N - 1):
        print(a[i])


if __name__ == "__main__":
    main()


Fixed submission:
# coding: utf-8

import math
import fractions
import heapq
import collections
import re
import array
import bisect

from collections import Counter, defaultdict


II = lambda: int(input())
MI = lambda: map(int, input().split())


def main():
    N, x = MI()
    if x in [1, 2 * N - 1]:
        print("No")
        return
    print("Yes")
    if N == 2:
        print("1\n2\n3")
        return
    s = set([i for i in range(1, 2 * N)])
    a = [None] * (2 * N - 1)
    MED = N - 1
    if x == 2 * N - 2:
        l = (x - 1, x, x + 1, x - 2)
        a[MED - 1:MED + 3] = l
        for i in l:
            s.remove(i)
    else:
        l = x + 1, x, x - 1, x + 2
        a[MED - 1:MED + 3] = l
        for i in l:
            s.remove(i)
    for i in range(2 * N - 1):
        if a[i] is None:
            a[i] = s.pop()
    for i in range(2 * N - 1):
        print(a[i])


if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
o = "Yes"
for v in collections.Counter(input().strip()).values():
    if v % 2 != 0: o = "No"
print(o)

Fixed submission:
import collections
o = "Yes"
for v in collections.Counter(input().strip()).values():
    if v % 2 != 0: o = "No"
print(o)
Buggy python submission (verdict: Runtime Error):
# coding: utf-8

from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
from __future__ import absolute_import
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect

def eat_all(al):
    for i in range(len(al)):
        al[i] -= 1
    while True:
        if al[0] == 0:
            al.pop(0)
        else:
            break
    return al

def step(turn, a_list):
    if len(a_list) == 1:
        if a_list[0] % 2 == 0:
            return turn
        else:
            return (not turn)
    if a_list[-1] % 2 != 0:
        a_list.pop()
        return step(not turn, a_list)
    else:
        a_list = eat_all(a_list)
        a_list.pop()
        if len(a_list) == 0:
            return turn
        return step(turn, a_list)

n = int(input())
a_list = [None] * n
inputs = input().split(" ")
for i in range(n):
    a_list[i] = int(inputs[i])
a_list.sort()
win = step(1, a_list)
if win == 1:
    print("First")
else:
    print("Second")



Fixed submission:
# coding: utf-8

from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
from __future__ import absolute_import
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect


a, b = map(int, input().split(" "))

p = "Positive"
n = "Negative"
z = "Zero"

if a > 0:
    print(p)
elif a == 0 or b == 0:
        print(z)
else:
    # a < 0
    if b >= 0:
        print(z)
    else:
        # a < 0, b < 0
        if (b - a) % 2 == 0:
            print(n)
        else:
            print(p)