Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
def input():
    return sys.stdin.readline()[:-1]

S = list(input())
K = int(input())
N = len(S)
ans = 0
last_same = False
if N==1:
    print(K//2)
    exit()
for i in range(1,N):
    if S[i]!=S[i-1]:
        break
else:
    print(N*K//2)
    exit()
pre = S[0]
p = False
for i in range(1,N):
    if p:
        pre = S[i]
        p = False
        continue
    s = S[i]
    if pre==s:
        ans += 1
        p = True
        if i==N-1:
            last_same = True
        elif i==N-2:
            if S[-1]==S[-2]:
                last_3_same = True
    pre = s

l_same = False
if not last_same:
    if not S[0]==S[1]:
        if S[0]==S[-1]:
            ans += 1
            l_same = True
    elif S[1]==S[2]:
        if last_3_same:
            ans += 1
            l_same = True

ANS = ans*K
if l_same:
    ANS -= 1
print(ANS)

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]

S = list(input())
K = int(input())
N = len(S)
ans = 0
last_same = False
if N==1:
    print(K//2)
    exit()
for i in range(1,N):
    if S[i]!=S[i-1]:
        break
else:
    print(N*K//2)
    exit()
p = False

#前からと後ろからで連続しているかずをかぞえあげる.
pre_num = 0
l_num = 1
if S[0]==S[-1]:
    pre_num = 1
    for i in range(1,N-1):
        if S[i]==S[i-1]:
            pre_num += 1
        else:
            break
    l_num = 1
    for i in range(N-1,0,-1):
        if S[i]==S[i-1]:
            l_num += 1
        else:
            break

for i in range(pre_num,N-l_num):
    if p:
        p = False
        continue
    if S[i]==S[i+1]:
        ans += 1
        p = True

ANS = (pre_num//2) + ans*K + ((pre_num+l_num)//2)*(K-1) + (l_num//2)

print(ANS)

Buggy python submission (verdict: Runtime Error):
import sys
def input():
    return sys.stdin.readline()[:-1]

S = list(input())
K = int(input())

N = len(S)
ans = 0
last_same = False
if S[-1]!=S[-2]:
    if S[0]==S[-1]:
        ans += 1
        last_same = True
pre = S[0]
p = False
for i in range(1,N):
    if p:
        pre = S[i]
        p = False
        continue
    s = S[i]
    if pre==s:
        ans += 1
        p = True
    pre = s
ANS = ans*K
if last_same:
    ANS -= 1
print(ANS)

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]

S = list(input())
K = int(input())
N = len(S)
ans = 0
last_same = False
if N==1:
    print(K//2)
    exit()
for i in range(1,N):
    if S[i]!=S[i-1]:
        break
else:
    print(N*K//2)
    exit()
p = False

#前からと後ろからで連続しているかずをかぞえあげる.
pre_num = 0
l_num = 1
if S[0]==S[-1]:
    pre_num = 1
    for i in range(1,N-1):
        if S[i]==S[i-1]:
            pre_num += 1
        else:
            break
    l_num = 1
    for i in range(N-1,0,-1):
        if S[i]==S[i-1]:
            l_num += 1
        else:
            break

for i in range(pre_num,N-l_num):
    if p:
        p = False
        continue
    if S[i]==S[i+1]:
        ans += 1
        p = True

ANS = (pre_num//2) + ans*K + ((pre_num+l_num)//2)*(K-1) + (l_num//2)

print(ANS)
Buggy python submission (verdict: Runtime Error):
import sys
def input():
    return sys.stdin.readline()[:-1]

N = int(input())
S = list(input())

if S[0]!='B' or S[-1]!='B':
    print(0)
    exit()

mod = 10**9 + 7
cnt_l = 1
cnt_r = 0
pre_s = 'B'
pre_d = 1 #1がleft
ans = 1

for i in range(1,N*2):
    s = S[i]

    if pre_s==s:
        if pre_d==1:
            d = 0
            ans *= cnt_l - cnt_r #ここまでに出てきたLeftの総数 - ここまでに出てきたrightの総数
            cnt_r += 1
        else:
            d = 1
            cnt_l += 1
    else:
        if pre_d==1:
            d = 1
            cnt_l += 1
        else:
            d = 0
            ans *= cnt_l - cnt_r #ここまでに出てきたLeftの総数 - ここまでに出てきたrightの総数
            cnt_r += 1
    pre_s = s
    pre_d = d

for i in range(1,N+1):
    ans *= i
    ans %= mod
if cnt_l!=N:
    print(0)
    exit()

print(ans)

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]
M,D = map(int,input().split(' '))

cnt = 0
for i in range(1,M+1):
    for j in range(1,D+1):
        dd = j // 10
        d  = j % 10
        if dd>=2 and d>=2 and d*dd==i:
            cnt += 1
print(cnt)

Buggy python submission (verdict: Runtime Error):
import sys
def input():
    return sys.stdin.readline()[:-1]

N = int(input())
S = list(input())

if S[0]!='B' or S[-1]!='B':
    print(0)
    exit()

mod = 10**9 + 7
cnt_l = 1
cnt_r = 0
pre_s = 'B'
pre_d = 1 #1がleft
ans = 1

for i in range(1,N*2):
    s = S[i]

    if pre_s==s:
        if pre_d==1:
            d = 0
            ans *= cnt_l - cnt_r #ここまでに出てきたLeftの総数 - ここまでに出てきたrightの総数
            cnt_r += 1
        else:
            d = 1
            cnt_l += 1
    else:
        if pre_d==1:
            d = 1
            cnt_l += 1
        else:
            d = 0
            ans *= cnt_l - cnt_r #ここまでに出てきたLeftの総数 - ここまでに出てきたrightの総数
            cnt_r += 1
    pre_s = s
    pre_d = d

for i in range(1,N+1):
    ans *= i
    ans %= mod
if cnt_l!=N:
    print(0)
    exit()

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]
M,D = map(int,input().split(' '))

cnt = 0
for i in range(1,M+1):
    for j in range(1,D+1):
        dd = j // 10
        d  = j % 10
        if dd>=2 and d>=2 and d*dd==i:
            cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
import math
a,b,c,d = map(int,input().split(' '))

def lcm(x, y):
    return (x * y) // math.gcd(x, y)
    
l_c = int((a-1)/c)
l_d = int((a-1)/d)
l_c_d = int((a-1)/lcm(c, d))

l_ans = a - 1 - (l_c + l_d - l_c_d)


g_c = int(b/c)
g_d = int(b/d)
g_c_d = int(b/lcm(c, d))
g_ans = b - (g_c + g_d - g_c_d)

print(g_ans - l_ans)


Fixed submission:
a,b,c,d = map(int,input().split(' '))

def gcd(m,n):
    x = max(m,n)
    y = min(m,n)
    if x%y == 0:
        return y
    else:
        while x%y != 0:
            z = x%y
            x = y
            y = z
        else:
            return z

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

l_c = (a-1)//c
l_d = (a-1)//d
l_c_d = (a-1)//lcm(c, d)

l_ans = a - 1 - (l_c + l_d - l_c_d)


g_c = b//c
g_d = b//d
g_c_d = b//lcm(c, d)
g_ans = b - (g_c + g_d - g_c_d)

print(g_ans - l_ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
l = [None]*N
s = []
for i in range(N):
    k = list(map(int,input().split()))
    if k[0]==k[1]:
        s.append(k)
    else:
        l[i] = k

if len(s)>1:
    print("No")
else:
    l = sorted(l, key=lambda x: x[1])
    cnt = 0
    if len(s)==1:
        cnt += s[0][1]

    flag = True
    for j in l:
        if j==None:
            continue
        else:
            cnt += j[0]
        if cnt>j[1]:
            print("No")
            flag = False
            break
    if flag:
        print("Yes")

Fixed submission:
N = int(input())
l = [None]*N
s = []
for i in range(N):
    k = list(map(int,input().split()))
    if k[0]==k[1]:
        s.append(k)
        l[i] = [0,0]
    else:
        l[i] = k

if len(s)>1:
    print("No")
else:
    l = sorted(l, key=lambda x: x[1])
    cnt = 0
    if len(s)==1:
        cnt += s[0][1]

    flag = True
    for j in l:
        if j==[0,0]:
            continue
        else:
            cnt += j[0]
        if cnt>j[1]:
            print("No")
            flag = False
            break
    if flag:
        print("Yes")

Buggy python submission (verdict: Runtime Error):
N = int(input())
l = [None]*N
s = []
for i in range(N):
    k = list(map(int,input().split()))
    if k[0]==k[1]:
        s.append(k)
    else:
        l[i] = k

if len(s)>1:
    print("No")
else:
    l = sorted(l, key=lambda x: x[1])
    cnt = 0
    if len(k)==1:
        cnt += s[0][1]

    flag = True
    for j in l:
        if j==None:
            continue
        else:
            cnt += j[0]
        if cnt>j[1]:
            print("No")
            flag = False
            break
    if flag:
        print("Yes")

Fixed submission:
N = int(input())
l = [None]*N
s = []
for i in range(N):
    k = list(map(int,input().split()))
    if k[0]==k[1]:
        s.append(k)
        l[i] = [0,0]
    else:
        l[i] = k

if len(s)>1:
    print("No")
else:
    l = sorted(l, key=lambda x: x[1])
    cnt = 0
    if len(s)==1:
        cnt += s[0][1]

    flag = True
    for j in l:
        if j==[0,0]:
            continue
        else:
            cnt += j[0]
        if cnt>j[1]:
            print("No")
            flag = False
            break
    if flag:
        print("Yes")
Buggy python submission (verdict: Runtime Error):
H,W = map(int,input().split(' '))
if not K==1:
    print(H-K)
else:
    print(0)

Fixed submission:
H,W = map(int,input().split(' '))
if not W==1:
    print(H-W)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
H,W = map(int,input().split(' '))
N = list(input())
N[W] = N[W].lower()
print("".join(N))

Fixed submission:
H,W = map(int,input().split(' '))
N = list(input())
N[W-1] = N[W-1].lower()
print("".join(N))
Buggy python submission (verdict: Runtime Error):
import math

N = int(input())
n = int(math.sqrt(N))
count=0
for i in range(1,n+1)
    d = N - i
    if d%i==0:
        k = int(d/i)
        count+=k
print(count)

Fixed submission:
import math

N = int(input())
n = int(math.sqrt(N))
count=0
for i in range(1,n+1):
    d = N - i
    if d%i==0 and i < (N // i) -1:
        k = d//i
        count+=k
print(count)

Buggy python submission (verdict: Runtime Error):
import math

N = int(input())
n = int(math.sqrt(N))
count=0
for i in range(1,n+1:
    d = N - i
    if d%i==0:
        k = int(d/i)
        count+=k
print(count)

Fixed submission:
import math

N = int(input())
n = int(math.sqrt(N))
count=0
for i in range(1,n+1):
    d = N - i
    if d%i==0 and i < (N // i) -1:
        k = d//i
        count+=k
print(count)
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
w=b=0
mn=0
for sk in s:
    if sk=="#":
        b+=1
    else:
        w-=1
    if mn>b+w:
        mn=b+w
print(mn-w)

Fixed submission:
a,b,c = map(int,input().split(' '))
if a<b:
    if c>a and c<b:
        print('Yes')
    else:
        print('No')
else:
    if c<a and c>b:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N =int(input())
l =[int(input()) for i in range(5)]
l = l[::-1]
s=[0 for i in range(5)]
s.append(N)
ans=0

while True:
    for i in range(5):
        if s[i+1]>=l[i]:
            s[i]+=l[i]
            s[i+1]-=l[i]
        else:
            s[i]+=s[i+1]
            s[i+1]=0
    ans+=1
    if s[0]==N:
        break
print(ans)


Fixed submission:
N =int(input())
l =[int(input()) for i in range(5)]
s=[N]
st=[0 for i in range(5)]
s.extend(st)
ans=0

min_num=min(l)
min_ind=l.index(min_num)

if N%min_num==0:
    times=int(N/min_num)
else:
    times=int(N/min_num)+1

dis=4
ans=times+dis

print(ans)
Buggy python submission (verdict: Runtime Error):
N,Q = map(int,input().split())
S = input()
c_l=[]
for i in range(Q):
    a,b = map(int,input().split())
    if b==N:
        l=S[a-1:]
    else:
        l=S[a-1:b]
    c = l.count("AC")
    c_l.append(c)
for i in c_l:
    print(i)


Fixed submission:
b = input()
if b=="A":
    print("T")
elif b=="T":
    print("A")
elif b=="G":
    print("C")
elif b=="C":
    print("G")

Buggy python submission (verdict: Runtime Error):
N,Q = map(int,input().split())
S = input()
count_l=[]
for i in range(Q):
    a,b = map(int,input().split())
    flag=False
    counting=0
    if b==N:
        l=S[a-1:]
    else:
        l=S[a-1:b]
    #print(l)
    counting = l.count("AC")
    """for ii in l:
        #print(ii)
        if ii=="A":
            flag=True
        elif ii=="C" and flag==True:
            counting+=1
            flag=False"""
    count_l.append(counting)
for i in count_l:
    print(i)


Fixed submission:
b = input()
if b=="A":
    print("T")
elif b=="T":
    print("A")
elif b=="G":
    print("C")
elif b=="C":
    print("G")
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int, input().split(" "))
A=["" for i in range(N)]
B=["" for i in range(N)]
for i in range(N):
    A[i],B[i] = map(int, input().split(" "))
total_num=0
total_mon=0
while True:
    min_a = min(A)
    ind = A.index(min_a)
    add = B[ind]
    total_num+=add
    if total_num>=M:
        add = add - (total_num-M)
        total_mon+=add*min_a
        break
    total_mon+=add*min_a
    A.pop(ind)
    B.pop(ind)
print(total_mon)


Fixed submission:
N,M = map(int, input().split(" "))
AB=["" for i in range(N)]
for i in range(N):
    A,B = map(int, input().split(" "))
    AB[i] = [A,B]
total_num=0
total_mon=0
AB = sorted(AB)
for i,t in enumerate(AB):
    add = t[1]
    total_num+=add
    if total_num>=M:
        add = add - (total_num-M)
        total_mon+=add*t[0]
        break
    total_mon+=add*t[0]
print(total_mon)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a*b%2==0:
  print("Even")
 else:
  print("Odd")


Fixed submission:
a, b = map(int, input().split())

if a*b%2==0:
  print("Even")
else:
  print("Odd")
Buggy python submission (verdict: Runtime Error):
a,b,c = map(str, input().split())
al = [a,b,c]
print(al.count("1"))
    

Fixed submission:
abc = input()
abc = str(abc)
print(abc.count("1"))

Buggy python submission (verdict: Runtime Error):
abc = map(int, input().split())
print(abc.count(1))
    

Fixed submission:
abc = input()
abc = str(abc)
print(abc.count("1"))
Buggy python submission (verdict: Time Limit Exceeded):
# E

import sys

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

a = list(map(int, input().split()))

s = sum(a)

for p in range(1,s+1) :
    if s % p != 0:
        continue
    b = s // p
    
    r1 = [x % b for x in a]
    r1.sort()
    s1 = sum(r1)
    
    mn = 1e9
    s2 = 0
    for i in range(n):
        s2 += r1[i]
        mn = min(max(s2, (n-1-i)*b - (s1-s2)), mn)
        
 
    if mn <= k :
        print(int(b))
        sys.exit(0)
        
    

Fixed submission:
# E

import sys

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

a = list(map(int, input().split()))

s = sum(a)

l = []

def check(b) :
    r1 = [x % b for x in a]
    r1.sort()
    s1 = sum(r1)
    
    mn = 1e9
    s2 = 0
    for i in range(n):
        s2 += r1[i]
        mn = min(max(s2, (n-1-i)*b - (s1-s2)), mn)
        
    if mn <= k :
        print(int(b))
        sys.exit(0)
        

for p in range(1,int((s+1)**0.5+1)) :
    if s % p != 0:
        continue
    b = s // p
    l.append(b)
    check(b)
    
l.reverse()

for p in l:
    b = s // p
    check(b)
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
N = int(input())
A = list(map(int,input().split()))
d = defaultdict(int)
for a in A:
    d[a-1] += 1
for i in range(N):
    print(d[i])


Fixed submission:
from math import pi
R = int(input())
print(2*R*pi)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
H,W,K = map(int,input().split())
S = np.array([list(map(int,input())) for _ in range(H)], dtype=np.int64)
ans = float("inf")
for i in range(2**(H-1)):
    kari = 0
    l = np.array([0]*H, dtype=np.int64)
    if H > 1:
        for j in range(0,H-1):
            if i >> j & 1:
                l[j+1] = l[j]+1
                kari += 1
            else:
                l[j+1] = l[j]
    num = np.array([0]*H, dtype=np.int64)

    for w in range(W):
        tmp = np.array([0]*H, dtype=np.int64)
        for h in range(H):
            if S[h,w]:
                tmp[l[h]] += 1

        if np.max(tmp) > K:
            break
        if np.max(num+tmp) <= K:
            num += tmp
        else:
            num = tmp
            kari += 1
    else:

        ans = min(ans,kari)
print(ans)


Fixed submission:

H,W,K = map(int,input().split())
S = [list(map(int,input())) for _ in range(H)]
ans = float("inf")
for i in range(2**(H-1)):
    kari = 0
    l = [0]*H
    if H > 1:
        for j in range(0,H-1):
            if i >> j & 1:
                l[j+1] = l[j]+1
                kari += 1
            else:
                l[j+1] = l[j]
    num = [0]*H

    for w in range(W):
        tmp = [0]*H
        for h in range(H):
            if S[h][w]:
                tmp[l[h]] += 1

        if max(tmp) > K:
            break

        if max([num[i]+tmp[i] for i in range(H)]) <= K:
            num = [num[i]+tmp[i] for i in range(H)]
            
            #num += tmp
        else:
            num = tmp
            kari += 1
    else:

        ans = min(ans,kari)
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
ans = 0
tmp = int(str(N)[1:-1])
NR = int(str(N)[-1])
for i in range(1,N+1):
    L = int(str(i)[0])
    R = int(str(i)[-1])
    if R == 0:
        continue
    if L == R:
        ans += 1
    for j in range(1,6):
        mini = (R*10**j) +L
        maxi = ((R+1)*10**j) +L-10
        if N < mini:
            break
        if maxi <= N:
            ans += 10**(j-1)
            continue
        
        if L <= NR:
            ans += tmp+1
        else:
            ans += tmp
        break
print(ans)


Fixed submission:
N = int(input())
ans = 0
tmp = int("0"+str(N)[1:-1])
NR = int(str(N)[-1])
for i in range(1,N+1):
    L = int(str(i)[0])
    R = int(str(i)[-1])
    if R == 0:
        continue
    if L == R:
        ans += 1
    for j in range(1,6):
        mini = (R*10**j) +L
        maxi = ((R+1)*10**j) +L-10
        if N < mini:
            break
        if maxi <= N:
            ans += 10**(j-1)
            continue
        
        if L <= NR:
            ans += tmp+1
        else:
            ans += tmp
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
M = 10**9+7

def nCr(n, r, mod=10**9+7):
    r = min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n+1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod

ans = 0
for i in range(K-1,N):
    t = nCr(i,K-1,M)
    ans += t*A[i]
A.sort(reverse=True)
for i in range(K-1,N):
    t = nCr(i,K-1,M)
    ans -= t*A[i]
print(ans%M)


Fixed submission:
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
M = 10**9+7

""" def nCr(n, r, mod=10**9+7):
    r = min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n+1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod """
def cmb(n, k, mod, fac, ifac):
    """
    nCkを計算する
    """
    k = min(k, n-k)
    return fac[n] * ifac[k] * ifac[n-k] % mod


def make_tables(mod, n):
    """
    階乗テーブル、逆元の階乗テーブルを作成する
    """
    fac = [1, 1] # 階乗テーブル・・・(1)
    ifac = [1, 1] #逆元の階乗テーブル・・・(2)
    inverse = [0, 1] #逆元テーブル・・・(3)

    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac

ans = 0
fac,ifac = make_tables(M,N)
for i in range(K-1,N):
    t = cmb(i,K-1,M,fac,ifac)
    ans += t*A[i]
A.sort(reverse=True)
for i in range(K-1,N):
    t = cmb(i,K-1,M,fac,ifac)
    ans -= t*A[i]
print(ans%M)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
M = 10**9+7

def nCr(n, r, mod=10**9+7):
    r = min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n+1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod

ans = 0
for i in range(K-1,N):
    t = nCr(i,K-1,M)
    ans += t*A[i]
A.sort(reverse=True)
for i in range(K-1,N):
    t = nCr(i,K-1,M)
    ans -= t*A[i]
print(ans%M)


Fixed submission:
N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
M = 10**9+7

""" def nCr(n, r, mod=10**9+7):
    r = min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n+1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod """
def cmb(n, k, mod, fac, ifac):
    """
    nCkを計算する
    """
    k = min(k, n-k)
    return fac[n] * ifac[k] * ifac[n-k] % mod


def make_tables(mod, n):
    """
    階乗テーブル、逆元の階乗テーブルを作成する
    """
    fac = [1, 1] # 階乗テーブル・・・(1)
    ifac = [1, 1] #逆元の階乗テーブル・・・(2)
    inverse = [0, 1] #逆元テーブル・・・(3)

    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac

ans = 0
fac,ifac = make_tables(M,N)
for i in range(K-1,N):
    t = cmb(i,K-1,M,fac,ifac)
    ans += t*A[i]
A.sort(reverse=True)
for i in range(K-1,N):
    t = cmb(i,K-1,M,fac,ifac)
    ans -= t*A[i]
print(ans%M)
Buggy python submission (verdict: Runtime Error):
S = input()
if S = "SUN":
    print(7)
if S = "MON":
    print(6)
if S = "TUE":
    print(5)
if S = "WED":
    print(4)
if S = "THU":
    print(3)
if S = "FRI":
    print(2)
if S = "SAT":
    print(1)


Fixed submission:
S = input()
if S == "SUN":
    print(7)
if S == "MON":
    print(6)
if S == "TUE":
    print(5)
if S == "WED":
    print(4)
if S == "THU":
    print(3)
if S == "FRI":
    print(2)
if S == "SAT":
    print(1)
Buggy python submission (verdict: Runtime Error):
import math
import numpy as np
import itertools
N = int(input())
x = []; y= []
for _ in range(N):
    x_,y_ = map(int,input().split())
    x.append(x_)
    y.append(y_)
lis = np.zeros((8,8))
for i in range(N):
    for j in range(N):
        lis[i,j] = math.sqrt((x[i]-x[j])**2 + (y[i]-y[j])**2)
num = 0
su = 0
ite = itertools.permutations([i for i in range(N)])
for it in ite:
    for i in range(len(it)-1):
        su += lis[it[i],it[i+1]]
    num += 1
print(su/num)


Fixed submission:
import math
import numpy as np
import itertools
N = int(input())
x = []; y= []
for _ in range(N):
    x_,y_ = map(int,input().split())
    x.append(x_)
    y.append(y_)
lis = np.zeros((8,8))
for i in range(N):
    for j in range(N):
        lis[i,j] = math.sqrt((x[i]-x[j])**2 + (y[i]-y[j])**2)
num = 0
su = 0
ite = itertools.permutations([i for i in range(N)])
for it in ite:
    for i in range(len(it)-1):
        su += lis[it[i],it[i+1]]
    num += 1
print(su/num)

Buggy python submission (verdict: Runtime Error):
import math
import numpy as np
from itertools import permutations
N = int(input())
x = []; y= []
for _ in range(N):
    x_,y_ = map(int,input().split())
    x.append(x_)
    y.append(y_)
lis = np.zeros((8,8))
for i in range(N):
    for j in range(N):
        lis[i,j] = math.sqrt((x[i]-x[j])**2 + (y[i]-y[j])**2)
num = 0
su = 0
ite = permutations([i for i in range(N)])
for it in ite:
    for i in range(len(it)-1):
        su += lis[it[i],it[i+1]]
    num += 1
print(su/num)

Fixed submission:
import math
import numpy as np
import itertools
N = int(input())
x = []; y= []
for _ in range(N):
    x_,y_ = map(int,input().split())
    x.append(x_)
    y.append(y_)
lis = np.zeros((8,8))
for i in range(N):
    for j in range(N):
        lis[i,j] = math.sqrt((x[i]-x[j])**2 + (y[i]-y[j])**2)
num = 0
su = 0
ite = itertools.permutations([i for i in range(N)])
for it in ite:
    for i in range(len(it)-1):
        su += lis[it[i],it[i+1]]
    num += 1
print(su/num)
Buggy python submission (verdict: Time Limit Exceeded):
import math
M = 10**9+7
X,Y = map(int,input().split())
if (X+Y)/3 != (X+Y)//3:
    print(0)
    exit()
n = (X+Y)//3
r = Y-n
if r<0 or r>n:
    print(0)
    exit()
#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

res = 1
for i in range(1,n+1):
    res = res*i%M
for i in range(1,r+1):
    res = res*mod_inv(i,M)%M
for i in range(1,n-r+1):
    res = res*mod_inv(i,M)%M
print(res)

Fixed submission:
import math
M = 10**9+7
X,Y = map(int,input().split())
if (X+Y)/3 != (X+Y)//3:
    print(0)
    exit()
n = (X+Y)//3
r = Y-n
if r<0 or r>n:
    print(0)
    exit()


#nCr and Mod
def nCr(n, r, mod=10**9+7):
    r = min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n+1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod

print(nCr(n,r,M))