Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
K,S=map(int,input().split())
ans = 0
for X in range(K+1):
  for Y in range(K+1):
    Z = S-X-Y   
      if 0<= Z <= K:
        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):
    Z = S-X-Y   
    if 0<= Z <= K:
      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):
    Z = S-X-Y   
    if 0<= Z <= K:
      ans += 1
    
print(ans)
Buggy python submission (verdict: Runtime Error):
N=int(input())
a=1
while N-a>=a:
    print(a)
    b=N-a
    N-=a
    a+=1 
print(b)

Fixed submission:
N=int(input())
a=1
cnt=1
while cnt<=N:
  a+=1
  cnt+=a
for i in range(a):
  if i+1!=cnt-N:
    print(i+1)
Buggy python submission (verdict: Runtime Error):
if __name__ == "__main__":
    N = input()
    for x in range(0, 100):
        y = N - 4 * x
        if y % 7 == 0:
            print ("Yes")
            exit(0)
    print ("No")

Fixed submission:
if __name__ == "__main__":
    N = int(input())
    for x in range(0, 100):
        y = N - 4 * x
        if y < 0:
            break
        if y % 7 == 0:
            print ("Yes")
            exit(0)
    print ("No")
Buggy python submission (verdict: Runtime Error):
if __name__ == "__main__":
    N = input()
    res = 0
    for x in range(N):
        a,b = map(int, input().split())
        res += b - a + 1
    print (res)


Fixed submission:
if __name__ == "__main__":
    N = int(input())
    res = 0
    for x in range(N):
        a,b = map(int, input().split())
        res += b - a + 1
    print (res)
Buggy python submission (verdict: Runtime Error):
if __name__ == "__main__":
    K = int(input())
    if (K == 0):
        print (2)
        print (0, 0)
        exit()
    if (K == 1):
        print (2)
        print (2, 0)

    if (K <= 50):
        print (K)
        res = []
        for x in range(K):
            res.append(x + 1)
        print (" ".join(map(str, res)))
        exit()
    assert(False)


Fixed submission:
if __name__ == "__main__":
    K = int(input())
    N = 50
    result = list(range(N))
    for x in range(N):
        result[x] += K // N
    K %= N

    for x in range(K):
        result[x] += N + 1
        for i in range(N):
            result[i] -= 1
    print (len(result))
    print (" ".join(map(str, result)))

Buggy python submission (verdict: Runtime Error):
if __name__ == "__main__":
    K = int(input())
    if (K == 0):
        print (1)
        print (0)
        exit()
    if (K <= 50):
        print (K)
        res = []
        for x in range(K):
            res.append(x + 1)
        print (" ".join(map(str, res)))
        exit()
    if (K <= 10 ** 16 + 1000):
        print (1)
        print (K)
        exit()
    assert(False)


Fixed submission:
if __name__ == "__main__":
    K = int(input())
    N = 50
    result = list(range(N))
    for x in range(N):
        result[x] += K // N
    K %= N

    for x in range(K):
        result[x] += N + 1
        for i in range(N):
            result[i] -= 1
    print (len(result))
    print (" ".join(map(str, result)))
Buggy python submission (verdict: Runtime Error):
import sys
if __name__ == "__main__":
    N = int(input())
    evidences = list(map(int, input().split()))
    evidences = list(sorted(evidences))
    unique_evidence = set(evidences)
    if (evidences[-1] - evidences[0] > 1):
        print ("No")
        sys.exit()
    if (len(unique_evidence) == 1):
        group = evidences[0];
        # all unique
        if (group == N - 1):
            print ("Yes")
            sys.exit()
        if (N - 2 * group < 0):
            print ("No")
            sys.exit()
        print ("Yes")
        sys.exit()
    # evidences[-1] - evidences[0] > 1
    min_val = min(evidences)
    max_val = max(evidences)

    min_val_cnt = 0
    max_val_cnt = 0
    for val in evidences:
        if (val == min_val):
            min_val_cnt += 1
        else:
            max_val_cnt += 1
    # violate not unique
    if (max_val_cnt <= 1):
        print ("No")
        sys.exit()
    #rest cat
    rest = N
    rest -= min_val_cnt

    min_group = min_val_cnt + 1
    max_group = min_val_cnt + (max_val_cnt // 2)
    if min_group <= evidences[-1] and evidences <= max_group:
        print ("Yes")
        sys.exit()
    print ("No")


Fixed submission:
import sys
if __name__ == "__main__":
    N = int(input())
    evidences = list(map(int, input().split()))
    evidences = list(sorted(evidences))
    unique_evidence = set(evidences)
    if (evidences[-1] - evidences[0] > 1):
        print ("No")
        sys.exit()
    if (len(unique_evidence) == 1):
        group = evidences[0];
        # all unique
        if (group == N - 1):
            print ("Yes")
            sys.exit()
        if (N - 2 * group < 0):
            print ("No")
            sys.exit()
        print ("Yes")
        sys.exit()
    # evidences[-1] - evidences[0] > 1
    min_val = min(evidences)
    max_val = max(evidences)

    min_val_cnt = 0
    max_val_cnt = 0
    for val in evidences:
        if (val == min_val):
            min_val_cnt += 1
        else:
            max_val_cnt += 1
    # violate not unique
    if (max_val_cnt <= 1):
        print ("No")
        sys.exit()
    #rest cat
    rest = N
    rest -= min_val_cnt

    min_group = min_val_cnt + 1
    max_group = min_val_cnt + (max_val_cnt // 2)
    if min_group <= evidences[-1] and evidences[-1] <= max_group:
        print ("Yes")
        sys.exit()
    print ("No")
Buggy python submission (verdict: Runtime Error):
if __name__ == "__main__":
    a,b,c = input().split()
    if (b == '+'):
        print (int(a) + int(b))
    else:
        print (int(a) - int(b))


Fixed submission:
if __name__ == "__main__":
    a,b,c = input().split()
    if (b == '+'):
        print (int(a) + int(c))
    else:
        print (int(a) - int(c))
Buggy python submission (verdict: Runtime Error):

    N = int(input())
    T = list(map(int, input().split()))
    M = int(input())
    data = []
    for x in range(M):
        p,x = map(int, input().split())
        p -= 1
        data.append([p, x])
    result = 2 ** 60
    for p,x in data:
        res = 0
        for i,t in enumerate(T):
            if (i == p):
                res += x
            else:
                res += t
        print (res)

Fixed submission:
if __name__ == "__main__":
    N = int(input())
    T = list(map(int, input().split()))
    M = int(input())
    data = []
    for x in range(M):
        p,x = map(int, input().split())
        p -= 1
        data.append([p, x])
    result = 2 ** 60
    for p,x in data:
        res = 0
        for i,t in enumerate(T):
            if (i == p):
                res += x
            else:
                res += t
        print (res)
Buggy python submission (verdict: Runtime Error):
import math
if __name__ == "__main__":
    A,B,C,D = map(int, input().split())
    A -= C
    B -= D
    W = abs(A)
    H = abs(B)
    if W == 0 or H == 0:
        print (0)
        exit()
    res = W + H - 1
    g = math.gcd(W, H)
    print (res - g + 1)

Fixed submission:
import fractions
if __name__ == "__main__":
    A, B, C, D = map(int, input().split())
    A -= C
    B -= D
    W = abs(A)
    H = abs(B)
    if W == 0 or H == 0:
        print(0)
        exit()
    res = W + H - 1
    g = fractions.gcd(W, H)
    print(res - g + 1)

Buggy python submission (verdict: Runtime Error):
import math
if __name__ == "__main__":
    A,B,C,D = map(int, input().split())
    A -= C
    B -= D
    W = abs(A)
    H = abs(B)
    if W == 0 or H == 0:
        print (0)
        exit()
    res = W + H - 1
    g = math.gcd(W, H)
    print (res - g + 1)
    
    

Fixed submission:
import fractions
if __name__ == "__main__":
    A, B, C, D = map(int, input().split())
    A -= C
    B -= D
    W = abs(A)
    H = abs(B)
    if W == 0 or H == 0:
        print(0)
        exit()
    res = W + H - 1
    g = fractions.gcd(W, H)
    print(res - g + 1)
Buggy python submission (verdict: Time Limit Exceeded):

from functools import *
import sys
sys.setrecursionlimit(100000)

def acinput():
    return list(map(int, input().split(" ")))


N=input()
a=acinput()

if min(a)==0:
    print(0)
    sys.exit()
res=1

for sa in a:
    res*=sa
    if res>10**18:
        res=-1
        
    
print(res)


Fixed submission:

from functools import *
import sys
sys.setrecursionlimit(100000)

def acinput():
    return list(map(int, input().split(" ")))


N=input()
a=acinput()

if min(a)==0:
    print(0)
    sys.exit()
res=1

for sa in a:
    res*=sa
    if res>10**18:
        res=-1
        break
        
    
print(res)

Buggy python submission (verdict: Time Limit Exceeded):

import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)

def acinput():
    return list(map(int, input().split(" ")))


N=input()
a=sorted(acinput())

res=1

for sa in a:
    res*=sa
    if res>10**18:
        res=-1
        
    
print(res)


Fixed submission:

from functools import *
import sys
sys.setrecursionlimit(100000)

def acinput():
    return list(map(int, input().split(" ")))


N=input()
a=acinput()

if min(a)==0:
    print(0)
    sys.exit()
res=1

for sa in a:
    res*=sa
    if res>10**18:
        res=-1
        break
        
    
print(res)
Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
S=list(input())



n=S.count("R")*S.count("G")*S.count("B")
count=0
for l in range(N-2):
    for r in range(l+2,N):
        m=(l+r)/2
        if m%1.0!=0:
            continue
        m=int(m)
        tmp =[S[l], S[r], S[m]]
        if len(set(tmp))==3:
            count+=1
            
            

print(n-count)
            



Fixed submission:
N=int(input())
S=list(input())



n=S.count("R")*S.count("G")*S.count("B")
count=0
for l in range(N-2):
    for r in range(l+2,N):
        m=(l+r)/2
        if m%1.0!=0:
            continue
        m=int(m)
        tmp =[S[l], S[r], S[m]]
        if len(set(tmp))==3:
            count+=1
            
            

print(n-count)
Buggy python submission (verdict: Time Limit Exceeded):

import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline




def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())

directions=np.array([[1,0],[0,1],[-1,0],[0,-1]])
directions = list(map(np.array, directions))

mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact



def serch(x, count):
    #print("top", x, count)
            

    for d in directions:
        nx = d+x
        #print(nx)
        if np.all(0 <= nx) and np.all(nx < (H, W)):
            if field[nx[0]][nx[1]] == "E":
                count += 1 
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)  
                continue
            if field[nx[0]][nx[1]] == "#":
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)    
                 
    return count

N,X,Y=acinput()



dist=[[-1 for j in range(N+1) ] for i in range(N+1)]


for i in range(1,N):
    for j in range(i,N+1):
        a=np.abs(i-X)
        b=np.abs(j-Y)
        dist[i][j]=min(j-i,a+b+1)
        

res=[0]*(N+1)
for i in range(N):
    for j in range(i, N+1):
        res[dist[i][j]]+=1
        

for i in range(1,N):
    print(res[i])

Fixed submission:

#import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline




def acinput():
    return list(map(int, input().split(" ")))



N,X,Y=acinput()



dist=[[-1 for j in range(N+1) ] for i in range(N+1)]


for i in range(1,N):
    for j in range(i,N+1):
        a=abs(i-X)
        b=abs(j-Y)
        dist[i][j]=min(j-i,a+b+1)
        

res=[0]*(N+1)
for i in range(N):
    for j in range(i, N+1):
        res[dist[i][j]]+=1
        

for i in range(1,N):
    print(res[i])

#print(np.array(dist))
#print(res)
Buggy python submission (verdict: Runtime Error):

import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)



def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())

directions=np.array([[1,0],[0,1],[-1,0],[0,-1]])
directions = list(map(np.array, directions))

mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact



def serch(x, count):
    #print("top", x, count)
            

    for d in directions:
        nx = d+x
        #print(nx)
        if np.all(0 <= nx) and np.all(nx < (H, W)):
            if field[nx[0]][nx[1]] == "E":
                count += 1 
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)  
                continue
            if field[nx[0]][nx[1]] == "#":
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)    
                 
    return count


def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X % n)
    return str(X % n)

N,K=acinput()
s=Base_10_to_n(N,K)
print(len(s))


Fixed submission:

import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)



def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())

directions=np.array([[1,0],[0,1],[-1,0],[0,-1]])
directions = list(map(np.array, directions))

mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact



def serch(x, count):
    #print("top", x, count)
            

    for d in directions:
        nx = d+x
        #print(nx)
        if np.all(0 <= nx) and np.all(nx < (H, W)):
            if field[nx[0]][nx[1]] == "E":
                count += 1 
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)  
                continue
            if field[nx[0]][nx[1]] == "#":
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)    
                 
    return count


def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X % n)
    return str(X % n)

N,K=acinput()
s=Base_10_to_n(N,K)
print(len(s))
Buggy python submission (verdict: Runtime Error):

import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)



def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())

directions=np.array([[1,0],[0,1],[-1,0],[0,-1]])
directions = list(map(np.array, directions))

mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact



def serch(x, count):
    #print("top", x, count)
            

    for d in directions:
        nx = d+x
        #print(nx)
        if np.all(0 <= nx) and np.all(nx < (H, W)):
            if field[nx[0]][nx[1]] == "E":
                count += 1 
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)  
                continue
            if field[nx[0]][nx[1]] == "#":
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)    
                 
    return count

N=int(input())
X=np.array(acinput())

u = round(np.mean(X))


res=0

print(int(np.sum((u-X)**2)))


Fixed submission:

import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)



def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())

directions=np.array([[1,0],[0,1],[-1,0],[0,-1]])
directions = list(map(np.array, directions))

mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact



def serch(x, count):
    #print("top", x, count)
            

    for d in directions:
        nx = d+x
        #print(nx)
        if np.all(0 <= nx) and np.all(nx < (H, W)):
            if field[nx[0]][nx[1]] == "E":
                count += 1 
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)  
                continue
            if field[nx[0]][nx[1]] == "#":
                field[nx[0]][nx[1]] = "V"
                count = serch(nx, count)    
                 
    return count

N=int(input())
X=np.array(acinput())

u = round(np.mean(X))


res=0

print(int(np.sum((u-X)**2)))
Buggy python submission (verdict: Time Limit Exceeded):

import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)



def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())


#N=list(map(int,list(input())[::-1]))
N = list(map(int, list(input())))

dp=[[-1,-1] for i in range(len(N)+1)]
dp[0]=[0,1]
b=0
N.insert(0,0)

for i in range(1,len(N)):
    up = 10-N[i]
    dp[i][0]=min(dp[i-1][0]+N[i],dp[i-1][1]+up)
    dp[i][1] = min(dp[i-1][0]+N[i]+1, dp[i-1][1]+up-1)
   

print(dp[-1][0])


Fixed submission:
N = list(map(int, list(input())))

dp=[[-1,-1] for i in range(len(N)+1)]
dp[0]=[0,1]
b=0
N.insert(0,0)

for i in range(1,len(N)):
    up = 10-N[i]
    dp[i][0]=min(dp[i-1][0]+N[i],dp[i-1][1]+up)
    dp[i][1] = min(dp[i-1][0]+N[i]+1, dp[i-1][1]+up-1)
   

print(dp[-1][0])
Buggy python submission (verdict: Time Limit Exceeded):
def acinput():
    return list(map(int, input().split(" ")))


import numpy as np

N,K=acinput()
p=np.array(acinput())


res=0

for i in range(N-K+1):
    tmp = (p[i:(i+K)]+1)/2
    res = max(res, np.sum(tmp))


print(res)


Fixed submission:
def acinput():
    return list(map(int, input().split(" ")))


import numpy as np

N,K=acinput()
p=np.array(acinput())

pp=(p+1)/2

pp=np.insert(pp,0,0)
p_cs=np.cumsum(pp)

res=0

for i in range(K,N+1):
    res=max(res,(p_cs[i]-p_cs[i-K]))
    #tmp = (p[i:(i+K)]+1)/2
    #res = max(res, np.sum(tmp))


print(res)
Buggy python submission (verdict: Runtime Error):
def acinput():
    return list(map(int, input().split(" ")))



import numpy as np
#from functools import reduce
import matha
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
import copy
import functools

N,M=acinput()

if N==M:
    print("Yes")
else:
    print("No")


Fixed submission:
def acinput():
    return list(map(int, input().split(" ")))


N,M=acinput()

if N==M:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

def acinput():
    return list(map(int, input().split(" ")))


a,b=acinput()

print(lcm(a,b))


Fixed submission:
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(x, y):
    return (x * y) //gcd(x, y)

def acinput():
    return list(map(int, input().split(" ")))


a,b=acinput()

print(lcm(a,b))
Buggy python submission (verdict: Runtime Error):

def acinput():
    return list(map(int, input().split(" ")))


def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
            #print(result)
            result%=(10**9+7)

    return result


X,Y=acinput()

import numpy as np
from numpy.linalg import solve
 

x=solve([[1,2],[2,1]],[X,Y])

#print(x)

if np.all(x%1.0==0) and np.all(x>=0):
    print(cmb(int(np.sum(x)),int(np.min(x)),10**9+7))

else:
    print(0)



Fixed submission:

def acinput():
    return list(map(int, input().split(" ")))


def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
            #print(result)
            result%=(10**9+7)

    return result


X,Y=acinput()

import numpy as np
from numpy.linalg import solve
 

x=solve([[1,2],[2,1]],[X,Y])

#print(x)

if np.all(x%1.0==0) and np.all(x>=0):
    print(cmb(int(np.sum(x)),int(np.min(x))))
    #print(cmb(int(np.sum(x)),int(np.min(x)),10**9+7))

else:
    print(0)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)

import numpy as np

def acinput():
    return list(map(int, input().split(" ")))


S=input()
d=["Sunny","Cloudy","Rainy"]

print(d[d.index(S)+1])




Fixed submission:


def acinput():
    return list(map(int, input().split(" ")))


S=input()
d=["Sunny","Cloudy","Rainy","Sunny"]

print(d[d.index(S)+1])
Buggy python submission (verdict: Runtime Error):

nCr = {}


def cmb(n, r):
    if r == 0 or r == n:
        return 1
    if r == 1:
        return n
    if (n, r) in nCr:
        return nCr[(n, r)]
    nCr[(n, r)] = cmb(n-1, r) + cmb(n-1, r-1)
    nCr[(n, r)] = nCr[(n, r)]
    return nCr[(n, r)]


def acinput():
    return list(map(int, input().split(" ")))


N = int(input())
dct = {}

for i in range(N):
    tmp = input()
    #print("head   ",tmp)
    tmp = "".join(sorted(tmp))
    try:
        dct[tmp] += 1
    except:

        dct[tmp] = 1


res = 0
for sdct in dct:
    if dct[sdct] > 1:
        res += cmb(dct[sdct], 2)

print(res)



Fixed submission:

import sys

sys.setrecursionlimit(1000000)

nCr = {}


def cmb(n, r):
    if r == 0 or r == n:
        return 1
    if r == 1:
        return n
    if (n, r) in nCr:
        return nCr[(n, r)]
    nCr[(n, r)] = cmb(n-1, r) + cmb(n-1, r-1)
    nCr[(n, r)] = nCr[(n, r)]
    return nCr[(n, r)]


def acinput():
    return list(map(int, input().split(" ")))


N = int(input())
dct = {}

for i in range(N):
    tmp = input()
    #print("head   ",tmp)
    tmp = "".join(sorted(tmp))
    try:
        dct[tmp] += 1
    except:

        dct[tmp] = 1


res = 0
for sdct in dct:
    if dct[sdct] > 1:
        res += cmb(dct[sdct], 2)

print(res)


#print(dct)